@yamatozhen/design_system 1.0.1 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +101 -101
  3. package/package.json +50 -50
  4. package/scripts/postinstall.js +91 -91
  5. package/template/app/ClientNav.tsx +258 -310
  6. package/template/app/globals.css +2 -167
  7. package/template/app/layout.tsx +94 -82
  8. package/template/app/themes/dark-mc.css +51 -51
  9. package/template/app/themes/dark.css +51 -51
  10. package/template/app/themes/light-mc.css +51 -51
  11. package/template/app/themes/light.css +51 -51
  12. package/template/app/themes/theme.css +272 -82
  13. package/template/components/{layout/button → (buttons)}/Button.module.css +351 -305
  14. package/template/components/{layout/button → (buttons)}/ButtonGroup.tsx +414 -503
  15. package/template/components/{layout/button → (buttons)}/FAB.tsx +119 -118
  16. package/template/components/(buttons)/button.tsx +164 -0
  17. package/template/components/(controls)/slider/Slider.module.css +250 -0
  18. package/template/components/(controls)/slider/Slider.tsx +386 -0
  19. package/template/components/{layout → (controls)}/switch/Switch.module.css +108 -102
  20. package/template/components/{layout → (controls)}/switch/Switch.tsx +69 -48
  21. package/template/components/(date & time)/calendar/Calendar.module.css +125 -0
  22. package/template/components/(date & time)/calendar/Calendar.tsx +206 -0
  23. package/template/components/(date & time)/dateField/DateField.module.css +25 -0
  24. package/template/components/(date & time)/dateField/DateField.tsx +193 -0
  25. package/template/components/(date & time)/datePicker/DatePicker.tsx +118 -0
  26. package/template/components/(date & time)/dateRangePicker/DateRangePicker.tsx +144 -0
  27. package/template/components/(date & time)/rangeCalendar/RangeCalendar.module.css +203 -0
  28. package/template/components/(date & time)/rangeCalendar/RangeCalendar.tsx +263 -0
  29. package/template/components/(date & time)/shared/dateUtils.ts +107 -0
  30. package/template/components/(date & time)/timeField/TimeField.module.css +39 -0
  31. package/template/components/(date & time)/timeField/TimeField.tsx +158 -0
  32. package/template/components/(feedback)/circularProgress/CircularProgress.tsx +646 -0
  33. package/template/components/(feedback)/linearProgress/LinearProgress.tsx +337 -0
  34. package/template/components/(feedback)/meter/Meter.tsx +111 -0
  35. package/template/components/(feedback)/skeleton/Skeleton.module.css +49 -0
  36. package/template/components/(feedback)/skeleton/Skeleton.tsx +32 -0
  37. package/template/components/(feedback)/spinner/Spinner.module.css +27 -0
  38. package/template/components/(feedback)/spinner/Spinner.tsx +60 -0
  39. package/template/components/(forms)/checkbox/Checkbox.tsx +121 -0
  40. package/template/components/(forms)/checkboxGroup/CheckboxGroup.tsx +83 -0
  41. package/template/components/(forms)/description/Description.tsx +34 -0
  42. package/template/components/(forms)/errorMessage/ErrorMessage.tsx +31 -0
  43. package/template/components/(forms)/fieldError/FieldError.tsx +39 -0
  44. package/template/components/(forms)/fieldset/Fieldset.tsx +51 -0
  45. package/template/components/(forms)/form/Form.tsx +54 -0
  46. package/template/components/(forms)/input/Input.tsx +50 -0
  47. package/template/components/(forms)/inputGroup/InputGroup.tsx +65 -0
  48. package/template/components/(forms)/inputOtp/InputOtp.tsx +139 -0
  49. package/template/components/(forms)/label/Label.tsx +46 -0
  50. package/template/components/(forms)/numberField/NumberField.tsx +292 -0
  51. package/template/components/(forms)/radioGroup/RadioGroup.tsx +175 -0
  52. package/template/components/(forms)/searchField/SearchField.tsx +139 -0
  53. package/template/components/(forms)/shared/field.module.css +75 -0
  54. package/template/components/(forms)/shared/fieldContext.ts +28 -0
  55. package/template/components/(forms)/textArea/TextArea.tsx +55 -0
  56. package/template/components/(forms)/textField/TextField.tsx +91 -0
  57. package/template/components/{layout → (layout)}/Lightbox/LightboxCard.tsx +100 -100
  58. package/template/components/{layout → (layout)}/Lightbox/LightboxGallery.module.css +249 -249
  59. package/template/components/{layout → (layout)}/Lightbox/LightboxGallery.tsx +72 -72
  60. package/template/components/{layout → (layout)}/Lightbox/LightboxGrid.tsx +185 -186
  61. package/template/components/{layout → (layout)}/Lightbox/LightboxModal.module.css +395 -395
  62. package/template/components/{layout → (layout)}/Lightbox/LightboxModal.tsx +498 -500
  63. package/template/components/{layout → (layout)}/Lightbox/demo.tsx +396 -412
  64. package/template/components/{layout → (layout)}/Lightbox/index.ts +30 -30
  65. package/template/components/{layout → (layout)}/Lightbox/types.ts +101 -113
  66. package/template/components/{layout → (layout)}/Lightbox/useLightboxFilters.ts +140 -140
  67. package/template/components/(layout)/accordion/Accordion.module.css +108 -0
  68. package/template/components/(layout)/accordion/Accordion.tsx +251 -0
  69. package/template/components/(layout)/card/Card.module.css +136 -0
  70. package/template/components/(layout)/card/Card.tsx +371 -0
  71. package/template/components/(layout)/list/List.module.css +83 -0
  72. package/template/components/(layout)/list/List.tsx +332 -0
  73. package/template/components/{layout → (layout)}/navigation/Wrap.tsx +41 -41
  74. package/template/components/(layout)/navigation/breadcrumbs/Breadcrumbs.tsx +145 -0
  75. package/template/components/{layout/navigation/nav/Nav.module.css → (layout)/navigation/nav/Nav.module.css.old} +474 -508
  76. package/template/components/{layout → (layout)}/navigation/nav/Nav.tsx +186 -167
  77. package/template/components/{layout → (layout)}/navigation/nav/NavBar.tsx +396 -419
  78. package/template/components/{layout → (layout)}/navigation/nav/NavContext.tsx +259 -259
  79. package/template/components/{layout → (layout)}/navigation/nav/NavItem.tsx +195 -173
  80. package/template/components/{layout → (layout)}/navigation/nav/NavNew.module.css +406 -373
  81. package/template/components/{layout → (layout)}/navigation/nav/NavRail.tsx +317 -315
  82. package/template/components/{layout → (layout)}/navigation/nav/NavSection.tsx +101 -102
  83. package/template/components/{layout → (layout)}/navigation/nav/NavTab.tsx +25 -25
  84. package/template/components/{layout → (layout)}/navigation/nav/navftb/NavFTB.module.css +253 -252
  85. package/template/components/{layout → (layout)}/navigation/nav/navftb/NavFTB.tsx +448 -399
  86. package/template/components/{layout → (layout)}/navigation/nav/navftb/useTabIndicator.ts +498 -484
  87. package/template/components/{layout → (layout)}/navigation/nav/navheader/NavHeader.module.css +59 -59
  88. package/template/components/{layout → (layout)}/navigation/nav/navheader/NavHeader.tsx +465 -473
  89. package/template/components/(layout)/navigation/pagination/Pagination.tsx +261 -0
  90. package/template/components/{layout → (layout)}/pages/loadingScreen.tsx +117 -102
  91. package/template/components/{layout → (layout)}/pages/maintenance/Maintenance.tsx +52 -52
  92. package/template/components/{layout → (layout)}/pages/maintenance/maintenance.module.css +162 -162
  93. package/template/components/(layout)/scrollShadow/ScrollShadow.module.css +81 -0
  94. package/template/components/(layout)/scrollShadow/ScrollShadow.tsx +161 -0
  95. package/template/components/(layout)/scrollShadow/useScrollShadow.ts +130 -0
  96. package/template/components/(layout)/separator/Separator.tsx +112 -0
  97. package/template/components/(overlays)/accessibilityModal/AccessibilityModal.tsx +307 -0
  98. package/template/components/(overlays)/drawer/Drawer.tsx +953 -0
  99. package/template/components/(overlays)/modal/Modal.tsx +654 -0
  100. package/template/components/(overlays)/popover/Popover.tsx +420 -0
  101. package/template/components/(overlays)/toast/Toast.tsx +692 -0
  102. package/template/components/(pickers)/autocomplete/Autocomplete.tsx +24 -0
  103. package/template/components/(pickers)/comboBox/ComboBox.tsx +21 -0
  104. package/template/components/(pickers)/select/Select.tsx +188 -0
  105. package/template/components/(pickers)/shared/FilterableField.tsx +223 -0
  106. package/template/components/(pickers)/shared/PickerItem.ts +13 -0
  107. package/template/components/tools/CustomScrollbar.tsx +107 -0
  108. package/template/components/tools/Divider.tsx +11 -11
  109. package/template/components/tools/ReduceMotionContext.tsx +5 -5
  110. package/template/components/tools/Sinewave.tsx +396 -199
  111. package/template/components/tools/SinewaveProgress.tsx +140 -135
  112. package/template/components/tools/badge/Badge.tsx +28 -28
  113. package/template/components/tools/dropdown/drop.module.css +196 -0
  114. package/template/components/tools/dropdown/drop.tsx +568 -0
  115. package/template/components/tools/easing.ts +118 -0
  116. package/template/components/tools/flubber.d.ts +6 -6
  117. package/template/components/tools/footer/Footer.tsx +20 -0
  118. package/template/components/tools/input/Input.module.css +45 -0
  119. package/template/components/tools/input/Input.tsx +99 -0
  120. package/template/components/tools/label/Icon.tsx +39 -0
  121. package/template/components/tools/label/Label.tsx +156 -0
  122. package/template/components/tools/mobileViewProvider.tsx +53 -58
  123. package/template/components/tools/ripple/ripple.css +38 -41
  124. package/template/components/tools/ripple/ripple.tsx +78 -53
  125. package/template/components/tools/shape/Shape.module.css +25 -0
  126. package/template/components/tools/shape/{ShapeMorph.tsx → Shape.tsx} +316 -190
  127. package/template/components/tools/shape/ShapeLoader.tsx +104 -101
  128. package/template/components/tools/shape/ShapePaths.ts +116 -116
  129. package/template/components/tools/switch/Switch.module.css +102 -102
  130. package/template/components/tools/switch/Switch.tsx +48 -48
  131. package/template/components/tools/useBodyScrollLock.tsx +27 -27
  132. package/template/components/tools/useImageColor.ts +47 -47
  133. package/template/components/tools/useNavSheetDrag.tsx +196 -196
  134. package/template/components/layout/accordion/Accordion.module.css +0 -149
  135. package/template/components/layout/accordion/Accordion.tsx +0 -114
  136. package/template/components/layout/button/button.tsx +0 -128
  137. package/template/components/layout/button/drop.module.css +0 -229
  138. package/template/components/layout/button/drop.tsx +0 -516
  139. package/template/components/layout/hero/v1/heroSlideshow.module.css +0 -107
  140. package/template/components/layout/hero/v1/heroSlideshow.tsx +0 -233
  141. package/template/components/layout/modals/accessibilityModal/AccessibilityModal.module.css +0 -126
  142. package/template/components/layout/modals/accessibilityModal/AccessibilityModal.tsx +0 -290
  143. package/template/components/layout/modals/alert/Alert.tsx +0 -188
  144. package/template/components/layout/navigation/MioCard.module.css +0 -88
  145. package/template/components/layout/navigation/MioCard.tsx +0 -266
  146. package/template/components/tools/ProgressiveBlur.tsx +0 -73
  147. package/template/components/tools/icon/icon.module.css +0 -0
  148. package/template/components/tools/icon/icon.tsx +0 -125
  149. package/template/components/tools/react-bits/ClickSpark.tsx +0 -177
  150. package/template/components/tools/react-bits/FadeContent.tsx +0 -90
  151. package/template/components/tools/react-bits/GlareHover.tsx +0 -73
  152. package/template/components/tools/react-bits/GradientText/GradientText.css +0 -70
  153. package/template/components/tools/react-bits/GradientText/GradientText.tsx +0 -44
  154. package/template/components/tools/react-bits/Magnet.tsx +0 -118
  155. package/template/components/tools/react-bits/Stepper/Stepper.css +0 -134
  156. package/template/components/tools/react-bits/Stepper/Stepper.tsx +0 -412
