@swan-io/shared-business 2.7.38 → 3.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.
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box } from "@swan-io/lake/src/components/Box";
3
+ import { LakeAlert } from "@swan-io/lake/src/components/LakeAlert";
4
+ import { LakeButton } from "@swan-io/lake/src/components/LakeButton";
5
+ import { LakeText } from "@swan-io/lake/src/components/LakeText";
6
+ import { Space } from "@swan-io/lake/src/components/Space";
7
+ import { Tag } from "@swan-io/lake/src/components/Tag";
8
+ import { commonStyles } from "@swan-io/lake/src/constants/commonStyles";
9
+ import { backgroundColor, colors, shadows, spacings } from "@swan-io/lake/src/constants/design";
10
+ import { getIconNameFromFilename } from "@swan-io/lake/src/utils/file";
11
+ import { isNotNullish, isNotNullishOrEmpty } from "@swan-io/lake/src/utils/nullish";
12
+ import { StyleSheet } from "react-native";
13
+ import { match } from "ts-pattern";
14
+ import { t } from "../utils/i18n";
15
+ const styles = StyleSheet.create({
16
+ base: {
17
+ backgroundColor: backgroundColor.accented,
18
+ borderRadius: 8,
19
+ boxShadow: shadows.tile,
20
+ overflow: "hidden",
21
+ },
22
+ content: {
23
+ height: 56,
24
+ paddingLeft: spacings[20],
25
+ paddingRight: spacings[8],
26
+ },
27
+ });
28
+ export const FileTile = ({ variant = "none", name, url, onRemove, title, description }) => (_jsxs(Box, { style: styles.base, children: [_jsxs(Box, { alignItems: "center", direction: "row", style: styles.content, children: [_jsx(Tag, { icon: getIconNameFromFilename(name), iconSize: 20, color: match(variant)
29
+ .with("none", "pending", () => "shakespear")
30
+ .with("verified", () => "positive")
31
+ .with("refused", () => "negative")
32
+ .exhaustive() }), _jsx(Space, { width: 16 }), _jsx(LakeText, { numberOfLines: 1, color: colors.gray[700], style: commonStyles.fill, children: name }), _jsx(Space, { width: 12 }), isNotNullishOrEmpty(url) && (_jsx(LakeButton, { mode: "tertiary", size: "small", icon: "open-filled", onPress: () => {
33
+ window.open(url, "_blank");
34
+ }, ariaLabel: t("common.open") })), isNotNullish(onRemove) && (_jsx(LakeButton, { mode: "tertiary", size: "small", icon: "delete-regular", color: "negative", onPress: onRemove, ariaLabel: t("common.remove") }))] }), variant !== "none" && (_jsx(LakeAlert, { anchored: true, title: title, variant: match(variant)
35
+ .with("pending", () => "info")
36
+ .with("verified", () => "success")
37
+ .with("refused", () => "error")
38
+ .exhaustive(), children: description }))] }));
@@ -0,0 +1,14 @@
1
+ import { IconName } from "@swan-io/lake/src/components/Icon";
2
+ import { Context } from "@swan-io/lake/src/components/ResponsiveContainer";
3
+ import { ColorVariants } from "@swan-io/lake/src/constants/design";
4
+ import { ReactNode } from "react";
5
+ export type LakeModalProps = {
6
+ visible: boolean;
7
+ title?: string;
8
+ icon?: IconName;
9
+ color?: ColorVariants;
10
+ children: ReactNode | ((context: Context) => ReactNode);
11
+ maxWidth?: number;
12
+ onPressClose?: () => void;
13
+ };
14
+ export declare const LakeModal: ({ visible, icon, title, color, children, maxWidth, onPressClose, }: LakeModalProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,136 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { FocusTrap } from "@swan-io/lake/src/components/FocusTrap";
3
+ import { Icon } from "@swan-io/lake/src/components/Icon";
4
+ import { LakeButton } from "@swan-io/lake/src/components/LakeButton";
5
+ import { LakeHeading } from "@swan-io/lake/src/components/LakeHeading";
6
+ import { LoadingView } from "@swan-io/lake/src/components/LoadingView";
7
+ import { Portal } from "@swan-io/lake/src/components/Portal";
8
+ import { Pressable } from "@swan-io/lake/src/components/Pressable";
9
+ import { ResponsiveContainer } from "@swan-io/lake/src/components/ResponsiveContainer";
10
+ import { Space } from "@swan-io/lake/src/components/Space";
11
+ import { TransitionView } from "@swan-io/lake/src/components/TransitionView";
12
+ import { commonStyles } from "@swan-io/lake/src/constants/commonStyles";
13
+ import { backgroundColor, breakpoints, colors, negativeSpacings, shadows, spacings, } from "@swan-io/lake/src/constants/design";
14
+ import { useBodyClassName } from "@swan-io/lake/src/hooks/useBodyClassName";
15
+ import { Suspense, useEffect, useState } from "react";
16
+ import { ScrollView, StyleSheet, View } from "react-native";
17
+ import { t } from "../utils/i18n";
18
+ const BACKGROUND_COLOR = "rgba(0, 0, 0, 0.6)";
19
+ const styles = StyleSheet.create({
20
+ root: {
21
+ ...StyleSheet.absoluteFillObject,
22
+ },
23
+ container: {
24
+ ...StyleSheet.absoluteFillObject,
25
+ },
26
+ inert: {
27
+ pointerEvents: "none",
28
+ },
29
+ fill: {
30
+ ...StyleSheet.absoluteFillObject,
31
+ animationFillMode: "forwards",
32
+ },
33
+ overlay: {
34
+ ...StyleSheet.absoluteFillObject,
35
+ backgroundColor: BACKGROUND_COLOR,
36
+ },
37
+ overlayEnter: {
38
+ animationKeyframes: {
39
+ "0%": { opacity: 0 },
40
+ },
41
+ animationDuration: "200ms",
42
+ animationTimingFunction: "ease-in-out",
43
+ },
44
+ overlayLeave: {
45
+ animationKeyframes: {
46
+ "100%": { opacity: 0 },
47
+ },
48
+ animationDuration: "200ms",
49
+ animationTimingFunction: "ease-in-out",
50
+ },
51
+ modalEnter: {
52
+ animationKeyframes: {
53
+ "0%": {
54
+ opacity: 0,
55
+ transform: "translateY(-20px)",
56
+ },
57
+ },
58
+ animationDuration: "300ms",
59
+ animationTimingFunction: "ease-in-out",
60
+ },
61
+ modalLeave: {
62
+ animationKeyframes: {
63
+ "100%": {
64
+ opacity: 0,
65
+ transform: "translateY(-20px)",
66
+ },
67
+ },
68
+ animationDuration: "300ms",
69
+ animationTimingFunction: "ease-in-out",
70
+ },
71
+ modalContainer: {
72
+ ...StyleSheet.absoluteFillObject,
73
+ },
74
+ modalContentContainer: {
75
+ padding: spacings[24],
76
+ justifyContent: "center",
77
+ flexGrow: 1,
78
+ },
79
+ modalContentContainerSmall: {
80
+ padding: spacings[8],
81
+ flexGrow: 1,
82
+ justifyContent: "center",
83
+ },
84
+ modal: {
85
+ backgroundColor: backgroundColor.default,
86
+ borderRadius: 24,
87
+ padding: spacings[48],
88
+ boxShadow: shadows.modal,
89
+ alignSelf: "stretch",
90
+ width: "100%",
91
+ marginHorizontal: "auto",
92
+ },
93
+ modalSmall: {
94
+ borderRadius: 16,
95
+ backgroundColor: backgroundColor.default,
96
+ width: "100%",
97
+ padding: spacings[24],
98
+ alignSelf: "stretch",
99
+ marginHorizontal: "auto",
100
+ },
101
+ modalHeader: {
102
+ display: "flex",
103
+ flexDirection: "row",
104
+ justifyContent: "space-between",
105
+ },
106
+ modalIconTitle: {
107
+ ...commonStyles.fill,
108
+ },
109
+ trap: {
110
+ ...commonStyles.fill,
111
+ },
112
+ pressableOverlay: {
113
+ ...StyleSheet.absoluteFillObject,
114
+ },
115
+ closeButton: {
116
+ top: negativeSpacings[16],
117
+ right: negativeSpacings[16],
118
+ },
119
+ });
120
+ export const LakeModal = ({ visible, icon, title, color = "current", children, maxWidth = 570, onPressClose, }) => {
121
+ const [rootElement, setRootElement] = useState(() => undefined);
122
+ useEffect(() => {
123
+ const rootElement = document.createElement("div");
124
+ document.body.append(rootElement);
125
+ setRootElement(rootElement);
126
+ return () => {
127
+ rootElement.remove();
128
+ setRootElement(undefined);
129
+ };
130
+ }, []);
131
+ useBodyClassName("ModalOpen", { enabled: visible });
132
+ if (rootElement == null) {
133
+ return null;
134
+ }
135
+ return (_jsx(Portal, { container: rootElement, children: _jsxs(View, { "aria-modal": true, style: [styles.container, !visible && styles.inert], children: [_jsx(TransitionView, { style: styles.fill, enter: styles.overlayEnter, leave: styles.overlayLeave, children: visible ? _jsx(View, { style: styles.overlay }) : null }), _jsx(Suspense, { fallback: _jsx(LoadingView, { color: backgroundColor.accented, delay: 0 }), children: _jsx(TransitionView, { style: styles.fill, enter: styles.modalEnter, leave: styles.modalLeave, children: visible ? (_jsx(ResponsiveContainer, { style: styles.root, breakpoint: breakpoints.tiny, children: ({ large, small }) => (_jsx(FocusTrap, { autoFocus: true, focusLock: true, returnFocus: true, onEscapeKey: onPressClose, style: styles.trap, children: _jsxs(ScrollView, { style: styles.modalContainer, contentContainerStyle: large ? styles.modalContentContainer : styles.modalContentContainerSmall, children: [onPressClose != null ? (_jsx(Pressable, { onPress: onPressClose, style: styles.pressableOverlay })) : null, _jsxs(View, { role: "dialog", style: [large ? styles.modal : styles.modalSmall, { maxWidth }], children: [_jsxs(View, { style: styles.modalHeader, children: [_jsxs(View, { style: styles.modalIconTitle, children: [icon != null ? (_jsx(Icon, { name: icon, size: large ? 40 : 32, color: colors[color][500] })) : null, icon != null && title != null ? _jsx(Space, { height: 12 }) : null, title != null ? (_jsxs(_Fragment, { children: [_jsx(LakeHeading, { level: 2, variant: "h3", children: title }), _jsx(Space, { height: 12 })] })) : null] }), onPressClose != null ? (_jsx(LakeButton, { style: styles.closeButton, mode: "tertiary", onPress: onPressClose, icon: "lake-close", ariaLabel: t("common.close") })) : null] }), typeof children == "function" ? children({ large, small }) : children] })] }) })) })) : null }) })] }) }));
136
+ };
@@ -2,7 +2,6 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import { Form } from "@swan-io/lake/src/components/Form";
3
3
  import { LakeButton, LakeButtonGroup } from "@swan-io/lake/src/components/LakeButton";
4
4
  import { LakeLabel } from "@swan-io/lake/src/components/LakeLabel";
5
- import { LakeModal } from "@swan-io/lake/src/components/LakeModal";
6
5
  import { LakeText } from "@swan-io/lake/src/components/LakeText";
7
6
  import { LakeTooltip } from "@swan-io/lake/src/components/LakeTooltip";
8
7
  import { Space } from "@swan-io/lake/src/components/Space";
@@ -13,6 +12,7 @@ import { useForm } from "react-ux-form";
13
12
  import { match } from "ts-pattern";
14
13
  import { MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE, MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE_MB, } from "../constants/uploads";
15
14
  import { locale, t } from "../utils/i18n";
15
+ import { LakeModal } from "./LakeModal";
16
16
  import { UploadArea } from "./UploadArea";
17
17
  const ACCEPTED_FORMATS = ["application/pdf", "image/png", "image/jpeg"];
18
18
  const NO_ID_YET = "NO_ID_YET";
@@ -1,3 +1,4 @@
1
+ import { AsyncData } from "@swan-io/boxed";
1
2
  import { IconName } from "@swan-io/lake/src/components/Icon";
2
3
  import { DropzoneOptions } from "react-dropzone";
3
4
  export type UploadFileStatus = ({
@@ -16,9 +17,10 @@ export type UploadFileStatus = ({
16
17
  type Props = {
17
18
  icon: IconName;
18
19
  documents?: UploadFileStatus[];
19
- onRemoveFile?: (fileId: string) => void;
20
+ onRemoveDocument?: (fileId: string) => void;
21
+ onRemoveFile?: () => void;
20
22
  accept: string[];
21
- value?: File | Element;
23
+ value?: AsyncData<File>;
22
24
  disabled?: boolean;
23
25
  onDropAccepted?: DropzoneOptions["onDropAccepted"];
24
26
  onDropRejected?: DropzoneOptions["onDropRejected"];
@@ -27,5 +29,5 @@ type Props = {
27
29
  error?: string;
28
30
  maxSize?: number;
29
31
  };
30
- export declare const UploadArea: ({ icon, accept, value, documents, disabled, onRemoveFile, onDropAccepted, onDropRejected, layout, description, error, maxSize, }: Props) => import("react/jsx-runtime").JSX.Element;
32
+ export declare const UploadArea: ({ icon, accept, value, documents, disabled, onRemoveFile, onRemoveDocument, onDropAccepted, onDropRejected, layout, description, error, maxSize, }: Props) => import("react/jsx-runtime").JSX.Element;
31
33
  export {};
@@ -1,16 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Box } from "@swan-io/lake/src/components/Box";
3
- import { FileTile } from "@swan-io/lake/src/components/FileTile";
4
3
  import { Icon } from "@swan-io/lake/src/components/Icon";
4
+ import { LakeButton } from "@swan-io/lake/src/components/LakeButton";
5
5
  import { LakeHeading } from "@swan-io/lake/src/components/LakeHeading";
6
6
  import { LakeText } from "@swan-io/lake/src/components/LakeText";
7
+ import { LoadingView } from "@swan-io/lake/src/components/LoadingView";
7
8
  import { Space } from "@swan-io/lake/src/components/Space";
8
9
  import { commonStyles } from "@swan-io/lake/src/constants/commonStyles";
9
10
  import { backgroundColor, colors, gray75, radii, shadows, spacings, } from "@swan-io/lake/src/constants/design";
10
11
  import { useBoolean } from "@swan-io/lake/src/hooks/useBoolean";
11
12
  import { getIconNameFromFilename } from "@swan-io/lake/src/utils/file";
12
13
  import { isNotNullish } from "@swan-io/lake/src/utils/nullish";
13
- import { Fragment, useLayoutEffect, useRef } from "react";
14
+ import { FileTile } from "@swan-io/shared-business/src/components/FileTile";
15
+ import { Fragment, useMemo } from "react";
14
16
  import { useDropzone } from "react-dropzone";
15
17
  import { StyleSheet, Text, View } from "react-native";
16
18
  import { match } from "ts-pattern";
@@ -103,32 +105,23 @@ const styles = StyleSheet.create({
103
105
  borderColor: colors.negative[500],
104
106
  },
105
107
  preview: {
106
- aspectRatio: 16 / 4,
108
+ aspectRatio: 16 / 5,
107
109
  width: "50%",
110
+ backgroundPosition: "center",
111
+ backgroundSize: "contain",
112
+ backgroundRepeat: "no-repeat",
113
+ },
114
+ deleteButton: {
115
+ position: "absolute",
116
+ right: spacings[20],
117
+ top: spacings[20],
108
118
  },
109
119
  });
110
- const UploadAreaPreview = ({ value }) => {
111
- const containerRef = useRef(null);
112
- useLayoutEffect(() => {
113
- const element = containerRef.current;
114
- if (element != null) {
115
- while (element.firstChild) {
116
- element.firstChild.remove();
117
- }
118
- const previewElement = value.cloneNode(true);
119
- element.append(previewElement);
120
- previewElement.style.position = "absolute";
121
- previewElement.style.top = "0";
122
- previewElement.style.left = "0";
123
- previewElement.style.width = "100%";
124
- previewElement.style.height = "100%";
125
- previewElement.style.objectFit = "contain";
126
- previewElement.style.objectPosition = "50% 50%";
127
- }
128
- }, [value]);
129
- return _jsx(View, { ref: containerRef, style: styles.preview });
120
+ const UploadAreaPreview = ({ file }) => {
121
+ const url = useMemo(() => URL.createObjectURL(file), [file]);
122
+ return _jsx(View, { style: [styles.preview, { backgroundImage: `url("${url}")` }] });
130
123
  };
131
- export const UploadArea = ({ icon, accept, value, documents = [], disabled = false, onRemoveFile, onDropAccepted, onDropRejected, layout = "vertical", description, error, maxSize, }) => {
124
+ export const UploadArea = ({ icon, accept, value, documents = [], disabled = false, onRemoveFile, onRemoveDocument, onDropAccepted, onDropRejected, layout = "vertical", description, error, maxSize, }) => {
132
125
  const [isHovered, setIsHovered] = useBoolean(false);
133
126
  const { getRootProps, getInputProps, isDragActive, fileRejections } = useDropzone({
134
127
  accept: accept.reduce((acc, item) => ({ ...acc, [item]: [] }), {}),
@@ -137,6 +130,18 @@ export const UploadArea = ({ icon, accept, value, documents = [], disabled = fal
137
130
  disabled,
138
131
  maxSize,
139
132
  });
133
+ const browseElement = (_jsxs(_Fragment, { children: [_jsxs(View, { style: styles.icon, children: [_jsx(Icon, { name: icon, size: 48, color: disabled ? colors.gray[200] : colors.current[500], style: [
134
+ styles.decorativeIconLeft,
135
+ (isDragActive || isHovered) && styles.decorativeIconLeftHovered,
136
+ ] }), _jsx(Icon, { name: icon, size: 48, color: disabled ? colors.gray[200] : colors.current[500], style: [
137
+ styles.decorativeIconRight,
138
+ (isDragActive || isHovered) && styles.decorativeIconRightHovered,
139
+ ] }), _jsx(Icon, { name: icon, size: 48, color: disabled ? colors.gray[200] : colors.current[500] })] }), _jsx(Space, { width: layout === "horizontal" ? 48 : 16, height: layout === "horizontal" ? 48 : 16 }), _jsxs(View, { style: styles.browseBlock, children: [_jsx(LakeHeading, { level: 5, variant: "h5", align: layout === "horizontal" ? "left" : "center", color: disabled ? colors.gray[200] : undefined, children: disabled
140
+ ? t("uploadArea.noValue")
141
+ : formatNestedMessage("uploadArea.dropFile", {
142
+ browse: _jsx(Text, { style: styles.browse, children: t("uploadArea.browse") }),
143
+ }) }), isNotNullish(error) ? (_jsxs(_Fragment, { children: [_jsx(Space, { height: 4 }), _jsx(LakeText, { color: colors.negative[400], align: layout === "horizontal" ? "left" : "center", children: error })] })) : (!disabled &&
144
+ isNotNullish(description) && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 4 }), _jsx(LakeText, { align: layout === "horizontal" ? "left" : "center", children: description })] })))] })] }));
140
145
  return (_jsxs(View, { style: commonStyles.fill, children: [_jsx("div", { ...getRootProps(), onMouseEnter: setIsHovered.on, onMouseLeave: setIsHovered.off, children: _jsxs(View, { "aria-errormessage": error ?? fileRejections[0]?.errors.join(", "), style: [
141
146
  styles.container,
142
147
  disabled && styles.disabled,
@@ -144,21 +149,16 @@ export const UploadArea = ({ icon, accept, value, documents = [], disabled = fal
144
149
  !disabled && isHovered && styles.hoveredContainer,
145
150
  isDragActive && styles.activeContainer,
146
151
  (error != null || fileRejections.length > 0) && styles.errorContainer,
147
- ], children: [_jsx("input", { ...getInputProps() }), isNotNullish(value) ? (value instanceof Element ? (_jsx(UploadAreaPreview, { value: value })) : (_jsxs(_Fragment, { children: [_jsx(Icon, { name: getIconNameFromFilename(value.name), size: 48, color: disabled ? colors.gray[200] : colors.current[500] }), _jsx(Space, { width: layout === "horizontal" ? 48 : 16, height: layout === "horizontal" ? 48 : 16 }), _jsxs(View, { style: styles.browseBlock, children: [_jsx(LakeHeading, { level: 5, variant: "h5", align: layout === "horizontal" ? "left" : "center", children: t("uploadArea.droppedFile") }), _jsx(Space, { height: 4 }), _jsx(LakeText, { variant: "smallRegular", color: colors.gray[200], children: value.name })] })] }))) : (_jsxs(_Fragment, { children: [_jsxs(View, { style: styles.icon, children: [_jsx(Icon, { name: icon, size: 48, color: disabled ? colors.gray[200] : colors.current[500], style: [
148
- styles.decorativeIconLeft,
149
- (isDragActive || isHovered) && styles.decorativeIconLeftHovered,
150
- ] }), _jsx(Icon, { name: icon, size: 48, color: disabled ? colors.gray[200] : colors.current[500], style: [
151
- styles.decorativeIconRight,
152
- (isDragActive || isHovered) && styles.decorativeIconRightHovered,
153
- ] }), _jsx(Icon, { name: icon, size: 48, color: disabled ? colors.gray[200] : colors.current[500] })] }), _jsx(Space, { width: layout === "horizontal" ? 48 : 16, height: layout === "horizontal" ? 48 : 16 }), _jsxs(View, { style: styles.browseBlock, children: [_jsx(LakeHeading, { level: 5, variant: "h5", align: layout === "horizontal" ? "left" : "center", color: disabled ? colors.gray[200] : undefined, children: disabled
154
- ? t("uploadArea.noValue")
155
- : formatNestedMessage("uploadArea.dropFile", {
156
- browse: _jsx(Text, { style: styles.browse, children: t("uploadArea.browse") }),
157
- }) }), isNotNullish(error) ? (_jsxs(_Fragment, { children: [_jsx(Space, { height: 4 }), _jsx(LakeText, { color: colors.negative[400], align: layout === "horizontal" ? "left" : "center", children: error })] })) : (!disabled &&
158
- isNotNullish(description) && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 4 }), _jsx(LakeText, { align: layout === "horizontal" ? "left" : "center", children: description })] })))] })] }))] }) }), documents.map(({ ...document }, index) => {
152
+ ], children: [_jsx("input", { ...getInputProps() }), isNotNullish(value)
153
+ ? value.match({
154
+ NotAsked: () => browseElement,
155
+ Loading: () => _jsx(LoadingView, {}),
156
+ Done: value => value.type.startsWith("image/") ? (_jsxs(_Fragment, { children: [_jsx(UploadAreaPreview, { file: value }), onRemoveFile != null ? (_jsx(LakeButton, { mode: "tertiary", size: "small", icon: "delete-regular", color: "negative", onPress: onRemoveFile, style: styles.deleteButton, ariaLabel: t("common.remove") })) : null] })) : (_jsxs(_Fragment, { children: [_jsx(Icon, { name: getIconNameFromFilename(value.name), size: 48, color: disabled ? colors.gray[200] : colors.current[500] }), _jsx(Space, { width: layout === "horizontal" ? 48 : 16, height: layout === "horizontal" ? 48 : 16 }), _jsxs(View, { style: styles.browseBlock, children: [_jsx(LakeHeading, { level: 5, variant: "h5", align: layout === "horizontal" ? "left" : "center", children: t("uploadArea.droppedFile") }), _jsx(Space, { height: 4 }), _jsx(LakeText, { variant: "smallRegular", color: colors.gray[200], children: value.name })] }), onRemoveFile != null ? (_jsx(LakeButton, { mode: "tertiary", size: "small", icon: "delete-regular", color: "negative", style: styles.deleteButton, onPress: onRemoveFile, ariaLabel: t("common.remove") })) : null] })),
157
+ })
158
+ : browseElement] }) }), documents.map(({ ...document }, index) => {
159
159
  return (_jsxs(Fragment, { children: [_jsx(Space, { height: index === 0 ? 8 : 4 }), match(document)
160
- .with({ status: "finished" }, () => (_jsx(FileTile, { name: document.name ?? t("uploadArea.unknownFileName"), url: document.fileUrl, onRemove: onRemoveFile ? () => onRemoveFile(document.id) : undefined })))
161
- .with({ status: "failed" }, ({ error }) => (_jsx(FileTile, { name: document.name ?? t("uploadArea.unknownFileName"), url: document.fileUrl, onRemove: () => (onRemoveFile ? onRemoveFile(document.id) : undefined), variant: "refused", title: error })))
160
+ .with({ status: "finished" }, () => (_jsx(FileTile, { name: document.name ?? t("uploadArea.unknownFileName"), url: document.fileUrl, onRemove: onRemoveDocument ? () => onRemoveDocument(document.id) : undefined })))
161
+ .with({ status: "failed" }, ({ error }) => (_jsx(FileTile, { name: document.name ?? t("uploadArea.unknownFileName"), url: document.fileUrl, onRemove: () => (onRemoveDocument ? onRemoveDocument(document.id) : undefined), variant: "refused", title: error })))
162
162
  .with({ status: "uploading" }, ({ progress }) => (_jsxs(Box, { direction: "row", alignItems: "center", style: styles.item, children: [_jsx(LakeText, { numberOfLines: 1, color: colors.gray[700], children: t("uploadArea.uploading") }), _jsx(Space, { width: 20 }), _jsx(View, { role: "progressbar", style: styles.progressBar, children: _jsx(View, { style: [styles.progress, { width: `${progress}%` }] }) })] })))
163
163
  .exhaustive()] }, document.id));
164
164
  })] }));
