@lion-npm/ui 1.0.1 → 1.0.2
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 +1 -1
- package/src/App.tsx +3 -0
- package/src/components/buttons/BootstrapButton.tsx +1 -1
- package/src/components/buttons/LionButton.tsx +0 -3
- package/src/components/inputs/BootstrapInput.tsx +20 -20
- package/src/components/inputs/IOSInput.tsx +6 -6
- package/src/components/inputs/LionInput.tsx +81 -0
- package/src/components/modals/LionModal.tsx +2 -4
- package/src/context/LionUIComponentsContext.tsx +10 -2
- package/src/features/Header.tsx +6 -0
- package/src/features/buttons/components/ButtonsBootstrapSection.tsx +1 -1
- package/src/features/buttons/components/ButtonsCustomSection.tsx +2 -2
- package/src/features/inputs/components/InputsCustomSection.tsx +234 -0
- package/src/features/inputs/components/InputsIOSSection.tsx +9 -9
- package/src/features/modals/components/ModalsAndroidSection.tsx +6 -1
- package/src/features/modals/components/ModalsWebSection.tsx +6 -1
- package/src/index.ts +27 -0
- package/src/interfaces/LionUIState.tsx +5 -0
- package/src/types/ButtonTypes.tsx +1 -1
- package/src/types/IOS/{iOSInputShapeTypes.tsx → IOSInputShapeTypes.tsx} +3 -3
- package/src/types/IOS/{iOSInputStyleTypes.tsx → IOSInputStyleTypes.tsx} +3 -3
- package/src/types/Web/BootstrapShapeTypes.tsx +1 -1
- package/vite.config.ts +26 -7
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -33,6 +33,7 @@ import ModalsIOSSection from "./features/modals/components/ModalsIOSSection.tsx"
|
|
|
33
33
|
import ModalsWebSection from "./features/modals/components/ModalsWebSection.tsx";
|
|
34
34
|
import LoadingSection from "./features/loadings/LoadingSection.tsx";
|
|
35
35
|
import LoadingBarSection from "./features/loadings/components/LoadingBarSection.tsx";
|
|
36
|
+
import InputsCustomSection from "./features/inputs/components/InputsCustomSection.tsx";
|
|
36
37
|
|
|
37
38
|
export default function App() {
|
|
38
39
|
return (
|
|
@@ -55,6 +56,8 @@ export default function App() {
|
|
|
55
56
|
</Route>
|
|
56
57
|
|
|
57
58
|
<Route path={"inputs"} element={<InputsSection />}>
|
|
59
|
+
<Route path={"custom"} element={<InputsCustomSection />} />
|
|
60
|
+
|
|
58
61
|
<Route path={"android"} element={<InputsAndroidSection />} />
|
|
59
62
|
|
|
60
63
|
<Route path={"ios"} element={<InputsIOSSection />} />
|
|
@@ -19,7 +19,7 @@ export default function BootstrapButton({
|
|
|
19
19
|
children,
|
|
20
20
|
variant = "primary" as VariantTypes,
|
|
21
21
|
styleType = BootstrapStyleTypes.FILLED,
|
|
22
|
-
shape = BootstrapShapeTypes.
|
|
22
|
+
shape = BootstrapShapeTypes.STANDARD,
|
|
23
23
|
size = "md" as SizeTypes,
|
|
24
24
|
type = "button" as ButtonTypes,
|
|
25
25
|
className = "",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { InputHTMLAttributes, useId} from "react";
|
|
1
|
+
import { type InputHTMLAttributes, useId } from "react";
|
|
2
2
|
import { InputTypes } from "../../types/InputTypes";
|
|
3
|
-
import {BootstrapInputShapeTypes} from "../../types/Web/BootstrapInputShapeTypes.tsx";
|
|
4
|
-
import {BootstrapInputStyleTypes} from "../../types/Web/BootstrapInputStyleTypes.tsx";
|
|
3
|
+
import { BootstrapInputShapeTypes } from "../../types/Web/BootstrapInputShapeTypes.tsx";
|
|
4
|
+
import { BootstrapInputStyleTypes } from "../../types/Web/BootstrapInputStyleTypes.tsx";
|
|
5
5
|
|
|
6
6
|
export interface BootstrapInputProps
|
|
7
7
|
extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "shape"> {
|
|
@@ -17,22 +17,22 @@ export interface BootstrapInputProps
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export default function BootstrapInput({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
type = InputTypes.TEXT,
|
|
21
|
+
styleType = BootstrapInputStyleTypes.FLOATING,
|
|
22
|
+
shape = BootstrapInputShapeTypes.ROUNDED,
|
|
23
|
+
variant = "primary",
|
|
24
|
+
sizeType = "md",
|
|
25
|
+
label,
|
|
26
|
+
required = false,
|
|
27
|
+
helperText,
|
|
28
|
+
error,
|
|
29
|
+
disabled = false,
|
|
30
|
+
readOnly = false,
|
|
31
|
+
id,
|
|
32
|
+
className = "",
|
|
33
|
+
placeholder = " ",
|
|
34
|
+
...rest
|
|
35
|
+
}: BootstrapInputProps) {
|
|
36
36
|
const generatedId = useId();
|
|
37
37
|
const inputId = id || generatedId;
|
|
38
38
|
|
|
@@ -103,4 +103,4 @@ export default function BootstrapInput({
|
|
|
103
103
|
) : null}
|
|
104
104
|
</div>
|
|
105
105
|
);
|
|
106
|
-
}
|
|
106
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React, { useId, useState } from "react";
|
|
2
2
|
import { InputTypes } from "../../types/InputTypes";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { IOSInputStyleTypes } from "../../types/IOS/IOSInputStyleTypes.tsx";
|
|
4
|
+
import { IOSInputShapeTypes } from "../../types/IOS/IOSInputShapeTypes.tsx";
|
|
5
5
|
|
|
6
6
|
export interface IOSInputProps
|
|
7
7
|
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "shape"> {
|
|
8
8
|
type?: InputTypes;
|
|
9
|
-
styleType?:
|
|
10
|
-
shape?:
|
|
9
|
+
styleType?: IOSInputStyleTypes;
|
|
10
|
+
shape?: IOSInputShapeTypes;
|
|
11
11
|
variant?: string;
|
|
12
12
|
sizeType?: "sx" | "sm" | "md" | "lg";
|
|
13
13
|
label?: string;
|
|
@@ -23,8 +23,8 @@ export interface IOSInputProps
|
|
|
23
23
|
|
|
24
24
|
export default function IOSInput({
|
|
25
25
|
type = InputTypes.TEXT,
|
|
26
|
-
styleType =
|
|
27
|
-
shape =
|
|
26
|
+
styleType = IOSInputStyleTypes.ROUNDED_BORDER,
|
|
27
|
+
shape = IOSInputShapeTypes.ROUNDED,
|
|
28
28
|
variant = "primary",
|
|
29
29
|
sizeType = "md",
|
|
30
30
|
label,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type InputHTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import { useLionUI } from "../../context/LionUIComponentsContext.tsx";
|
|
3
|
+
import { PlatformTypes } from "../../types/PlatformTypes.tsx";
|
|
4
|
+
import type { AndroidStyleTypes } from "../../types/Android/AndroidStyleTypes.tsx";
|
|
5
|
+
import type { AndroidShapeTypes } from "../../types/Android/AndroidShapeTypes.tsx";
|
|
6
|
+
import type { BootstrapShapeTypes } from "../../types/Web/BootstrapShapeTypes.tsx";
|
|
7
|
+
import type { BootstrapStyleTypes } from "../../types/Web/BootstrapStyleTypes.tsx";
|
|
8
|
+
import type { IOSShapeTypes } from "../../types/IOS/IOSShapeTypes.tsx";
|
|
9
|
+
import type { IOSStyleTypes } from "../../types/IOS/IOSStyleTypes.tsx";
|
|
10
|
+
import AndroidInput from "./AndroidInput.tsx";
|
|
11
|
+
import IOSInput from "./IOSInput.tsx";
|
|
12
|
+
import BootstrapInput from "./BootstrapInput.tsx";
|
|
13
|
+
|
|
14
|
+
type PlatformMapping<T> = {
|
|
15
|
+
[PlatformTypes.ANDROID]?: T;
|
|
16
|
+
[PlatformTypes.IOS]?: T;
|
|
17
|
+
[PlatformTypes.WEB]?: T;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type LionInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "shape"> & {
|
|
21
|
+
variant?: string;
|
|
22
|
+
platform?: string;
|
|
23
|
+
sizeType?: string;
|
|
24
|
+
shape?: BootstrapShapeTypes | AndroidShapeTypes | IOSShapeTypes | string | PlatformMapping<BootstrapShapeTypes | AndroidShapeTypes | IOSShapeTypes | string>;
|
|
25
|
+
styleType?: BootstrapStyleTypes | AndroidStyleTypes | IOSStyleTypes | string | PlatformMapping<BootstrapStyleTypes | AndroidStyleTypes | IOSStyleTypes | string>;
|
|
26
|
+
label?: string;
|
|
27
|
+
required?: boolean;
|
|
28
|
+
helperText?: string;
|
|
29
|
+
error?: boolean | string;
|
|
30
|
+
startIcon?: ReactNode;
|
|
31
|
+
endIcon?: ReactNode;
|
|
32
|
+
prefixText?: string;
|
|
33
|
+
suffixText?: string;
|
|
34
|
+
counter?: boolean | number;
|
|
35
|
+
clearable?: boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default function LionInput({
|
|
39
|
+
shape,
|
|
40
|
+
styleType,
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
platform = null,
|
|
43
|
+
...props
|
|
44
|
+
}: LionInputProps) {
|
|
45
|
+
const { state } = useLionUI();
|
|
46
|
+
|
|
47
|
+
// Resolve active platform from props or global context
|
|
48
|
+
const activePlatform = platform ?? state.platform;
|
|
49
|
+
|
|
50
|
+
// Helper function to resolve platform-specific property mappings
|
|
51
|
+
const resolvePlatformProp = <T,>(propValue?: T | PlatformMapping<T>): T | undefined => {
|
|
52
|
+
if (typeof propValue === "object" && propValue !== null) {
|
|
53
|
+
const map = propValue as PlatformMapping<T>;
|
|
54
|
+
return map[activePlatform as keyof PlatformMapping<T>] ?? map[activePlatform.toLowerCase() as keyof PlatformMapping<T>];
|
|
55
|
+
}
|
|
56
|
+
return propValue as T;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const resolvedShape = resolvePlatformProp(shape);
|
|
60
|
+
const resolvedStyleType = resolvePlatformProp(styleType);
|
|
61
|
+
|
|
62
|
+
const inputProps = {
|
|
63
|
+
...props,
|
|
64
|
+
...(resolvedShape !== undefined && { shape: resolvedShape }),
|
|
65
|
+
...(resolvedStyleType !== undefined && { styleType: resolvedStyleType }),
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Render the appropriate input component based on the active platform
|
|
69
|
+
switch (activePlatform) {
|
|
70
|
+
case PlatformTypes.ANDROID:
|
|
71
|
+
return <AndroidInput {...(inputProps as any)} />;
|
|
72
|
+
|
|
73
|
+
case PlatformTypes.IOS:
|
|
74
|
+
return <IOSInput {...(inputProps as any)} />;
|
|
75
|
+
|
|
76
|
+
case PlatformTypes.WEB:
|
|
77
|
+
case PlatformTypes.DESKTOP:
|
|
78
|
+
default:
|
|
79
|
+
return <BootstrapInput {...(inputProps as any)} />;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -11,12 +11,12 @@ export interface LionModalProps {
|
|
|
11
11
|
title: string;
|
|
12
12
|
body: ReactNode;
|
|
13
13
|
buttons?: ReactNode;
|
|
14
|
-
backdrop
|
|
14
|
+
backdrop?: string;
|
|
15
15
|
fullscreen?: true | "sm" | "md" | "lg" | "xl" | "xxl" | "sm-down" | "md-down" | "lg-down" | "xl-down" | "xxl-down";
|
|
16
16
|
// @ts-ignore
|
|
17
17
|
size?: SizeTypes.SM | SizeTypes.LG | SizeTypes.XL;
|
|
18
18
|
variant?: VariantTypes | string;
|
|
19
|
-
platform?: string;
|
|
19
|
+
platform?: PlatformTypes | string;
|
|
20
20
|
cancelButtonIcon?: ReactNode;
|
|
21
21
|
cancelButtonText?: string;
|
|
22
22
|
}
|
|
@@ -140,8 +140,6 @@ export default function LionModal({
|
|
|
140
140
|
</Modal.Title>
|
|
141
141
|
</Modal.Header>
|
|
142
142
|
|
|
143
|
-
{/* state.loading && <LoadingBar /> */}
|
|
144
|
-
|
|
145
143
|
<Modal.Body className="custom-modal-body px-4 py-3">
|
|
146
144
|
{modalId === state.modal ? body : null}
|
|
147
145
|
</Modal.Body>
|
|
@@ -18,7 +18,7 @@ export const LionUIComponentsProvider: FC<LionUIComponentsProviderProps> = ({
|
|
|
18
18
|
initialPlatform = defaultPlatform;
|
|
19
19
|
} else {
|
|
20
20
|
const capPlatform = Capacitor.getPlatform();
|
|
21
|
-
if (capPlatform ===
|
|
21
|
+
if (capPlatform === PlatformTypes.IOS || capPlatform === PlatformTypes.ANDROID) {
|
|
22
22
|
initialPlatform = capPlatform as PlatformTypes;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -27,7 +27,12 @@ export const LionUIComponentsProvider: FC<LionUIComponentsProviderProps> = ({
|
|
|
27
27
|
platform: initialPlatform,
|
|
28
28
|
loading: false,
|
|
29
29
|
reload: false,
|
|
30
|
+
booting: false,
|
|
31
|
+
sidebar: false,
|
|
32
|
+
version: null,
|
|
30
33
|
modal: null,
|
|
34
|
+
logo: null,
|
|
35
|
+
background: null,
|
|
31
36
|
};
|
|
32
37
|
});
|
|
33
38
|
|
|
@@ -39,7 +44,10 @@ export const LionUIComponentsProvider: FC<LionUIComponentsProviderProps> = ({
|
|
|
39
44
|
if (!defaultPlatform) {
|
|
40
45
|
const capPlatform = Capacitor.getPlatform();
|
|
41
46
|
|
|
42
|
-
const detected: PlatformTypes =
|
|
47
|
+
const detected: PlatformTypes =
|
|
48
|
+
capPlatform === PlatformTypes.IOS || capPlatform === PlatformTypes.ANDROID
|
|
49
|
+
? (capPlatform as PlatformTypes)
|
|
50
|
+
: PlatformTypes.WEB;
|
|
43
51
|
|
|
44
52
|
if (detected !== state.platform) {
|
|
45
53
|
setState((prev) => ({ ...prev, platform: detected }));
|
package/src/features/Header.tsx
CHANGED
|
@@ -37,6 +37,12 @@ export default function Header() {
|
|
|
37
37
|
</NavDropdown>
|
|
38
38
|
|
|
39
39
|
<NavDropdown title="Inputs" id="inputs-nav-dropdown">
|
|
40
|
+
<NavDropdown.Item as={Link} to={"/inputs/custom"} href={"#"}>
|
|
41
|
+
Custom
|
|
42
|
+
</NavDropdown.Item>
|
|
43
|
+
|
|
44
|
+
<NavDropdown.Divider />
|
|
45
|
+
|
|
40
46
|
<NavDropdown.Item as={Link} to={"/inputs/android"} href={"#"}>
|
|
41
47
|
Android
|
|
42
48
|
</NavDropdown.Item>
|
|
@@ -14,7 +14,7 @@ const StyleTypeList: Array<{ label: string; styleType: BootstrapStyleTypes }> =
|
|
|
14
14
|
|
|
15
15
|
// List of supported Bootstrap shapes
|
|
16
16
|
const ShapeList: Array<{ label: string; shape: BootstrapShapeTypes }> = [
|
|
17
|
-
{ label: "Default Shape", shape: BootstrapShapeTypes.
|
|
17
|
+
{ label: "Default Shape", shape: BootstrapShapeTypes.STANDARD },
|
|
18
18
|
{ label: "Pill Shape", shape: BootstrapShapeTypes.PILL },
|
|
19
19
|
{ label: "Square Shape", shape: BootstrapShapeTypes.SQUARE },
|
|
20
20
|
];
|
|
@@ -21,7 +21,7 @@ const shapesByPlatform = {
|
|
|
21
21
|
{ label: "Rounded", value: IOSShapeTypes.ROUNDED },
|
|
22
22
|
],
|
|
23
23
|
[PlatformTypes.WEB]: [
|
|
24
|
-
{ label: "
|
|
24
|
+
{ label: "Standard", value: BootstrapShapeTypes.STANDARD },
|
|
25
25
|
{ label: "Pill", value: BootstrapShapeTypes.PILL },
|
|
26
26
|
{ label: "Square", value: BootstrapShapeTypes.SQUARE },
|
|
27
27
|
],
|
|
@@ -51,7 +51,7 @@ export default function ButtonsCustomSection() {
|
|
|
51
51
|
const [selectedPlatform, setSelectedPlatform] = useState<PlatformTypes>(PlatformTypes.ANDROID);
|
|
52
52
|
const [selectedAndroidShape, setSelectedAndroidShape] = useState<AndroidShapeTypes>(AndroidShapeTypes.PILL);
|
|
53
53
|
const [selectedIOSShape, setSelectedIOSShape] = useState<IOSShapeTypes>(IOSShapeTypes.CAPSULE);
|
|
54
|
-
const [selectedWebShape, setSelectedWebShape] = useState<BootstrapShapeTypes>(BootstrapShapeTypes.
|
|
54
|
+
const [selectedWebShape, setSelectedWebShape] = useState<BootstrapShapeTypes>(BootstrapShapeTypes.STANDARD);
|
|
55
55
|
|
|
56
56
|
const [selectedAndroidStyle, setSelectedAndroidStyle] = useState<AndroidStyleTypes>(AndroidStyleTypes.TONAL);
|
|
57
57
|
const [selectedIOSStyle, setSelectedIOSStyle] = useState<IOSStyleTypes>(IOSStyleTypes.TINTED);
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import VariantList from "../../VariantList.tsx";
|
|
2
|
+
import { PlatformTypes } from "../../../types/PlatformTypes.tsx";
|
|
3
|
+
import { InputTypes } from "../../../types/InputTypes.tsx";
|
|
4
|
+
import { AndroidInputStyleTypes } from "../../../types/Android/AndroidInputStyleTypes.tsx";
|
|
5
|
+
import { IOSInputStyleTypes } from "../../../types/IOS/IOSInputStyleTypes.tsx";
|
|
6
|
+
import { BootstrapInputStyleTypes } from "../../../types/Web/BootstrapInputStyleTypes.tsx";
|
|
7
|
+
import { AndroidInputShapeTypes } from "../../../types/Android/AndroidInputShapeTypes.tsx";
|
|
8
|
+
import { BootstrapInputShapeTypes } from "../../../types/Web/BootstrapInputShapeTypes.tsx";
|
|
9
|
+
import { IOSInputShapeTypes } from "../../../types/IOS/IOSInputShapeTypes.tsx";
|
|
10
|
+
import { Fragment, useState } from "react";
|
|
11
|
+
import LionInput from "../../../components/inputs/LionInput.tsx";
|
|
12
|
+
|
|
13
|
+
const shapesByPlatform = {
|
|
14
|
+
[PlatformTypes.ANDROID]: [
|
|
15
|
+
{ label: "Small", value: AndroidInputShapeTypes.SMALL },
|
|
16
|
+
{ label: "Normal", value: AndroidInputShapeTypes.NORMAL },
|
|
17
|
+
],
|
|
18
|
+
[PlatformTypes.IOS]: [
|
|
19
|
+
{ label: "Rounded", value: IOSInputShapeTypes.ROUNDED },
|
|
20
|
+
{ label: "Pill", value: IOSInputShapeTypes.PILL },
|
|
21
|
+
{ label: "Square", value: IOSInputShapeTypes.SQUARE },
|
|
22
|
+
],
|
|
23
|
+
[PlatformTypes.WEB]: [
|
|
24
|
+
{ label: "Rounded", value: BootstrapInputShapeTypes.ROUNDED },
|
|
25
|
+
{ label: "Pill", value: BootstrapInputShapeTypes.PILL },
|
|
26
|
+
{ label: "Square", value: BootstrapInputShapeTypes.SQUARE },
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const stylesByPlatform = {
|
|
31
|
+
[PlatformTypes.ANDROID]: [
|
|
32
|
+
{ label: "Outlined", value: AndroidInputStyleTypes.OUTLINED },
|
|
33
|
+
{ label: "Filled", value: AndroidInputStyleTypes.FILLED },
|
|
34
|
+
],
|
|
35
|
+
[PlatformTypes.IOS]: [
|
|
36
|
+
{ label: "Form", value: IOSInputStyleTypes.FORM },
|
|
37
|
+
{ label: "Rounded Border", value: IOSInputStyleTypes.ROUNDED_BORDER },
|
|
38
|
+
{ label: "Filled", value: IOSInputStyleTypes.FILLED },
|
|
39
|
+
{ label: "Outlined", value: IOSInputStyleTypes.OUTLINED },
|
|
40
|
+
{ label: "Plain", value: IOSInputStyleTypes.PLAIN },
|
|
41
|
+
],
|
|
42
|
+
[PlatformTypes.WEB]: [
|
|
43
|
+
{ label: "Floating", value: BootstrapInputStyleTypes.FLOATING },
|
|
44
|
+
{ label: "Standard", value: BootstrapInputStyleTypes.STANDARD },
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default function InputsCustomSection() {
|
|
49
|
+
const [selectedPlatform, setSelectedPlatform] = useState<PlatformTypes>(PlatformTypes.ANDROID);
|
|
50
|
+
const [selectedAndroidShape, setSelectedAndroidShape] = useState<AndroidInputShapeTypes>(AndroidInputShapeTypes.NORMAL);
|
|
51
|
+
const [selectedIOSShape, setSelectedIOSShape] = useState<IOSInputShapeTypes>(IOSInputShapeTypes.ROUNDED);
|
|
52
|
+
const [selectedWebShape, setSelectedWebShape] = useState<BootstrapInputShapeTypes>(BootstrapInputShapeTypes.ROUNDED);
|
|
53
|
+
|
|
54
|
+
const [selectedAndroidStyle, setSelectedAndroidStyle] = useState<AndroidInputStyleTypes>(AndroidInputStyleTypes.OUTLINED);
|
|
55
|
+
const [selectedIOSStyle, setSelectedIOSStyle] = useState<IOSInputStyleTypes>(IOSInputStyleTypes.ROUNDED_BORDER);
|
|
56
|
+
const [selectedWebStyle, setSelectedWebStyle] = useState<BootstrapInputStyleTypes>(BootstrapInputStyleTypes.FLOATING);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<Fragment>
|
|
60
|
+
<h2>Inputs (Custom Cross-Platform Test)</h2>
|
|
61
|
+
|
|
62
|
+
<div className="card p-3 mb-4 bg-light">
|
|
63
|
+
<div className="row g-3">
|
|
64
|
+
<div className="col-md-4">
|
|
65
|
+
<label className="form-label fw-bold">Platform:</label>
|
|
66
|
+
<div className="btn-group w-100" role="group">
|
|
67
|
+
<button
|
|
68
|
+
type="button"
|
|
69
|
+
className={`btn ${selectedPlatform === PlatformTypes.ANDROID ? "btn-primary" : "btn-outline-primary"}`}
|
|
70
|
+
onClick={() => setSelectedPlatform(PlatformTypes.ANDROID)}
|
|
71
|
+
>
|
|
72
|
+
Android
|
|
73
|
+
</button>
|
|
74
|
+
<button
|
|
75
|
+
type="button"
|
|
76
|
+
className={`btn ${selectedPlatform === PlatformTypes.IOS ? "btn-primary" : "btn-outline-primary"}`}
|
|
77
|
+
onClick={() => setSelectedPlatform(PlatformTypes.IOS)}
|
|
78
|
+
>
|
|
79
|
+
iOS
|
|
80
|
+
</button>
|
|
81
|
+
<button
|
|
82
|
+
type="button"
|
|
83
|
+
className={`btn ${selectedPlatform === PlatformTypes.WEB ? "btn-primary" : "btn-outline-primary"}`}
|
|
84
|
+
onClick={() => setSelectedPlatform(PlatformTypes.WEB)}
|
|
85
|
+
>
|
|
86
|
+
Web
|
|
87
|
+
</button>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<div className="col-md-4">
|
|
92
|
+
<label className="form-label fw-bold">Shape:</label>
|
|
93
|
+
|
|
94
|
+
{selectedPlatform === PlatformTypes.ANDROID && (
|
|
95
|
+
<select
|
|
96
|
+
className="form-select"
|
|
97
|
+
value={selectedAndroidShape}
|
|
98
|
+
onChange={(e) => setSelectedAndroidShape(e.target.value as AndroidInputShapeTypes)}
|
|
99
|
+
>
|
|
100
|
+
{shapesByPlatform[PlatformTypes.ANDROID].map((s) => (
|
|
101
|
+
<option key={s.value} value={s.value}>{s.label}</option>
|
|
102
|
+
))}
|
|
103
|
+
</select>
|
|
104
|
+
)}
|
|
105
|
+
|
|
106
|
+
{selectedPlatform === PlatformTypes.IOS && (
|
|
107
|
+
<select
|
|
108
|
+
className="form-select"
|
|
109
|
+
value={selectedIOSShape}
|
|
110
|
+
onChange={(e) => setSelectedIOSShape(e.target.value as IOSInputShapeTypes)}
|
|
111
|
+
>
|
|
112
|
+
{shapesByPlatform[PlatformTypes.IOS].map((s) => (
|
|
113
|
+
<option key={s.value} value={s.value}>{s.label}</option>
|
|
114
|
+
))}
|
|
115
|
+
</select>
|
|
116
|
+
)}
|
|
117
|
+
|
|
118
|
+
{selectedPlatform === PlatformTypes.WEB && (
|
|
119
|
+
<select
|
|
120
|
+
className="form-select"
|
|
121
|
+
value={selectedWebShape}
|
|
122
|
+
onChange={(e) => setSelectedWebShape(e.target.value as BootstrapInputShapeTypes)}
|
|
123
|
+
>
|
|
124
|
+
{shapesByPlatform[PlatformTypes.WEB].map((s) => (
|
|
125
|
+
<option key={s.value} value={s.value}>{s.label}</option>
|
|
126
|
+
))}
|
|
127
|
+
</select>
|
|
128
|
+
)}
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<div className="col-md-4">
|
|
132
|
+
<label className="form-label fw-bold">StyleType:</label>
|
|
133
|
+
{selectedPlatform === PlatformTypes.ANDROID && (
|
|
134
|
+
<select
|
|
135
|
+
className="form-select"
|
|
136
|
+
value={selectedAndroidStyle}
|
|
137
|
+
onChange={(e) => setSelectedAndroidStyle(e.target.value as AndroidInputStyleTypes)}
|
|
138
|
+
>
|
|
139
|
+
{stylesByPlatform[PlatformTypes.ANDROID].map((s) => (
|
|
140
|
+
<option key={s.value} value={s.value}>{s.label}</option>
|
|
141
|
+
))}
|
|
142
|
+
</select>
|
|
143
|
+
)}
|
|
144
|
+
|
|
145
|
+
{selectedPlatform === PlatformTypes.IOS && (
|
|
146
|
+
<select
|
|
147
|
+
className="form-select"
|
|
148
|
+
value={selectedIOSStyle}
|
|
149
|
+
onChange={(e) => setSelectedIOSStyle(e.target.value as IOSInputStyleTypes)}
|
|
150
|
+
>
|
|
151
|
+
{stylesByPlatform[PlatformTypes.IOS].map((s) => (
|
|
152
|
+
<option key={s.value} value={s.value}>{s.label}</option>
|
|
153
|
+
))}
|
|
154
|
+
</select>
|
|
155
|
+
)}
|
|
156
|
+
|
|
157
|
+
{selectedPlatform === PlatformTypes.WEB && (
|
|
158
|
+
<select
|
|
159
|
+
className="form-select"
|
|
160
|
+
value={selectedWebStyle}
|
|
161
|
+
onChange={(e) => setSelectedWebStyle(e.target.value as BootstrapInputStyleTypes)}
|
|
162
|
+
>
|
|
163
|
+
{stylesByPlatform[PlatformTypes.WEB].map((s) => (
|
|
164
|
+
<option key={s.value} value={s.value}>{s.label}</option>
|
|
165
|
+
))}
|
|
166
|
+
</select>
|
|
167
|
+
)}
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
<div className="my-4">
|
|
173
|
+
<div className="ms-3 mb-4">
|
|
174
|
+
{/* Enabled State */}
|
|
175
|
+
<div className="mb-4">
|
|
176
|
+
<span className="text-muted d-block mb-2 small fw-bold">Enabled</span>
|
|
177
|
+
<div className="row g-3">
|
|
178
|
+
{VariantList.map((variant) => (
|
|
179
|
+
<div key={`custom-input-${variant}-enabled`} className="col-md-4">
|
|
180
|
+
<LionInput
|
|
181
|
+
type={InputTypes.TEXT}
|
|
182
|
+
platform={selectedPlatform}
|
|
183
|
+
variant={variant}
|
|
184
|
+
label={`${variant} input`}
|
|
185
|
+
placeholder="Enter text..."
|
|
186
|
+
styleType={{
|
|
187
|
+
android: selectedAndroidStyle,
|
|
188
|
+
ios: selectedIOSStyle,
|
|
189
|
+
web: selectedWebStyle,
|
|
190
|
+
}}
|
|
191
|
+
shape={{
|
|
192
|
+
android: selectedAndroidShape,
|
|
193
|
+
ios: selectedIOSShape,
|
|
194
|
+
web: selectedWebShape,
|
|
195
|
+
}}
|
|
196
|
+
/>
|
|
197
|
+
</div>
|
|
198
|
+
))}
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
{/* Disabled State */}
|
|
203
|
+
<div>
|
|
204
|
+
<span className="text-muted d-block mb-2 small fw-bold">Disabled</span>
|
|
205
|
+
<div className="row g-3">
|
|
206
|
+
{VariantList.map((variant) => (
|
|
207
|
+
<div key={`custom-input-${variant}-disabled`} className="col-md-4">
|
|
208
|
+
<LionInput
|
|
209
|
+
type={InputTypes.TEXT}
|
|
210
|
+
platform={selectedPlatform}
|
|
211
|
+
variant={variant}
|
|
212
|
+
label={`${variant} input`}
|
|
213
|
+
placeholder="Disabled..."
|
|
214
|
+
disabled={true}
|
|
215
|
+
styleType={{
|
|
216
|
+
android: selectedAndroidStyle,
|
|
217
|
+
ios: selectedIOSStyle,
|
|
218
|
+
web: selectedWebStyle,
|
|
219
|
+
}}
|
|
220
|
+
shape={{
|
|
221
|
+
android: selectedAndroidShape,
|
|
222
|
+
ios: selectedIOSShape,
|
|
223
|
+
web: selectedWebShape,
|
|
224
|
+
}}
|
|
225
|
+
/>
|
|
226
|
+
</div>
|
|
227
|
+
))}
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
</Fragment>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import VariantList from "../../VariantList.tsx";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { IOSInputStyleTypes } from "../../../types/IOS/IOSInputStyleTypes.tsx";
|
|
3
|
+
import { IOSInputShapeTypes } from "../../../types/IOS/IOSInputShapeTypes.tsx";
|
|
4
4
|
import { InputTypes } from "../../../types/InputTypes.tsx";
|
|
5
5
|
|
|
6
6
|
import { Fragment, useState } from "react";
|
|
7
7
|
import IOSInput from "../../../components/inputs/IOSInput.tsx";
|
|
8
8
|
|
|
9
|
-
const StyleTypeList: Array<{ label: string; styleType:
|
|
10
|
-
{ label: "Form", styleType:
|
|
11
|
-
{ label: "Rounded Border", styleType:
|
|
9
|
+
const StyleTypeList: Array<{ label: string; styleType: IOSInputStyleTypes }> = [
|
|
10
|
+
{ label: "Form", styleType: IOSInputStyleTypes.FORM },
|
|
11
|
+
{ label: "Rounded Border", styleType: IOSInputStyleTypes.ROUNDED_BORDER },
|
|
12
12
|
];
|
|
13
13
|
|
|
14
|
-
const ShapeList: Array<{ label: string; shape:
|
|
15
|
-
{ label: "Rounded Shape", shape:
|
|
16
|
-
{ label: "Pill Shape", shape:
|
|
17
|
-
{ label: "Square Shape", shape:
|
|
14
|
+
const ShapeList: Array<{ label: string; shape: IOSInputShapeTypes }> = [
|
|
15
|
+
{ label: "Rounded Shape", shape: IOSInputShapeTypes.ROUNDED },
|
|
16
|
+
{ label: "Pill Shape", shape: IOSInputShapeTypes.PILL },
|
|
17
|
+
{ label: "Square Shape", shape: IOSInputShapeTypes.SQUARE },
|
|
18
18
|
];
|
|
19
19
|
|
|
20
20
|
export default function InputsIOSSection() {
|
|
@@ -86,7 +86,12 @@ export default function ModalsAndroidSection() {
|
|
|
86
86
|
title={modal.title}
|
|
87
87
|
size={modal.size}
|
|
88
88
|
fullscreen={modal.fullscreen}
|
|
89
|
-
body={
|
|
89
|
+
body={(
|
|
90
|
+
<ModalsDefaultForm
|
|
91
|
+
platform={PlatformTypes.ANDROID}
|
|
92
|
+
variant={modal.variant}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
90
95
|
buttons={(
|
|
91
96
|
<LionButton
|
|
92
97
|
variant={VariantTypes.MODAL}
|
|
@@ -82,7 +82,12 @@ export default function ModalsWebSection() {
|
|
|
82
82
|
title={modal.title}
|
|
83
83
|
size={modal.size}
|
|
84
84
|
fullscreen={modal.fullscreen}
|
|
85
|
-
body={
|
|
85
|
+
body={(
|
|
86
|
+
<ModalsDefaultForm
|
|
87
|
+
platform={PlatformTypes.WEB}
|
|
88
|
+
variant={modal.variant}
|
|
89
|
+
/>
|
|
90
|
+
)}
|
|
86
91
|
buttons={(
|
|
87
92
|
<LionButton
|
|
88
93
|
variant={VariantTypes.MODAL}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "./assets/css/index.css";
|
|
2
|
+
import "./assets/css/buttons/buttons-android.css";
|
|
3
|
+
import "./assets/css/buttons/buttons-ios.css";
|
|
4
|
+
import "./assets/css/buttons/buttons-web.css";
|
|
5
|
+
import "./assets/css/inputs/inputs-android.css";
|
|
6
|
+
import "./assets/css/inputs/inputs-ios.css";
|
|
7
|
+
import "./assets/css/inputs/inputs-bootstrap.css";
|
|
8
|
+
import "./assets/css/modals/modals.css";
|
|
9
|
+
import "./assets/css/loadings/loading-bar.css";
|
|
10
|
+
|
|
11
|
+
export { LionUIComponentsProvider } from './context/LionUIComponentsContext';
|
|
12
|
+
export { default as AndroidButton } from './components/buttons/AndroidButton';
|
|
13
|
+
export { default as BootstrapButton } from './components/buttons/BootstrapButton';
|
|
14
|
+
export { default as IOSButton } from './components/buttons/IOSButton';
|
|
15
|
+
export { default as LionButton } from './components/buttons/LionButton';
|
|
16
|
+
export { default as AndroidInput } from './components/inputs/AndroidInput';
|
|
17
|
+
export { default as BootstrapInput } from './components/inputs/BootstrapInput';
|
|
18
|
+
export { default as IOSInput } from './components/inputs/IOSInput';
|
|
19
|
+
export { default as LionInput } from './components/inputs/LionInput';
|
|
20
|
+
export { default as LoadingBar } from './components/loadings/LoadingBar';
|
|
21
|
+
export { default as LionModal } from './components/modals/LionModal';
|
|
22
|
+
|
|
23
|
+
export * from './types/ButtonTypes';
|
|
24
|
+
export * from './types/InputTypes';
|
|
25
|
+
export * from './types/PlatformTypes';
|
|
26
|
+
export * from './types/SizeTypes';
|
|
27
|
+
export * from './types/VariantTypes';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Official iOS / SwiftUI layout shapes and corner radiuses
|
|
2
|
-
export const
|
|
2
|
+
export const IOSInputShapeTypes = {
|
|
3
3
|
ROUNDED: "rounded", // Standard continuous iOS rounded corner
|
|
4
4
|
PILL: "pill", // Capsule shape
|
|
5
5
|
SQUARE: "square", // Sharp edges
|
|
6
6
|
} as const;
|
|
7
7
|
|
|
8
|
-
export type
|
|
9
|
-
(typeof
|
|
8
|
+
export type IOSInputShapeTypes =
|
|
9
|
+
(typeof IOSInputShapeTypes)[keyof typeof IOSInputShapeTypes];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Official SwiftUI TextFieldStyle representations from Apple Documentation
|
|
2
|
-
export const
|
|
2
|
+
export const IOSInputStyleTypes = {
|
|
3
3
|
FORM: "form", // SwiftUI Form/List row style (Horizontal Label + Input/Prompt)
|
|
4
4
|
ROUNDED_BORDER: "rounded-border", // SwiftUI .textFieldStyle(.roundedBorder)
|
|
5
5
|
FILLED: "filled", // iOS Native filled field style (Background tinted)
|
|
@@ -7,5 +7,5 @@ export const iOSInputStyleTypes = {
|
|
|
7
7
|
PLAIN: "plain", // SwiftUI .textFieldStyle(.plain)
|
|
8
8
|
} as const;
|
|
9
9
|
|
|
10
|
-
export type
|
|
11
|
-
(typeof
|
|
10
|
+
export type IOSInputStyleTypes =
|
|
11
|
+
(typeof IOSInputStyleTypes)[keyof typeof IOSInputStyleTypes];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Bootstrap 5 Corner Radius Options
|
|
2
2
|
export const BootstrapShapeTypes = {
|
|
3
|
-
|
|
3
|
+
STANDARD: "standard", // Standard Bootstrap border radius (~0.375rem)
|
|
4
4
|
PILL: "pill", // Fully rounded pill shape (.rounded-pill)
|
|
5
5
|
SQUARE: "square", // Sharp corners (.rounded-0)
|
|
6
6
|
} as const;
|
package/vite.config.ts
CHANGED
|
@@ -1,11 +1,30 @@
|
|
|
1
|
-
import { defineConfig } from 'vite'
|
|
2
|
-
import react from '@vitejs/plugin-react'
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import { resolve } from 'path';
|
|
3
4
|
|
|
4
|
-
// https://vite.dev/config/
|
|
5
5
|
export default defineConfig({
|
|
6
6
|
plugins: [react()],
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
build: {
|
|
8
|
+
lib: {
|
|
9
|
+
entry: resolve(__dirname, 'src/index.ts'),
|
|
10
|
+
name: 'LionUI',
|
|
11
|
+
fileName: 'index',
|
|
12
|
+
},
|
|
13
|
+
rollupOptions: {
|
|
14
|
+
external: ['react', 'react-dom', 'react/jsx-runtime'],
|
|
15
|
+
output: {
|
|
16
|
+
globals: {
|
|
17
|
+
react: 'React',
|
|
18
|
+
'react-dom': 'ReactDOM',
|
|
19
|
+
'react/jsx-runtime': 'react/jsx-runtime',
|
|
20
|
+
},
|
|
21
|
+
assetFileNames: (assetInfo) => {
|
|
22
|
+
if (assetInfo.name && assetInfo.name.endsWith('.css')) {
|
|
23
|
+
return 'style.css';
|
|
24
|
+
}
|
|
25
|
+
return 'assets/[name]-[hash][extname]';
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
10
29
|
},
|
|
11
|
-
})
|
|
30
|
+
});
|