@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,516 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React, {
|
|
4
|
-
createContext,
|
|
5
|
-
useContext,
|
|
6
|
-
useEffect,
|
|
7
|
-
useLayoutEffect,
|
|
8
|
-
useRef,
|
|
9
|
-
useState,
|
|
10
|
-
} from "react";
|
|
11
|
-
import { motion, AnimatePresence, easeInOut } from "framer-motion";
|
|
12
|
-
import Icon from "@/components/tools/icon/icon";
|
|
13
|
-
import styles from "./drop.module.css";
|
|
14
|
-
|
|
15
|
-
// ---------------- motion ----------------
|
|
16
|
-
const EASE_EXPRESSIVE = [0.01, 1.25, 0.23, 1.01] as const;
|
|
17
|
-
const MORPH = { duration: 0.6, ease: EASE_EXPRESSIVE };
|
|
18
|
-
const EASE_EXPRESSIVE_FAST = [0.55, 0.57, 0, 1.58] as const;
|
|
19
|
-
const MORPH_2 = { duration: 0.6, ease: EASE_EXPRESSIVE_FAST };
|
|
20
|
-
|
|
21
|
-
// ---------------- variants (same shape as button.tsx) ----------------
|
|
22
|
-
type Variant =
|
|
23
|
-
| "primary"
|
|
24
|
-
| "secondary"
|
|
25
|
-
| "tertiary"
|
|
26
|
-
| "outlined"
|
|
27
|
-
| "text"
|
|
28
|
-
| "link";
|
|
29
|
-
|
|
30
|
-
type VariantBools = {
|
|
31
|
-
primary?: boolean;
|
|
32
|
-
secondary?: boolean;
|
|
33
|
-
tertiary?: boolean;
|
|
34
|
-
outlined?: boolean;
|
|
35
|
-
text?: boolean;
|
|
36
|
-
link?: boolean;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
function resolveVariant(p: VariantBools): Variant {
|
|
40
|
-
if (p.primary) return "primary";
|
|
41
|
-
if (p.secondary) return "secondary";
|
|
42
|
-
if (p.tertiary) return "tertiary";
|
|
43
|
-
if (p.outlined) return "outlined";
|
|
44
|
-
if (p.text) return "text";
|
|
45
|
-
if (p.link) return "link";
|
|
46
|
-
return "primary";
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// ---------------- types ----------------
|
|
50
|
-
type ItemProps = {
|
|
51
|
-
systemName?: string;
|
|
52
|
-
label?: string;
|
|
53
|
-
href?: string;
|
|
54
|
-
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
55
|
-
/** Makes the item selectable (toggles active instead of closing the menu). */
|
|
56
|
-
toggle?: boolean;
|
|
57
|
-
/** Starts active. In exclusive mode only the first default wins. */
|
|
58
|
-
default?: boolean;
|
|
59
|
-
children?: React.ReactNode;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
type MenuNode = {
|
|
63
|
-
kind: "item" | "raw";
|
|
64
|
-
key: string;
|
|
65
|
-
id: string; // stable path id, used for active tracking across nesting
|
|
66
|
-
element?: React.ReactElement; // for "raw" passthrough (e.g. <Divider/>)
|
|
67
|
-
systemName?: string;
|
|
68
|
-
label?: string;
|
|
69
|
-
href?: string;
|
|
70
|
-
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
71
|
-
toggle?: boolean;
|
|
72
|
-
default?: boolean;
|
|
73
|
-
children: MenuNode[];
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// ---------------- declarative item ----------------
|
|
77
|
-
function Item(_props: ItemProps) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
Item.displayName = "Drop.Item";
|
|
81
|
-
|
|
82
|
-
function buildModel(children: React.ReactNode, prefix = ""): MenuNode[] {
|
|
83
|
-
return React.Children.toArray(children)
|
|
84
|
-
.filter((c): c is React.ReactElement => React.isValidElement(c))
|
|
85
|
-
.map((c, i) => {
|
|
86
|
-
const key = c.key != null ? String(c.key) : String(i);
|
|
87
|
-
const id = prefix ? `${prefix}/${key}` : key;
|
|
88
|
-
|
|
89
|
-
// Anything that isn't a Drop.Item (e.g. <Divider/>) renders in place.
|
|
90
|
-
if (c.type !== Item) {
|
|
91
|
-
return { kind: "raw", key, id, element: c, children: [] };
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const p = c.props as ItemProps;
|
|
95
|
-
return {
|
|
96
|
-
kind: "item",
|
|
97
|
-
key,
|
|
98
|
-
id,
|
|
99
|
-
systemName: p.systemName,
|
|
100
|
-
label: p.label,
|
|
101
|
-
href: p.href,
|
|
102
|
-
onClick: p.onClick,
|
|
103
|
-
toggle: p.toggle,
|
|
104
|
-
default: p.default,
|
|
105
|
-
children: buildModel(p.children, id),
|
|
106
|
-
};
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// ---------------- context ----------------
|
|
111
|
-
type MenuContextValue = {
|
|
112
|
-
submenuIcon: string;
|
|
113
|
-
activeIcon: string;
|
|
114
|
-
openSubmenuIndex: number | null;
|
|
115
|
-
openSubmenu: (index: number, el: HTMLElement | null) => void;
|
|
116
|
-
closeSubmenu: () => void;
|
|
117
|
-
closeAll: () => void;
|
|
118
|
-
isActive: (id: string) => boolean;
|
|
119
|
-
toggleActive: (id: string) => void;
|
|
120
|
-
};
|
|
121
|
-
const MenuContext = createContext<MenuContextValue | null>(null);
|
|
122
|
-
|
|
123
|
-
// ---------------- rows ----------------
|
|
124
|
-
function LeafRow({ node }: { node: MenuNode }) {
|
|
125
|
-
const ctx = useContext(MenuContext)!;
|
|
126
|
-
const active = !!node.toggle && ctx.isActive(node.id);
|
|
127
|
-
|
|
128
|
-
const handle = (e: React.MouseEvent<HTMLElement>) => {
|
|
129
|
-
if (node.toggle) {
|
|
130
|
-
ctx.toggleActive(node.id);
|
|
131
|
-
node.onClick?.(e);
|
|
132
|
-
return; // selection — keep the menu open
|
|
133
|
-
}
|
|
134
|
-
node.onClick?.(e);
|
|
135
|
-
ctx.closeAll();
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
// Active → swap to (or add) the check icon, and drop the no-icon indent.
|
|
139
|
-
const iconName = active ? ctx.activeIcon : node.systemName;
|
|
140
|
-
const noIcon = active ? false : !node.systemName;
|
|
141
|
-
const inner = <Icon systemName={iconName} label={node.label} />;
|
|
142
|
-
|
|
143
|
-
// Real links navigate; toggles are buttons.
|
|
144
|
-
return node.href && !node.toggle ? (
|
|
145
|
-
<a
|
|
146
|
-
className={styles.row}
|
|
147
|
-
data-noicon={noIcon || undefined}
|
|
148
|
-
data-active={active || undefined}
|
|
149
|
-
href={node.href}
|
|
150
|
-
onClick={handle}
|
|
151
|
-
>
|
|
152
|
-
{inner}
|
|
153
|
-
</a>
|
|
154
|
-
) : (
|
|
155
|
-
<button
|
|
156
|
-
type="button"
|
|
157
|
-
className={styles.row}
|
|
158
|
-
data-noicon={noIcon || undefined}
|
|
159
|
-
data-active={active || undefined}
|
|
160
|
-
aria-pressed={node.toggle ? active : undefined}
|
|
161
|
-
onClick={handle}
|
|
162
|
-
>
|
|
163
|
-
{inner}
|
|
164
|
-
</button>
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function SubmenuTriggerRow({ node, index }: { node: MenuNode; index: number }) {
|
|
169
|
-
const ctx = useContext(MenuContext)!;
|
|
170
|
-
const ref = useRef<HTMLButtonElement>(null);
|
|
171
|
-
const isOpen = ctx.openSubmenuIndex === index;
|
|
172
|
-
return (
|
|
173
|
-
<button
|
|
174
|
-
ref={ref}
|
|
175
|
-
type="button"
|
|
176
|
-
className={styles.row}
|
|
177
|
-
data-noicon={!node.systemName || undefined}
|
|
178
|
-
aria-haspopup="menu"
|
|
179
|
-
aria-expanded={isOpen}
|
|
180
|
-
onClick={() => ctx.openSubmenu(index, ref.current)}
|
|
181
|
-
>
|
|
182
|
-
<Icon systemName={node.systemName} label={node.label} />
|
|
183
|
-
<span className={styles.chev}>
|
|
184
|
-
<Icon systemName={ctx.submenuIcon} />
|
|
185
|
-
</span>
|
|
186
|
-
</button>
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Static mirror of a row, used only inside the hidden width measurer.
|
|
191
|
-
function MeasureRow({ node, chevIcon }: { node: MenuNode; chevIcon: string }) {
|
|
192
|
-
return (
|
|
193
|
-
<div className={styles.row} data-noicon={!node.systemName || undefined}>
|
|
194
|
-
<Icon systemName={node.systemName} label={node.label} />
|
|
195
|
-
{node.children.length > 0 && (
|
|
196
|
-
<span className={styles.chev}>
|
|
197
|
-
<Icon systemName={chevIcon} />
|
|
198
|
-
</span>
|
|
199
|
-
)}
|
|
200
|
-
</div>
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// ---------------- Menu ----------------
|
|
205
|
-
type DropMenuProps = {
|
|
206
|
-
systemName?: string;
|
|
207
|
-
label?: string;
|
|
208
|
-
submenuIcon?: string;
|
|
209
|
-
submenuOpenIcon?: string;
|
|
210
|
-
/** Icon shown on active/toggled items (default: check_small). */
|
|
211
|
-
activeIcon?: string;
|
|
212
|
-
/** Only one item active at a time (default true), like ButtonGroup. */
|
|
213
|
-
exclusive?: boolean;
|
|
214
|
-
/** Inverse of exclusive. If both set, this wins. */
|
|
215
|
-
multiSelect?: boolean;
|
|
216
|
-
children: React.ReactNode;
|
|
217
|
-
} & VariantBools;
|
|
218
|
-
|
|
219
|
-
function DropMenu({
|
|
220
|
-
systemName,
|
|
221
|
-
label,
|
|
222
|
-
submenuIcon = "chevron_right",
|
|
223
|
-
submenuOpenIcon = "expand_more",
|
|
224
|
-
activeIcon = "check_small",
|
|
225
|
-
exclusive = true,
|
|
226
|
-
multiSelect,
|
|
227
|
-
children,
|
|
228
|
-
...variantBools
|
|
229
|
-
}: DropMenuProps) {
|
|
230
|
-
const variant = resolveVariant(variantBools);
|
|
231
|
-
const model = buildModel(children);
|
|
232
|
-
const isExclusive = multiSelect !== undefined ? !multiSelect : exclusive;
|
|
233
|
-
|
|
234
|
-
const [open, setOpen] = useState(false);
|
|
235
|
-
const [openSubmenuIndex, setOpenSubmenuIndex] = useState<number | null>(null);
|
|
236
|
-
const [submenuTop, setSubmenuTop] = useState(0);
|
|
237
|
-
|
|
238
|
-
// ---- active / toggle state (keyed by stable id) ----
|
|
239
|
-
const [activeIds, setActiveIds] = useState<Set<string>>(() => {
|
|
240
|
-
const defaults = new Set<string>();
|
|
241
|
-
const walk = (nodes: MenuNode[]) =>
|
|
242
|
-
nodes.forEach((n) => {
|
|
243
|
-
if (n.default && !(isExclusive && defaults.size > 0))
|
|
244
|
-
defaults.add(n.id);
|
|
245
|
-
walk(n.children);
|
|
246
|
-
});
|
|
247
|
-
walk(model);
|
|
248
|
-
return defaults;
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
const isActive = (id: string) => activeIds.has(id);
|
|
252
|
-
const toggleActive = (id: string) => {
|
|
253
|
-
setActiveIds((prev) => {
|
|
254
|
-
const next = new Set(prev);
|
|
255
|
-
const was = next.has(id);
|
|
256
|
-
if (was && isExclusive) return prev; // can't unset the active one in exclusive
|
|
257
|
-
if (was) next.delete(id);
|
|
258
|
-
else {
|
|
259
|
-
if (isExclusive) next.clear();
|
|
260
|
-
next.add(id);
|
|
261
|
-
}
|
|
262
|
-
return next;
|
|
263
|
-
});
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
const rootRef = useRef<HTMLDivElement>(null);
|
|
267
|
-
|
|
268
|
-
// ---- width measurement ----
|
|
269
|
-
const closedRef = useRef<HTMLDivElement>(null); // in-flow spacer = collapsed width
|
|
270
|
-
const measureRef = useRef<HTMLDivElement>(null); // offscreen clone = expanded width
|
|
271
|
-
const [closedW, setClosedW] = useState(0);
|
|
272
|
-
const [openW, setOpenW] = useState(0);
|
|
273
|
-
|
|
274
|
-
useLayoutEffect(() => {
|
|
275
|
-
const update = () => {
|
|
276
|
-
if (closedRef.current) setClosedW(closedRef.current.offsetWidth);
|
|
277
|
-
if (measureRef.current) setOpenW(measureRef.current.offsetWidth);
|
|
278
|
-
};
|
|
279
|
-
update();
|
|
280
|
-
const ro = new ResizeObserver(update);
|
|
281
|
-
if (closedRef.current) ro.observe(closedRef.current);
|
|
282
|
-
if (measureRef.current) ro.observe(measureRef.current);
|
|
283
|
-
return () => ro.disconnect();
|
|
284
|
-
}, []);
|
|
285
|
-
|
|
286
|
-
const closeAll = () => {
|
|
287
|
-
setOpenSubmenuIndex(null);
|
|
288
|
-
setOpen(false);
|
|
289
|
-
};
|
|
290
|
-
const closeSubmenu = () => setOpenSubmenuIndex(null);
|
|
291
|
-
|
|
292
|
-
const openSubmenu = (index: number, el: HTMLElement | null) => {
|
|
293
|
-
const root = rootRef.current;
|
|
294
|
-
if (el && root) {
|
|
295
|
-
setSubmenuTop(
|
|
296
|
-
el.getBoundingClientRect().top - root.getBoundingClientRect().top,
|
|
297
|
-
);
|
|
298
|
-
}
|
|
299
|
-
setOpenSubmenuIndex(index);
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
useEffect(() => {
|
|
303
|
-
if (!open) return;
|
|
304
|
-
const onDown = (e: MouseEvent) => {
|
|
305
|
-
if (rootRef.current && !rootRef.current.contains(e.target as Node))
|
|
306
|
-
closeAll();
|
|
307
|
-
};
|
|
308
|
-
const onKey = (e: KeyboardEvent) => {
|
|
309
|
-
if (e.key !== "Escape") return;
|
|
310
|
-
if (openSubmenuIndex != null) closeSubmenu();
|
|
311
|
-
else closeAll();
|
|
312
|
-
};
|
|
313
|
-
document.addEventListener("mousedown", onDown);
|
|
314
|
-
document.addEventListener("keydown", onKey);
|
|
315
|
-
return () => {
|
|
316
|
-
document.removeEventListener("mousedown", onDown);
|
|
317
|
-
document.removeEventListener("keydown", onKey);
|
|
318
|
-
};
|
|
319
|
-
}, [open, openSubmenuIndex]);
|
|
320
|
-
|
|
321
|
-
const submenuOpen = openSubmenuIndex != null;
|
|
322
|
-
const submenuNode = submenuOpen ? model[openSubmenuIndex!] : null;
|
|
323
|
-
const targetWidth = (open ? openW : closedW) || "max-content";
|
|
324
|
-
|
|
325
|
-
const ctx: MenuContextValue = {
|
|
326
|
-
submenuIcon,
|
|
327
|
-
activeIcon,
|
|
328
|
-
openSubmenuIndex,
|
|
329
|
-
openSubmenu,
|
|
330
|
-
closeSubmenu,
|
|
331
|
-
closeAll,
|
|
332
|
-
isActive,
|
|
333
|
-
toggleActive,
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
return (
|
|
337
|
-
<MenuContext.Provider value={ctx}>
|
|
338
|
-
<div ref={rootRef} className={styles.root}>
|
|
339
|
-
{/* In-flow clone — reserves the collapsed footprint + gives the closed width. */}
|
|
340
|
-
<div
|
|
341
|
-
ref={closedRef}
|
|
342
|
-
className={[styles.pillBox, styles[variant], styles.spacer].join(" ")}
|
|
343
|
-
aria-hidden
|
|
344
|
-
>
|
|
345
|
-
<div className={styles.header}>
|
|
346
|
-
<Icon systemName={systemName} label={label} />
|
|
347
|
-
</div>
|
|
348
|
-
</div>
|
|
349
|
-
|
|
350
|
-
{/* Offscreen clone of the open card — measures the expanded width. */}
|
|
351
|
-
<div
|
|
352
|
-
ref={measureRef}
|
|
353
|
-
className={[styles.pillBox, styles.measure].join(" ")}
|
|
354
|
-
aria-hidden
|
|
355
|
-
>
|
|
356
|
-
<div className={styles.header}>
|
|
357
|
-
<Icon systemName={systemName} label={label} />
|
|
358
|
-
</div>
|
|
359
|
-
<ul className={styles.list}>
|
|
360
|
-
{model.map((node) =>
|
|
361
|
-
node.kind === "raw" ? null : (
|
|
362
|
-
<li key={node.key}>
|
|
363
|
-
<MeasureRow node={node} chevIcon={submenuIcon} />
|
|
364
|
-
</li>
|
|
365
|
-
),
|
|
366
|
-
)}
|
|
367
|
-
</ul>
|
|
368
|
-
</div>
|
|
369
|
-
|
|
370
|
-
{/* The real, absolutely-positioned dropdown: pill ⇄ card. */}
|
|
371
|
-
<motion.div
|
|
372
|
-
className={[styles.pillBox, styles[variant], styles.drop].join(" ")}
|
|
373
|
-
data-open={open}
|
|
374
|
-
animate={{
|
|
375
|
-
width: targetWidth,
|
|
376
|
-
borderRadius: open ? 30 : 84,
|
|
377
|
-
scale: submenuOpen ? 0.95 : 1,
|
|
378
|
-
pointerEvents: submenuOpen ? "none" : "auto",
|
|
379
|
-
background: submenuOpen
|
|
380
|
-
? "var(--md-sys-color-surface-container-low)"
|
|
381
|
-
: open
|
|
382
|
-
? "var(--md-sys-color-surface-container-lowest)"
|
|
383
|
-
: `var(--md-sys-color-${variant}-container)`,
|
|
384
|
-
padding: 6,
|
|
385
|
-
}}
|
|
386
|
-
whileTap={!open ? { borderRadius: 14 } : undefined}
|
|
387
|
-
transition={{
|
|
388
|
-
...MORPH,
|
|
389
|
-
borderRadius: { ...MORPH_2, delay: 0.02 },
|
|
390
|
-
}}
|
|
391
|
-
>
|
|
392
|
-
<button
|
|
393
|
-
type="button"
|
|
394
|
-
className={styles.header}
|
|
395
|
-
style={{
|
|
396
|
-
scale: open ? 0.8 : 1,
|
|
397
|
-
transformOrigin: "left",
|
|
398
|
-
transform: open ? "translateX(-20px)" : "translateX(0px)",
|
|
399
|
-
|
|
400
|
-
transition:
|
|
401
|
-
"scale var(--transition-expressive-color), transform var(--transition-expressive-color)",
|
|
402
|
-
}}
|
|
403
|
-
aria-haspopup="menu"
|
|
404
|
-
aria-expanded={open}
|
|
405
|
-
onClick={() => (open ? closeAll() : setOpen(true))}
|
|
406
|
-
>
|
|
407
|
-
<Icon
|
|
408
|
-
systemName={systemName}
|
|
409
|
-
iconStyle={{
|
|
410
|
-
opacity: open ? 0 : 1,
|
|
411
|
-
transition: "opacity var(--transition-expressive-color)",
|
|
412
|
-
}}
|
|
413
|
-
label={label}
|
|
414
|
-
/>
|
|
415
|
-
</button>
|
|
416
|
-
|
|
417
|
-
<AnimatePresence initial={false}>
|
|
418
|
-
{open && (
|
|
419
|
-
<motion.ul
|
|
420
|
-
className={styles.list}
|
|
421
|
-
style={{ gap: multiSelect || exclusive ? 6 : 0 }}
|
|
422
|
-
initial={{ height: 0, opacity: 0 }}
|
|
423
|
-
animate={{ height: "auto", opacity: submenuOpen ? 0.5 : 1 }}
|
|
424
|
-
exit={{ height: 0, opacity: 0 }}
|
|
425
|
-
transition={{
|
|
426
|
-
...MORPH,
|
|
427
|
-
width: { ...MORPH, delay: 0.8 },
|
|
428
|
-
opacity: { ease: easeInOut, duration: 0.2 },
|
|
429
|
-
}}
|
|
430
|
-
>
|
|
431
|
-
{model.map((node, i) =>
|
|
432
|
-
node.kind === "raw" ? (
|
|
433
|
-
<li
|
|
434
|
-
key={node.key}
|
|
435
|
-
className={styles.dividerRow}
|
|
436
|
-
aria-hidden
|
|
437
|
-
>
|
|
438
|
-
{node.element}
|
|
439
|
-
</li>
|
|
440
|
-
) : node.children.length > 0 ? (
|
|
441
|
-
<li key={node.key}>
|
|
442
|
-
<SubmenuTriggerRow node={node} index={i} />
|
|
443
|
-
</li>
|
|
444
|
-
) : (
|
|
445
|
-
<li key={node.key}>
|
|
446
|
-
<LeafRow node={node} />
|
|
447
|
-
</li>
|
|
448
|
-
),
|
|
449
|
-
)}
|
|
450
|
-
</motion.ul>
|
|
451
|
-
)}
|
|
452
|
-
</AnimatePresence>
|
|
453
|
-
</motion.div>
|
|
454
|
-
|
|
455
|
-
{/* Submenu layer — pops from the trigger row, above the dimmed menu. */}
|
|
456
|
-
<AnimatePresence>
|
|
457
|
-
{submenuNode && (
|
|
458
|
-
<motion.div
|
|
459
|
-
className={`${styles.submenuCard} ${openSubmenuIndex != null ? styles.subMenuOpen : ""}`}
|
|
460
|
-
style={{ top: submenuTop }}
|
|
461
|
-
initial={{ opacity: 0, scale: 1, height: 62, marginTop: "-13px" }}
|
|
462
|
-
animate={{
|
|
463
|
-
opacity: 1,
|
|
464
|
-
scale: 1,
|
|
465
|
-
height: "fit-content",
|
|
466
|
-
marginTop: "-7px",
|
|
467
|
-
}}
|
|
468
|
-
exit={{ opacity: 0, scale: 1, height: 62, marginTop: "-13px" }}
|
|
469
|
-
transition={{
|
|
470
|
-
...MORPH,
|
|
471
|
-
height: { ...MORPH },
|
|
472
|
-
}}
|
|
473
|
-
>
|
|
474
|
-
<button
|
|
475
|
-
type="button"
|
|
476
|
-
className={styles.row}
|
|
477
|
-
data-noicon={!submenuNode.systemName || undefined}
|
|
478
|
-
aria-expanded
|
|
479
|
-
onClick={closeSubmenu}
|
|
480
|
-
>
|
|
481
|
-
<Icon
|
|
482
|
-
systemName={submenuNode.systemName}
|
|
483
|
-
label={submenuNode.label}
|
|
484
|
-
/>
|
|
485
|
-
<span className={styles.chev}>
|
|
486
|
-
<Icon systemName={submenuOpenIcon} />
|
|
487
|
-
</span>
|
|
488
|
-
</button>
|
|
489
|
-
<ul className={styles.submenuList}>
|
|
490
|
-
{submenuNode.children.map((child) =>
|
|
491
|
-
child.kind === "raw" ? (
|
|
492
|
-
<li
|
|
493
|
-
key={child.key}
|
|
494
|
-
className={styles.dividerRow}
|
|
495
|
-
aria-hidden
|
|
496
|
-
>
|
|
497
|
-
{child.element}
|
|
498
|
-
</li>
|
|
499
|
-
) : (
|
|
500
|
-
<li key={child.key}>
|
|
501
|
-
<LeafRow node={child} />
|
|
502
|
-
</li>
|
|
503
|
-
),
|
|
504
|
-
)}
|
|
505
|
-
</ul>
|
|
506
|
-
</motion.div>
|
|
507
|
-
)}
|
|
508
|
-
</AnimatePresence>
|
|
509
|
-
</div>
|
|
510
|
-
</MenuContext.Provider>
|
|
511
|
-
);
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
// ---------------- namespace export ----------------
|
|
515
|
-
const Drop = { Menu: DropMenu, Item };
|
|
516
|
-
export default Drop;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
.heroWrap {
|
|
2
|
-
position: relative;
|
|
3
|
-
width: 100%;
|
|
4
|
-
height: 83dvh;
|
|
5
|
-
overflow: hidden;
|
|
6
|
-
border: 1px solid var(--globalUIBorderCard);
|
|
7
|
-
border-radius: 36px;
|
|
8
|
-
overflow: hidden;
|
|
9
|
-
isolation: isolate;
|
|
10
|
-
will-change: transform;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.slideshow {
|
|
14
|
-
position: absolute;
|
|
15
|
-
inset: 0;
|
|
16
|
-
width: 100%;
|
|
17
|
-
height: 100%;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.gradient {
|
|
21
|
-
position: absolute;
|
|
22
|
-
inset: 0;
|
|
23
|
-
pointer-events: none;
|
|
24
|
-
z-index: 1;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.contentCTA {
|
|
28
|
-
position: absolute;
|
|
29
|
-
bottom: 56px;
|
|
30
|
-
left: 32px;
|
|
31
|
-
z-index: 2;
|
|
32
|
-
display: flex;
|
|
33
|
-
flex-direction: column;
|
|
34
|
-
gap: 12px;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.ctaTitle {
|
|
38
|
-
margin: 0;
|
|
39
|
-
text-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.ctaText {
|
|
43
|
-
margin: 0;
|
|
44
|
-
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.indicators {
|
|
48
|
-
position: absolute;
|
|
49
|
-
bottom: 16px;
|
|
50
|
-
left: 50%;
|
|
51
|
-
translate: -50% 0;
|
|
52
|
-
display: flex;
|
|
53
|
-
cursor: pointer;
|
|
54
|
-
align-items: center;
|
|
55
|
-
gap: 8px;
|
|
56
|
-
z-index: 20;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.dot {
|
|
60
|
-
width: 6px;
|
|
61
|
-
height: 6px;
|
|
62
|
-
border-radius: 12px;
|
|
63
|
-
background: rgba(255, 255, 255, 0.243);
|
|
64
|
-
cursor: pointer;
|
|
65
|
-
padding: 0;
|
|
66
|
-
transition:
|
|
67
|
-
background 0.3s ease,
|
|
68
|
-
width var(--transition-expressive);
|
|
69
|
-
}
|
|
70
|
-
.dot:hover {
|
|
71
|
-
width: 12px;
|
|
72
|
-
background-color: white;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.dotActive {
|
|
76
|
-
background: white;
|
|
77
|
-
width: 24px;
|
|
78
|
-
}
|
|
79
|
-
.dotActive:hover {
|
|
80
|
-
width: 28px;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.arrowBtn {
|
|
84
|
-
display: flex;
|
|
85
|
-
align-items: center;
|
|
86
|
-
justify-content: center;
|
|
87
|
-
background: none;
|
|
88
|
-
border: none;
|
|
89
|
-
padding: 0;
|
|
90
|
-
cursor: pointer;
|
|
91
|
-
opacity: 0.6;
|
|
92
|
-
transition: opacity 0.2s ease;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.arrowBtn:hover {
|
|
96
|
-
opacity: 1;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
@media screen and (max-width: 812px) {
|
|
100
|
-
.heroWrap {
|
|
101
|
-
height: 64vh;
|
|
102
|
-
border-radius: 36px;
|
|
103
|
-
}
|
|
104
|
-
.arrowBtn {
|
|
105
|
-
display: none;
|
|
106
|
-
}
|
|
107
|
-
}
|