@@ -0,0 +1,337 @@
1
+ "use client";
2
+ import React from "react";
3
+ import { easeInOut, motion } from "framer-motion";
4
+ import { cubicBezier } from "@/components/tools/easing";
5
+ import Sinewave from "@/components/tools/Sinewave";
6
+
7
+ // =============================================================================
8
+ // MARK: Public types
9
+ // =============================================================================
10
+ // The linear progress indicator, in both shapes and both behaviors.
11
+ // Self-contained; CircularProgress is its counterpart and shares no code.
12
+
13
+ export type LinearProgressBehavior = "determinate" | "indeterminate";
14
+ export type LinearProgressWeight = 4 | 6 | 8;
15
+ export type LinearProgressVariant =
16
+ | "default"
17
+ | "primary"
18
+ | "secondary"
19
+ | "tertiary";
20
+ export type LinearProgressShape = "flat" | "wavy";
21
+
22
+ // "default" is the odd one out: active reads as primary, but the inactive
23
+ // track deliberately does NOT follow primary-container — it's pinned to
24
+ // secondary-container. Every other variant follows the normal MD3 pairing
25
+ // (color / color-container).
26
+ function activeColorFor(variant: LinearProgressVariant) {
27
+ return variant === "default"
28
+ ? "var(--md-sys-color-primary)"
29
+ : `var(--md-sys-color-${variant})`;
30
+ }
31
+ function remainingColorFor(variant: LinearProgressVariant) {
32
+ return variant === "default"
33
+ ? "var(--md-sys-color-secondary-container)"
34
+ : `var(--md-sys-color-${variant}-container)`;
35
+ }
36
+
37
+ export interface LinearProgressProps {
38
+ /** 0-100 task progress. Only meaningful in `behavior="determinate"`. */
39
+ progress?: number;
40
+ behavior?: LinearProgressBehavior;
41
+ /** Line thickness. @default 4 */
42
+ weight?: LinearProgressWeight;
43
+ variant?: LinearProgressVariant;
44
+ /** Total track width in px. @default 400 */
45
+ width?: number;
46
+ /** Fires once, the instant `progress` crosses into 100 — not on every
47
+ * render while already at 100, and not again until it drops below 100
48
+ * and climbs back up. */
49
+ onComplete?: () => void;
50
+ shape?: LinearProgressShape;
51
+ className?: string;
52
+ style?: React.CSSProperties;
53
+ }
54
+ const PROGRESS_TRANSITION = "1s cubic-bezier(0.3, 0, 0, 1)";
55
+ const COLOR_TRANSITION = "0.2s cubic-bezier(0.2, 0, 0, 1)";
56
+ const FADE = { duration: 0.2, ease: easeInOut };
57
+
58
+ const WAVE_HEIGHT = 20;
59
+ const LINEAR_WAVE_FREQ_PER_PX = 0.05;
60
+ const LINEAR_WAVE_AMPLITUDE = 2;
61
+ const WAVE_DURATION = 0.8;
62
+ const TRACK_GAP = 8;
63
+ const DETERMINATE_GAP_THRESHOLD = 2;
64
+ const STOP_INDICATOR_SIZE = 4;
65
+ const INDETERMINATE_LOOP_MS = 2000;
66
+ const INDETERMINATE_MAX_WIDTH = 50;
67
+ const INDETERMINATE_ENTER_TRAVEL = 100 - INDETERMINATE_MAX_WIDTH;
68
+ const INDETERMINATE_GROW_EASING: [number, number, number, number] = [
69
+ 0, 0, 0, 0,
70
+ ];
71
+ const INDETERMINATE_GROW_EASE = cubicBezier(...INDETERMINATE_GROW_EASING);
72
+ const INDETERMINATE_EXIT_EASING: [number, number, number, number] = [
73
+ 0, 0, 0, 0,
74
+ ];
75
+ const INDETERMINATE_EXIT_EASE = cubicBezier(...INDETERMINATE_EXIT_EASING);
76
+ const INDETERMINATE_A_TIMING: [number, number, number, number] = [0.7, 0, 1, 1];
77
+ const INDETERMINATE_A_TIMING_EASE = cubicBezier(...INDETERMINATE_A_TIMING);
78
+ const INDETERMINATE_B_TIMING: [number, number, number, number] = [0, 0, 0.3, 1];
79
+ const INDETERMINATE_B_TIMING_EASE = cubicBezier(...INDETERMINATE_B_TIMING);
80
+
81
+ // =============================================================================
82
+ // MARK: Animation hooks
83
+ // =============================================================================
84
+
85
+ function useIndeterminateSlide(active: boolean) {
86
+ const [state, setState] = React.useState({ left: 0, width: 0 });
87
+
88
+ React.useEffect(() => {
89
+ if (!active) return;
90
+ const startTime = performance.now();
91
+ let frame = 0;
92
+ const cycleMs = INDETERMINATE_LOOP_MS * 2;
93
+ const tick = (now: number) => {
94
+ const cycleT = (now - startTime) % cycleMs;
95
+ const reverse = cycleT >= INDETERMINATE_LOOP_MS;
96
+ const rawT = (cycleT % INDETERMINATE_LOOP_MS) / INDETERMINATE_LOOP_MS;
97
+ const t = reverse
98
+ ? INDETERMINATE_B_TIMING_EASE(rawT)
99
+ : INDETERMINATE_A_TIMING_EASE(rawT);
100
+ const growing = t < 0.5;
101
+ const phaseT = growing ? t / 0.5 : (t - 0.5) / 0.5;
102
+
103
+ let left: number;
104
+ let width: number;
105
+ if (!reverse) {
106
+ if (growing) {
107
+ const p = INDETERMINATE_GROW_EASE(phaseT);
108
+ width = INDETERMINATE_MAX_WIDTH * p;
109
+ left = INDETERMINATE_ENTER_TRAVEL * p;
110
+ } else {
111
+ left =
112
+ INDETERMINATE_ENTER_TRAVEL +
113
+ (100 - INDETERMINATE_ENTER_TRAVEL) *
114
+ INDETERMINATE_EXIT_EASE(phaseT);
115
+ width = 100 - left;
116
+ }
117
+ } else if (growing) {
118
+ width = INDETERMINATE_MAX_WIDTH * INDETERMINATE_GROW_EASE(phaseT);
119
+ left = 0;
120
+ } else {
121
+ const e = INDETERMINATE_EXIT_EASE(phaseT);
122
+ left = 100 * e;
123
+ width = INDETERMINATE_MAX_WIDTH * (1 - e);
124
+ }
125
+
126
+ setState({ left, width });
127
+ frame = requestAnimationFrame(tick);
128
+ };
129
+ frame = requestAnimationFrame(tick);
130
+ return () => cancelAnimationFrame(frame);
131
+ }, [active]);
132
+
133
+ return state;
134
+ }
135
+
136
+ // =============================================================================
137
+ // MARK: Public component
138
+ // =============================================================================
139
+ // Renders both shape="flat" and "wavy" — one component, since both shapes
140
+ // share the exact same layout (active track / remaining track / stop
141
+ // indicator) and only differ in what fills the active track.
142
+
143
+ const LinearProgress: React.FC<LinearProgressProps> = ({
144
+ progress = 0,
145
+ behavior = "determinate",
146
+ weight = 4,
147
+ variant = "default",
148
+ width = 400,
149
+ onComplete,
150
+ shape = "flat",
151
+ className,
152
+ style,
153
+ }) => {
154
+ const activeColor = activeColorFor(variant);
155
+ const remainingColor = remainingColorFor(variant);
156
+
157
+ const clamped = Math.min(100, Math.max(0, progress));
158
+ const complete = clamped >= 100;
159
+
160
+ // Edge-triggered: fires once per 0→100 crossing, not on every render at 100.
161
+ const wasCompleteRef = React.useRef(false);
162
+ React.useEffect(() => {
163
+ if (complete && !wasCompleteRef.current) onComplete?.();
164
+ wasCompleteRef.current = complete;
165
+ }, [complete, onComplete]);
166
+
167
+ const a11y = {
168
+ role: "progressbar" as const,
169
+ "aria-valuemin": 0,
170
+ "aria-valuemax": 100,
171
+ "aria-valuenow": clamped,
172
+ };
173
+
174
+ const indeterminate = behavior === "indeterminate";
175
+ const slide = useIndeterminateSlide(indeterminate);
176
+ const trackHeight = shape === "wavy" ? WAVE_HEIGHT : weight;
177
+ const determinateWidth = (clamped / 100) * width;
178
+
179
+ // Indeterminate geometry, in px. The bar never leaves the track — its right
180
+ // edge reaches 100% at the midpoint and stays there — so nothing needs
181
+ // clipping or wrapping.
182
+ const indeterminateLeft = (slide.left / 100) * width;
183
+ const indeterminateWidth = (slide.width / 100) * width;
184
+
185
+ const activeLeft = indeterminate ? indeterminateLeft : 0;
186
+ const activeWidth = indeterminate ? indeterminateWidth : determinateWidth;
187
+
188
+ // Indeterminate leaves track on BOTH sides of the bar, each held off by the
189
+ // gap. Either can collapse to nothing — the leading one at the start of the
190
+ // loop, the trailing one once the bar reaches the end — so both are clamped
191
+ // at 0 rather than allowed to invert.
192
+ //
193
+ // The gap RETIRES WITH THE BAR: a bar narrower than TRACK_GAP gets a
194
+ // proportionally smaller gap, reaching 0 exactly when the bar does. Holding
195
+ // it at a fixed 8px instead is what made the loop visibly snap — at the wrap
196
+ // the bar is zero-width at both ends, so the remaining track should read as
197
+ // the full track either side of it, but a fixed gap put it at [0, 392] on
198
+ // one frame and [8, 400] on the next. Same rule the ring uses: with nothing
199
+ // left to gap against, there is no gap.
200
+ const indeterminateGapPx = Math.min(TRACK_GAP, indeterminateWidth);
201
+ const gapBeforePx = Math.max(0, indeterminateLeft - indeterminateGapPx);
202
+ const gapAfterLeftPx =
203
+ indeterminateLeft + indeterminateWidth + indeterminateGapPx;
204
+ const gapAfterWidthPx = Math.max(0, width - gapAfterLeftPx);
205
+ const started = indeterminate ? true : clamped > 0;
206
+ // The slide's own per-frame state IS the animation — a CSS transition on
207
+ // top would just add lag chasing an already-moving target.
208
+ const activeSizeTransition = indeterminate ? undefined : PROGRESS_TRANSITION;
209
+
210
+ const centered: React.CSSProperties = {
211
+ position: "absolute",
212
+ top: "50%",
213
+ transform: "translateY(-50%)",
214
+ };
215
+
216
+ return (
217
+ <div
218
+ {...a11y}
219
+ className={className}
220
+ style={{
221
+ position: "relative",
222
+ width,
223
+ height: trackHeight,
224
+ ...style,
225
+ }}
226
+ >
227
+ {/* Active track */}
228
+ {shape === "wavy" ? (
229
+ <motion.div
230
+ animate={{ opacity: started ? 1 : 0 }}
231
+ transition={FADE}
232
+ style={{
233
+ ...centered,
234
+ left: activeLeft,
235
+ width: activeWidth,
236
+ height: WAVE_HEIGHT,
237
+ ...(activeSizeTransition && {
238
+ transition: `left ${activeSizeTransition}, width ${activeSizeTransition}`,
239
+ }),
240
+ }}
241
+ >
242
+ <Sinewave
243
+ fluid
244
+ freqPerPx={LINEAR_WAVE_FREQ_PER_PX}
245
+ height={WAVE_HEIGHT}
246
+ amplitude={LINEAR_WAVE_AMPLITUDE}
247
+ strokeWidth={weight}
248
+ stroke={activeColor}
249
+ animate
250
+ duration={WAVE_DURATION}
251
+ style={{ margin: 0, minHeight: WAVE_HEIGHT, width: "100%" }}
252
+ />
253
+ </motion.div>
254
+ ) : (
255
+ <div
256
+ style={{
257
+ ...centered,
258
+ left: activeLeft,
259
+ width: activeWidth,
260
+ height: weight,
261
+ background: activeColor,
262
+ borderRadius: weight / 2,
263
+ transition: activeSizeTransition
264
+ ? `left ${activeSizeTransition}, width ${activeSizeTransition}, background ${COLOR_TRANSITION}`
265
+ : `background ${COLOR_TRANSITION}`,
266
+ }}
267
+ />
268
+ )}
269
+ {/* Remaining track. Determinate: one segment pinned to the right edge,
270
+ its left edge trailing the active track by TRACK_GAP on the same
271
+ curve, so the total can never overflow. Indeterminate: TWO segments,
272
+ one either side of the bar, each held off by the same gap. */}
273
+ {indeterminate ? (
274
+ <>
275
+ <div
276
+ style={{
277
+ ...centered,
278
+ left: 0,
279
+ width: gapBeforePx,
280
+ height: weight,
281
+ background: remainingColor,
282
+ borderRadius: weight / 2,
283
+ transition: `background ${COLOR_TRANSITION}`,
284
+ }}
285
+ />
286
+ <div
287
+ style={{
288
+ ...centered,
289
+ left: gapAfterLeftPx,
290
+ width: gapAfterWidthPx,
291
+ height: weight,
292
+ background: remainingColor,
293
+ borderRadius: weight / 2,
294
+ transition: `background ${COLOR_TRANSITION}`,
295
+ }}
296
+ />
297
+ </>
298
+ ) : (
299
+ <div
300
+ style={{
301
+ ...centered,
302
+ // Below the threshold there isn't enough active bar yet for a
303
+ // gap to read as intentional rather than a rendering glitch, so
304
+ // the remaining track holds the full width until progress
305
+ // reaches DETERMINATE_GAP_THRESHOLD — same rule the ring uses.
306
+ left:
307
+ clamped >= DETERMINATE_GAP_THRESHOLD
308
+ ? Math.min(width, determinateWidth + TRACK_GAP)
309
+ : 0,
310
+ right: 0,
311
+ height: weight,
312
+ background: remainingColor,
313
+ borderRadius: weight / 2,
314
+ transition: `left ${PROGRESS_TRANSITION}, background ${COLOR_TRANSITION}`,
315
+ }}
316
+ />
317
+ )}
318
+ {/* Stop indicator — always mounted so it can fade instead of popping.
319
+ Not used at all in indeterminate (no endpoint to mark). */}
320
+ <motion.span
321
+ aria-hidden="true"
322
+ animate={{ opacity: complete || indeterminate ? 0 : 1 }}
323
+ transition={FADE}
324
+ style={{
325
+ ...centered,
326
+ right: weight == 4 ? 0 : weight == 6 ? 1 : weight == 8 ? 2 : 0,
327
+ width: STOP_INDICATOR_SIZE,
328
+ height: STOP_INDICATOR_SIZE,
329
+ borderRadius: "50%",
330
+ background: activeColor,
331
+ }}
332
+ />
333
+ </div>
334
+ );
335
+ };
336
+
337
+ export default LinearProgress;
@@ -0,0 +1,111 @@
1
+ "use client";
2
+ import Sinewave from "@/components/tools/Sinewave";
3
+ import LinearProgress from "../linearProgress/LinearProgress";
4
+
5
+ export type MeterSize = "sm" | "md" | "lg";
6
+ export type MeterColor =
7
+ | "default"
8
+ | "primary"
9
+ | "secondary"
10
+ | "tertiary"
11
+ | "success"
12
+ | "error";
13
+
14
+ export interface MeterProps {
15
+ value?: number;
16
+ minValue?: number;
17
+ maxValue?: number;
18
+ size?: MeterSize;
19
+ color?: MeterColor;
20
+ formatOptions?: Intl.NumberFormatOptions;
21
+ locale?: string;
22
+ label?: string;
23
+ width?: number;
24
+ valueLabel?: React.ReactNode;
25
+ showValueLabel?: boolean;
26
+ "aria-label"?: string;
27
+ className?: string;
28
+ style?: React.CSSProperties;
29
+ }
30
+
31
+ // Same wave-fill idea as tools/SinewaveProgress.tsx, but without its
32
+ // collapse-to-nothing-at-100% animation — that's the right call for a
33
+ // one-shot task-completion bar, but wrong for a persistent gauge (a
34
+ // meter reading "100% full" collapsing to a blank line reads as broken,
35
+ // not "done").
36
+ const SIZE_HEIGHT: Record<MeterSize, number> = { sm: 6, md: 10, lg: 14 };
37
+
38
+ function colorFor(color: MeterColor) {
39
+ return color === "default"
40
+ ? "var(--md-sys-color-primary)"
41
+ : `var(--md-sys-color-${color})`;
42
+ }
43
+
44
+ export default function Meter({
45
+ value = 0,
46
+ minValue = 0,
47
+ maxValue = 100,
48
+ size = "md",
49
+ color = "default",
50
+ formatOptions = { style: "percent" },
51
+ locale = "en-US",
52
+ width = 400,
53
+ label,
54
+ valueLabel,
55
+ showValueLabel = true,
56
+ "aria-label": ariaLabel,
57
+ className,
58
+ style,
59
+ }: MeterProps) {
60
+ const percentage = Math.min(
61
+ 1,
62
+ Math.max(0, (value - minValue) / (maxValue - minValue)),
63
+ );
64
+ const resolvedFormatOptions =
65
+ formatOptions.style === "currency" && !formatOptions.currencyDisplay
66
+ ? { ...formatOptions, currencyDisplay: "narrowSymbol" as const }
67
+ : formatOptions;
68
+ const valueText =
69
+ valueLabel ??
70
+ new Intl.NumberFormat(locale, resolvedFormatOptions).format(
71
+ formatOptions.style === "percent" ? percentage : value,
72
+ );
73
+ const height = SIZE_HEIGHT[size];
74
+ const stroke = colorFor(color);
75
+
76
+ return (
77
+ <div
78
+ role="meter"
79
+ aria-label={ariaLabel ?? label}
80
+ aria-valuenow={value}
81
+ aria-valuemin={minValue}
82
+ aria-valuemax={maxValue}
83
+ aria-valuetext={String(valueText)}
84
+ className={className}
85
+ style={{ display: "flex", flexDirection: "column", gap: 6, ...style }}
86
+ >
87
+ {(label || (showValueLabel && valueText)) && (
88
+ <div
89
+ style={{
90
+ display: "flex",
91
+ justifyContent: "space-between",
92
+ fontSize: 14,
93
+ width,
94
+ }}
95
+ >
96
+ {label && (
97
+ <span style={{ color: "var(--md-sys-color-on-surface)" }}>
98
+ {label}
99
+ </span>
100
+ )}
101
+ {showValueLabel && valueText && (
102
+ <span style={{ color: "var(--md-sys-color-on-surface-variant)" }}>
103
+ {valueText}
104
+ </span>
105
+ )}
106
+ </div>
107
+ )}
108
+ <LinearProgress shape="flat" progress={value} width={width} weight={8} />
109
+ </div>
110
+ );
111
+ }
@@ -0,0 +1,49 @@
1
+ .skeleton {
2
+ position: relative;
3
+ overflow: hidden;
4
+ border-radius: var(--borderRadius-sm);
5
+ background: var(--md-sys-color-surface-container-highest);
6
+ width: 100%;
7
+ height: 16px;
8
+ }
9
+
10
+ .skeleton[data-animation="shimmer"]::before {
11
+ content: "";
12
+ position: absolute;
13
+ inset: 0;
14
+ transform: translateX(-100%);
15
+ background: linear-gradient(
16
+ 90deg,
17
+ transparent,
18
+ var(--md-sys-color-surface-container-low),
19
+ transparent
20
+ );
21
+ animation: shimmer 2s linear infinite;
22
+ }
23
+
24
+ .skeleton[data-animation="pulse"] {
25
+ animation: pulse 1.5s ease-in-out infinite;
26
+ }
27
+
28
+ @keyframes shimmer {
29
+ 100% {
30
+ transform: translateX(100%);
31
+ }
32
+ }
33
+
34
+ @keyframes pulse {
35
+ 0%,
36
+ 100% {
37
+ opacity: 1;
38
+ }
39
+ 50% {
40
+ opacity: 0.5;
41
+ }
42
+ }
43
+
44
+ @media (prefers-reduced-motion: reduce) {
45
+ .skeleton[data-animation="shimmer"]::before,
46
+ .skeleton[data-animation="pulse"] {
47
+ animation: none;
48
+ }
49
+ }
@@ -0,0 +1,32 @@
1
+ import styles from "./Skeleton.module.css";
2
+
3
+ export type SkeletonAnimationType = "shimmer" | "pulse" | "none";
4
+
5
+ export interface SkeletonProps {
6
+ animationType?: SkeletonAnimationType;
7
+ children?: React.ReactNode;
8
+ className?: string;
9
+ style?: React.CSSProperties;
10
+ }
11
+
12
+ // This codebase doesn't use Tailwind (everything else in this port is
13
+ // inline style/CSS Module) — HeroUI's own Skeleton has no width/height/
14
+ // radius props at all, expecting `className="h-4 w-32"` etc.; `style` here
15
+ // is the equivalent, same as every other component in this port.
16
+ export default function Skeleton({
17
+ animationType = "shimmer",
18
+ children,
19
+ className,
20
+ style,
21
+ }: SkeletonProps) {
22
+ return (
23
+ <div
24
+ aria-hidden
25
+ data-animation={animationType}
26
+ className={[styles.skeleton, className].filter(Boolean).join(" ")}
27
+ style={style}
28
+ >
29
+ {children}
30
+ </div>
31
+ );
32
+ }
@@ -0,0 +1,27 @@
1
+ .spinner {
2
+ display: inline-block;
3
+ box-sizing: border-box;
4
+ border-radius: 50%;
5
+ border: 3px solid transparent;
6
+ border-top-color: var(--md-sys-color-primary);
7
+ border-right-color: var(--md-sys-color-primary);
8
+ animation: spin 0.7s linear infinite;
9
+ }
10
+
11
+ @keyframes spin {
12
+ to {
13
+ transform: rotate(360deg);
14
+ }
15
+ }
16
+
17
+ .srOnly {
18
+ position: absolute;
19
+ width: 1px;
20
+ height: 1px;
21
+ padding: 0;
22
+ margin: -1px;
23
+ overflow: hidden;
24
+ clip: rect(0, 0, 0, 0);
25
+ white-space: nowrap;
26
+ border: 0;
27
+ }
@@ -0,0 +1,60 @@
1
+ import styles from "./Spinner.module.css";
2
+
3
+ export type SpinnerSize = "sm" | "md" | "lg" | "xl";
4
+ // "current" inherits currentColor from whatever text context it's in
5
+ // (e.g. inside a Button). Otherwise the same color-role vocabulary as
6
+ // Toast/Modal/Drawer, minus "default" (a spinner always needs visible
7
+ // contrast, there's no neutral option) — and no "warning", since no
8
+ // --md-sys-color-warning token exists anywhere else in this system either.
9
+ export type SpinnerColor =
10
+ | "current"
11
+ | "primary"
12
+ | "secondary"
13
+ | "tertiary"
14
+ | "success"
15
+ | "error";
16
+
17
+ export interface SpinnerProps {
18
+ size?: SpinnerSize;
19
+ color?: SpinnerColor;
20
+ /** Visually-hidden text for screen readers — the spinner itself is
21
+ * `aria-hidden`, this is what actually gets announced. @default "Loading" */
22
+ label?: string;
23
+ className?: string;
24
+ style?: React.CSSProperties;
25
+ }
26
+
27
+ const SIZE_PX: Record<SpinnerSize, number> = {
28
+ sm: 16,
29
+ md: 24,
30
+ lg: 32,
31
+ xl: 40,
32
+ };
33
+
34
+ export default function Spinner({
35
+ size = "md",
36
+ color = "primary",
37
+ label = "Loading",
38
+ className,
39
+ style,
40
+ }: SpinnerProps) {
41
+ const dimension = SIZE_PX[size];
42
+ const strokeColor =
43
+ color === "current" ? "currentColor" : `var(--md-sys-color-${color})`;
44
+
45
+ return (
46
+ <span
47
+ role="status"
48
+ className={[styles.spinner, className].filter(Boolean).join(" ")}
49
+ style={{
50
+ width: dimension,
51
+ height: dimension,
52
+ borderTopColor: strokeColor,
53
+ borderRightColor: strokeColor,
54
+ ...style,
55
+ }}
56
+ >
57
+ <span className={styles.srOnly}>{label}</span>
58
+ </span>
59
+ );
60
+ }