@@ -45,13 +45,19 @@
45
45
  "businessActivity.realEstate": "Immobilien",
46
46
  "businessActivity.scientificActivities": "Wissenschaftliche Tätigkeiten",
47
47
  "businessActivity.transportation": "Transportwesen",
48
+ "common.cancel": "Abbrechen",
49
+ "common.close": "Schließen",
48
50
  "common.form.help.nbCharacters": "{nbCharacters} Zeichen",
49
51
  "common.form.help.nbDigits": "{nbDigits} Ziffern",
50
52
  "common.form.invalidTaxIdentificationNumber": "Diese Steueridentifikationsnummer ist ungültig",
51
53
  "common.form.taxIdentificationNumber.placeholder": "Steueridentifikationsnummer",
52
54
  "common.form.taxIdentificationNumber.tooltip.deu": "Identifikationsnummer (auch Steuerliche Identifikationsnummer, Persönliche Identificationsnummer, Identifikationsnummer, Steuer-IdNr., IdNr oder Steuer-ID gemäß § 139b AO)",
55
+ "common.next": "Weiter",
53
56
  "common.noResult": "Leeres Ergebnis",
57
+ "common.open": "Öffnen",
54
58
  "common.optional": "Optional",
59
+ "common.previous": "Zurück",
60
+ "common.remove": "Entfernen",
55
61
  "common.skipToContent": "Zum Inhalt springen",
