@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
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { createContext, useContext, useMemo } from "react";
|
|
3
|
+
import Shape from "@/components/tools/shape/Shape";
|
|
4
|
+
import type { ShapeInput } from "@/components/tools/shape/ShapePaths";
|
|
5
|
+
import Switch, {
|
|
6
|
+
type SwitchVariant,
|
|
7
|
+
} from "@/components/(controls)/switch/Switch";
|
|
8
|
+
import styles from "./List.module.css";
|
|
9
|
+
|
|
10
|
+
export type ListGroupVariant =
|
|
11
|
+
| "default"
|
|
12
|
+
| "lowest"
|
|
13
|
+
| "low"
|
|
14
|
+
| "high"
|
|
15
|
+
| "highest"
|
|
16
|
+
| "primary"
|
|
17
|
+
| "secondary"
|
|
18
|
+
| "tertiary";
|
|
19
|
+
|
|
20
|
+
// withIcon's own variant — a subset of ListGroupVariant restricted to what
|
|
21
|
+
// actually makes sense on an icon badge (no elevation tones).
|
|
22
|
+
export type ListItemVariant = "default" | "primary" | "secondary" | "tertiary";
|
|
23
|
+
|
|
24
|
+
const COLOR_ROLE_VARIANTS = new Set<ListGroupVariant>([
|
|
25
|
+
"primary",
|
|
26
|
+
"secondary",
|
|
27
|
+
"tertiary",
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
function isColorRole(variant: ListGroupVariant): variant is SwitchVariant {
|
|
31
|
+
return COLOR_ROLE_VARIANTS.has(variant);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Default (non-color-role) icon badge colors — same as Card's own default.
|
|
35
|
+
const DEFAULT_ICON_BG = "var(--globalUIBorderCard)";
|
|
36
|
+
const DEFAULT_ICON_FG = "var(--md-sys-color-on-surface)";
|
|
37
|
+
const DEFAULT_TOGGLE_VARIANT: SwitchVariant = "primary";
|
|
38
|
+
|
|
39
|
+
function listItemColors(variant: ListItemVariant) {
|
|
40
|
+
if (variant === "default") {
|
|
41
|
+
return { bg: DEFAULT_ICON_BG, fg: DEFAULT_ICON_FG };
|
|
42
|
+
}
|
|
43
|
+
// Bold/plain pair, not -container — the group's own background is the
|
|
44
|
+
// container tone, so the icon badge needs the bolder tone to read against
|
|
45
|
+
// it instead of blending in.
|
|
46
|
+
return {
|
|
47
|
+
bg: `var(--md-sys-color-${variant})`,
|
|
48
|
+
fg: `var(--md-sys-color-on-${variant})`,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
// Group context — rows read this to know:
|
|
54
|
+
// - forcedVariant: set only when the group itself is a color role
|
|
55
|
+
// (primary/secondary/tertiary). Forces icon/toggle/title/description
|
|
56
|
+
// colors on every row inside, regardless of the row's own props.
|
|
57
|
+
// - groupVariant: the group's full variant (including neutral surface
|
|
58
|
+
// tones like default/lowest/low/high/highest), used purely to compute
|
|
59
|
+
// each row's own background so background paints per-row while the
|
|
60
|
+
// variant prop still lives on List.Group.
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
interface ListGroupContextValue {
|
|
63
|
+
forcedVariant: SwitchVariant | null;
|
|
64
|
+
groupVariant: ListGroupVariant;
|
|
65
|
+
}
|
|
66
|
+
const ListGroupContext = createContext<ListGroupContextValue>({
|
|
67
|
+
forcedVariant: null,
|
|
68
|
+
groupVariant: "default",
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
// List — pure styling wrapper around one or more List.Group sections.
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
type ListProps = {
|
|
75
|
+
style?: React.CSSProperties;
|
|
76
|
+
children?: React.ReactNode;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
function List({ style, children }: ListProps) {
|
|
80
|
+
return (
|
|
81
|
+
<div
|
|
82
|
+
style={{
|
|
83
|
+
display: "flex",
|
|
84
|
+
flexDirection: "column",
|
|
85
|
+
width: "100%",
|
|
86
|
+
gap: 24,
|
|
87
|
+
...style,
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
{children}
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
// List.Group — owns the variant; rows read it from context to compute their
|
|
97
|
+
// own background. A color-role variant (primary/secondary/tertiary) forces
|
|
98
|
+
// every row inside it — withIcon, toggle, title, and description colors all
|
|
99
|
+
// follow the group, regardless of what the row itself specifies. A neutral
|
|
100
|
+
// surface tone (default/lowest/low/high/highest) doesn't force row content
|
|
101
|
+
// colors, but still drives each row's background via groupVariant.
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
type ListGroupProps = {
|
|
104
|
+
variant?: ListGroupVariant;
|
|
105
|
+
title?: string;
|
|
106
|
+
comment?: string;
|
|
107
|
+
style?: React.CSSProperties;
|
|
108
|
+
children?: React.ReactNode;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
function ListGroup({
|
|
112
|
+
variant = "default",
|
|
113
|
+
title,
|
|
114
|
+
comment,
|
|
115
|
+
style,
|
|
116
|
+
children,
|
|
117
|
+
}: ListGroupProps) {
|
|
118
|
+
const forcedVariant = isColorRole(variant) ? variant : null;
|
|
119
|
+
|
|
120
|
+
const contextValue = useMemo<ListGroupContextValue>(
|
|
121
|
+
() => ({ forcedVariant, groupVariant: variant }),
|
|
122
|
+
[forcedVariant, variant],
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<div style={{ display: "flex", flexDirection: "column", width: "100%" }}>
|
|
127
|
+
{title && (
|
|
128
|
+
<p
|
|
129
|
+
style={{
|
|
130
|
+
fontWeight: 500,
|
|
131
|
+
padding: "0 0 8px 20px",
|
|
132
|
+
color: "var(--md-sys-color-outline)",
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
{title}
|
|
136
|
+
</p>
|
|
137
|
+
)}
|
|
138
|
+
<ul className={styles.list}>
|
|
139
|
+
<ListGroupContext.Provider value={contextValue}>
|
|
140
|
+
{children}
|
|
141
|
+
</ListGroupContext.Provider>
|
|
142
|
+
</ul>
|
|
143
|
+
{comment && (
|
|
144
|
+
<p
|
|
145
|
+
style={{
|
|
146
|
+
fontSize: 14,
|
|
147
|
+
color: "var(--md-sys-color-outline)",
|
|
148
|
+
padding: "8px 20px 0",
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
{comment}
|
|
152
|
+
</p>
|
|
153
|
+
)}
|
|
154
|
+
</div>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// ---------------------------------------------------------------------------
|
|
159
|
+
// List.Row
|
|
160
|
+
// ---------------------------------------------------------------------------
|
|
161
|
+
type ListRowIcon = {
|
|
162
|
+
systemName: string;
|
|
163
|
+
shapePath: ShapeInput;
|
|
164
|
+
variant?: ListItemVariant;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
type ListRowToggle = {
|
|
168
|
+
checked: boolean;
|
|
169
|
+
onToggleOn?: () => void;
|
|
170
|
+
onToggleOff?: () => void;
|
|
171
|
+
variant?: SwitchVariant;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
type ListRowProps = {
|
|
175
|
+
title: string;
|
|
176
|
+
description?: string;
|
|
177
|
+
onClick?: () => void;
|
|
178
|
+
withIcon?: ListRowIcon;
|
|
179
|
+
toggle?: ListRowToggle;
|
|
180
|
+
style?: React.CSSProperties;
|
|
181
|
+
children?: React.ReactNode;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
function ListRow({
|
|
185
|
+
title,
|
|
186
|
+
description,
|
|
187
|
+
onClick,
|
|
188
|
+
withIcon,
|
|
189
|
+
children,
|
|
190
|
+
toggle,
|
|
191
|
+
style,
|
|
192
|
+
}: ListRowProps) {
|
|
193
|
+
const { forcedVariant, groupVariant } = useContext(ListGroupContext);
|
|
194
|
+
|
|
195
|
+
// The group's own color role always wins over whatever the row specifies.
|
|
196
|
+
const effectiveIconVariant: ListItemVariant =
|
|
197
|
+
forcedVariant ?? withIcon?.variant ?? "default";
|
|
198
|
+
const effectiveToggleVariant: SwitchVariant =
|
|
199
|
+
forcedVariant ?? toggle?.variant ?? DEFAULT_TOGGLE_VARIANT;
|
|
200
|
+
|
|
201
|
+
const iconColors = listItemColors(effectiveIconVariant);
|
|
202
|
+
|
|
203
|
+
const titleColor = forcedVariant
|
|
204
|
+
? `var(--md-sys-color-on-${forcedVariant}-container)`
|
|
205
|
+
: "var(--md-sys-color-on-surface)";
|
|
206
|
+
const descriptionColor = forcedVariant
|
|
207
|
+
? `color-mix(in srgb, var(--md-sys-color-on-${forcedVariant}-container) 75%, transparent)`
|
|
208
|
+
: "var(--md-sys-color-on-surface-variant)";
|
|
209
|
+
|
|
210
|
+
// toggle present + no onClick → clicking the row body toggles directly.
|
|
211
|
+
// toggle present + onClick → row click fires onClick only; the switch
|
|
212
|
+
// control's own click (stopPropagation'd below) fires onToggleOn/Off
|
|
213
|
+
// independently, so the two never both fire from one gesture.
|
|
214
|
+
const handleRowActivate = () => {
|
|
215
|
+
if (onClick) {
|
|
216
|
+
onClick();
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (toggle) {
|
|
220
|
+
if (toggle.checked) toggle.onToggleOff?.();
|
|
221
|
+
else toggle.onToggleOn?.();
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const isClickable = !!onClick || !!toggle;
|
|
226
|
+
|
|
227
|
+
// Background is computed per-row from the group's variant (via context),
|
|
228
|
+
// not from a local prop — List.Group still owns `variant`, rows just
|
|
229
|
+
// read it to paint themselves individually.
|
|
230
|
+
const background = forcedVariant
|
|
231
|
+
? `var(--md-sys-color-${forcedVariant}-container)`
|
|
232
|
+
: groupVariant === "default"
|
|
233
|
+
? "var(--md-sys-color-surface-container)"
|
|
234
|
+
: `var(--md-sys-color-surface-container-${groupVariant})`;
|
|
235
|
+
|
|
236
|
+
return (
|
|
237
|
+
<>
|
|
238
|
+
<li
|
|
239
|
+
className={styles.wrapper}
|
|
240
|
+
data-clickable={isClickable || undefined}
|
|
241
|
+
role={isClickable ? "button" : undefined}
|
|
242
|
+
tabIndex={isClickable ? 0 : undefined}
|
|
243
|
+
onClick={isClickable ? handleRowActivate : undefined}
|
|
244
|
+
onKeyDown={
|
|
245
|
+
isClickable
|
|
246
|
+
? (e) => {
|
|
247
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
248
|
+
e.preventDefault();
|
|
249
|
+
handleRowActivate();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
: undefined
|
|
253
|
+
}
|
|
254
|
+
style={{ backgroundColor: background, ...style }}
|
|
255
|
+
>
|
|
256
|
+
<div className={styles.row}>
|
|
257
|
+
{withIcon && (
|
|
258
|
+
<Shape
|
|
259
|
+
systemName={withIcon.systemName}
|
|
260
|
+
shapePath={withIcon.shapePath}
|
|
261
|
+
size="xs"
|
|
262
|
+
background={iconColors.bg}
|
|
263
|
+
color={iconColors.fg}
|
|
264
|
+
interactive={false}
|
|
265
|
+
/>
|
|
266
|
+
)}
|
|
267
|
+
<div className={withIcon ? styles.rowTextWithIcon : styles.rowText}>
|
|
268
|
+
<span className={styles.rowTitle} style={{ color: titleColor }}>
|
|
269
|
+
{title}
|
|
270
|
+
</span>
|
|
271
|
+
{description && (
|
|
272
|
+
<span
|
|
273
|
+
className={styles.rowDescription}
|
|
274
|
+
style={{ color: descriptionColor }}
|
|
275
|
+
>
|
|
276
|
+
{description}
|
|
277
|
+
</span>
|
|
278
|
+
)}
|
|
279
|
+
</div>
|
|
280
|
+
{toggle && (
|
|
281
|
+
// Switch is its own fully-independent interactive control (real
|
|
282
|
+
// native checkbox) — stopping propagation here is what keeps it
|
|
283
|
+
// decoupled from the row's own onClick once one is passed, and
|
|
284
|
+
// prevents a double-toggle when one isn't.
|
|
285
|
+
<span style={{ height: 28 }} onClick={(e) => e.stopPropagation()}>
|
|
286
|
+
<Switch
|
|
287
|
+
checked={toggle.checked}
|
|
288
|
+
onToggleOn={toggle.onToggleOn}
|
|
289
|
+
onToggleOff={toggle.onToggleOff}
|
|
290
|
+
variant={effectiveToggleVariant}
|
|
291
|
+
/>
|
|
292
|
+
</span>
|
|
293
|
+
)}
|
|
294
|
+
</div>
|
|
295
|
+
{children && <div className={styles.children}>{children}</div>}
|
|
296
|
+
</li>
|
|
297
|
+
</>
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export default Object.assign(List, {
|
|
302
|
+
Group: ListGroup,
|
|
303
|
+
Row: ListRow,
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
/* Example usage:
|
|
307
|
+
|
|
308
|
+
<List>
|
|
309
|
+
<List.Group title="Vision" variant="default">
|
|
310
|
+
<List.Row
|
|
311
|
+
title="Increase contrast"
|
|
312
|
+
toggle={{ checked: contrast, onToggleOn: () => setContrast(true), onToggleOff: () => setContrast(false) }}
|
|
313
|
+
/>
|
|
314
|
+
<List.Row
|
|
315
|
+
title="Accessibility"
|
|
316
|
+
description="Open accessibility settings"
|
|
317
|
+
withIcon={{ systemName: "accessibility_new", shapePath: "gem" }}
|
|
318
|
+
onClick={() => openSettings()}
|
|
319
|
+
/>
|
|
320
|
+
</List.Group>
|
|
321
|
+
|
|
322
|
+
<List.Group variant="tertiary" comment="Applies to all sources.">
|
|
323
|
+
<List.Row
|
|
324
|
+
title="Test row"
|
|
325
|
+
description="testRow"
|
|
326
|
+
withIcon={{ systemName: "star", shapePath: "sunny" }}
|
|
327
|
+
toggle={{ checked, onToggleOn, onToggleOff }}
|
|
328
|
+
/>
|
|
329
|
+
</List.Group>
|
|
330
|
+
</List>
|
|
331
|
+
|
|
332
|
+
*/
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
type WrapProps = {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
min?: string;
|
|
6
|
-
gap?: string;
|
|
7
|
-
style?: React.CSSProperties;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export function Wrap({
|
|
11
|
-
children,
|
|
12
|
-
min = "314px",
|
|
13
|
-
gap = "12px",
|
|
14
|
-
style,
|
|
15
|
-
}: WrapProps) {
|
|
16
|
-
return (
|
|
17
|
-
<div
|
|
18
|
-
style={{
|
|
19
|
-
display: "flex",
|
|
20
|
-
flexDirection: "row",
|
|
21
|
-
flexWrap: "wrap",
|
|
22
|
-
alignItems: "stretch",
|
|
23
|
-
gap,
|
|
24
|
-
width: "100%",
|
|
25
|
-
...style,
|
|
26
|
-
}}
|
|
27
|
-
>
|
|
28
|
-
{React.Children.map(children, (child) => {
|
|
29
|
-
if (!React.isValidElement(child)) return child;
|
|
30
|
-
const el = child as React.ReactElement<{ style?: React.CSSProperties }>;
|
|
31
|
-
return React.cloneElement(el, {
|
|
32
|
-
style: {
|
|
33
|
-
...(el.props.style ?? {}),
|
|
34
|
-
flex: `1 1 ${min}`,
|
|
35
|
-
alignSelf: "stretch",
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
})}
|
|
39
|
-
</div>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
type WrapProps = {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
min?: string;
|
|
6
|
+
gap?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function Wrap({
|
|
11
|
+
children,
|
|
12
|
+
min = "314px",
|
|
13
|
+
gap = "12px",
|
|
14
|
+
style,
|
|
15
|
+
}: WrapProps) {
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
style={{
|
|
19
|
+
display: "flex",
|
|
20
|
+
flexDirection: "row",
|
|
21
|
+
flexWrap: "wrap",
|
|
22
|
+
alignItems: "stretch",
|
|
23
|
+
gap,
|
|
24
|
+
width: "100%",
|
|
25
|
+
...style,
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
{React.Children.map(children, (child) => {
|
|
29
|
+
if (!React.isValidElement(child)) return child;
|
|
30
|
+
const el = child as React.ReactElement<{ style?: React.CSSProperties }>;
|
|
31
|
+
return React.cloneElement(el, {
|
|
32
|
+
style: {
|
|
33
|
+
...(el.props.style ?? {}),
|
|
34
|
+
flex: `1 1 ${min}`,
|
|
35
|
+
alignSelf: "stretch",
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
})}
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import Icon from "@/components/tools/label/Icon";
|
|
4
|
+
|
|
5
|
+
export interface BreadcrumbsProps {
|
|
6
|
+
/** Custom separator between items. @default a chevron_right Icon */
|
|
7
|
+
separator?: React.ReactNode;
|
|
8
|
+
isDisabled?: boolean;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const defaultSeparator = (
|
|
15
|
+
<Icon
|
|
16
|
+
systemName="chevron_right"
|
|
17
|
+
style={{ fontSize: 24, color: "var(--md-sys-color-secondary)" }}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
function Breadcrumbs({
|
|
22
|
+
separator = defaultSeparator,
|
|
23
|
+
isDisabled = false,
|
|
24
|
+
children,
|
|
25
|
+
style,
|
|
26
|
+
className,
|
|
27
|
+
}: BreadcrumbsProps) {
|
|
28
|
+
const items = React.Children.toArray(children).filter(
|
|
29
|
+
(child): child is React.ReactElement<BreadcrumbItemProps> =>
|
|
30
|
+
React.isValidElement(child),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<nav aria-label="Breadcrumb" className={className} style={style}>
|
|
35
|
+
<ol
|
|
36
|
+
style={{
|
|
37
|
+
display: "flex",
|
|
38
|
+
flexWrap: "wrap",
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
gap: 8,
|
|
41
|
+
margin: 0,
|
|
42
|
+
padding: 0,
|
|
43
|
+
listStyle: "none",
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
{items.map((item, index) => {
|
|
47
|
+
const isLast = index === items.length - 1;
|
|
48
|
+
return (
|
|
49
|
+
<React.Fragment key={index}>
|
|
50
|
+
<li style={{ display: "flex", alignItems: "center", gap: 8 }}>
|
|
51
|
+
{React.cloneElement(item, {
|
|
52
|
+
isCurrent: isLast && !item.props.href,
|
|
53
|
+
isDisabled: isDisabled || item.props.isDisabled,
|
|
54
|
+
})}
|
|
55
|
+
</li>
|
|
56
|
+
{!isLast && (
|
|
57
|
+
<li
|
|
58
|
+
aria-hidden
|
|
59
|
+
style={{
|
|
60
|
+
display: "flex",
|
|
61
|
+
alignItems: "center",
|
|
62
|
+
color: "var(--md-sys-color-on-surface-variant)",
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
{separator}
|
|
66
|
+
</li>
|
|
67
|
+
)}
|
|
68
|
+
</React.Fragment>
|
|
69
|
+
);
|
|
70
|
+
})}
|
|
71
|
+
</ol>
|
|
72
|
+
</nav>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface BreadcrumbItemProps {
|
|
77
|
+
href?: string;
|
|
78
|
+
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
79
|
+
isDisabled?: boolean;
|
|
80
|
+
// Set internally by Breadcrumbs (last item with no href) — not meant to
|
|
81
|
+
// be passed directly, but not blocked either, since a consumer might
|
|
82
|
+
// reasonably want to force it for an item that does have an href.
|
|
83
|
+
isCurrent?: boolean;
|
|
84
|
+
children?: React.ReactNode;
|
|
85
|
+
className?: string;
|
|
86
|
+
style?: React.CSSProperties;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function BreadcrumbsItem({
|
|
90
|
+
href,
|
|
91
|
+
onClick,
|
|
92
|
+
isDisabled = false,
|
|
93
|
+
isCurrent = false,
|
|
94
|
+
children,
|
|
95
|
+
className,
|
|
96
|
+
style,
|
|
97
|
+
}: BreadcrumbItemProps) {
|
|
98
|
+
const baseStyle: React.CSSProperties = {
|
|
99
|
+
fontSize: 14,
|
|
100
|
+
textDecoration: "none",
|
|
101
|
+
color: isCurrent
|
|
102
|
+
? "var(--md-sys-color-on-surface)"
|
|
103
|
+
: "var(--md-sys-color-secondary)",
|
|
104
|
+
fontWeight: isCurrent ? 500 : 400,
|
|
105
|
+
opacity: isDisabled ? 0.5 : 1,
|
|
106
|
+
marginBottom: 2,
|
|
107
|
+
pointerEvents: isDisabled ? "none" : undefined,
|
|
108
|
+
...style,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
if (isCurrent || (!href && !onClick)) {
|
|
112
|
+
return (
|
|
113
|
+
<span
|
|
114
|
+
aria-current={isCurrent ? "page" : undefined}
|
|
115
|
+
className={className}
|
|
116
|
+
style={baseStyle}
|
|
117
|
+
>
|
|
118
|
+
{children}
|
|
119
|
+
</span>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<a
|
|
125
|
+
href={href}
|
|
126
|
+
onClick={(e) => {
|
|
127
|
+
if (isDisabled) {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
onClick?.(e);
|
|
132
|
+
}}
|
|
133
|
+
aria-disabled={isDisabled || undefined}
|
|
134
|
+
className={className}
|
|
135
|
+
style={{
|
|
136
|
+
...baseStyle,
|
|
137
|
+
cursor: isDisabled ? "default" : "pointer",
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
{children}
|
|
141
|
+
</a>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export default Object.assign(Breadcrumbs, { Item: BreadcrumbsItem });
|