@szum-tech/design-system 3.11.1 → 3.12.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/components/alert/index.d.cts +3 -3
- package/dist/components/alert/index.d.ts +3 -3
- package/dist/components/badge/index.d.cts +3 -3
- package/dist/components/badge/index.d.ts +3 -3
- package/dist/components/badge-overflow/index.cjs +182 -0
- package/dist/components/badge-overflow/index.d.cts +21 -0
- package/dist/components/badge-overflow/index.d.ts +21 -0
- package/dist/components/badge-overflow/index.js +160 -0
- package/dist/components/button/index.cjs +10 -10
- package/dist/components/button/index.d.cts +5 -5
- package/dist/components/button/index.d.ts +5 -5
- package/dist/components/button/index.js +10 -10
- package/dist/components/carousel/index.cjs +261 -0
- package/dist/components/carousel/index.d.cts +47 -0
- package/dist/components/carousel/index.d.ts +47 -0
- package/dist/components/carousel/index.js +230 -0
- package/dist/components/color-swatch/index.d.cts +3 -3
- package/dist/components/color-swatch/index.d.ts +3 -3
- package/dist/components/dialog/index.d.cts +3 -3
- package/dist/components/dialog/index.d.ts +3 -3
- package/dist/components/empty/index.d.cts +3 -3
- package/dist/components/empty/index.d.ts +3 -3
- package/dist/components/field/index.d.cts +4 -4
- package/dist/components/field/index.d.ts +4 -4
- package/dist/components/index.cjs +104 -104
- package/dist/components/index.js +10 -10
- package/dist/components/item/index.d.cts +7 -7
- package/dist/components/item/index.d.ts +7 -7
- package/dist/components/radio-group/index.d.cts +12 -1
- package/dist/components/radio-group/index.d.ts +12 -1
- package/dist/components/sheet/index.d.cts +3 -3
- package/dist/components/sheet/index.d.ts +3 -3
- package/dist/components/status/index.d.cts +3 -3
- package/dist/components/status/index.d.ts +3 -3
- package/dist/components/stepper/index.cjs +10 -10
- package/dist/components/stepper/index.d.cts +1 -1
- package/dist/components/stepper/index.d.ts +1 -1
- package/dist/components/stepper/index.js +10 -10
- package/dist/components/timeline/index.d.cts +1 -1
- package/dist/components/timeline/index.d.ts +1 -1
- package/dist/components/toaster/index.cjs +10 -10
- package/dist/components/toaster/index.js +10 -10
- package/package.json +19 -18
|
@@ -3,9 +3,9 @@ import * as React from 'react';
|
|
|
3
3
|
import { VariantProps } from 'class-variance-authority';
|
|
4
4
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
5
5
|
|
|
6
|
-
declare const alertVariants: (props?:
|
|
7
|
-
variant?: "default" | "destructive"
|
|
8
|
-
} & class_variance_authority_types.ClassProp)
|
|
6
|
+
declare const alertVariants: (props?: {
|
|
7
|
+
variant?: "default" | "destructive";
|
|
8
|
+
} & class_variance_authority_types.ClassProp) => string;
|
|
9
9
|
|
|
10
10
|
type AlertVariantsProps = VariantProps<typeof alertVariants>;
|
|
11
11
|
type AlertVariant = NonNullable<AlertVariantsProps["variant"]>;
|
|
@@ -3,9 +3,9 @@ import * as React from 'react';
|
|
|
3
3
|
import { VariantProps } from 'class-variance-authority';
|
|
4
4
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
5
5
|
|
|
6
|
-
declare const alertVariants: (props?:
|
|
7
|
-
variant?: "default" | "destructive"
|
|
8
|
-
} & class_variance_authority_types.ClassProp)
|
|
6
|
+
declare const alertVariants: (props?: {
|
|
7
|
+
variant?: "default" | "destructive";
|
|
8
|
+
} & class_variance_authority_types.ClassProp) => string;
|
|
9
9
|
|
|
10
10
|
type AlertVariantsProps = VariantProps<typeof alertVariants>;
|
|
11
11
|
type AlertVariant = NonNullable<AlertVariantsProps["variant"]>;
|
|
@@ -4,9 +4,9 @@ import React__default from 'react';
|
|
|
4
4
|
import { VariantProps } from 'class-variance-authority';
|
|
5
5
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
6
|
|
|
7
|
-
declare const badgeVariants: (props?:
|
|
8
|
-
variant?: "primary" | "secondary" | "outline" | "success" | "warning" | "error"
|
|
9
|
-
} & class_variance_authority_types.ClassProp)
|
|
7
|
+
declare const badgeVariants: (props?: {
|
|
8
|
+
variant?: "primary" | "secondary" | "outline" | "success" | "warning" | "error";
|
|
9
|
+
} & class_variance_authority_types.ClassProp) => string;
|
|
10
10
|
|
|
11
11
|
type BadgeVariantsProps = VariantProps<typeof badgeVariants>;
|
|
12
12
|
type BadgeVariant = NonNullable<BadgeVariantsProps["variant"]>;
|
|
@@ -4,9 +4,9 @@ import React__default from 'react';
|
|
|
4
4
|
import { VariantProps } from 'class-variance-authority';
|
|
5
5
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
6
|
|
|
7
|
-
declare const badgeVariants: (props?:
|
|
8
|
-
variant?: "primary" | "secondary" | "outline" | "success" | "warning" | "error"
|
|
9
|
-
} & class_variance_authority_types.ClassProp)
|
|
7
|
+
declare const badgeVariants: (props?: {
|
|
8
|
+
variant?: "primary" | "secondary" | "outline" | "success" | "warning" | "error";
|
|
9
|
+
} & class_variance_authority_types.ClassProp) => string;
|
|
10
10
|
|
|
11
11
|
type BadgeVariantsProps = VariantProps<typeof badgeVariants>;
|
|
12
12
|
type BadgeVariant = NonNullable<BadgeVariantsProps["variant"]>;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkXIQUR62A_cjs = require('../../chunk-XIQUR62A.cjs');
|
|
4
|
+
var chunkH2BWO3SI_cjs = require('../../chunk-H2BWO3SI.cjs');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var radixUi = require('radix-ui');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
|
+
|
|
29
|
+
function BadgeOverflow(props) {
|
|
30
|
+
const {
|
|
31
|
+
items,
|
|
32
|
+
getBadgeLabel: getBadgeLabelProp,
|
|
33
|
+
lineCount = 1,
|
|
34
|
+
renderBadge,
|
|
35
|
+
renderOverflow,
|
|
36
|
+
asChild,
|
|
37
|
+
className,
|
|
38
|
+
style,
|
|
39
|
+
ref,
|
|
40
|
+
...rootProps
|
|
41
|
+
} = props;
|
|
42
|
+
const getBadgeLabel = React__namespace.useCallback(
|
|
43
|
+
(item) => {
|
|
44
|
+
if (typeof item === "object" && !getBadgeLabelProp) {
|
|
45
|
+
throw new Error("`getBadgeLabel` is required when using array of objects");
|
|
46
|
+
}
|
|
47
|
+
return getBadgeLabelProp ? getBadgeLabelProp(item) : item;
|
|
48
|
+
},
|
|
49
|
+
[getBadgeLabelProp]
|
|
50
|
+
);
|
|
51
|
+
const rootRef = React__namespace.useRef(null);
|
|
52
|
+
const composedRef = chunkXIQUR62A_cjs.useComposedRefs(ref, rootRef);
|
|
53
|
+
const measureRef = React__namespace.useRef(null);
|
|
54
|
+
const [containerWidth, setContainerWidth] = React__namespace.useState(0);
|
|
55
|
+
const [badgeGap, setBadgeGap] = React__namespace.useState(4);
|
|
56
|
+
const [badgeHeight, setBadgeHeight] = React__namespace.useState(20);
|
|
57
|
+
const [overflowBadgeWidth, setOverflowBadgeWidth] = React__namespace.useState(40);
|
|
58
|
+
const [isMeasured, setIsMeasured] = React__namespace.useState(false);
|
|
59
|
+
const [badgeWidths, setBadgeWidths] = React__namespace.useState(/* @__PURE__ */ new Map());
|
|
60
|
+
React__namespace.useLayoutEffect(() => {
|
|
61
|
+
if (!rootRef.current || !measureRef.current) return;
|
|
62
|
+
function measureContainer() {
|
|
63
|
+
if (!rootRef.current || !measureRef.current) return;
|
|
64
|
+
const computedStyle = getComputedStyle(rootRef.current);
|
|
65
|
+
const gapValue = computedStyle.gap;
|
|
66
|
+
const gap = gapValue ? parseFloat(gapValue) : 4;
|
|
67
|
+
setBadgeGap(gap);
|
|
68
|
+
const paddingLeft = parseFloat(computedStyle.paddingLeft) || 0;
|
|
69
|
+
const paddingRight = parseFloat(computedStyle.paddingRight) || 0;
|
|
70
|
+
const totalPadding = paddingLeft + paddingRight;
|
|
71
|
+
const widthMap = /* @__PURE__ */ new Map();
|
|
72
|
+
const measureChildren = measureRef.current.children;
|
|
73
|
+
for (let i = 0; i < items.length; i++) {
|
|
74
|
+
const child = measureChildren[i];
|
|
75
|
+
if (child) {
|
|
76
|
+
const label = getBadgeLabel(items[i]);
|
|
77
|
+
widthMap.set(label, child.offsetWidth);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
setBadgeWidths(widthMap);
|
|
81
|
+
const firstBadge = measureChildren[0];
|
|
82
|
+
if (firstBadge) {
|
|
83
|
+
setBadgeHeight(firstBadge.offsetHeight || 20);
|
|
84
|
+
}
|
|
85
|
+
const overflowChild = measureChildren[items.length];
|
|
86
|
+
if (overflowChild) {
|
|
87
|
+
setOverflowBadgeWidth(overflowChild.offsetWidth || 40);
|
|
88
|
+
}
|
|
89
|
+
const width = rootRef.current.clientWidth - totalPadding;
|
|
90
|
+
setContainerWidth(width);
|
|
91
|
+
setIsMeasured(true);
|
|
92
|
+
}
|
|
93
|
+
measureContainer();
|
|
94
|
+
const resizeObserver = new ResizeObserver(measureContainer);
|
|
95
|
+
resizeObserver.observe(rootRef.current);
|
|
96
|
+
return () => {
|
|
97
|
+
resizeObserver.disconnect();
|
|
98
|
+
};
|
|
99
|
+
}, [items, getBadgeLabel]);
|
|
100
|
+
const placeholderHeight = React__namespace.useMemo(
|
|
101
|
+
() => badgeHeight * lineCount + badgeGap * (lineCount - 1),
|
|
102
|
+
[badgeHeight, badgeGap, lineCount]
|
|
103
|
+
);
|
|
104
|
+
const { visibleItems, hiddenCount } = React__namespace.useMemo(() => {
|
|
105
|
+
if (!containerWidth || items.length === 0 || badgeWidths.size === 0) {
|
|
106
|
+
return { visibleItems: items, hiddenCount: 0 };
|
|
107
|
+
}
|
|
108
|
+
let currentLineWidth = 0;
|
|
109
|
+
let currentLine = 1;
|
|
110
|
+
const visible = [];
|
|
111
|
+
for (let i = 0; i < items.length; i++) {
|
|
112
|
+
const item = items[i];
|
|
113
|
+
if (!item) continue;
|
|
114
|
+
const label = getBadgeLabel(item);
|
|
115
|
+
const badgeWidth = badgeWidths.get(label);
|
|
116
|
+
if (!badgeWidth) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const widthWithGap = badgeWidth + badgeGap;
|
|
120
|
+
const isLastLine = currentLine === lineCount;
|
|
121
|
+
const hasMoreItems = i < items.length - 1;
|
|
122
|
+
const availableWidth = isLastLine && hasMoreItems ? containerWidth - overflowBadgeWidth - badgeGap : containerWidth;
|
|
123
|
+
if (currentLineWidth + widthWithGap <= availableWidth) {
|
|
124
|
+
currentLineWidth += widthWithGap;
|
|
125
|
+
visible.push(item);
|
|
126
|
+
} else if (currentLine < lineCount) {
|
|
127
|
+
currentLine++;
|
|
128
|
+
currentLineWidth = widthWithGap;
|
|
129
|
+
visible.push(item);
|
|
130
|
+
} else {
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
visibleItems: visible,
|
|
136
|
+
hiddenCount: Math.max(0, items.length - visible.length)
|
|
137
|
+
};
|
|
138
|
+
}, [items, getBadgeLabel, containerWidth, lineCount, badgeGap, overflowBadgeWidth, badgeWidths]);
|
|
139
|
+
const Component = asChild ? radixUi.Slot.Slot : "div";
|
|
140
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
|
|
141
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { ref: measureRef, className: "pointer-events-none invisible absolute flex flex-wrap", style: { gap: badgeGap }, children: [
|
|
142
|
+
items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(React__namespace.Fragment, { children: renderBadge(item, getBadgeLabel(item)) }, index)),
|
|
143
|
+
renderOverflow ? renderOverflow(99) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-flex h-5 shrink-0 items-center rounded-md border px-1.5 text-xs font-semibold", children: "+99" })
|
|
144
|
+
] }),
|
|
145
|
+
isMeasured ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
146
|
+
Component,
|
|
147
|
+
{
|
|
148
|
+
"data-slot": "badge-overflow",
|
|
149
|
+
...rootProps,
|
|
150
|
+
ref: composedRef,
|
|
151
|
+
className: chunkH2BWO3SI_cjs.cn("flex flex-wrap", className),
|
|
152
|
+
style: {
|
|
153
|
+
gap: badgeGap,
|
|
154
|
+
...style
|
|
155
|
+
},
|
|
156
|
+
children: [
|
|
157
|
+
visibleItems.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(React__namespace.Fragment, { children: renderBadge(item, getBadgeLabel(item)) }, index)),
|
|
158
|
+
hiddenCount > 0 && (renderOverflow ? renderOverflow(hiddenCount) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "inline-flex h-5 shrink-0 items-center rounded-md border px-1.5 text-xs font-semibold", children: [
|
|
159
|
+
"+",
|
|
160
|
+
hiddenCount
|
|
161
|
+
] }))
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
165
|
+
Component,
|
|
166
|
+
{
|
|
167
|
+
"data-slot": "badge-overflow",
|
|
168
|
+
...rootProps,
|
|
169
|
+
ref: composedRef,
|
|
170
|
+
className: chunkH2BWO3SI_cjs.cn("flex flex-wrap", className),
|
|
171
|
+
style: {
|
|
172
|
+
gap: badgeGap,
|
|
173
|
+
minHeight: placeholderHeight,
|
|
174
|
+
...style
|
|
175
|
+
},
|
|
176
|
+
children: items.slice(0, Math.min(items.length, lineCount * 3 - (lineCount > 1 ? 1 : 0))).map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(React__namespace.Fragment, { children: renderBadge(item, getBadgeLabel(item)) }, index))
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
] });
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
exports.BadgeOverflow = BadgeOverflow;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
interface GetBadgeLabel<T> {
|
|
5
|
+
/**
|
|
6
|
+
* Callback that returns a label string for each badge item.
|
|
7
|
+
* Optional for primitive arrays (strings, numbers), required for object arrays.
|
|
8
|
+
* @example getBadgeLabel={(item) => item.name}
|
|
9
|
+
*/
|
|
10
|
+
getBadgeLabel: (item: T) => string;
|
|
11
|
+
}
|
|
12
|
+
type BadgeOverflowProps<T = string> = React.ComponentProps<"div"> & (T extends object ? GetBadgeLabel<T> : Partial<GetBadgeLabel<T>>) & {
|
|
13
|
+
items: T[];
|
|
14
|
+
lineCount?: number;
|
|
15
|
+
renderBadge: (item: T, label: string) => React.ReactNode;
|
|
16
|
+
renderOverflow?: (count: number) => React.ReactNode;
|
|
17
|
+
asChild?: boolean;
|
|
18
|
+
};
|
|
19
|
+
declare function BadgeOverflow<T = string>(props: BadgeOverflowProps<T>): react_jsx_runtime.JSX.Element;
|
|
20
|
+
|
|
21
|
+
export { BadgeOverflow, type BadgeOverflowProps };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
interface GetBadgeLabel<T> {
|
|
5
|
+
/**
|
|
6
|
+
* Callback that returns a label string for each badge item.
|
|
7
|
+
* Optional for primitive arrays (strings, numbers), required for object arrays.
|
|
8
|
+
* @example getBadgeLabel={(item) => item.name}
|
|
9
|
+
*/
|
|
10
|
+
getBadgeLabel: (item: T) => string;
|
|
11
|
+
}
|
|
12
|
+
type BadgeOverflowProps<T = string> = React.ComponentProps<"div"> & (T extends object ? GetBadgeLabel<T> : Partial<GetBadgeLabel<T>>) & {
|
|
13
|
+
items: T[];
|
|
14
|
+
lineCount?: number;
|
|
15
|
+
renderBadge: (item: T, label: string) => React.ReactNode;
|
|
16
|
+
renderOverflow?: (count: number) => React.ReactNode;
|
|
17
|
+
asChild?: boolean;
|
|
18
|
+
};
|
|
19
|
+
declare function BadgeOverflow<T = string>(props: BadgeOverflowProps<T>): react_jsx_runtime.JSX.Element;
|
|
20
|
+
|
|
21
|
+
export { BadgeOverflow, type BadgeOverflowProps };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { useComposedRefs } from '../../chunk-SB5UG7OC.js';
|
|
2
|
+
import { cn } from '../../chunk-ZD2QRAOX.js';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Slot } from 'radix-ui';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
function BadgeOverflow(props) {
|
|
8
|
+
const {
|
|
9
|
+
items,
|
|
10
|
+
getBadgeLabel: getBadgeLabelProp,
|
|
11
|
+
lineCount = 1,
|
|
12
|
+
renderBadge,
|
|
13
|
+
renderOverflow,
|
|
14
|
+
asChild,
|
|
15
|
+
className,
|
|
16
|
+
style,
|
|
17
|
+
ref,
|
|
18
|
+
...rootProps
|
|
19
|
+
} = props;
|
|
20
|
+
const getBadgeLabel = React.useCallback(
|
|
21
|
+
(item) => {
|
|
22
|
+
if (typeof item === "object" && !getBadgeLabelProp) {
|
|
23
|
+
throw new Error("`getBadgeLabel` is required when using array of objects");
|
|
24
|
+
}
|
|
25
|
+
return getBadgeLabelProp ? getBadgeLabelProp(item) : item;
|
|
26
|
+
},
|
|
27
|
+
[getBadgeLabelProp]
|
|
28
|
+
);
|
|
29
|
+
const rootRef = React.useRef(null);
|
|
30
|
+
const composedRef = useComposedRefs(ref, rootRef);
|
|
31
|
+
const measureRef = React.useRef(null);
|
|
32
|
+
const [containerWidth, setContainerWidth] = React.useState(0);
|
|
33
|
+
const [badgeGap, setBadgeGap] = React.useState(4);
|
|
34
|
+
const [badgeHeight, setBadgeHeight] = React.useState(20);
|
|
35
|
+
const [overflowBadgeWidth, setOverflowBadgeWidth] = React.useState(40);
|
|
36
|
+
const [isMeasured, setIsMeasured] = React.useState(false);
|
|
37
|
+
const [badgeWidths, setBadgeWidths] = React.useState(/* @__PURE__ */ new Map());
|
|
38
|
+
React.useLayoutEffect(() => {
|
|
39
|
+
if (!rootRef.current || !measureRef.current) return;
|
|
40
|
+
function measureContainer() {
|
|
41
|
+
if (!rootRef.current || !measureRef.current) return;
|
|
42
|
+
const computedStyle = getComputedStyle(rootRef.current);
|
|
43
|
+
const gapValue = computedStyle.gap;
|
|
44
|
+
const gap = gapValue ? parseFloat(gapValue) : 4;
|
|
45
|
+
setBadgeGap(gap);
|
|
46
|
+
const paddingLeft = parseFloat(computedStyle.paddingLeft) || 0;
|
|
47
|
+
const paddingRight = parseFloat(computedStyle.paddingRight) || 0;
|
|
48
|
+
const totalPadding = paddingLeft + paddingRight;
|
|
49
|
+
const widthMap = /* @__PURE__ */ new Map();
|
|
50
|
+
const measureChildren = measureRef.current.children;
|
|
51
|
+
for (let i = 0; i < items.length; i++) {
|
|
52
|
+
const child = measureChildren[i];
|
|
53
|
+
if (child) {
|
|
54
|
+
const label = getBadgeLabel(items[i]);
|
|
55
|
+
widthMap.set(label, child.offsetWidth);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
setBadgeWidths(widthMap);
|
|
59
|
+
const firstBadge = measureChildren[0];
|
|
60
|
+
if (firstBadge) {
|
|
61
|
+
setBadgeHeight(firstBadge.offsetHeight || 20);
|
|
62
|
+
}
|
|
63
|
+
const overflowChild = measureChildren[items.length];
|
|
64
|
+
if (overflowChild) {
|
|
65
|
+
setOverflowBadgeWidth(overflowChild.offsetWidth || 40);
|
|
66
|
+
}
|
|
67
|
+
const width = rootRef.current.clientWidth - totalPadding;
|
|
68
|
+
setContainerWidth(width);
|
|
69
|
+
setIsMeasured(true);
|
|
70
|
+
}
|
|
71
|
+
measureContainer();
|
|
72
|
+
const resizeObserver = new ResizeObserver(measureContainer);
|
|
73
|
+
resizeObserver.observe(rootRef.current);
|
|
74
|
+
return () => {
|
|
75
|
+
resizeObserver.disconnect();
|
|
76
|
+
};
|
|
77
|
+
}, [items, getBadgeLabel]);
|
|
78
|
+
const placeholderHeight = React.useMemo(
|
|
79
|
+
() => badgeHeight * lineCount + badgeGap * (lineCount - 1),
|
|
80
|
+
[badgeHeight, badgeGap, lineCount]
|
|
81
|
+
);
|
|
82
|
+
const { visibleItems, hiddenCount } = React.useMemo(() => {
|
|
83
|
+
if (!containerWidth || items.length === 0 || badgeWidths.size === 0) {
|
|
84
|
+
return { visibleItems: items, hiddenCount: 0 };
|
|
85
|
+
}
|
|
86
|
+
let currentLineWidth = 0;
|
|
87
|
+
let currentLine = 1;
|
|
88
|
+
const visible = [];
|
|
89
|
+
for (let i = 0; i < items.length; i++) {
|
|
90
|
+
const item = items[i];
|
|
91
|
+
if (!item) continue;
|
|
92
|
+
const label = getBadgeLabel(item);
|
|
93
|
+
const badgeWidth = badgeWidths.get(label);
|
|
94
|
+
if (!badgeWidth) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const widthWithGap = badgeWidth + badgeGap;
|
|
98
|
+
const isLastLine = currentLine === lineCount;
|
|
99
|
+
const hasMoreItems = i < items.length - 1;
|
|
100
|
+
const availableWidth = isLastLine && hasMoreItems ? containerWidth - overflowBadgeWidth - badgeGap : containerWidth;
|
|
101
|
+
if (currentLineWidth + widthWithGap <= availableWidth) {
|
|
102
|
+
currentLineWidth += widthWithGap;
|
|
103
|
+
visible.push(item);
|
|
104
|
+
} else if (currentLine < lineCount) {
|
|
105
|
+
currentLine++;
|
|
106
|
+
currentLineWidth = widthWithGap;
|
|
107
|
+
visible.push(item);
|
|
108
|
+
} else {
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
visibleItems: visible,
|
|
114
|
+
hiddenCount: Math.max(0, items.length - visible.length)
|
|
115
|
+
};
|
|
116
|
+
}, [items, getBadgeLabel, containerWidth, lineCount, badgeGap, overflowBadgeWidth, badgeWidths]);
|
|
117
|
+
const Component = asChild ? Slot.Slot : "div";
|
|
118
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
119
|
+
/* @__PURE__ */ jsxs("div", { ref: measureRef, className: "pointer-events-none invisible absolute flex flex-wrap", style: { gap: badgeGap }, children: [
|
|
120
|
+
items.map((item, index) => /* @__PURE__ */ jsx(React.Fragment, { children: renderBadge(item, getBadgeLabel(item)) }, index)),
|
|
121
|
+
renderOverflow ? renderOverflow(99) : /* @__PURE__ */ jsx("div", { className: "inline-flex h-5 shrink-0 items-center rounded-md border px-1.5 text-xs font-semibold", children: "+99" })
|
|
122
|
+
] }),
|
|
123
|
+
isMeasured ? /* @__PURE__ */ jsxs(
|
|
124
|
+
Component,
|
|
125
|
+
{
|
|
126
|
+
"data-slot": "badge-overflow",
|
|
127
|
+
...rootProps,
|
|
128
|
+
ref: composedRef,
|
|
129
|
+
className: cn("flex flex-wrap", className),
|
|
130
|
+
style: {
|
|
131
|
+
gap: badgeGap,
|
|
132
|
+
...style
|
|
133
|
+
},
|
|
134
|
+
children: [
|
|
135
|
+
visibleItems.map((item, index) => /* @__PURE__ */ jsx(React.Fragment, { children: renderBadge(item, getBadgeLabel(item)) }, index)),
|
|
136
|
+
hiddenCount > 0 && (renderOverflow ? renderOverflow(hiddenCount) : /* @__PURE__ */ jsxs("div", { className: "inline-flex h-5 shrink-0 items-center rounded-md border px-1.5 text-xs font-semibold", children: [
|
|
137
|
+
"+",
|
|
138
|
+
hiddenCount
|
|
139
|
+
] }))
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
) : /* @__PURE__ */ jsx(
|
|
143
|
+
Component,
|
|
144
|
+
{
|
|
145
|
+
"data-slot": "badge-overflow",
|
|
146
|
+
...rootProps,
|
|
147
|
+
ref: composedRef,
|
|
148
|
+
className: cn("flex flex-wrap", className),
|
|
149
|
+
style: {
|
|
150
|
+
gap: badgeGap,
|
|
151
|
+
minHeight: placeholderHeight,
|
|
152
|
+
...style
|
|
153
|
+
},
|
|
154
|
+
children: items.slice(0, Math.min(items.length, lineCount * 3 - (lineCount > 1 ? 1 : 0))).map((item, index) => /* @__PURE__ */ jsx(React.Fragment, { children: renderBadge(item, getBadgeLabel(item)) }, index))
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
] });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export { BadgeOverflow };
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkCP43WJCN_cjs = require('../../chunk-CP43WJCN.cjs');
|
|
4
|
+
require('../../chunk-DGWBE2Y3.cjs');
|
|
5
|
+
require('../../chunk-GYXQUTWZ.cjs');
|
|
6
|
+
require('../../chunk-YEFLGE3L.cjs');
|
|
4
7
|
require('../../chunk-NU5UQPBX.cjs');
|
|
5
|
-
require('../../chunk-UJX74PFK.cjs');
|
|
6
8
|
require('../../chunk-KQ6QE7BT.cjs');
|
|
7
|
-
require('../../chunk-A7SBXO2Y.cjs');
|
|
8
|
-
require('../../chunk-DGWBE2Y3.cjs');
|
|
9
9
|
require('../../chunk-EUH466AL.cjs');
|
|
10
|
+
require('../../chunk-A7SBXO2Y.cjs');
|
|
11
|
+
require('../../chunk-S2BCU6WG.cjs');
|
|
12
|
+
require('../../chunk-TH44JYXB.cjs');
|
|
10
13
|
require('../../chunk-XENOUBSI.cjs');
|
|
14
|
+
require('../../chunk-UJX74PFK.cjs');
|
|
11
15
|
require('../../chunk-XJZOANXX.cjs');
|
|
12
|
-
require('../../chunk-GHV2TURY.cjs');
|
|
13
16
|
require('../../chunk-3WSQRFUY.cjs');
|
|
14
|
-
require('../../chunk-
|
|
15
|
-
require('../../chunk-
|
|
17
|
+
require('../../chunk-GHV2TURY.cjs');
|
|
18
|
+
require('../../chunk-VK5EX3OG.cjs');
|
|
19
|
+
require('../../chunk-CXHDWIGF.cjs');
|
|
16
20
|
require('../../chunk-DTYX7CYN.cjs');
|
|
17
21
|
require('../../chunk-6X26XC6P.cjs');
|
|
18
22
|
require('../../chunk-5AA4IE2T.cjs');
|
|
@@ -20,15 +24,11 @@ require('../../chunk-CFJ44JVK.cjs');
|
|
|
20
24
|
require('../../chunk-UIOBJSKZ.cjs');
|
|
21
25
|
require('../../chunk-S3ANEJJ7.cjs');
|
|
22
26
|
require('../../chunk-2WQJ36RD.cjs');
|
|
23
|
-
require('../../chunk-S2BCU6WG.cjs');
|
|
24
|
-
require('../../chunk-TH44JYXB.cjs');
|
|
25
27
|
require('../../chunk-ZVF7J4EI.cjs');
|
|
26
28
|
require('../../chunk-2Y2ZCPNV.cjs');
|
|
27
29
|
require('../../chunk-HCHVDUI6.cjs');
|
|
28
30
|
require('../../chunk-ULEEQ723.cjs');
|
|
29
31
|
require('../../chunk-USIW3VT5.cjs');
|
|
30
|
-
require('../../chunk-VK5EX3OG.cjs');
|
|
31
|
-
require('../../chunk-CXHDWIGF.cjs');
|
|
32
32
|
require('../../chunk-XIQUR62A.cjs');
|
|
33
33
|
require('../../chunk-X3ZT3KGX.cjs');
|
|
34
34
|
require('../../chunk-3GNVQFCK.cjs');
|
|
@@ -44,11 +44,11 @@ type ButtonProps = React.ComponentProps<"button"> & {
|
|
|
44
44
|
};
|
|
45
45
|
declare function Button({ asChild, variant, disabled, fullWidth, loadingPosition: loadingPositionProp, children, type, loading, size, endIcon, startIcon, className, ...props }: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
46
46
|
|
|
47
|
-
declare const buttonVariants: (props?:
|
|
48
|
-
variant?: "link" | "secondary" | "outline" | "error" | "default" | "ghost"
|
|
49
|
-
size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg"
|
|
50
|
-
fullWidth?: boolean
|
|
51
|
-
} & class_variance_authority_types.ClassProp)
|
|
47
|
+
declare const buttonVariants: (props?: {
|
|
48
|
+
variant?: "link" | "secondary" | "outline" | "error" | "default" | "ghost";
|
|
49
|
+
size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg";
|
|
50
|
+
fullWidth?: boolean;
|
|
51
|
+
} & class_variance_authority_types.ClassProp) => string;
|
|
52
52
|
|
|
53
53
|
type ButtonCvaProps = VariantProps<typeof buttonVariants>;
|
|
54
54
|
type ButtonSizeType = NonNullable<ButtonCvaProps["size"]>;
|
|
@@ -44,11 +44,11 @@ type ButtonProps = React.ComponentProps<"button"> & {
|
|
|
44
44
|
};
|
|
45
45
|
declare function Button({ asChild, variant, disabled, fullWidth, loadingPosition: loadingPositionProp, children, type, loading, size, endIcon, startIcon, className, ...props }: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
46
46
|
|
|
47
|
-
declare const buttonVariants: (props?:
|
|
48
|
-
variant?: "link" | "secondary" | "outline" | "error" | "default" | "ghost"
|
|
49
|
-
size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg"
|
|
50
|
-
fullWidth?: boolean
|
|
51
|
-
} & class_variance_authority_types.ClassProp)
|
|
47
|
+
declare const buttonVariants: (props?: {
|
|
48
|
+
variant?: "link" | "secondary" | "outline" | "error" | "default" | "ghost";
|
|
49
|
+
size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg";
|
|
50
|
+
fullWidth?: boolean;
|
|
51
|
+
} & class_variance_authority_types.ClassProp) => string;
|
|
52
52
|
|
|
53
53
|
type ButtonCvaProps = VariantProps<typeof buttonVariants>;
|
|
54
54
|
type ButtonSizeType = NonNullable<ButtonCvaProps["size"]>;
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
export { Button } from '../../chunk-QTYNFISP.js';
|
|
2
|
+
import '../../chunk-K5AURCK5.js';
|
|
3
|
+
import '../../chunk-IWF52DDE.js';
|
|
4
|
+
import '../../chunk-OCOCENE6.js';
|
|
2
5
|
import '../../chunk-OQCNPNPS.js';
|
|
3
|
-
import '../../chunk-M7NIRB3U.js';
|
|
4
6
|
import '../../chunk-WXZE35FK.js';
|
|
5
|
-
import '../../chunk-U7XZJQ4O.js';
|
|
6
|
-
import '../../chunk-K5AURCK5.js';
|
|
7
7
|
import '../../chunk-WMGJCB7O.js';
|
|
8
|
+
import '../../chunk-U7XZJQ4O.js';
|
|
9
|
+
import '../../chunk-DL54DIMD.js';
|
|
10
|
+
import '../../chunk-PBEZZMAB.js';
|
|
8
11
|
import '../../chunk-4TRADSTP.js';
|
|
12
|
+
import '../../chunk-M7NIRB3U.js';
|
|
9
13
|
import '../../chunk-E5TYGWGE.js';
|
|
10
|
-
import '../../chunk-DTSFPOLX.js';
|
|
11
14
|
import '../../chunk-P5IUC7HJ.js';
|
|
12
|
-
import '../../chunk-
|
|
13
|
-
import '../../chunk-
|
|
15
|
+
import '../../chunk-DTSFPOLX.js';
|
|
16
|
+
import '../../chunk-BTSHACKG.js';
|
|
17
|
+
import '../../chunk-HNRVLRMN.js';
|
|
14
18
|
import '../../chunk-3MH6P44N.js';
|
|
15
19
|
import '../../chunk-VT5GDGZJ.js';
|
|
16
20
|
import '../../chunk-UGSNASZM.js';
|
|
@@ -18,15 +22,11 @@ import '../../chunk-KGGCA634.js';
|
|
|
18
22
|
import '../../chunk-XJIUGEPN.js';
|
|
19
23
|
import '../../chunk-I3RSTJP6.js';
|
|
20
24
|
import '../../chunk-YUMKV5TH.js';
|
|
21
|
-
import '../../chunk-DL54DIMD.js';
|
|
22
|
-
import '../../chunk-PBEZZMAB.js';
|
|
23
25
|
import '../../chunk-U3QKV7I4.js';
|
|
24
26
|
import '../../chunk-6BSR3O2J.js';
|
|
25
27
|
import '../../chunk-5F2Y65JH.js';
|
|
26
28
|
import '../../chunk-3RK5PCIC.js';
|
|
27
29
|
import '../../chunk-P4JIMFSL.js';
|
|
28
|
-
import '../../chunk-BTSHACKG.js';
|
|
29
|
-
import '../../chunk-HNRVLRMN.js';
|
|
30
30
|
import '../../chunk-SB5UG7OC.js';
|
|
31
31
|
import '../../chunk-B7RHEMZH.js';
|
|
32
32
|
import '../../chunk-5MV54MWS.js';
|