@bosonprotocol/react-kit 0.34.0-alpha.24 → 0.34.0-alpha.26
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/dist/cjs/components/buttons/BaseButton.d.ts.map +1 -1
- package/dist/cjs/components/buttons/BaseButton.js +3 -3
- package/dist/cjs/components/buttons/BaseButton.js.map +1 -1
- package/dist/cjs/components/form/Field.styles.d.ts +1 -0
- package/dist/cjs/components/form/Field.styles.d.ts.map +1 -1
- package/dist/cjs/components/form/Field.styles.js +1 -0
- package/dist/cjs/components/form/Field.styles.js.map +1 -1
- package/dist/cjs/components/form/Upload/BaseUpload.d.ts +6 -0
- package/dist/cjs/components/form/Upload/BaseUpload.d.ts.map +1 -1
- package/dist/cjs/components/form/Upload/BaseUpload.js +34 -16
- package/dist/cjs/components/form/Upload/BaseUpload.js.map +1 -1
- package/dist/cjs/components/form/Upload/WithUploadToIpfs.d.ts +3 -1
- package/dist/cjs/components/form/Upload/WithUploadToIpfs.d.ts.map +1 -1
- package/dist/cjs/components/form/Upload/WithUploadToIpfs.js +5 -1
- package/dist/cjs/components/form/Upload/WithUploadToIpfs.js.map +1 -1
- package/dist/cjs/components/form/types.d.ts +2 -0
- package/dist/cjs/components/form/types.d.ts.map +1 -1
- package/dist/cjs/components/ui/Video.js +1 -1
- package/dist/cjs/components/ui/Video.js.map +1 -1
- package/dist/cjs/components/wallet2/accountDrawer/IconButton.js +4 -3
- package/dist/cjs/components/wallet2/accountDrawer/IconButton.js.map +1 -1
- package/dist/cjs/theme.d.ts +1 -0
- package/dist/cjs/theme.d.ts.map +1 -1
- package/dist/cjs/theme.js +2 -1
- package/dist/cjs/theme.js.map +1 -1
- package/dist/cjs/types/helpers.d.ts +3 -12
- package/dist/cjs/types/helpers.d.ts.map +1 -1
- package/dist/cjs/types/helpers.js +0 -1
- package/dist/cjs/types/helpers.js.map +1 -1
- package/dist/esm/components/buttons/BaseButton.d.ts.map +1 -1
- package/dist/esm/components/buttons/BaseButton.js +3 -3
- package/dist/esm/components/buttons/BaseButton.js.map +1 -1
- package/dist/esm/components/form/Field.styles.d.ts +1 -0
- package/dist/esm/components/form/Field.styles.d.ts.map +1 -1
- package/dist/esm/components/form/Field.styles.js +1 -0
- package/dist/esm/components/form/Field.styles.js.map +1 -1
- package/dist/esm/components/form/Upload/BaseUpload.d.ts +6 -0
- package/dist/esm/components/form/Upload/BaseUpload.d.ts.map +1 -1
- package/dist/esm/components/form/Upload/BaseUpload.js +36 -18
- package/dist/esm/components/form/Upload/BaseUpload.js.map +1 -1
- package/dist/esm/components/form/Upload/WithUploadToIpfs.d.ts +3 -1
- package/dist/esm/components/form/Upload/WithUploadToIpfs.d.ts.map +1 -1
- package/dist/esm/components/form/Upload/WithUploadToIpfs.js +5 -1
- package/dist/esm/components/form/Upload/WithUploadToIpfs.js.map +1 -1
- package/dist/esm/components/form/types.d.ts +2 -0
- package/dist/esm/components/form/types.d.ts.map +1 -1
- package/dist/esm/components/ui/Video.js +1 -1
- package/dist/esm/components/ui/Video.js.map +1 -1
- package/dist/esm/components/wallet2/accountDrawer/IconButton.js +4 -3
- package/dist/esm/components/wallet2/accountDrawer/IconButton.js.map +1 -1
- package/dist/esm/theme.d.ts +1 -0
- package/dist/esm/theme.d.ts.map +1 -1
- package/dist/esm/theme.js +2 -1
- package/dist/esm/theme.js.map +1 -1
- package/dist/esm/types/helpers.d.ts +3 -12
- package/dist/esm/types/helpers.d.ts.map +1 -1
- package/dist/esm/types/helpers.js +0 -1
- package/dist/esm/types/helpers.js.map +1 -1
- package/package.json +5 -5
- package/src/components/buttons/BaseButton.tsx +11 -10
- package/src/components/form/Field.styles.ts +5 -1
- package/src/components/form/Upload/BaseUpload.tsx +39 -21
- package/src/components/form/Upload/WithUploadToIpfs.tsx +8 -2
- package/src/components/form/types.ts +5 -1
- package/src/components/ui/Video.tsx +1 -1
- package/src/components/wallet2/accountDrawer/IconButton.tsx +4 -4
- package/src/stories/buttons/Upload.stories.tsx +9 -7
- package/src/theme.ts +2 -1
- package/src/types/helpers.ts +3 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/types/helpers.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAI,CAAY,EAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/types/helpers.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAI,CAAY,EAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bosonprotocol/react-kit",
|
|
3
3
|
"description": "React toolkit with smart components and hooks for building on top of the Boson Protocol.",
|
|
4
|
-
"version": "0.34.0-alpha.
|
|
4
|
+
"version": "0.34.0-alpha.26",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
7
7
|
"types": "./dist/cjs/index.d.ts",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"license": "Apache-2.0",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@bosonprotocol/chat-sdk": "^1.3.1-alpha.9",
|
|
18
|
-
"@bosonprotocol/core-sdk": "^1.41.0-alpha.
|
|
19
|
-
"@bosonprotocol/ethers-sdk": "^1.15.0-alpha.
|
|
20
|
-
"@bosonprotocol/ipfs-storage": "^1.12.0-alpha.
|
|
18
|
+
"@bosonprotocol/core-sdk": "^1.41.0-alpha.28",
|
|
19
|
+
"@bosonprotocol/ethers-sdk": "^1.15.0-alpha.14",
|
|
20
|
+
"@bosonprotocol/ipfs-storage": "^1.12.0-alpha.26",
|
|
21
21
|
"@davatar/react": "1.11.1",
|
|
22
22
|
"@ethersproject/units": "5.6.0",
|
|
23
23
|
"@glidejs/glide": "3.6.0",
|
|
@@ -188,5 +188,5 @@
|
|
|
188
188
|
"overrides": {
|
|
189
189
|
"typescript": "^5.1.6"
|
|
190
190
|
},
|
|
191
|
-
"gitHead": "
|
|
191
|
+
"gitHead": "71dd801decf1b8f99fab70dac84fcdd8482a2b99"
|
|
192
192
|
}
|
|
@@ -13,16 +13,17 @@ import { Typography } from "../ui/Typography";
|
|
|
13
13
|
import { theme } from "../../theme";
|
|
14
14
|
import { Loading } from "../ui/loading/Loading";
|
|
15
15
|
import { ButtonSize } from "../ui/buttonSize";
|
|
16
|
-
|
|
16
|
+
import { AddDollarPrefixToKeys } from "../../types/helpers";
|
|
17
17
|
const colors = theme.colors.light;
|
|
18
18
|
|
|
19
|
-
const ButtonWithThemeProps = styled.button<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
19
|
+
const ButtonWithThemeProps = styled.button<
|
|
20
|
+
AddDollarPrefixToKeys<{
|
|
21
|
+
size: ButtonSizeProp;
|
|
22
|
+
fill: boolean | undefined;
|
|
23
|
+
}> & { theme: BaseButtonTheme }
|
|
24
|
+
>`
|
|
24
25
|
${() => Styles.button};
|
|
25
|
-
${(props) => Styles[props
|
|
26
|
+
${(props) => Styles[props.$size as keyof typeof Styles]}
|
|
26
27
|
border-style: solid;
|
|
27
28
|
border-color: ${(props) => props.theme?.borderColor || "transparent"};
|
|
28
29
|
border-width: ${(props) => props.theme?.borderWidth || 0}px;
|
|
@@ -35,7 +36,7 @@ const ButtonWithThemeProps = styled.button<{
|
|
|
35
36
|
stroke: ${(props) => props.theme?.color || "#000000"};
|
|
36
37
|
}
|
|
37
38
|
${(props) =>
|
|
38
|
-
props
|
|
39
|
+
props.$fill
|
|
39
40
|
? css`
|
|
40
41
|
width: 100%;
|
|
41
42
|
`
|
|
@@ -175,8 +176,8 @@ export const BaseButton = forwardRef<HTMLButtonElement, BaseButtonProps>(
|
|
|
175
176
|
<ButtonWithThemeProps
|
|
176
177
|
onClick={onClick}
|
|
177
178
|
type={type}
|
|
178
|
-
size={size}
|
|
179
|
-
fill={fill ? fill : undefined}
|
|
179
|
+
$size={size}
|
|
180
|
+
$fill={fill ? fill : undefined}
|
|
180
181
|
theme={theme}
|
|
181
182
|
{...rest}
|
|
182
183
|
ref={ref}
|
|
@@ -125,6 +125,7 @@ export type FileUploadWrapperTheme = Partial<{
|
|
|
125
125
|
error: Partial<{
|
|
126
126
|
borderColor: CSSProperties["borderColor"];
|
|
127
127
|
}>;
|
|
128
|
+
overrides: Partial<CSSProperties>;
|
|
128
129
|
}>;
|
|
129
130
|
export const FileUploadWrapper = styled.div<{
|
|
130
131
|
$error: unknown;
|
|
@@ -188,13 +189,16 @@ export const FileUploadWrapper = styled.div<{
|
|
|
188
189
|
cursor: not-allowed;
|
|
189
190
|
opacity: 0.5;
|
|
190
191
|
}
|
|
192
|
+
${({ theme: { overrides } }) => overrides}
|
|
191
193
|
`;
|
|
192
194
|
|
|
193
195
|
export const FieldFileUpload = styled(FieldInput)`
|
|
194
196
|
display: none;
|
|
195
197
|
`;
|
|
196
198
|
|
|
197
|
-
export const FieldFileUploadWrapper = styled.div<{
|
|
199
|
+
export const FieldFileUploadWrapper = styled.div<{
|
|
200
|
+
$disabled: boolean;
|
|
201
|
+
}>`
|
|
198
202
|
position: relative;
|
|
199
203
|
display: inline-block;
|
|
200
204
|
${({ $disabled }) =>
|
|
@@ -9,7 +9,7 @@ import { theme } from "../../../theme";
|
|
|
9
9
|
import Loading from "../../ui/loading/LoadingWrapper";
|
|
10
10
|
import ThemedButton from "../../ui/ThemedButton";
|
|
11
11
|
import { Typography } from "../../ui/Typography";
|
|
12
|
-
import
|
|
12
|
+
import ErrorComponent from "../Error";
|
|
13
13
|
import {
|
|
14
14
|
FieldFileUploadWrapper,
|
|
15
15
|
FieldInput,
|
|
@@ -52,6 +52,7 @@ function BaseUpload({
|
|
|
52
52
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
53
53
|
removeFile,
|
|
54
54
|
saveButtonTheme,
|
|
55
|
+
errorComponent,
|
|
55
56
|
theme,
|
|
56
57
|
...props
|
|
57
58
|
}: UploadPropsWithNoIpfs & WithUploadToIpfsProps) {
|
|
@@ -60,6 +61,7 @@ function BaseUpload({
|
|
|
60
61
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
61
62
|
const [preview, setPreview] = useState<string | null>();
|
|
62
63
|
const [field, meta, helpers] = useField(name);
|
|
64
|
+
const [errorMesage, setErrorMessage] = useState<string>();
|
|
63
65
|
|
|
64
66
|
const handleLoading = useCallback(
|
|
65
67
|
(loadingValue: boolean) => {
|
|
@@ -123,12 +125,12 @@ function BaseUpload({
|
|
|
123
125
|
}
|
|
124
126
|
handleLoading(true);
|
|
125
127
|
try {
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
128
|
-
setPreview(
|
|
128
|
+
const videoPreview = await loadMedia(fileSrc || "");
|
|
129
|
+
if (videoPreview) {
|
|
130
|
+
setPreview(videoPreview);
|
|
129
131
|
} else {
|
|
130
132
|
console.warn(
|
|
131
|
-
`
|
|
133
|
+
`videoPreview ${videoPreview} is falsy in loadIpfsImagePreview`
|
|
132
134
|
);
|
|
133
135
|
}
|
|
134
136
|
} catch (error) {
|
|
@@ -216,16 +218,26 @@ function BaseUpload({
|
|
|
216
218
|
helpers.setTouched(true);
|
|
217
219
|
}
|
|
218
220
|
handleLoading(true);
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
221
|
+
try {
|
|
222
|
+
const files = await saveToIpfs(efiles, { throwOnError: true });
|
|
223
|
+
setErrorMessage(undefined);
|
|
224
|
+
if (files) {
|
|
225
|
+
setFiles(files);
|
|
226
|
+
} else {
|
|
227
|
+
setFiles([]);
|
|
228
|
+
console.warn(
|
|
229
|
+
`There has been an error because 'files' ${files} is falsy in handleSave`
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
} catch (err) {
|
|
233
|
+
if (err instanceof Error) {
|
|
234
|
+
setErrorMessage(err.message);
|
|
235
|
+
} else {
|
|
236
|
+
setErrorMessage("Something went wrong");
|
|
237
|
+
}
|
|
238
|
+
} finally {
|
|
239
|
+
handleLoading(false);
|
|
227
240
|
}
|
|
228
|
-
handleLoading(false);
|
|
229
241
|
},
|
|
230
242
|
[meta.touched, handleLoading, saveToIpfs, helpers, setFiles]
|
|
231
243
|
);
|
|
@@ -234,6 +246,7 @@ function BaseUpload({
|
|
|
234
246
|
borderRadius: borderRadius ? `${borderRadius}${borderRadiusUnit}` : "",
|
|
235
247
|
width: width ? `100%` : ""
|
|
236
248
|
};
|
|
249
|
+
const showPreview = field.value && field.value?.length !== 0 && preview;
|
|
237
250
|
return (
|
|
238
251
|
<>
|
|
239
252
|
{withEditor && showEditor && (
|
|
@@ -262,6 +275,7 @@ function BaseUpload({
|
|
|
262
275
|
}}
|
|
263
276
|
/>
|
|
264
277
|
)}
|
|
278
|
+
{errorMesage && errorComponent?.(errorMesage)}
|
|
265
279
|
<FieldFileUploadWrapper {...wrapperProps} $disabled={!!disabled}>
|
|
266
280
|
<FieldInput
|
|
267
281
|
{...props}
|
|
@@ -313,17 +327,21 @@ function BaseUpload({
|
|
|
313
327
|
<Loading size={2} />
|
|
314
328
|
) : (
|
|
315
329
|
<>
|
|
316
|
-
{
|
|
330
|
+
{showPreview ? (
|
|
317
331
|
<>
|
|
318
332
|
{isVideoOnly ? (
|
|
319
333
|
<VideoPreview
|
|
320
334
|
src={
|
|
321
335
|
preview?.startsWith("http")
|
|
322
336
|
? preview
|
|
323
|
-
:
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
337
|
+
: preview?.startsWith(
|
|
338
|
+
"data:application/octet-stream;base64,"
|
|
339
|
+
)
|
|
340
|
+
? "data:video/mp4;base64," +
|
|
341
|
+
preview?.substring(
|
|
342
|
+
"data:application/octet-stream;base64,".length
|
|
343
|
+
)
|
|
344
|
+
: preview
|
|
327
345
|
}
|
|
328
346
|
autoPlay
|
|
329
347
|
muted
|
|
@@ -341,7 +359,7 @@ function BaseUpload({
|
|
|
341
359
|
) : (
|
|
342
360
|
<Image size={24} />
|
|
343
361
|
)}
|
|
344
|
-
{placeholder && (
|
|
362
|
+
{placeholder && !showPreview && (
|
|
345
363
|
<Typography tag="p" marginBottom={0} textAlign="center">
|
|
346
364
|
{placeholder}
|
|
347
365
|
</Typography>
|
|
@@ -359,7 +377,7 @@ function BaseUpload({
|
|
|
359
377
|
<UploadedFiles files={files} handleRemoveFile={handleRemoveFile} />
|
|
360
378
|
)}
|
|
361
379
|
</FieldFileUploadWrapper>
|
|
362
|
-
<
|
|
380
|
+
<ErrorComponent display={displayError} message={errorMessage} />
|
|
363
381
|
</>
|
|
364
382
|
);
|
|
365
383
|
}
|
|
@@ -22,7 +22,8 @@ export const SUPPORTED_FORMATS = [
|
|
|
22
22
|
];
|
|
23
23
|
export interface WithUploadToIpfsProps {
|
|
24
24
|
saveToIpfs: (
|
|
25
|
-
files: File[] | null
|
|
25
|
+
files: File[] | null,
|
|
26
|
+
options?: { throwOnError?: boolean }
|
|
26
27
|
) => Promise<false | FileProps[] | undefined>;
|
|
27
28
|
loadMedia: (src: string) => Promise<string | undefined>;
|
|
28
29
|
removeFile: (src: string) => Promise<void>;
|
|
@@ -39,7 +40,10 @@ export function WithUploadToIpfs<P extends WithUploadToIpfsProps>(
|
|
|
39
40
|
const { saveFile, loadMedia, removeFile } = useSaveImageToIpfs();
|
|
40
41
|
|
|
41
42
|
const saveToIpfs: WithUploadToIpfsProps["saveToIpfs"] = useCallback(
|
|
42
|
-
async (
|
|
43
|
+
async (
|
|
44
|
+
filesArray: File[] | null,
|
|
45
|
+
options: { throwOnError?: boolean } = {}
|
|
46
|
+
) => {
|
|
43
47
|
if (!filesArray) {
|
|
44
48
|
return;
|
|
45
49
|
}
|
|
@@ -53,10 +57,12 @@ export function WithUploadToIpfs<P extends WithUploadToIpfsProps>(
|
|
|
53
57
|
const err = `File ${
|
|
54
58
|
file?.name
|
|
55
59
|
} size cannot exceed more than ${bytesToSize(sizeValidation)}!`;
|
|
60
|
+
if (options?.throwOnError) throw new Error(err);
|
|
56
61
|
filesErrors.push(err);
|
|
57
62
|
}
|
|
58
63
|
if (!formatValidation.includes(file?.type)) {
|
|
59
64
|
const err = `Uploaded file has unsupported format of ${file?.type}!`;
|
|
65
|
+
if (options?.throwOnError) throw new Error(err);
|
|
60
66
|
filesErrors.push(err);
|
|
61
67
|
}
|
|
62
68
|
}
|
|
@@ -137,8 +137,12 @@ export type UploadProps = BaseProps & {
|
|
|
137
137
|
borderRadiusUnit?: "px" | "%";
|
|
138
138
|
width?: number;
|
|
139
139
|
height?: number;
|
|
140
|
+
errorComponent?: (errorMessage: string) => React.ReactNode;
|
|
140
141
|
imgPreviewStyle?: Pick<CSSProperties, "objectFit">;
|
|
141
|
-
theme?: Partial<{
|
|
142
|
+
theme?: Partial<{
|
|
143
|
+
triggerTheme: FileUploadWrapperTheme;
|
|
144
|
+
overrides: React.CSSProperties;
|
|
145
|
+
}>;
|
|
142
146
|
} & (
|
|
143
147
|
| {
|
|
144
148
|
withEditor: true;
|
|
@@ -198,7 +198,7 @@ export const Video: React.FC<VideoProps> = ({
|
|
|
198
198
|
return <ComponentWhileLoading />;
|
|
199
199
|
}
|
|
200
200
|
return (
|
|
201
|
-
<VideoWrapper {...rest}>
|
|
201
|
+
<VideoWrapper {...rest} className="video-container">
|
|
202
202
|
<VideoPlaceholder $position="static">
|
|
203
203
|
<Typography tag="div">
|
|
204
204
|
<Loading />
|
|
@@ -112,19 +112,19 @@ const IconBlock = forwardRef<
|
|
|
112
112
|
borderRadius: CSSProperties["borderRadius"];
|
|
113
113
|
}
|
|
114
114
|
>(function IconBlock(props, ref) {
|
|
115
|
-
const { color, backgroundColor, borderRadius } = props;
|
|
116
115
|
if ("href" in props) {
|
|
116
|
+
const { color, backgroundColor, borderRadius, ...restProps } = props;
|
|
117
117
|
return (
|
|
118
118
|
<IconBlockLink
|
|
119
119
|
ref={ref as React.ForwardedRef<HTMLAnchorElement>}
|
|
120
120
|
$color={color}
|
|
121
121
|
$backgroundColor={backgroundColor}
|
|
122
122
|
$borderRadius={borderRadius}
|
|
123
|
-
{...
|
|
123
|
+
{...restProps}
|
|
124
124
|
/>
|
|
125
125
|
);
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
const { color, backgroundColor, borderRadius, ...restProps } = props;
|
|
128
128
|
return (
|
|
129
129
|
<IconBlockButton
|
|
130
130
|
// ignoring 'button' 'type' conflict between React and styled-components
|
|
@@ -134,7 +134,7 @@ const IconBlock = forwardRef<
|
|
|
134
134
|
$color={color}
|
|
135
135
|
$backgroundColor={backgroundColor}
|
|
136
136
|
$borderRadius={borderRadius}
|
|
137
|
-
{...
|
|
137
|
+
{...restProps}
|
|
138
138
|
/>
|
|
139
139
|
);
|
|
140
140
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Meta } from "@storybook/react";
|
|
3
|
-
import { QueryClientProviderCustom, Upload } from "../..";
|
|
3
|
+
import { BaseUploadProps, QueryClientProviderCustom, Upload } from "../..";
|
|
4
4
|
import { EnvironmentProvider } from "../../components/environment/EnvironmentProvider";
|
|
5
5
|
import { IpfsProvider } from "../../components/ipfs/IpfsProvider";
|
|
6
6
|
import { Formik } from "formik";
|
|
@@ -20,7 +20,6 @@ export default {
|
|
|
20
20
|
},
|
|
21
21
|
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
22
22
|
tags: ["autodocs"],
|
|
23
|
-
// args: { onClick: fn() },
|
|
24
23
|
argTypes: {
|
|
25
24
|
name: {
|
|
26
25
|
table: {
|
|
@@ -69,20 +68,23 @@ export default {
|
|
|
69
68
|
} satisfies Meta<typeof Upload>;
|
|
70
69
|
|
|
71
70
|
const BASE_ARGS = {
|
|
72
|
-
name
|
|
73
|
-
|
|
71
|
+
name,
|
|
72
|
+
placeholder: "",
|
|
73
|
+
withEditor: false,
|
|
74
|
+
saveButtonTheme: undefined
|
|
75
|
+
} as const satisfies BaseUploadProps;
|
|
74
76
|
|
|
75
77
|
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
76
78
|
export const Base = {
|
|
77
79
|
args: {
|
|
78
80
|
...BASE_ARGS
|
|
79
|
-
}
|
|
81
|
+
} satisfies BaseUploadProps
|
|
80
82
|
};
|
|
81
83
|
|
|
82
84
|
export const VideoOnly = {
|
|
83
85
|
args: {
|
|
84
86
|
...BASE_ARGS,
|
|
85
87
|
accept: "video/mp4",
|
|
86
|
-
withUpload:
|
|
87
|
-
}
|
|
88
|
+
withUpload: false
|
|
89
|
+
} satisfies BaseUploadProps
|
|
88
90
|
};
|
package/src/theme.ts
CHANGED
package/src/types/helpers.ts
CHANGED
|
@@ -13,30 +13,6 @@ type Falsy = false | 0 | "" | null | undefined;
|
|
|
13
13
|
|
|
14
14
|
export const isTruthy = <T>(x: T | Falsy): x is T => !!x;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} extends { [_ in keyof T]: infer U }
|
|
20
|
-
? {} extends U
|
|
21
|
-
? never
|
|
22
|
-
: U
|
|
23
|
-
: never; // I don't know why not just U work here, but ({} extends U ? never : U) work
|
|
24
|
-
|
|
25
|
-
type OmitFromKnownKeys<T, K extends keyof T> =
|
|
26
|
-
KnownKeys<T> extends infer U
|
|
27
|
-
? [U] extends [keyof T]
|
|
28
|
-
? Pick<T, Exclude<U, K>>
|
|
29
|
-
: never
|
|
30
|
-
: never;
|
|
31
|
-
export type ExtendedOmit<T, K extends keyof T> = OmitFromKnownKeys<T, K> &
|
|
32
|
-
(string extends K
|
|
33
|
-
? {}
|
|
34
|
-
: string extends keyof T
|
|
35
|
-
? { [n: string]: T[Exclude<keyof T, number>] }
|
|
36
|
-
: {}) & // support number property
|
|
37
|
-
(number extends K
|
|
38
|
-
? {}
|
|
39
|
-
: number extends keyof T
|
|
40
|
-
? { [n: number]: T[Exclude<keyof T, string>] }
|
|
41
|
-
: {}); // support number property
|
|
42
|
-
//#endregion
|
|
16
|
+
export type AddDollarPrefixToKeys<T> = {
|
|
17
|
+
[K in keyof T as `$${string & K}`]: T[K];
|
|
18
|
+
};
|