56
62
  "country.AUT": "Österreich",
57
63
  "country.BEL": "Belgien",
@@ -100,8 +106,10 @@
100
106
  "datePicker.month.june": "Juni",
101
107
  "datePicker.month.march": "März",
102
108
  "datePicker.month.may": "Mai",
109
+ "datePicker.month.next": "Nächster Monat",
103
110
  "datePicker.month.november": "November",
104
111
  "datePicker.month.october": "Oktober",
112
+ "datePicker.month.previous": "Vorheriger Monat",
105
113
  "datePicker.month.september": "September",
106
114
  "error.generic": "Es ist ein Fehler aufgetreten",
107
115
  "error.network.500": "Interner Serverfehler",
@@ -45,13 +45,19 @@
45
45
  "businessActivity.realEstate": "Real estate",
46
46
  "businessActivity.scientificActivities": "Scientific activities",
47
47
  "businessActivity.transportation": "Transportation",
48
+ "common.close": "Close",
48
49
  "common.form.help.nbCharacters": "{nbCharacters} characters",
49
50
  "common.form.help.nbDigits": "{nbDigits} digits",
50
51
  "common.form.invalidTaxIdentificationNumber": "This tax identification number is invalid",
51
52
  "common.form.taxIdentificationNumber.placeholder": "Tax ID",
