reusify-ui 2.1.0 → 2.2.0
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/README.md +25 -6
- package/dist/reusify-ui.cjs +760 -8
- package/dist/reusify-ui.js +760 -8
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/reusify-ui.cjs
CHANGED
|
@@ -12,7 +12,7 @@ const legacyVariants = {
|
|
|
12
12
|
danger: ["solid", "danger"],
|
|
13
13
|
success: ["solid", "success"]
|
|
14
14
|
};
|
|
15
|
-
const semanticColors$
|
|
15
|
+
const semanticColors$5 = /* @__PURE__ */ new Set(["primary", "secondary", "success", "danger", "warning", "info"]);
|
|
16
16
|
const radii = { none: "0", sm: "6px", md: "10px", lg: "14px", xl: "18px", "2xl": "24px", full: "9999px" };
|
|
17
17
|
function resolveRadius(radius) {
|
|
18
18
|
if (radius === void 0) return void 0;
|
|
@@ -50,7 +50,7 @@ const Button = react.forwardRef(function Button2({
|
|
|
50
50
|
onPointerMove == null ? void 0 : onPointerMove(e);
|
|
51
51
|
} : onPointerMove;
|
|
52
52
|
const resolvedColor = color ?? legacyColor ?? "primary";
|
|
53
|
-
const customColor = !semanticColors$
|
|
53
|
+
const customColor = !semanticColors$5.has(resolvedColor);
|
|
54
54
|
const classes = cn(
|
|
55
55
|
"ru-btn",
|
|
56
56
|
`ru-btn--${kind}`,
|
|
@@ -145,6 +145,16 @@ const UserIcon = (p) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { ...base, ...p,
|
|
|
145
145
|
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "8", r: "4" }),
|
|
146
146
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4 21a8 8 0 0 1 16 0" })
|
|
147
147
|
] });
|
|
148
|
+
const UploadCloudIcon = (p) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { ...base, ...p, children: [
|
|
149
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4 14.9A7 7 0 1 1 15.7 8h1.8a4.5 4.5 0 0 1 2.5 8.2" }),
|
|
150
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 12v9M16 16l-4-4-4 4" })
|
|
151
|
+
] });
|
|
152
|
+
const FileIcon = (p) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { ...base, ...p, children: [
|
|
153
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" }),
|
|
154
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M14 2v4a2 2 0 0 0 2 2h4" })
|
|
155
|
+
] });
|
|
156
|
+
const TrendUpIcon = (p) => /* @__PURE__ */ jsxRuntime.jsx("svg", { ...base, ...p, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 19V5M5 12l7-7 7 7" }) });
|
|
157
|
+
const TrendDownIcon = (p) => /* @__PURE__ */ jsxRuntime.jsx("svg", { ...base, ...p, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 5v14M19 12l-7 7-7-7" }) });
|
|
148
158
|
const statusIcons = {
|
|
149
159
|
info: InfoIcon,
|
|
150
160
|
success: SuccessIcon,
|
|
@@ -160,11 +170,17 @@ function Spinner({ size = "md", color = "primary", label = "Loading", className,
|
|
|
160
170
|
label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-sr-only", children: label })
|
|
161
171
|
] });
|
|
162
172
|
}
|
|
173
|
+
const progressColors = /* @__PURE__ */ new Set(["primary", "secondary", "success", "danger", "warning", "info"]);
|
|
163
174
|
function Progress({
|
|
164
175
|
value,
|
|
165
176
|
max = 100,
|
|
166
177
|
size = "md",
|
|
167
178
|
color = "primary",
|
|
179
|
+
variant = "bar",
|
|
180
|
+
ticks = 24,
|
|
181
|
+
glow = false,
|
|
182
|
+
icon,
|
|
183
|
+
endLabel,
|
|
168
184
|
label,
|
|
169
185
|
showValue = false,
|
|
170
186
|
className,
|
|
@@ -172,7 +188,86 @@ function Progress({
|
|
|
172
188
|
}) {
|
|
173
189
|
const indeterminate = value === void 0;
|
|
174
190
|
const percent = indeterminate ? 0 : Math.min(100, Math.max(0, value / max * 100));
|
|
175
|
-
|
|
191
|
+
const semantic = progressColors.has(color);
|
|
192
|
+
const glowColor = glow === true ? semantic ? `var(--ru-${color})` : color : glow || void 0;
|
|
193
|
+
const meterStyle = { ...!semantic && { "--_c": color }, ...glowColor && { "--_glow": glowColor } };
|
|
194
|
+
if (variant === "capsule") {
|
|
195
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("ru-progress", "ru-progress--capsule", `ru-progress--${size}`, glowColor && "ru-progress--glow", className), ...rest, children: [
|
|
196
|
+
label && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ru-progress__label", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: label }) }),
|
|
197
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
198
|
+
"div",
|
|
199
|
+
{
|
|
200
|
+
role: "progressbar",
|
|
201
|
+
"aria-valuemin": 0,
|
|
202
|
+
"aria-valuemax": max,
|
|
203
|
+
"aria-valuenow": value ?? 0,
|
|
204
|
+
"aria-label": typeof label === "string" ? label : void 0,
|
|
205
|
+
className: cn("ru-progress__capsule", semantic && `ru-c-${color}`),
|
|
206
|
+
style: meterStyle,
|
|
207
|
+
children: [
|
|
208
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ru-progress__capsule-fill", style: { width: `max(var(--_h), ${percent}%)` }, children: icon ?? (showValue && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ru-progress__capsule-value", children: [
|
|
209
|
+
Math.round(percent),
|
|
210
|
+
"%"
|
|
211
|
+
] })) }),
|
|
212
|
+
endLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-progress__capsule-end", children: endLabel })
|
|
213
|
+
]
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
] });
|
|
217
|
+
}
|
|
218
|
+
if (variant === "bars") {
|
|
219
|
+
const total = Math.max(2, ticks);
|
|
220
|
+
const lit = Math.round(percent / 100 * total);
|
|
221
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("ru-progress", "ru-progress--bars", `ru-progress--${size}`, glowColor && "ru-progress--glow", className), ...rest, children: [
|
|
222
|
+
(label || showValue) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ru-progress__label", children: [
|
|
223
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: label }),
|
|
224
|
+
showValue && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ru-progress__value ru-progress__value--accent", children: [
|
|
225
|
+
Math.round(percent),
|
|
226
|
+
"%"
|
|
227
|
+
] })
|
|
228
|
+
] }),
|
|
229
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
230
|
+
"div",
|
|
231
|
+
{
|
|
232
|
+
role: "progressbar",
|
|
233
|
+
"aria-valuemin": 0,
|
|
234
|
+
"aria-valuemax": max,
|
|
235
|
+
"aria-valuenow": value ?? 0,
|
|
236
|
+
"aria-label": typeof label === "string" ? label : void 0,
|
|
237
|
+
className: cn("ru-progress__bars", semantic && `ru-c-${color}`),
|
|
238
|
+
style: meterStyle,
|
|
239
|
+
children: Array.from({ length: total }, (_, i) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(i < lit && "is-on", i === lit - 1 && percent > 0 && percent < 100 && "is-marker") }, i))
|
|
240
|
+
}
|
|
241
|
+
)
|
|
242
|
+
] });
|
|
243
|
+
}
|
|
244
|
+
if (variant === "ticks") {
|
|
245
|
+
const remaining = percent >= 100 ? 0 : Math.max(1, Math.round(ticks * (1 - percent / 100)));
|
|
246
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("ru-progress", "ru-progress--ticks", `ru-progress--${size}`, glowColor && "ru-progress--glow", className), ...rest, children: [
|
|
247
|
+
label && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ru-progress__label", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: label }) }),
|
|
248
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
249
|
+
"div",
|
|
250
|
+
{
|
|
251
|
+
role: "progressbar",
|
|
252
|
+
"aria-valuemin": 0,
|
|
253
|
+
"aria-valuemax": max,
|
|
254
|
+
"aria-valuenow": value ?? 0,
|
|
255
|
+
"aria-label": typeof label === "string" ? label : void 0,
|
|
256
|
+
className: cn("ru-progress__meter", semantic && `ru-c-${color}`),
|
|
257
|
+
style: meterStyle,
|
|
258
|
+
children: [
|
|
259
|
+
percent > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ru-progress__fill", style: { width: `${percent}%` }, children: showValue && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ru-progress__fill-value", children: [
|
|
260
|
+
Math.round(percent),
|
|
261
|
+
"%"
|
|
262
|
+
] }) }),
|
|
263
|
+
percent > 0 && percent < 100 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-progress__marker", "aria-hidden": "true" }),
|
|
264
|
+
remaining > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ru-progress__ticks", "aria-hidden": "true", children: Array.from({ length: remaining }, (_, i) => /* @__PURE__ */ jsxRuntime.jsx("span", {}, i)) })
|
|
265
|
+
]
|
|
266
|
+
}
|
|
267
|
+
)
|
|
268
|
+
] });
|
|
269
|
+
}
|
|
270
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("ru-progress", indeterminate && "ru-progress--indeterminate", glowColor && "ru-progress--glow", className), ...rest, children: [
|
|
176
271
|
(label || showValue) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ru-progress__label", children: [
|
|
177
272
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: label }),
|
|
178
273
|
showValue && !indeterminate && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ru-progress__value", children: [
|
|
@@ -188,7 +283,8 @@ function Progress({
|
|
|
188
283
|
"aria-valuemax": max,
|
|
189
284
|
"aria-valuenow": indeterminate ? void 0 : value,
|
|
190
285
|
"aria-label": typeof label === "string" ? label : void 0,
|
|
191
|
-
className: cn("ru-progress__track", `ru-progress__track--${size}`, `ru-c-${color}`),
|
|
286
|
+
className: cn("ru-progress__track", `ru-progress__track--${size}`, semantic && `ru-c-${color}`),
|
|
287
|
+
style: meterStyle,
|
|
192
288
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ru-progress__bar", style: indeterminate ? void 0 : { width: `${percent}%` } })
|
|
193
289
|
}
|
|
194
290
|
)
|
|
@@ -1862,7 +1958,18 @@ function SpotlightCard({ color, className, style, onMouseMove, children, ...rest
|
|
|
1862
1958
|
}
|
|
1863
1959
|
);
|
|
1864
1960
|
}
|
|
1865
|
-
|
|
1961
|
+
function DotText({ as: Tag = "span", dot = 4, color, glow = false, className, style, children, ...rest }) {
|
|
1962
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1963
|
+
Tag,
|
|
1964
|
+
{
|
|
1965
|
+
className: cn("ru-dot-text", glow && "ru-dot-text--glow", className),
|
|
1966
|
+
style: { "--_d": `${dot}px`, ...color && { color }, ...style },
|
|
1967
|
+
...rest,
|
|
1968
|
+
children
|
|
1969
|
+
}
|
|
1970
|
+
);
|
|
1971
|
+
}
|
|
1972
|
+
const semanticColors$4 = /* @__PURE__ */ new Set(["primary", "secondary", "success", "danger", "warning", "info"]);
|
|
1866
1973
|
function Pager({ onPrev, onNext, prevLabel, nextLabel }) {
|
|
1867
1974
|
if (!onPrev && !onNext) return null;
|
|
1868
1975
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ru-frame-card__pager", children: [
|
|
@@ -1900,7 +2007,7 @@ function FrameCard({
|
|
|
1900
2007
|
{
|
|
1901
2008
|
className: cn("ru-frame-card", onFrame && "ru-frame-card--title-frame", className),
|
|
1902
2009
|
style: {
|
|
1903
|
-
"--_fc": semanticColors$
|
|
2010
|
+
"--_fc": semanticColors$4.has(color) ? `var(--ru-${color})` : color,
|
|
1904
2011
|
...textColor && { "--_fc-on": textColor, "--_fc-ink": textColor },
|
|
1905
2012
|
...style
|
|
1906
2013
|
},
|
|
@@ -1939,7 +2046,7 @@ function FrameCard({
|
|
|
1939
2046
|
}
|
|
1940
2047
|
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
1941
2048
|
const WEEKDAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
1942
|
-
const semanticColors = /* @__PURE__ */ new Set(["primary", "secondary", "success", "danger", "warning", "info"]);
|
|
2049
|
+
const semanticColors$3 = /* @__PURE__ */ new Set(["primary", "secondary", "success", "danger", "warning", "info"]);
|
|
1943
2050
|
const dayKey = (d) => d.getFullYear() * 1e4 + d.getMonth() * 100 + d.getDate();
|
|
1944
2051
|
const sameDay = (a, b) => Boolean(a && b) && dayKey(a) === dayKey(b);
|
|
1945
2052
|
function Calendar({
|
|
@@ -1999,7 +2106,7 @@ function Calendar({
|
|
|
1999
2106
|
next.focus();
|
|
2000
2107
|
}
|
|
2001
2108
|
};
|
|
2002
|
-
const ink = color ? semanticColors.has(color) ? `var(--ru-${color})` : color : void 0;
|
|
2109
|
+
const ink = color ? semanticColors$3.has(color) ? `var(--ru-${color})` : color : void 0;
|
|
2003
2110
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("ru-calendar", className), style: ink ? { "--_cc": ink, ...style } : style, ...rest, children: [
|
|
2004
2111
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ru-calendar__head", children: [
|
|
2005
2112
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "ru-calendar__nav", "aria-label": "Previous month", onClick: () => shift(-1), children: /* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon, {}) }),
|
|
@@ -2054,6 +2161,638 @@ function Calendar({
|
|
|
2054
2161
|
}) })
|
|
2055
2162
|
] });
|
|
2056
2163
|
}
|
|
2164
|
+
const normalize = (options) => options.map((o) => typeof o === "object" ? o : { label: String(o), value: o });
|
|
2165
|
+
function SegmentedControl({
|
|
2166
|
+
options,
|
|
2167
|
+
value,
|
|
2168
|
+
defaultValue,
|
|
2169
|
+
onChange,
|
|
2170
|
+
size = "md",
|
|
2171
|
+
fullWidth = false,
|
|
2172
|
+
pill = false,
|
|
2173
|
+
disabled = false,
|
|
2174
|
+
className,
|
|
2175
|
+
style,
|
|
2176
|
+
...rest
|
|
2177
|
+
}) {
|
|
2178
|
+
var _a;
|
|
2179
|
+
const items = normalize(options);
|
|
2180
|
+
const firstEnabled = (_a = items.find((i) => !i.disabled)) == null ? void 0 : _a.value;
|
|
2181
|
+
const [active, setActive] = useControllableState(value, defaultValue ?? firstEnabled, onChange);
|
|
2182
|
+
const rootRef = react.useRef(null);
|
|
2183
|
+
const [thumb, setThumb] = react.useState(null);
|
|
2184
|
+
const activeIndex = items.findIndex((i) => i.value === active);
|
|
2185
|
+
react.useEffect(() => {
|
|
2186
|
+
const root = rootRef.current;
|
|
2187
|
+
if (!root) return void 0;
|
|
2188
|
+
const measure = () => {
|
|
2189
|
+
const el = root.querySelectorAll('[role="radio"]')[activeIndex];
|
|
2190
|
+
setThumb(el ? { x: el.offsetLeft, w: el.offsetWidth } : null);
|
|
2191
|
+
};
|
|
2192
|
+
measure();
|
|
2193
|
+
if (typeof ResizeObserver === "undefined") return void 0;
|
|
2194
|
+
const ro = new ResizeObserver(measure);
|
|
2195
|
+
ro.observe(root);
|
|
2196
|
+
return () => ro.disconnect();
|
|
2197
|
+
}, [activeIndex, items.length]);
|
|
2198
|
+
const move = (from, step) => {
|
|
2199
|
+
var _a2;
|
|
2200
|
+
const buttons = rootRef.current.querySelectorAll('[role="radio"]');
|
|
2201
|
+
for (let n = 1; n <= items.length; n++) {
|
|
2202
|
+
const i = (from + step * n + items.length) % items.length;
|
|
2203
|
+
if (!items[i].disabled) {
|
|
2204
|
+
setActive(items[i].value);
|
|
2205
|
+
(_a2 = buttons[i]) == null ? void 0 : _a2.focus();
|
|
2206
|
+
return;
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
};
|
|
2210
|
+
const onKeyDown = (e, index) => {
|
|
2211
|
+
if (e.key === "ArrowRight" || e.key === "ArrowDown") move(index, 1);
|
|
2212
|
+
else if (e.key === "ArrowLeft" || e.key === "ArrowUp") move(index, -1);
|
|
2213
|
+
else return;
|
|
2214
|
+
e.preventDefault();
|
|
2215
|
+
};
|
|
2216
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2217
|
+
"div",
|
|
2218
|
+
{
|
|
2219
|
+
ref: rootRef,
|
|
2220
|
+
role: "radiogroup",
|
|
2221
|
+
"aria-disabled": disabled || void 0,
|
|
2222
|
+
className: cn(
|
|
2223
|
+
"ru-segmented",
|
|
2224
|
+
`ru-segmented--${size}`,
|
|
2225
|
+
fullWidth && "ru-segmented--full",
|
|
2226
|
+
pill && "ru-segmented--pill",
|
|
2227
|
+
thumb && "ru-segmented--ready",
|
|
2228
|
+
className
|
|
2229
|
+
),
|
|
2230
|
+
style: thumb ? { "--_x": `${thumb.x}px`, "--_w": `${thumb.w}px`, ...style } : style,
|
|
2231
|
+
...rest,
|
|
2232
|
+
children: [
|
|
2233
|
+
thumb && activeIndex >= 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-segmented__thumb", "aria-hidden": "true" }),
|
|
2234
|
+
items.map((item, i) => {
|
|
2235
|
+
const selected = i === activeIndex;
|
|
2236
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2237
|
+
"button",
|
|
2238
|
+
{
|
|
2239
|
+
type: "button",
|
|
2240
|
+
role: "radio",
|
|
2241
|
+
"aria-checked": selected,
|
|
2242
|
+
tabIndex: selected || activeIndex < 0 && i === 0 ? 0 : -1,
|
|
2243
|
+
disabled: disabled || item.disabled,
|
|
2244
|
+
className: "ru-segmented__item",
|
|
2245
|
+
onClick: () => setActive(item.value),
|
|
2246
|
+
onKeyDown: (e) => onKeyDown(e, i),
|
|
2247
|
+
children: [
|
|
2248
|
+
item.icon,
|
|
2249
|
+
item.label
|
|
2250
|
+
]
|
|
2251
|
+
},
|
|
2252
|
+
String(item.value)
|
|
2253
|
+
);
|
|
2254
|
+
})
|
|
2255
|
+
]
|
|
2256
|
+
}
|
|
2257
|
+
);
|
|
2258
|
+
}
|
|
2259
|
+
const semanticColors$2 = /* @__PURE__ */ new Set(["primary", "secondary", "success", "danger", "warning", "info"]);
|
|
2260
|
+
function ProgressRing({
|
|
2261
|
+
value = 0,
|
|
2262
|
+
max = 100,
|
|
2263
|
+
size = 48,
|
|
2264
|
+
thickness = 4,
|
|
2265
|
+
color = "primary",
|
|
2266
|
+
trackColor,
|
|
2267
|
+
showValue = false,
|
|
2268
|
+
label,
|
|
2269
|
+
className,
|
|
2270
|
+
style,
|
|
2271
|
+
children,
|
|
2272
|
+
...rest
|
|
2273
|
+
}) {
|
|
2274
|
+
const percent = Math.min(100, Math.max(0, value / max * 100));
|
|
2275
|
+
const r = (size - thickness) / 2;
|
|
2276
|
+
const circumference = 2 * Math.PI * r;
|
|
2277
|
+
const ink = semanticColors$2.has(color) ? `var(--ru-${color})` : color;
|
|
2278
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2279
|
+
"div",
|
|
2280
|
+
{
|
|
2281
|
+
role: "progressbar",
|
|
2282
|
+
"aria-valuemin": 0,
|
|
2283
|
+
"aria-valuemax": max,
|
|
2284
|
+
"aria-valuenow": value,
|
|
2285
|
+
"aria-label": label,
|
|
2286
|
+
className: cn("ru-ring", className),
|
|
2287
|
+
style: { width: size, height: size, "--_c": ink, ...trackColor && { "--_track": trackColor }, ...style },
|
|
2288
|
+
...rest,
|
|
2289
|
+
children: [
|
|
2290
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, "aria-hidden": "true", children: [
|
|
2291
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { className: "ru-ring__track", cx: size / 2, cy: size / 2, r, strokeWidth: thickness }),
|
|
2292
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2293
|
+
"circle",
|
|
2294
|
+
{
|
|
2295
|
+
className: "ru-ring__bar",
|
|
2296
|
+
cx: size / 2,
|
|
2297
|
+
cy: size / 2,
|
|
2298
|
+
r,
|
|
2299
|
+
strokeWidth: thickness,
|
|
2300
|
+
strokeDasharray: circumference,
|
|
2301
|
+
strokeDashoffset: circumference * (1 - percent / 100)
|
|
2302
|
+
}
|
|
2303
|
+
)
|
|
2304
|
+
] }),
|
|
2305
|
+
(children !== void 0 || showValue) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-ring__label", style: { fontSize: Math.max(10, Math.round(size * 0.24)) }, children: children ?? `${Math.round(percent)}%` })
|
|
2306
|
+
]
|
|
2307
|
+
}
|
|
2308
|
+
);
|
|
2309
|
+
}
|
|
2310
|
+
const semanticColors$1 = /* @__PURE__ */ new Set(["primary", "secondary", "success", "danger", "warning", "info"]);
|
|
2311
|
+
function Stat({
|
|
2312
|
+
label,
|
|
2313
|
+
value,
|
|
2314
|
+
trend,
|
|
2315
|
+
trendLabel,
|
|
2316
|
+
invertTrend = false,
|
|
2317
|
+
helpText,
|
|
2318
|
+
size = "md",
|
|
2319
|
+
align = "start",
|
|
2320
|
+
className,
|
|
2321
|
+
...rest
|
|
2322
|
+
}) {
|
|
2323
|
+
const hasTrend = typeof trend === "number";
|
|
2324
|
+
const up = hasTrend && trend >= 0;
|
|
2325
|
+
const good = up !== invertTrend;
|
|
2326
|
+
const TrendIcon = up ? TrendUpIcon : TrendDownIcon;
|
|
2327
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("ru-stat", `ru-stat--${size}`, align === "end" && "ru-stat--end", className), ...rest, children: [
|
|
2328
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ru-stat__top", children: [
|
|
2329
|
+
label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-stat__label", children: label }),
|
|
2330
|
+
hasTrend && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cn("ru-stat__trend", good ? "ru-stat__trend--good" : "ru-stat__trend--bad"), children: [
|
|
2331
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-stat__trend-icon", children: /* @__PURE__ */ jsxRuntime.jsx(TrendIcon, {}) }),
|
|
2332
|
+
trendLabel ?? `${Math.abs(trend).toLocaleString()}%`,
|
|
2333
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-sr-only", children: up ? " increase" : " decrease" })
|
|
2334
|
+
] })
|
|
2335
|
+
] }),
|
|
2336
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ru-stat__value", children: value }),
|
|
2337
|
+
helpText && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ru-stat__help", children: helpText })
|
|
2338
|
+
] });
|
|
2339
|
+
}
|
|
2340
|
+
function DateTile({ date, color = "primary", size = "md", className, style, ...rest }) {
|
|
2341
|
+
const d = date instanceof Date ? date : new Date(date);
|
|
2342
|
+
const ink = semanticColors$1.has(color) ? `var(--ru-${color})` : color;
|
|
2343
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2344
|
+
"time",
|
|
2345
|
+
{
|
|
2346
|
+
dateTime: d.toISOString().slice(0, 10),
|
|
2347
|
+
"aria-label": d.toLocaleDateString("en-US", { weekday: "long", month: "long", day: "numeric", year: "numeric" }),
|
|
2348
|
+
className: cn("ru-date-tile", `ru-date-tile--${size}`, className),
|
|
2349
|
+
style: { "--_c": ink, ...style },
|
|
2350
|
+
...rest,
|
|
2351
|
+
children: [
|
|
2352
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-date-tile__month", "aria-hidden": "true", children: d.toLocaleDateString("en-US", { month: "short" }) }),
|
|
2353
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-date-tile__day", "aria-hidden": "true", children: d.getDate() })
|
|
2354
|
+
]
|
|
2355
|
+
}
|
|
2356
|
+
);
|
|
2357
|
+
}
|
|
2358
|
+
function matchesAccept(file, accept) {
|
|
2359
|
+
if (!accept) return true;
|
|
2360
|
+
return accept.split(",").some((rule) => {
|
|
2361
|
+
const r = rule.trim().toLowerCase();
|
|
2362
|
+
if (!r) return false;
|
|
2363
|
+
if (r.startsWith(".")) return file.name.toLowerCase().endsWith(r);
|
|
2364
|
+
if (r.endsWith("/*")) return file.type.toLowerCase().startsWith(r.slice(0, -1));
|
|
2365
|
+
return file.type.toLowerCase() === r;
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
function formatBytes(bytes) {
|
|
2369
|
+
if (typeof bytes !== "number") return bytes;
|
|
2370
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
2371
|
+
const units = ["KB", "MB", "GB"];
|
|
2372
|
+
let n = bytes / 1024;
|
|
2373
|
+
let i = 0;
|
|
2374
|
+
while (n >= 1024 && i < units.length - 1) {
|
|
2375
|
+
n /= 1024;
|
|
2376
|
+
i++;
|
|
2377
|
+
}
|
|
2378
|
+
return `${Number(n.toFixed(1))}${units[i]}`;
|
|
2379
|
+
}
|
|
2380
|
+
function Dropzone({
|
|
2381
|
+
onFiles,
|
|
2382
|
+
onReject,
|
|
2383
|
+
accept,
|
|
2384
|
+
multiple = true,
|
|
2385
|
+
maxSize,
|
|
2386
|
+
disabled = false,
|
|
2387
|
+
icon,
|
|
2388
|
+
title = "Drag & drop files here",
|
|
2389
|
+
description,
|
|
2390
|
+
className,
|
|
2391
|
+
children,
|
|
2392
|
+
...rest
|
|
2393
|
+
}) {
|
|
2394
|
+
const inputRef = react.useRef(null);
|
|
2395
|
+
const [dragging, setDragging] = react.useState(false);
|
|
2396
|
+
const handle = (list) => {
|
|
2397
|
+
const files = Array.from(list ?? []);
|
|
2398
|
+
const accepted = [];
|
|
2399
|
+
const rejected = [];
|
|
2400
|
+
for (const file of multiple ? files : files.slice(0, 1)) {
|
|
2401
|
+
if (!matchesAccept(file, accept)) rejected.push({ file, reason: "type" });
|
|
2402
|
+
else if (maxSize && file.size > maxSize) rejected.push({ file, reason: "size" });
|
|
2403
|
+
else accepted.push(file);
|
|
2404
|
+
}
|
|
2405
|
+
if (accepted.length) onFiles == null ? void 0 : onFiles(accepted);
|
|
2406
|
+
if (rejected.length) onReject == null ? void 0 : onReject(rejected);
|
|
2407
|
+
};
|
|
2408
|
+
const open = () => {
|
|
2409
|
+
var _a;
|
|
2410
|
+
return !disabled && ((_a = inputRef.current) == null ? void 0 : _a.click());
|
|
2411
|
+
};
|
|
2412
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2413
|
+
"div",
|
|
2414
|
+
{
|
|
2415
|
+
role: "button",
|
|
2416
|
+
tabIndex: disabled ? -1 : 0,
|
|
2417
|
+
"aria-disabled": disabled || void 0,
|
|
2418
|
+
className: cn("ru-dropzone", dragging && "ru-dropzone--active", disabled && "ru-dropzone--disabled", className),
|
|
2419
|
+
onClick: open,
|
|
2420
|
+
onKeyDown: (e) => {
|
|
2421
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
2422
|
+
e.preventDefault();
|
|
2423
|
+
open();
|
|
2424
|
+
}
|
|
2425
|
+
},
|
|
2426
|
+
onDragEnter: (e) => {
|
|
2427
|
+
e.preventDefault();
|
|
2428
|
+
if (!disabled) setDragging(true);
|
|
2429
|
+
},
|
|
2430
|
+
onDragOver: (e) => e.preventDefault(),
|
|
2431
|
+
onDragLeave: (e) => {
|
|
2432
|
+
if (!e.currentTarget.contains(e.relatedTarget)) setDragging(false);
|
|
2433
|
+
},
|
|
2434
|
+
onDrop: (e) => {
|
|
2435
|
+
e.preventDefault();
|
|
2436
|
+
setDragging(false);
|
|
2437
|
+
if (!disabled) handle(e.dataTransfer.files);
|
|
2438
|
+
},
|
|
2439
|
+
...rest,
|
|
2440
|
+
children: [
|
|
2441
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2442
|
+
"input",
|
|
2443
|
+
{
|
|
2444
|
+
ref: inputRef,
|
|
2445
|
+
type: "file",
|
|
2446
|
+
hidden: true,
|
|
2447
|
+
accept,
|
|
2448
|
+
multiple,
|
|
2449
|
+
disabled,
|
|
2450
|
+
onChange: (e) => {
|
|
2451
|
+
handle(e.target.files);
|
|
2452
|
+
e.target.value = "";
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
),
|
|
2456
|
+
children ?? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2457
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-dropzone__icon", children: icon ?? /* @__PURE__ */ jsxRuntime.jsx(UploadCloudIcon, {}) }),
|
|
2458
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-dropzone__title", children: title }),
|
|
2459
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-dropzone__desc", children: description ?? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2460
|
+
"or ",
|
|
2461
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-dropzone__browse", children: "browse" }),
|
|
2462
|
+
" to choose files",
|
|
2463
|
+
maxSize ? ` (max ${formatBytes(maxSize)})` : ""
|
|
2464
|
+
] }) })
|
|
2465
|
+
] })
|
|
2466
|
+
]
|
|
2467
|
+
}
|
|
2468
|
+
);
|
|
2469
|
+
}
|
|
2470
|
+
const statusText = { uploading: "Uploading…", complete: "Completed", error: "Failed" };
|
|
2471
|
+
function FileItem({
|
|
2472
|
+
name,
|
|
2473
|
+
size,
|
|
2474
|
+
status = "complete",
|
|
2475
|
+
progress = 0,
|
|
2476
|
+
icon,
|
|
2477
|
+
error,
|
|
2478
|
+
onRemove,
|
|
2479
|
+
action,
|
|
2480
|
+
removeLabel,
|
|
2481
|
+
className,
|
|
2482
|
+
...rest
|
|
2483
|
+
}) {
|
|
2484
|
+
const uploading = status === "uploading";
|
|
2485
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("ru-file-item", `ru-file-item--${status}`, className), ...rest, children: [
|
|
2486
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-file-item__icon", children: icon ?? /* @__PURE__ */ jsxRuntime.jsx(FileIcon, {}) }),
|
|
2487
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ru-file-item__body", children: [
|
|
2488
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ru-file-item__name", title: name, children: name }),
|
|
2489
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ru-file-item__meta", children: [
|
|
2490
|
+
size !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { children: formatBytes(size) }),
|
|
2491
|
+
size !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-file-item__dot", "aria-hidden": "true" }),
|
|
2492
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-file-item__status", children: status === "error" && error ? error : statusText[status] })
|
|
2493
|
+
] }),
|
|
2494
|
+
uploading && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2495
|
+
"div",
|
|
2496
|
+
{
|
|
2497
|
+
className: "ru-file-item__bar",
|
|
2498
|
+
role: "progressbar",
|
|
2499
|
+
"aria-valuemin": 0,
|
|
2500
|
+
"aria-valuemax": 100,
|
|
2501
|
+
"aria-valuenow": progress,
|
|
2502
|
+
"aria-label": `Uploading ${name}`,
|
|
2503
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: { width: `${progress}%` } })
|
|
2504
|
+
}
|
|
2505
|
+
)
|
|
2506
|
+
] }),
|
|
2507
|
+
uploading && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ru-file-item__percent", children: [
|
|
2508
|
+
Math.round(progress),
|
|
2509
|
+
"%"
|
|
2510
|
+
] }),
|
|
2511
|
+
action,
|
|
2512
|
+
onRemove && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "ru-file-item__remove", "aria-label": removeLabel ?? `Remove ${name}`, onClick: onRemove, children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {}) })
|
|
2513
|
+
] });
|
|
2514
|
+
}
|
|
2515
|
+
const UndoIcon = () => /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
2516
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 14 4 9l5-5" }),
|
|
2517
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4 9h10.5a5.5 5.5 0 0 1 0 11H11" })
|
|
2518
|
+
] });
|
|
2519
|
+
const EraserIcon = () => /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
2520
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "m7 21-4.3-4.3a1 1 0 0 1 0-1.4l10-10a1 1 0 0 1 1.4 0l5.6 5.6a1 1 0 0 1 0 1.4L11 21" }),
|
|
2521
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M22 21H7M5 11l9 9" })
|
|
2522
|
+
] });
|
|
2523
|
+
const SignaturePad = react.forwardRef(function SignaturePad2({
|
|
2524
|
+
onChange,
|
|
2525
|
+
strokeColor,
|
|
2526
|
+
strokeWidth = 2.5,
|
|
2527
|
+
height = 180,
|
|
2528
|
+
placeholder = "Sign here",
|
|
2529
|
+
showControls = true,
|
|
2530
|
+
undoLabel = "Undo",
|
|
2531
|
+
clearLabel = "Clear",
|
|
2532
|
+
actions,
|
|
2533
|
+
disabled = false,
|
|
2534
|
+
className,
|
|
2535
|
+
style,
|
|
2536
|
+
...rest
|
|
2537
|
+
}, ref) {
|
|
2538
|
+
const canvasRef = react.useRef(null);
|
|
2539
|
+
const strokes = react.useRef([]);
|
|
2540
|
+
const drawing = react.useRef(null);
|
|
2541
|
+
const [count, setCount] = react.useState(0);
|
|
2542
|
+
const ink = react.useCallback(() => strokeColor ?? getComputedStyle(canvasRef.current).color, [strokeColor]);
|
|
2543
|
+
const drawStroke = react.useCallback(
|
|
2544
|
+
(ctx, points) => {
|
|
2545
|
+
ctx.strokeStyle = ink();
|
|
2546
|
+
ctx.fillStyle = ctx.strokeStyle;
|
|
2547
|
+
if (points.length === 1) {
|
|
2548
|
+
ctx.beginPath();
|
|
2549
|
+
ctx.arc(points[0].x, points[0].y, strokeWidth / 2, 0, Math.PI * 2);
|
|
2550
|
+
ctx.fill();
|
|
2551
|
+
return;
|
|
2552
|
+
}
|
|
2553
|
+
for (let i = 1; i < points.length; i++) {
|
|
2554
|
+
const a = points[i - 1];
|
|
2555
|
+
const b = points[i];
|
|
2556
|
+
const mid = { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
|
|
2557
|
+
ctx.lineWidth = b.w;
|
|
2558
|
+
ctx.beginPath();
|
|
2559
|
+
ctx.moveTo(a.mx ?? a.x, a.my ?? a.y);
|
|
2560
|
+
ctx.quadraticCurveTo(a.x, a.y, mid.x, mid.y);
|
|
2561
|
+
ctx.stroke();
|
|
2562
|
+
b.mx = mid.x;
|
|
2563
|
+
b.my = mid.y;
|
|
2564
|
+
}
|
|
2565
|
+
},
|
|
2566
|
+
[ink, strokeWidth]
|
|
2567
|
+
);
|
|
2568
|
+
const redraw = react.useCallback(() => {
|
|
2569
|
+
const canvas = canvasRef.current;
|
|
2570
|
+
if (!canvas) return;
|
|
2571
|
+
const ctx = canvas.getContext("2d");
|
|
2572
|
+
if (!ctx) return;
|
|
2573
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
2574
|
+
ctx.lineCap = "round";
|
|
2575
|
+
ctx.lineJoin = "round";
|
|
2576
|
+
strokes.current.forEach((s) => drawStroke(ctx, s.map(({ x, y, w }) => ({ x, y, w }))));
|
|
2577
|
+
}, [drawStroke]);
|
|
2578
|
+
react.useEffect(() => {
|
|
2579
|
+
const canvas = canvasRef.current;
|
|
2580
|
+
if (!canvas) return void 0;
|
|
2581
|
+
const fit = () => {
|
|
2582
|
+
var _a;
|
|
2583
|
+
const dpr = window.devicePixelRatio || 1;
|
|
2584
|
+
const { width, height: h } = canvas.getBoundingClientRect();
|
|
2585
|
+
canvas.width = Math.max(1, Math.round(width * dpr));
|
|
2586
|
+
canvas.height = Math.max(1, Math.round(h * dpr));
|
|
2587
|
+
(_a = canvas.getContext("2d")) == null ? void 0 : _a.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
2588
|
+
redraw();
|
|
2589
|
+
};
|
|
2590
|
+
fit();
|
|
2591
|
+
if (typeof ResizeObserver === "undefined") return void 0;
|
|
2592
|
+
const ro = new ResizeObserver(fit);
|
|
2593
|
+
ro.observe(canvas);
|
|
2594
|
+
return () => ro.disconnect();
|
|
2595
|
+
}, [redraw]);
|
|
2596
|
+
const emit = () => onChange == null ? void 0 : onChange(strokes.current.length ? canvasRef.current.toDataURL("image/png") : null);
|
|
2597
|
+
const point = (e) => {
|
|
2598
|
+
const rect = canvasRef.current.getBoundingClientRect();
|
|
2599
|
+
return { x: e.clientX - rect.left, y: e.clientY - rect.top, t: e.timeStamp };
|
|
2600
|
+
};
|
|
2601
|
+
const onPointerDown = (e) => {
|
|
2602
|
+
if (disabled || e.pointerType === "mouse" && e.button !== 0) return;
|
|
2603
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
2604
|
+
const p = { ...point(e), w: strokeWidth };
|
|
2605
|
+
drawing.current = [p];
|
|
2606
|
+
const ctx = canvasRef.current.getContext("2d");
|
|
2607
|
+
ctx.lineCap = "round";
|
|
2608
|
+
ctx.lineJoin = "round";
|
|
2609
|
+
drawStroke(ctx, [p]);
|
|
2610
|
+
};
|
|
2611
|
+
const onPointerMove = (e) => {
|
|
2612
|
+
const stroke = drawing.current;
|
|
2613
|
+
if (!stroke) return;
|
|
2614
|
+
const prev = stroke[stroke.length - 1];
|
|
2615
|
+
const p = point(e);
|
|
2616
|
+
const dist = Math.hypot(p.x - prev.x, p.y - prev.y);
|
|
2617
|
+
if (dist < 1.5) return;
|
|
2618
|
+
const speed = dist / Math.max(1, p.t - prev.t);
|
|
2619
|
+
const target = strokeWidth * Math.max(0.45, Math.min(1.35, 1.4 - speed * 0.45));
|
|
2620
|
+
p.w = prev.w * 0.6 + target * 0.4;
|
|
2621
|
+
stroke.push(p);
|
|
2622
|
+
drawStroke(canvasRef.current.getContext("2d"), stroke.slice(-3));
|
|
2623
|
+
};
|
|
2624
|
+
const onPointerUp = () => {
|
|
2625
|
+
if (!drawing.current) return;
|
|
2626
|
+
strokes.current = [...strokes.current, drawing.current];
|
|
2627
|
+
drawing.current = null;
|
|
2628
|
+
setCount(strokes.current.length);
|
|
2629
|
+
emit();
|
|
2630
|
+
};
|
|
2631
|
+
const undo = () => {
|
|
2632
|
+
strokes.current = strokes.current.slice(0, -1);
|
|
2633
|
+
setCount(strokes.current.length);
|
|
2634
|
+
redraw();
|
|
2635
|
+
emit();
|
|
2636
|
+
};
|
|
2637
|
+
const clear = () => {
|
|
2638
|
+
strokes.current = [];
|
|
2639
|
+
setCount(0);
|
|
2640
|
+
redraw();
|
|
2641
|
+
emit();
|
|
2642
|
+
};
|
|
2643
|
+
react.useImperativeHandle(ref, () => ({
|
|
2644
|
+
clear,
|
|
2645
|
+
undo,
|
|
2646
|
+
isEmpty: () => strokes.current.length === 0,
|
|
2647
|
+
toDataURL: (type = "image/png") => canvasRef.current.toDataURL(type)
|
|
2648
|
+
}));
|
|
2649
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("ru-signature", disabled && "ru-signature--disabled", className), style, ...rest, children: [
|
|
2650
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ru-signature__canvas-wrap", style: { height }, children: [
|
|
2651
|
+
count === 0 && placeholder && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-signature__placeholder", "aria-hidden": "true", children: placeholder }),
|
|
2652
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2653
|
+
"canvas",
|
|
2654
|
+
{
|
|
2655
|
+
ref: canvasRef,
|
|
2656
|
+
className: "ru-signature__canvas",
|
|
2657
|
+
role: "img",
|
|
2658
|
+
"aria-label": count ? "Signature drawn" : "Signature pad, empty",
|
|
2659
|
+
onPointerDown,
|
|
2660
|
+
onPointerMove,
|
|
2661
|
+
onPointerUp,
|
|
2662
|
+
onPointerCancel: onPointerUp
|
|
2663
|
+
}
|
|
2664
|
+
),
|
|
2665
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-signature__baseline", "aria-hidden": "true" })
|
|
2666
|
+
] }),
|
|
2667
|
+
(showControls || actions) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ru-signature__bar", children: [
|
|
2668
|
+
showControls && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2669
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "ru-signature__btn", onClick: undo, disabled: disabled || count === 0, children: [
|
|
2670
|
+
/* @__PURE__ */ jsxRuntime.jsx(UndoIcon, {}),
|
|
2671
|
+
undoLabel
|
|
2672
|
+
] }),
|
|
2673
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-signature__sep", "aria-hidden": "true" }),
|
|
2674
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "ru-signature__btn", onClick: clear, disabled: disabled || count === 0, children: [
|
|
2675
|
+
/* @__PURE__ */ jsxRuntime.jsx(EraserIcon, {}),
|
|
2676
|
+
clearLabel
|
|
2677
|
+
] })
|
|
2678
|
+
] }),
|
|
2679
|
+
actions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ru-signature__actions", children: actions })
|
|
2680
|
+
] })
|
|
2681
|
+
] });
|
|
2682
|
+
});
|
|
2683
|
+
const statusLabels = {
|
|
2684
|
+
running: "In progress",
|
|
2685
|
+
queued: "Queued",
|
|
2686
|
+
pending: "Not started",
|
|
2687
|
+
partial: "Partly done",
|
|
2688
|
+
complete: "Complete",
|
|
2689
|
+
error: "Failed"
|
|
2690
|
+
};
|
|
2691
|
+
function StatusIcon({ status = "pending", progress = 50, size = 20, label, className, style, ...rest }) {
|
|
2692
|
+
const r = 8;
|
|
2693
|
+
const c = 2 * Math.PI * r;
|
|
2694
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2695
|
+
"span",
|
|
2696
|
+
{
|
|
2697
|
+
role: "img",
|
|
2698
|
+
"aria-label": label ?? statusLabels[status] ?? status,
|
|
2699
|
+
className: cn("ru-status-icon", `ru-status-icon--${status}`, className),
|
|
2700
|
+
style: { width: size, height: size, ...style },
|
|
2701
|
+
...rest,
|
|
2702
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 20 20", width: size, height: size, "aria-hidden": "true", children: status === "complete" || status === "error" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2703
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "10", cy: "10", r: "10", className: "ru-status-icon__fill" }),
|
|
2704
|
+
status === "complete" ? /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m6 10.2 2.6 2.6L14 7.4", className: "ru-status-icon__glyph" }) : /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m7 7 6 6M13 7l-6 6", className: "ru-status-icon__glyph" })
|
|
2705
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2706
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2707
|
+
"circle",
|
|
2708
|
+
{
|
|
2709
|
+
cx: "10",
|
|
2710
|
+
cy: "10",
|
|
2711
|
+
r,
|
|
2712
|
+
className: "ru-status-icon__ring",
|
|
2713
|
+
strokeDasharray: status === "running" || status === "queued" ? "2.6 2.4" : void 0
|
|
2714
|
+
}
|
|
2715
|
+
),
|
|
2716
|
+
status === "partial" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2717
|
+
"circle",
|
|
2718
|
+
{
|
|
2719
|
+
cx: "10",
|
|
2720
|
+
cy: "10",
|
|
2721
|
+
r,
|
|
2722
|
+
className: "ru-status-icon__arc",
|
|
2723
|
+
strokeDasharray: c,
|
|
2724
|
+
strokeDashoffset: c * (1 - Math.min(100, Math.max(0, progress)) / 100)
|
|
2725
|
+
}
|
|
2726
|
+
)
|
|
2727
|
+
] }) })
|
|
2728
|
+
}
|
|
2729
|
+
);
|
|
2730
|
+
}
|
|
2731
|
+
function StepList({ items, connector = true, dividers = true, className, ...rest }) {
|
|
2732
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", { className: cn("ru-step-list", !dividers && "ru-step-list--plain", className), ...rest, children: items.map((item, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2733
|
+
"li",
|
|
2734
|
+
{
|
|
2735
|
+
className: cn("ru-step-list__item", `ru-step-list__item--${item.status ?? "pending"}`),
|
|
2736
|
+
"aria-current": item.status === "running" ? "step" : void 0,
|
|
2737
|
+
children: [
|
|
2738
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ru-step-list__rail", children: [
|
|
2739
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-step-list__icon", children: /* @__PURE__ */ jsxRuntime.jsx(StatusIcon, { status: item.status, progress: item.progress, size: 22 }) }),
|
|
2740
|
+
connector && i < items.length - 1 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-step-list__line", "aria-hidden": "true" })
|
|
2741
|
+
] }),
|
|
2742
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ru-step-list__body", children: [
|
|
2743
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ru-step-list__title", children: item.title }),
|
|
2744
|
+
item.description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ru-step-list__desc", children: item.description })
|
|
2745
|
+
] }),
|
|
2746
|
+
item.meta && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ru-step-list__meta", children: item.meta })
|
|
2747
|
+
]
|
|
2748
|
+
},
|
|
2749
|
+
item.key ?? i
|
|
2750
|
+
)) });
|
|
2751
|
+
}
|
|
2752
|
+
function StackedProgress({ segments, max, size = "md", showLegend = true, gap = 4, label, className, ...rest }) {
|
|
2753
|
+
const total = max ?? segments.reduce((sum, s) => sum + s.value, 0);
|
|
2754
|
+
const summary = segments.map((s) => `${s.label} ${Math.round(s.value / total * 100)}%`).join(", ");
|
|
2755
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("ru-stacked", `ru-stacked--${size}`, className), ...rest, children: [
|
|
2756
|
+
(label || showLegend) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ru-stacked__head", children: [
|
|
2757
|
+
label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-stacked__label", children: label }),
|
|
2758
|
+
showLegend && /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "ru-stacked__legend", children: segments.map((s) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
|
|
2759
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-stacked__dot", style: { background: s.color } }),
|
|
2760
|
+
s.label
|
|
2761
|
+
] }, s.label)) })
|
|
2762
|
+
] }),
|
|
2763
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ru-stacked__bar", role: "img", "aria-label": summary, style: { gap }, children: [
|
|
2764
|
+
segments.map((s) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-stacked__seg", title: `${s.label}: ${s.value}`, style: { flexGrow: s.value, background: s.color } }, s.label)),
|
|
2765
|
+
max !== void 0 && total > segments.reduce((sum, s) => sum + s.value, 0) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-stacked__rest", style: { flexGrow: total - segments.reduce((sum, s) => sum + s.value, 0) } })
|
|
2766
|
+
] })
|
|
2767
|
+
] });
|
|
2768
|
+
}
|
|
2769
|
+
const semanticColors = /* @__PURE__ */ new Set(["primary", "secondary", "success", "danger", "warning", "info"]);
|
|
2770
|
+
function IconTile({
|
|
2771
|
+
color = "primary",
|
|
2772
|
+
size = 48,
|
|
2773
|
+
radius,
|
|
2774
|
+
badge,
|
|
2775
|
+
glow = true,
|
|
2776
|
+
label,
|
|
2777
|
+
className,
|
|
2778
|
+
style,
|
|
2779
|
+
children,
|
|
2780
|
+
...rest
|
|
2781
|
+
}) {
|
|
2782
|
+
const ink = semanticColors.has(color) ? `var(--ru-${color})` : color;
|
|
2783
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2784
|
+
"span",
|
|
2785
|
+
{
|
|
2786
|
+
className: cn("ru-icon-tile", glow && "ru-icon-tile--glow", className),
|
|
2787
|
+
style: { "--_c": ink, "--_s": `${size}px`, ...radius !== void 0 && { "--_r": typeof radius === "number" ? `${radius}px` : radius }, ...style },
|
|
2788
|
+
...rest,
|
|
2789
|
+
children: [
|
|
2790
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-icon-tile__face", role: label ? "img" : void 0, "aria-label": label, "aria-hidden": label ? void 0 : true, children }),
|
|
2791
|
+
badge && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ru-icon-tile__badge", "aria-hidden": "true", children: badge })
|
|
2792
|
+
]
|
|
2793
|
+
}
|
|
2794
|
+
);
|
|
2795
|
+
}
|
|
2057
2796
|
exports.Accordion = Accordion;
|
|
2058
2797
|
exports.Alert = Alert;
|
|
2059
2798
|
exports.Avatar = Avatar;
|
|
@@ -2068,10 +2807,15 @@ exports.CardBody = CardBody;
|
|
|
2068
2807
|
exports.CardFooter = CardFooter;
|
|
2069
2808
|
exports.CardHeader = CardHeader;
|
|
2070
2809
|
exports.Checkbox = Checkbox;
|
|
2810
|
+
exports.DateTile = DateTile;
|
|
2071
2811
|
exports.Divider = Divider;
|
|
2812
|
+
exports.DotText = DotText;
|
|
2072
2813
|
exports.Drawer = Drawer;
|
|
2073
2814
|
exports.Dropdown = Dropdown;
|
|
2815
|
+
exports.Dropzone = Dropzone;
|
|
2816
|
+
exports.FileItem = FileItem;
|
|
2074
2817
|
exports.FrameCard = FrameCard;
|
|
2818
|
+
exports.IconTile = IconTile;
|
|
2075
2819
|
exports.Input = Input;
|
|
2076
2820
|
exports.Kbd = Kbd;
|
|
2077
2821
|
exports.Modal = Modal;
|
|
@@ -2079,12 +2823,19 @@ exports.NativeSelect = NativeSelect;
|
|
|
2079
2823
|
exports.Pagination = Pagination;
|
|
2080
2824
|
exports.Pattern = Pattern;
|
|
2081
2825
|
exports.Progress = Progress;
|
|
2826
|
+
exports.ProgressRing = ProgressRing;
|
|
2082
2827
|
exports.Radio = Radio;
|
|
2083
2828
|
exports.RadioGroup = RadioGroup;
|
|
2829
|
+
exports.SegmentedControl = SegmentedControl;
|
|
2084
2830
|
exports.Select = Select;
|
|
2831
|
+
exports.SignaturePad = SignaturePad;
|
|
2085
2832
|
exports.Skeleton = Skeleton;
|
|
2086
2833
|
exports.Spinner = Spinner;
|
|
2087
2834
|
exports.SpotlightCard = SpotlightCard;
|
|
2835
|
+
exports.StackedProgress = StackedProgress;
|
|
2836
|
+
exports.Stat = Stat;
|
|
2837
|
+
exports.StatusIcon = StatusIcon;
|
|
2838
|
+
exports.StepList = StepList;
|
|
2088
2839
|
exports.Switch = Switch;
|
|
2089
2840
|
exports.Table = Table;
|
|
2090
2841
|
exports.Tabs = Tabs;
|
|
@@ -2092,6 +2843,7 @@ exports.Textarea = Textarea;
|
|
|
2092
2843
|
exports.ToastProvider = ToastProvider;
|
|
2093
2844
|
exports.Tooltip = Tooltip;
|
|
2094
2845
|
exports.cn = cn;
|
|
2846
|
+
exports.formatBytes = formatBytes;
|
|
2095
2847
|
exports.useClickOutside = useClickOutside;
|
|
2096
2848
|
exports.useControllableState = useControllableState;
|
|
2097
2849
|
exports.useDisclosure = useDisclosure;
|