@yamatozhen/design_system 1.0.0 → 1.1.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/LICENSE +201 -201
- package/README.md +101 -101
- package/package.json +50 -49
- package/scripts/postinstall.js +91 -105
- package/template/app/ClientNav.tsx +258 -310
- package/template/app/globals.css +2 -167
- package/template/app/layout.tsx +94 -128
- package/template/app/themes/dark-mc 2.css +51 -0
- package/template/app/themes/dark-mc.css +51 -51
- package/template/app/themes/dark.css +51 -51
- package/template/app/themes/light 2.css +51 -0
- package/template/app/themes/light-mc 2.css +51 -0
- package/template/app/themes/light-mc.css +51 -51
- package/template/app/themes/light.css +51 -51
- package/template/app/themes/theme 2.css +272 -0
- 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/(controls)/switch/Switch.module.css +108 -0
- package/template/components/(controls)/switch/Switch.tsx +69 -0
- 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 -478
- 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 2.tsx +107 -0
- package/template/components/tools/CustomScrollbar.tsx +107 -0
- package/template/components/tools/Divider 2.tsx +11 -0
- package/template/components/tools/Divider.tsx +11 -11
- package/template/components/tools/ReduceMotionContext 2.tsx +5 -0
- package/template/components/tools/ReduceMotionContext.tsx +5 -5
- package/template/components/tools/Sinewave 2.tsx +206 -0
- package/template/components/tools/Sinewave.tsx +396 -199
- package/template/components/tools/SinewaveProgress 2.tsx +140 -0
- package/template/components/tools/SinewaveProgress.tsx +140 -135
- package/template/components/tools/badge/Badge 2.tsx +28 -0
- 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 2.ts +7 -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 2.tsx +99 -0
- package/template/components/tools/input/Input.module 2.css +45 -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 2.tsx +39 -0
- package/template/components/tools/label/Icon.tsx +39 -0
- package/template/components/tools/label/Label 2.tsx +150 -0
- package/template/components/tools/label/Label.tsx +156 -0
- package/template/components/tools/mobileViewProvider 2.tsx +53 -0
- package/template/components/tools/mobileViewProvider.tsx +53 -58
- package/template/components/tools/ripple/ripple 2.css +38 -0
- package/template/components/tools/ripple/ripple 2.tsx +78 -0
- package/template/components/tools/ripple/ripple.css +38 -41
- package/template/components/tools/ripple/ripple.tsx +78 -53
- package/template/components/tools/shape/{ShapeMorph.tsx → Shape 2.tsx } +313 -190
- package/template/components/tools/shape/Shape.module 2.css +21 -0
- package/template/components/tools/shape/Shape.module.css +25 -0
- package/template/components/tools/shape/Shape.tsx +316 -0
- package/template/components/tools/shape/ShapeLoader 2.tsx +104 -0
- package/template/components/tools/shape/ShapeLoader.tsx +104 -101
- package/template/components/tools/shape/ShapePaths 2.ts +116 -0
- package/template/components/tools/shape/ShapePaths.ts +116 -116
- package/template/components/{layout/switch/Switch.tsx → tools/switch/Switch 2.tsx } +48 -48
- package/template/components/{layout/switch/Switch.module.css → tools/switch/Switch.module 2.css } +102 -102
- package/template/components/tools/switch/Switch.module.css +102 -102
- package/template/components/tools/switch/Switch.tsx +48 -48
- package/template/components/tools/useBodyScrollLock 2.tsx +27 -0
- package/template/components/tools/useBodyScrollLock.tsx +27 -27
- package/template/components/tools/useImageColor 2.ts +47 -0
- package/template/components/tools/useImageColor.ts +47 -47
- package/template/components/tools/useNavSheetDrag 2.tsx +196 -0
- package/template/components/tools/useNavSheetDrag.tsx +196 -196
- package/template/public/fonts/material-symbols/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght 2.woff2 +0 -0
- 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/SocialIcons.tsx +0 -88
- 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,399 +1,448 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
memo,
|
|
3
|
-
useCallback,
|
|
4
|
-
useContext,
|
|
5
|
-
useEffect,
|
|
6
|
-
useMemo,
|
|
7
|
-
useRef,
|
|
8
|
-
useState,
|
|
9
|
-
} from "react";
|
|
10
|
-
import { easeInOut, motion } from "framer-motion";
|
|
11
|
-
import Icon from "@/components/tools/
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
useHasHeader,
|
|
15
|
-
NavFTBStickyContext,
|
|
16
|
-
NavFTBEmbeddedContext,
|
|
17
|
-
NavFTBGroupContext,
|
|
18
|
-
} from "../NavContext";
|
|
19
|
-
import { useReduceMotion } from "@/components/tools/ReduceMotionContext";
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} from "
|
|
29
|
-
import
|
|
30
|
-
import {
|
|
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
|
-
if (!
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
//
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
isEmbedded
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
onTabChange,
|
|
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
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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
|
-
const
|
|
399
|
-
|
|
1
|
+
import React, {
|
|
2
|
+
memo,
|
|
3
|
+
useCallback,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from "react";
|
|
10
|
+
import { easeInOut, motion } from "framer-motion";
|
|
11
|
+
import Icon from "@/components/tools/label/Icon";
|
|
12
|
+
import Label from "@/components/tools/label/Label";
|
|
13
|
+
import {
|
|
14
|
+
useHasHeader,
|
|
15
|
+
NavFTBStickyContext,
|
|
16
|
+
NavFTBEmbeddedContext,
|
|
17
|
+
NavFTBGroupContext,
|
|
18
|
+
} from "../NavContext";
|
|
19
|
+
import { useReduceMotion } from "@/components/tools/ReduceMotionContext";
|
|
20
|
+
import styles from "./NavFTB.module.css";
|
|
21
|
+
import { useTabIndicator } from "./useTabIndicator";
|
|
22
|
+
import type {
|
|
23
|
+
NavFTBProps,
|
|
24
|
+
FTBRefProps,
|
|
25
|
+
NavFTBGroupContextValue,
|
|
26
|
+
} from "../NavContext";
|
|
27
|
+
import Card from "@/components/(layout)/card/Card";
|
|
28
|
+
import { Wrap } from "@/components/(layout)/navigation/Wrap";
|
|
29
|
+
import type { ShapeType } from "@/components/tools/shape/ShapePaths";
|
|
30
|
+
import { useBreakpoints } from "@/components/tools/mobileViewProvider";
|
|
31
|
+
|
|
32
|
+
function FTBRef({ forLabel, children }: FTBRefProps) {
|
|
33
|
+
const ctx = useContext(NavFTBGroupContext);
|
|
34
|
+
const rm = useReduceMotion();
|
|
35
|
+
if (!ctx) {
|
|
36
|
+
if (process.env.NODE_ENV !== "production") {
|
|
37
|
+
console.error("<FTB.Ref> must be used within <Nav.FTB>");
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
if (ctx.selectedLabel.toLowerCase() !== forLabel.toLowerCase()) return null;
|
|
42
|
+
// Each tab's content mounts fresh when it becomes active, so this replays
|
|
43
|
+
// its fade-from-bottom on every reveal. 300ms tuned snappy for a tab
|
|
44
|
+
// switch.
|
|
45
|
+
return (
|
|
46
|
+
<motion.div
|
|
47
|
+
initial={{ opacity: 0, y: rm ? 0 : 40 }}
|
|
48
|
+
animate={{ opacity: 1, y: 0 }}
|
|
49
|
+
transition={{ duration: rm ? 0 : 0.3, ease: easeInOut }}
|
|
50
|
+
style={{
|
|
51
|
+
display: "flex",
|
|
52
|
+
flexDirection: "column",
|
|
53
|
+
alignItems: "center",
|
|
54
|
+
width: "100%",
|
|
55
|
+
gap: 12,
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
{children}
|
|
59
|
+
</motion.div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const NavFTBInner = memo(function NavFTB({
|
|
64
|
+
tabs,
|
|
65
|
+
id,
|
|
66
|
+
onTabChange,
|
|
67
|
+
activeTabId,
|
|
68
|
+
inSection = false,
|
|
69
|
+
children,
|
|
70
|
+
}: NavFTBProps) {
|
|
71
|
+
const [selected, setSelected] = useState(() => {
|
|
72
|
+
if (activeTabId) {
|
|
73
|
+
const idx = tabs.findIndex(
|
|
74
|
+
(t) => t.label.toLowerCase() === activeTabId.toLowerCase(),
|
|
75
|
+
);
|
|
76
|
+
return idx >= 0 ? idx : 0;
|
|
77
|
+
}
|
|
78
|
+
const childArray = React.Children.toArray(children);
|
|
79
|
+
for (const child of childArray) {
|
|
80
|
+
if (
|
|
81
|
+
React.isValidElement(child) &&
|
|
82
|
+
(child.props as FTBRefProps).defaultTab
|
|
83
|
+
) {
|
|
84
|
+
const label = (child.props as FTBRefProps).forLabel;
|
|
85
|
+
const idx = tabs.findIndex(
|
|
86
|
+
(t) => t.label.toLowerCase() === label.toLowerCase(),
|
|
87
|
+
);
|
|
88
|
+
if (idx >= 0) return idx;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return 0;
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (process.env.NODE_ENV === "production") return;
|
|
96
|
+
const childArray = React.Children.toArray(children);
|
|
97
|
+
if (childArray.length === 0) return;
|
|
98
|
+
const hasDefault = childArray.some(
|
|
99
|
+
(child) =>
|
|
100
|
+
React.isValidElement(child) && (child.props as FTBRefProps).defaultTab,
|
|
101
|
+
);
|
|
102
|
+
if (!hasDefault) {
|
|
103
|
+
console.warn(
|
|
104
|
+
"<Nav.FTB>: No <FTB.Ref defaultTab> found. " +
|
|
105
|
+
"Add the defaultTab prop to the Ref that should be shown initially.",
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
109
|
+
}, []);
|
|
110
|
+
|
|
111
|
+
// Syncs `selected` to the externally-driven activeTabId (e.g. route
|
|
112
|
+
// changes) — a real external signal, not something derivable at render.
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (!activeTabId) return;
|
|
115
|
+
const idx = tabs.findIndex(
|
|
116
|
+
(t) => t.label.toLowerCase() === activeTabId.toLowerCase(),
|
|
117
|
+
);
|
|
118
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
119
|
+
if (idx >= 0) setSelected(idx);
|
|
120
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
121
|
+
}, [activeTabId]);
|
|
122
|
+
|
|
123
|
+
const isHeader = useHasHeader();
|
|
124
|
+
// Sticky offset of the bar + the sentinel threshold that flips `elevated`.
|
|
125
|
+
// Mirror of `top` in .FTBRoot — keep the two in sync. Only Nav.Header
|
|
126
|
+
// reserves real space up top, so the threshold collapses to a small margin
|
|
127
|
+
// when there's no header to clear.
|
|
128
|
+
const marginHeader = isHeader ? 68 : 12;
|
|
129
|
+
|
|
130
|
+
const sentinelRef = useRef<HTMLDivElement>(null);
|
|
131
|
+
// Marks the bottom edge of the whole FTB block (bar + children). Lets
|
|
132
|
+
// `elevated` turn back off once the block has scrolled past the top of the
|
|
133
|
+
// viewport, instead of staying stuck for the rest of the page — the top
|
|
134
|
+
// sentinel alone never re-crosses back below marginHeader once you've
|
|
135
|
+
// scrolled past the entire section.
|
|
136
|
+
const endSentinelRef = useRef<HTMLDivElement>(null);
|
|
137
|
+
const [elevated, setElevated] = useState(false);
|
|
138
|
+
const programmaticRef = useRef(false);
|
|
139
|
+
|
|
140
|
+
// Mirrors .FTBRoot's height in NavFTB.module.css — keep the two in sync.
|
|
141
|
+
const FTB_HEIGHT = 72;
|
|
142
|
+
|
|
143
|
+
// Samples the sentinel every rAF during scroll to drive `elevated`. The
|
|
144
|
+
// programmatic guard freezes it while the tab-change scroll runs so the
|
|
145
|
+
// smooth scroll can't flap elevated across the threshold (which would mount/
|
|
146
|
+
// unmount the mobile mirror mid-scroll and judder).
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
const el = sentinelRef.current;
|
|
149
|
+
if (!el) return;
|
|
150
|
+
let ticking = false;
|
|
151
|
+
const measure = () => {
|
|
152
|
+
ticking = false;
|
|
153
|
+
if (programmaticRef.current) return;
|
|
154
|
+
const endEl = endSentinelRef.current;
|
|
155
|
+
const stillOnScreen = endEl
|
|
156
|
+
? endEl.getBoundingClientRect().top > marginHeader + FTB_HEIGHT
|
|
157
|
+
: true;
|
|
158
|
+
setElevated(
|
|
159
|
+
el.getBoundingClientRect().top < marginHeader && stillOnScreen,
|
|
160
|
+
);
|
|
161
|
+
};
|
|
162
|
+
const onScroll = () => {
|
|
163
|
+
if (ticking) return;
|
|
164
|
+
ticking = true;
|
|
165
|
+
requestAnimationFrame(measure);
|
|
166
|
+
};
|
|
167
|
+
measure();
|
|
168
|
+
document.addEventListener("scroll", onScroll, {
|
|
169
|
+
capture: true,
|
|
170
|
+
passive: true,
|
|
171
|
+
});
|
|
172
|
+
window.addEventListener("resize", onScroll, { passive: true });
|
|
173
|
+
return () => {
|
|
174
|
+
document.removeEventListener("scroll", onScroll, { capture: true });
|
|
175
|
+
window.removeEventListener("resize", onScroll);
|
|
176
|
+
};
|
|
177
|
+
}, [marginHeader]);
|
|
178
|
+
|
|
179
|
+
// On tab change, bring the new tab to the top. scrollIntoView + the
|
|
180
|
+
// sentinel's scroll-margin-top clears the bar/chrome natively; `elevated` is
|
|
181
|
+
// frozen for the duration so the mirror can't toggle mid-scroll.
|
|
182
|
+
const didMountRef = useRef(false);
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
if (!didMountRef.current) {
|
|
185
|
+
didMountRef.current = true;
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const el = sentinelRef.current;
|
|
189
|
+
if (!el) return;
|
|
190
|
+
|
|
191
|
+
programmaticRef.current = true;
|
|
192
|
+
el.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
193
|
+
|
|
194
|
+
let done = false;
|
|
195
|
+
const settle = () => {
|
|
196
|
+
if (done) return;
|
|
197
|
+
done = true;
|
|
198
|
+
programmaticRef.current = false;
|
|
199
|
+
const s = sentinelRef.current;
|
|
200
|
+
const endEl = endSentinelRef.current;
|
|
201
|
+
const stillOnScreen = endEl
|
|
202
|
+
? endEl.getBoundingClientRect().top > marginHeader + FTB_HEIGHT
|
|
203
|
+
: true;
|
|
204
|
+
if (s)
|
|
205
|
+
setElevated(
|
|
206
|
+
s.getBoundingClientRect().top < marginHeader && stillOnScreen,
|
|
207
|
+
);
|
|
208
|
+
window.removeEventListener("scrollend", settle);
|
|
209
|
+
window.clearTimeout(fallback);
|
|
210
|
+
};
|
|
211
|
+
const fallback = window.setTimeout(settle, 700);
|
|
212
|
+
window.addEventListener("scrollend", settle);
|
|
213
|
+
return () => {
|
|
214
|
+
programmaticRef.current = false;
|
|
215
|
+
window.removeEventListener("scrollend", settle);
|
|
216
|
+
window.clearTimeout(fallback);
|
|
217
|
+
};
|
|
218
|
+
}, [selected, marginHeader]);
|
|
219
|
+
|
|
220
|
+
const reduceMotion = useReduceMotion();
|
|
221
|
+
const { isTablet } = useBreakpoints();
|
|
222
|
+
const isEmbedded = useContext(NavFTBEmbeddedContext);
|
|
223
|
+
const stickyCtx = useContext(NavFTBStickyContext);
|
|
224
|
+
const setFtbProps = stickyCtx?.setFtbProps;
|
|
225
|
+
|
|
226
|
+
// Mirror the bar into the fixed top bar when it elevates on mobile.
|
|
227
|
+
useEffect(() => {
|
|
228
|
+
if (isEmbedded || !setFtbProps) return;
|
|
229
|
+
if (elevated && isTablet) {
|
|
230
|
+
setFtbProps({
|
|
231
|
+
id,
|
|
232
|
+
tabs,
|
|
233
|
+
onTabChange: (index: number) => {
|
|
234
|
+
setSelected(index);
|
|
235
|
+
onTabChange?.(index);
|
|
236
|
+
},
|
|
237
|
+
activeTabId: tabs[selected]?.label,
|
|
238
|
+
});
|
|
239
|
+
} else {
|
|
240
|
+
setFtbProps(null);
|
|
241
|
+
}
|
|
242
|
+
return () => setFtbProps(null);
|
|
243
|
+
}, [
|
|
244
|
+
elevated,
|
|
245
|
+
isTablet,
|
|
246
|
+
isEmbedded,
|
|
247
|
+
setFtbProps,
|
|
248
|
+
id,
|
|
249
|
+
tabs,
|
|
250
|
+
onTabChange,
|
|
251
|
+
selected,
|
|
252
|
+
]);
|
|
253
|
+
|
|
254
|
+
const {
|
|
255
|
+
containerRef,
|
|
256
|
+
indicatorRef,
|
|
257
|
+
registerTab,
|
|
258
|
+
remeasureAndSnap,
|
|
259
|
+
onTabPointerEnter,
|
|
260
|
+
onTabPointerLeave,
|
|
261
|
+
} = useTabIndicator({
|
|
262
|
+
selected,
|
|
263
|
+
setSelected,
|
|
264
|
+
tabs,
|
|
265
|
+
elevated,
|
|
266
|
+
isEmbedded,
|
|
267
|
+
reduceMotion,
|
|
268
|
+
onTabChange,
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
const handleClick = useCallback(
|
|
272
|
+
(index: number) => {
|
|
273
|
+
setSelected(index);
|
|
274
|
+
onTabChange?.(index);
|
|
275
|
+
},
|
|
276
|
+
[onTabChange],
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
const selectTab = useCallback(
|
|
280
|
+
(target: number | string) => {
|
|
281
|
+
const index =
|
|
282
|
+
typeof target === "number"
|
|
283
|
+
? target
|
|
284
|
+
: tabs.findIndex(
|
|
285
|
+
(t) => t.label.toLowerCase() === target.toLowerCase(),
|
|
286
|
+
);
|
|
287
|
+
if (index < 0 || index >= tabs.length) return;
|
|
288
|
+
setSelected(index);
|
|
289
|
+
onTabChange?.(index);
|
|
290
|
+
},
|
|
291
|
+
[tabs, onTabChange],
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
const selectedLabel = tabs[selected]?.label ?? "";
|
|
295
|
+
|
|
296
|
+
const groupValue = useMemo<NavFTBGroupContextValue>(
|
|
297
|
+
() => ({ selectedLabel, selectedIndex: selected, tabs, selectTab }),
|
|
298
|
+
[selectedLabel, selected, tabs, selectTab],
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
return (
|
|
302
|
+
<NavFTBGroupContext.Provider value={groupValue}>
|
|
303
|
+
<div
|
|
304
|
+
ref={sentinelRef}
|
|
305
|
+
aria-hidden="true"
|
|
306
|
+
className={styles.FTBsentinel}
|
|
307
|
+
data-header={isHeader ? "" : undefined}
|
|
308
|
+
/>
|
|
309
|
+
|
|
310
|
+
<motion.div
|
|
311
|
+
className={styles.FTBRoot}
|
|
312
|
+
data-elevated={elevated ? "" : undefined}
|
|
313
|
+
data-embedded={isEmbedded ? "" : undefined}
|
|
314
|
+
data-section={inSection ? "" : undefined}
|
|
315
|
+
data-mobile={isTablet ? "" : undefined}
|
|
316
|
+
data-header={isHeader ? "" : undefined}
|
|
317
|
+
layout={!isEmbedded}
|
|
318
|
+
whileHover={{ scale: !isTablet && elevated ? 1.02 : 1 }}
|
|
319
|
+
transition={{
|
|
320
|
+
ease: [0.01, 1.25, 0.23, 1.01],
|
|
321
|
+
duration: 0.4,
|
|
322
|
+
delay: 0,
|
|
323
|
+
scale: { ease: easeInOut, duration: 0.2 },
|
|
324
|
+
}}
|
|
325
|
+
onLayoutAnimationComplete={remeasureAndSnap}
|
|
326
|
+
>
|
|
327
|
+
<div
|
|
328
|
+
ref={containerRef}
|
|
329
|
+
role="tablist"
|
|
330
|
+
aria-label={id}
|
|
331
|
+
className={styles.FTBscroller}
|
|
332
|
+
>
|
|
333
|
+
<div
|
|
334
|
+
ref={indicatorRef}
|
|
335
|
+
aria-hidden="true"
|
|
336
|
+
className={styles.FTBindicator}
|
|
337
|
+
/>
|
|
338
|
+
{tabs.map((tab, i) => (
|
|
339
|
+
<span
|
|
340
|
+
key={tab.label}
|
|
341
|
+
ref={registerTab(i)}
|
|
342
|
+
role="tab"
|
|
343
|
+
aria-selected={selected === i}
|
|
344
|
+
tabIndex={selected === i ? 0 : -1}
|
|
345
|
+
onClick={() => handleClick(i)}
|
|
346
|
+
onPointerEnter={() => onTabPointerEnter(i)}
|
|
347
|
+
onPointerLeave={onTabPointerLeave}
|
|
348
|
+
className={`${styles.tab} ${
|
|
349
|
+
selected !== i ? styles.tabInactive : ""
|
|
350
|
+
}`}
|
|
351
|
+
>
|
|
352
|
+
{tab.systemName && <Icon systemName={tab.systemName} />}
|
|
353
|
+
{tab.label ||
|
|
354
|
+
(tab.label && tab.systemName && (
|
|
355
|
+
<Label systemName={tab.systemName} label={tab.label} />
|
|
356
|
+
))}
|
|
357
|
+
</span>
|
|
358
|
+
))}
|
|
359
|
+
</div>
|
|
360
|
+
</motion.div>
|
|
361
|
+
|
|
362
|
+
<div
|
|
363
|
+
aria-hidden="true"
|
|
364
|
+
className={styles.FTBfade}
|
|
365
|
+
data-elevated={elevated ? "" : undefined}
|
|
366
|
+
data-mobile={isTablet ? "" : undefined}
|
|
367
|
+
data-header={isHeader ? "" : undefined}
|
|
368
|
+
/>
|
|
369
|
+
|
|
370
|
+
{children}
|
|
371
|
+
|
|
372
|
+
<div
|
|
373
|
+
ref={endSentinelRef}
|
|
374
|
+
aria-hidden="true"
|
|
375
|
+
className={styles.FTBendSentinel}
|
|
376
|
+
/>
|
|
377
|
+
</NavFTBGroupContext.Provider>
|
|
378
|
+
);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
const DEFAULT_MIO_SHAPES: ShapeType[] = ["sunny", "bun", "gem", "flower"];
|
|
382
|
+
|
|
383
|
+
// Deterministic, NOT random — Math.random() here would pick a different
|
|
384
|
+
// shape on the server render vs. the client render (same component, two
|
|
385
|
+
// separate evaluations), which is exactly what caused the hydration
|
|
386
|
+
// mismatch on <ShapeMorph>'s `d` attribute. Hashing the label instead means
|
|
387
|
+
// the same tab always resolves to the same shape everywhere, while still
|
|
388
|
+
// varying shape-to-shape for visual variety.
|
|
389
|
+
function hashString(str: string): number {
|
|
390
|
+
let hash = 0;
|
|
391
|
+
for (let i = 0; i < str.length; i++) {
|
|
392
|
+
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
393
|
+
hash |= 0; // keep it a 32-bit int
|
|
394
|
+
}
|
|
395
|
+
return Math.abs(hash);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const pickShape = (pool: ShapeType[], seed: string) =>
|
|
399
|
+
pool[hashString(seed) % pool.length];
|
|
400
|
+
|
|
401
|
+
function FTBMio({ shapes = DEFAULT_MIO_SHAPES }: { shapes?: ShapeType[] }) {
|
|
402
|
+
const ctx = useContext(NavFTBGroupContext);
|
|
403
|
+
const prev = ctx ? ctx.tabs[ctx.selectedIndex - 1] : undefined;
|
|
404
|
+
const next = ctx ? ctx.tabs[ctx.selectedIndex + 1] : undefined;
|
|
405
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
406
|
+
const prevShape = useMemo(
|
|
407
|
+
() => pickShape(shapes, prev?.label ?? ""),
|
|
408
|
+
[prev?.label],
|
|
409
|
+
);
|
|
410
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
411
|
+
const nextShape = useMemo(
|
|
412
|
+
() => pickShape(shapes, next?.label ?? ""),
|
|
413
|
+
[next?.label],
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
if (!ctx || (!prev && !next)) return null;
|
|
417
|
+
const { selectedIndex, selectTab } = ctx;
|
|
418
|
+
|
|
419
|
+
return (
|
|
420
|
+
<Wrap>
|
|
421
|
+
{prev && (
|
|
422
|
+
<Card
|
|
423
|
+
navigate="previous"
|
|
424
|
+
withIcon={{ systemName: prev.systemName, shapePath: prevShape }}
|
|
425
|
+
onClick={() => selectTab(selectedIndex - 1)}
|
|
426
|
+
>
|
|
427
|
+
<Card.Header>
|
|
428
|
+
<h5>{prev.label}</h5>
|
|
429
|
+
</Card.Header>
|
|
430
|
+
</Card>
|
|
431
|
+
)}
|
|
432
|
+
{next && (
|
|
433
|
+
<Card
|
|
434
|
+
navigate="next"
|
|
435
|
+
withIcon={{ systemName: next.systemName, shapePath: nextShape }}
|
|
436
|
+
onClick={() => selectTab(selectedIndex + 1)}
|
|
437
|
+
>
|
|
438
|
+
<Card.Header>
|
|
439
|
+
<h5>{next.label}</h5>
|
|
440
|
+
</Card.Header>
|
|
441
|
+
</Card>
|
|
442
|
+
)}
|
|
443
|
+
</Wrap>
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
const NavFTB = Object.assign(NavFTBInner, { Ref: FTBRef, Mio: FTBMio });
|
|
448
|
+
export default NavFTB;
|