52
53
  "common.form.taxIdentificationNumber.tooltip.deu": "Identifikationsnummer (also Steuerliche Identifikationsnummer, Persönliche Identificationsnummer, Identifikationsnummer, Steuer-IdNr., IdNr or Steuer-ID, according to § 139b AO)",
54
+ "common.next": "Next",
55
+ "common.cancel": "Cancel",
53
56
  "common.noResult": "Empty result",
57
+ "common.open": "Open",
54
58
  "common.optional": "Optional",
59
+ "common.previous": "Previous",
60
+ "common.remove": "Remove",
55
61
  "common.skipToContent": "Skip to content",
56
62
  "country.AUT": "Austria",
57
63
  "country.BEL": "Belgium",
@@ -100,8 +106,10 @@
100
106
  "datePicker.month.june": "June",
101
107
  "datePicker.month.march": "March",
102
108
  "datePicker.month.may": "May",
109
+ "datePicker.month.next": "Next month",
103
110
  "datePicker.month.november": "November",
104
111
  "datePicker.month.october": "October",
112
+ "datePicker.month.previous": "Previous month",
105
113
  "datePicker.month.september": "September",
106
114
  "error.generic": "An error occurred",
107
115
  "error.network.500": "Internal server error",
@@ -45,13 +45,19 @@
45
45
  "businessActivity.realEstate": "Sector inmobiliario",
