banhaten 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/README.md +361 -0
- package/banhaten.config.example.json +13 -0
- package/package.json +59 -0
- package/registry/assets/activity-feed-avatar.png +0 -0
- package/registry/assets/avatars/avatar-01.jpg +0 -0
- package/registry/assets/avatars/avatar-02.jpg +0 -0
- package/registry/assets/avatars/avatar-03.jpg +0 -0
- package/registry/assets/avatars/avatar-04.jpg +0 -0
- package/registry/assets/avatars/avatar-05.jpg +0 -0
- package/registry/assets/avatars/avatar-06.jpg +0 -0
- package/registry/assets/avatars/avatar-07.jpg +0 -0
- package/registry/assets/avatars/avatar-08.jpg +0 -0
- package/registry/assets/avatars/avatar-09.jpg +0 -0
- package/registry/assets/avatars/avatar-10.jpg +0 -0
- package/registry/assets/avatars/avatar-11.jpg +0 -0
- package/registry/assets/avatars/avatar-12.jpg +0 -0
- package/registry/assets/avatars/avatar-13.jpg +0 -0
- package/registry/assets/avatars/avatar-14.jpg +0 -0
- package/registry/assets/avatars/avatar-15.jpg +0 -0
- package/registry/assets/avatars/avatar-16.jpg +0 -0
- package/registry/assets/avatars/avatar-17.jpg +0 -0
- package/registry/assets/avatars/avatar-18.jpg +0 -0
- package/registry/assets/avatars/avatar-19.jpg +0 -0
- package/registry/assets/avatars/avatar-20.jpg +0 -0
- package/registry/assets/avatars/avatar-21.jpg +0 -0
- package/registry/assets/avatars/avatar-22.jpg +0 -0
- package/registry/assets/avatars/avatar-23.jpg +0 -0
- package/registry/assets/avatars/avatar-24.jpg +0 -0
- package/registry/assets/avatars/avatar-25.jpg +0 -0
- package/registry/assets/avatars/avatar-26.jpg +0 -0
- package/registry/assets/avatars/avatar-27.jpg +0 -0
- package/registry/assets/avatars/avatar-28.jpg +0 -0
- package/registry/assets/avatars/avatar-29.jpg +0 -0
- package/registry/assets/avatars/avatar-30.jpg +0 -0
- package/registry/assets/avatars/avatar-31.jpg +0 -0
- package/registry/assets/avatars/avatar-32.jpg +0 -0
- package/registry/assets/avatars/avatar-33.jpg +0 -0
- package/registry/assets/avatars/avatar-34.jpg +0 -0
- package/registry/assets/avatars/avatar-35.jpg +0 -0
- package/registry/assets/image-assets.json +744 -0
- package/registry/assets/images/art-01.jpg +0 -0
- package/registry/assets/images/art-02.jpg +0 -0
- package/registry/assets/images/art-03.jpg +0 -0
- package/registry/assets/images/art-04.jpg +0 -0
- package/registry/assets/images/art-05.jpg +0 -0
- package/registry/assets/images/art-06.jpg +0 -0
- package/registry/assets/images/art-07.jpg +0 -0
- package/registry/assets/images/art-08.jpg +0 -0
- package/registry/assets/images/art-09.jpg +0 -0
- package/registry/assets/images/art-10.jpg +0 -0
- package/registry/assets/images/art-11.jpg +0 -0
- package/registry/assets/images/art-12.jpg +0 -0
- package/registry/assets/images/art-13.jpg +0 -0
- package/registry/assets/images/art-14.jpg +0 -0
- package/registry/assets/images/art-15.jpg +0 -0
- package/registry/assets/images/art-16.jpg +0 -0
- package/registry/assets/images/art-17.jpg +0 -0
- package/registry/assets/images/art-18.jpg +0 -0
- package/registry/assets/images/art-19.jpg +0 -0
- package/registry/assets/images/art-20.jpg +0 -0
- package/registry/assets/images/art-21.jpg +0 -0
- package/registry/assets/images/art-22.jpg +0 -0
- package/registry/assets/images/art-23.jpg +0 -0
- package/registry/assets/images/art-24.jpg +0 -0
- package/registry/assets/images/art-25.jpg +0 -0
- package/registry/assets/images/art-26.jpg +0 -0
- package/registry/assets/images/art-27.jpg +0 -0
- package/registry/assets/images/nature-01.jpg +0 -0
- package/registry/assets/images/nature-02.jpg +0 -0
- package/registry/assets/images/nature-03.jpg +0 -0
- package/registry/assets/images/nature-04.jpg +0 -0
- package/registry/assets/images/nature-05.jpg +0 -0
- package/registry/assets/images/nature-06.jpg +0 -0
- package/registry/assets/images/nature-07.jpg +0 -0
- package/registry/assets/images/nature-08.jpg +0 -0
- package/registry/assets/images/nature-09.jpg +0 -0
- package/registry/assets/images/nature-10.jpg +0 -0
- package/registry/assets/images/nature-11.jpg +0 -0
- package/registry/assets/images/nature-12.jpg +0 -0
- package/registry/assets/images/nature-13.jpg +0 -0
- package/registry/assets/images/nature-14.jpg +0 -0
- package/registry/assets/images/nature-15.jpg +0 -0
- package/registry/assets/images/nature-16.jpg +0 -0
- package/registry/assets/images/nature-17.jpg +0 -0
- package/registry/assets/images/nature-18.jpg +0 -0
- package/registry/assets/images/nature-19.jpg +0 -0
- package/registry/assets/images/nature-20.jpg +0 -0
- package/registry/components/accordion.tsx +119 -0
- package/registry/components/alert.tsx +282 -0
- package/registry/components/attribute.tsx +452 -0
- package/registry/components/avatar.tsx +142 -0
- package/registry/components/badge.tsx +567 -0
- package/registry/components/button-group.tsx +246 -0
- package/registry/components/button.tsx +102 -0
- package/registry/components/card.tsx +613 -0
- package/registry/components/checkbox.tsx +244 -0
- package/registry/components/date-picker.tsx +1143 -0
- package/registry/components/divider.tsx +82 -0
- package/registry/components/expanded/ActivityFeed.tsx +226 -0
- package/registry/components/expanded/Banner.tsx +145 -0
- package/registry/components/expanded/BannerBoard.tsx +225 -0
- package/registry/components/expanded/Breadcrumbs.tsx +156 -0
- package/registry/components/expanded/CatalogComponentsShowcase.tsx +211 -0
- package/registry/components/expanded/CatalogDivider.tsx +48 -0
- package/registry/components/expanded/CatalogTag.tsx +92 -0
- package/registry/components/expanded/CommandBar.tsx +406 -0
- package/registry/components/expanded/FileUpload.tsx +231 -0
- package/registry/components/expanded/IconExplorer.tsx +612 -0
- package/registry/components/expanded/OnboardingStepListItem.tsx +67 -0
- package/registry/components/expanded/PageHeader.tsx +184 -0
- package/registry/components/expanded/Slideout.tsx +514 -0
- package/registry/components/expanded/Steps.tsx +266 -0
- package/registry/components/expanded/Table.tsx +1014 -0
- package/registry/components/expanded/Tabs.tsx +86 -0
- package/registry/components/expanded/Timeline.tsx +235 -0
- package/registry/components/expanded/TimelineShowcase.tsx +158 -0
- package/registry/components/expanded/activityFeed.css +292 -0
- package/registry/components/expanded/banner.css +312 -0
- package/registry/components/expanded/breadcrumbs.css +140 -0
- package/registry/components/expanded/catalogComponentsShowcase.css +87 -0
- package/registry/components/expanded/commandBar.css +473 -0
- package/registry/components/expanded/divider.css +75 -0
- package/registry/components/expanded/fileUpload.css +228 -0
- package/registry/components/expanded/iconExplorer.css +764 -0
- package/registry/components/expanded/iconPacks.ts +866 -0
- package/registry/components/expanded/onboardingStepListItem.css +126 -0
- package/registry/components/expanded/pageHeader.css +287 -0
- package/registry/components/expanded/slideout.css +955 -0
- package/registry/components/expanded/steps.css +329 -0
- package/registry/components/expanded/table.css +607 -0
- package/registry/components/expanded/tabs.css +197 -0
- package/registry/components/expanded/tag.css +148 -0
- package/registry/components/expanded/timeline.css +282 -0
- package/registry/components/input-content.ts +106 -0
- package/registry/components/input.tsx +866 -0
- package/registry/components/menu.tsx +758 -0
- package/registry/components/modal.tsx +799 -0
- package/registry/components/pagination.tsx +543 -0
- package/registry/components/progress-slider.tsx +216 -0
- package/registry/components/progress.tsx +367 -0
- package/registry/components/radio-card.tsx +654 -0
- package/registry/components/radio-group.tsx +570 -0
- package/registry/components/select-content.tsx +313 -0
- package/registry/components/select.tsx +871 -0
- package/registry/components/slider.tsx +380 -0
- package/registry/components/social-button.tsx +360 -0
- package/registry/components/spinner.tsx +31 -0
- package/registry/components/tag.tsx +423 -0
- package/registry/components/textarea.tsx +625 -0
- package/registry/components/toggle.tsx +272 -0
- package/registry/components/toolbar.tsx +467 -0
- package/registry/components/tooltip.tsx +427 -0
- package/registry/examples/accordion-demo.tsx +34 -0
- package/registry/examples/alert-demo.tsx +14 -0
- package/registry/examples/attribute-demo.tsx +65 -0
- package/registry/examples/avatar-demo.tsx +74 -0
- package/registry/examples/badge-demo.tsx +53 -0
- package/registry/examples/button-demo.tsx +83 -0
- package/registry/examples/button-group-demo.tsx +42 -0
- package/registry/examples/card-demo.tsx +48 -0
- package/registry/examples/checkbox-demo.tsx +67 -0
- package/registry/examples/date-picker-demo.tsx +74 -0
- package/registry/examples/divider-demo.tsx +17 -0
- package/registry/examples/expanded/activity-feed-demo.tsx +22 -0
- package/registry/examples/expanded/banner-demo.tsx +23 -0
- package/registry/examples/expanded/catalog-components-demo.tsx +5 -0
- package/registry/examples/expanded/command-bar-demo.tsx +10 -0
- package/registry/examples/expanded/icons-demo.tsx +5 -0
- package/registry/examples/expanded/onboarding-step-demo.tsx +11 -0
- package/registry/examples/expanded/page-header-demo.tsx +19 -0
- package/registry/examples/expanded/slideout-demo.tsx +15 -0
- package/registry/examples/expanded/steps-demo.tsx +18 -0
- package/registry/examples/expanded/tabs-demo.tsx +13 -0
- package/registry/examples/expanded/timeline-demo.tsx +18 -0
- package/registry/examples/input-demo.tsx +87 -0
- package/registry/examples/menu-demo.tsx +109 -0
- package/registry/examples/modal-demo.tsx +16 -0
- package/registry/examples/pagination-demo.tsx +17 -0
- package/registry/examples/progress-demo.tsx +37 -0
- package/registry/examples/progress-slider-demo.tsx +29 -0
- package/registry/examples/radio-card-demo.tsx +51 -0
- package/registry/examples/radio-group-demo.tsx +62 -0
- package/registry/examples/select-demo.tsx +73 -0
- package/registry/examples/slider-demo.tsx +31 -0
- package/registry/examples/social-button-demo.tsx +51 -0
- package/registry/examples/tag-demo.tsx +29 -0
- package/registry/examples/textarea-demo.tsx +79 -0
- package/registry/examples/toggle-demo.tsx +59 -0
- package/registry/examples/toolbar-demo.tsx +80 -0
- package/registry/examples/tooltip-demo.tsx +115 -0
- package/registry/hooks/use-direction.ts +27 -0
- package/registry/index.json +1213 -0
- package/registry/styles/globals.css +4600 -0
- package/registry/utils/cn.ts +6 -0
- package/src/cli/index.js +826 -0
- package/tokens/Color mode.zip +0 -0
- package/tokens/Numbers.zip +0 -0
- package/tokens/Radius.zip +0 -0
- package/tokens/Theme.zip +0 -0
- package/tokens/banhaten.tokens.json +5525 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { useRef, useState, type ChangeEvent, type DragEvent } from "react";
|
|
2
|
+
import "./fileUpload.css";
|
|
3
|
+
|
|
4
|
+
export type FileUploadSize = "lg" | "sm";
|
|
5
|
+
export type FileUploadItemStatus = "uploaded" | "uploading" | "error";
|
|
6
|
+
|
|
7
|
+
export type FileUploadFile = {
|
|
8
|
+
errorLabel?: string;
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
sizeLabel: string;
|
|
12
|
+
status: FileUploadItemStatus;
|
|
13
|
+
versionLabel?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type FileUploadProps = {
|
|
17
|
+
accept?: string;
|
|
18
|
+
browseLabel?: string;
|
|
19
|
+
dir?: "ltr" | "rtl" | "auto";
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
files?: FileUploadFile[];
|
|
22
|
+
helperText?: string;
|
|
23
|
+
multiple?: boolean;
|
|
24
|
+
onBrowse?: () => void;
|
|
25
|
+
onCancel?: (fileId: string) => void;
|
|
26
|
+
onDrop?: (files: FileList) => void;
|
|
27
|
+
onRemove?: (fileId: string) => void;
|
|
28
|
+
onRetry?: (fileId: string) => void;
|
|
29
|
+
prompt?: string;
|
|
30
|
+
size?: FileUploadSize;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function FileUpload({
|
|
34
|
+
accept,
|
|
35
|
+
browseLabel,
|
|
36
|
+
dir = "ltr",
|
|
37
|
+
disabled = false,
|
|
38
|
+
files = [],
|
|
39
|
+
helperText,
|
|
40
|
+
multiple = false,
|
|
41
|
+
onBrowse,
|
|
42
|
+
onCancel,
|
|
43
|
+
onDrop,
|
|
44
|
+
onRemove,
|
|
45
|
+
onRetry,
|
|
46
|
+
prompt,
|
|
47
|
+
size = "lg",
|
|
48
|
+
}: FileUploadProps) {
|
|
49
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
50
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
51
|
+
|
|
52
|
+
function browse() {
|
|
53
|
+
if (disabled) return;
|
|
54
|
+
onBrowse?.();
|
|
55
|
+
inputRef.current?.click();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function handleInputChange(event: ChangeEvent<HTMLInputElement>) {
|
|
59
|
+
const selectedFiles = event.currentTarget.files;
|
|
60
|
+
if (selectedFiles?.length) {
|
|
61
|
+
onDrop?.(selectedFiles);
|
|
62
|
+
}
|
|
63
|
+
event.currentTarget.value = "";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function handleDragOver(event: DragEvent<HTMLDivElement>) {
|
|
67
|
+
if (disabled) return;
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
setIsDragging(true);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function handleDrop(event: DragEvent<HTMLDivElement>) {
|
|
73
|
+
if (disabled) return;
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
setIsDragging(false);
|
|
76
|
+
if (event.dataTransfer.files.length) {
|
|
77
|
+
onDrop?.(event.dataTransfer.files);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div className={`ds-file-upload ds-file-upload--${size}`} dir={dir}>
|
|
83
|
+
<div
|
|
84
|
+
aria-disabled={disabled || undefined}
|
|
85
|
+
className={isDragging ? "ds-file-upload__dropzone is-dragging" : "ds-file-upload__dropzone"}
|
|
86
|
+
onDragLeave={() => setIsDragging(false)}
|
|
87
|
+
onDragOver={handleDragOver}
|
|
88
|
+
onDrop={handleDrop}
|
|
89
|
+
>
|
|
90
|
+
<input
|
|
91
|
+
accept={accept}
|
|
92
|
+
className="ds-file-upload__input"
|
|
93
|
+
disabled={disabled}
|
|
94
|
+
multiple={multiple}
|
|
95
|
+
onChange={handleInputChange}
|
|
96
|
+
ref={inputRef}
|
|
97
|
+
type="file"
|
|
98
|
+
/>
|
|
99
|
+
<span className="ds-file-upload__icon" aria-hidden="true">
|
|
100
|
+
<UploadIcon />
|
|
101
|
+
</span>
|
|
102
|
+
{(prompt || browseLabel) && (
|
|
103
|
+
<p>
|
|
104
|
+
{prompt}{" "}
|
|
105
|
+
{browseLabel && (
|
|
106
|
+
<button className="ds-file-upload__browse" disabled={disabled} onClick={browse} type="button">
|
|
107
|
+
{browseLabel}
|
|
108
|
+
</button>
|
|
109
|
+
)}
|
|
110
|
+
</p>
|
|
111
|
+
)}
|
|
112
|
+
{helperText && <span className="ds-file-upload__helper">{helperText}</span>}
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
{files.length > 0 && (
|
|
116
|
+
<ul className="ds-file-upload__list" aria-label="Queued files">
|
|
117
|
+
{files.map((file) => (
|
|
118
|
+
<FileUploadRow
|
|
119
|
+
file={file}
|
|
120
|
+
key={file.id}
|
|
121
|
+
onCancel={onCancel}
|
|
122
|
+
onRemove={onRemove}
|
|
123
|
+
onRetry={onRetry}
|
|
124
|
+
size={size}
|
|
125
|
+
/>
|
|
126
|
+
))}
|
|
127
|
+
</ul>
|
|
128
|
+
)}
|
|
129
|
+
</div>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function FileUploadRow({
|
|
134
|
+
file,
|
|
135
|
+
onCancel,
|
|
136
|
+
onRemove,
|
|
137
|
+
onRetry,
|
|
138
|
+
size,
|
|
139
|
+
}: {
|
|
140
|
+
file: FileUploadFile;
|
|
141
|
+
onCancel?: (fileId: string) => void;
|
|
142
|
+
onRemove?: (fileId: string) => void;
|
|
143
|
+
onRetry?: (fileId: string) => void;
|
|
144
|
+
size: FileUploadSize;
|
|
145
|
+
}) {
|
|
146
|
+
return (
|
|
147
|
+
<li className={`ds-file-upload-row ds-file-upload-row--${file.status} ds-file-upload-row--${size}`}>
|
|
148
|
+
<span className="ds-file-upload-row__file-icon" aria-hidden="true">
|
|
149
|
+
<FileIcon />
|
|
150
|
+
</span>
|
|
151
|
+
<div className="ds-file-upload-row__copy">
|
|
152
|
+
<strong title={file.name}>{file.name}</strong>
|
|
153
|
+
<span>
|
|
154
|
+
{file.sizeLabel}
|
|
155
|
+
{file.versionLabel ? ` - ${file.versionLabel}` : ""}
|
|
156
|
+
</span>
|
|
157
|
+
{file.status === "error" && file.errorLabel && <em>{file.errorLabel}</em>}
|
|
158
|
+
</div>
|
|
159
|
+
<StatusIcon status={file.status} />
|
|
160
|
+
<div className="ds-file-upload-row__actions">
|
|
161
|
+
{file.status === "uploading" && (
|
|
162
|
+
<button aria-label={`Cancel upload for ${file.name}`} onClick={() => onCancel?.(file.id)} type="button">
|
|
163
|
+
Cancel
|
|
164
|
+
</button>
|
|
165
|
+
)}
|
|
166
|
+
{file.status === "error" && (
|
|
167
|
+
<button aria-label={`Retry upload for ${file.name}`} onClick={() => onRetry?.(file.id)} type="button">
|
|
168
|
+
Retry
|
|
169
|
+
</button>
|
|
170
|
+
)}
|
|
171
|
+
{file.status !== "uploading" && (
|
|
172
|
+
<button aria-label={`Remove ${file.name}`} onClick={() => onRemove?.(file.id)} type="button">
|
|
173
|
+
Remove
|
|
174
|
+
</button>
|
|
175
|
+
)}
|
|
176
|
+
</div>
|
|
177
|
+
</li>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function StatusIcon({ status }: { status: FileUploadItemStatus }) {
|
|
182
|
+
return (
|
|
183
|
+
<span className={`ds-file-upload-row__status ds-file-upload-row__status--${status}`} aria-label={status}>
|
|
184
|
+
{status === "uploaded" && <CheckIcon />}
|
|
185
|
+
{status === "uploading" && <SpinnerIcon />}
|
|
186
|
+
{status === "error" && <WarningIcon />}
|
|
187
|
+
</span>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function UploadIcon() {
|
|
192
|
+
return (
|
|
193
|
+
<svg viewBox="0 0 24 24">
|
|
194
|
+
<path d="M12 16V5m0 0 4 4m-4-4-4 4M5 16v2.5A1.5 1.5 0 0 0 6.5 20h11a1.5 1.5 0 0 0 1.5-1.5V16" fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.8" />
|
|
195
|
+
</svg>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function FileIcon() {
|
|
200
|
+
return (
|
|
201
|
+
<svg viewBox="0 0 24 24">
|
|
202
|
+
<path d="M7 3.5h6.8L18 7.7v12.8H7V3.5Z" fill="none" stroke="currentColor" strokeLinejoin="round" strokeWidth="1.8" />
|
|
203
|
+
<path d="M13.5 3.8v4.4h4.2" fill="none" stroke="currentColor" strokeLinejoin="round" strokeWidth="1.8" />
|
|
204
|
+
</svg>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function CheckIcon() {
|
|
209
|
+
return (
|
|
210
|
+
<svg viewBox="0 0 20 20">
|
|
211
|
+
<path d="m4.5 10 3.4 3.4 7.6-7.8" fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.9" />
|
|
212
|
+
</svg>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function SpinnerIcon() {
|
|
217
|
+
return (
|
|
218
|
+
<svg viewBox="0 0 20 20">
|
|
219
|
+
<path d="M10 3a7 7 0 1 1-6.2 3.8" fill="none" stroke="currentColor" strokeLinecap="round" strokeWidth="1.8" />
|
|
220
|
+
</svg>
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function WarningIcon() {
|
|
225
|
+
return (
|
|
226
|
+
<svg viewBox="0 0 20 20">
|
|
227
|
+
<path d="M10 3.2 18 17H2l8-13.8Z" fill="none" stroke="currentColor" strokeLinejoin="round" strokeWidth="1.6" />
|
|
228
|
+
<path d="M10 8v4m0 2.5h.1" fill="none" stroke="currentColor" strokeLinecap="round" strokeWidth="1.9" />
|
|
229
|
+
</svg>
|
|
230
|
+
);
|
|
231
|
+
}
|