@behivetech/molecules.file-dropzone 0.2.5 → 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 +21 -0
- package/README.md +10 -0
- package/dist/index.cjs +68 -14
- package/dist/index.css +56 -52
- package/dist/index.d.ts +81 -1
- package/dist/index.js +69 -14
- package/dist/index.native.js +252 -0
- package/dist/native/file-dropzone.block.d.ts +75 -0
- package/dist/native/file-dropzone.block.native.d.ts +2 -0
- package/dist/native/file-dropzone.native.d.ts +39 -0
- package/dist/native/index.d.ts +2 -0
- package/docs.json +8 -1
- package/file-dropzone.block.css +74 -0
- package/file-dropzone.block.native.ts +164 -0
- package/file-dropzone.block.ts +58 -0
- package/file-dropzone.native.tsx +144 -0
- package/file-dropzone.tsx +14 -9
- package/index.ts +2 -2
- package/package.json +41 -8
- package/file-dropzone.module.scss +0 -69
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// file-dropzone.native.tsx
|
|
2
|
+
import {
|
|
3
|
+
pressHandlers,
|
|
4
|
+
useBlock
|
|
5
|
+
} from "@behivetech/blocks.core/native";
|
|
6
|
+
import { getDocumentAsync } from "expo-document-picker";
|
|
7
|
+
import { useRef, useState } from "react";
|
|
8
|
+
import {
|
|
9
|
+
Pressable,
|
|
10
|
+
Text
|
|
11
|
+
} from "react-native";
|
|
12
|
+
|
|
13
|
+
// file-dropzone.block.native.ts
|
|
14
|
+
import { createNativeBlock as __bhtCreateNativeBlock } from "@behivetech/blocks.core/native";
|
|
15
|
+
import { StyleSheet as __bhtStyleSheet } from "react-native";
|
|
16
|
+
var __bht0_shared = __bhtStyleSheet.create({});
|
|
17
|
+
var __bht0_light = __bhtStyleSheet.create({
|
|
18
|
+
root: {
|
|
19
|
+
position: "relative",
|
|
20
|
+
display: "flex",
|
|
21
|
+
flexDirection: "row",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
justifyContent: "center",
|
|
24
|
+
textAlign: "center",
|
|
25
|
+
minHeight: 128,
|
|
26
|
+
paddingTop: 24,
|
|
27
|
+
paddingRight: 24,
|
|
28
|
+
paddingBottom: 24,
|
|
29
|
+
paddingLeft: 24,
|
|
30
|
+
borderTopWidth: 2,
|
|
31
|
+
borderRightWidth: 2,
|
|
32
|
+
borderBottomWidth: 2,
|
|
33
|
+
borderLeftWidth: 2,
|
|
34
|
+
borderStyle: "dashed",
|
|
35
|
+
borderTopColor: "#777777",
|
|
36
|
+
borderRightColor: "#777777",
|
|
37
|
+
borderBottomColor: "#777777",
|
|
38
|
+
borderLeftColor: "#777777",
|
|
39
|
+
borderTopLeftRadius: 12,
|
|
40
|
+
borderTopRightRadius: 12,
|
|
41
|
+
borderBottomRightRadius: 12,
|
|
42
|
+
borderBottomLeftRadius: 12,
|
|
43
|
+
color: "#474747",
|
|
44
|
+
fontFamily: "Inter",
|
|
45
|
+
fontSize: 14,
|
|
46
|
+
fontWeight: "400",
|
|
47
|
+
lineHeight: 20,
|
|
48
|
+
letterSpacing: 0.2506
|
|
49
|
+
},
|
|
50
|
+
"root:hover": {
|
|
51
|
+
borderTopColor: "#64558f",
|
|
52
|
+
borderRightColor: "#64558f",
|
|
53
|
+
borderBottomColor: "#64558f",
|
|
54
|
+
borderLeftColor: "#64558f"
|
|
55
|
+
},
|
|
56
|
+
"root:focusVisible": {
|
|
57
|
+
outlineWidth: 3,
|
|
58
|
+
outlineStyle: "solid",
|
|
59
|
+
outlineColor: "#615b71",
|
|
60
|
+
outlineOffset: 2
|
|
61
|
+
},
|
|
62
|
+
"root:pressed": {
|
|
63
|
+
borderTopColor: "#64558f",
|
|
64
|
+
borderRightColor: "#64558f",
|
|
65
|
+
borderBottomColor: "#64558f",
|
|
66
|
+
borderLeftColor: "#64558f"
|
|
67
|
+
},
|
|
68
|
+
"root~text": {
|
|
69
|
+
textAlign: "center",
|
|
70
|
+
color: "#474747",
|
|
71
|
+
fontFamily: "Inter",
|
|
72
|
+
fontSize: 14,
|
|
73
|
+
fontWeight: "400",
|
|
74
|
+
lineHeight: 20,
|
|
75
|
+
letterSpacing: 0.2506
|
|
76
|
+
},
|
|
77
|
+
"--dragging": {
|
|
78
|
+
borderTopColor: "#64558f",
|
|
79
|
+
borderRightColor: "#64558f",
|
|
80
|
+
borderBottomColor: "#64558f",
|
|
81
|
+
borderLeftColor: "#64558f"
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
var __bht0_dark = __bhtStyleSheet.create({
|
|
85
|
+
root: {
|
|
86
|
+
position: "relative",
|
|
87
|
+
display: "flex",
|
|
88
|
+
flexDirection: "row",
|
|
89
|
+
alignItems: "center",
|
|
90
|
+
justifyContent: "center",
|
|
91
|
+
textAlign: "center",
|
|
92
|
+
minHeight: 128,
|
|
93
|
+
paddingTop: 24,
|
|
94
|
+
paddingRight: 24,
|
|
95
|
+
paddingBottom: 24,
|
|
96
|
+
paddingLeft: 24,
|
|
97
|
+
borderTopWidth: 2,
|
|
98
|
+
borderRightWidth: 2,
|
|
99
|
+
borderBottomWidth: 2,
|
|
100
|
+
borderLeftWidth: 2,
|
|
101
|
+
borderStyle: "dashed",
|
|
102
|
+
borderTopColor: "#919191",
|
|
103
|
+
borderRightColor: "#919191",
|
|
104
|
+
borderBottomColor: "#919191",
|
|
105
|
+
borderLeftColor: "#919191",
|
|
106
|
+
borderTopLeftRadius: 12,
|
|
107
|
+
borderTopRightRadius: 12,
|
|
108
|
+
borderBottomRightRadius: 12,
|
|
109
|
+
borderBottomLeftRadius: 12,
|
|
110
|
+
color: "#c6c6c6",
|
|
111
|
+
fontFamily: "Inter",
|
|
112
|
+
fontSize: 14,
|
|
113
|
+
fontWeight: "400",
|
|
114
|
+
lineHeight: 20,
|
|
115
|
+
letterSpacing: 0.2506
|
|
116
|
+
},
|
|
117
|
+
"root:hover": {
|
|
118
|
+
borderTopColor: "#cebdfe",
|
|
119
|
+
borderRightColor: "#cebdfe",
|
|
120
|
+
borderBottomColor: "#cebdfe",
|
|
121
|
+
borderLeftColor: "#cebdfe"
|
|
122
|
+
},
|
|
123
|
+
"root:focusVisible": {
|
|
124
|
+
outlineWidth: 3,
|
|
125
|
+
outlineStyle: "solid",
|
|
126
|
+
outlineColor: "#cbc3dc",
|
|
127
|
+
outlineOffset: 2
|
|
128
|
+
},
|
|
129
|
+
"root:pressed": {
|
|
130
|
+
borderTopColor: "#cebdfe",
|
|
131
|
+
borderRightColor: "#cebdfe",
|
|
132
|
+
borderBottomColor: "#cebdfe",
|
|
133
|
+
borderLeftColor: "#cebdfe"
|
|
134
|
+
},
|
|
135
|
+
"root~text": {
|
|
136
|
+
textAlign: "center",
|
|
137
|
+
color: "#c6c6c6",
|
|
138
|
+
fontFamily: "Inter",
|
|
139
|
+
fontSize: 14,
|
|
140
|
+
fontWeight: "400",
|
|
141
|
+
lineHeight: 20,
|
|
142
|
+
letterSpacing: 0.2506
|
|
143
|
+
},
|
|
144
|
+
"--dragging": {
|
|
145
|
+
borderTopColor: "#cebdfe",
|
|
146
|
+
borderRightColor: "#cebdfe",
|
|
147
|
+
borderBottomColor: "#cebdfe",
|
|
148
|
+
borderLeftColor: "#cebdfe"
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
var fileDropzone = __bhtCreateNativeBlock("BHT__FileDropzone", {
|
|
152
|
+
structure: {
|
|
153
|
+
a11y: { role: "button" },
|
|
154
|
+
children: { label: {} },
|
|
155
|
+
variants: { dragging: { children: {} } }
|
|
156
|
+
},
|
|
157
|
+
sheets: {
|
|
158
|
+
light: { ...__bht0_shared, ...__bht0_light },
|
|
159
|
+
dark: { ...__bht0_shared, ...__bht0_dark }
|
|
160
|
+
},
|
|
161
|
+
plan: {
|
|
162
|
+
root: [
|
|
163
|
+
{ key: "root" },
|
|
164
|
+
{ key: "root:hover", when: { state: "hover" } },
|
|
165
|
+
{ key: "root:focusVisible", when: { state: "focusVisible" } },
|
|
166
|
+
{ key: "root:pressed", when: { state: "pressed" } },
|
|
167
|
+
{ key: "--dragging", when: { variant: "dragging" } }
|
|
168
|
+
],
|
|
169
|
+
children: { label: [{ key: "root~text" }] }
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// file-dropzone.native.tsx
|
|
174
|
+
import { jsx } from "react/jsx-runtime";
|
|
175
|
+
var DEFAULT_LABEL = "Tap to choose files";
|
|
176
|
+
var ANY_FILE = "*/*";
|
|
177
|
+
var getMimeTypes = (accept) => {
|
|
178
|
+
const types = (accept ?? "").split(",").map((entry) => entry.trim()).filter((entry) => entry.includes("/"));
|
|
179
|
+
return types.length > 0 ? types : [ANY_FILE];
|
|
180
|
+
};
|
|
181
|
+
var FileDropzone = ({
|
|
182
|
+
onFiles,
|
|
183
|
+
onError,
|
|
184
|
+
accept,
|
|
185
|
+
multiple = true,
|
|
186
|
+
label = DEFAULT_LABEL,
|
|
187
|
+
style,
|
|
188
|
+
styles,
|
|
189
|
+
...rest
|
|
190
|
+
}) => {
|
|
191
|
+
const [isPicking, setIsPicking] = useState(false);
|
|
192
|
+
const [rootProps, childProps] = useBlock(
|
|
193
|
+
fileDropzone,
|
|
194
|
+
{},
|
|
195
|
+
{
|
|
196
|
+
style,
|
|
197
|
+
styles,
|
|
198
|
+
// The block's own handlers track its states; the consumer's are called after them, not replaced by the spread.
|
|
199
|
+
handlers: pressHandlers(rest),
|
|
200
|
+
hitSlop: rest.hitSlop
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
const isWords = typeof label === "string" || typeof label === "number";
|
|
204
|
+
const picking = useRef(false);
|
|
205
|
+
const pick = async () => {
|
|
206
|
+
if (picking.current) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
picking.current = true;
|
|
210
|
+
setIsPicking(true);
|
|
211
|
+
let files = [];
|
|
212
|
+
try {
|
|
213
|
+
const result = await getDocumentAsync({
|
|
214
|
+
type: getMimeTypes(accept),
|
|
215
|
+
multiple,
|
|
216
|
+
copyToCacheDirectory: true
|
|
217
|
+
});
|
|
218
|
+
if (!result.canceled) {
|
|
219
|
+
files = result.assets.map(({ uri, name, size, mimeType }) => ({
|
|
220
|
+
uri,
|
|
221
|
+
name,
|
|
222
|
+
size,
|
|
223
|
+
mimeType
|
|
224
|
+
}));
|
|
225
|
+
}
|
|
226
|
+
} catch (error) {
|
|
227
|
+
onError?.(error);
|
|
228
|
+
} finally {
|
|
229
|
+
picking.current = false;
|
|
230
|
+
setIsPicking(false);
|
|
231
|
+
}
|
|
232
|
+
if (files.length > 0) {
|
|
233
|
+
onFiles(files);
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
return /* @__PURE__ */ jsx(
|
|
237
|
+
Pressable,
|
|
238
|
+
{
|
|
239
|
+
accessibilityLabel: isWords ? String(label) : void 0,
|
|
240
|
+
...rest,
|
|
241
|
+
...rootProps,
|
|
242
|
+
role: "button",
|
|
243
|
+
accessibilityState: { busy: isPicking },
|
|
244
|
+
disabled: isPicking,
|
|
245
|
+
onPress: () => void pick(),
|
|
246
|
+
children: /* @__PURE__ */ jsx(Text, { ...childProps("label"), children: label })
|
|
247
|
+
}
|
|
248
|
+
);
|
|
249
|
+
};
|
|
250
|
+
export {
|
|
251
|
+
FileDropzone
|
|
252
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export declare const fileDropzone: import("@behivetech/blocks.core").Block<"BHT__FileDropzone", {
|
|
2
|
+
readonly a11y: {
|
|
3
|
+
readonly role: "button";
|
|
4
|
+
};
|
|
5
|
+
readonly position: "relative";
|
|
6
|
+
readonly display: "flex";
|
|
7
|
+
readonly alignItems: "center";
|
|
8
|
+
readonly justifyContent: "center";
|
|
9
|
+
readonly textAlign: "center";
|
|
10
|
+
readonly minHeight: "8rem";
|
|
11
|
+
readonly padding: import("@behivetech/blocks.core").Token<"length">;
|
|
12
|
+
readonly border: readonly [2, "dashed", import("@behivetech/blocks.core").Token<"color">];
|
|
13
|
+
readonly borderRadius: import("@behivetech/blocks.core").Token<"length">;
|
|
14
|
+
readonly color: import("@behivetech/blocks.core").Token<"color">;
|
|
15
|
+
readonly fontFamily: import("@behivetech/blocks.core").Token<"font">;
|
|
16
|
+
readonly fontSize: import("@behivetech/blocks.core").Token<"length">;
|
|
17
|
+
readonly fontWeight: import("@behivetech/blocks.core").Token<"weight">;
|
|
18
|
+
readonly lineHeight: import("@behivetech/blocks.core").Token<"length">;
|
|
19
|
+
readonly letterSpacing: import("@behivetech/blocks.core").Token<"tracking">;
|
|
20
|
+
readonly native: {
|
|
21
|
+
readonly states: {
|
|
22
|
+
readonly pressed: {
|
|
23
|
+
readonly borderColor: import("@behivetech/blocks.core").Token<"color">;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
readonly states: {
|
|
28
|
+
readonly hover: {
|
|
29
|
+
readonly borderColor: import("@behivetech/blocks.core").Token<"color">;
|
|
30
|
+
};
|
|
31
|
+
readonly focusVisible: {
|
|
32
|
+
readonly outlineWidth: 3;
|
|
33
|
+
readonly outlineStyle: "solid";
|
|
34
|
+
readonly outlineColor: import("@behivetech/blocks.core").Token<"color">;
|
|
35
|
+
readonly outlineOffset: 2;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly children: {
|
|
39
|
+
readonly label: {};
|
|
40
|
+
};
|
|
41
|
+
readonly variants: {
|
|
42
|
+
readonly dragging: {
|
|
43
|
+
readonly borderColor: import("@behivetech/blocks.core").Token<"color">;
|
|
44
|
+
readonly web: {
|
|
45
|
+
readonly "&::after": {
|
|
46
|
+
readonly opacity: import("@behivetech/blocks.core").Token<"number">;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
readonly web: {
|
|
52
|
+
readonly isolation: "isolate";
|
|
53
|
+
readonly cursor: "pointer";
|
|
54
|
+
readonly transition: import("@behivetech/blocks.core").CssValue;
|
|
55
|
+
readonly "&::after": {
|
|
56
|
+
readonly content: "\"\"";
|
|
57
|
+
readonly position: "absolute";
|
|
58
|
+
readonly inset: 0;
|
|
59
|
+
readonly borderRadius: "inherit";
|
|
60
|
+
readonly background: "currentColor";
|
|
61
|
+
readonly opacity: 0;
|
|
62
|
+
readonly pointerEvents: "none";
|
|
63
|
+
readonly transition: import("@behivetech/blocks.core").CssValue;
|
|
64
|
+
};
|
|
65
|
+
readonly "&:hover::after": {
|
|
66
|
+
readonly opacity: import("@behivetech/blocks.core").Token<"number">;
|
|
67
|
+
};
|
|
68
|
+
readonly "&:focus-visible::after": {
|
|
69
|
+
readonly opacity: import("@behivetech/blocks.core").Token<"number">;
|
|
70
|
+
};
|
|
71
|
+
readonly "&:active::after": {
|
|
72
|
+
readonly opacity: import("@behivetech/blocks.core").Token<"number">;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
}>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type StylesFor } from "@behivetech/blocks.core/native";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
import { type PressableProps, type StyleProp, type ViewStyle } from "react-native";
|
|
4
|
+
import { fileDropzone } from "./file-dropzone.block.native";
|
|
5
|
+
/** A file the picker returned. Read it from `uri` (with `expo-file-system`, or upload it from there). */
|
|
6
|
+
export interface PickedFile {
|
|
7
|
+
/** Where the file is, as a `file://` address in the app's cache */
|
|
8
|
+
uri: string;
|
|
9
|
+
/** The file's name, with its extension */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Size in bytes, when the platform says */
|
|
12
|
+
size?: number;
|
|
13
|
+
/** MIME type, when the platform says */
|
|
14
|
+
mimeType?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface FileDropzoneProps extends Omit<PressableProps, "style" | "children" | "onPress" | "disabled"> {
|
|
17
|
+
/** Called with the chosen files; not called when the person cancels the picker */
|
|
18
|
+
onFiles: (files: PickedFile[]) => void;
|
|
19
|
+
/** Called when the picker fails to open or to read a file */
|
|
20
|
+
onError?: (error: unknown) => void;
|
|
21
|
+
/** MIME types the picker offers, separated by commas, e.g. "image/*,application/pdf"; the web's file extensions (`.pdf`) are ignored. Omit for any file. */
|
|
22
|
+
accept?: string;
|
|
23
|
+
/** Whether more than one file can be selected at once; defaults to true */
|
|
24
|
+
multiple?: boolean;
|
|
25
|
+
/** Prompt content; defaults to "Tap to choose files". The label is drawn inside a `Text`; a text label names the button for a screen reader unless you pass an `accessibilityLabel`. */
|
|
26
|
+
label?: ReactNode;
|
|
27
|
+
/** Additional styles, appended after the block's own */
|
|
28
|
+
style?: StyleProp<ViewStyle>;
|
|
29
|
+
/** An override block made with `defineBlock`, typed to this component's children and variants; it wins over the block's own styles. */
|
|
30
|
+
styles?: StylesFor<typeof fileDropzone>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The React Native renderer of FileDropzone: the same block as the web one, as a button that opens the
|
|
34
|
+
* device's file picker (`expo-document-picker`, an optional peer dependency: an Expo app lists it, `npx expo
|
|
35
|
+
* install expo-document-picker`). There is no drag and drop on a phone. `onFiles` receives `PickedFile`s (a
|
|
36
|
+
* `uri`, not the web's `File` objects), and `accept` takes MIME types only. The picker opens once at a time.
|
|
37
|
+
* Your press, hover and focus handlers are called after the block's own, and a `hitSlop` you pass is the button's.
|
|
38
|
+
*/
|
|
39
|
+
export declare const FileDropzone: ({ onFiles, onError, accept, multiple, label, style, styles, ...rest }: FileDropzoneProps) => import("react").JSX.Element;
|
package/docs.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://github.com/behivetech/bht-component-registry/docs.schema.json",
|
|
3
3
|
"version": 2,
|
|
4
|
-
"generatedAt": "2026-11-
|
|
4
|
+
"generatedAt": "2026-11-26T18:10:51.219Z",
|
|
5
5
|
"docs": [
|
|
6
6
|
{
|
|
7
7
|
"displayName": "FileDropzone",
|
|
@@ -42,6 +42,13 @@
|
|
|
42
42
|
"required": false,
|
|
43
43
|
"defaultValue": "true",
|
|
44
44
|
"description": "Whether more than one file can be selected at once; defaults to true"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "styles",
|
|
48
|
+
"type": "StylesFor<Block<\"BHT__FileDropzone\", { readonly a11y: { readonly role: \"button\"; }; readonly position: \"relative\"; readonly display: \"flex\"; readonly alignItems: \"center\"; readonly justifyContent: \"center\"; ... 15 more ...; readonly web: { ...; }; }>>",
|
|
49
|
+
"required": false,
|
|
50
|
+
"defaultValue": null,
|
|
51
|
+
"description": "An override block made with `defineBlock`, typed to this component's children and variants; it wins over the block's own styles."
|
|
45
52
|
}
|
|
46
53
|
]
|
|
47
54
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/* GENERATED from file-dropzone.block.ts by @behivetech/blocks.builder. Do not edit by hand: run `pnpm block:build`. */
|
|
2
|
+
|
|
3
|
+
@layer bht {
|
|
4
|
+
.BHT__FileDropzone {
|
|
5
|
+
position: relative;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
text-align: center;
|
|
10
|
+
min-height: 8rem;
|
|
11
|
+
padding: var(--spacing-6, 1.5rem);
|
|
12
|
+
border: 2px dashed var(--md-sys-color-outline, #777777);
|
|
13
|
+
border-radius: var(--md-sys-shape-corner-medium, 12px);
|
|
14
|
+
color: var(--md-sys-color-on-surface-variant, #474747);
|
|
15
|
+
font-family: var(
|
|
16
|
+
--md-sys-typescale-body-medium-font,
|
|
17
|
+
"Inter",
|
|
18
|
+
system-ui,
|
|
19
|
+
-apple-system,
|
|
20
|
+
sans-serif
|
|
21
|
+
);
|
|
22
|
+
font-size: var(--md-sys-typescale-body-medium-size, 0.875rem);
|
|
23
|
+
font-weight: var(--md-sys-typescale-body-medium-weight, 400);
|
|
24
|
+
line-height: var(--md-sys-typescale-body-medium-line-height, 1.25rem);
|
|
25
|
+
letter-spacing: var(--md-sys-typescale-body-medium-tracking, 0.0179em);
|
|
26
|
+
isolation: isolate;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
transition: border-color var(--md-sys-motion-duration-short-3, 150ms)
|
|
29
|
+
var(--md-sys-motion-easing-standard, cubic-bezier(0.2, 0, 0, 1));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.BHT__FileDropzone:hover {
|
|
33
|
+
border-color: var(--md-sys-color-primary, #64558f);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.BHT__FileDropzone:focus-visible {
|
|
37
|
+
outline-width: 3px;
|
|
38
|
+
outline-style: solid;
|
|
39
|
+
outline-color: var(--md-sys-color-secondary, #615b71);
|
|
40
|
+
outline-offset: 2px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.BHT__FileDropzone::after {
|
|
44
|
+
content: "";
|
|
45
|
+
position: absolute;
|
|
46
|
+
inset: 0;
|
|
47
|
+
border-radius: inherit;
|
|
48
|
+
background: currentColor;
|
|
49
|
+
opacity: 0;
|
|
50
|
+
pointer-events: none;
|
|
51
|
+
transition: opacity var(--md-sys-motion-duration-short-2, 100ms)
|
|
52
|
+
var(--md-sys-motion-easing-standard, cubic-bezier(0.2, 0, 0, 1));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.BHT__FileDropzone:hover::after {
|
|
56
|
+
opacity: var(--md-sys-state-hover-opacity, 0.08);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.BHT__FileDropzone:focus-visible::after {
|
|
60
|
+
opacity: var(--md-sys-state-focus-opacity, 0.1);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.BHT__FileDropzone:active::after {
|
|
64
|
+
opacity: var(--md-sys-state-pressed-opacity, 0.1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.BHT__FileDropzone--dragging.BHT__FileDropzone {
|
|
68
|
+
border-color: var(--md-sys-color-primary, #64558f);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.BHT__FileDropzone--dragging.BHT__FileDropzone::after {
|
|
72
|
+
opacity: var(--md-sys-state-dragged-opacity, 0.16);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// GENERATED from file-dropzone.block.ts by @behivetech/blocks.builder. Do not edit by hand: run `pnpm block:build`.
|
|
2
|
+
import { createNativeBlock as __bhtCreateNativeBlock } from "@behivetech/blocks.core/native";
|
|
3
|
+
import { StyleSheet as __bhtStyleSheet } from "react-native";
|
|
4
|
+
import type { fileDropzone as __bht0_source } from "./file-dropzone.block";
|
|
5
|
+
|
|
6
|
+
// Entries that read no color token are one object in both schemes.
|
|
7
|
+
const __bht0_shared = __bhtStyleSheet.create({});
|
|
8
|
+
const __bht0_light = __bhtStyleSheet.create({
|
|
9
|
+
root: {
|
|
10
|
+
position: "relative",
|
|
11
|
+
display: "flex",
|
|
12
|
+
flexDirection: "row",
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
justifyContent: "center",
|
|
15
|
+
textAlign: "center",
|
|
16
|
+
minHeight: 128,
|
|
17
|
+
paddingTop: 24,
|
|
18
|
+
paddingRight: 24,
|
|
19
|
+
paddingBottom: 24,
|
|
20
|
+
paddingLeft: 24,
|
|
21
|
+
borderTopWidth: 2,
|
|
22
|
+
borderRightWidth: 2,
|
|
23
|
+
borderBottomWidth: 2,
|
|
24
|
+
borderLeftWidth: 2,
|
|
25
|
+
borderStyle: "dashed",
|
|
26
|
+
borderTopColor: "#777777",
|
|
27
|
+
borderRightColor: "#777777",
|
|
28
|
+
borderBottomColor: "#777777",
|
|
29
|
+
borderLeftColor: "#777777",
|
|
30
|
+
borderTopLeftRadius: 12,
|
|
31
|
+
borderTopRightRadius: 12,
|
|
32
|
+
borderBottomRightRadius: 12,
|
|
33
|
+
borderBottomLeftRadius: 12,
|
|
34
|
+
color: "#474747",
|
|
35
|
+
fontFamily: "Inter",
|
|
36
|
+
fontSize: 14,
|
|
37
|
+
fontWeight: "400",
|
|
38
|
+
lineHeight: 20,
|
|
39
|
+
letterSpacing: 0.2506,
|
|
40
|
+
},
|
|
41
|
+
"root:hover": {
|
|
42
|
+
borderTopColor: "#64558f",
|
|
43
|
+
borderRightColor: "#64558f",
|
|
44
|
+
borderBottomColor: "#64558f",
|
|
45
|
+
borderLeftColor: "#64558f",
|
|
46
|
+
},
|
|
47
|
+
"root:focusVisible": {
|
|
48
|
+
outlineWidth: 3,
|
|
49
|
+
outlineStyle: "solid",
|
|
50
|
+
outlineColor: "#615b71",
|
|
51
|
+
outlineOffset: 2,
|
|
52
|
+
},
|
|
53
|
+
"root:pressed": {
|
|
54
|
+
borderTopColor: "#64558f",
|
|
55
|
+
borderRightColor: "#64558f",
|
|
56
|
+
borderBottomColor: "#64558f",
|
|
57
|
+
borderLeftColor: "#64558f",
|
|
58
|
+
},
|
|
59
|
+
"root~text": {
|
|
60
|
+
textAlign: "center",
|
|
61
|
+
color: "#474747",
|
|
62
|
+
fontFamily: "Inter",
|
|
63
|
+
fontSize: 14,
|
|
64
|
+
fontWeight: "400",
|
|
65
|
+
lineHeight: 20,
|
|
66
|
+
letterSpacing: 0.2506,
|
|
67
|
+
},
|
|
68
|
+
"--dragging": {
|
|
69
|
+
borderTopColor: "#64558f",
|
|
70
|
+
borderRightColor: "#64558f",
|
|
71
|
+
borderBottomColor: "#64558f",
|
|
72
|
+
borderLeftColor: "#64558f",
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
const __bht0_dark = __bhtStyleSheet.create({
|
|
76
|
+
root: {
|
|
77
|
+
position: "relative",
|
|
78
|
+
display: "flex",
|
|
79
|
+
flexDirection: "row",
|
|
80
|
+
alignItems: "center",
|
|
81
|
+
justifyContent: "center",
|
|
82
|
+
textAlign: "center",
|
|
83
|
+
minHeight: 128,
|
|
84
|
+
paddingTop: 24,
|
|
85
|
+
paddingRight: 24,
|
|
86
|
+
paddingBottom: 24,
|
|
87
|
+
paddingLeft: 24,
|
|
88
|
+
borderTopWidth: 2,
|
|
89
|
+
borderRightWidth: 2,
|
|
90
|
+
borderBottomWidth: 2,
|
|
91
|
+
borderLeftWidth: 2,
|
|
92
|
+
borderStyle: "dashed",
|
|
93
|
+
borderTopColor: "#919191",
|
|
94
|
+
borderRightColor: "#919191",
|
|
95
|
+
borderBottomColor: "#919191",
|
|
96
|
+
borderLeftColor: "#919191",
|
|
97
|
+
borderTopLeftRadius: 12,
|
|
98
|
+
borderTopRightRadius: 12,
|
|
99
|
+
borderBottomRightRadius: 12,
|
|
100
|
+
borderBottomLeftRadius: 12,
|
|
101
|
+
color: "#c6c6c6",
|
|
102
|
+
fontFamily: "Inter",
|
|
103
|
+
fontSize: 14,
|
|
104
|
+
fontWeight: "400",
|
|
105
|
+
lineHeight: 20,
|
|
106
|
+
letterSpacing: 0.2506,
|
|
107
|
+
},
|
|
108
|
+
"root:hover": {
|
|
109
|
+
borderTopColor: "#cebdfe",
|
|
110
|
+
borderRightColor: "#cebdfe",
|
|
111
|
+
borderBottomColor: "#cebdfe",
|
|
112
|
+
borderLeftColor: "#cebdfe",
|
|
113
|
+
},
|
|
114
|
+
"root:focusVisible": {
|
|
115
|
+
outlineWidth: 3,
|
|
116
|
+
outlineStyle: "solid",
|
|
117
|
+
outlineColor: "#cbc3dc",
|
|
118
|
+
outlineOffset: 2,
|
|
119
|
+
},
|
|
120
|
+
"root:pressed": {
|
|
121
|
+
borderTopColor: "#cebdfe",
|
|
122
|
+
borderRightColor: "#cebdfe",
|
|
123
|
+
borderBottomColor: "#cebdfe",
|
|
124
|
+
borderLeftColor: "#cebdfe",
|
|
125
|
+
},
|
|
126
|
+
"root~text": {
|
|
127
|
+
textAlign: "center",
|
|
128
|
+
color: "#c6c6c6",
|
|
129
|
+
fontFamily: "Inter",
|
|
130
|
+
fontSize: 14,
|
|
131
|
+
fontWeight: "400",
|
|
132
|
+
lineHeight: 20,
|
|
133
|
+
letterSpacing: 0.2506,
|
|
134
|
+
},
|
|
135
|
+
"--dragging": {
|
|
136
|
+
borderTopColor: "#cebdfe",
|
|
137
|
+
borderRightColor: "#cebdfe",
|
|
138
|
+
borderBottomColor: "#cebdfe",
|
|
139
|
+
borderLeftColor: "#cebdfe",
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
export const fileDropzone: typeof __bht0_source = __bhtCreateNativeBlock<
|
|
143
|
+
typeof __bht0_source
|
|
144
|
+
>("BHT__FileDropzone", {
|
|
145
|
+
structure: {
|
|
146
|
+
a11y: { role: "button" },
|
|
147
|
+
children: { label: {} },
|
|
148
|
+
variants: { dragging: { children: {} } },
|
|
149
|
+
},
|
|
150
|
+
sheets: {
|
|
151
|
+
light: { ...__bht0_shared, ...__bht0_light },
|
|
152
|
+
dark: { ...__bht0_shared, ...__bht0_dark },
|
|
153
|
+
},
|
|
154
|
+
plan: {
|
|
155
|
+
root: [
|
|
156
|
+
{ key: "root" },
|
|
157
|
+
{ key: "root:hover", when: { state: "hover" } },
|
|
158
|
+
{ key: "root:focusVisible", when: { state: "focusVisible" } },
|
|
159
|
+
{ key: "root:pressed", when: { state: "pressed" } },
|
|
160
|
+
{ key: "--dragging", when: { variant: "dragging" } },
|
|
161
|
+
],
|
|
162
|
+
children: { label: [{ key: "root~text" }] },
|
|
163
|
+
},
|
|
164
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Converted from file-dropzone.module.scss by `block convert`; this file is the source from here on.
|
|
2
|
+
import { css, defineBlock } from "@behivetech/blocks.core";
|
|
3
|
+
import { tokens } from "@behivetech/blocks.core/tokens";
|
|
4
|
+
const { color, motion, shape, spacing, state, type } = tokens;
|
|
5
|
+
export const fileDropzone = defineBlock("BHT__FileDropzone", {
|
|
6
|
+
a11y: { role: "button" },
|
|
7
|
+
position: "relative",
|
|
8
|
+
display: "flex",
|
|
9
|
+
alignItems: "center",
|
|
10
|
+
justifyContent: "center",
|
|
11
|
+
textAlign: "center",
|
|
12
|
+
minHeight: "8rem",
|
|
13
|
+
padding: spacing[6],
|
|
14
|
+
border: [2, "dashed", color.outline],
|
|
15
|
+
borderRadius: shape.cornerMedium,
|
|
16
|
+
color: color.onSurfaceVariant,
|
|
17
|
+
fontFamily: type.bodyMedium.font,
|
|
18
|
+
fontSize: type.bodyMedium.size,
|
|
19
|
+
fontWeight: type.bodyMedium.weight,
|
|
20
|
+
lineHeight: type.bodyMedium.lineHeight,
|
|
21
|
+
letterSpacing: type.bodyMedium.tracking,
|
|
22
|
+
native: { states: { pressed: { borderColor: color.primary } } },
|
|
23
|
+
states: {
|
|
24
|
+
hover: { borderColor: color.primary },
|
|
25
|
+
focusVisible: {
|
|
26
|
+
outlineWidth: 3,
|
|
27
|
+
outlineStyle: "solid",
|
|
28
|
+
outlineColor: color.secondary,
|
|
29
|
+
outlineOffset: 2,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
// Native only: the prompt's text, which takes the root's text properties as a child does.
|
|
33
|
+
children: { label: {} },
|
|
34
|
+
variants: {
|
|
35
|
+
dragging: {
|
|
36
|
+
borderColor: color.primary,
|
|
37
|
+
web: { "&::after": { opacity: state.draggedOpacity } },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
web: {
|
|
41
|
+
isolation: "isolate",
|
|
42
|
+
cursor: "pointer",
|
|
43
|
+
transition: css`border-color ${motion.durationShort3} ${motion.easingStandard}`,
|
|
44
|
+
"&::after": {
|
|
45
|
+
content: '""',
|
|
46
|
+
position: "absolute",
|
|
47
|
+
inset: 0,
|
|
48
|
+
borderRadius: "inherit",
|
|
49
|
+
background: "currentColor",
|
|
50
|
+
opacity: 0,
|
|
51
|
+
pointerEvents: "none",
|
|
52
|
+
transition: css`opacity ${motion.durationShort2} ${motion.easingStandard}`,
|
|
53
|
+
},
|
|
54
|
+
"&:hover::after": { opacity: state.hoverOpacity },
|
|
55
|
+
"&:focus-visible::after": { opacity: state.focusOpacity },
|
|
56
|
+
"&:active::after": { opacity: state.pressedOpacity },
|
|
57
|
+
},
|
|
58
|
+
});
|