@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.
- package/LICENSE +201 -201
- package/README.md +101 -101
- package/package.json +50 -50
- package/scripts/postinstall.js +91 -91
- package/template/app/ClientNav.tsx +258 -310
- package/template/app/globals.css +2 -167
- package/template/app/layout.tsx +94 -82
- package/template/app/themes/dark-mc.css +51 -51
- package/template/app/themes/dark.css +51 -51
- package/template/app/themes/light-mc.css +51 -51
- package/template/app/themes/light.css +51 -51
- package/template/app/themes/theme.css +272 -82
- package/template/components/{layout/button → (buttons)}/Button.module.css +351 -305
- package/template/components/{layout/button → (buttons)}/ButtonGroup.tsx +414 -503
- package/template/components/{layout/button → (buttons)}/FAB.tsx +119 -118
- package/template/components/(buttons)/button.tsx +164 -0
- package/template/components/(controls)/slider/Slider.module.css +250 -0
- package/template/components/(controls)/slider/Slider.tsx +386 -0
- package/template/components/{layout → (controls)}/switch/Switch.module.css +108 -102
- package/template/components/{layout → (controls)}/switch/Switch.tsx +69 -48
- package/template/components/(date & time)/calendar/Calendar.module.css +125 -0
- package/template/components/(date & time)/calendar/Calendar.tsx +206 -0
- package/template/components/(date & time)/dateField/DateField.module.css +25 -0
- package/template/components/(date & time)/dateField/DateField.tsx +193 -0
- package/template/components/(date & time)/datePicker/DatePicker.tsx +118 -0
- package/template/components/(date & time)/dateRangePicker/DateRangePicker.tsx +144 -0
- package/template/components/(date & time)/rangeCalendar/RangeCalendar.module.css +203 -0
- package/template/components/(date & time)/rangeCalendar/RangeCalendar.tsx +263 -0
- package/template/components/(date & time)/shared/dateUtils.ts +107 -0
- package/template/components/(date & time)/timeField/TimeField.module.css +39 -0
- package/template/components/(date & time)/timeField/TimeField.tsx +158 -0
- package/template/components/(feedback)/circularProgress/CircularProgress.tsx +646 -0
- package/template/components/(feedback)/linearProgress/LinearProgress.tsx +337 -0
- package/template/components/(feedback)/meter/Meter.tsx +111 -0
- package/template/components/(feedback)/skeleton/Skeleton.module.css +49 -0
- package/template/components/(feedback)/skeleton/Skeleton.tsx +32 -0
- package/template/components/(feedback)/spinner/Spinner.module.css +27 -0
- package/template/components/(feedback)/spinner/Spinner.tsx +60 -0
- package/template/components/(forms)/checkbox/Checkbox.tsx +121 -0
- package/template/components/(forms)/checkboxGroup/CheckboxGroup.tsx +83 -0
- package/template/components/(forms)/description/Description.tsx +34 -0
- package/template/components/(forms)/errorMessage/ErrorMessage.tsx +31 -0
- package/template/components/(forms)/fieldError/FieldError.tsx +39 -0
- package/template/components/(forms)/fieldset/Fieldset.tsx +51 -0
- package/template/components/(forms)/form/Form.tsx +54 -0
- package/template/components/(forms)/input/Input.tsx +50 -0
- package/template/components/(forms)/inputGroup/InputGroup.tsx +65 -0
- package/template/components/(forms)/inputOtp/InputOtp.tsx +139 -0
- package/template/components/(forms)/label/Label.tsx +46 -0
- package/template/components/(forms)/numberField/NumberField.tsx +292 -0
- package/template/components/(forms)/radioGroup/RadioGroup.tsx +175 -0
- package/template/components/(forms)/searchField/SearchField.tsx +139 -0
- package/template/components/(forms)/shared/field.module.css +75 -0
- package/template/components/(forms)/shared/fieldContext.ts +28 -0
- package/template/components/(forms)/textArea/TextArea.tsx +55 -0
- package/template/components/(forms)/textField/TextField.tsx +91 -0
- package/template/components/{layout → (layout)}/Lightbox/LightboxCard.tsx +100 -100
- package/template/components/{layout → (layout)}/Lightbox/LightboxGallery.module.css +249 -249
- package/template/components/{layout → (layout)}/Lightbox/LightboxGallery.tsx +72 -72
- package/template/components/{layout → (layout)}/Lightbox/LightboxGrid.tsx +185 -186
- package/template/components/{layout → (layout)}/Lightbox/LightboxModal.module.css +395 -395
- package/template/components/{layout → (layout)}/Lightbox/LightboxModal.tsx +498 -500
- package/template/components/{layout → (layout)}/Lightbox/demo.tsx +396 -412
- package/template/components/{layout → (layout)}/Lightbox/index.ts +30 -30
- package/template/components/{layout → (layout)}/Lightbox/types.ts +101 -113
- package/template/components/{layout → (layout)}/Lightbox/useLightboxFilters.ts +140 -140
- package/template/components/(layout)/accordion/Accordion.module.css +108 -0
- package/template/components/(layout)/accordion/Accordion.tsx +251 -0
- package/template/components/(layout)/card/Card.module.css +136 -0
- package/template/components/(layout)/card/Card.tsx +371 -0
- package/template/components/(layout)/list/List.module.css +83 -0
- package/template/components/(layout)/list/List.tsx +332 -0
- package/template/components/{layout → (layout)}/navigation/Wrap.tsx +41 -41
- package/template/components/(layout)/navigation/breadcrumbs/Breadcrumbs.tsx +145 -0
- package/template/components/{layout/navigation/nav/Nav.module.css → (layout)/navigation/nav/Nav.module.css.old} +474 -508
- package/template/components/{layout → (layout)}/navigation/nav/Nav.tsx +186 -167
- package/template/components/{layout → (layout)}/navigation/nav/NavBar.tsx +396 -419
- package/template/components/{layout → (layout)}/navigation/nav/NavContext.tsx +259 -259
- package/template/components/{layout → (layout)}/navigation/nav/NavItem.tsx +195 -173
- package/template/components/{layout → (layout)}/navigation/nav/NavNew.module.css +406 -373
- package/template/components/{layout → (layout)}/navigation/nav/NavRail.tsx +317 -315
- package/template/components/{layout → (layout)}/navigation/nav/NavSection.tsx +101 -102
- package/template/components/{layout → (layout)}/navigation/nav/NavTab.tsx +25 -25
- package/template/components/{layout → (layout)}/navigation/nav/navftb/NavFTB.module.css +253 -252
- package/template/components/{layout → (layout)}/navigation/nav/navftb/NavFTB.tsx +448 -399
- package/template/components/{layout → (layout)}/navigation/nav/navftb/useTabIndicator.ts +498 -484
- package/template/components/{layout → (layout)}/navigation/nav/navheader/NavHeader.module.css +59 -59
- package/template/components/{layout → (layout)}/navigation/nav/navheader/NavHeader.tsx +465 -473
- package/template/components/(layout)/navigation/pagination/Pagination.tsx +261 -0
- package/template/components/{layout → (layout)}/pages/loadingScreen.tsx +117 -102
- package/template/components/{layout → (layout)}/pages/maintenance/Maintenance.tsx +52 -52
- package/template/components/{layout → (layout)}/pages/maintenance/maintenance.module.css +162 -162
- package/template/components/(layout)/scrollShadow/ScrollShadow.module.css +81 -0
- package/template/components/(layout)/scrollShadow/ScrollShadow.tsx +161 -0
- package/template/components/(layout)/scrollShadow/useScrollShadow.ts +130 -0
- package/template/components/(layout)/separator/Separator.tsx +112 -0
- package/template/components/(overlays)/accessibilityModal/AccessibilityModal.tsx +307 -0
- package/template/components/(overlays)/drawer/Drawer.tsx +953 -0
- package/template/components/(overlays)/modal/Modal.tsx +654 -0
- package/template/components/(overlays)/popover/Popover.tsx +420 -0
- package/template/components/(overlays)/toast/Toast.tsx +692 -0
- package/template/components/(pickers)/autocomplete/Autocomplete.tsx +24 -0
- package/template/components/(pickers)/comboBox/ComboBox.tsx +21 -0
- package/template/components/(pickers)/select/Select.tsx +188 -0
- package/template/components/(pickers)/shared/FilterableField.tsx +223 -0
- package/template/components/(pickers)/shared/PickerItem.ts +13 -0
- package/template/components/tools/CustomScrollbar.tsx +107 -0
- package/template/components/tools/Divider.tsx +11 -11
- package/template/components/tools/ReduceMotionContext.tsx +5 -5
- package/template/components/tools/Sinewave.tsx +396 -199
- package/template/components/tools/SinewaveProgress.tsx +140 -135
- package/template/components/tools/badge/Badge.tsx +28 -28
- package/template/components/tools/dropdown/drop.module.css +196 -0
- package/template/components/tools/dropdown/drop.tsx +568 -0
- package/template/components/tools/easing.ts +118 -0
- package/template/components/tools/flubber.d.ts +6 -6
- package/template/components/tools/footer/Footer.tsx +20 -0
- package/template/components/tools/input/Input.module.css +45 -0
- package/template/components/tools/input/Input.tsx +99 -0
- package/template/components/tools/label/Icon.tsx +39 -0
- package/template/components/tools/label/Label.tsx +156 -0
- package/template/components/tools/mobileViewProvider.tsx +53 -58
- package/template/components/tools/ripple/ripple.css +38 -41
- package/template/components/tools/ripple/ripple.tsx +78 -53
- package/template/components/tools/shape/Shape.module.css +25 -0
- package/template/components/tools/shape/{ShapeMorph.tsx → Shape.tsx} +316 -190
- package/template/components/tools/shape/ShapeLoader.tsx +104 -101
- package/template/components/tools/shape/ShapePaths.ts +116 -116
- package/template/components/tools/switch/Switch.module.css +102 -102
- package/template/components/tools/switch/Switch.tsx +48 -48
- package/template/components/tools/useBodyScrollLock.tsx +27 -27
- package/template/components/tools/useImageColor.ts +47 -47
- package/template/components/tools/useNavSheetDrag.tsx +196 -196
- package/template/components/layout/accordion/Accordion.module.css +0 -149
- package/template/components/layout/accordion/Accordion.tsx +0 -114
- package/template/components/layout/button/button.tsx +0 -128
- package/template/components/layout/button/drop.module.css +0 -229
- package/template/components/layout/button/drop.tsx +0 -516
- package/template/components/layout/hero/v1/heroSlideshow.module.css +0 -107
- package/template/components/layout/hero/v1/heroSlideshow.tsx +0 -233
- package/template/components/layout/modals/accessibilityModal/AccessibilityModal.module.css +0 -126
- package/template/components/layout/modals/accessibilityModal/AccessibilityModal.tsx +0 -290
- package/template/components/layout/modals/alert/Alert.tsx +0 -188
- package/template/components/layout/navigation/MioCard.module.css +0 -88
- package/template/components/layout/navigation/MioCard.tsx +0 -266
- package/template/components/tools/ProgressiveBlur.tsx +0 -73
- package/template/components/tools/icon/icon.module.css +0 -0
- package/template/components/tools/icon/icon.tsx +0 -125
- package/template/components/tools/react-bits/ClickSpark.tsx +0 -177
- package/template/components/tools/react-bits/FadeContent.tsx +0 -90
- package/template/components/tools/react-bits/GlareHover.tsx +0 -73
- package/template/components/tools/react-bits/GradientText/GradientText.css +0 -70
- package/template/components/tools/react-bits/GradientText/GradientText.tsx +0 -44
- package/template/components/tools/react-bits/Magnet.tsx +0 -118
- package/template/components/tools/react-bits/Stepper/Stepper.css +0 -134
- package/template/components/tools/react-bits/Stepper/Stepper.tsx +0 -412
|
@@ -1,473 +1,465 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React, {
|
|
4
|
-
createContext,
|
|
5
|
-
useCallback,
|
|
6
|
-
useContext,
|
|
7
|
-
useEffect,
|
|
8
|
-
useLayoutEffect,
|
|
9
|
-
useId,
|
|
10
|
-
useMemo,
|
|
11
|
-
useRef,
|
|
12
|
-
useState,
|
|
13
|
-
} from "react";
|
|
14
|
-
import { motion, HTMLMotionProps, easeInOut } from "framer-motion";
|
|
15
|
-
import styles from "./NavHeader.module.css";
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} from "
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
{
|
|
115
|
-
>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
// •
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
//
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
onScroll()
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
//
|
|
307
|
-
//
|
|
308
|
-
//
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
)
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
"
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
const NavHeader = Object.assign(NavHeaderBody, {
|
|
468
|
-
Group: NavHeaderGroup,
|
|
469
|
-
Tab: NavHeaderTab,
|
|
470
|
-
Logo: NavHeaderLogo,
|
|
471
|
-
}) as NavHeaderComponent;
|
|
472
|
-
|
|
473
|
-
export default NavHeader;
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, {
|
|
4
|
+
createContext,
|
|
5
|
+
useCallback,
|
|
6
|
+
useContext,
|
|
7
|
+
useEffect,
|
|
8
|
+
useLayoutEffect,
|
|
9
|
+
useId,
|
|
10
|
+
useMemo,
|
|
11
|
+
useRef,
|
|
12
|
+
useState,
|
|
13
|
+
} from "react";
|
|
14
|
+
import { motion, HTMLMotionProps, easeInOut } from "framer-motion";
|
|
15
|
+
import styles from "./NavHeader.module.css";
|
|
16
|
+
import Label from "@/components/tools/label/Label";
|
|
17
|
+
import {
|
|
18
|
+
NavHeaderOverlayContext,
|
|
19
|
+
useNavRail,
|
|
20
|
+
useCollapseOnOutsideInteraction,
|
|
21
|
+
} from "../NavContext";
|
|
22
|
+
import { useBreakpoints } from "@/components/tools/mobileViewProvider";
|
|
23
|
+
|
|
24
|
+
export const HEADER_TRANSITION = {
|
|
25
|
+
type: "spring",
|
|
26
|
+
stiffness: 400,
|
|
27
|
+
damping: 30,
|
|
28
|
+
background: { ease: easeInOut, duration: 0.3 },
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
// ── Types ───────────────────────────────────────────────────────────────────
|
|
32
|
+
export type NavHeaderBodyProps = {
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
style?: React.CSSProperties;
|
|
35
|
+
className?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Route(s) on which the header renders in its expanded (hero) state. Defaults
|
|
38
|
+
* to the home page. Accepts a single path or several; matching is exact for
|
|
39
|
+
* "/" and prefix-based otherwise ("/settings" also covers "/settings/...").
|
|
40
|
+
*/
|
|
41
|
+
expandedPaths?: string | string[];
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type NavHeaderGroupProps = {
|
|
45
|
+
/** When true, the group stays visible/interactive while a mega menu is open. */
|
|
46
|
+
alwaysVisible?: boolean;
|
|
47
|
+
children?: React.ReactNode;
|
|
48
|
+
style?: React.CSSProperties;
|
|
49
|
+
className?: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type NavHeaderTabProps = {
|
|
53
|
+
systemName?: string;
|
|
54
|
+
label: string;
|
|
55
|
+
/** Route pushed when the tab has no mega-menu children. Also used for active match. */
|
|
56
|
+
path?: string;
|
|
57
|
+
match?: string | string[];
|
|
58
|
+
/** Mega-menu content. Having children turns the tab into a menu opener. */
|
|
59
|
+
children?: React.ReactNode;
|
|
60
|
+
onClick?: () => void;
|
|
61
|
+
style?: React.CSSProperties;
|
|
62
|
+
className?: string;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** Header.Logo behaves like a motion.div; logoWrap class + base layout merged in. */
|
|
66
|
+
export type NavHeaderLogoProps = HTMLMotionProps<"div">;
|
|
67
|
+
|
|
68
|
+
// MARK: Header State Context (mega/ collapsed,,,)
|
|
69
|
+
type HeaderStateValue = { collapsed: boolean; megaOpen: boolean };
|
|
70
|
+
const NavHeaderStateContext = createContext<HeaderStateValue>({
|
|
71
|
+
collapsed: true,
|
|
72
|
+
megaOpen: false,
|
|
73
|
+
});
|
|
74
|
+
/** Read header collapse / mega-open state (e.g. to size the logo). */
|
|
75
|
+
export function useNavHeaderState() {
|
|
76
|
+
return useContext(NavHeaderStateContext);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// MARK: Tab activation context
|
|
80
|
+
type TabContextValue = {
|
|
81
|
+
activeId: string | null;
|
|
82
|
+
activate: (id: string, content: React.ReactNode) => void;
|
|
83
|
+
close: () => void;
|
|
84
|
+
navigate: (path: string) => void;
|
|
85
|
+
activePath: string;
|
|
86
|
+
};
|
|
87
|
+
const NavHeaderTabContext = createContext<TabContextValue | null>(null);
|
|
88
|
+
|
|
89
|
+
function matchesRoute(matchers: string[], activePath: string): boolean {
|
|
90
|
+
return matchers.some((m) =>
|
|
91
|
+
m === "/"
|
|
92
|
+
? activePath === "/"
|
|
93
|
+
: activePath === m || activePath.startsWith(m + "/"),
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//MARK: Header.Logo
|
|
98
|
+
// Carries the logoWrap layout (state-aware) as defaults; any passed style wins.
|
|
99
|
+
// Only one Header.Logo may exist in the whole header body (dev-checked below).
|
|
100
|
+
function NavHeaderLogo({
|
|
101
|
+
className,
|
|
102
|
+
children,
|
|
103
|
+
style,
|
|
104
|
+
...rest
|
|
105
|
+
}: NavHeaderLogoProps) {
|
|
106
|
+
return (
|
|
107
|
+
<motion.div
|
|
108
|
+
className={`${styles.logoWrap ?? ""} ${className ?? ""}`}
|
|
109
|
+
style={{
|
|
110
|
+
...style,
|
|
111
|
+
}}
|
|
112
|
+
{...rest}
|
|
113
|
+
>
|
|
114
|
+
{children}
|
|
115
|
+
</motion.div>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//MARK: Header.Tab
|
|
120
|
+
// Renders its own <li className=headerItem>. `children` are NOT rendered here —
|
|
121
|
+
// they're lifted into the mega region by NavHeader when this tab is active.
|
|
122
|
+
//
|
|
123
|
+
// Active rule (only ever ONE active tab):
|
|
124
|
+
// • a mega menu open anywhere → only the opener tab is active (route match
|
|
125
|
+
// is suppressed, so Home loses its active state while Projects is open).
|
|
126
|
+
// • nothing open → active follows the route (path / match).
|
|
127
|
+
function NavHeaderTab({
|
|
128
|
+
systemName,
|
|
129
|
+
label,
|
|
130
|
+
path,
|
|
131
|
+
match,
|
|
132
|
+
children,
|
|
133
|
+
onClick,
|
|
134
|
+
style,
|
|
135
|
+
className,
|
|
136
|
+
}: NavHeaderTabProps) {
|
|
137
|
+
const ctx = useContext(NavHeaderTabContext);
|
|
138
|
+
const id = useId();
|
|
139
|
+
const hasMenu = React.Children.count(children) > 0;
|
|
140
|
+
|
|
141
|
+
const someMegaOpen = ctx?.activeId != null;
|
|
142
|
+
const isOpen = ctx?.activeId === id;
|
|
143
|
+
|
|
144
|
+
const matchers = match
|
|
145
|
+
? Array.isArray(match)
|
|
146
|
+
? match
|
|
147
|
+
: [match]
|
|
148
|
+
: path
|
|
149
|
+
? [path]
|
|
150
|
+
: [];
|
|
151
|
+
const routeActive = !!ctx && matchesRoute(matchers, ctx.activePath);
|
|
152
|
+
|
|
153
|
+
const isActive = someMegaOpen ? isOpen : routeActive;
|
|
154
|
+
|
|
155
|
+
const handleClick = useCallback(() => {
|
|
156
|
+
onClick?.();
|
|
157
|
+
if (hasMenu) {
|
|
158
|
+
// Toggle this tab's mega menu (re-click closes it).
|
|
159
|
+
ctx?.activate(id, children);
|
|
160
|
+
} else {
|
|
161
|
+
// Plain link tab: close any open mega, then route.
|
|
162
|
+
ctx?.close();
|
|
163
|
+
if (path) ctx?.navigate(path);
|
|
164
|
+
}
|
|
165
|
+
}, [onClick, hasMenu, ctx, id, children, path]);
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
// eslint-disable-next-line jsx-a11y/role-supports-aria-props
|
|
169
|
+
<li
|
|
170
|
+
className={`${styles.headerItem ?? ""} ${isActive ? (styles.active ?? "") : ""} ${className ?? ""}`}
|
|
171
|
+
style={style}
|
|
172
|
+
onClick={handleClick}
|
|
173
|
+
aria-haspopup={hasMenu || undefined}
|
|
174
|
+
aria-expanded={hasMenu ? isOpen : undefined}
|
|
175
|
+
>
|
|
176
|
+
<span
|
|
177
|
+
style={{
|
|
178
|
+
display: "inline-flex",
|
|
179
|
+
alignItems: "center",
|
|
180
|
+
margin: hasMenu ? 0 : "0 6px 0 0",
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
183
|
+
<Label
|
|
184
|
+
label={label}
|
|
185
|
+
systemName={hasMenu ? "keyboard_arrow_down" : systemName}
|
|
186
|
+
/>
|
|
187
|
+
</span>
|
|
188
|
+
</li>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// MARK: Header.Group
|
|
193
|
+
// A Header.Logo child is lifted out as a direct flex sibling; every other child
|
|
194
|
+
// (Header.Tab / Button / Drop.Menu) is wrapped in a single <ul className=headerMenu>.
|
|
195
|
+
// !alwaysVisible groups fade + go inert while a mega menu is open.
|
|
196
|
+
function NavHeaderGroup({
|
|
197
|
+
alwaysVisible,
|
|
198
|
+
children,
|
|
199
|
+
style,
|
|
200
|
+
className,
|
|
201
|
+
}: NavHeaderGroupProps) {
|
|
202
|
+
const { megaOpen } = useNavHeaderState();
|
|
203
|
+
const hidden = !alwaysVisible && megaOpen;
|
|
204
|
+
|
|
205
|
+
const { logo, menuChildren } = useMemo(() => {
|
|
206
|
+
let logoEl: React.ReactNode = null;
|
|
207
|
+
const rest: React.ReactNode[] = [];
|
|
208
|
+
React.Children.forEach(children, (child) => {
|
|
209
|
+
if (React.isValidElement(child) && child.type === NavHeaderLogo) {
|
|
210
|
+
logoEl = child;
|
|
211
|
+
} else {
|
|
212
|
+
rest.push(child);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
return { logo: logoEl, menuChildren: rest };
|
|
216
|
+
}, [children]);
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<div
|
|
220
|
+
aria-hidden={hidden || undefined}
|
|
221
|
+
className={`${styles.headerGroup ?? ""} ${className ?? ""}`}
|
|
222
|
+
style={{
|
|
223
|
+
display: "flex",
|
|
224
|
+
alignItems: "flex-start",
|
|
225
|
+
opacity: hidden ? 0 : 1,
|
|
226
|
+
pointerEvents: hidden ? "none" : "auto",
|
|
227
|
+
transition:
|
|
228
|
+
"opacity var(--transition-expressive-color), height var(--transition-expressive), width var(--transition-expressive) ",
|
|
229
|
+
...style,
|
|
230
|
+
}}
|
|
231
|
+
>
|
|
232
|
+
{logo}
|
|
233
|
+
{menuChildren.length > 0 && (
|
|
234
|
+
<ul className={styles.headerMenu ?? ""}>{menuChildren}</ul>
|
|
235
|
+
)}
|
|
236
|
+
</div>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
//MARK: Nav.Header
|
|
241
|
+
function NavHeaderBody({
|
|
242
|
+
children,
|
|
243
|
+
style,
|
|
244
|
+
className,
|
|
245
|
+
expandedPaths,
|
|
246
|
+
}: NavHeaderBodyProps) {
|
|
247
|
+
const { navigate, activePath } = useNavRail();
|
|
248
|
+
const { isTablet } = useBreakpoints();
|
|
249
|
+
|
|
250
|
+
// Source of truth for the mega menu. id === null means closed.
|
|
251
|
+
const [active, setActive] = useState<{
|
|
252
|
+
id: string | null;
|
|
253
|
+
content: React.ReactNode;
|
|
254
|
+
}>({ id: null, content: null });
|
|
255
|
+
|
|
256
|
+
const megaOpen = active.id != null;
|
|
257
|
+
|
|
258
|
+
const megaContentRef = useRef<HTMLDivElement>(null);
|
|
259
|
+
const [megaHeight, setMegaHeight] = useState(0);
|
|
260
|
+
|
|
261
|
+
useLayoutEffect(() => {
|
|
262
|
+
if (megaOpen && megaContentRef.current) {
|
|
263
|
+
const cap = window.innerHeight * 0.8; // your 50dvh
|
|
264
|
+
setMegaHeight(Math.min(megaContentRef.current.scrollHeight, cap));
|
|
265
|
+
} else {
|
|
266
|
+
setMegaHeight(0);
|
|
267
|
+
}
|
|
268
|
+
}, [megaOpen, active.content]);
|
|
269
|
+
|
|
270
|
+
// Routes that render the header in its expanded (hero) state. Defaults to the
|
|
271
|
+
// home page; pass `expandedPaths` to opt in other routes (single or several).
|
|
272
|
+
const expandMatchers = useMemo(
|
|
273
|
+
() =>
|
|
274
|
+
expandedPaths
|
|
275
|
+
? Array.isArray(expandedPaths)
|
|
276
|
+
? expandedPaths
|
|
277
|
+
: [expandedPaths]
|
|
278
|
+
: ["/"],
|
|
279
|
+
[expandedPaths],
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
// Collapse once the page scrolls past 24px; re-expand the hero only within 4px
|
|
283
|
+
// of the very top. The 4–24px range holds the previous state (hysteresis), and
|
|
284
|
+
// scrolling while the mega menu is open latches collapsed — so closing the menu
|
|
285
|
+
// mid-scroll near the top can't flash the hero back before the 24px threshold
|
|
286
|
+
// catches up. Desktop only — the header is hidden on mobile.
|
|
287
|
+
const [scrolled, setScrolled] = useState(false);
|
|
288
|
+
const megaOpenRef = useRef(megaOpen);
|
|
289
|
+
useLayoutEffect(() => {
|
|
290
|
+
megaOpenRef.current = megaOpen;
|
|
291
|
+
});
|
|
292
|
+
useEffect(() => {
|
|
293
|
+
if (isTablet) return;
|
|
294
|
+
const onScroll = () => {
|
|
295
|
+
const y = window.scrollY;
|
|
296
|
+
setScrolled((prev) =>
|
|
297
|
+
megaOpenRef.current || y > 24 ? true : y < 4 ? false : prev,
|
|
298
|
+
);
|
|
299
|
+
};
|
|
300
|
+
onScroll();
|
|
301
|
+
window.addEventListener("scroll", onScroll, { passive: true });
|
|
302
|
+
return () => window.removeEventListener("scroll", onScroll);
|
|
303
|
+
}, [isTablet]);
|
|
304
|
+
|
|
305
|
+
// An open mega menu always forces the collapsed (compact) header — nothing
|
|
306
|
+
// overrides it. Otherwise the header expands only on an eligible route while
|
|
307
|
+
// still scrolled to the top. Either way the mega region expands directly below
|
|
308
|
+
// the header content in the flex column (see render).
|
|
309
|
+
const collapsed =
|
|
310
|
+
megaOpen || !matchesRoute(expandMatchers, activePath) || scrolled;
|
|
311
|
+
|
|
312
|
+
// Closing only clears the id so `active.content` stays mounted through the
|
|
313
|
+
// collapse animation; the content is nulled in onAnimationComplete once the
|
|
314
|
+
// mega region has finished shrinking to 0 (see render).
|
|
315
|
+
const close = useCallback(
|
|
316
|
+
() => setActive((prev) => ({ ...prev, id: null })),
|
|
317
|
+
[],
|
|
318
|
+
);
|
|
319
|
+
const activate = useCallback((id: string, content: React.ReactNode) => {
|
|
320
|
+
setActive((prev) =>
|
|
321
|
+
prev.id === id ? { ...prev, id: null } : { id, content },
|
|
322
|
+
);
|
|
323
|
+
}, []);
|
|
324
|
+
|
|
325
|
+
// Dev-only: only one Header.Logo allowed in the whole body.
|
|
326
|
+
if (process.env.NODE_ENV !== "production") {
|
|
327
|
+
let logoCount = 0;
|
|
328
|
+
const scan = (nodes: React.ReactNode) =>
|
|
329
|
+
React.Children.forEach(nodes, (c) => {
|
|
330
|
+
if (!React.isValidElement(c)) return;
|
|
331
|
+
if (c.type === NavHeaderLogo) logoCount++;
|
|
332
|
+
const kids = (c.props as { children?: React.ReactNode }).children;
|
|
333
|
+
if (kids) scan(kids);
|
|
334
|
+
});
|
|
335
|
+
scan(children);
|
|
336
|
+
if (logoCount > 1)
|
|
337
|
+
console.warn(
|
|
338
|
+
"Nav.Header: only one Header.Logo may exist in the header body.",
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const tabContextValue = useMemo<TabContextValue>(
|
|
343
|
+
() => ({ activeId: active.id, activate, close, navigate, activePath }),
|
|
344
|
+
[active.id, activate, close, navigate, activePath],
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
const stateContextValue = useMemo<HeaderStateValue>(
|
|
348
|
+
() => ({ collapsed, megaOpen }),
|
|
349
|
+
[collapsed, megaOpen],
|
|
350
|
+
);
|
|
351
|
+
|
|
352
|
+
// Publish open-state + close handler so Nav.Content's dim (in Nav.tsx) reacts.
|
|
353
|
+
// setOverlay is a stable useState setter → no feedback loop.
|
|
354
|
+
const setOverlay = useContext(NavHeaderOverlayContext)?.setOverlay;
|
|
355
|
+
useEffect(() => {
|
|
356
|
+
setOverlay?.({ isOpen: megaOpen, close });
|
|
357
|
+
}, [megaOpen, close, setOverlay]);
|
|
358
|
+
useEffect(() => () => setOverlay?.(null), [setOverlay]);
|
|
359
|
+
|
|
360
|
+
// Close on scroll / outside pointerdown — desktop only (header is hidden on
|
|
361
|
+
// mobile and must not fight Nav.Bar's listeners).
|
|
362
|
+
const headerRef = useRef<HTMLElement>(null);
|
|
363
|
+
useCollapseOnOutsideInteraction(megaOpen, close, headerRef, !isTablet);
|
|
364
|
+
|
|
365
|
+
return (
|
|
366
|
+
<NavHeaderStateContext.Provider value={stateContextValue}>
|
|
367
|
+
<NavHeaderTabContext.Provider value={tabContextValue}>
|
|
368
|
+
<motion.header
|
|
369
|
+
ref={headerRef}
|
|
370
|
+
className={`${styles.headerBody ?? ""} ${megaOpen ? (styles.megaMenu ?? "") : ""} ${className ?? ""}`}
|
|
371
|
+
style={{
|
|
372
|
+
display: "flex",
|
|
373
|
+
flexDirection: "column",
|
|
374
|
+
alignItems: "flex-start",
|
|
375
|
+
position: "fixed",
|
|
376
|
+
width: "100%",
|
|
377
|
+
zIndex: 1010,
|
|
378
|
+
background:
|
|
379
|
+
"linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 0%, transparent 100%)",
|
|
380
|
+
left: 0,
|
|
381
|
+
top: 0,
|
|
382
|
+
...style,
|
|
383
|
+
}}
|
|
384
|
+
animate={{
|
|
385
|
+
borderRadius: megaOpen ? "0px 0px 36px 36px" : "0px 0px 0px 0px",
|
|
386
|
+
boxShadow: megaOpen
|
|
387
|
+
? "0 1px 1px rgba(0,0,0,0.1), 0 2px 2px rgba(0,0,0,0.1), 0 4px 4px rgba(0,0,0,0.1)"
|
|
388
|
+
: "0 0 0 rgba(0,0,0,0)",
|
|
389
|
+
}}
|
|
390
|
+
transition={HEADER_TRANSITION}
|
|
391
|
+
>
|
|
392
|
+
<motion.div
|
|
393
|
+
aria-hidden
|
|
394
|
+
initial={false}
|
|
395
|
+
animate={{ opacity: megaOpen ? 1 : 0 }}
|
|
396
|
+
transition={HEADER_TRANSITION.background}
|
|
397
|
+
style={{
|
|
398
|
+
position: "absolute",
|
|
399
|
+
inset: 0,
|
|
400
|
+
zIndex: -1,
|
|
401
|
+
borderRadius: "inherit",
|
|
402
|
+
pointerEvents: "none",
|
|
403
|
+
background: "var(--md-sys-color-surface-container-low)",
|
|
404
|
+
borderBottom: "1px solid var(--globalUIBorderCard)",
|
|
405
|
+
}}
|
|
406
|
+
/>
|
|
407
|
+
|
|
408
|
+
{/* Top row: your Header.Group(s) — space-between */}
|
|
409
|
+
<div
|
|
410
|
+
className={styles.headerContent ?? ""}
|
|
411
|
+
style={{
|
|
412
|
+
display: "flex",
|
|
413
|
+
height: "fit-content",
|
|
414
|
+
width: "100%",
|
|
415
|
+
justifyContent: "space-between",
|
|
416
|
+
padding: collapsed ? "12px" : "24px",
|
|
417
|
+
}}
|
|
418
|
+
>
|
|
419
|
+
{children}
|
|
420
|
+
</div>
|
|
421
|
+
|
|
422
|
+
{/* Mega region: the active tab's children render here. */}
|
|
423
|
+
<motion.div
|
|
424
|
+
className={styles.megamenuContent ?? ""}
|
|
425
|
+
style={{
|
|
426
|
+
width: "100%",
|
|
427
|
+
overflow: "hidden",
|
|
428
|
+
paddingLeft: 24,
|
|
429
|
+
paddingRight: 24,
|
|
430
|
+
}}
|
|
431
|
+
initial={false}
|
|
432
|
+
animate={{
|
|
433
|
+
height: megaHeight,
|
|
434
|
+
opacity: megaOpen ? 1 : 0,
|
|
435
|
+
paddingTop: megaOpen ? 24 : 0,
|
|
436
|
+
paddingBottom: megaOpen ? 24 : 0,
|
|
437
|
+
}}
|
|
438
|
+
transition={HEADER_TRANSITION}
|
|
439
|
+
onAnimationComplete={() =>
|
|
440
|
+
setActive((prev) =>
|
|
441
|
+
prev.id === null ? { id: null, content: null } : prev,
|
|
442
|
+
)
|
|
443
|
+
}
|
|
444
|
+
>
|
|
445
|
+
<div ref={megaContentRef}>{active.content}</div>
|
|
446
|
+
</motion.div>
|
|
447
|
+
</motion.header>
|
|
448
|
+
</NavHeaderTabContext.Provider>
|
|
449
|
+
</NavHeaderStateContext.Provider>
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
type NavHeaderComponent = React.FC<NavHeaderBodyProps> & {
|
|
454
|
+
Group: React.FC<NavHeaderGroupProps>;
|
|
455
|
+
Tab: React.FC<NavHeaderTabProps>;
|
|
456
|
+
Logo: React.FC<NavHeaderLogoProps>;
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
const NavHeader = Object.assign(NavHeaderBody, {
|
|
460
|
+
Group: NavHeaderGroup,
|
|
461
|
+
Tab: NavHeaderTab,
|
|
462
|
+
Logo: NavHeaderLogo,
|
|
463
|
+
}) as NavHeaderComponent;
|
|
464
|
+
|
|
465
|
+
export default NavHeader;
|