@bug-on/m3-expressive 1.0.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/CHANGELOG.md +110 -0
- package/README.md +110 -0
- package/dist/assets/fonts/GoogleSansFlex-VariableFont.woff2 +0 -0
- package/dist/assets/fonts/MaterialSymbolsOutlined-VariableFont_FILL,GRAD,opsz,wght.ttf +0 -0
- package/dist/assets/fonts/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght.ttf +0 -0
- package/dist/assets/fonts/MaterialSymbolsSharp-VariableFont_FILL,GRAD,opsz,wght.ttf +0 -0
- package/dist/assets/loading-indicator.svg +19 -0
- package/dist/assets/material-symbols-cdn.css +65 -0
- package/dist/assets/material-symbols-self-hosted.css +94 -0
- package/dist/buttons.d.mts +180 -0
- package/dist/buttons.d.ts +180 -0
- package/dist/buttons.js +4282 -0
- package/dist/buttons.js.map +1 -0
- package/dist/buttons.mjs +4227 -0
- package/dist/buttons.mjs.map +1 -0
- package/dist/core.d.mts +422 -0
- package/dist/core.d.ts +422 -0
- package/dist/core.js +2581 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +2547 -0
- package/dist/core.mjs.map +1 -0
- package/dist/feedback.d.mts +600 -0
- package/dist/feedback.d.ts +600 -0
- package/dist/feedback.js +2357 -0
- package/dist/feedback.js.map +1 -0
- package/dist/feedback.mjs +2321 -0
- package/dist/feedback.mjs.map +1 -0
- package/dist/forms.d.mts +40 -0
- package/dist/forms.d.ts +40 -0
- package/dist/forms.js +4263 -0
- package/dist/forms.js.map +1 -0
- package/dist/forms.mjs +4228 -0
- package/dist/forms.mjs.map +1 -0
- package/dist/icon-button-D-gs0gfj.d.mts +136 -0
- package/dist/icon-button-D-gs0gfj.d.ts +136 -0
- package/dist/index.css +309 -0
- package/dist/index.css.d.ts +2 -0
- package/dist/index.d.mts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +23972 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +23668 -0
- package/dist/index.mjs.map +1 -0
- package/dist/layout.d.mts +610 -0
- package/dist/layout.d.ts +610 -0
- package/dist/layout.js +5091 -0
- package/dist/layout.js.map +1 -0
- package/dist/layout.mjs +5042 -0
- package/dist/layout.mjs.map +1 -0
- package/dist/material-symbols-cdn.css +65 -0
- package/dist/material-symbols-cdn.css.d.ts +2 -0
- package/dist/material-symbols-self-hosted.css +94 -0
- package/dist/material-symbols-self-hosted.css.d.ts +2 -0
- package/dist/md3-DFhj-NZj.d.mts +17 -0
- package/dist/md3-DFhj-NZj.d.ts +17 -0
- package/dist/navigation.d.mts +2766 -0
- package/dist/navigation.d.ts +2766 -0
- package/dist/navigation.js +6684 -0
- package/dist/navigation.js.map +1 -0
- package/dist/navigation.mjs +6573 -0
- package/dist/navigation.mjs.map +1 -0
- package/dist/overlays.d.mts +161 -0
- package/dist/overlays.d.ts +161 -0
- package/dist/overlays.js +3298 -0
- package/dist/overlays.js.map +1 -0
- package/dist/overlays.mjs +3244 -0
- package/dist/overlays.mjs.map +1 -0
- package/dist/pickers.d.mts +1074 -0
- package/dist/pickers.d.ts +1074 -0
- package/dist/pickers.js +4240 -0
- package/dist/pickers.js.map +1 -0
- package/dist/pickers.mjs +4200 -0
- package/dist/pickers.mjs.map +1 -0
- package/dist/plugin.d.mts +1 -0
- package/dist/plugin.d.ts +1 -0
- package/dist/plugin.js +13 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugin.mjs +3 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/scroll-area-CVS6HyLl.d.mts +33 -0
- package/dist/scroll-area-CVS6HyLl.d.ts +33 -0
- package/dist/shapes.d.mts +1119 -0
- package/dist/shapes.d.ts +1119 -0
- package/dist/shapes.js +2941 -0
- package/dist/shapes.js.map +1 -0
- package/dist/shapes.mjs +2889 -0
- package/dist/shapes.mjs.map +1 -0
- package/dist/side-sheet-modal-BY6VCC8p.d.mts +553 -0
- package/dist/side-sheet-modal-CglP6KYA.d.ts +553 -0
- package/dist/split-button-trailing-uncheckable-C5CLCIKP.d.ts +731 -0
- package/dist/split-button-trailing-uncheckable-MXj_kyNt.d.mts +731 -0
- package/dist/text-field-eAIpz9z1.d.mts +1038 -0
- package/dist/text-field-eAIpz9z1.d.ts +1038 -0
- package/dist/typography-339RV6v7.d.mts +486 -0
- package/dist/typography-339RV6v7.d.ts +486 -0
- package/dist/typography.css +22 -0
- package/dist/typography.css.d.ts +2 -0
- package/package.json +207 -0
|
@@ -0,0 +1,2321 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useReducedMotion, LazyMotion, domMax, m, useMotionValue, animate, useAnimationFrame, AnimatePresence } from 'motion/react';
|
|
3
|
+
import * as React12 from 'react';
|
|
4
|
+
import { forwardRef, useState, useCallback, useEffect, useRef, useId, cloneElement, useLayoutEffect } from 'react';
|
|
5
|
+
import { clsx } from 'clsx';
|
|
6
|
+
import { twMerge } from 'tailwind-merge';
|
|
7
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
9
|
+
import { createPortal } from 'react-dom';
|
|
10
|
+
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __defProps = Object.defineProperties;
|
|
13
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
14
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
17
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
18
|
+
var __spreadValues = (a, b) => {
|
|
19
|
+
for (var prop in b || (b = {}))
|
|
20
|
+
if (__hasOwnProp.call(b, prop))
|
|
21
|
+
__defNormalProp(a, prop, b[prop]);
|
|
22
|
+
if (__getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
24
|
+
if (__propIsEnum.call(b, prop))
|
|
25
|
+
__defNormalProp(a, prop, b[prop]);
|
|
26
|
+
}
|
|
27
|
+
return a;
|
|
28
|
+
};
|
|
29
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
30
|
+
var __objRest = (source, exclude) => {
|
|
31
|
+
var target = {};
|
|
32
|
+
for (var prop in source)
|
|
33
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
34
|
+
target[prop] = source[prop];
|
|
35
|
+
if (source != null && __getOwnPropSymbols)
|
|
36
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
37
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
38
|
+
target[prop] = source[prop];
|
|
39
|
+
}
|
|
40
|
+
return target;
|
|
41
|
+
};
|
|
42
|
+
function cn(...inputs) {
|
|
43
|
+
return twMerge(clsx(inputs));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/ui/shared/motion-tokens.ts
|
|
47
|
+
var FAST_SPATIAL_SPRING = {
|
|
48
|
+
type: "spring",
|
|
49
|
+
stiffness: 800,
|
|
50
|
+
damping: 33.94
|
|
51
|
+
};
|
|
52
|
+
var DEFAULT_SPATIAL_SPRING = {
|
|
53
|
+
type: "spring",
|
|
54
|
+
stiffness: 380,
|
|
55
|
+
damping: 31.19
|
|
56
|
+
};
|
|
57
|
+
var FAST_EFFECTS_SPRING = {
|
|
58
|
+
type: "spring",
|
|
59
|
+
stiffness: 3800,
|
|
60
|
+
damping: 123.29
|
|
61
|
+
};
|
|
62
|
+
var DEFAULT_EFFECTS_SPRING = {
|
|
63
|
+
type: "spring",
|
|
64
|
+
stiffness: 1600,
|
|
65
|
+
damping: 80
|
|
66
|
+
};
|
|
67
|
+
function formatBadgeLabel(children, max) {
|
|
68
|
+
if (typeof children === "number") {
|
|
69
|
+
return max !== void 0 && children > max ? `${max}+` : String(children);
|
|
70
|
+
}
|
|
71
|
+
if (typeof children === "string") {
|
|
72
|
+
if (max !== void 0) {
|
|
73
|
+
const asNum = Number(children);
|
|
74
|
+
if (!Number.isNaN(asNum) && asNum > max) return `${max}+`;
|
|
75
|
+
}
|
|
76
|
+
return children.length > 4 ? children.slice(0, 4) : children;
|
|
77
|
+
}
|
|
78
|
+
return "";
|
|
79
|
+
}
|
|
80
|
+
function detectBadgeHasContent(badge) {
|
|
81
|
+
return React12.isValidElement(badge) && badge.props.children != null;
|
|
82
|
+
}
|
|
83
|
+
var BadgeImpl = React12.forwardRef(
|
|
84
|
+
(_a, ref) => {
|
|
85
|
+
var _b = _a, {
|
|
86
|
+
children,
|
|
87
|
+
max,
|
|
88
|
+
containerColor,
|
|
89
|
+
contentColor,
|
|
90
|
+
className,
|
|
91
|
+
style,
|
|
92
|
+
"aria-label": ariaLabel
|
|
93
|
+
} = _b, props = __objRest(_b, [
|
|
94
|
+
"children",
|
|
95
|
+
"max",
|
|
96
|
+
"containerColor",
|
|
97
|
+
"contentColor",
|
|
98
|
+
"className",
|
|
99
|
+
"style",
|
|
100
|
+
"aria-label"
|
|
101
|
+
]);
|
|
102
|
+
const hasContent = children != null;
|
|
103
|
+
const label = hasContent ? formatBadgeLabel(children, max) : "";
|
|
104
|
+
const reducedMotion = useReducedMotion();
|
|
105
|
+
const isDecorative = !hasContent && !ariaLabel;
|
|
106
|
+
const springTransition = reducedMotion ? { duration: 0 } : FAST_SPATIAL_SPRING;
|
|
107
|
+
const colorStyle = __spreadValues(__spreadValues(__spreadValues({}, containerColor && { backgroundColor: containerColor }), contentColor && { color: contentColor }), style);
|
|
108
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
|
|
109
|
+
m.span,
|
|
110
|
+
__spreadProps(__spreadValues({
|
|
111
|
+
ref,
|
|
112
|
+
role: isDecorative ? void 0 : "status",
|
|
113
|
+
"aria-hidden": isDecorative ? "true" : void 0,
|
|
114
|
+
"aria-label": hasContent ? ariaLabel != null ? ariaLabel : label : ariaLabel,
|
|
115
|
+
initial: { scale: 0, opacity: 0 },
|
|
116
|
+
animate: { scale: 1, opacity: 1 },
|
|
117
|
+
exit: { scale: 0, opacity: 0 },
|
|
118
|
+
transition: springTransition,
|
|
119
|
+
className: cn(
|
|
120
|
+
"rounded-full ring-[1.5px] ring-m3-surface",
|
|
121
|
+
!containerColor && "bg-m3-error",
|
|
122
|
+
hasContent ? cn(
|
|
123
|
+
"inline-flex items-center justify-center",
|
|
124
|
+
"min-w-4 h-4 px-1 text-[11px] font-medium leading-none",
|
|
125
|
+
!contentColor && "text-m3-on-error"
|
|
126
|
+
) : "inline-block w-1.5 h-1.5",
|
|
127
|
+
className
|
|
128
|
+
),
|
|
129
|
+
style: colorStyle
|
|
130
|
+
}, props), {
|
|
131
|
+
children: hasContent && label
|
|
132
|
+
})
|
|
133
|
+
) });
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
BadgeImpl.displayName = "Badge";
|
|
137
|
+
var Badge = React12.memo(BadgeImpl);
|
|
138
|
+
function BadgedBox({
|
|
139
|
+
badge,
|
|
140
|
+
children,
|
|
141
|
+
className,
|
|
142
|
+
badgeSize
|
|
143
|
+
}) {
|
|
144
|
+
const isLarge = badgeSize ? badgeSize === "large" : detectBadgeHasContent(badge);
|
|
145
|
+
const badgePositionClass = isLarge ? "translate-x-[35%] -translate-y-[35%]" : "translate-x-[50%] -translate-y-[50%]";
|
|
146
|
+
return /* @__PURE__ */ jsxs("span", { className: cn("relative inline-flex", className), children: [
|
|
147
|
+
children,
|
|
148
|
+
/* @__PURE__ */ jsx(
|
|
149
|
+
"span",
|
|
150
|
+
{
|
|
151
|
+
className: cn("absolute right-0 top-0", badgePositionClass),
|
|
152
|
+
"aria-hidden": "true",
|
|
153
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: badge })
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
] });
|
|
157
|
+
}
|
|
158
|
+
var SHAPE_KEY_TIMES = "0; 0.14; 0.14; 0.29; 0.29; 0.43; 0.43; 0.57; 0.57; 0.71; 0.71; 0.86; 0.86; 1";
|
|
159
|
+
var SHAPE_KEY_SPLINES = [
|
|
160
|
+
"0.5 0.2 0 0.8",
|
|
161
|
+
"0.5 0.2 0 0.8",
|
|
162
|
+
"0.5 0.2 0 0.8",
|
|
163
|
+
"0.5 0.2 0 0.8",
|
|
164
|
+
"0.5 0.2 0 0.8",
|
|
165
|
+
"0.5 0.2 0 0.8",
|
|
166
|
+
"0.5 0.2 0 0.8",
|
|
167
|
+
"0.5 0.2 0 0.8",
|
|
168
|
+
"0.5 0.2 0 0.8",
|
|
169
|
+
"0.5 0.2 0 0.8",
|
|
170
|
+
"0.5 0.2 0 0.8",
|
|
171
|
+
"0.5 0.2 0 0.8",
|
|
172
|
+
"0.5 0.2 0 0.8"
|
|
173
|
+
].join("; ");
|
|
174
|
+
var SHAPE_VALUES = [
|
|
175
|
+
"M20.9 10.4 21.4 9.5 21.9 8.7 22.5 7.8 23.2 7.2 24.2 7 25.1 7.4 25.7 8.1 26.2 9 26.8 9.8 27.3 10.6 28.1 11.2 29 11.3 30 11 30.9 10.6 31.8 10.3 32.8 9.9 33.7 10 34.5 10.6 34.9 11.5 34.8 12.5 34.8 13.5 34.7 14.5 34.7 15.5 35.2 16.3 36 16.8 37 17.1 37.9 17.3 38.9 17.5 39.8 17.9 40.4 18.7 40.5 19.7 40 20.5 39.4 21.3 38.7 22 38.1 22.8 37.6 23.7 37.7 24.6 38.3 25.5 38.9 26.2 39.6 27 40.2 27.7 40.5 28.7 40.3 29.6 39.5 30.3 38.6 30.6 37.6 30.8 36.7 31 35.7 31.3 35 31.9 34.6 32.8 34.7 33.8 34.8 34.8 34.9 35.8 34.8 36.8 34.3 37.6 33.4 38.1 32.4 38 31.5 37.6 30.6 37.2 29.7 36.9 28.7 36.6 27.8 36.9 27.1 37.6 26.6 38.5 26.1 39.3 25.5 40.2 24.8 40.8 23.8 41 22.9 40.6 22.3 39.9 21.8 39 21.2 38.2 20.7 37.4 19.9 36.8 19 36.7 18 37 17.1 37.4 16.2 37.7 15.2 38.1 14.3 38 13.5 37.4 13.1 36.5 13.2 35.5 13.2 34.5 13.3 33.5 13.3 32.5 12.8 31.7 12 31.2 11 31 10.1 30.7 9.1 30.5 8.2 30.1 7.6 29.3 7.5 28.3 8 27.5 8.7 26.7 9.3 26 9.9 25.2 10.4 24.3 10.3 23.4 9.7 22.5 9.1 21.8 8.4 21 7.8 20.3 7.5 19.3 7.7 18.4 8.5 17.7 9.4 17.4 10.4 17.2 11.3 17 12.3 16.7 13 16.1 13.4 15.2 13.3 14.2 13.2 13.2 13.1 12.2 13.2 11.2 13.7 10.4 14.6 9.9 15.6 10 16.5 10.4 17.4 10.8 18.3 11.1 19.3 11.4 20.2 11.1Z",
|
|
176
|
+
"M20.3 8.6 21.1 8 22 7.6 23 7.3 23 7.3 24 7.2 25 7.3 25.9 7.5 26.8 8 27.6 8.6 28.4 9.1 28.4 9.1 29.3 9.6 30.3 9.8 31.3 9.9 32.3 10 33.3 10.2 34.2 10.6 34.2 10.6 35 11.2 35.7 11.9 36.3 12.7 36.7 13.6 36.9 14.6 37.2 15.5 37.2 15.5 37.6 16.5 38.2 17.3 38.9 18 39.6 18.7 40.2 19.5 40.6 20.4 40.6 20.4 40.9 21.3 41 22.3 40.9 23.3 40.6 24.3 40.2 25.2 39.8 26.1 39.8 26.1 39.5 27 39.4 28 39.5 29 39.6 30 39.5 31 39.3 32 39.3 32 38.9 32.9 38.3 33.7 37.6 34.4 36.8 35 35.9 35.4 35 35.8 35 35.8 34.1 36.3 33.4 37 32.9 37.9 32.3 38.7 31.6 39.4 30.8 40 30.8 40 29.9 40.4 28.9 40.7 27.9 40.8 27 40.7 26 40.4 25 40.1 25 40.1 24 40 23 40.1 22.1 40.4 21.1 40.7 20.1 40.8 19.1 40.7 19.1 40.7 18.2 40.5 17.3 40 16.4 39.5 15.7 38.8 15.2 37.9 14.6 37.1 14.6 37.1 13.9 36.4 13.1 35.8 12.2 35.4 11.3 35 10.5 34.4 9.7 33.8 9.7 33.8 9.1 32.9 8.7 32 8.5 31.1 8.4 30.1 8.5 29.1 8.6 28.1 8.6 28.1 8.5 27.1 8.3 26.1 7.8 25.2 7.4 24.3 7.1 23.4 7 22.4 7 22.4 7.1 21.4 7.3 20.4 7.8 19.5 8.3 18.7 9.1 18 9.8 17.3 9.8 17.3 10.4 16.5 10.8 15.6 11 14.6 11.3 13.7 11.7 12.8 12.2 11.9 12.2 11.9 12.9 11.2 13.8 10.7 14.7 10.2 15.6 10 16.6 9.9 17.6 9.8 17.6 9.8 18.6 9.6 19.5 9.2Z",
|
|
177
|
+
"M18.6 9.6 19.5 9.2 20.3 8.6 21.1 8 22 7.6 23 7.3 24 7.2 25 7.3 25.9 7.5 26.8 8 27.6 8.6 28.4 9.1 29.3 9.6 30.3 9.8 31.3 9.9 32.3 10 33.3 10.2 34.2 10.6 35 11.2 35.7 11.9 36.3 12.7 36.7 13.6 36.9 14.6 37.2 15.5 37.6 16.4 38.2 17.3 38.9 18 39.6 18.7 40.2 19.5 40.6 20.4 40.9 21.3 41 22.3 40.9 23.3 40.6 24.3 40.2 25.2 39.8 26.1 39.5 27 39.4 28 39.5 29 39.6 30 39.5 31 39.3 32 38.9 32.9 38.3 33.7 37.6 34.4 36.8 35 35.9 35.4 35 35.8 34.1 36.3 33.4 37 32.9 37.9 32.3 38.7 31.6 39.4 30.8 40 29.9 40.4 28.9 40.7 27.9 40.8 27 40.7 26 40.4 25 40.1 24 40 23 40.1 22.1 40.4 21.1 40.7 20.1 40.8 19.1 40.7 18.2 40.5 17.3 40 16.4 39.5 15.7 38.8 15.2 37.9 14.6 37.1 13.9 36.4 13.1 35.8 12.2 35.4 11.3 35 10.5 34.4 9.7 33.8 9.1 32.9 8.7 32 8.5 31.1 8.4 30.1 8.5 29.1 8.6 28.1 8.5 27.1 8.3 26.1 7.8 25.2 7.4 24.3 7.1 23.4 7 22.4 7.1 21.4 7.3 20.4 7.8 19.5 8.3 18.7 9.1 18 9.8 17.3 10.4 16.5 10.8 15.6 11 14.6 11.3 13.7 11.7 12.8 12.2 11.9 12.9 11.2 13.8 10.7 14.7 10.2 15.6 10 16.6 9.9 17.6 9.8Z",
|
|
178
|
+
"M18.6 9.9 19.5 9.4 20.3 8.8 21.1 8.2 22 7.8 23 7.6 23.9 7.5 24.9 7.6 25.9 7.8 26.8 8.2 27.6 8.7 28.5 9.3 29.3 9.9 30.1 10.5 30.9 11 31.7 11.6 32.5 12.2 33.3 12.8 33.7 13.1 34.1 13.3 34.9 13.9 35.7 14.5 36.6 15 37.4 15.6 38.2 16.2 39 16.8 39.7 17.5 40.2 18.3 40.7 19.2 40.9 20.1 41 21.1 40.9 22.1 40.7 23.1 40.3 24 40 24.9 39.7 25.9 39.4 26.8 39 27.8 38.7 28.7 38.4 29.6 38.1 30.6 37.8 31.5 37.5 32.5 37.2 33.4 36.9 34.4 36.6 35.3 36.2 36.2 35.7 37.1 35 37.8 34.3 38.4 33.4 38.9 32.5 39.3 31.5 39.5 30.5 39.5 30 39.5 29.5 39.5 28.5 39.5 27.5 39.5 26.5 39.5 25.5 39.4 24.5 39.4 23.6 39.4 22.6 39.4 21.6 39.5 20.6 39.5 19.6 39.5 18.6 39.5 17.6 39.5 16.6 39.5 15.6 39.3 14.7 39 13.8 38.5 13.1 37.9 12.4 37.2 11.9 36.3 11.5 35.4 11.2 34.5 10.9 33.5 10.6 32.6 10.3 31.6 10 30.7 9.7 29.7 9.3 28.8 9 27.9 8.7 26.9 8.4 26 8 25 7.7 24.1 7.4 23.2 7.1 22.2 7.1 21.7 7 21.2 7.1 20.2 7.3 19.3 7.7 18.4 8.3 17.5 8.9 16.8 9.7 16.2 10.5 15.6 11.4 15.1 12.2 14.5 13 14 13.8 13.4 14.6 12.8 15.4 12.3 16.2 11.7 17 11.1 17.8 10.5Z",
|
|
179
|
+
"M15.4 12.3 16.2 11.7 17 11.1 17.8 10.5 18.6 9.9 19.5 9.4 20.3 8.8 21.1 8.3 22 7.8 23 7.6 23.9 7.5 24.9 7.6 25.9 7.8 26.8 8.2 27.6 8.7 28.5 9.3 29.3 9.9 30.1 10.5 30.9 11 31.7 11.6 32.5 12.2 33.3 12.8 34.1 13.3 34.9 13.9 35.7 14.5 36.6 15 37.4 15.6 38.2 16.2 39 16.8 39.7 17.5 40.2 18.3 40.7 19.2 40.9 20.1 41 21.1 40.9 22.1 40.7 23.1 40.3 24 40 24.9 39.7 25.9 39.4 26.8 39 27.8 38.7 28.7 38.4 29.6 38.1 30.6 37.8 31.5 37.5 32.5 37.2 33.4 36.9 34.4 36.6 35.3 36.2 36.2 35.7 37.1 35 37.8 34.3 38.4 33.4 38.9 32.5 39.3 31.5 39.4 30.5 39.5 29.5 39.5 28.5 39.5 27.5 39.5 26.5 39.5 25.5 39.4 24.5 39.4 23.6 39.4 22.6 39.4 21.6 39.5 20.6 39.5 19.6 39.5 18.6 39.5 17.6 39.5 16.6 39.5 15.6 39.3 14.7 39 13.8 38.5 13.1 37.9 12.4 37.2 11.9 36.3 11.5 35.4 11.2 34.5 10.9 33.5 10.6 32.6 10.3 31.6 10 30.7 9.7 29.7 9.3 28.8 9 27.9 8.7 26.9 8.4 26 8 25 7.7 24.1 7.4 23.2 7.1 22.2 7 21.2 7.1 20.2 7.3 19.3 7.7 18.4 8.3 17.5 8.9 16.8 9.7 16.2 10.5 15.6 11.4 15.1 12.2 14.5 13 14 13.8 13.4 14.6 12.8Z",
|
|
180
|
+
"M17 12.8 17.7 12.1 18.5 11.5 19.3 10.9 20.1 10.5 20.2 10.4 21.1 10 22 9.7 23 9.4 24 9.2 25 9 26 9 27 9 27.6 9.1 28 9.1 28.9 9.3 29.9 9.6 30.9 9.9 31.8 10.3 32.6 10.8 33.5 11.3 34.3 11.9 34.6 12.2 35 12.6 35.7 13.3 36.4 14.1 36.9 14.9 37.4 15.8 37.9 16.6 38.3 17.6 38.6 18.5 38.6 18.7 38.8 19.5 38.9 20.5 39 21.5 39 22.5 38.9 23.5 38.7 24.5 38.5 25.4 38.2 26.3 38.2 26.4 37.8 27.3 37.4 28.2 36.8 29.1 36.2 29.9 35.6 30.6 34.9 31.3 34.2 32 33.8 32.5 33.5 32.8 32.8 33.5 32.1 34.2 31.4 34.9 30.7 35.6 29.9 36.2 29.1 36.8 28.2 37.3 27.9 37.5 27.4 37.8 26.4 38.2 25.5 38.5 24.5 38.7 23.5 38.9 22.5 39 21.5 39 20.5 38.9 20.4 38.9 19.5 38.8 18.6 38.6 17.6 38.3 16.7 37.9 15.8 37.5 14.9 37 14.1 36.4 13.4 35.8 13.3 35.8 12.6 35.1 12 34.3 11.3 33.5 10.8 32.7 10.3 31.8 9.9 30.9 9.6 30 9.4 29.3 9.3 29 9.1 28 9 27 9 26 9 25 9.2 24 9.4 23 9.6 22.1 9.8 21.7 10 21.1 10.4 20.2 10.9 19.4 11.4 18.5 12.1 17.8 12.7 17 13.4 16.3 14.2 15.6 14.2 15.5 14.9 14.9 15.6 14.2 16.3 13.5Z",
|
|
181
|
+
"M33.5 11.3 34.3 11.9 35 12.6 35.3 12.8 35.7 13.3 36.4 14.1 36.9 14.9 37.4 15.8 37.9 16.6 38.3 17.6 38.3 17.7 38.6 18.5 38.8 19.5 38.9 20.5 39 21.5 39 22.5 38.9 23.5 38.9 23.5 38.7 24.5 38.5 25.4 38.2 26.4 37.8 27.3 37.4 28.2 36.9 28.9 36.8 29.1 36.2 29.9 35.6 30.6 34.9 31.3 34.2 32 33.5 32.8 33.1 33.2 32.8 33.5 32.1 34.2 31.4 34.9 30.7 35.6 29.9 36.2 29.1 36.8 28.7 37 28.2 37.3 27.4 37.8 26.4 38.2 25.5 38.5 24.5 38.7 23.5 38.9 23.3 38.9 22.5 39 21.5 39 20.5 38.9 19.5 38.8 18.6 38.6 17.6 38.3 17.6 38.3 16.7 37.9 15.8 37.5 14.9 37 14.1 36.4 13.3 35.8 12.7 35.2 12.6 35.1 12 34.3 11.3 33.5 10.8 32.7 10.3 31.8 9.9 30.9 9.7 30.3 9.6 29.9 9.3 29 9.1 28 9 27 9 26 9 25 9.1 24.5 9.2 24 9.4 23 9.6 22.1 10 21.1 10.4 20.2 10.9 19.4 11.1 19.1 11.5 18.5 12.1 17.7 12.7 17 13.5 16.3 14.2 15.6 14.9 14.9 14.9 14.8 15.6 14.2 16.3 13.5 17 12.8 17.7 12.1 18.5 11.5 19.3 11 19.3 10.9 20.2 10.4 21.1 10 22 9.7 23 9.4 24 9.2 24.7 9.1 25 9 26 9 27 9 28 9.1 28.9 9.3 29.9 9.6 30.4 9.7 30.9 9.9 31.8 10.3 32.6 10.8Z",
|
|
182
|
+
"M33.2 11.1 34.2 11.2 35.1 11.4 36 11.9 36.6 12.7 36.8 13.7 36.9 14.7 36.9 15.7 37 16.7 37.1 17.7 37.3 18.6 37.9 19.4 38.5 20.2 39.2 20.9 39.8 21.7 40.5 22.4 40.9 23.3 41 24.3 40.7 25.2 40.1 26 39.4 26.8 38.8 27.5 38.1 28.3 37.5 29.1 37.1 30 37 31 37 31.9 36.9 32.9 36.8 33.9 36.7 34.9 36.2 35.8 35.5 36.4 34.5 36.8 33.6 36.8 32.6 36.9 31.6 37 30.6 37.1 29.6 37.2 28.8 37.7 28 38.4 27.3 39 26.5 39.7 25.8 40.3 24.9 40.8 23.9 41 23 40.8 22.1 40.2 21.4 39.6 20.6 38.9 19.9 38.3 19.1 37.6 18.3 37.2 17.3 37 16.3 37 15.3 36.9 14.3 36.8 13.3 36.7 12.4 36.4 11.7 35.7 11.3 34.8 11.2 33.8 11.1 32.8 11 31.8 11 30.8 10.9 29.9 10.4 29 9.8 28.2 9.1 27.5 8.5 26.7 7.8 26 7.3 25.1 7 24.2 7.1 23.2 7.6 22.3 8.2 21.6 8.9 20.8 9.5 20.1 10.2 19.3 10.7 18.5 10.9 17.5 11 16.6 11.1 15.6 11.1 14.6 11.2 13.6 11.5 12.6 12.1 11.9 13 11.4 13.9 11.2 14.9 11.1 15.9 11 16.9 11 17.9 10.9 18.8 10.6 19.6 10 20.4 9.3 21.1 8.6 21.9 8 22.6 7.4 23.6 7 24.6 7.1 25.5 7.5 26.2 8.1 27 8.7 27.7 9.4 28.5 10 29.3 10.6 30.2 10.9 31.2 11 32.2 11.1Z",
|
|
183
|
+
"M27.7 9.4 28.5 10 29.3 10.6 30.2 10.9 31.2 11 32.2 11.1 33.2 11.1 34.2 11.2 35.1 11.4 36 11.9 36.6 12.7 36.8 13.7 36.9 14.7 36.9 15.7 37 16.7 37.1 17.7 37.3 18.6 37.9 19.4 38.5 20.2 39.2 20.9 39.8 21.7 40.5 22.4 40.9 23.3 41 24.3 40.7 25.2 40.1 26 39.4 26.8 38.8 27.5 38.1 28.3 37.5 29.1 37.1 30 37 31 37 31.9 36.9 32.9 36.8 33.9 36.7 34.9 36.2 35.8 35.5 36.4 34.5 36.8 33.6 36.9 32.6 36.9 31.6 37 30.6 37.1 29.6 37.2 28.8 37.7 28 38.4 27.3 39 26.5 39.7 25.8 40.3 24.9 40.8 23.9 41 23 40.8 22.1 40.2 21.4 39.6 20.6 38.9 19.9 38.3 19.1 37.6 18.3 37.2 17.3 37 16.3 37 15.3 36.9 14.3 36.8 13.3 36.7 12.4 36.4 11.7 35.7 11.3 34.8 11.2 33.8 11.1 32.8 11 31.8 11 30.8 10.9 29.9 10.4 29 9.8 28.2 9.1 27.5 8.5 26.7 7.8 26 7.3 25.1 7 24.2 7.1 23.2 7.6 22.3 8.2 21.6 8.9 20.8 9.5 20.1 10.2 19.3 10.7 18.5 10.9 17.5 11 16.5 11.1 15.6 11.1 14.6 11.2 13.6 11.5 12.6 12.1 11.9 13 11.4 13.9 11.2 14.9 11.1 15.9 11 16.9 11 17.9 10.9 18.8 10.6 19.6 10 20.4 9.3 21.1 8.6 21.9 8 22.6 7.4 23.6 7 24.6 7.1 25.5 7.5 26.2 8.1 27 8.7Z",
|
|
184
|
+
"M27.9 10.6 28.8 10.3 29.8 10.1 30.8 10 31.8 10.1 32.7 10.3 33.7 10.6 34.6 11.1 34.8 11.3 35.4 11.7 36.1 12.4 36.7 13.1 37.2 14 37.6 14.9 37.9 15.9 38 16.9 38 17.9 37.8 18.8 37.5 19.8 37.1 20.7 36.8 21.6 36.5 22.6 36.4 23.6 36.4 24.4 36.4 24.6 36.5 25.5 36.8 26.5 37.2 27.4 37.6 28.3 37.8 29.3 38 30.3 38 31.3 37.8 32.3 37.6 33.2 37.2 34.1 36.6 35 36 35.7 35.3 36.4 34.4 37 34.1 37.2 33.6 37.4 32.6 37.8 31.6 37.9 30.6 38 29.7 37.9 28.7 37.7 27.8 37.3 26.8 36.9 25.9 36.6 24.9 36.4 23.9 36.4 22.9 36.4 22 36.6 21 37 20.1 37.4 20.1 37.4 19.2 37.7 18.2 37.9 17.2 38 16.2 37.9 15.3 37.7 14.3 37.4 13.4 36.9 12.6 36.3 11.9 35.6 11.3 34.9 10.8 34 10.4 33.1 10.1 32.1 10 31.1 10 30.6 10 30.1 10.2 29.2 10.5 28.2 10.9 27.3 11.2 26.4 11.5 25.4 11.6 24.4 11.6 23.4 11.5 22.5 11.2 21.5 10.8 20.6 10.4 19.7 10.2 18.7 10 17.7 10 16.7 10 16.6 10.2 15.7 10.4 14.8 10.8 13.9 11.4 13 12 12.3 12.7 11.6 13.6 11 14.4 10.6 15.4 10.2 16.4 10.1 17.4 10 18.3 10.1 19.3 10.3 20.2 10.7 20.9 11 21.2 11.1 22.1 11.4 23.1 11.6 24.1 11.6 25.1 11.6 26 11.4 27 11Z",
|
|
185
|
+
"M36 35.7 35.3 36.4 34.4 37 33.6 37.4 32.6 37.8 31.6 37.9 30.6 38 29.7 37.9 28.7 37.7 27.8 37.3 26.8 36.9 25.9 36.6 24.9 36.4 23.9 36.4 22.9 36.4 22 36.6 21 37 20.1 37.4 19.2 37.7 18.2 37.9 17.2 38 16.2 37.9 15.3 37.7 14.3 37.4 13.4 36.9 12.6 36.3 11.9 35.6 11.3 34.9 10.8 34 10.4 33.1 10.1 32.1 10 31.1 10 30.2 10.2 29.2 10.5 28.2 10.9 27.3 11.2 26.4 11.5 25.4 11.6 24.4 11.6 23.4 11.5 22.5 11.2 21.5 10.8 20.6 10.4 19.7 10.2 18.7 10 17.7 10 16.7 10.2 15.7 10.4 14.8 10.8 13.9 11.4 13 12 12.3 12.7 11.6 13.6 11 14.4 10.6 15.4 10.2 16.4 10.1 17.4 10 18.3 10.1 19.3 10.3 20.2 10.7 21.2 11.1 22.1 11.4 23.1 11.6 24.1 11.6 25.1 11.6 26 11.4 27 11 27.9 10.6 28.8 10.3 29.8 10.1 30.8 10 31.8 10.1 32.7 10.3 33.7 10.6 34.6 11.1 35.4 11.7 36.1 12.4 36.7 13.1 37.2 14 37.6 14.9 37.9 15.9 38 16.9 38 17.8 37.8 18.8 37.5 19.8 37.1 20.7 36.8 21.6 36.5 22.6 36.4 23.6 36.4 24.6 36.5 25.5 36.8 26.5 37.2 27.4 37.6 28.3 37.8 29.3 38 30.3 38 31.3 37.8 32.3 37.6 33.2 37.2 34.1 36.6 35Z",
|
|
186
|
+
"M32.1 32.1 31.4 32.8 30.7 33.5 29.9 34.1 29.1 34.7 28.3 35.3 27.6 35.8 27.5 35.8 26.6 36.4 25.8 36.8 24.9 37.3 24 37.7 23.1 38 22.1 38.3 21.2 38.6 20.2 38.8 19.2 38.9 18.2 39 17.2 39 16.6 38.9 16.3 38.9 15.3 38.7 14.3 38.4 13.4 38 12.5 37.5 11.7 36.9 11.1 36.3 10.5 35.5 10 34.6 9.6 33.7 9.3 32.7 9.1 31.7 9.1 31.4 9 30.8 9 29.8 9.1 28.8 9.2 27.8 9.4 26.8 9.7 25.9 10 24.9 10.3 24 10.7 23.1 11.2 22.2 11.6 21.4 12.2 20.5 12.2 20.4 12.7 19.7 13.3 18.9 13.9 18.1 14.5 17.3 15.2 16.6 15.9 15.9 16.6 15.2 17.3 14.5 18.1 13.9 18.9 13.3 19.7 12.7 20.4 12.2 20.5 12.2 21.4 11.6 22.2 11.2 23.1 10.7 24 10.3 24.9 10 25.9 9.7 26.8 9.4 27.8 9.2 28.8 9.1 29.8 9 30.8 9 31.4 9.1 31.7 9.1 32.7 9.3 33.7 9.6 34.6 10 35.5 10.5 36.3 11.1 36.9 11.7 37.5 12.5 38 13.4 38.4 14.3 38.7 15.3 38.9 16.3 38.9 16.6 39 17.2 39 18.2 38.9 19.2 38.8 20.2 38.6 21.2 38.3 22.1 38 23.1 37.7 24 37.3 24.9 36.8 25.8 36.4 26.6 35.8 27.5 35.8 27.6 35.3 28.3 34.7 29.1 34.1 29.9 33.5 30.7 32.8 31.4Z",
|
|
187
|
+
"M24.3 10.2 24.9 10 25.9 9.7 26.8 9.4 27.1 9.4 27.8 9.2 28.8 9.1 29.8 9 29.9 9 30.8 9 31.7 9.1 32.7 9.3 32.8 9.3 33.7 9.6 34.6 10 35.5 10.5 35.5 10.5 36.3 11.1 36.9 11.7 37.5 12.5 37.5 12.5 38 13.4 38.4 14.3 38.7 15.2 38.7 15.3 38.9 16.3 39 17.2 39 18.1 39 18.2 38.9 19.2 38.8 20.2 38.6 20.9 38.6 21.2 38.3 22.1 38 23.1 37.8 23.7 37.7 24 37.3 24.9 36.8 25.8 36.5 26.4 36.4 26.6 35.8 27.5 35.3 28.3 35 28.8 34.7 29.1 34.1 29.9 33.5 30.7 33.1 31.1 32.8 31.4 32.1 32.1 31.4 32.8 31.1 33.1 30.7 33.5 29.9 34.1 29.1 34.7 28.8 35 28.3 35.3 27.5 35.8 26.6 36.4 26.4 36.5 25.8 36.8 24.9 37.3 24 37.7 23.7 37.8 23.1 38 22.1 38.3 21.2 38.6 20.9 38.6 20.2 38.8 19.2 38.9 18.2 39 18.1 39 17.2 39 16.3 38.9 15.3 38.7 15.2 38.7 14.3 38.4 13.4 38 12.5 37.5 12.5 37.5 11.7 36.9 11.1 36.3 10.5 35.5 10.5 35.5 10 34.6 9.6 33.7 9.3 32.8 9.3 32.7 9.1 31.7 9 30.8 9 29.9 9 29.8 9.1 28.8 9.2 27.8 9.4 27.1 9.4 26.8 9.7 25.9 10 24.9 10.2 24.3 10.3 24 10.7 23.1 11.2 22.2 11.5 21.6 11.6 21.4 12.2 20.5 12.7 19.7 13 19.2 13.3 18.9 13.9 18.1 14.5 17.3 14.9 16.9 15.2 16.6 15.9 15.9 16.6 15.2 16.9 14.9 17.3 14.5 18.1 13.9 18.9 13.3 19.2 13 19.7 12.7 20.5 12.2 21.4 11.6 21.6 11.5 22.2 11.2 23.1 10.7 24 10.3Z",
|
|
188
|
+
"M22.5 7.8 23.2 7.2 24.2 7 25.1 7.4 25.7 8.1 26.2 9 26.8 9.8 27.3 10.6 28.1 11.2 29 11.3 30 11 30.9 10.6 31.8 10.3 32.8 9.9 33.7 10 34.5 10.6 34.9 11.5 34.8 12.5 34.8 13.5 34.7 14.5 34.7 15.5 35.2 16.3 36 16.8 37 17 37.9 17.3 38.9 17.5 39.8 17.9 40.4 18.7 40.5 19.7 40 20.5 39.3 21.3 38.7 22 38.1 22.8 37.6 23.7 37.7 24.6 38.3 25.4 38.9 26.2 39.6 27 40.2 27.7 40.5 28.6 40.3 29.6 39.5 30.3 38.6 30.6 37.6 30.8 36.7 31 35.7 31.3 35 31.9 34.6 32.8 34.7 33.8 34.8 34.8 34.8 35.8 34.8 36.8 34.3 37.6 33.4 38.1 32.4 38 31.5 37.6 30.6 37.2 29.7 36.9 28.7 36.6 27.8 36.9 27.1 37.6 26.6 38.5 26.1 39.3 25.5 40.2 24.8 40.8 23.8 41 22.9 40.6 22.3 39.9 21.8 39 21.2 38.2 20.7 37.4 19.9 36.8 19 36.7 18 37 17.1 37.4 16.2 37.7 15.2 38.1 14.3 38 13.5 37.4 13.1 36.5 13.2 35.5 13.2 34.5 13.3 33.5 13.3 32.5 12.8 31.7 12 31.2 11 31 10.1 30.7 9.1 30.5 8.2 30.1 7.6 29.3 7.5 28.3 8 27.5 8.7 26.7 9.3 26 9.9 25.2 10.4 24.3 10.3 23.4 9.7 22.6 9.1 21.8 8.4 21 7.8 20.3 7.5 19.4 7.7 18.4 8.5 17.7 9.4 17.4 10.4 17.2 11.3 17 12.3 16.7 13 16.1 13.4 15.2 13.3 14.2 13.2 13.2 13.2 12.2 13.2 11.2 13.7 10.4 14.6 9.9 15.6 10 16.5 10.4 17.4 10.8 18.3 11.1 19.3 11.4 20.2 11.1 20.9 10.4 21.4 9.5 21.9 8.7Z"
|
|
189
|
+
].join(";");
|
|
190
|
+
var ROTATE_KEY_TIMES = "0; 0.14; 0.29; 0.43; 0.57; 0.71; 0.86; 1";
|
|
191
|
+
var ROTATE_KEY_SPLINES = [
|
|
192
|
+
"0.5 0.2 0 0.8",
|
|
193
|
+
"0.5 0.2 0 0.8",
|
|
194
|
+
"0.5 0.2 0 0.8",
|
|
195
|
+
"0.5 0.2 0 0.8",
|
|
196
|
+
"0.5 0.2 0 0.8",
|
|
197
|
+
"0.5 0.2 0 0.8",
|
|
198
|
+
"0.5 0.2 0 0.8"
|
|
199
|
+
].join("; ");
|
|
200
|
+
var ROTATE_VALUES = "0 24 24; 154 24 24; 309 24 24; 463 24 24; 617 24 24; 771 24 24; 926 24 24; 1080 24 24";
|
|
201
|
+
var DETERMINATE_CIRCLE = "M24 7 C34.49 7 41 13.51 41 24 C41 34.49 34.49 41 24 41 C13.51 41 7 34.49 7 24 C7 13.51 13.51 7 24 7 Z";
|
|
202
|
+
var DETERMINATE_SOFT_BURST = "M20.9 10.4 21.4 9.5 21.9 8.7 22.5 7.8 23.2 7.2 24.2 7 25.1 7.4 25.7 8.1 26.2 9 26.8 9.8 27.3 10.6 28.1 11.2 29 11.3 30 11 30.9 10.6 31.8 10.3 32.8 9.9 33.7 10 34.5 10.6 34.9 11.5 34.8 12.5 34.8 13.5 34.7 14.5 34.7 15.5 35.2 16.3 36 16.8 37 17.1 37.9 17.3 38.9 17.5 39.8 17.9 40.4 18.7 40.5 19.7 40 20.5 39.4 21.3 38.7 22 38.1 22.8 37.6 23.7 37.7 24.6 38.3 25.5 38.9 26.2 39.6 27 40.2 27.7 40.5 28.7 40.3 29.6 39.5 30.3 38.6 30.6 37.6 30.8 36.7 31 35.7 31.3 35 31.9 34.6 32.8 34.7 33.8 34.8 34.8 34.9 35.8 34.8 36.8 34.3 37.6 33.4 38.1 32.4 38 31.5 37.6 30.6 37.2 29.7 36.9 28.7 36.6 27.8 36.9 27.1 37.6 26.6 38.5 26.1 39.3 25.5 40.2 24.8 40.8 23.8 41 22.9 40.6 22.3 39.9 21.8 39 21.2 38.2 20.7 37.4 19.9 36.8 19 36.7 18 37 17.1 37.4 16.2 37.7 15.2 38.1 14.3 38 13.5 37.4 13.1 36.5 13.2 35.5 13.2 34.5 13.3 33.5 13.3 32.5 12.8 31.7 12 31.2 11 31 10.1 30.7 9.1 30.5 8.2 30.1 7.6 29.3 7.5 28.3 8 27.5 8.7 26.7 9.3 26 9.9 25.2 10.4 24.3 10.3 23.4 9.7 22.5 9.1 21.8 8.4 21 7.8 20.3 7.5 19.3 7.7 18.4 8.5 17.7 9.4 17.4 10.4 17.2 11.3 17 12.3 16.7 13 16.1 13.4 15.2 13.3 14.2 13.2 13.2 13.1 12.2 13.2 11.2 13.7 10.4 14.6 9.9 15.6 10 16.5 10.4 17.4 10.8 18.3 11.1 19.3 11.4 20.2 11.1Z";
|
|
203
|
+
var IndeterminateSvg = React12.memo(function IndeterminateSvg2({
|
|
204
|
+
size
|
|
205
|
+
}) {
|
|
206
|
+
const [ready, setReady] = React12.useState(false);
|
|
207
|
+
React12.useEffect(() => {
|
|
208
|
+
const raf = requestAnimationFrame(() => setReady(true));
|
|
209
|
+
return () => cancelAnimationFrame(raf);
|
|
210
|
+
}, []);
|
|
211
|
+
return /* @__PURE__ */ jsx(
|
|
212
|
+
"svg",
|
|
213
|
+
{
|
|
214
|
+
viewBox: "4 4 40 40",
|
|
215
|
+
width: size,
|
|
216
|
+
height: size,
|
|
217
|
+
fill: "currentColor",
|
|
218
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
219
|
+
"aria-hidden": "true",
|
|
220
|
+
focusable: "false",
|
|
221
|
+
children: /* @__PURE__ */ jsx("path", { d: SHAPE_VALUES.split(";")[0], children: ready && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
222
|
+
/* @__PURE__ */ jsx(
|
|
223
|
+
"animate",
|
|
224
|
+
{
|
|
225
|
+
attributeName: "d",
|
|
226
|
+
dur: "5s",
|
|
227
|
+
repeatCount: "indefinite",
|
|
228
|
+
calcMode: "spline",
|
|
229
|
+
keySplines: SHAPE_KEY_SPLINES,
|
|
230
|
+
keyTimes: SHAPE_KEY_TIMES,
|
|
231
|
+
values: SHAPE_VALUES
|
|
232
|
+
}
|
|
233
|
+
),
|
|
234
|
+
/* @__PURE__ */ jsx(
|
|
235
|
+
"animateTransform",
|
|
236
|
+
{
|
|
237
|
+
attributeName: "transform",
|
|
238
|
+
attributeType: "XML",
|
|
239
|
+
type: "rotate",
|
|
240
|
+
dur: "5s",
|
|
241
|
+
repeatCount: "indefinite",
|
|
242
|
+
calcMode: "spline",
|
|
243
|
+
keySplines: ROTATE_KEY_SPLINES,
|
|
244
|
+
keyTimes: ROTATE_KEY_TIMES,
|
|
245
|
+
values: ROTATE_VALUES
|
|
246
|
+
}
|
|
247
|
+
)
|
|
248
|
+
] }) })
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
});
|
|
252
|
+
var DeterminateSvg = React12.memo(function DeterminateSvg2({
|
|
253
|
+
size,
|
|
254
|
+
progress
|
|
255
|
+
}) {
|
|
256
|
+
const p = Math.min(1, Math.max(0, progress));
|
|
257
|
+
const rotation = -180 * p;
|
|
258
|
+
const pathD = p < 0.5 ? DETERMINATE_CIRCLE : DETERMINATE_SOFT_BURST;
|
|
259
|
+
return /* @__PURE__ */ jsx(
|
|
260
|
+
"svg",
|
|
261
|
+
{
|
|
262
|
+
viewBox: "4 4 40 40",
|
|
263
|
+
width: size,
|
|
264
|
+
height: size,
|
|
265
|
+
fill: "currentColor",
|
|
266
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
267
|
+
"aria-hidden": "true",
|
|
268
|
+
focusable: "false",
|
|
269
|
+
style: {
|
|
270
|
+
transform: `rotate(${rotation}deg)`,
|
|
271
|
+
transition: "transform 0.3s ease"
|
|
272
|
+
},
|
|
273
|
+
children: /* @__PURE__ */ jsx("path", { d: pathD, style: { transition: "d 0.3s ease" } })
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
});
|
|
277
|
+
var LoadingIndicator = React12.forwardRef(
|
|
278
|
+
(_a, ref) => {
|
|
279
|
+
var _b = _a, {
|
|
280
|
+
variant = "uncontained",
|
|
281
|
+
size = 48,
|
|
282
|
+
progress,
|
|
283
|
+
color,
|
|
284
|
+
className,
|
|
285
|
+
"aria-label": ariaLabel,
|
|
286
|
+
style
|
|
287
|
+
} = _b, restProps = __objRest(_b, [
|
|
288
|
+
"variant",
|
|
289
|
+
"size",
|
|
290
|
+
"progress",
|
|
291
|
+
"color",
|
|
292
|
+
"className",
|
|
293
|
+
"aria-label",
|
|
294
|
+
"style"
|
|
295
|
+
]);
|
|
296
|
+
const isContained = variant === "contained";
|
|
297
|
+
const isDeterminate = progress !== void 0;
|
|
298
|
+
const clampedSize = Math.min(240, Math.max(24, size));
|
|
299
|
+
const scaleFactor = clampedSize / 48;
|
|
300
|
+
const containerSize = isContained ? 38 * scaleFactor : void 0;
|
|
301
|
+
const indicatorSize = isContained ? 24 * scaleFactor : clampedSize;
|
|
302
|
+
const activeColor = isContained ? color != null ? color : "var(--md-sys-color-indicator-contained-active)" : color != null ? color : "var(--md-sys-color-indicator-active)";
|
|
303
|
+
const ariaNow = isDeterminate ? Math.round(Math.min(1, Math.max(0, progress)) * 100) : void 0;
|
|
304
|
+
return /* @__PURE__ */ jsx(
|
|
305
|
+
"div",
|
|
306
|
+
__spreadProps(__spreadValues({
|
|
307
|
+
ref,
|
|
308
|
+
role: "progressbar",
|
|
309
|
+
"aria-label": ariaLabel,
|
|
310
|
+
"aria-valuemin": 0,
|
|
311
|
+
"aria-valuemax": 100,
|
|
312
|
+
"aria-valuenow": ariaNow,
|
|
313
|
+
className: cn(
|
|
314
|
+
"inline-flex items-center justify-center shrink-0",
|
|
315
|
+
className
|
|
316
|
+
),
|
|
317
|
+
style: __spreadValues({
|
|
318
|
+
width: clampedSize,
|
|
319
|
+
height: clampedSize,
|
|
320
|
+
color: activeColor
|
|
321
|
+
}, style)
|
|
322
|
+
}, restProps), {
|
|
323
|
+
children: isContained ? /* @__PURE__ */ jsx(
|
|
324
|
+
"div",
|
|
325
|
+
{
|
|
326
|
+
className: "flex items-center justify-center rounded-full",
|
|
327
|
+
style: {
|
|
328
|
+
width: containerSize,
|
|
329
|
+
height: containerSize,
|
|
330
|
+
backgroundColor: "var(--md-sys-color-indicator-contained-container)"
|
|
331
|
+
},
|
|
332
|
+
children: isDeterminate ? /* @__PURE__ */ jsx(DeterminateSvg, { size: indicatorSize, progress }) : /* @__PURE__ */ jsx(IndeterminateSvg, { size: indicatorSize })
|
|
333
|
+
}
|
|
334
|
+
) : isDeterminate ? /* @__PURE__ */ jsx(DeterminateSvg, { size: indicatorSize, progress }) : /* @__PURE__ */ jsx(IndeterminateSvg, { size: indicatorSize })
|
|
335
|
+
})
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
);
|
|
339
|
+
LoadingIndicator.displayName = "LoadingIndicator";
|
|
340
|
+
|
|
341
|
+
// src/ui/progress-indicator/utils.ts
|
|
342
|
+
function easeInOutCubic(x) {
|
|
343
|
+
return x < 0.5 ? 4 * x * x * x : 1 - (-2 * x + 2) ** 3 / 2;
|
|
344
|
+
}
|
|
345
|
+
function generateWavyCircularPath(center, radius, amplitude, wavelength) {
|
|
346
|
+
const circumference = 2 * Math.PI * radius;
|
|
347
|
+
const numWaves = Math.max(
|
|
348
|
+
3,
|
|
349
|
+
Math.round(circumference / Math.max(1, wavelength))
|
|
350
|
+
);
|
|
351
|
+
const steps = numWaves * 4;
|
|
352
|
+
const dt = 2 * Math.PI / steps;
|
|
353
|
+
const rAt = (t) => radius + amplitude * Math.sin(numWaves * t);
|
|
354
|
+
const drAt = (t) => amplitude * numWaves * Math.cos(numWaves * t);
|
|
355
|
+
const xAt = (t) => center + rAt(t) * Math.cos(t);
|
|
356
|
+
const yAt = (t) => center + rAt(t) * Math.sin(t);
|
|
357
|
+
const dxAt = (t) => drAt(t) * Math.cos(t) - rAt(t) * Math.sin(t);
|
|
358
|
+
const dyAt = (t) => drAt(t) * Math.sin(t) + rAt(t) * Math.cos(t);
|
|
359
|
+
let d = "";
|
|
360
|
+
const tStart = 0;
|
|
361
|
+
for (let i = 0; i < steps; i++) {
|
|
362
|
+
const t0 = tStart + i * dt;
|
|
363
|
+
const t1 = tStart + (i + 1) * dt;
|
|
364
|
+
const scale = dt / 3;
|
|
365
|
+
const cp1x = xAt(t0) + scale * dxAt(t0);
|
|
366
|
+
const cp1y = yAt(t0) + scale * dyAt(t0);
|
|
367
|
+
const cp2x = xAt(t1) - scale * dxAt(t1);
|
|
368
|
+
const cp2y = yAt(t1) - scale * dyAt(t1);
|
|
369
|
+
if (i === 0) d += `M ${xAt(t0).toFixed(2)} ${yAt(t0).toFixed(2)}`;
|
|
370
|
+
d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${xAt(t1).toFixed(2)} ${yAt(t1).toFixed(2)}`;
|
|
371
|
+
}
|
|
372
|
+
d += " Z";
|
|
373
|
+
return d;
|
|
374
|
+
}
|
|
375
|
+
function getSinePath(startX, endX, phase, wl, amp) {
|
|
376
|
+
if (startX >= endX) return "";
|
|
377
|
+
let d = "";
|
|
378
|
+
const step = amp === 0 ? Math.max(10, endX - startX) : 1;
|
|
379
|
+
const yStart = Math.sin((startX + phase) / wl * 2 * Math.PI) * amp;
|
|
380
|
+
d += `M ${startX.toFixed(2)} ${yStart.toFixed(2)}`;
|
|
381
|
+
let nextX = Math.ceil(startX / step) * step;
|
|
382
|
+
if (nextX === startX) nextX += step;
|
|
383
|
+
while (nextX < endX) {
|
|
384
|
+
const y = Math.sin((nextX + phase) / wl * 2 * Math.PI) * amp;
|
|
385
|
+
d += ` L ${nextX.toFixed(2)} ${y.toFixed(2)}`;
|
|
386
|
+
nextX += step;
|
|
387
|
+
}
|
|
388
|
+
const yEnd = Math.sin((endX + phase) / wl * 2 * Math.PI) * amp;
|
|
389
|
+
d += ` L ${endX.toFixed(2)} ${yEnd.toFixed(2)}`;
|
|
390
|
+
return d;
|
|
391
|
+
}
|
|
392
|
+
var CircularProgress = React12.forwardRef(
|
|
393
|
+
(_a, ref) => {
|
|
394
|
+
var _b = _a, {
|
|
395
|
+
value,
|
|
396
|
+
size = 48,
|
|
397
|
+
trackHeight = 4,
|
|
398
|
+
shape = "flat",
|
|
399
|
+
amplitude,
|
|
400
|
+
wavelength,
|
|
401
|
+
gapSize = 4,
|
|
402
|
+
crawlerSpeed = 1,
|
|
403
|
+
color,
|
|
404
|
+
trackColor,
|
|
405
|
+
className,
|
|
406
|
+
"aria-label": ariaLabel
|
|
407
|
+
} = _b, restProps = __objRest(_b, [
|
|
408
|
+
"value",
|
|
409
|
+
"size",
|
|
410
|
+
"trackHeight",
|
|
411
|
+
"shape",
|
|
412
|
+
"amplitude",
|
|
413
|
+
"wavelength",
|
|
414
|
+
"gapSize",
|
|
415
|
+
"crawlerSpeed",
|
|
416
|
+
"color",
|
|
417
|
+
"trackColor",
|
|
418
|
+
"className",
|
|
419
|
+
"aria-label"
|
|
420
|
+
]);
|
|
421
|
+
const isDeterminate = value !== void 0;
|
|
422
|
+
const clampedValue = isDeterminate ? Math.min(100, Math.max(0, value)) : 0;
|
|
423
|
+
const radius = (size - trackHeight) / 2;
|
|
424
|
+
const center = size / 2;
|
|
425
|
+
const activeColor = color || "var(--md-sys-color-indicator-active)";
|
|
426
|
+
const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
|
|
427
|
+
const isWavy = shape === "wavy";
|
|
428
|
+
const BASELINE_SIZE = 48;
|
|
429
|
+
const scaleFactor = size / BASELINE_SIZE;
|
|
430
|
+
const effectiveAmplitude = React12.useMemo(
|
|
431
|
+
() => amplitude != null ? amplitude : 1.6 * scaleFactor,
|
|
432
|
+
[amplitude, scaleFactor]
|
|
433
|
+
);
|
|
434
|
+
const effectiveWavelength = React12.useMemo(
|
|
435
|
+
() => wavelength != null ? wavelength : 15 * scaleFactor,
|
|
436
|
+
[wavelength, scaleFactor]
|
|
437
|
+
);
|
|
438
|
+
const wavyActivePath = React12.useMemo(
|
|
439
|
+
() => isWavy ? generateWavyCircularPath(
|
|
440
|
+
center,
|
|
441
|
+
radius,
|
|
442
|
+
effectiveAmplitude,
|
|
443
|
+
effectiveWavelength
|
|
444
|
+
) : null,
|
|
445
|
+
[isWavy, center, radius, effectiveAmplitude, effectiveWavelength]
|
|
446
|
+
);
|
|
447
|
+
const circumference = React12.useMemo(() => 2 * Math.PI * radius, [radius]);
|
|
448
|
+
const gapForTrack = React12.useMemo(
|
|
449
|
+
() => (gapSize + trackHeight) / circumference,
|
|
450
|
+
[gapSize, trackHeight, circumference]
|
|
451
|
+
);
|
|
452
|
+
const activeAngularFraction = isDeterminate ? clampedValue / 100 : 0;
|
|
453
|
+
const trackOffset = isDeterminate ? activeAngularFraction + gapForTrack : 0;
|
|
454
|
+
const trackLength = isDeterminate ? Math.max(1e-3, 1 - activeAngularFraction - 2 * gapForTrack) : 1;
|
|
455
|
+
const ActiveCircleElem = m.circle;
|
|
456
|
+
const ActivePathElem = m.path;
|
|
457
|
+
return /* @__PURE__ */ jsx(
|
|
458
|
+
"div",
|
|
459
|
+
__spreadProps(__spreadValues({
|
|
460
|
+
ref,
|
|
461
|
+
role: "progressbar",
|
|
462
|
+
"aria-label": ariaLabel,
|
|
463
|
+
"aria-valuenow": isDeterminate ? clampedValue : void 0,
|
|
464
|
+
"aria-valuemin": 0,
|
|
465
|
+
"aria-valuemax": 100,
|
|
466
|
+
className: cn(
|
|
467
|
+
"relative inline-flex items-center justify-center shrink-0",
|
|
468
|
+
className
|
|
469
|
+
),
|
|
470
|
+
style: { width: size, height: size }
|
|
471
|
+
}, restProps), {
|
|
472
|
+
children: /* @__PURE__ */ jsxs(LazyMotion, { features: domMax, strict: true, children: [
|
|
473
|
+
/* @__PURE__ */ jsxs(
|
|
474
|
+
"svg",
|
|
475
|
+
{
|
|
476
|
+
width: size,
|
|
477
|
+
height: size,
|
|
478
|
+
viewBox: `0 0 ${size} ${size}`,
|
|
479
|
+
"aria-hidden": "true",
|
|
480
|
+
style: { transform: "rotate(-90deg)", overflow: "visible" },
|
|
481
|
+
children: [
|
|
482
|
+
isDeterminate ? /* @__PURE__ */ jsx(
|
|
483
|
+
m.circle,
|
|
484
|
+
{
|
|
485
|
+
cx: center,
|
|
486
|
+
cy: center,
|
|
487
|
+
r: radius,
|
|
488
|
+
fill: "none",
|
|
489
|
+
stroke: bgTrackColor,
|
|
490
|
+
strokeWidth: trackHeight,
|
|
491
|
+
initial: { pathLength: trackLength, pathOffset: trackOffset },
|
|
492
|
+
animate: { pathLength: trackLength, pathOffset: trackOffset },
|
|
493
|
+
transition: { duration: 0.4, ease: [0.2, 0, 0, 1] },
|
|
494
|
+
strokeLinecap: "round"
|
|
495
|
+
}
|
|
496
|
+
) : null,
|
|
497
|
+
isDeterminate && (isWavy ? /* @__PURE__ */ jsx(
|
|
498
|
+
ActivePathElem,
|
|
499
|
+
{
|
|
500
|
+
d: wavyActivePath != null ? wavyActivePath : "",
|
|
501
|
+
fill: "none",
|
|
502
|
+
stroke: activeColor,
|
|
503
|
+
strokeWidth: trackHeight,
|
|
504
|
+
strokeLinecap: "round",
|
|
505
|
+
initial: { pathLength: 0 },
|
|
506
|
+
animate: { pathLength: clampedValue / 100 },
|
|
507
|
+
transition: {
|
|
508
|
+
duration: 0.4,
|
|
509
|
+
ease: [0.2, 0, 0, 1]
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
) : /* @__PURE__ */ jsx(
|
|
513
|
+
ActiveCircleElem,
|
|
514
|
+
{
|
|
515
|
+
cx: center,
|
|
516
|
+
cy: center,
|
|
517
|
+
r: radius,
|
|
518
|
+
fill: "none",
|
|
519
|
+
stroke: activeColor,
|
|
520
|
+
strokeWidth: trackHeight,
|
|
521
|
+
strokeLinecap: "round",
|
|
522
|
+
initial: { pathLength: 0 },
|
|
523
|
+
animate: { pathLength: clampedValue / 100 },
|
|
524
|
+
transition: {
|
|
525
|
+
duration: 0.4,
|
|
526
|
+
ease: [0.2, 0, 0, 1]
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
))
|
|
530
|
+
]
|
|
531
|
+
}
|
|
532
|
+
),
|
|
533
|
+
!isDeterminate && /* @__PURE__ */ jsxs(
|
|
534
|
+
m.svg,
|
|
535
|
+
{
|
|
536
|
+
width: size,
|
|
537
|
+
height: size,
|
|
538
|
+
viewBox: `0 0 ${size} ${size}`,
|
|
539
|
+
"aria-hidden": "true",
|
|
540
|
+
style: {
|
|
541
|
+
position: "absolute",
|
|
542
|
+
inset: 0,
|
|
543
|
+
overflow: "visible",
|
|
544
|
+
rotate: "-90deg",
|
|
545
|
+
transformOrigin: "center"
|
|
546
|
+
},
|
|
547
|
+
animate: { rotate: ["-90deg", "270deg"] },
|
|
548
|
+
transition: {
|
|
549
|
+
rotate: {
|
|
550
|
+
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
551
|
+
repeat: Number.POSITIVE_INFINITY,
|
|
552
|
+
ease: "linear"
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
children: [
|
|
556
|
+
/* @__PURE__ */ jsx(
|
|
557
|
+
m.circle,
|
|
558
|
+
{
|
|
559
|
+
cx: center,
|
|
560
|
+
cy: center,
|
|
561
|
+
r: radius,
|
|
562
|
+
fill: "none",
|
|
563
|
+
stroke: bgTrackColor,
|
|
564
|
+
strokeWidth: trackHeight,
|
|
565
|
+
strokeLinecap: "round",
|
|
566
|
+
style: { originX: "50%", originY: "50%" },
|
|
567
|
+
animate: {
|
|
568
|
+
pathLength: [
|
|
569
|
+
Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack),
|
|
570
|
+
Math.max(1e-3, 1 - 0.75 - 2 * gapForTrack),
|
|
571
|
+
Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack)
|
|
572
|
+
],
|
|
573
|
+
rotate: [
|
|
574
|
+
`${(0.1 + gapForTrack) * 360}deg`,
|
|
575
|
+
`${(1 + gapForTrack) * 360}deg`,
|
|
576
|
+
`${(1.1 + gapForTrack) * 360}deg`
|
|
577
|
+
]
|
|
578
|
+
},
|
|
579
|
+
transition: {
|
|
580
|
+
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
581
|
+
repeat: Number.POSITIVE_INFINITY,
|
|
582
|
+
ease: [0.4, 0, 0.2, 1]
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
),
|
|
586
|
+
isWavy ? /* @__PURE__ */ jsx(
|
|
587
|
+
ActivePathElem,
|
|
588
|
+
{
|
|
589
|
+
d: wavyActivePath != null ? wavyActivePath : "",
|
|
590
|
+
fill: "none",
|
|
591
|
+
stroke: activeColor,
|
|
592
|
+
strokeWidth: trackHeight,
|
|
593
|
+
strokeLinecap: "round",
|
|
594
|
+
style: { originX: "50%", originY: "50%" },
|
|
595
|
+
animate: {
|
|
596
|
+
pathLength: [0.1, 0.75, 0.1],
|
|
597
|
+
rotate: ["0deg", "90deg", "360deg"]
|
|
598
|
+
},
|
|
599
|
+
transition: {
|
|
600
|
+
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
601
|
+
repeat: Number.POSITIVE_INFINITY,
|
|
602
|
+
ease: [0.4, 0, 0.2, 1]
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
) : /* @__PURE__ */ jsx(
|
|
606
|
+
ActiveCircleElem,
|
|
607
|
+
{
|
|
608
|
+
cx: center,
|
|
609
|
+
cy: center,
|
|
610
|
+
r: radius,
|
|
611
|
+
fill: "none",
|
|
612
|
+
stroke: activeColor,
|
|
613
|
+
strokeWidth: trackHeight,
|
|
614
|
+
strokeLinecap: "round",
|
|
615
|
+
style: { originX: "50%", originY: "50%" },
|
|
616
|
+
animate: {
|
|
617
|
+
pathLength: [0.1, 0.75, 0.1],
|
|
618
|
+
rotate: ["0deg", "90deg", "360deg"]
|
|
619
|
+
},
|
|
620
|
+
transition: {
|
|
621
|
+
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
622
|
+
repeat: Number.POSITIVE_INFINITY,
|
|
623
|
+
ease: [0.4, 0, 0.2, 1]
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
)
|
|
627
|
+
]
|
|
628
|
+
}
|
|
629
|
+
)
|
|
630
|
+
] })
|
|
631
|
+
})
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
);
|
|
635
|
+
CircularProgress.displayName = "CircularProgress";
|
|
636
|
+
function useContainerWidth() {
|
|
637
|
+
const [width, setWidth] = React12.useState(0);
|
|
638
|
+
const observerRef = React12.useRef(null);
|
|
639
|
+
const ref = React12.useCallback((node) => {
|
|
640
|
+
if (observerRef.current) {
|
|
641
|
+
observerRef.current.disconnect();
|
|
642
|
+
observerRef.current = null;
|
|
643
|
+
}
|
|
644
|
+
if (node) {
|
|
645
|
+
const obs = new ResizeObserver((entries) => {
|
|
646
|
+
const contentRect = entries[0].contentRect;
|
|
647
|
+
setWidth(contentRect.width);
|
|
648
|
+
});
|
|
649
|
+
obs.observe(node);
|
|
650
|
+
observerRef.current = obs;
|
|
651
|
+
}
|
|
652
|
+
}, []);
|
|
653
|
+
React12.useEffect(() => {
|
|
654
|
+
return () => {
|
|
655
|
+
if (observerRef.current) {
|
|
656
|
+
observerRef.current.disconnect();
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
}, []);
|
|
660
|
+
return [ref, width];
|
|
661
|
+
}
|
|
662
|
+
function useMergedRef(...refs) {
|
|
663
|
+
return React12.useCallback(
|
|
664
|
+
(node) => {
|
|
665
|
+
for (const ref of refs) {
|
|
666
|
+
if (typeof ref === "function") {
|
|
667
|
+
ref(node);
|
|
668
|
+
} else if (ref && typeof ref === "object") {
|
|
669
|
+
ref.current = node;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
},
|
|
673
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
674
|
+
[refs]
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
var FlatLinearTrack = React12.memo(function FlatLinearTrack2({
|
|
678
|
+
trackHeight,
|
|
679
|
+
activeColor,
|
|
680
|
+
trackColor,
|
|
681
|
+
value,
|
|
682
|
+
isRtl,
|
|
683
|
+
gapSize,
|
|
684
|
+
crawlerSpeed
|
|
685
|
+
}) {
|
|
686
|
+
const isDeterminate = value !== void 0;
|
|
687
|
+
const radius = trackHeight / 2;
|
|
688
|
+
const minActiveWidth = trackHeight;
|
|
689
|
+
return /* @__PURE__ */ jsx(
|
|
690
|
+
"div",
|
|
691
|
+
{
|
|
692
|
+
className: "relative w-full overflow-hidden",
|
|
693
|
+
style: { height: trackHeight, borderRadius: radius },
|
|
694
|
+
children: isDeterminate ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
695
|
+
/* @__PURE__ */ jsx(
|
|
696
|
+
m.div,
|
|
697
|
+
{
|
|
698
|
+
className: "absolute inset-y-0",
|
|
699
|
+
style: {
|
|
700
|
+
backgroundColor: trackColor,
|
|
701
|
+
borderRadius: radius,
|
|
702
|
+
width: "100%"
|
|
703
|
+
},
|
|
704
|
+
initial: {
|
|
705
|
+
[isRtl ? "right" : "left"]: `calc(max(${minActiveWidth}px, 0%) + ${gapSize}px)`
|
|
706
|
+
},
|
|
707
|
+
animate: {
|
|
708
|
+
[isRtl ? "right" : "left"]: `calc(max(${minActiveWidth}px, ${value}%) + ${gapSize}px)`
|
|
709
|
+
},
|
|
710
|
+
transition: { duration: 0.4, ease: [0.2, 0, 0, 1] }
|
|
711
|
+
}
|
|
712
|
+
),
|
|
713
|
+
/* @__PURE__ */ jsx(
|
|
714
|
+
m.div,
|
|
715
|
+
{
|
|
716
|
+
className: "absolute inset-y-0",
|
|
717
|
+
style: __spreadValues({
|
|
718
|
+
backgroundColor: activeColor,
|
|
719
|
+
borderRadius: radius,
|
|
720
|
+
minWidth: minActiveWidth
|
|
721
|
+
}, isRtl ? { right: 0 } : { left: 0 }),
|
|
722
|
+
initial: { width: `${minActiveWidth}px` },
|
|
723
|
+
animate: { width: `${value}%` },
|
|
724
|
+
transition: { duration: 0.4, ease: [0.2, 0, 0, 1] }
|
|
725
|
+
}
|
|
726
|
+
)
|
|
727
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
728
|
+
/* @__PURE__ */ jsx(
|
|
729
|
+
"div",
|
|
730
|
+
{
|
|
731
|
+
className: "absolute inset-0",
|
|
732
|
+
style: { backgroundColor: trackColor, borderRadius: radius }
|
|
733
|
+
}
|
|
734
|
+
),
|
|
735
|
+
/* @__PURE__ */ jsx(
|
|
736
|
+
m.div,
|
|
737
|
+
{
|
|
738
|
+
className: "absolute inset-y-0",
|
|
739
|
+
style: { backgroundColor: activeColor, borderRadius: radius },
|
|
740
|
+
initial: { left: "-40%", width: "40%" },
|
|
741
|
+
animate: { left: ["-40%", "100%"], width: ["40%", "20%", "40%"] },
|
|
742
|
+
transition: {
|
|
743
|
+
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
744
|
+
repeat: Number.POSITIVE_INFINITY,
|
|
745
|
+
ease: "easeInOut"
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
)
|
|
749
|
+
] })
|
|
750
|
+
}
|
|
751
|
+
);
|
|
752
|
+
});
|
|
753
|
+
var WavyLinearTrack = React12.memo(function WavyLinearTrack2({
|
|
754
|
+
trackHeight,
|
|
755
|
+
svgHeight,
|
|
756
|
+
amplitude,
|
|
757
|
+
wavelength,
|
|
758
|
+
indeterminateWavelength,
|
|
759
|
+
activeColor,
|
|
760
|
+
trackColor,
|
|
761
|
+
value,
|
|
762
|
+
isRtl,
|
|
763
|
+
gapSize,
|
|
764
|
+
waveSpeed,
|
|
765
|
+
crawlerSpeed,
|
|
766
|
+
determinateAnimation,
|
|
767
|
+
indeterminateAnimation,
|
|
768
|
+
trackShape
|
|
769
|
+
}) {
|
|
770
|
+
const isDeterminate = typeof value === "number";
|
|
771
|
+
const clampedValue = isDeterminate ? Math.max(0, Math.min(100, value)) : 100;
|
|
772
|
+
const titleId = React12.useId();
|
|
773
|
+
const [containerRef, width] = useContainerWidth();
|
|
774
|
+
const activePathRef = React12.useRef(null);
|
|
775
|
+
const trackPathRef = React12.useRef(null);
|
|
776
|
+
const amplitudeMV = useMotionValue(amplitude);
|
|
777
|
+
const fractionMV = useMotionValue(isDeterminate ? clampedValue / 100 : 1);
|
|
778
|
+
React12.useEffect(() => {
|
|
779
|
+
if (isDeterminate) {
|
|
780
|
+
const fraction = clampedValue / 100;
|
|
781
|
+
let targetAmp = amplitude;
|
|
782
|
+
if (determinateAnimation === "md3") {
|
|
783
|
+
targetAmp = fraction <= 0.1 || fraction >= 0.95 ? 0 : amplitude;
|
|
784
|
+
}
|
|
785
|
+
animate(amplitudeMV, targetAmp, {
|
|
786
|
+
type: "spring",
|
|
787
|
+
bounce: 0,
|
|
788
|
+
duration: 0.5
|
|
789
|
+
});
|
|
790
|
+
animate(fractionMV, fraction, { duration: 0.4, ease: [0.2, 0, 0, 1] });
|
|
791
|
+
}
|
|
792
|
+
}, [
|
|
793
|
+
clampedValue,
|
|
794
|
+
isDeterminate,
|
|
795
|
+
amplitude,
|
|
796
|
+
amplitudeMV,
|
|
797
|
+
fractionMV,
|
|
798
|
+
determinateAnimation
|
|
799
|
+
]);
|
|
800
|
+
const activeWavelength = Math.max(
|
|
801
|
+
1,
|
|
802
|
+
isDeterminate ? wavelength : indeterminateWavelength
|
|
803
|
+
);
|
|
804
|
+
const trackAmp = trackShape === "wavy" ? amplitude : 0;
|
|
805
|
+
useAnimationFrame((time) => {
|
|
806
|
+
if (width === 0) return;
|
|
807
|
+
const currentAmp = amplitudeMV.get();
|
|
808
|
+
const phase = time / 1e3 * waveSpeed * activeWavelength;
|
|
809
|
+
const capWidth = trackHeight / 2;
|
|
810
|
+
let activePathD = "";
|
|
811
|
+
let trackD = "";
|
|
812
|
+
const totalGap = gapSize + trackHeight;
|
|
813
|
+
if (isDeterminate) {
|
|
814
|
+
const fraction = fractionMV.get();
|
|
815
|
+
const barHead = fraction * width;
|
|
816
|
+
const adjHead = Math.max(capWidth, Math.min(width - capWidth, barHead));
|
|
817
|
+
const adjTail = capWidth;
|
|
818
|
+
if (fraction > 0 && adjHead - adjTail > 0.1) {
|
|
819
|
+
activePathD = getSinePath(
|
|
820
|
+
adjTail,
|
|
821
|
+
adjHead,
|
|
822
|
+
phase,
|
|
823
|
+
activeWavelength,
|
|
824
|
+
currentAmp
|
|
825
|
+
);
|
|
826
|
+
} else if (fraction === 0) {
|
|
827
|
+
activePathD = `M ${capWidth} 0 L ${capWidth + 0.01} 0`;
|
|
828
|
+
}
|
|
829
|
+
const trackStart = adjHead + totalGap;
|
|
830
|
+
if (trackStart < width - capWidth) {
|
|
831
|
+
trackD = getSinePath(
|
|
832
|
+
trackStart,
|
|
833
|
+
width - capWidth,
|
|
834
|
+
phase,
|
|
835
|
+
activeWavelength,
|
|
836
|
+
trackAmp
|
|
837
|
+
);
|
|
838
|
+
}
|
|
839
|
+
} else {
|
|
840
|
+
const safeCrawlerSpeed = Math.max(0.1, crawlerSpeed);
|
|
841
|
+
const activeLines = [];
|
|
842
|
+
if (indeterminateAnimation === "continuous") {
|
|
843
|
+
const cycle = 2e3 / safeCrawlerSpeed;
|
|
844
|
+
const fraction = time % cycle / cycle;
|
|
845
|
+
activeLines.push({
|
|
846
|
+
tail: easeInOutCubic(Math.max(0, fraction * 1.5 - 0.5)),
|
|
847
|
+
head: easeInOutCubic(Math.min(1, fraction * 1.5))
|
|
848
|
+
});
|
|
849
|
+
} else {
|
|
850
|
+
const cycle = 1750 / safeCrawlerSpeed;
|
|
851
|
+
const t = time % cycle * safeCrawlerSpeed;
|
|
852
|
+
const l1H = easeInOutCubic(Math.max(0, Math.min(1, t / 1e3)));
|
|
853
|
+
const l1T = easeInOutCubic(Math.max(0, Math.min(1, (t - 250) / 1e3)));
|
|
854
|
+
const l2H = easeInOutCubic(Math.max(0, Math.min(1, (t - 650) / 850)));
|
|
855
|
+
const l2T = easeInOutCubic(Math.max(0, Math.min(1, (t - 900) / 850)));
|
|
856
|
+
activeLines.push({ tail: l1T, head: l1H });
|
|
857
|
+
activeLines.push({ tail: l2T, head: l2H });
|
|
858
|
+
}
|
|
859
|
+
const segments = activeLines.map((line) => {
|
|
860
|
+
const barTail = line.tail * width;
|
|
861
|
+
const barHead = line.head * width;
|
|
862
|
+
const adjTail = Math.max(
|
|
863
|
+
capWidth,
|
|
864
|
+
Math.min(width - capWidth, barTail)
|
|
865
|
+
);
|
|
866
|
+
const adjHead = Math.max(
|
|
867
|
+
capWidth,
|
|
868
|
+
Math.min(width - capWidth, barHead)
|
|
869
|
+
);
|
|
870
|
+
return { adjTail, adjHead };
|
|
871
|
+
}).filter((seg) => seg.adjHead - seg.adjTail > 0.1);
|
|
872
|
+
activePathD = segments.map(
|
|
873
|
+
(seg) => getSinePath(
|
|
874
|
+
seg.adjTail,
|
|
875
|
+
seg.adjHead,
|
|
876
|
+
phase,
|
|
877
|
+
activeWavelength,
|
|
878
|
+
currentAmp
|
|
879
|
+
)
|
|
880
|
+
).join(" ");
|
|
881
|
+
let currentTrackX = capWidth;
|
|
882
|
+
for (const seg of segments) {
|
|
883
|
+
const trackEnd = seg.adjTail - totalGap;
|
|
884
|
+
if (trackEnd > currentTrackX) {
|
|
885
|
+
trackD += `${getSinePath(currentTrackX, trackEnd, phase, activeWavelength, trackAmp)} `;
|
|
886
|
+
}
|
|
887
|
+
currentTrackX = Math.max(currentTrackX, seg.adjHead + totalGap);
|
|
888
|
+
}
|
|
889
|
+
if (currentTrackX < width - capWidth) {
|
|
890
|
+
trackD += getSinePath(
|
|
891
|
+
currentTrackX,
|
|
892
|
+
width - capWidth,
|
|
893
|
+
phase,
|
|
894
|
+
activeWavelength,
|
|
895
|
+
trackAmp
|
|
896
|
+
);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
if (activePathRef.current)
|
|
900
|
+
activePathRef.current.setAttribute("d", activePathD);
|
|
901
|
+
if (trackPathRef.current)
|
|
902
|
+
trackPathRef.current.setAttribute("d", trackD.trim());
|
|
903
|
+
});
|
|
904
|
+
return /* @__PURE__ */ jsx(
|
|
905
|
+
"div",
|
|
906
|
+
{
|
|
907
|
+
ref: containerRef,
|
|
908
|
+
className: "relative w-full overflow-hidden",
|
|
909
|
+
style: { height: svgHeight },
|
|
910
|
+
children: width > 0 && /* @__PURE__ */ jsxs(
|
|
911
|
+
"svg",
|
|
912
|
+
{
|
|
913
|
+
className: "absolute inset-0 w-full h-full",
|
|
914
|
+
style: {
|
|
915
|
+
overflow: "visible",
|
|
916
|
+
transform: isRtl ? "scaleX(-1)" : void 0
|
|
917
|
+
},
|
|
918
|
+
"aria-labelledby": titleId,
|
|
919
|
+
children: [
|
|
920
|
+
/* @__PURE__ */ jsx("title", { id: titleId, children: isDeterminate ? `Progress: ${clampedValue}%` : "Indeterminate loading progress" }),
|
|
921
|
+
/* @__PURE__ */ jsxs("g", { transform: `translate(0, ${svgHeight / 2})`, children: [
|
|
922
|
+
/* @__PURE__ */ jsx(
|
|
923
|
+
"path",
|
|
924
|
+
{
|
|
925
|
+
ref: trackPathRef,
|
|
926
|
+
fill: "none",
|
|
927
|
+
stroke: trackColor,
|
|
928
|
+
strokeWidth: trackHeight,
|
|
929
|
+
strokeLinecap: "round"
|
|
930
|
+
}
|
|
931
|
+
),
|
|
932
|
+
/* @__PURE__ */ jsx(
|
|
933
|
+
"path",
|
|
934
|
+
{
|
|
935
|
+
ref: activePathRef,
|
|
936
|
+
fill: "none",
|
|
937
|
+
stroke: activeColor,
|
|
938
|
+
strokeWidth: trackHeight,
|
|
939
|
+
strokeLinecap: "round"
|
|
940
|
+
}
|
|
941
|
+
)
|
|
942
|
+
] })
|
|
943
|
+
]
|
|
944
|
+
}
|
|
945
|
+
)
|
|
946
|
+
}
|
|
947
|
+
);
|
|
948
|
+
});
|
|
949
|
+
var LinearProgress = React12.forwardRef(
|
|
950
|
+
(_a, ref) => {
|
|
951
|
+
var _b = _a, {
|
|
952
|
+
value,
|
|
953
|
+
shape = "flat",
|
|
954
|
+
trackShape,
|
|
955
|
+
trackHeight = 4,
|
|
956
|
+
amplitude,
|
|
957
|
+
wavelength = 40,
|
|
958
|
+
indeterminateWavelength = 20,
|
|
959
|
+
waveSpeed = 1,
|
|
960
|
+
crawlerSpeed = 1,
|
|
961
|
+
determinateAnimation = "md3",
|
|
962
|
+
indeterminateAnimation = "continuous",
|
|
963
|
+
gapSize = 4,
|
|
964
|
+
showStopIndicator = "auto",
|
|
965
|
+
color,
|
|
966
|
+
trackColor,
|
|
967
|
+
className,
|
|
968
|
+
"aria-label": ariaLabel
|
|
969
|
+
} = _b, restProps = __objRest(_b, [
|
|
970
|
+
"value",
|
|
971
|
+
"shape",
|
|
972
|
+
"trackShape",
|
|
973
|
+
"trackHeight",
|
|
974
|
+
"amplitude",
|
|
975
|
+
"wavelength",
|
|
976
|
+
"indeterminateWavelength",
|
|
977
|
+
"waveSpeed",
|
|
978
|
+
"crawlerSpeed",
|
|
979
|
+
"determinateAnimation",
|
|
980
|
+
"indeterminateAnimation",
|
|
981
|
+
"gapSize",
|
|
982
|
+
"showStopIndicator",
|
|
983
|
+
"color",
|
|
984
|
+
"trackColor",
|
|
985
|
+
"className",
|
|
986
|
+
"aria-label"
|
|
987
|
+
]);
|
|
988
|
+
const isDeterminate = value !== void 0;
|
|
989
|
+
const clampedValue = isDeterminate ? Math.min(100, Math.max(0, value)) : 0;
|
|
990
|
+
const containerRef = React12.useRef(null);
|
|
991
|
+
const mergedRef = useMergedRef(ref, containerRef);
|
|
992
|
+
const [isRtl, setIsRtl] = React12.useState(false);
|
|
993
|
+
React12.useEffect(() => {
|
|
994
|
+
if (containerRef.current) {
|
|
995
|
+
const dir = getComputedStyle(containerRef.current).direction;
|
|
996
|
+
setIsRtl(dir === "rtl");
|
|
997
|
+
}
|
|
998
|
+
}, []);
|
|
999
|
+
const isWavy = shape === "wavy";
|
|
1000
|
+
const resolvedTrackShape = trackShape != null ? trackShape : shape;
|
|
1001
|
+
const effectiveAmplitude = React12.useMemo(() => amplitude != null ? amplitude : 3, [amplitude]);
|
|
1002
|
+
const svgHeight = React12.useMemo(
|
|
1003
|
+
() => isWavy ? trackHeight + effectiveAmplitude * 2 : trackHeight,
|
|
1004
|
+
[isWavy, trackHeight, effectiveAmplitude]
|
|
1005
|
+
);
|
|
1006
|
+
const shouldShowStop = React12.useMemo(
|
|
1007
|
+
() => isDeterminate && resolvedTrackShape === "flat" && (showStopIndicator === true || showStopIndicator === "auto" && isDeterminate),
|
|
1008
|
+
[isDeterminate, resolvedTrackShape, showStopIndicator]
|
|
1009
|
+
);
|
|
1010
|
+
const stopSize = React12.useMemo(
|
|
1011
|
+
() => Math.max(2, trackHeight > 4 ? 4 : trackHeight / 2),
|
|
1012
|
+
[trackHeight]
|
|
1013
|
+
);
|
|
1014
|
+
const stopOffset = (trackHeight - stopSize) / 2;
|
|
1015
|
+
const activeColor = color || "var(--md-sys-color-indicator-active)";
|
|
1016
|
+
const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
|
|
1017
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsxs(
|
|
1018
|
+
"div",
|
|
1019
|
+
__spreadProps(__spreadValues({
|
|
1020
|
+
ref: mergedRef,
|
|
1021
|
+
role: "progressbar",
|
|
1022
|
+
"aria-label": ariaLabel,
|
|
1023
|
+
"aria-valuenow": isDeterminate ? clampedValue : void 0,
|
|
1024
|
+
"aria-valuemin": 0,
|
|
1025
|
+
"aria-valuemax": 100,
|
|
1026
|
+
className: cn(
|
|
1027
|
+
"relative flex w-full flex-col justify-center",
|
|
1028
|
+
className
|
|
1029
|
+
),
|
|
1030
|
+
style: { height: svgHeight }
|
|
1031
|
+
}, restProps), {
|
|
1032
|
+
children: [
|
|
1033
|
+
isWavy ? /* @__PURE__ */ jsx(
|
|
1034
|
+
WavyLinearTrack,
|
|
1035
|
+
{
|
|
1036
|
+
trackHeight,
|
|
1037
|
+
svgHeight,
|
|
1038
|
+
amplitude: effectiveAmplitude,
|
|
1039
|
+
wavelength,
|
|
1040
|
+
indeterminateWavelength,
|
|
1041
|
+
activeColor,
|
|
1042
|
+
trackColor: bgTrackColor,
|
|
1043
|
+
value: isDeterminate ? clampedValue : void 0,
|
|
1044
|
+
isRtl,
|
|
1045
|
+
gapSize,
|
|
1046
|
+
waveSpeed,
|
|
1047
|
+
crawlerSpeed,
|
|
1048
|
+
determinateAnimation,
|
|
1049
|
+
indeterminateAnimation,
|
|
1050
|
+
trackShape: resolvedTrackShape
|
|
1051
|
+
}
|
|
1052
|
+
) : /* @__PURE__ */ jsx(
|
|
1053
|
+
FlatLinearTrack,
|
|
1054
|
+
{
|
|
1055
|
+
trackHeight,
|
|
1056
|
+
activeColor,
|
|
1057
|
+
trackColor: bgTrackColor,
|
|
1058
|
+
value: isDeterminate ? clampedValue : void 0,
|
|
1059
|
+
isRtl,
|
|
1060
|
+
gapSize,
|
|
1061
|
+
crawlerSpeed
|
|
1062
|
+
}
|
|
1063
|
+
),
|
|
1064
|
+
shouldShowStop && /* @__PURE__ */ jsx(
|
|
1065
|
+
"div",
|
|
1066
|
+
{
|
|
1067
|
+
"aria-hidden": "true",
|
|
1068
|
+
className: "absolute rounded-full",
|
|
1069
|
+
style: __spreadValues({
|
|
1070
|
+
width: stopSize,
|
|
1071
|
+
height: stopSize,
|
|
1072
|
+
backgroundColor: "var(--md-sys-color-indicator-stop)",
|
|
1073
|
+
top: svgHeight / 2 - stopSize / 2
|
|
1074
|
+
}, isRtl ? { left: stopOffset } : { right: stopOffset })
|
|
1075
|
+
}
|
|
1076
|
+
)
|
|
1077
|
+
]
|
|
1078
|
+
})
|
|
1079
|
+
) });
|
|
1080
|
+
}
|
|
1081
|
+
);
|
|
1082
|
+
LinearProgress.displayName = "LinearProgress";
|
|
1083
|
+
var ProgressIndicator = React12.forwardRef((props, ref) => {
|
|
1084
|
+
if (props.variant === "circular") {
|
|
1085
|
+
return /* @__PURE__ */ jsx(CircularProgress, __spreadValues({ ref }, props));
|
|
1086
|
+
}
|
|
1087
|
+
return /* @__PURE__ */ jsx(LinearProgress, __spreadValues({ ref }, props));
|
|
1088
|
+
});
|
|
1089
|
+
ProgressIndicator.displayName = "ProgressIndicator";
|
|
1090
|
+
var RippleItem = React12.memo(function RippleItem2({
|
|
1091
|
+
ripple,
|
|
1092
|
+
onDone
|
|
1093
|
+
}) {
|
|
1094
|
+
return /* @__PURE__ */ jsx(
|
|
1095
|
+
m.span,
|
|
1096
|
+
{
|
|
1097
|
+
"aria-hidden": "true",
|
|
1098
|
+
style: {
|
|
1099
|
+
position: "absolute",
|
|
1100
|
+
left: ripple.x - ripple.size / 2,
|
|
1101
|
+
top: ripple.y - ripple.size / 2,
|
|
1102
|
+
width: ripple.size,
|
|
1103
|
+
height: ripple.size,
|
|
1104
|
+
borderRadius: "50%",
|
|
1105
|
+
backgroundColor: "currentColor",
|
|
1106
|
+
pointerEvents: "none",
|
|
1107
|
+
transformOrigin: "center"
|
|
1108
|
+
},
|
|
1109
|
+
initial: { scale: 0, opacity: 0.12 },
|
|
1110
|
+
animate: { scale: 1, opacity: 0 },
|
|
1111
|
+
exit: { opacity: 0 },
|
|
1112
|
+
transition: {
|
|
1113
|
+
scale: { duration: 0.5, ease: [0.2, 0, 0, 1] },
|
|
1114
|
+
opacity: { duration: 0.4, ease: "easeOut", delay: 0.1 }
|
|
1115
|
+
},
|
|
1116
|
+
onAnimationComplete: () => onDone(ripple.id)
|
|
1117
|
+
},
|
|
1118
|
+
ripple.id
|
|
1119
|
+
);
|
|
1120
|
+
});
|
|
1121
|
+
function Ripple({
|
|
1122
|
+
ripples,
|
|
1123
|
+
onRippleDone,
|
|
1124
|
+
disabled = false,
|
|
1125
|
+
respectSystemMotion = true
|
|
1126
|
+
}) {
|
|
1127
|
+
const prefersReduced = useReducedMotion();
|
|
1128
|
+
if (disabled) return null;
|
|
1129
|
+
if (respectSystemMotion && prefersReduced) return null;
|
|
1130
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: ripples.map((r) => /* @__PURE__ */ jsx(RippleItem, { ripple: r, onDone: onRippleDone }, r.id)) });
|
|
1131
|
+
}
|
|
1132
|
+
function useRippleState(options = {}) {
|
|
1133
|
+
const { disabled = false } = options;
|
|
1134
|
+
const [ripples, setRipples] = React12.useState([]);
|
|
1135
|
+
const onPointerDown = React12.useCallback(
|
|
1136
|
+
(e) => {
|
|
1137
|
+
if (disabled) return;
|
|
1138
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
1139
|
+
const x = e.clientX - rect.left;
|
|
1140
|
+
const y = e.clientY - rect.top;
|
|
1141
|
+
const rippleSize = Math.hypot(rect.width, rect.height) * 2;
|
|
1142
|
+
setRipples((prev) => [
|
|
1143
|
+
...prev,
|
|
1144
|
+
{ id: Date.now(), x, y, size: rippleSize }
|
|
1145
|
+
]);
|
|
1146
|
+
},
|
|
1147
|
+
[disabled]
|
|
1148
|
+
);
|
|
1149
|
+
const removeRipple = React12.useCallback((id) => {
|
|
1150
|
+
setRipples((prev) => prev.filter((r) => r.id !== id));
|
|
1151
|
+
}, []);
|
|
1152
|
+
return { ripples, onPointerDown, removeRipple };
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
// src/ui/shared/constants.ts
|
|
1156
|
+
var SPRING_TRANSITION_FAST = FAST_EFFECTS_SPRING;
|
|
1157
|
+
var SPRING_TRANSITION = DEFAULT_EFFECTS_SPRING;
|
|
1158
|
+
var ICON_SPAN_VARIANTS = {
|
|
1159
|
+
initial: { scale: 0.01 },
|
|
1160
|
+
animate: { scale: 1 },
|
|
1161
|
+
exit: { scale: 0.01 }
|
|
1162
|
+
};
|
|
1163
|
+
function TouchTarget() {
|
|
1164
|
+
return /* @__PURE__ */ jsx(
|
|
1165
|
+
"span",
|
|
1166
|
+
{
|
|
1167
|
+
"aria-hidden": "true",
|
|
1168
|
+
className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 min-w-12 min-h-12 cursor-pointer pointer-events-none"
|
|
1169
|
+
}
|
|
1170
|
+
);
|
|
1171
|
+
}
|
|
1172
|
+
var SIZE_STYLES = {
|
|
1173
|
+
xs: "h-8 w-8",
|
|
1174
|
+
sm: "h-10 w-10",
|
|
1175
|
+
md: "h-14 w-14",
|
|
1176
|
+
lg: "h-24 w-24",
|
|
1177
|
+
xl: "h-[8.5rem] w-[8.5rem]"
|
|
1178
|
+
};
|
|
1179
|
+
var SIZE_ICON = {
|
|
1180
|
+
xs: { cls: "size-5", px: 20 },
|
|
1181
|
+
sm: { cls: "size-6", px: 24 },
|
|
1182
|
+
md: { cls: "size-6", px: 24 },
|
|
1183
|
+
lg: { cls: "size-8", px: 32 },
|
|
1184
|
+
xl: { cls: "size-10", px: 40 }
|
|
1185
|
+
};
|
|
1186
|
+
var RADIUS_MAP = {
|
|
1187
|
+
xs: {
|
|
1188
|
+
round: 16,
|
|
1189
|
+
square: 12,
|
|
1190
|
+
pressed: 8,
|
|
1191
|
+
selectedRound: 12,
|
|
1192
|
+
selectedSquare: 16
|
|
1193
|
+
},
|
|
1194
|
+
sm: {
|
|
1195
|
+
round: 20,
|
|
1196
|
+
square: 12,
|
|
1197
|
+
pressed: 8,
|
|
1198
|
+
selectedRound: 12,
|
|
1199
|
+
selectedSquare: 20
|
|
1200
|
+
},
|
|
1201
|
+
md: {
|
|
1202
|
+
round: 28,
|
|
1203
|
+
square: 16,
|
|
1204
|
+
pressed: 12,
|
|
1205
|
+
selectedRound: 16,
|
|
1206
|
+
selectedSquare: 28
|
|
1207
|
+
},
|
|
1208
|
+
lg: {
|
|
1209
|
+
round: 48,
|
|
1210
|
+
square: 28,
|
|
1211
|
+
pressed: 16,
|
|
1212
|
+
selectedRound: 28,
|
|
1213
|
+
selectedSquare: 48
|
|
1214
|
+
},
|
|
1215
|
+
xl: {
|
|
1216
|
+
round: 68,
|
|
1217
|
+
square: 28,
|
|
1218
|
+
pressed: 16,
|
|
1219
|
+
selectedRound: 28,
|
|
1220
|
+
selectedSquare: 68
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
var SIZE_OUTLINE_WIDTH = {
|
|
1224
|
+
xs: "border",
|
|
1225
|
+
sm: "border",
|
|
1226
|
+
md: "border",
|
|
1227
|
+
lg: "border-2",
|
|
1228
|
+
xl: "border-[3px]"
|
|
1229
|
+
};
|
|
1230
|
+
var colorStyles = {
|
|
1231
|
+
standard: {
|
|
1232
|
+
default: "text-m3-on-surface-variant hover:bg-m3-on-surface-variant/8 active:bg-m3-on-surface-variant/12",
|
|
1233
|
+
selected: "text-m3-primary hover:bg-m3-primary/8 active:bg-m3-primary/12"
|
|
1234
|
+
},
|
|
1235
|
+
filled: {
|
|
1236
|
+
default: "bg-m3-surface-container text-m3-on-surface-variant hover:bg-m3-on-surface-variant/8 active:bg-m3-on-surface-variant/12",
|
|
1237
|
+
selected: "bg-m3-primary text-m3-on-primary hover:brightness-95 active:brightness-90"
|
|
1238
|
+
},
|
|
1239
|
+
tonal: {
|
|
1240
|
+
default: "bg-m3-secondary-container text-m3-on-secondary-container hover:bg-m3-on-secondary-container/8 active:bg-m3-on-secondary-container/12",
|
|
1241
|
+
selected: "bg-m3-secondary text-m3-on-secondary hover:brightness-95 active:brightness-90"
|
|
1242
|
+
},
|
|
1243
|
+
outlined: {
|
|
1244
|
+
default: "border-m3-outline-variant text-m3-on-surface-variant hover:bg-m3-on-surface-variant/8 active:bg-m3-on-surface-variant/12",
|
|
1245
|
+
selected: "bg-m3-inverse-surface text-m3-inverse-on-surface border-transparent hover:brightness-95 active:brightness-90"
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
var baseIconButtonClasses = [
|
|
1249
|
+
"relative shrink-0 inline-flex items-center justify-center",
|
|
1250
|
+
"select-none cursor-pointer",
|
|
1251
|
+
"transition-[background-color,color,border-color,box-shadow,opacity,filter] duration-200",
|
|
1252
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-m3-primary focus-visible:ring-offset-2",
|
|
1253
|
+
"disabled:pointer-events-none disabled:opacity-[0.38]"
|
|
1254
|
+
];
|
|
1255
|
+
function resolveAnimateRadius(radiusConfig, shape, isToggle, isSelected) {
|
|
1256
|
+
if (isToggle && isSelected) {
|
|
1257
|
+
return shape === "round" ? radiusConfig.selectedRound : radiusConfig.selectedSquare;
|
|
1258
|
+
}
|
|
1259
|
+
return shape === "round" ? radiusConfig.round : radiusConfig.square;
|
|
1260
|
+
}
|
|
1261
|
+
function resolveDisabledBgClass(colorStyle) {
|
|
1262
|
+
if (colorStyle === "filled" || colorStyle === "tonal") {
|
|
1263
|
+
return "disabled:bg-m3-on-surface/12 disabled:text-m3-on-surface/[0.38]";
|
|
1264
|
+
}
|
|
1265
|
+
if (colorStyle === "outlined") {
|
|
1266
|
+
return "disabled:text-m3-on-surface/[0.38] disabled:border-m3-on-surface/[0.12]";
|
|
1267
|
+
}
|
|
1268
|
+
return "disabled:text-m3-on-surface/[0.38]";
|
|
1269
|
+
}
|
|
1270
|
+
var IconButtonComponent = React12.forwardRef(
|
|
1271
|
+
(_a, ref) => {
|
|
1272
|
+
var _b = _a, {
|
|
1273
|
+
className,
|
|
1274
|
+
style,
|
|
1275
|
+
variant = "default",
|
|
1276
|
+
colorStyle = "standard",
|
|
1277
|
+
size = "sm",
|
|
1278
|
+
shape = "round",
|
|
1279
|
+
selected,
|
|
1280
|
+
loading = false,
|
|
1281
|
+
loadingVariant = "loading-indicator",
|
|
1282
|
+
iconSize,
|
|
1283
|
+
children,
|
|
1284
|
+
onClick,
|
|
1285
|
+
onKeyDown,
|
|
1286
|
+
"aria-label": ariaLabel
|
|
1287
|
+
} = _b, restProps = __objRest(_b, [
|
|
1288
|
+
"className",
|
|
1289
|
+
"style",
|
|
1290
|
+
"variant",
|
|
1291
|
+
"colorStyle",
|
|
1292
|
+
"size",
|
|
1293
|
+
"shape",
|
|
1294
|
+
"selected",
|
|
1295
|
+
"loading",
|
|
1296
|
+
"loadingVariant",
|
|
1297
|
+
"iconSize",
|
|
1298
|
+
"children",
|
|
1299
|
+
"onClick",
|
|
1300
|
+
"onKeyDown",
|
|
1301
|
+
"aria-label"
|
|
1302
|
+
]);
|
|
1303
|
+
var _a2, _b2;
|
|
1304
|
+
const isToggle = variant === "toggle";
|
|
1305
|
+
const isSelected = isToggle && !!selected;
|
|
1306
|
+
const resolvedColorClass = React12.useMemo(
|
|
1307
|
+
() => isSelected ? colorStyles[colorStyle].selected : colorStyles[colorStyle].default,
|
|
1308
|
+
[isSelected, colorStyle]
|
|
1309
|
+
);
|
|
1310
|
+
const outlineWidthClass = React12.useMemo(
|
|
1311
|
+
() => {
|
|
1312
|
+
var _a3;
|
|
1313
|
+
return colorStyle === "outlined" && !isSelected ? (_a3 = SIZE_OUTLINE_WIDTH[size]) != null ? _a3 : "border" : "";
|
|
1314
|
+
},
|
|
1315
|
+
[colorStyle, isSelected, size]
|
|
1316
|
+
);
|
|
1317
|
+
const disabledBgClass = React12.useMemo(
|
|
1318
|
+
() => resolveDisabledBgClass(colorStyle),
|
|
1319
|
+
[colorStyle]
|
|
1320
|
+
);
|
|
1321
|
+
const radiusConfig = (_a2 = RADIUS_MAP[size]) != null ? _a2 : RADIUS_MAP.sm;
|
|
1322
|
+
const animateRadius = resolveAnimateRadius(
|
|
1323
|
+
radiusConfig,
|
|
1324
|
+
shape,
|
|
1325
|
+
isToggle,
|
|
1326
|
+
isSelected
|
|
1327
|
+
);
|
|
1328
|
+
const pressedRadius = radiusConfig.pressed;
|
|
1329
|
+
const sizeIcon = (_b2 = SIZE_ICON[size]) != null ? _b2 : SIZE_ICON.sm;
|
|
1330
|
+
const iconClass = sizeIcon.cls;
|
|
1331
|
+
const defaultIconPx = sizeIcon.px;
|
|
1332
|
+
const iconPx = iconSize != null ? iconSize : defaultIconPx;
|
|
1333
|
+
const isCustomSize = iconSize != null && iconSize !== "inherit";
|
|
1334
|
+
const needsTouchTarget = size === "xs" || size === "sm";
|
|
1335
|
+
const { ripples, onPointerDown, removeRipple } = useRippleState({
|
|
1336
|
+
disabled: loading
|
|
1337
|
+
});
|
|
1338
|
+
const handleClick = React12.useCallback(
|
|
1339
|
+
(e) => {
|
|
1340
|
+
if (loading) {
|
|
1341
|
+
e.preventDefault();
|
|
1342
|
+
return;
|
|
1343
|
+
}
|
|
1344
|
+
onClick == null ? void 0 : onClick(e);
|
|
1345
|
+
},
|
|
1346
|
+
[loading, onClick]
|
|
1347
|
+
);
|
|
1348
|
+
const handleKeyDown = React12.useCallback(
|
|
1349
|
+
(e) => {
|
|
1350
|
+
if (loading) return;
|
|
1351
|
+
if ((e.key === "Enter" || e.key === " ") && onClick) {
|
|
1352
|
+
e.preventDefault();
|
|
1353
|
+
e.currentTarget.click();
|
|
1354
|
+
}
|
|
1355
|
+
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
1356
|
+
},
|
|
1357
|
+
[loading, onClick, onKeyDown]
|
|
1358
|
+
);
|
|
1359
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsxs(
|
|
1360
|
+
m.button,
|
|
1361
|
+
__spreadProps(__spreadValues({
|
|
1362
|
+
ref,
|
|
1363
|
+
type: "button",
|
|
1364
|
+
"aria-pressed": isToggle ? isSelected : void 0,
|
|
1365
|
+
"aria-label": ariaLabel,
|
|
1366
|
+
"aria-busy": loading || void 0,
|
|
1367
|
+
"aria-disabled": loading || restProps.disabled,
|
|
1368
|
+
onClick: handleClick,
|
|
1369
|
+
onPointerDown,
|
|
1370
|
+
onKeyDown: handleKeyDown,
|
|
1371
|
+
style,
|
|
1372
|
+
animate: { borderRadius: animateRadius },
|
|
1373
|
+
whileTap: { borderRadius: pressedRadius },
|
|
1374
|
+
transition: { borderRadius: SPRING_TRANSITION_FAST },
|
|
1375
|
+
className: cn(
|
|
1376
|
+
baseIconButtonClasses,
|
|
1377
|
+
resolvedColorClass,
|
|
1378
|
+
outlineWidthClass,
|
|
1379
|
+
disabledBgClass,
|
|
1380
|
+
"overflow-hidden",
|
|
1381
|
+
SIZE_STYLES[size],
|
|
1382
|
+
loading && "pointer-events-none opacity-75 cursor-not-allowed",
|
|
1383
|
+
className
|
|
1384
|
+
)
|
|
1385
|
+
}, restProps), {
|
|
1386
|
+
children: [
|
|
1387
|
+
needsTouchTarget && /* @__PURE__ */ jsx(TouchTarget, {}),
|
|
1388
|
+
/* @__PURE__ */ jsx(Ripple, { ripples, onRippleDone: removeRipple }),
|
|
1389
|
+
/* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", initial: false, children: loading ? /* @__PURE__ */ jsx(
|
|
1390
|
+
m.span,
|
|
1391
|
+
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
1392
|
+
transition: SPRING_TRANSITION,
|
|
1393
|
+
className: cn(
|
|
1394
|
+
"flex items-center justify-center shrink-0",
|
|
1395
|
+
iconSize != null ? void 0 : iconClass
|
|
1396
|
+
),
|
|
1397
|
+
style: isCustomSize ? { width: `${iconSize}px`, height: `${iconSize}px` } : void 0,
|
|
1398
|
+
children: loadingVariant === "loading-indicator" ? /* @__PURE__ */ jsx(
|
|
1399
|
+
LoadingIndicator,
|
|
1400
|
+
{
|
|
1401
|
+
size: typeof iconPx === "number" ? iconPx : defaultIconPx,
|
|
1402
|
+
color: "currentColor",
|
|
1403
|
+
"aria-label": "Loading"
|
|
1404
|
+
}
|
|
1405
|
+
) : /* @__PURE__ */ jsx(
|
|
1406
|
+
ProgressIndicator,
|
|
1407
|
+
{
|
|
1408
|
+
variant: "circular",
|
|
1409
|
+
size: typeof iconPx === "number" ? iconPx : defaultIconPx,
|
|
1410
|
+
color: "currentColor",
|
|
1411
|
+
trackColor: "transparent",
|
|
1412
|
+
"aria-label": "Loading"
|
|
1413
|
+
}
|
|
1414
|
+
)
|
|
1415
|
+
}),
|
|
1416
|
+
"loading"
|
|
1417
|
+
) : /* @__PURE__ */ jsx(
|
|
1418
|
+
m.span,
|
|
1419
|
+
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
1420
|
+
transition: SPRING_TRANSITION,
|
|
1421
|
+
"aria-hidden": "true",
|
|
1422
|
+
className: cn(
|
|
1423
|
+
"flex items-center justify-center shrink-0 [&_svg]:w-full [&_svg]:h-full [&_.md-icon]:text-[length:inherit]!",
|
|
1424
|
+
iconSize != null ? void 0 : iconClass
|
|
1425
|
+
),
|
|
1426
|
+
style: {
|
|
1427
|
+
fontSize: typeof iconPx === "number" ? `${iconPx}px` : iconPx,
|
|
1428
|
+
width: isCustomSize ? `${iconSize}px` : void 0,
|
|
1429
|
+
height: isCustomSize ? `${iconSize}px` : void 0
|
|
1430
|
+
},
|
|
1431
|
+
children
|
|
1432
|
+
}),
|
|
1433
|
+
"content"
|
|
1434
|
+
) })
|
|
1435
|
+
]
|
|
1436
|
+
})
|
|
1437
|
+
) });
|
|
1438
|
+
}
|
|
1439
|
+
);
|
|
1440
|
+
IconButtonComponent.displayName = "IconButton";
|
|
1441
|
+
var IconButton = React12.memo(IconButtonComponent);
|
|
1442
|
+
var VARIANT_FONT = {
|
|
1443
|
+
outlined: "'Material Symbols Outlined'",
|
|
1444
|
+
rounded: "'Material Symbols Rounded'",
|
|
1445
|
+
sharp: "'Material Symbols Sharp'"
|
|
1446
|
+
};
|
|
1447
|
+
var IconComponent = React12.forwardRef(
|
|
1448
|
+
(_a, ref) => {
|
|
1449
|
+
var _b = _a, {
|
|
1450
|
+
name,
|
|
1451
|
+
variant = "outlined",
|
|
1452
|
+
fill = 0,
|
|
1453
|
+
weight = 400,
|
|
1454
|
+
grade = 0,
|
|
1455
|
+
opticalSize = 24,
|
|
1456
|
+
size,
|
|
1457
|
+
animateFill = false,
|
|
1458
|
+
className,
|
|
1459
|
+
style
|
|
1460
|
+
} = _b, restProps = __objRest(_b, [
|
|
1461
|
+
"name",
|
|
1462
|
+
"variant",
|
|
1463
|
+
"fill",
|
|
1464
|
+
"weight",
|
|
1465
|
+
"grade",
|
|
1466
|
+
"opticalSize",
|
|
1467
|
+
"size",
|
|
1468
|
+
"animateFill",
|
|
1469
|
+
"className",
|
|
1470
|
+
"style"
|
|
1471
|
+
]);
|
|
1472
|
+
const fontVariationSettings = `'FILL' ${fill}, 'wght' ${weight}, 'GRAD' ${grade}, 'opsz' ${opticalSize}`;
|
|
1473
|
+
const computedStyle = __spreadValues({
|
|
1474
|
+
fontFamily: VARIANT_FONT[variant],
|
|
1475
|
+
fontSize: size === "inherit" ? "inherit" : size != null ? `${size}px` : `${opticalSize}px`,
|
|
1476
|
+
fontVariationSettings
|
|
1477
|
+
}, style);
|
|
1478
|
+
if (animateFill) {
|
|
1479
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
|
|
1480
|
+
m.span,
|
|
1481
|
+
__spreadProps(__spreadValues({
|
|
1482
|
+
ref,
|
|
1483
|
+
className: cn(
|
|
1484
|
+
"md-icon inline-flex items-center justify-center shrink-0 select-none",
|
|
1485
|
+
className
|
|
1486
|
+
),
|
|
1487
|
+
"aria-hidden": "true",
|
|
1488
|
+
animate: { fontVariationSettings },
|
|
1489
|
+
transition: SPRING_TRANSITION_FAST,
|
|
1490
|
+
style: computedStyle
|
|
1491
|
+
}, restProps), {
|
|
1492
|
+
children: name
|
|
1493
|
+
})
|
|
1494
|
+
) });
|
|
1495
|
+
}
|
|
1496
|
+
return /* @__PURE__ */ jsx(
|
|
1497
|
+
"span",
|
|
1498
|
+
__spreadProps(__spreadValues({
|
|
1499
|
+
ref,
|
|
1500
|
+
className: cn(
|
|
1501
|
+
"md-icon inline-flex items-center justify-center shrink-0 select-none",
|
|
1502
|
+
className
|
|
1503
|
+
),
|
|
1504
|
+
"aria-hidden": "true",
|
|
1505
|
+
style: computedStyle
|
|
1506
|
+
}, restProps), {
|
|
1507
|
+
children: name
|
|
1508
|
+
})
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1511
|
+
);
|
|
1512
|
+
IconComponent.displayName = "Icon";
|
|
1513
|
+
var Icon = React12.memo(IconComponent);
|
|
1514
|
+
var DURATION_MAP = {
|
|
1515
|
+
short: 4e3,
|
|
1516
|
+
long: 7e3
|
|
1517
|
+
};
|
|
1518
|
+
var RESULT = {
|
|
1519
|
+
ACTION: "action-performed",
|
|
1520
|
+
DISMISSED: "dismissed"
|
|
1521
|
+
};
|
|
1522
|
+
var SNACKBAR_SPRING = DEFAULT_SPATIAL_SPRING;
|
|
1523
|
+
var SNACKBAR_ANIM = {
|
|
1524
|
+
initial: { opacity: 0, y: 56, scale: 0.9 },
|
|
1525
|
+
animate: {
|
|
1526
|
+
opacity: 1,
|
|
1527
|
+
y: 0,
|
|
1528
|
+
scale: 1,
|
|
1529
|
+
transition: SNACKBAR_SPRING
|
|
1530
|
+
},
|
|
1531
|
+
exit: {
|
|
1532
|
+
opacity: 0,
|
|
1533
|
+
y: 24,
|
|
1534
|
+
scale: 0.95,
|
|
1535
|
+
transition: { duration: 0.2, ease: "easeIn" }
|
|
1536
|
+
}
|
|
1537
|
+
};
|
|
1538
|
+
var REDUCED_MOTION_ANIM = {
|
|
1539
|
+
initial: { opacity: 0 },
|
|
1540
|
+
animate: { opacity: 1 },
|
|
1541
|
+
exit: { opacity: 0 }
|
|
1542
|
+
};
|
|
1543
|
+
function resolveDuration(duration) {
|
|
1544
|
+
if (duration === void 0) return DURATION_MAP.short;
|
|
1545
|
+
if (typeof duration === "number") return duration;
|
|
1546
|
+
return DURATION_MAP[duration];
|
|
1547
|
+
}
|
|
1548
|
+
function generateId() {
|
|
1549
|
+
return typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(36).slice(2);
|
|
1550
|
+
}
|
|
1551
|
+
function toSnackbarData(item) {
|
|
1552
|
+
return { id: generateId(), visuals: item.visuals, resolve: item.resolve };
|
|
1553
|
+
}
|
|
1554
|
+
function useSnackbarState() {
|
|
1555
|
+
const [current, setCurrent] = React12.useState(null);
|
|
1556
|
+
const queueRef = React12.useRef([]);
|
|
1557
|
+
const showSnackbar = React12.useCallback(
|
|
1558
|
+
(visuals) => {
|
|
1559
|
+
return new Promise((resolve) => {
|
|
1560
|
+
const item = { visuals, resolve };
|
|
1561
|
+
setCurrent((prev) => {
|
|
1562
|
+
if (prev === null) return toSnackbarData(item);
|
|
1563
|
+
queueRef.current.push(item);
|
|
1564
|
+
return prev;
|
|
1565
|
+
});
|
|
1566
|
+
});
|
|
1567
|
+
},
|
|
1568
|
+
[]
|
|
1569
|
+
);
|
|
1570
|
+
const _dismiss = React12.useCallback((result) => {
|
|
1571
|
+
setCurrent((prev) => {
|
|
1572
|
+
if (prev) prev.resolve(result);
|
|
1573
|
+
const next = queueRef.current.shift();
|
|
1574
|
+
return next ? toSnackbarData(next) : null;
|
|
1575
|
+
});
|
|
1576
|
+
}, []);
|
|
1577
|
+
React12.useEffect(() => {
|
|
1578
|
+
return () => {
|
|
1579
|
+
for (const item of queueRef.current) {
|
|
1580
|
+
item.resolve(RESULT.DISMISSED);
|
|
1581
|
+
}
|
|
1582
|
+
queueRef.current = [];
|
|
1583
|
+
};
|
|
1584
|
+
}, []);
|
|
1585
|
+
return { current, showSnackbar, _dismiss };
|
|
1586
|
+
}
|
|
1587
|
+
var Snackbar = React12.memo(function Snackbar2({
|
|
1588
|
+
data,
|
|
1589
|
+
className
|
|
1590
|
+
}) {
|
|
1591
|
+
const { visuals, resolve } = data;
|
|
1592
|
+
const {
|
|
1593
|
+
message,
|
|
1594
|
+
actionLabel,
|
|
1595
|
+
withDismissAction = false,
|
|
1596
|
+
actionOnNewLine = false,
|
|
1597
|
+
duration
|
|
1598
|
+
} = visuals;
|
|
1599
|
+
const reducedMotion = useReducedMotion();
|
|
1600
|
+
const durationMs = resolveDuration(duration);
|
|
1601
|
+
React12.useEffect(() => {
|
|
1602
|
+
const timer = setTimeout(() => resolve(RESULT.DISMISSED), durationMs);
|
|
1603
|
+
return () => clearTimeout(timer);
|
|
1604
|
+
}, [resolve, durationMs]);
|
|
1605
|
+
const handleAction = React12.useCallback(
|
|
1606
|
+
() => resolve(RESULT.ACTION),
|
|
1607
|
+
[resolve]
|
|
1608
|
+
);
|
|
1609
|
+
const handleDismiss = React12.useCallback(
|
|
1610
|
+
() => resolve(RESULT.DISMISSED),
|
|
1611
|
+
[resolve]
|
|
1612
|
+
);
|
|
1613
|
+
const hasActions = actionLabel || withDismissAction;
|
|
1614
|
+
const anim = reducedMotion ? REDUCED_MOTION_ANIM : SNACKBAR_ANIM;
|
|
1615
|
+
return /* @__PURE__ */ jsxs(
|
|
1616
|
+
m.div,
|
|
1617
|
+
__spreadProps(__spreadValues({
|
|
1618
|
+
role: "status",
|
|
1619
|
+
"aria-live": "polite",
|
|
1620
|
+
"aria-atomic": "true"
|
|
1621
|
+
}, anim), {
|
|
1622
|
+
className: cn(
|
|
1623
|
+
"flex items-center gap-2",
|
|
1624
|
+
"min-w-72 max-w-142 w-max",
|
|
1625
|
+
"rounded-sm px-4 py-3 shadow-md",
|
|
1626
|
+
"text-m3-inverse-on-surface bg-m3-inverse-surface",
|
|
1627
|
+
actionOnNewLine ? "flex-col items-start" : "flex-row",
|
|
1628
|
+
className,
|
|
1629
|
+
visuals.className
|
|
1630
|
+
),
|
|
1631
|
+
children: [
|
|
1632
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1 text-sm leading-5 font-normal", children: message }),
|
|
1633
|
+
hasActions && /* @__PURE__ */ jsxs(
|
|
1634
|
+
"div",
|
|
1635
|
+
{
|
|
1636
|
+
className: cn(
|
|
1637
|
+
"flex shrink-0 items-center gap-1",
|
|
1638
|
+
actionOnNewLine && "self-end"
|
|
1639
|
+
),
|
|
1640
|
+
children: [
|
|
1641
|
+
actionLabel && /* @__PURE__ */ jsx(
|
|
1642
|
+
"button",
|
|
1643
|
+
{
|
|
1644
|
+
type: "button",
|
|
1645
|
+
onClick: handleAction,
|
|
1646
|
+
className: cn(
|
|
1647
|
+
"text-sm font-medium",
|
|
1648
|
+
"px-2 py-1 rounded-sm",
|
|
1649
|
+
"focus-visible:outline-none focus-visible:ring-2",
|
|
1650
|
+
"transition-colors whitespace-nowrap",
|
|
1651
|
+
"text-m3-inverse-primary"
|
|
1652
|
+
),
|
|
1653
|
+
children: actionLabel
|
|
1654
|
+
}
|
|
1655
|
+
),
|
|
1656
|
+
withDismissAction && /* @__PURE__ */ jsx(
|
|
1657
|
+
IconButton,
|
|
1658
|
+
{
|
|
1659
|
+
size: "sm",
|
|
1660
|
+
colorStyle: "filled",
|
|
1661
|
+
"aria-label": "Dismiss notification",
|
|
1662
|
+
onClick: handleDismiss,
|
|
1663
|
+
className: "text-m3-inverse-on-surface bg-m3-inverse-surface",
|
|
1664
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "close", "aria-hidden": "true" })
|
|
1665
|
+
}
|
|
1666
|
+
)
|
|
1667
|
+
]
|
|
1668
|
+
}
|
|
1669
|
+
)
|
|
1670
|
+
]
|
|
1671
|
+
})
|
|
1672
|
+
);
|
|
1673
|
+
});
|
|
1674
|
+
Snackbar.displayName = "Snackbar";
|
|
1675
|
+
function SnackbarHost({ state, className }) {
|
|
1676
|
+
const { current, _dismiss } = state;
|
|
1677
|
+
const wrappedData = React12.useMemo(() => {
|
|
1678
|
+
if (!current) return null;
|
|
1679
|
+
return __spreadProps(__spreadValues({}, current), { resolve: _dismiss });
|
|
1680
|
+
}, [current, _dismiss]);
|
|
1681
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
|
|
1682
|
+
"section",
|
|
1683
|
+
{
|
|
1684
|
+
"aria-label": "Snackbar notifications",
|
|
1685
|
+
className: cn(
|
|
1686
|
+
"fixed bottom-4 left-1/2 -translate-x-1/2 z-50",
|
|
1687
|
+
"flex flex-col items-center pointer-events-none",
|
|
1688
|
+
className
|
|
1689
|
+
),
|
|
1690
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: wrappedData && /* @__PURE__ */ jsx("div", { className: "pointer-events-auto", children: /* @__PURE__ */ jsx(Snackbar, { data: wrappedData }) }, wrappedData.id) })
|
|
1691
|
+
}
|
|
1692
|
+
) });
|
|
1693
|
+
}
|
|
1694
|
+
SnackbarHost.displayName = "SnackbarHost";
|
|
1695
|
+
var SnackbarContext = React12.createContext(
|
|
1696
|
+
null
|
|
1697
|
+
);
|
|
1698
|
+
function SnackbarProvider({ children }) {
|
|
1699
|
+
const state = useSnackbarState();
|
|
1700
|
+
const contextValue = React12.useMemo(
|
|
1701
|
+
() => ({ showSnackbar: state.showSnackbar }),
|
|
1702
|
+
[state.showSnackbar]
|
|
1703
|
+
);
|
|
1704
|
+
return /* @__PURE__ */ jsxs(SnackbarContext.Provider, { value: contextValue, children: [
|
|
1705
|
+
children,
|
|
1706
|
+
/* @__PURE__ */ jsx(SnackbarHost, { state })
|
|
1707
|
+
] });
|
|
1708
|
+
}
|
|
1709
|
+
SnackbarProvider.displayName = "SnackbarProvider";
|
|
1710
|
+
function useSnackbar() {
|
|
1711
|
+
const ctx = React12.useContext(SnackbarContext);
|
|
1712
|
+
if (!ctx) {
|
|
1713
|
+
throw new Error("useSnackbar must be used within a <SnackbarProvider>.");
|
|
1714
|
+
}
|
|
1715
|
+
return ctx;
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
// src/ui/tooltip/tooltip.tokens.ts
|
|
1719
|
+
var TooltipTokens = {
|
|
1720
|
+
PlainTooltip: {
|
|
1721
|
+
containerColor: "var(--md-sys-color-inverse-surface)",
|
|
1722
|
+
// #322F35 light / #E6E1E5 dark
|
|
1723
|
+
textColor: "var(--md-sys-color-inverse-on-surface)",
|
|
1724
|
+
// #F5EFF7 light / #322F35 dark
|
|
1725
|
+
shape: "rounded-[4px]",
|
|
1726
|
+
// CornerExtraSmall = 4dp
|
|
1727
|
+
font: "text-[12px] font-normal tracking-[0.4px] leading-[16px]",
|
|
1728
|
+
// BodySmall
|
|
1729
|
+
height: "min-h-6",
|
|
1730
|
+
// 24dp min height
|
|
1731
|
+
padding: "px-2 py-1",
|
|
1732
|
+
// 8dp all sides
|
|
1733
|
+
maxWidth: "max-w-50"
|
|
1734
|
+
},
|
|
1735
|
+
RichTooltip: {
|
|
1736
|
+
containerColor: "var(--md-sys-color-surface-container)",
|
|
1737
|
+
elevation: "shadow-md",
|
|
1738
|
+
// ElevationTokens.Level2 (approximate with shadow-md)
|
|
1739
|
+
shape: "rounded-[12px]",
|
|
1740
|
+
// CornerMedium = 12dp
|
|
1741
|
+
paddingTop: "pt-3",
|
|
1742
|
+
// 12dp
|
|
1743
|
+
paddingBottom: "pb-2",
|
|
1744
|
+
// 8dp
|
|
1745
|
+
paddingX: "px-4",
|
|
1746
|
+
// 16dp
|
|
1747
|
+
maxWidth: "max-w-80",
|
|
1748
|
+
subheadColor: "var(--md-sys-color-on-surface-variant)",
|
|
1749
|
+
subheadFont: "text-[14px] font-medium leading-[20px]",
|
|
1750
|
+
// TitleSmall
|
|
1751
|
+
bodyColor: "var(--md-sys-color-on-surface-variant)",
|
|
1752
|
+
bodyFont: "text-[14px] font-normal leading-[20px]",
|
|
1753
|
+
// BodyMedium
|
|
1754
|
+
actionColor: "var(--md-sys-color-primary)",
|
|
1755
|
+
actionFont: "text-[14px] font-medium leading-[20px]"
|
|
1756
|
+
// LabelLarge
|
|
1757
|
+
}
|
|
1758
|
+
};
|
|
1759
|
+
var CENTER_H = "left-1/2 -translate-x-1/2";
|
|
1760
|
+
var CENTER_V = "top-1/2 -translate-y-1/2 flex items-center justify-center";
|
|
1761
|
+
var POSITION_BY_SIDE = {
|
|
1762
|
+
top: (h) => `bottom-[calc(-1*${h}px)] ${CENTER_H}`,
|
|
1763
|
+
bottom: (h) => `top-[calc(-1*${h}px)] ${CENTER_H}`,
|
|
1764
|
+
left: (h) => `right-[calc(-1*${h}px)] ${CENTER_V}`,
|
|
1765
|
+
right: (h) => `left-[calc(-1*${h}px)] ${CENTER_V}`
|
|
1766
|
+
};
|
|
1767
|
+
var ROTATION = {
|
|
1768
|
+
top: "180deg",
|
|
1769
|
+
bottom: "0deg",
|
|
1770
|
+
left: "90deg",
|
|
1771
|
+
right: "-90deg"
|
|
1772
|
+
};
|
|
1773
|
+
function TooltipCaretShape({
|
|
1774
|
+
side,
|
|
1775
|
+
width = 16,
|
|
1776
|
+
height = 8,
|
|
1777
|
+
color,
|
|
1778
|
+
customPath,
|
|
1779
|
+
className = ""
|
|
1780
|
+
}) {
|
|
1781
|
+
const isHorizontal = side === "left" || side === "right";
|
|
1782
|
+
const path = customPath != null ? customPath : `M 0,${height} L ${width / 2},0 L ${width},${height} Z`;
|
|
1783
|
+
return /* @__PURE__ */ jsx(
|
|
1784
|
+
"div",
|
|
1785
|
+
{
|
|
1786
|
+
className: `absolute pointer-events-none z-[-1] ${POSITION_BY_SIDE[side](height)} ${className}`,
|
|
1787
|
+
style: {
|
|
1788
|
+
width: isHorizontal ? height : width,
|
|
1789
|
+
height: isHorizontal ? width : height,
|
|
1790
|
+
color
|
|
1791
|
+
},
|
|
1792
|
+
"aria-hidden": "true",
|
|
1793
|
+
children: /* @__PURE__ */ jsx(
|
|
1794
|
+
"svg",
|
|
1795
|
+
{
|
|
1796
|
+
width,
|
|
1797
|
+
height,
|
|
1798
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
1799
|
+
fill: "currentColor",
|
|
1800
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1801
|
+
"aria-hidden": "true",
|
|
1802
|
+
style: {
|
|
1803
|
+
transform: `rotate(${ROTATION[side]})`,
|
|
1804
|
+
display: "block",
|
|
1805
|
+
transformOrigin: "center"
|
|
1806
|
+
},
|
|
1807
|
+
children: /* @__PURE__ */ jsx("path", { d: path })
|
|
1808
|
+
}
|
|
1809
|
+
)
|
|
1810
|
+
}
|
|
1811
|
+
);
|
|
1812
|
+
}
|
|
1813
|
+
var PlainTooltip = forwardRef(
|
|
1814
|
+
(_a, ref) => {
|
|
1815
|
+
var _b = _a, {
|
|
1816
|
+
children,
|
|
1817
|
+
caret,
|
|
1818
|
+
className = "",
|
|
1819
|
+
maxWidth,
|
|
1820
|
+
containerColor,
|
|
1821
|
+
textColor
|
|
1822
|
+
} = _b, props = __objRest(_b, [
|
|
1823
|
+
"children",
|
|
1824
|
+
"caret",
|
|
1825
|
+
"className",
|
|
1826
|
+
"maxWidth",
|
|
1827
|
+
"containerColor",
|
|
1828
|
+
"textColor"
|
|
1829
|
+
]);
|
|
1830
|
+
var _a2;
|
|
1831
|
+
const {
|
|
1832
|
+
containerColor: tokenContainer,
|
|
1833
|
+
textColor: tokenText,
|
|
1834
|
+
font,
|
|
1835
|
+
padding,
|
|
1836
|
+
shape,
|
|
1837
|
+
height,
|
|
1838
|
+
maxWidth: tokenMaxWidth
|
|
1839
|
+
} = TooltipTokens.PlainTooltip;
|
|
1840
|
+
const style = __spreadValues(__spreadProps(__spreadValues({}, props.style), {
|
|
1841
|
+
backgroundColor: containerColor != null ? containerColor : tokenContainer,
|
|
1842
|
+
color: textColor != null ? textColor : tokenText
|
|
1843
|
+
}), maxWidth && { maxWidth });
|
|
1844
|
+
const side = (_a2 = props["data-side"]) != null ? _a2 : "top";
|
|
1845
|
+
return /* @__PURE__ */ jsxs(
|
|
1846
|
+
"div",
|
|
1847
|
+
__spreadProps(__spreadValues({
|
|
1848
|
+
ref,
|
|
1849
|
+
className: `relative inline-flex items-center box-border ${shape} ${font} ${padding} ${height} ${!maxWidth ? tokenMaxWidth : ""} ${className}`,
|
|
1850
|
+
style
|
|
1851
|
+
}, props), {
|
|
1852
|
+
children: [
|
|
1853
|
+
(caret == null ? void 0 : caret.enabled) && /* @__PURE__ */ jsx(
|
|
1854
|
+
TooltipCaretShape,
|
|
1855
|
+
{
|
|
1856
|
+
side,
|
|
1857
|
+
width: caret.width,
|
|
1858
|
+
height: caret.height,
|
|
1859
|
+
color: style.backgroundColor,
|
|
1860
|
+
customPath: caret.customPath
|
|
1861
|
+
}
|
|
1862
|
+
),
|
|
1863
|
+
/* @__PURE__ */ jsx("span", { className: "whitespace-normal text-start wrap-break-word", children })
|
|
1864
|
+
]
|
|
1865
|
+
})
|
|
1866
|
+
);
|
|
1867
|
+
}
|
|
1868
|
+
);
|
|
1869
|
+
PlainTooltip.displayName = "PlainTooltip";
|
|
1870
|
+
var RichTooltip = forwardRef(
|
|
1871
|
+
(_a, ref) => {
|
|
1872
|
+
var _b = _a, {
|
|
1873
|
+
children,
|
|
1874
|
+
title,
|
|
1875
|
+
action,
|
|
1876
|
+
caret,
|
|
1877
|
+
className = "",
|
|
1878
|
+
maxWidth,
|
|
1879
|
+
colors = {}
|
|
1880
|
+
} = _b, props = __objRest(_b, [
|
|
1881
|
+
"children",
|
|
1882
|
+
"title",
|
|
1883
|
+
"action",
|
|
1884
|
+
"caret",
|
|
1885
|
+
"className",
|
|
1886
|
+
"maxWidth",
|
|
1887
|
+
"colors"
|
|
1888
|
+
]);
|
|
1889
|
+
var _a2, _b2, _c, _d, _e;
|
|
1890
|
+
const {
|
|
1891
|
+
containerColor: tokenContainer,
|
|
1892
|
+
elevation,
|
|
1893
|
+
shape,
|
|
1894
|
+
paddingTop,
|
|
1895
|
+
paddingBottom,
|
|
1896
|
+
paddingX,
|
|
1897
|
+
maxWidth: tokenMaxWidth,
|
|
1898
|
+
subheadColor,
|
|
1899
|
+
subheadFont,
|
|
1900
|
+
bodyColor,
|
|
1901
|
+
bodyFont,
|
|
1902
|
+
actionColor,
|
|
1903
|
+
actionFont
|
|
1904
|
+
} = TooltipTokens.RichTooltip;
|
|
1905
|
+
const containerStyle = __spreadValues(__spreadProps(__spreadValues({}, props.style), {
|
|
1906
|
+
backgroundColor: (_a2 = colors.container) != null ? _a2 : tokenContainer
|
|
1907
|
+
}), maxWidth && { maxWidth });
|
|
1908
|
+
const side = (_b2 = props["data-side"]) != null ? _b2 : "top";
|
|
1909
|
+
const titleColor = (_c = colors.title) != null ? _c : subheadColor;
|
|
1910
|
+
const bodyColorResolved = (_d = colors.body) != null ? _d : bodyColor;
|
|
1911
|
+
const actionColorResolved = (_e = colors.action) != null ? _e : actionColor;
|
|
1912
|
+
return /* @__PURE__ */ jsxs(
|
|
1913
|
+
"div",
|
|
1914
|
+
__spreadProps(__spreadValues({
|
|
1915
|
+
ref,
|
|
1916
|
+
className: `relative box-border flex flex-col ${shape} ${elevation} ${paddingTop} ${paddingBottom} ${paddingX} ${!maxWidth ? tokenMaxWidth : ""} ${className}`,
|
|
1917
|
+
style: containerStyle
|
|
1918
|
+
}, props), {
|
|
1919
|
+
children: [
|
|
1920
|
+
(caret == null ? void 0 : caret.enabled) && /* @__PURE__ */ jsx(
|
|
1921
|
+
TooltipCaretShape,
|
|
1922
|
+
{
|
|
1923
|
+
side,
|
|
1924
|
+
width: caret.width,
|
|
1925
|
+
height: caret.height,
|
|
1926
|
+
color: containerStyle.backgroundColor,
|
|
1927
|
+
customPath: caret.customPath
|
|
1928
|
+
}
|
|
1929
|
+
),
|
|
1930
|
+
title && /* @__PURE__ */ jsx("div", { className: `mb-1 ${subheadFont}`, style: { color: titleColor }, children: title }),
|
|
1931
|
+
children && /* @__PURE__ */ jsx(
|
|
1932
|
+
"div",
|
|
1933
|
+
{
|
|
1934
|
+
className: `whitespace-normal text-start wrap-break-word ${bodyFont}`,
|
|
1935
|
+
style: { color: bodyColorResolved },
|
|
1936
|
+
children
|
|
1937
|
+
}
|
|
1938
|
+
),
|
|
1939
|
+
action && /* @__PURE__ */ jsx(
|
|
1940
|
+
"div",
|
|
1941
|
+
{
|
|
1942
|
+
className: `mt-2 flex min-h-9 flex-wrap items-center gap-2 ${actionFont}`,
|
|
1943
|
+
style: { color: actionColorResolved },
|
|
1944
|
+
children: action
|
|
1945
|
+
}
|
|
1946
|
+
)
|
|
1947
|
+
]
|
|
1948
|
+
})
|
|
1949
|
+
);
|
|
1950
|
+
}
|
|
1951
|
+
);
|
|
1952
|
+
RichTooltip.displayName = "RichTooltip";
|
|
1953
|
+
var VIEWPORT_PADDING = 8;
|
|
1954
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
1955
|
+
function resolveAutoPlacement(spaceTop, spaceBottom, spaceLeft, spaceRight, tooltipWidth, tooltipHeight, spacing) {
|
|
1956
|
+
if (spaceTop >= tooltipHeight + spacing) return "top";
|
|
1957
|
+
if (spaceBottom >= tooltipHeight + spacing) return "bottom";
|
|
1958
|
+
if (spaceLeft >= tooltipWidth + spacing) return "left";
|
|
1959
|
+
if (spaceRight >= tooltipWidth + spacing) return "right";
|
|
1960
|
+
return "top";
|
|
1961
|
+
}
|
|
1962
|
+
function resolveActualSide(targetPlacement, spaceTop, spaceBottom, spaceLeft, spaceRight, tooltipWidth, tooltipHeight, spacing) {
|
|
1963
|
+
const needsHeight = tooltipHeight + spacing;
|
|
1964
|
+
const needsWidth = tooltipWidth + spacing;
|
|
1965
|
+
if (targetPlacement === "top")
|
|
1966
|
+
return spaceTop < needsHeight && spaceBottom >= needsHeight ? "bottom" : "top";
|
|
1967
|
+
if (targetPlacement === "bottom")
|
|
1968
|
+
return spaceBottom < needsHeight && spaceTop >= needsHeight ? "top" : "bottom";
|
|
1969
|
+
if (targetPlacement === "left")
|
|
1970
|
+
return spaceLeft < needsWidth && spaceRight >= needsWidth ? "right" : "left";
|
|
1971
|
+
return spaceRight < needsWidth && spaceLeft >= needsWidth ? "left" : "right";
|
|
1972
|
+
}
|
|
1973
|
+
function calculateXY(side, anchorRect, tooltipWidth, tooltipHeight, spacing) {
|
|
1974
|
+
const anchorCenterX = anchorRect.left + anchorRect.width / 2;
|
|
1975
|
+
const anchorCenterY = anchorRect.top + anchorRect.height / 2;
|
|
1976
|
+
if (side === "top")
|
|
1977
|
+
return {
|
|
1978
|
+
top: anchorRect.top - tooltipHeight - spacing,
|
|
1979
|
+
left: anchorCenterX - tooltipWidth / 2
|
|
1980
|
+
};
|
|
1981
|
+
if (side === "bottom")
|
|
1982
|
+
return {
|
|
1983
|
+
top: anchorRect.bottom + spacing,
|
|
1984
|
+
left: anchorCenterX - tooltipWidth / 2
|
|
1985
|
+
};
|
|
1986
|
+
if (side === "left")
|
|
1987
|
+
return {
|
|
1988
|
+
top: anchorCenterY - tooltipHeight / 2,
|
|
1989
|
+
left: anchorRect.left - tooltipWidth - spacing
|
|
1990
|
+
};
|
|
1991
|
+
return {
|
|
1992
|
+
top: anchorCenterY - tooltipHeight / 2,
|
|
1993
|
+
left: anchorRect.right + spacing
|
|
1994
|
+
};
|
|
1995
|
+
}
|
|
1996
|
+
function clampToViewport(side, top, left, tooltipWidth, tooltipHeight) {
|
|
1997
|
+
const isVertical = side === "top" || side === "bottom";
|
|
1998
|
+
const viewportWidth = window.innerWidth;
|
|
1999
|
+
const viewportHeight = window.innerHeight;
|
|
2000
|
+
if (isVertical) {
|
|
2001
|
+
left = Math.max(
|
|
2002
|
+
VIEWPORT_PADDING,
|
|
2003
|
+
Math.min(left, viewportWidth - VIEWPORT_PADDING - tooltipWidth)
|
|
2004
|
+
);
|
|
2005
|
+
} else {
|
|
2006
|
+
top = Math.max(
|
|
2007
|
+
VIEWPORT_PADDING,
|
|
2008
|
+
Math.min(top, viewportHeight - VIEWPORT_PADDING - tooltipHeight)
|
|
2009
|
+
);
|
|
2010
|
+
}
|
|
2011
|
+
return { top, left };
|
|
2012
|
+
}
|
|
2013
|
+
function useTooltipPosition(anchorRef, tooltipRef, placement, spacing, isVisible) {
|
|
2014
|
+
const [position, setPosition] = useState({
|
|
2015
|
+
top: -9999,
|
|
2016
|
+
left: -9999,
|
|
2017
|
+
actualSide: placement === "auto" ? "top" : placement
|
|
2018
|
+
});
|
|
2019
|
+
useIsomorphicLayoutEffect(() => {
|
|
2020
|
+
if (!isVisible || !anchorRef.current || !tooltipRef.current) return;
|
|
2021
|
+
const calculatePosition = () => {
|
|
2022
|
+
const anchorEl = anchorRef.current;
|
|
2023
|
+
const tooltipEl = tooltipRef.current;
|
|
2024
|
+
if (!anchorEl || !tooltipEl) return;
|
|
2025
|
+
const anchorRect = anchorEl.getBoundingClientRect();
|
|
2026
|
+
const tooltipRect = tooltipEl.getBoundingClientRect();
|
|
2027
|
+
const tooltipWidth = tooltipRect.width;
|
|
2028
|
+
const tooltipHeight = tooltipRect.height;
|
|
2029
|
+
const spaceTop = anchorRect.top;
|
|
2030
|
+
const spaceBottom = window.innerHeight - anchorRect.bottom;
|
|
2031
|
+
const spaceLeft = anchorRect.left;
|
|
2032
|
+
const spaceRight = window.innerWidth - anchorRect.right;
|
|
2033
|
+
const targetSide = placement === "auto" ? resolveAutoPlacement(
|
|
2034
|
+
spaceTop,
|
|
2035
|
+
spaceBottom,
|
|
2036
|
+
spaceLeft,
|
|
2037
|
+
spaceRight,
|
|
2038
|
+
tooltipWidth,
|
|
2039
|
+
tooltipHeight,
|
|
2040
|
+
spacing
|
|
2041
|
+
) : placement;
|
|
2042
|
+
const actualSide = resolveActualSide(
|
|
2043
|
+
targetSide,
|
|
2044
|
+
spaceTop,
|
|
2045
|
+
spaceBottom,
|
|
2046
|
+
spaceLeft,
|
|
2047
|
+
spaceRight,
|
|
2048
|
+
tooltipWidth,
|
|
2049
|
+
tooltipHeight,
|
|
2050
|
+
spacing
|
|
2051
|
+
);
|
|
2052
|
+
const { top, left } = calculateXY(
|
|
2053
|
+
actualSide,
|
|
2054
|
+
anchorRect,
|
|
2055
|
+
tooltipWidth,
|
|
2056
|
+
tooltipHeight,
|
|
2057
|
+
spacing
|
|
2058
|
+
);
|
|
2059
|
+
const clamped = clampToViewport(
|
|
2060
|
+
actualSide,
|
|
2061
|
+
top,
|
|
2062
|
+
left,
|
|
2063
|
+
tooltipWidth,
|
|
2064
|
+
tooltipHeight
|
|
2065
|
+
);
|
|
2066
|
+
setPosition(__spreadProps(__spreadValues({}, clamped), { actualSide }));
|
|
2067
|
+
};
|
|
2068
|
+
calculatePosition();
|
|
2069
|
+
window.addEventListener("resize", calculatePosition);
|
|
2070
|
+
window.addEventListener("scroll", calculatePosition, true);
|
|
2071
|
+
const resizeObserver = new ResizeObserver(calculatePosition);
|
|
2072
|
+
if (anchorRef.current) resizeObserver.observe(anchorRef.current);
|
|
2073
|
+
if (tooltipRef.current) resizeObserver.observe(tooltipRef.current);
|
|
2074
|
+
return () => {
|
|
2075
|
+
window.removeEventListener("resize", calculatePosition);
|
|
2076
|
+
window.removeEventListener("scroll", calculatePosition, true);
|
|
2077
|
+
resizeObserver.disconnect();
|
|
2078
|
+
};
|
|
2079
|
+
}, [isVisible, placement, spacing, anchorRef, tooltipRef]);
|
|
2080
|
+
return position;
|
|
2081
|
+
}
|
|
2082
|
+
var activeTooltipDismissals = /* @__PURE__ */ new Set();
|
|
2083
|
+
function useTooltipState(config) {
|
|
2084
|
+
const {
|
|
2085
|
+
initialVisible = false,
|
|
2086
|
+
isPersistent = false,
|
|
2087
|
+
duration = 1500
|
|
2088
|
+
} = config != null ? config : {};
|
|
2089
|
+
const [isVisible, setIsVisible] = useState(initialVisible);
|
|
2090
|
+
const dismiss = useCallback(() => {
|
|
2091
|
+
setIsVisible(false);
|
|
2092
|
+
activeTooltipDismissals.delete(dismiss);
|
|
2093
|
+
}, []);
|
|
2094
|
+
const show = useCallback(() => {
|
|
2095
|
+
for (const otherDismiss of activeTooltipDismissals) {
|
|
2096
|
+
if (otherDismiss !== dismiss) otherDismiss();
|
|
2097
|
+
}
|
|
2098
|
+
setIsVisible(true);
|
|
2099
|
+
activeTooltipDismissals.add(dismiss);
|
|
2100
|
+
}, [dismiss]);
|
|
2101
|
+
useEffect(() => {
|
|
2102
|
+
if (!isVisible || isPersistent) return;
|
|
2103
|
+
const timeoutId = setTimeout(dismiss, duration);
|
|
2104
|
+
return () => clearTimeout(timeoutId);
|
|
2105
|
+
}, [isVisible, isPersistent, duration, dismiss]);
|
|
2106
|
+
useEffect(() => {
|
|
2107
|
+
return () => {
|
|
2108
|
+
activeTooltipDismissals.delete(dismiss);
|
|
2109
|
+
};
|
|
2110
|
+
}, [dismiss]);
|
|
2111
|
+
return { isVisible, show, dismiss };
|
|
2112
|
+
}
|
|
2113
|
+
var TRANSFORM_ORIGIN = {
|
|
2114
|
+
top: "50% 100%",
|
|
2115
|
+
bottom: "50% 0%",
|
|
2116
|
+
left: "100% 50%",
|
|
2117
|
+
right: "0% 50%"
|
|
2118
|
+
};
|
|
2119
|
+
var MOTION_VARIANTS = {
|
|
2120
|
+
full: {
|
|
2121
|
+
hidden: { opacity: 0, scale: 0.8 },
|
|
2122
|
+
visible: {
|
|
2123
|
+
opacity: 1,
|
|
2124
|
+
scale: 1,
|
|
2125
|
+
transition: {
|
|
2126
|
+
opacity: { duration: 0.1, ease: "easeOut" },
|
|
2127
|
+
scale: { type: "spring", stiffness: 900, damping: 90, mass: 0.5 }
|
|
2128
|
+
}
|
|
2129
|
+
},
|
|
2130
|
+
exit: {
|
|
2131
|
+
opacity: 0,
|
|
2132
|
+
scale: 0.8,
|
|
2133
|
+
transition: {
|
|
2134
|
+
opacity: { duration: 0.075, ease: "easeIn" },
|
|
2135
|
+
scale: { duration: 0.1, ease: "easeIn" }
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
},
|
|
2139
|
+
reduced: {
|
|
2140
|
+
hidden: { opacity: 0 },
|
|
2141
|
+
visible: { opacity: 1, transition: { duration: 0.15 } },
|
|
2142
|
+
exit: { opacity: 0, transition: { duration: 0.1 } }
|
|
2143
|
+
}
|
|
2144
|
+
};
|
|
2145
|
+
function clearTimeout2(ref) {
|
|
2146
|
+
if (ref.current !== null) window.clearTimeout(ref.current);
|
|
2147
|
+
}
|
|
2148
|
+
function TooltipBox({
|
|
2149
|
+
children,
|
|
2150
|
+
tooltip,
|
|
2151
|
+
placement = "top",
|
|
2152
|
+
trigger = ["hover", "focus"],
|
|
2153
|
+
state: controlledState,
|
|
2154
|
+
spacingFromAnchor = 4,
|
|
2155
|
+
disabled = false,
|
|
2156
|
+
className = "",
|
|
2157
|
+
showDelay = 400,
|
|
2158
|
+
hideDelay = 200,
|
|
2159
|
+
"aria-label": ariaLabel
|
|
2160
|
+
}) {
|
|
2161
|
+
const internalState = useTooltipState();
|
|
2162
|
+
const state = controlledState != null ? controlledState : internalState;
|
|
2163
|
+
const anchorRef = useRef(null);
|
|
2164
|
+
const tooltipRef = useRef(null);
|
|
2165
|
+
const hoverTimeoutRef = useRef(null);
|
|
2166
|
+
const hideTimeoutRef = useRef(null);
|
|
2167
|
+
const pressTimeoutRef = useRef(null);
|
|
2168
|
+
const triggers = Array.isArray(trigger) ? trigger : [trigger];
|
|
2169
|
+
const [mounted, setMounted] = useState(false);
|
|
2170
|
+
const [hasHoverSupport, setHasHoverSupport] = useState(true);
|
|
2171
|
+
const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
|
|
2172
|
+
useEffect(() => {
|
|
2173
|
+
setMounted(true);
|
|
2174
|
+
setHasHoverSupport(!window.matchMedia("(hover: none)").matches);
|
|
2175
|
+
}, []);
|
|
2176
|
+
useEffect(() => {
|
|
2177
|
+
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
2178
|
+
setPrefersReducedMotion(mediaQuery.matches);
|
|
2179
|
+
const onChange = (e) => setPrefersReducedMotion(e.matches);
|
|
2180
|
+
mediaQuery.addEventListener("change", onChange);
|
|
2181
|
+
return () => mediaQuery.removeEventListener("change", onChange);
|
|
2182
|
+
}, []);
|
|
2183
|
+
const position = useTooltipPosition(
|
|
2184
|
+
anchorRef,
|
|
2185
|
+
tooltipRef,
|
|
2186
|
+
placement,
|
|
2187
|
+
spacingFromAnchor,
|
|
2188
|
+
state.isVisible
|
|
2189
|
+
);
|
|
2190
|
+
const canHover = !disabled && hasHoverSupport && triggers.includes("hover");
|
|
2191
|
+
const canClick = !disabled && triggers.includes("click");
|
|
2192
|
+
const handlePointerEnter = () => {
|
|
2193
|
+
if (!canHover) return;
|
|
2194
|
+
clearTimeout2(hoverTimeoutRef);
|
|
2195
|
+
clearTimeout2(hideTimeoutRef);
|
|
2196
|
+
hoverTimeoutRef.current = window.setTimeout(() => state.show(), showDelay);
|
|
2197
|
+
};
|
|
2198
|
+
const handlePointerLeave = () => {
|
|
2199
|
+
if (!canHover) return;
|
|
2200
|
+
clearTimeout2(hoverTimeoutRef);
|
|
2201
|
+
hideTimeoutRef.current = window.setTimeout(
|
|
2202
|
+
() => state.dismiss(),
|
|
2203
|
+
hideDelay
|
|
2204
|
+
);
|
|
2205
|
+
};
|
|
2206
|
+
const handleFocus = () => {
|
|
2207
|
+
if (disabled || !triggers.includes("focus")) return;
|
|
2208
|
+
state.show();
|
|
2209
|
+
};
|
|
2210
|
+
const handleBlur = (e) => {
|
|
2211
|
+
if (disabled) return;
|
|
2212
|
+
const focusMovedInside = tooltipRef.current && (e.relatedTarget === tooltipRef.current || tooltipRef.current.contains(e.relatedTarget));
|
|
2213
|
+
if (focusMovedInside) return;
|
|
2214
|
+
state.dismiss();
|
|
2215
|
+
};
|
|
2216
|
+
const handlePointerDown = (e) => {
|
|
2217
|
+
if (disabled || !triggers.includes("long-press") || e.pointerType === "mouse")
|
|
2218
|
+
return;
|
|
2219
|
+
clearTimeout2(pressTimeoutRef);
|
|
2220
|
+
pressTimeoutRef.current = window.setTimeout(() => state.show(), 500);
|
|
2221
|
+
};
|
|
2222
|
+
const handleClick = () => {
|
|
2223
|
+
if (!canClick) return;
|
|
2224
|
+
if (state.isVisible) state.dismiss();
|
|
2225
|
+
else state.show();
|
|
2226
|
+
};
|
|
2227
|
+
const handleKeyDown = (e) => {
|
|
2228
|
+
if (disabled || !canClick) return;
|
|
2229
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
2230
|
+
e.preventDefault();
|
|
2231
|
+
handleClick();
|
|
2232
|
+
}
|
|
2233
|
+
};
|
|
2234
|
+
const handleContextMenu = (e) => {
|
|
2235
|
+
if (triggers.includes("long-press") && state.isVisible) e.preventDefault();
|
|
2236
|
+
};
|
|
2237
|
+
const handleTooltipPointerEnter = () => {
|
|
2238
|
+
if (!canHover) return;
|
|
2239
|
+
clearTimeout2(hideTimeoutRef);
|
|
2240
|
+
};
|
|
2241
|
+
const handleTooltipPointerLeave = () => {
|
|
2242
|
+
if (!canHover) return;
|
|
2243
|
+
hideTimeoutRef.current = window.setTimeout(
|
|
2244
|
+
() => state.dismiss(),
|
|
2245
|
+
hideDelay
|
|
2246
|
+
);
|
|
2247
|
+
};
|
|
2248
|
+
useEffect(() => {
|
|
2249
|
+
if (!state.isVisible) return;
|
|
2250
|
+
const onKeyDown = (e) => {
|
|
2251
|
+
var _a;
|
|
2252
|
+
if (e.key === "Escape") {
|
|
2253
|
+
state.dismiss();
|
|
2254
|
+
(_a = anchorRef.current) == null ? void 0 : _a.focus();
|
|
2255
|
+
}
|
|
2256
|
+
};
|
|
2257
|
+
document.addEventListener("keydown", onKeyDown);
|
|
2258
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
2259
|
+
}, [state.isVisible, state]);
|
|
2260
|
+
const tooltipId = useId();
|
|
2261
|
+
const tooltipWithProps = cloneElement(
|
|
2262
|
+
tooltip,
|
|
2263
|
+
{
|
|
2264
|
+
"data-side": position.actualSide,
|
|
2265
|
+
id: tooltipId,
|
|
2266
|
+
role: "tooltip",
|
|
2267
|
+
onBlur: handleBlur
|
|
2268
|
+
}
|
|
2269
|
+
);
|
|
2270
|
+
const variants = prefersReducedMotion ? MOTION_VARIANTS.reduced : MOTION_VARIANTS.full;
|
|
2271
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2272
|
+
/* @__PURE__ */ jsx(
|
|
2273
|
+
Slot,
|
|
2274
|
+
{
|
|
2275
|
+
ref: anchorRef,
|
|
2276
|
+
className: `inline-flex ${className}`,
|
|
2277
|
+
onPointerEnter: handlePointerEnter,
|
|
2278
|
+
onPointerLeave: handlePointerLeave,
|
|
2279
|
+
onFocus: handleFocus,
|
|
2280
|
+
onBlur: handleBlur,
|
|
2281
|
+
onPointerDown: handlePointerDown,
|
|
2282
|
+
onPointerUp: () => clearTimeout2(pressTimeoutRef),
|
|
2283
|
+
onPointerCancel: () => clearTimeout2(pressTimeoutRef),
|
|
2284
|
+
onContextMenu: handleContextMenu,
|
|
2285
|
+
onClick: handleClick,
|
|
2286
|
+
onKeyDown: handleKeyDown,
|
|
2287
|
+
"aria-label": ariaLabel,
|
|
2288
|
+
"aria-describedby": state.isVisible ? tooltipId : void 0,
|
|
2289
|
+
children: React12.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children })
|
|
2290
|
+
}
|
|
2291
|
+
),
|
|
2292
|
+
mounted && createPortal(
|
|
2293
|
+
/* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: state.isVisible && !disabled && /* @__PURE__ */ jsx(
|
|
2294
|
+
m.div,
|
|
2295
|
+
{
|
|
2296
|
+
ref: tooltipRef,
|
|
2297
|
+
initial: "hidden",
|
|
2298
|
+
animate: "visible",
|
|
2299
|
+
exit: "exit",
|
|
2300
|
+
variants,
|
|
2301
|
+
onPointerEnter: handleTooltipPointerEnter,
|
|
2302
|
+
onPointerLeave: handleTooltipPointerLeave,
|
|
2303
|
+
style: {
|
|
2304
|
+
position: "fixed",
|
|
2305
|
+
top: position.top,
|
|
2306
|
+
left: position.left,
|
|
2307
|
+
transformOrigin: TRANSFORM_ORIGIN[position.actualSide],
|
|
2308
|
+
zIndex: 50,
|
|
2309
|
+
pointerEvents: "auto"
|
|
2310
|
+
},
|
|
2311
|
+
children: tooltipWithProps
|
|
2312
|
+
}
|
|
2313
|
+
) }),
|
|
2314
|
+
document.body
|
|
2315
|
+
)
|
|
2316
|
+
] });
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
export { Badge, BadgedBox, LoadingIndicator, PlainTooltip, ProgressIndicator, RichTooltip, Snackbar, SnackbarHost, SnackbarProvider, TooltipBox, TooltipCaretShape, TooltipTokens, useSnackbar, useSnackbarState, useTooltipPosition, useTooltipState };
|
|
2320
|
+
//# sourceMappingURL=feedback.mjs.map
|
|
2321
|
+
//# sourceMappingURL=feedback.mjs.map
|