@swan-io/shared-business 15.5.1 → 15.5.3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swan-io/shared-business",
|
|
3
|
-
"version": "15.5.
|
|
3
|
+
"version": "15.5.3",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">22.12.0"
|
|
6
6
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"react": ">=19.0.0",
|
|
29
29
|
"react-dom": ">=19.0.0",
|
|
30
30
|
"react-native-web": ">=0.21.2",
|
|
31
|
-
"@swan-io/lake": "15.5.
|
|
31
|
+
"@swan-io/lake": "15.5.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@formatjs/intl": "^4.1.16",
|
|
@@ -53,6 +53,6 @@
|
|
|
53
53
|
"react-dom": "^19.2.7",
|
|
54
54
|
"react-native-web": "^0.21.2",
|
|
55
55
|
"type-fest": "^5.8.0",
|
|
56
|
-
"@swan-io/lake": "15.5.
|
|
56
|
+
"@swan-io/lake": "15.5.3"
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -14,7 +14,7 @@ import { Pressable } from "@swan-io/lake/src/components/Pressable";
|
|
|
14
14
|
import { Separator } from "@swan-io/lake/src/components/Separator";
|
|
15
15
|
import { Space } from "@swan-io/lake/src/components/Space";
|
|
16
16
|
import { colors, spacings } from "@swan-io/lake/src/constants/design";
|
|
17
|
-
import {
|
|
17
|
+
import { useBoolean } from "@swan-io/lake/src/hooks/useBoolean";
|
|
18
18
|
import { useFirstMountState } from "@swan-io/lake/src/hooks/useFirstMountState";
|
|
19
19
|
import { useResponsive } from "@swan-io/lake/src/hooks/useResponsive";
|
|
20
20
|
import { noop } from "@swan-io/lake/src/utils/function";
|
|
@@ -477,7 +477,7 @@ const DatePickerPopoverContent = ({ value, format, firstWeekDay, desktop, isSele
|
|
|
477
477
|
export const DatePicker = ({ label, value, error, format, firstWeekDay, isSelectable, onChange, }) => {
|
|
478
478
|
const { desktop } = useResponsive(DATE_PICKER_MOBILE_THRESHOLD);
|
|
479
479
|
const ref = useRef(null);
|
|
480
|
-
const [isOpened, { open, close }] =
|
|
480
|
+
const [isOpened, { on: open, off: close }] = useBoolean(false);
|
|
481
481
|
const popoverId = useId();
|
|
482
482
|
return (_jsxs(_Fragment, { children: [_jsx(Box, { direction: "row", alignItems: "end", children: _jsx(LakeLabel, { label: label, style: styles.label, actions: _jsx(LakeButton, { mode: "secondary", icon: "calendar-ltr-regular", size: "small", onPress: open, ariaLabel: t("common.open"), ariaExpanded: isOpened }), render: id => (_jsx(Rifm, { value: value !== null && value !== void 0 ? value : "", onChange: onChange, ...rifmDateProps, children: ({ value, onChange }) => (_jsx(LakeTextInput, { ref: ref, id: id, placeholder: format, value: value, error: error, onChange: onChange })) })) }) }), _jsx(Popover, { id: popoverId, role: "dialog", onDismiss: close, referenceRef: ref, visible: isOpened, children: _jsx(View, { style: desktop ? styles.popoverDesktop : styles.popover, children: _jsx(DatePickerPopoverContent, { value: value, format: format, firstWeekDay: firstWeekDay, desktop: desktop, isSelectable: isSelectable, onChange: onChange }) }) })] }));
|
|
483
483
|
};
|
|
@@ -614,7 +614,7 @@ export const DateRangePicker = ({ value, error, format, startLabel, endLabel, fi
|
|
|
614
614
|
const { desktop } = useResponsive(DATE_PICKER_MOBILE_THRESHOLD);
|
|
615
615
|
const { desktop: displayTwoCalendar } = useResponsive(DATE_RANGE_PICKER_THRESHOLD);
|
|
616
616
|
const ref = useRef(null);
|
|
617
|
-
const [isOpened, { open, close }] =
|
|
617
|
+
const [isOpened, { on: open, off: close }] = useBoolean(false);
|
|
618
618
|
const handleStartChange = useCallback((start) => {
|
|
619
619
|
onChange({ start, end: value.end });
|
|
620
620
|
}, [value, onChange]);
|
|
@@ -4,6 +4,7 @@ type DistFile = {
|
|
|
4
4
|
name?: string;
|
|
5
5
|
};
|
|
6
6
|
type Props = {
|
|
7
|
+
id?: string;
|
|
7
8
|
accept: string[];
|
|
8
9
|
value?: DistFile | File;
|
|
9
10
|
disabled?: boolean;
|
|
@@ -16,5 +17,5 @@ type Props = {
|
|
|
16
17
|
onError?: () => void;
|
|
17
18
|
onPressRemove?: () => void;
|
|
18
19
|
};
|
|
19
|
-
export declare const FileInput: ({ icon, accept, value, disabled, onPressRemove, onFiles, onError, layout, description, error, maxSize, }: Props) => import("react").JSX.Element;
|
|
20
|
+
export declare const FileInput: ({ id, icon, accept, value, disabled, onPressRemove, onFiles, onError, layout, description, error, maxSize, }: Props) => import("react").JSX.Element;
|
|
20
21
|
export {};
|
|
@@ -94,7 +94,7 @@ const styles = StyleSheet.create({
|
|
|
94
94
|
top: spacings[20],
|
|
95
95
|
},
|
|
96
96
|
});
|
|
97
|
-
export const FileInput = ({ icon = "document-regular", accept, value, disabled = false, onPressRemove, onFiles, onError, layout = "vertical", description, error, maxSize, }) => {
|
|
97
|
+
export const FileInput = ({ id, icon = "document-regular", accept, value, disabled = false, onPressRemove, onFiles, onError, layout = "vertical", description, error, maxSize, }) => {
|
|
98
98
|
var _a;
|
|
99
99
|
const [isHovered, setIsHovered] = useBoolean(false);
|
|
100
100
|
// We use the `accept` field as a heuristic to know if we can display a preview
|
|
@@ -130,7 +130,7 @@ export const FileInput = ({ icon = "document-regular", accept, value, disabled =
|
|
|
130
130
|
!disabled && isHovered && styles.hoveredContainer,
|
|
131
131
|
isDragActive && styles.activeContainer,
|
|
132
132
|
(error != null || fileRejections.length > 0) && styles.errorContainer,
|
|
133
|
-
], children: [_jsx("input", { ...getInputProps() }), match({ file, isImageOnly })
|
|
133
|
+
], children: [_jsx("input", { ...getInputProps({ id }) }), match({ file, isImageOnly })
|
|
134
134
|
.with({ file: Option.Some(P.select()), isImageOnly: true }, ({ url }) => (_jsxs(_Fragment, { children: [_jsx(View, { style: [styles.preview, { backgroundImage: `url("${url}")` }] }), onPressRemove != null ? (_jsx(LakeButton, { mode: "tertiary", size: "small", icon: "delete-regular", color: "negative", onPress: onPressRemove, style: styles.deleteButton, ariaLabel: t("common.remove") })) : null] })))
|
|
135
135
|
.with({ file: Option.Some(P.select()), isImageOnly: false }, ({ name }) => (_jsxs(_Fragment, { children: [_jsx(Icon, { name: getIconNameFromFilename(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("fileInput.clickToModify") }), _jsx(Space, { height: 4 }), _jsx(LakeText, { variant: "smallRegular", color: colors.gray[200], align: layout === "horizontal" ? "left" : "center", children: name })] }), onPressRemove != null ? (_jsx(LakeButton, { mode: "tertiary", size: "small", icon: "delete-regular", color: "negative", style: styles.deleteButton, onPress: onPressRemove, ariaLabel: t("common.remove") })) : null] })))
|
|
136
136
|
.otherwise(() => (_jsxs(_Fragment, { children: [_jsxs(View, { style: styles.icon, children: [_jsx(Icon, { name: icon, size: 48, color: disabled ? colors.gray[200] : colors.current[500], style: [
|
|
@@ -8,8 +8,8 @@ import { Pressable } from "@swan-io/lake/src/components/Pressable";
|
|
|
8
8
|
import { Separator } from "@swan-io/lake/src/components/Separator";
|
|
9
9
|
import { Space } from "@swan-io/lake/src/components/Space";
|
|
10
10
|
import { colors, radii, spacings, texts } from "@swan-io/lake/src/constants/design";
|
|
11
|
+
import { useBoolean } from "@swan-io/lake/src/hooks/useBoolean";
|
|
11
12
|
import { useDebounce } from "@swan-io/lake/src/hooks/useDebounce";
|
|
12
|
-
import { useDisclosure } from "@swan-io/lake/src/hooks/useDisclosure";
|
|
13
13
|
import { isNotNullish, isNotNullishOrEmpty } from "@swan-io/lake/src/utils/nullish";
|
|
14
14
|
import { deburr } from "@swan-io/lake/src/utils/string";
|
|
15
15
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
@@ -65,7 +65,7 @@ const styles = StyleSheet.create({
|
|
|
65
65
|
export const PhoneCountryPicker = ({ value, onValueChange, countries, style, disabled = false, readOnly = false, error, ariaLabel = "Select country", }) => {
|
|
66
66
|
const referenceRef = useRef(null);
|
|
67
67
|
const inputRef = useRef(null);
|
|
68
|
-
const [visible, { open, close }] =
|
|
68
|
+
const [visible, { on: open, off: close }] = useBoolean(false);
|
|
69
69
|
const allowedCountries = useMemo(() => countries
|
|
70
70
|
.filter((cca3, index, array) => array.indexOf(cca3) === index)
|
|
71
71
|
.map(cca3 => getCountryByCCA3(cca3)), [countries]);
|