46
46
  "businessActivity.scientificActivities": "Actividades científicas",
47
47
  "businessActivity.transportation": "Transporte",
48
+ "common.close": "Cerrar",
49
+ "common.cancel": "Cancelar",
48
50
  "common.form.help.nbCharacters": "{nbCharacters} caracteres",
49
51
  "common.form.help.nbDigits": "{nbDigits} dígitos",
50
52
  "common.form.invalidTaxIdentificationNumber": "Este número de identificación fiscal no es válido",
51
53
  "common.form.taxIdentificationNumber.placeholder": "Número de identificación fiscal",
52
54
  "common.form.taxIdentificationNumber.tooltip.deu": "Identifikationsnummer (también Steuerliche Identifikationsnummer, Persönliche Identificationsnummer, Identifikationsnummer, Steuer-IdNr., IdNr o Steuer-ID, según § 139b AO)",
55
+ "common.next": "Siguiente",
53
56
  "common.noResult": "No hay resultados",
57
+ "common.open": "Abrir",
54
58
  "common.optional": "Opcional",
59
+ "common.previous": "Anterior",
60
+ "common.remove": "Eliminar",
55
61
  "common.skipToContent": "Saltar al contenido",
56
62
  "country.AUT": "Austria",
57
63
  "country.BEL": "Bélgica",
