@endfield-ui/react 0.0.0-stage → 0.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 +21 -0
- package/NOTICE.md +27 -0
- package/README.md +768 -2
- package/dist/index.d.ts +3243 -0
- package/dist/index.js +8182 -0
- package/dist/styles.css +2 -0
- package/package.json +83 -3
- package/src/components/README.md +172 -0
- package/src/components/accordion/Accordion.tsx +168 -0
- package/src/components/accordion/index.ts +8 -0
- package/src/components/alert/Alert.tsx +106 -0
- package/src/components/alert/index.ts +1 -0
- package/src/components/avatar/Avatar.tsx +89 -0
- package/src/components/avatar/AvatarSwitcher.tsx +261 -0
- package/src/components/avatar/index.ts +8 -0
- package/src/components/back-to-top/BackToTop.tsx +124 -0
- package/src/components/back-to-top/index.ts +5 -0
- package/src/components/badge/Badge.tsx +75 -0
- package/src/components/badge/index.ts +1 -0
- package/src/components/bracket-title/BracketTitle.tsx +40 -0
- package/src/components/bracket-title/index.ts +1 -0
- package/src/components/breadcrumb/Breadcrumb.tsx +161 -0
- package/src/components/breadcrumb/index.ts +6 -0
- package/src/components/button/Button.tsx +357 -0
- package/src/components/button/ButtonGroup.tsx +55 -0
- package/src/components/button/index.ts +13 -0
- package/src/components/calendar/Calendar.tsx +443 -0
- package/src/components/calendar/index.ts +7 -0
- package/src/components/carousel/Carousel.tsx +292 -0
- package/src/components/carousel/index.ts +7 -0
- package/src/components/checkbox/Checkbox.tsx +94 -0
- package/src/components/checkbox/choice-style.ts +30 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/chip/FilterChip.tsx +68 -0
- package/src/components/chip/ResourceChip.tsx +63 -0
- package/src/components/chip/capsule-style.ts +22 -0
- package/src/components/chip/index.ts +6 -0
- package/src/components/combobox/Combobox.tsx +450 -0
- package/src/components/combobox/index.ts +10 -0
- package/src/components/completion-banner/CompletionBanner.tsx +72 -0
- package/src/components/completion-banner/index.ts +4 -0
- package/src/components/context-menu/ContextMenu.tsx +70 -0
- package/src/components/context-menu/index.ts +5 -0
- package/src/components/corner-brackets/CornerBrackets.tsx +43 -0
- package/src/components/corner-brackets/index.ts +5 -0
- package/src/components/countdown/Countdown.tsx +145 -0
- package/src/components/countdown/index.ts +6 -0
- package/src/components/dash-indicator/DashIndicator.tsx +44 -0
- package/src/components/dash-indicator/index.ts +1 -0
- package/src/components/data-row/DataRow.tsx +282 -0
- package/src/components/data-row/index.ts +8 -0
- package/src/components/date-picker/DateField.tsx +159 -0
- package/src/components/date-picker/DatePicker.tsx +182 -0
- package/src/components/date-picker/DateRangePicker.tsx +203 -0
- package/src/components/date-picker/index.ts +7 -0
- package/src/components/dialog/Dialog.tsx +203 -0
- package/src/components/dialog/index.ts +7 -0
- package/src/components/dialog/initial-focus.ts +19 -0
- package/src/components/dialog/overlay-style.ts +28 -0
- package/src/components/drawer/Drawer.tsx +213 -0
- package/src/components/drawer/index.ts +6 -0
- package/src/components/dropdown-menu/DropdownMenu.tsx +427 -0
- package/src/components/dropdown-menu/MenuCheck.tsx +44 -0
- package/src/components/dropdown-menu/index.ts +22 -0
- package/src/components/dropdown-menu/menu-style.ts +47 -0
- package/src/components/empty-state/EmptyState.tsx +79 -0
- package/src/components/empty-state/index.ts +1 -0
- package/src/components/field/Field.tsx +203 -0
- package/src/components/field/index.ts +6 -0
- package/src/components/file-upload/FileItem.tsx +201 -0
- package/src/components/file-upload/FileUpload.tsx +425 -0
- package/src/components/file-upload/index.ts +9 -0
- package/src/components/flyout-bar/FlyoutBar.tsx +158 -0
- package/src/components/flyout-bar/index.ts +7 -0
- package/src/components/ghost-text/GhostText.tsx +47 -0
- package/src/components/ghost-text/index.ts +5 -0
- package/src/components/hatch/Hatch.tsx +35 -0
- package/src/components/hatch/index.ts +1 -0
- package/src/components/hazard-stripe/HazardStripe.tsx +35 -0
- package/src/components/hazard-stripe/index.ts +5 -0
- package/src/components/icon-button/IconButton.tsx +95 -0
- package/src/components/icon-button/index.ts +6 -0
- package/src/components/input/Input.tsx +109 -0
- package/src/components/input/control-box.ts +71 -0
- package/src/components/input/index.ts +6 -0
- package/src/components/input/value-chip.ts +34 -0
- package/src/components/item-slot/ItemGrid.tsx +207 -0
- package/src/components/item-slot/ItemSlot.tsx +283 -0
- package/src/components/item-slot/index.ts +7 -0
- package/src/components/kbd/Kbd.tsx +33 -0
- package/src/components/kbd/index.ts +1 -0
- package/src/components/link-element/LinkElement.tsx +25 -0
- package/src/components/list/List.tsx +229 -0
- package/src/components/list/band-style.ts +18 -0
- package/src/components/list/index.ts +8 -0
- package/src/components/loader/Loader.tsx +154 -0
- package/src/components/loader/index.ts +1 -0
- package/src/components/marquee/Marquee.tsx +96 -0
- package/src/components/marquee/index.ts +1 -0
- package/src/components/media-card/MediaCard.tsx +139 -0
- package/src/components/media-card/index.ts +5 -0
- package/src/components/nav-action/NavAction.tsx +142 -0
- package/src/components/nav-action/index.ts +5 -0
- package/src/components/nav-menu/NavMenu.tsx +288 -0
- package/src/components/nav-menu/index.ts +6 -0
- package/src/components/navigator/Navigator.tsx +136 -0
- package/src/components/navigator/index.ts +5 -0
- package/src/components/pagination/Pagination.tsx +181 -0
- package/src/components/pagination/index.ts +5 -0
- package/src/components/panel/Panel.tsx +114 -0
- package/src/components/panel/index.ts +13 -0
- package/src/components/play-button/PlayButton.tsx +92 -0
- package/src/components/play-button/index.ts +7 -0
- package/src/components/popover/Popover.tsx +105 -0
- package/src/components/popover/index.ts +8 -0
- package/src/components/progress/Progress.tsx +133 -0
- package/src/components/progress/ProgressRing.tsx +123 -0
- package/src/components/progress/index.ts +2 -0
- package/src/components/radio/Radio.tsx +182 -0
- package/src/components/radio/index.ts +7 -0
- package/src/components/rec-indicator/RecIndicator.tsx +47 -0
- package/src/components/rec-indicator/index.ts +1 -0
- package/src/components/registration-strip/RegistrationStrip.tsx +51 -0
- package/src/components/registration-strip/index.ts +5 -0
- package/src/components/schedule/Schedule.tsx +457 -0
- package/src/components/schedule/index.ts +9 -0
- package/src/components/scroll-hint/ScrollHint.tsx +78 -0
- package/src/components/scroll-hint/index.ts +5 -0
- package/src/components/section-title/SectionTitle.tsx +202 -0
- package/src/components/section-title/index.ts +5 -0
- package/src/components/segmented-control/SegmentedControl.tsx +220 -0
- package/src/components/segmented-control/index.ts +8 -0
- package/src/components/select/Select.tsx +390 -0
- package/src/components/select/index.ts +15 -0
- package/src/components/side-rail/SideRail.tsx +317 -0
- package/src/components/side-rail/SideRailSub.tsx +298 -0
- package/src/components/side-rail/index.ts +14 -0
- package/src/components/skeleton/Skeleton.tsx +70 -0
- package/src/components/skeleton/index.ts +1 -0
- package/src/components/slider/Slider.tsx +219 -0
- package/src/components/slider/index.ts +8 -0
- package/src/components/sparkline/Sparkline.tsx +122 -0
- package/src/components/sparkline/index.ts +6 -0
- package/src/components/spinner/Spinner.tsx +64 -0
- package/src/components/spinner/index.ts +1 -0
- package/src/components/stat/Stat.tsx +79 -0
- package/src/components/stat/index.ts +1 -0
- package/src/components/stepper/Stepper.tsx +316 -0
- package/src/components/stepper/index.ts +1 -0
- package/src/components/steps/Steps.tsx +302 -0
- package/src/components/steps/index.ts +10 -0
- package/src/components/switch/Switch.tsx +120 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/table/Table.tsx +559 -0
- package/src/components/table/index.ts +20 -0
- package/src/components/tabs/Tabs.tsx +313 -0
- package/src/components/tabs/index.ts +12 -0
- package/src/components/tag/Tag.tsx +66 -0
- package/src/components/tag/TagPair.tsx +34 -0
- package/src/components/tag/index.ts +2 -0
- package/src/components/tag-input/TagInput.tsx +501 -0
- package/src/components/tag-input/index.ts +8 -0
- package/src/components/term/Term.tsx +53 -0
- package/src/components/term/index.ts +1 -0
- package/src/components/textarea/Textarea.tsx +99 -0
- package/src/components/textarea/index.ts +1 -0
- package/src/components/texture/Texture.tsx +45 -0
- package/src/components/texture/index.ts +1 -0
- package/src/components/tick-ring/TickRing.tsx +77 -0
- package/src/components/tick-ring/index.ts +1 -0
- package/src/components/timeline/Timeline.tsx +84 -0
- package/src/components/timeline/index.ts +7 -0
- package/src/components/toast/Toast.tsx +257 -0
- package/src/components/toast/index.ts +10 -0
- package/src/components/toc/Toc.tsx +262 -0
- package/src/components/toc/index.ts +7 -0
- package/src/components/toolbar/Toolbar.tsx +389 -0
- package/src/components/toolbar/index.ts +17 -0
- package/src/components/tooltip/Tooltip.tsx +175 -0
- package/src/components/tooltip/index.ts +8 -0
- package/src/components/top-bar/TopBar.tsx +47 -0
- package/src/components/top-bar/index.ts +1 -0
- package/src/components/viewfinder/Viewfinder.tsx +97 -0
- package/src/components/viewfinder/index.ts +6 -0
- package/src/hooks/README.md +14 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useControllableState.ts +30 -0
- package/src/hooks/useInView.ts +44 -0
- package/src/hooks/useOverflowing.ts +28 -0
- package/src/hooks/usePortalScope.ts +68 -0
- package/src/hooks/useScrollPosition.ts +57 -0
- package/src/hooks/useTheme.ts +102 -0
- package/src/icons/ArrowCorner.tsx +7 -0
- package/src/icons/ArrowLeft.tsx +6 -0
- package/src/icons/ArrowRight.tsx +6 -0
- package/src/icons/CalendarIcon.tsx +10 -0
- package/src/icons/Check.tsx +4 -0
- package/src/icons/ChevronDown.tsx +3 -0
- package/src/icons/ChevronLeft.tsx +6 -0
- package/src/icons/ChevronRight.tsx +6 -0
- package/src/icons/Close.tsx +3 -0
- package/src/icons/Crosshair.tsx +7 -0
- package/src/icons/Lock.tsx +6 -0
- package/src/icons/Menu.tsx +4 -0
- package/src/icons/Minus.tsx +4 -0
- package/src/icons/Plus.tsx +3 -0
- package/src/icons/README.md +31 -0
- package/src/icons/StatusDanger.tsx +7 -0
- package/src/icons/StatusInfo.tsx +7 -0
- package/src/icons/StatusSuccess.tsx +10 -0
- package/src/icons/StatusWarning.tsx +7 -0
- package/src/icons/TriangleRight.tsx +7 -0
- package/src/icons/Upload.tsx +7 -0
- package/src/icons/createIcon.tsx +34 -0
- package/src/icons/index.ts +21 -0
- package/src/index.ts +82 -0
- package/src/lib/README.md +17 -0
- package/src/lib/cn.ts +34 -0
- package/src/lib/date.ts +125 -0
- package/src/lib/decor.ts +6 -0
- package/src/lib/defined.ts +9 -0
- package/src/lib/file.ts +61 -0
- package/src/lib/focus-ring.ts +11 -0
- package/src/lib/merge-refs.ts +11 -0
- package/src/styles/README.md +70 -0
- package/src/styles/index.css +25 -0
- package/src/styles/theme.css +568 -0
- package/src/styles/utilities.css +241 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
useContext,
|
|
4
|
+
useId,
|
|
5
|
+
useMemo,
|
|
6
|
+
type ChangeEvent,
|
|
7
|
+
type ComponentProps,
|
|
8
|
+
type ReactNode,
|
|
9
|
+
} from "react";
|
|
10
|
+
import { useControllableState } from "../../hooks/useControllableState";
|
|
11
|
+
import { cn } from "../../lib/cn";
|
|
12
|
+
import { focusRing } from "../../lib/focus-ring";
|
|
13
|
+
import {
|
|
14
|
+
choiceBox,
|
|
15
|
+
choiceControl,
|
|
16
|
+
choiceFrame,
|
|
17
|
+
choiceLabel,
|
|
18
|
+
choiceMark,
|
|
19
|
+
} from "../checkbox/choice-style";
|
|
20
|
+
import { useFieldContext } from "../field/Field";
|
|
21
|
+
|
|
22
|
+
type RadioGroupContextValue = {
|
|
23
|
+
name: string;
|
|
24
|
+
value: string | undefined;
|
|
25
|
+
select: (value: string) => void;
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
required: boolean;
|
|
28
|
+
invalid: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const RadioGroupContext = createContext<RadioGroupContextValue | null>(null);
|
|
32
|
+
|
|
33
|
+
export type RadioGroupOrientation = "vertical" | "horizontal";
|
|
34
|
+
|
|
35
|
+
export type RadioGroupProps = Omit<
|
|
36
|
+
ComponentProps<"div">,
|
|
37
|
+
"onChange" | "defaultValue"
|
|
38
|
+
> & {
|
|
39
|
+
/** 受控的当前值 */
|
|
40
|
+
value?: string;
|
|
41
|
+
/** 非受控时的初始值 */
|
|
42
|
+
defaultValue?: string;
|
|
43
|
+
onValueChange?: (value: string) => void;
|
|
44
|
+
/** 表单提交用的字段名,缺省自动生成 */
|
|
45
|
+
name?: string;
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
required?: boolean;
|
|
48
|
+
/** 竖排(默认)或横排 */
|
|
49
|
+
orientation?: RadioGroupOrientation;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 单选组。方向键在组内移动并选中,这是原生单选的行为,组件不另外处理。
|
|
54
|
+
* 标签用 `<Field group label="…">` 包住它,或者自己传 `aria-label`。
|
|
55
|
+
*/
|
|
56
|
+
export function RadioGroup({
|
|
57
|
+
value,
|
|
58
|
+
defaultValue,
|
|
59
|
+
onValueChange,
|
|
60
|
+
name,
|
|
61
|
+
disabled: disabledProp,
|
|
62
|
+
required: requiredProp,
|
|
63
|
+
orientation = "vertical",
|
|
64
|
+
className,
|
|
65
|
+
...props
|
|
66
|
+
}: RadioGroupProps) {
|
|
67
|
+
const field = useFieldContext();
|
|
68
|
+
const autoName = useId();
|
|
69
|
+
const [current, setCurrent] = useControllableState<string | undefined>({
|
|
70
|
+
value,
|
|
71
|
+
defaultValue,
|
|
72
|
+
onChange: (next) => {
|
|
73
|
+
if (next !== undefined) onValueChange?.(next);
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const disabled = disabledProp ?? field?.disabled ?? false;
|
|
78
|
+
const required = requiredProp ?? field?.required ?? false;
|
|
79
|
+
const invalid = field?.invalid ?? false;
|
|
80
|
+
const groupName = name ?? autoName;
|
|
81
|
+
|
|
82
|
+
const context = useMemo<RadioGroupContextValue>(
|
|
83
|
+
() => ({
|
|
84
|
+
name: groupName,
|
|
85
|
+
value: current,
|
|
86
|
+
select: setCurrent,
|
|
87
|
+
disabled,
|
|
88
|
+
required,
|
|
89
|
+
invalid,
|
|
90
|
+
}),
|
|
91
|
+
[groupName, current, setCurrent, disabled, required, invalid],
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<RadioGroupContext value={context}>
|
|
96
|
+
<div
|
|
97
|
+
role="radiogroup"
|
|
98
|
+
// 字段是 <fieldset> 时名称由 <legend> 给;否则指向字段的标签
|
|
99
|
+
aria-labelledby={field && !field.group ? field.labelId : undefined}
|
|
100
|
+
aria-describedby={field?.describedBy}
|
|
101
|
+
aria-invalid={invalid || undefined}
|
|
102
|
+
aria-required={required || undefined}
|
|
103
|
+
aria-disabled={disabled || undefined}
|
|
104
|
+
{...props}
|
|
105
|
+
data-orientation={orientation}
|
|
106
|
+
className={cn(
|
|
107
|
+
"flex",
|
|
108
|
+
orientation === "vertical" ? "flex-col" : "flex-wrap gap-x-6",
|
|
109
|
+
className,
|
|
110
|
+
)}
|
|
111
|
+
/>
|
|
112
|
+
</RadioGroupContext>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type RadioProps = Omit<
|
|
117
|
+
ComponentProps<"input">,
|
|
118
|
+
"type" | "size" | "value"
|
|
119
|
+
> & {
|
|
120
|
+
value: string;
|
|
121
|
+
/** 右侧的文字标签。不传时必须自己给 `aria-label` */
|
|
122
|
+
children?: ReactNode;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 单选框,放在 `RadioGroup` 里。`className` 给整行,其余属性与 `ref` 给 `<input>`。
|
|
127
|
+
* 脱离 `RadioGroup` 时就是一个原生单选,自己管 `name` 与 `checked`。
|
|
128
|
+
*/
|
|
129
|
+
export function Radio({
|
|
130
|
+
value,
|
|
131
|
+
disabled,
|
|
132
|
+
onChange,
|
|
133
|
+
className,
|
|
134
|
+
children,
|
|
135
|
+
...props
|
|
136
|
+
}: RadioProps) {
|
|
137
|
+
const group = useContext(RadioGroupContext);
|
|
138
|
+
|
|
139
|
+
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
140
|
+
onChange?.(event);
|
|
141
|
+
if (event.target.checked) group?.select(value);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const groupProps = group
|
|
145
|
+
? {
|
|
146
|
+
name: group.name,
|
|
147
|
+
checked: group.value === value,
|
|
148
|
+
required: group.required,
|
|
149
|
+
"aria-invalid": group.invalid || undefined,
|
|
150
|
+
}
|
|
151
|
+
: {};
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<label className={cn(choiceLabel, className)}>
|
|
155
|
+
<span className={choiceControl}>
|
|
156
|
+
<span className={choiceFrame}>
|
|
157
|
+
<input
|
|
158
|
+
{...props}
|
|
159
|
+
{...groupProps}
|
|
160
|
+
type="radio"
|
|
161
|
+
value={value}
|
|
162
|
+
disabled={disabled ?? group?.disabled}
|
|
163
|
+
onChange={handleChange}
|
|
164
|
+
className={cn(
|
|
165
|
+
choiceBox,
|
|
166
|
+
"rounded-full choice-diamond:rounded-none",
|
|
167
|
+
focusRing,
|
|
168
|
+
)}
|
|
169
|
+
/>
|
|
170
|
+
<span
|
|
171
|
+
aria-hidden="true"
|
|
172
|
+
className={cn(
|
|
173
|
+
choiceMark,
|
|
174
|
+
"size-2 rounded-full bg-accent-ink-inverse peer-checked:opacity-100 peer-disabled:bg-ink-disabled choice-diamond:hidden",
|
|
175
|
+
)}
|
|
176
|
+
/>
|
|
177
|
+
</span>
|
|
178
|
+
</span>
|
|
179
|
+
{children !== undefined && <span className="min-w-0">{children}</span>}
|
|
180
|
+
</label>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
import { cn } from "../../lib/cn";
|
|
3
|
+
|
|
4
|
+
export type RecIndicatorProps = Omit<ComponentProps<"span">, "children"> & {
|
|
5
|
+
/** 方括号里的字,默认 `REC`;直播、实时数据可以写 `LIVE` */
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
/** 红点硬切明灭,默认开。关掉后红点常亮 */
|
|
8
|
+
blink?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 录制指示:一个红点 + `[ REC ]`。
|
|
13
|
+
* 只在确有"进行中"的语义时用(正在录制、直播中、实时数据),不要当氛围装饰——
|
|
14
|
+
* 红色在这套语言里是危险与紧急。
|
|
15
|
+
*/
|
|
16
|
+
export function RecIndicator({
|
|
17
|
+
label = "REC",
|
|
18
|
+
blink = true,
|
|
19
|
+
className,
|
|
20
|
+
...props
|
|
21
|
+
}: RecIndicatorProps) {
|
|
22
|
+
return (
|
|
23
|
+
<span
|
|
24
|
+
{...props}
|
|
25
|
+
className={cn(
|
|
26
|
+
"inline-flex items-center gap-1 font-tech text-xs leading-none font-medium whitespace-nowrap text-ink uppercase",
|
|
27
|
+
className,
|
|
28
|
+
)}
|
|
29
|
+
>
|
|
30
|
+
{/* 有意不随主题变:角色色里的"危险"红,作填充用 */}
|
|
31
|
+
<span
|
|
32
|
+
aria-hidden="true"
|
|
33
|
+
className={cn(
|
|
34
|
+
"mr-0.5 size-2 shrink-0 rounded-full bg-alert",
|
|
35
|
+
blink && "animate-blink",
|
|
36
|
+
)}
|
|
37
|
+
/>
|
|
38
|
+
<span aria-hidden="true" className="text-ink-tertiary">
|
|
39
|
+
[
|
|
40
|
+
</span>
|
|
41
|
+
<span>{label}</span>
|
|
42
|
+
<span aria-hidden="true" className="text-ink-tertiary">
|
|
43
|
+
]
|
|
44
|
+
</span>
|
|
45
|
+
</span>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RecIndicator, type RecIndicatorProps } from "./RecIndicator";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
import { cn } from "../../lib/cn";
|
|
3
|
+
import { decor } from "../../lib/decor";
|
|
4
|
+
|
|
5
|
+
export type RegistrationStripOrientation = "horizontal" | "vertical";
|
|
6
|
+
|
|
7
|
+
export type RegistrationStripProps = Omit<ComponentProps<"div">, "children"> & {
|
|
8
|
+
/** 横条高 3px、每段 64px;竖条是三段 6 × 14px 叠放 */
|
|
9
|
+
orientation?: RegistrationStripOrientation;
|
|
10
|
+
/** 横条后面接一段灰线、撑满容器:用作名称下方的分隔线 */
|
|
11
|
+
rule?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// 有意不随主题变:印刷校准用的三原色,只做装饰,不要用在别处
|
|
15
|
+
const segments = ["bg-reg-magenta", "bg-reg-cyan", "bg-reg-yellow"] as const;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 注册色条:品红、青、黄三段的微条,印刷品语气的点缀。
|
|
19
|
+
* 纯装饰,不承担任何数据或状态含义;一个版块最多一处,离图表远一点。
|
|
20
|
+
*/
|
|
21
|
+
export function RegistrationStrip({
|
|
22
|
+
orientation = "horizontal",
|
|
23
|
+
rule = false,
|
|
24
|
+
className,
|
|
25
|
+
...props
|
|
26
|
+
}: RegistrationStripProps) {
|
|
27
|
+
const vertical = orientation === "vertical";
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div
|
|
31
|
+
{...props}
|
|
32
|
+
aria-hidden="true"
|
|
33
|
+
data-orientation={orientation}
|
|
34
|
+
className={cn(
|
|
35
|
+
decor,
|
|
36
|
+
vertical
|
|
37
|
+
? "inline-flex flex-col"
|
|
38
|
+
: ["flex h-[3px] max-w-full", rule && "w-full"],
|
|
39
|
+
className,
|
|
40
|
+
)}
|
|
41
|
+
>
|
|
42
|
+
{segments.map((color) => (
|
|
43
|
+
<span
|
|
44
|
+
key={color}
|
|
45
|
+
className={cn(color, vertical ? "h-3.5 w-1.5" : "w-16 min-w-0")}
|
|
46
|
+
/>
|
|
47
|
+
))}
|
|
48
|
+
{rule && !vertical && <span className="min-w-0 flex-1 bg-line" />}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|