@korsolutions/ui 0.0.53 → 0.0.55
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/babel.config.js +1 -11
- package/dist/module/components/alert/components/alert-body.js.map +1 -1
- package/dist/module/components/alert/components/alert-description.js.map +1 -1
- package/dist/module/components/alert/components/alert-icon.js.map +1 -1
- package/dist/module/components/alert/components/alert-root.js.map +1 -1
- package/dist/module/components/alert/components/alert-title.js.map +1 -1
- package/dist/module/components/alert/index.js.map +1 -1
- package/dist/module/components/alert/variants/default.js.map +1 -1
- package/dist/module/components/alert/variants/destructive.js.map +1 -1
- package/dist/module/components/alert/variants/index.js.map +1 -1
- package/dist/module/components/alert-dialog/async-alert-dialog.js.map +1 -1
- package/dist/module/components/alert-dialog/components/alert-dialog-action.js.map +1 -1
- package/dist/module/components/alert-dialog/components/alert-dialog-cancel.js.map +1 -1
- package/dist/module/components/alert-dialog/components/alert-dialog-content.js.map +1 -1
- package/dist/module/components/alert-dialog/components/alert-dialog-description.js.map +1 -1
- package/dist/module/components/alert-dialog/components/alert-dialog-footer.js.map +1 -1
- package/dist/module/components/alert-dialog/components/alert-dialog-overlay.js.map +1 -1
- package/dist/module/components/alert-dialog/components/alert-dialog-portal.js.map +1 -1
- package/dist/module/components/alert-dialog/components/alert-dialog-root.js.map +1 -1
- package/dist/module/components/alert-dialog/components/alert-dialog-title.js.map +1 -1
- package/dist/module/components/alert-dialog/components/alert-dialog-trigger.js.map +1 -1
- package/dist/module/components/alert-dialog/index.js.map +1 -1
- package/dist/module/components/alert-dialog/variants/default.js.map +1 -1
- package/dist/module/components/alert-dialog/variants/index.js.map +1 -1
- package/dist/module/components/avatar/components/avatar-fallback.js.map +1 -1
- package/dist/module/components/avatar/components/avatar-image.js.map +1 -1
- package/dist/module/components/avatar/components/avatar-root.js.map +1 -1
- package/dist/module/components/avatar/index.js.map +1 -1
- package/dist/module/components/avatar/variants/default.js.map +1 -1
- package/dist/module/components/avatar/variants/index.js.map +1 -1
- package/dist/module/components/badge/components/badge-label.js.map +1 -1
- package/dist/module/components/badge/components/badge-root.js.map +1 -1
- package/dist/module/components/badge/index.js.map +1 -1
- package/dist/module/components/badge/variants/default.js.map +1 -1
- package/dist/module/components/badge/variants/index.js.map +1 -1
- package/dist/module/components/badge/variants/secondary.js.map +1 -1
- package/dist/module/components/button/components/button-label.js.map +1 -1
- package/dist/module/components/button/components/button-root.js.map +1 -1
- package/dist/module/components/button/components/button-spinner.js.map +1 -1
- package/dist/module/components/button/index.js.map +1 -1
- package/dist/module/components/button/variants/default.js.map +1 -1
- package/dist/module/components/button/variants/index.js.map +1 -1
- package/dist/module/components/button/variants/secondary.js.map +1 -1
- package/dist/module/components/calendar/components/calendar-day.js.map +1 -1
- package/dist/module/components/calendar/components/calendar-header.js.map +1 -1
- package/dist/module/components/calendar/components/calendar-nav-button.js.map +1 -1
- package/dist/module/components/calendar/components/calendar-root.js.map +1 -1
- package/dist/module/components/calendar/components/calendar-title.js.map +1 -1
- package/dist/module/components/calendar/components/calendar-week-labels.js.map +1 -1
- package/dist/module/components/calendar/components/calendar-weeks.js.map +1 -1
- package/dist/module/components/calendar/index.js.map +1 -1
- package/dist/module/components/calendar/variants/default.js.map +1 -1
- package/dist/module/components/calendar/variants/index.js.map +1 -1
- package/dist/module/components/card/card-body.js.map +1 -1
- package/dist/module/components/card/card-footer.js.map +1 -1
- package/dist/module/components/card/card-header.js.map +1 -1
- package/dist/module/components/card/card-root.js.map +1 -1
- package/dist/module/components/card/card-title.js.map +1 -1
- package/dist/module/components/card/index.js.map +1 -1
- package/dist/module/components/card/variants/default.js.map +1 -1
- package/dist/module/components/card/variants/index.js.map +1 -1
- package/dist/module/components/checkbox/components/checkbox-content.js.map +1 -1
- package/dist/module/components/checkbox/components/checkbox-description.js.map +1 -1
- package/dist/module/components/checkbox/components/checkbox-indicator.js.map +1 -1
- package/dist/module/components/checkbox/components/checkbox-root.js.map +1 -1
- package/dist/module/components/checkbox/components/checkbox-title.js.map +1 -1
- package/dist/module/components/checkbox/index.js.map +1 -1
- package/dist/module/components/checkbox/variants/default.js.map +1 -1
- package/dist/module/components/checkbox/variants/index.js.map +1 -1
- package/dist/module/components/checkbox/variants/outlined.js.map +1 -1
- package/dist/module/components/empty/components/empty-description.js.map +1 -1
- package/dist/module/components/empty/components/empty-media.js.map +1 -1
- package/dist/module/components/empty/components/empty-root.js.map +1 -1
- package/dist/module/components/empty/components/empty-title.js.map +1 -1
- package/dist/module/components/empty/index.js.map +1 -1
- package/dist/module/components/empty/variants/default.js.map +1 -1
- package/dist/module/components/empty/variants/index.js.map +1 -1
- package/dist/module/components/field/components/field-description.js.map +1 -1
- package/dist/module/components/field/components/field-error.js.map +1 -1
- package/dist/module/components/field/components/field-label.js.map +1 -1
- package/dist/module/components/field/components/field-root.js.map +1 -1
- package/dist/module/components/field/index.js.map +1 -1
- package/dist/module/components/field/variants/default.js.map +1 -1
- package/dist/module/components/field/variants/index.js.map +1 -1
- package/dist/module/components/icon/icon.js.map +1 -1
- package/dist/module/components/icon/index.js.map +1 -1
- package/dist/module/components/icon/variants/default.js.map +1 -1
- package/dist/module/components/icon/variants/index.js.map +1 -1
- package/dist/module/components/index.js.map +1 -1
- package/dist/module/components/input/index.js.map +1 -1
- package/dist/module/components/input/input.js.map +1 -1
- package/dist/module/components/input/numeric-input.js.map +1 -1
- package/dist/module/components/input/variants/default.js.map +1 -1
- package/dist/module/components/input/variants/index.js.map +1 -1
- package/dist/module/components/input/variants/secondary.js.map +1 -1
- package/dist/module/components/link/index.js.map +1 -1
- package/dist/module/components/link/link.js.map +1 -1
- package/dist/module/components/link/variants/default.js.map +1 -1
- package/dist/module/components/link/variants/index.js.map +1 -1
- package/dist/module/components/list/index.js.map +1 -1
- package/dist/module/components/menu/components/menu-content.js.map +1 -1
- package/dist/module/components/menu/components/menu-item.js.map +1 -1
- package/dist/module/components/menu/components/menu-overlay.js.map +1 -1
- package/dist/module/components/menu/components/menu-portal.js.map +1 -1
- package/dist/module/components/menu/components/menu-root.js.map +1 -1
- package/dist/module/components/menu/components/menu-trigger.js.map +1 -1
- package/dist/module/components/menu/index.js.map +1 -1
- package/dist/module/components/menu/variants/default.js.map +1 -1
- package/dist/module/components/menu/variants/index.js.map +1 -1
- package/dist/module/components/phone-input/components/country-picker.js +101 -0
- package/dist/module/components/phone-input/components/country-picker.js.map +1 -0
- package/dist/module/components/phone-input/components/phone-input-root.js +57 -0
- package/dist/module/components/phone-input/components/phone-input-root.js.map +1 -0
- package/dist/module/components/phone-input/components/phone-input.js +31 -0
- package/dist/module/components/phone-input/components/phone-input.js.map +1 -0
- package/dist/module/components/phone-input/context.js +12 -0
- package/dist/module/components/phone-input/context.js.map +1 -0
- package/dist/module/components/phone-input/index.js +8 -1
- package/dist/module/components/phone-input/index.js.map +1 -1
- package/dist/module/components/phone-input/variants/default.js +1 -1
- package/dist/module/components/phone-input/variants/default.js.map +1 -1
- package/dist/module/components/phone-input/variants/index.js.map +1 -1
- package/dist/module/components/popover/components/popover-close.js.map +1 -1
- package/dist/module/components/popover/components/popover-content.js.map +1 -1
- package/dist/module/components/popover/components/popover-overlay.js.map +1 -1
- package/dist/module/components/popover/components/popover-portal.js.map +1 -1
- package/dist/module/components/popover/components/popover-root.js.map +1 -1
- package/dist/module/components/popover/components/popover-trigger.js.map +1 -1
- package/dist/module/components/popover/index.js.map +1 -1
- package/dist/module/components/popover/variants/default.js.map +1 -1
- package/dist/module/components/popover/variants/index.js.map +1 -1
- package/dist/module/components/popover/variants/unstyled.js.map +1 -1
- package/dist/module/components/portal/index.js.map +1 -1
- package/dist/module/components/portal/portal.js.map +1 -1
- package/dist/module/components/portal/portal.web.js.map +1 -1
- package/dist/module/components/progress/components/progress-indicator.js.map +1 -1
- package/dist/module/components/progress/components/progress-root.js.map +1 -1
- package/dist/module/components/progress/index.js.map +1 -1
- package/dist/module/components/progress/variants/default.js.map +1 -1
- package/dist/module/components/progress/variants/index.js.map +1 -1
- package/dist/module/components/scroll-bar/index.js.map +1 -1
- package/dist/module/components/scroll-bar/scroll-bar.js.map +1 -1
- package/dist/module/components/select/components/select-content.js.map +1 -1
- package/dist/module/components/select/components/select-option.js.map +1 -1
- package/dist/module/components/select/components/select-overlay.js.map +1 -1
- package/dist/module/components/select/components/select-portal.js +10 -1
- package/dist/module/components/select/components/select-portal.js.map +1 -1
- package/dist/module/components/select/components/select-root.js.map +1 -1
- package/dist/module/components/select/components/select-trigger.js +5 -4
- package/dist/module/components/select/components/select-trigger.js.map +1 -1
- package/dist/module/components/select/index.js.map +1 -1
- package/dist/module/components/select/variants/default.js.map +1 -1
- package/dist/module/components/select/variants/index.js.map +1 -1
- package/dist/module/components/tabs/components/tabs-list.js.map +1 -1
- package/dist/module/components/tabs/components/tabs-root.js.map +1 -1
- package/dist/module/components/tabs/components/tabs-trigger-text.js.map +1 -1
- package/dist/module/components/tabs/components/tabs-trigger.js.map +1 -1
- package/dist/module/components/tabs/index.js.map +1 -1
- package/dist/module/components/tabs/variants/default.js.map +1 -1
- package/dist/module/components/tabs/variants/index.js.map +1 -1
- package/dist/module/components/tabs/variants/line.js.map +1 -1
- package/dist/module/components/textarea/index.js.map +1 -1
- package/dist/module/components/textarea/textarea.js.map +1 -1
- package/dist/module/components/textarea/variants/default.js.map +1 -1
- package/dist/module/components/textarea/variants/index.js.map +1 -1
- package/dist/module/components/toast/components/toast-body.js +16 -0
- package/dist/module/components/toast/components/toast-body.js.map +1 -0
- package/dist/module/components/toast/components/toast-description.js.map +1 -1
- package/dist/module/components/toast/components/toast-icon.js.map +1 -1
- package/dist/module/components/toast/components/toast-root.js.map +1 -1
- package/dist/module/components/toast/components/toast-title.js.map +1 -1
- package/dist/module/components/toast/index.js.map +1 -1
- package/dist/module/components/toast/manager.js +15 -5
- package/dist/module/components/toast/manager.js.map +1 -1
- package/dist/module/components/toast/variants/danger.js +6 -2
- package/dist/module/components/toast/variants/danger.js.map +1 -1
- package/dist/module/components/toast/variants/default.js +6 -2
- package/dist/module/components/toast/variants/default.js.map +1 -1
- package/dist/module/components/toast/variants/index.js.map +1 -1
- package/dist/module/components/toast/variants/success.js +6 -2
- package/dist/module/components/toast/variants/success.js.map +1 -1
- package/dist/module/components/typography/index.js.map +1 -1
- package/dist/module/components/typography/typography.js.map +1 -1
- package/dist/module/components/typography/variants/body-lg.js.map +1 -1
- package/dist/module/components/typography/variants/body-md.js.map +1 -1
- package/dist/module/components/typography/variants/body-sm.js.map +1 -1
- package/dist/module/components/typography/variants/heading-lg.js.map +1 -1
- package/dist/module/components/typography/variants/heading-md.js.map +1 -1
- package/dist/module/components/typography/variants/heading-sm.js.map +1 -1
- package/dist/module/components/typography/variants/index.js.map +1 -1
- package/dist/module/data/countries.js.map +1 -1
- package/dist/module/hooks/index.js.map +1 -1
- package/dist/module/hooks/use-phone-mask.js.map +1 -1
- package/dist/module/index.js +3 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/safe-area/index.js.map +1 -1
- package/dist/module/safe-area/provider.js.map +1 -1
- package/dist/module/themes/adapters/index.js.map +1 -1
- package/dist/module/themes/adapters/react-navigation.js.map +1 -1
- package/dist/module/themes/default/index.js.map +1 -1
- package/dist/module/themes/index.js.map +1 -1
- package/dist/module/themes/provider.js +11 -2
- package/dist/module/themes/provider.js.map +1 -1
- package/dist/module/utils/use-themed-styles.js.map +1 -1
- package/dist/typescript/babel.config.d.ts +1 -6
- package/dist/typescript/babel.config.d.ts.map +1 -1
- package/dist/typescript/src/components/phone-input/components/country-picker.d.ts +3 -0
- package/dist/typescript/src/components/phone-input/components/country-picker.d.ts.map +1 -0
- package/dist/typescript/src/components/phone-input/components/phone-input-root.d.ts +17 -0
- package/dist/typescript/src/components/phone-input/components/phone-input-root.d.ts.map +1 -0
- package/dist/typescript/src/components/phone-input/components/phone-input.d.ts +8 -0
- package/dist/typescript/src/components/phone-input/components/phone-input.d.ts.map +1 -0
- package/dist/typescript/src/components/phone-input/context.d.ts +17 -0
- package/dist/typescript/src/components/phone-input/context.d.ts.map +1 -0
- package/dist/typescript/src/components/phone-input/index.d.ts +8 -1
- package/dist/typescript/src/components/phone-input/index.d.ts.map +1 -1
- package/dist/typescript/src/components/select/components/select-portal.d.ts +1 -1
- package/dist/typescript/src/components/select/components/select-portal.d.ts.map +1 -1
- package/dist/typescript/src/components/select/components/select-trigger.d.ts.map +1 -1
- package/dist/typescript/src/components/toast/components/toast-body.d.ts +9 -0
- package/dist/typescript/src/components/toast/components/toast-body.d.ts.map +1 -0
- package/dist/typescript/src/components/toast/manager.d.ts.map +1 -1
- package/dist/typescript/src/components/toast/types.d.ts +2 -0
- package/dist/typescript/src/components/toast/types.d.ts.map +1 -1
- package/dist/typescript/src/components/toast/variants/danger.d.ts.map +1 -1
- package/dist/typescript/src/components/toast/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/toast/variants/success.d.ts.map +1 -1
- package/dist/typescript/src/data/countries.d.ts +2 -1
- package/dist/typescript/src/data/countries.d.ts.map +1 -1
- package/dist/typescript/src/hooks/use-phone-mask.d.ts +2 -2
- package/dist/typescript/src/hooks/use-phone-mask.d.ts.map +1 -1
- package/dist/typescript/src/index.d.ts +4 -3
- package/dist/typescript/src/index.d.ts.map +1 -1
- package/dist/typescript/src/themes/provider.d.ts +10 -0
- package/dist/typescript/src/themes/provider.d.ts.map +1 -1
- package/package.json +2 -7
- package/src/components/phone-input/components/country-picker.tsx +155 -0
- package/src/components/phone-input/components/phone-input-root.tsx +85 -0
- package/src/components/phone-input/components/phone-input.tsx +43 -0
- package/src/components/phone-input/context.ts +32 -0
- package/src/components/phone-input/index.ts +10 -1
- package/src/components/phone-input/variants/default.tsx +1 -1
- package/src/components/select/components/select-portal.tsx +14 -2
- package/src/components/select/components/select-trigger.tsx +5 -6
- package/src/components/toast/components/toast-body.tsx +19 -0
- package/src/components/toast/manager.tsx +15 -5
- package/src/components/toast/types.ts +2 -0
- package/src/components/toast/variants/danger.tsx +6 -2
- package/src/components/toast/variants/default.tsx +6 -2
- package/src/components/toast/variants/success.tsx +6 -2
- package/src/data/countries.ts +606 -68
- package/src/hooks/use-phone-mask.ts +2 -2
- package/src/index.tsx +9 -3
- package/src/themes/provider.tsx +22 -1
- package/dist/module/components/phone-input/phone-input.js +0 -165
- package/dist/module/components/phone-input/phone-input.js.map +0 -1
- package/dist/typescript/src/components/phone-input/phone-input.d.ts +0 -16
- package/dist/typescript/src/components/phone-input/phone-input.d.ts.map +0 -1
- package/scripts/build.sh +0 -2
- package/src/components/phone-input/phone-input.tsx +0 -220
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
import type { PhoneMask } from "../../hooks";
|
|
3
|
+
import type { ViewRef } from "../../types/element.types";
|
|
4
|
+
import type { PhoneInputState, PhoneInputStyles } from "./types";
|
|
5
|
+
|
|
6
|
+
export interface PhoneInputContext {
|
|
7
|
+
value: string | undefined;
|
|
8
|
+
onChange: ((value: string) => void) | undefined;
|
|
9
|
+
|
|
10
|
+
isFocused: boolean;
|
|
11
|
+
setIsFocused: (focused: boolean) => void;
|
|
12
|
+
isDisabled: boolean;
|
|
13
|
+
|
|
14
|
+
triggerRef: React.RefObject<ViewRef | null>;
|
|
15
|
+
|
|
16
|
+
phoneMask: PhoneMask;
|
|
17
|
+
|
|
18
|
+
state: PhoneInputState;
|
|
19
|
+
styles: PhoneInputStyles;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const PhoneInputContext = createContext<PhoneInputContext | undefined>(
|
|
23
|
+
undefined,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const usePhoneInput = () => {
|
|
27
|
+
const context = useContext(PhoneInputContext);
|
|
28
|
+
if (!context) {
|
|
29
|
+
throw new Error("usePhoneInput must be used within a PhoneInputRoot");
|
|
30
|
+
}
|
|
31
|
+
return context;
|
|
32
|
+
};
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
export { PhoneInput, type PhoneInputProps } from "./phone-input";
|
|
2
1
|
export type { PhoneInputState, PhoneInputStyles } from "./types";
|
|
2
|
+
|
|
3
|
+
import { CountryPicker } from "./components/country-picker";
|
|
4
|
+
import { PhoneInput as PhoneInputComponent } from "./components/phone-input";
|
|
5
|
+
import { PhoneInputRoot } from "./components/phone-input-root";
|
|
6
|
+
|
|
7
|
+
export const PhoneInput = {
|
|
8
|
+
Root: PhoneInputRoot,
|
|
9
|
+
CountryPicker,
|
|
10
|
+
Input: PhoneInputComponent,
|
|
11
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
2
3
|
import { Portal } from "../../portal";
|
|
3
4
|
import { SelectContext, useSelect } from "../context";
|
|
4
5
|
|
|
@@ -16,12 +17,23 @@ export function SelectPortal(props: SelectPortalProps) {
|
|
|
16
17
|
}, []);
|
|
17
18
|
|
|
18
19
|
if (!select.isOpen) {
|
|
19
|
-
return
|
|
20
|
+
return (
|
|
21
|
+
<View
|
|
22
|
+
style={{ display: "none" }}
|
|
23
|
+
aria-hidden
|
|
24
|
+
accessibilityElementsHidden
|
|
25
|
+
importantForAccessibility="no-hide-descendants"
|
|
26
|
+
>
|
|
27
|
+
{props.children}
|
|
28
|
+
</View>
|
|
29
|
+
);
|
|
20
30
|
}
|
|
21
31
|
|
|
22
32
|
return (
|
|
23
33
|
<Portal name="select-portal">
|
|
24
|
-
<SelectContext.Provider value={select}>
|
|
34
|
+
<SelectContext.Provider value={select}>
|
|
35
|
+
{props.children}
|
|
36
|
+
</SelectContext.Provider>
|
|
25
37
|
</Portal>
|
|
26
38
|
);
|
|
27
39
|
}
|
|
@@ -62,18 +62,17 @@ export function SelectValue(props: SelectValueProps) {
|
|
|
62
62
|
(option) => option.value === select.value,
|
|
63
63
|
);
|
|
64
64
|
const selectedOptionLabel = selectedOption?.label;
|
|
65
|
+
const displayValue = selectedOptionLabel ?? select.value;
|
|
65
66
|
|
|
66
67
|
const composedStyles = calculateComposedStyles(
|
|
67
68
|
select.styles,
|
|
68
69
|
select.state,
|
|
69
|
-
|
|
70
|
+
displayValue ? "value" : "placeholder",
|
|
70
71
|
);
|
|
71
|
-
if (typeof
|
|
72
|
-
return <>{
|
|
72
|
+
if (!!displayValue && typeof displayValue !== "string") {
|
|
73
|
+
return <>{displayValue}</>;
|
|
73
74
|
}
|
|
74
75
|
return (
|
|
75
|
-
<Text style={composedStyles}>
|
|
76
|
-
{selectedOptionLabel ?? props.placeholder}
|
|
77
|
-
</Text>
|
|
76
|
+
<Text style={composedStyles}>{displayValue ?? props.placeholder}</Text>
|
|
78
77
|
);
|
|
79
78
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PropsWithRender } from "../../../types/props.types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { type StyleProp, View, type ViewStyle } from "react-native";
|
|
4
|
+
import { useToast } from "../context";
|
|
5
|
+
|
|
6
|
+
export interface ToastBodyProps {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
|
|
9
|
+
style?: StyleProp<ViewStyle>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function ToastBody(props: PropsWithRender<ToastBodyProps>) {
|
|
13
|
+
const toast = useToast();
|
|
14
|
+
|
|
15
|
+
const composedStyle = [toast.styles?.body, props.style];
|
|
16
|
+
|
|
17
|
+
const Component = props.render ?? View;
|
|
18
|
+
return <Component {...props} style={composedStyle} />;
|
|
19
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React, { useSyncExternalStore } from "react";
|
|
2
2
|
import { StyleSheet, View } from "react-native";
|
|
3
3
|
import { useSafeAreaInsets } from "../../safe-area";
|
|
4
|
+
import { useComponentsConfig } from "../../themes";
|
|
4
5
|
import { Portal } from "../portal";
|
|
6
|
+
import { ToastBody } from "./components/toast-body";
|
|
5
7
|
import { ToastDescription } from "./components/toast-description";
|
|
8
|
+
import { ToastIcon } from "./components/toast-icon";
|
|
6
9
|
import { ToastRoot } from "./components/toast-root";
|
|
7
10
|
import { ToastTitle } from "./components/toast-title";
|
|
8
11
|
import { ToastVariants } from "./variants";
|
|
@@ -107,12 +110,19 @@ interface ToastProps {
|
|
|
107
110
|
}
|
|
108
111
|
|
|
109
112
|
export function ToastComponent(props: ToastProps) {
|
|
113
|
+
const config = useComponentsConfig();
|
|
114
|
+
const variant = props.variant ?? "default";
|
|
115
|
+
const IconComponent = config?.toast?.icons?.[variant];
|
|
116
|
+
|
|
110
117
|
return (
|
|
111
|
-
<ToastRoot variant={
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
<
|
|
115
|
-
|
|
118
|
+
<ToastRoot variant={variant}>
|
|
119
|
+
{!!IconComponent && <ToastIcon render={IconComponent} />}
|
|
120
|
+
<ToastBody>
|
|
121
|
+
<ToastTitle>{props.title}</ToastTitle>
|
|
122
|
+
{!!props.description && (
|
|
123
|
+
<ToastDescription>{props.description}</ToastDescription>
|
|
124
|
+
)}
|
|
125
|
+
</ToastBody>
|
|
116
126
|
</ToastRoot>
|
|
117
127
|
);
|
|
118
128
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ToastBodyProps } from "./components/toast-body";
|
|
1
2
|
import type { ToastDescriptionProps } from "./components/toast-description";
|
|
2
3
|
import type { ToastIconProps } from "./components/toast-icon";
|
|
3
4
|
import type { ToastRootProps } from "./components/toast-root";
|
|
@@ -5,6 +6,7 @@ import type { ToastTitleProps } from "./components/toast-title";
|
|
|
5
6
|
|
|
6
7
|
export interface ToastStyles {
|
|
7
8
|
root?: ToastRootProps["style"];
|
|
9
|
+
body?: ToastBodyProps["style"];
|
|
8
10
|
icon?: ToastIconProps;
|
|
9
11
|
title?: ToastTitleProps["style"];
|
|
10
12
|
description?: ToastDescriptionProps["style"];
|
|
@@ -10,14 +10,18 @@ export const useToastVariantDanger = (): ToastStyles => {
|
|
|
10
10
|
borderColor: colors.danger,
|
|
11
11
|
borderRadius: radius,
|
|
12
12
|
padding: 16,
|
|
13
|
-
gap:
|
|
13
|
+
gap: 12,
|
|
14
14
|
minWidth: 300,
|
|
15
15
|
maxWidth: 400,
|
|
16
16
|
flexDirection: "row",
|
|
17
17
|
},
|
|
18
|
+
body: {
|
|
19
|
+
flex: 1,
|
|
20
|
+
gap: 4,
|
|
21
|
+
},
|
|
18
22
|
icon: {
|
|
19
23
|
color: colors.foreground,
|
|
20
|
-
size:
|
|
24
|
+
size: 16,
|
|
21
25
|
style: {
|
|
22
26
|
marginTop: 2,
|
|
23
27
|
},
|
|
@@ -10,14 +10,18 @@ export const useToastVariantDefault = (): ToastStyles => {
|
|
|
10
10
|
borderColor: colors.border,
|
|
11
11
|
borderRadius: radius,
|
|
12
12
|
padding: 16,
|
|
13
|
-
gap:
|
|
13
|
+
gap: 12,
|
|
14
14
|
minWidth: 300,
|
|
15
15
|
maxWidth: 400,
|
|
16
16
|
flexDirection: "row",
|
|
17
17
|
},
|
|
18
|
+
body: {
|
|
19
|
+
flex: 1,
|
|
20
|
+
gap: 4,
|
|
21
|
+
},
|
|
18
22
|
icon: {
|
|
19
23
|
color: colors.foreground,
|
|
20
|
-
size:
|
|
24
|
+
size: 16,
|
|
21
25
|
style: {
|
|
22
26
|
marginTop: 2,
|
|
23
27
|
},
|
|
@@ -10,14 +10,18 @@ export const useToastVariantSuccess = (): ToastStyles => {
|
|
|
10
10
|
borderColor: colors.success,
|
|
11
11
|
borderRadius: radius,
|
|
12
12
|
padding: 16,
|
|
13
|
-
gap:
|
|
13
|
+
gap: 12,
|
|
14
14
|
minWidth: 300,
|
|
15
15
|
maxWidth: 400,
|
|
16
16
|
flexDirection: "row",
|
|
17
17
|
},
|
|
18
|
+
body: {
|
|
19
|
+
flex: 1,
|
|
20
|
+
gap: 4,
|
|
21
|
+
},
|
|
18
22
|
icon: {
|
|
19
23
|
color: colors.foreground,
|
|
20
|
-
size:
|
|
24
|
+
size: 16,
|
|
21
25
|
style: {
|
|
22
26
|
marginTop: 2,
|
|
23
27
|
},
|