@@ -100,8 +106,10 @@
100
106
  "datePicker.month.june": "Junio",
101
107
  "datePicker.month.march": "Marzo",
102
108
  "datePicker.month.may": "Mayo",
109
+ "datePicker.month.next": "Próximo mes",
103
110
  "datePicker.month.november": "Noviembre",
104
111
  "datePicker.month.october": "Octubre",
112
+ "datePicker.month.previous": "Mes anterior",
105
113
  "datePicker.month.september": "Septiembre",
106
114
  "error.generic": "Ha ocurrido un error",
107
115
  "error.network.500": "Error de servidor interno",
@@ -45,13 +45,19 @@
45
45
  "businessActivity.realEstate": "Immobilier",
46
46
  "businessActivity.scientificActivities": "Activités scientifiques",
47
47
  "businessActivity.transportation": "Transports",
48
+ "common.close": "Fermer",
49
+ "common.cancel": "Annuler",
48
50
  "common.form.help.nbCharacters": "{nbCharacters} caractères",
49
51
  "common.form.help.nbDigits": "{nbDigits} chiffres",
50
52
  "common.form.invalidTaxIdentificationNumber": "Ce numéro d'identification fiscale n'est pas valide",
51
53
  "common.form.taxIdentificationNumber.placeholder": "Numéro d'identification fiscale",
52
54
  "common.form.taxIdentificationNumber.tooltip.deu": "Identifikationsnummer (également Steuerliche Identifikationsnummer, Persönliche Identificationsnummer, Identifikationsnummer, Steuer-IdNr., IdNr ou Steuer-ID, selon § 139b AO)",
55
+ "common.next": "Suivant",
53
56
  "common.noResult": "Résultat vide",
57
+ "common.open": "Ouvrir",
54
58
  "common.optional": "Facultatif",
59
+ "common.previous": "Précédent",
60
+ "common.remove": "Supprimer",
55
61
  "common.skipToContent": "Aller au contenu",
56
62
  "country.AUT": "Autriche",
57
63
  "country.BEL": "Belgique",
@@ -100,8 +106,10 @@
100
106
  "datePicker.month.june": "Juin",
101
107
  "datePicker.month.march": "Mars",
102
108
  "datePicker.month.may": "Mai",
109
+ "datePicker.month.next": "Mois suivant",
103
110
  "datePicker.month.november": "Novembre",
104
111
  "datePicker.month.october": "Octobre",
112
+ "datePicker.month.previous": "Mois précédent",
105
113
  "datePicker.month.september": "Septembre",
106
114
  "error.generic": "Une erreur est survenue",
107
115
  "error.network.500": "Erreur de serveur interne",
@@ -45,13 +45,19 @@
45
45
  "businessActivity.realEstate": "Servizi immobiliari",
46
46
  "businessActivity.scientificActivities": "Attività scientifiche",
47
47
  "businessActivity.transportation": "Trasporto",
48
+ "common.close": "Chiudi",
49
+ "common.cancel": "Annulla",
48
50
  "common.form.help.nbCharacters": "{nbCharacters} caratteri",
49
51
  "common.form.help.nbDigits": "{nbDigits} cifre",
50
52
  "common.form.invalidTaxIdentificationNumber": "Codice fiscale non valido",
51
53
  "common.form.taxIdentificationNumber.placeholder": "Codice fiscale",
52
54
  "common.form.taxIdentificationNumber.tooltip.deu": "Identifikationsnummer (anche Steuerliche Identifikationsnummer, Persönliche Identificationsnummer, Steuer-IDNr., Steuer-ID o Steuer-ID, secondo § 139b AO)",
55
+ "common.next": "Avanti",
53
56
  "common.noResult": "Risultato vuoto",
57
+ "common.open": "Apri",
54
58
  "common.optional": "Opzionale",
59
+ "common.previous": "Precedente",
60
+ "common.remove": "Rimuovi",
55
61
  "common.skipToContent": "Salta al contenuto",
56
62
  "country.AUT": "Austria",
57
63
  "country.BEL": "Belgio",
@@ -100,8 +106,10 @@
100
106
  "datePicker.month.june": "Giugno",
101
107
  "datePicker.month.march": "Marzo",
102
108
  "datePicker.month.may": "Maggio",
109
+ "datePicker.month.next": "Mese successivo",
103
110
  "datePicker.month.november": "Novembre",
104
111
  "datePicker.month.october": "Ottobre",
112
+ "datePicker.month.previous": "Mese precedente",
105
113
  "datePicker.month.september": "Settembre",
106
114
  "error.generic": "Si è verificato un errore",
107
115
  "error.network.500": "Errore interno del server",
@@ -45,13 +45,19 @@
45
45
  "businessActivity.realEstate": "Onroerend goed",
46
46
  "businessActivity.scientificActivities": "Wetenschap",
47
47
  "businessActivity.transportation": "Transport",
48
+ "common.close": "Sluiten",
49
+ "common.cancel": "Annuleren",
48
50
  "common.form.help.nbCharacters": "{nbCharacters} tekens",
49
51
  "common.form.help.nbDigits": "{nbDigits} cijfers",
50
52
  "common.form.invalidTaxIdentificationNumber": "Dit fiscale identificatienummer is ongeldig",
51
53
  "common.form.taxIdentificationNumber.placeholder": "BTW-nummer",
52
54
  "common.form.taxIdentificationNumber.tooltip.deu": "Identifikationsnummer (ook Steuerliche Identifikationsnummer, Persönliche Identificationsnummer, Identifikationsnummer, Steuer-IDnr., IDnr of Steuer-ID, volgens § 139b AO)",
55
+ "common.next": "Volgende",
53
56
  "common.noResult": "Leeg resultaat",
57
+ "common.open": "Openen",
54
58
  "common.optional": "Optioneel",
59
+ "common.previous": "Vorige",
60
+ "common.remove": "Verwijderen",
55
61
  "common.skipToContent": "Doorgaan naar artikel",
56
62
  "country.AUT": "Oostenrijk",
57
63
  "country.BEL": "België",
@@ -100,8 +106,10 @@
100
106
  "datePicker.month.june": "Juni",
101
107
  "datePicker.month.march": "Maart",
102
108
  "datePicker.month.may": "Mei",
109
+ "datePicker.month.next": "Volgende maand",
103
110
  "datePicker.month.november": "November",
104
111
  "datePicker.month.october": "Oktober",
112
+ "datePicker.month.previous": "Vorige maand",
105
113
  "datePicker.month.september": "September",
106
114
  "error.generic": "Er is een fout opgetreden",
107
115
  "error.network.500": "Interne Server Fout",
@@ -45,13 +45,19 @@
45
45
  "businessActivity.realEstate": "Imobiliária",
46
46
  "businessActivity.scientificActivities": "Atividades científicas",
47
47
  "businessActivity.transportation": "Transporte",
48
+ "common.close": "Fechar",
49
+ "common.cancel": "Cancelar",
48
50
  "common.form.help.nbCharacters": "{nbCharacters} caracteres",
49
51
  "common.form.help.nbDigits": "{nbDigits} dígitos",
50
52
  "common.form.invalidTaxIdentificationNumber": "Este número de identificação fiscal é inválido",
51
53
  "common.form.taxIdentificationNumber.placeholder": "Número de Identificação Fiscal",
52
54
  "common.form.taxIdentificationNumber.tooltip.deu": "Identifikationsnummer (também Steuerliche Identificationsnummer, Persönliche Identificationsnummer, Identifikationsnummer, Steuer-IdNr., IdNr ou Steuer-ID, conforme § 139b AO)",
55
+ "common.next": "Próximo",
53
56
  "common.noResult": "Resultado vazio",
57
+ "common.open": "Abrir",
54
58
  "common.optional": "Opcional",
59
+ "common.previous": "Anterior",
60
+ "common.remove": "Remover",
55
61
  "common.skipToContent": "Saltar para o conteúdo",
56
62
  "country.AUT": "Áustria",
57
63
  "country.BEL": "Bélgica",
@@ -100,8 +106,10 @@
100
106
  "datePicker.month.june": "Junho",
101
107
  "datePicker.month.march": "Março",
102
108
  "datePicker.month.may": "Maio",
109
+ "datePicker.month.next": "Próximo mês",
103
110
  "datePicker.month.november": "Novembro",
104
111
  "datePicker.month.october": "Outubro",
112
+ "datePicker.month.previous": "Mês anterior",
105
113
  "datePicker.month.september": "Setembro",
106
114
  "error.generic": "Ocorreu um erro",
107
115
  "error.network.500": "Erro interno do servidor",
@@ -1,5 +1,2 @@
1
- import { MonthNames, WeekDayNames } from "@swan-io/lake/src/components/DatePicker";
2
1
  export declare const decodeBirthDate: (value: string) => string;
3
2
  export declare const encodeBirthDate: (value: string) => string;
4
- export declare const weekDayNames: WeekDayNames;
5
- export declare const monthNames: MonthNames;
package/src/utils/date.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import dayjs from "dayjs";
2
- import { t } from "./i18n";
3
2
  export const decodeBirthDate = (value) => {
4
3
  const date = dayjs.utc(value, "YYYY-MM-DD");
5
4
  return date.isValid() ? date.format("DD/MM/YYYY") : "";
@@ -8,26 +7,3 @@ export const encodeBirthDate = (value) => {
8
7
  const date = dayjs.utc(value, "DD/MM/YYYY");
9
8
  return date.isValid() ? date.format("YYYY-MM-DD") : "";
10
9
  };
11
- export const weekDayNames = [
12
- t("datePicker.day.sunday"),
13
- t("datePicker.day.monday"),
14
- t("datePicker.day.tuesday"),
15
- t("datePicker.day.wednesday"),
16
- t("datePicker.day.thursday"),
17
- t("datePicker.day.friday"),
18
- t("datePicker.day.saturday"),
19
- ];
20
- export const monthNames = [
21
- t("datePicker.month.january"),
22
- t("datePicker.month.february"),
23
- t("datePicker.month.march"),
24
- t("datePicker.month.april"),
25
- t("datePicker.month.may"),
26
- t("datePicker.month.june"),
27
- t("datePicker.month.july"),
28
- t("datePicker.month.august"),
29
- t("datePicker.month.september"),
30
- t("datePicker.month.october"),
31
- t("datePicker.month.november"),
32
- t("datePicker.month.december"),
33
- ];
@@ -1,6 +1,6 @@
1
- import type { DateFormat } from "@swan-io/lake/src/components/DatePicker";
2
1
  import { RifmProps } from "@swan-io/lake/src/utils/rifm";
3
2
  import { ReactElement, ReactNode } from "react";
3
+ import type { DateFormat } from "../components/DatePicker";
4
4
  import translationEN from "../locales/en.json";
5
5
  declare const supportedLanguages: readonly ["en", "es", "de", "fr", "it", "nl", "pt"];
6
6
  type SupportedLanguage = (typeof supportedLanguages)[number];