@pathscale/ui 0.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.
- package/LICENSE +21 -0
- package/README.md +12 -0
- package/dist/Avatar-CzIirpVq.d.ts +33 -0
- package/dist/Button-BOYHKShy.d.ts +63 -0
- package/dist/Input-CvNxe1rq.d.ts +34 -0
- package/dist/Textarea-5_oQknZn.d.ts +37 -0
- package/dist/chunk/3MUBOGZG.js +213 -0
- package/dist/chunk/EB7KXR65.js +102 -0
- package/dist/chunk/G6RG4LR7.js +87 -0
- package/dist/chunk/HEJAQSH5.jsx +100 -0
- package/dist/chunk/HKS7ET6T.js +56 -0
- package/dist/chunk/KACNXPUM.jsx +103 -0
- package/dist/chunk/NLD5D3P7.jsx +94 -0
- package/dist/chunk/P7WPLZNA.jsx +59 -0
- package/dist/chunk/UTRNHAP4.js +95 -0
- package/dist/chunk/VMEDFWWG.js +102 -0
- package/dist/chunk/WB6NEEQV.jsx +107 -0
- package/dist/chunk/YZ3ID3UY.jsx +226 -0
- package/dist/classes-B_S9K-9I.d.ts +13 -0
- package/dist/components/avatar/index.d.ts +8 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/avatar/index.jsx +7 -0
- package/dist/components/button/index.d.ts +9 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/button/index.jsx +8 -0
- package/dist/components/input/index.d.ts +8 -0
- package/dist/components/input/index.js +1 -0
- package/dist/components/input/index.jsx +7 -0
- package/dist/components/polymorphic/index.d.ts +35 -0
- package/dist/components/polymorphic/index.js +1 -0
- package/dist/components/polymorphic/index.jsx +8 -0
- package/dist/components/textarea/index.d.ts +8 -0
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/textarea/index.jsx +7 -0
- package/dist/index.css +73 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -0
- package/dist/index.jsx +20 -0
- package/package.json +60 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cva
|
|
3
|
+
} from "./P7WPLZNA.jsx";
|
|
4
|
+
|
|
5
|
+
// src/components/Avatar/Avatar.tsx
|
|
6
|
+
import {
|
|
7
|
+
createSignal,
|
|
8
|
+
createMemo,
|
|
9
|
+
createEffect,
|
|
10
|
+
mergeProps,
|
|
11
|
+
splitProps,
|
|
12
|
+
Show
|
|
13
|
+
} from "solid-js";
|
|
14
|
+
|
|
15
|
+
// src/components/Avatar/Avatar.styles.ts
|
|
16
|
+
var avatarVariants = cva(
|
|
17
|
+
[
|
|
18
|
+
"flex items-center justify-center mx-1",
|
|
19
|
+
"font-medium outline-none select-none transition active:transition-none",
|
|
20
|
+
"not-disabled:cursor-pointer",
|
|
21
|
+
"disabled:cursor-not-allowed disabled:opacity-25",
|
|
22
|
+
"aria-busy:cursor-wait"
|
|
23
|
+
],
|
|
24
|
+
{
|
|
25
|
+
variants: {
|
|
26
|
+
size: {
|
|
27
|
+
sm: "size-8 text-sm",
|
|
28
|
+
md: "size-16 text-base",
|
|
29
|
+
lg: "size-24 text-lg"
|
|
30
|
+
},
|
|
31
|
+
shape: {
|
|
32
|
+
circle: "rounded-full overflow-hidden",
|
|
33
|
+
rounded: "rounded-lg overflow-hidden"
|
|
34
|
+
},
|
|
35
|
+
variant: {
|
|
36
|
+
filled: "bg-gray-200 text-gray-800",
|
|
37
|
+
outlined: "border-2 border-gray-300 text-gray-800",
|
|
38
|
+
ghost: "text-gray-800"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
defaultVariants: {
|
|
42
|
+
size: "md",
|
|
43
|
+
shape: "circle",
|
|
44
|
+
variant: "filled"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// src/components/Avatar/utils.ts
|
|
50
|
+
function parseCaption(alt) {
|
|
51
|
+
if (!alt) return "";
|
|
52
|
+
const parts = alt.split(" ");
|
|
53
|
+
if (parts.length >= 2 && parts[0] && parts[1]) {
|
|
54
|
+
return `${parts[0][0] ?? ""}${parts[1][0] ?? ""}`;
|
|
55
|
+
}
|
|
56
|
+
return "";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/components/Avatar/Avatar.tsx
|
|
60
|
+
var Avatar = (rawProps) => {
|
|
61
|
+
const props = mergeProps({ alt: "User Avatar" }, rawProps);
|
|
62
|
+
const [variantProps, otherProps] = splitProps(props, [
|
|
63
|
+
"class",
|
|
64
|
+
...avatarVariants.variantKeys
|
|
65
|
+
]);
|
|
66
|
+
const [source, setSource] = createSignal(props.src || props.dataSrc);
|
|
67
|
+
createEffect(() => {
|
|
68
|
+
if (import.meta.env.PROD && props.dataSrc) {
|
|
69
|
+
setSource(props.dataSrc);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
const backgroundColor = createMemo(
|
|
73
|
+
() => source() ? "" : props.class ?? "bg-blue-500"
|
|
74
|
+
);
|
|
75
|
+
const textColor = createMemo(
|
|
76
|
+
() => source() ? "" : props.text ?? "text-white"
|
|
77
|
+
);
|
|
78
|
+
const caption = createMemo(() => parseCaption(props.alt));
|
|
79
|
+
return <figure class={avatarVariants(variantProps)}>
|
|
80
|
+
<Show
|
|
81
|
+
when={source()}
|
|
82
|
+
fallback={<figcaption class="text-lg">{caption()}</figcaption>}
|
|
83
|
+
>
|
|
84
|
+
<img
|
|
85
|
+
src={source()}
|
|
86
|
+
data-src={props.dataSrc}
|
|
87
|
+
class="size-full object-cover"
|
|
88
|
+
{...otherProps}
|
|
89
|
+
/>
|
|
90
|
+
</Show>
|
|
91
|
+
</figure>;
|
|
92
|
+
};
|
|
93
|
+
var Avatar_default = Avatar;
|
|
94
|
+
|
|
95
|
+
// src/components/Avatar/index.ts
|
|
96
|
+
var Avatar_default2 = Avatar_default;
|
|
97
|
+
|
|
98
|
+
export {
|
|
99
|
+
Avatar_default2 as Avatar_default
|
|
100
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// src/lib/style/classes.ts
|
|
2
|
+
function classes(...args) {
|
|
3
|
+
return args.flat().filter(Boolean).join(" ");
|
|
4
|
+
}
|
|
5
|
+
function falsyToString(value) {
|
|
6
|
+
return typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
7
|
+
}
|
|
8
|
+
function cva(base, config) {
|
|
9
|
+
const fn = (props) => {
|
|
10
|
+
if (config?.variants == null) return classes(base, props?.class);
|
|
11
|
+
const { variants, defaultVariants } = config;
|
|
12
|
+
const getVariantClassNames = Object.keys(variants).map((variant) => {
|
|
13
|
+
const variantProp = props?.[variant];
|
|
14
|
+
const defaultVariantProp = defaultVariants?.[variant];
|
|
15
|
+
if (variantProp === null) return null;
|
|
16
|
+
const variantKey = falsyToString(variantProp) || falsyToString(
|
|
17
|
+
defaultVariantProp
|
|
18
|
+
);
|
|
19
|
+
return variants[variant]?.[variantKey];
|
|
20
|
+
});
|
|
21
|
+
const propsWithoutUndefined = Object.entries(props || {}).reduce(
|
|
22
|
+
(acc, [key, value]) => {
|
|
23
|
+
if (value !== void 0) {
|
|
24
|
+
acc[key] = value;
|
|
25
|
+
}
|
|
26
|
+
return acc;
|
|
27
|
+
},
|
|
28
|
+
{}
|
|
29
|
+
);
|
|
30
|
+
const getCompoundVariantClassNames = config?.compoundVariants?.reduce(
|
|
31
|
+
(acc, { class: cvClass, ...compoundVariantOptions }) => {
|
|
32
|
+
const isMatch = Object.entries(compoundVariantOptions).every(
|
|
33
|
+
([key, value]) => {
|
|
34
|
+
const currentValue = {
|
|
35
|
+
...defaultVariants,
|
|
36
|
+
...propsWithoutUndefined
|
|
37
|
+
}[key];
|
|
38
|
+
return Array.isArray(value) ? value.includes(currentValue) : currentValue === value;
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
return isMatch ? [...acc, cvClass] : acc;
|
|
42
|
+
},
|
|
43
|
+
[]
|
|
44
|
+
);
|
|
45
|
+
return classes(
|
|
46
|
+
base,
|
|
47
|
+
getVariantClassNames,
|
|
48
|
+
getCompoundVariantClassNames,
|
|
49
|
+
props?.class
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
fn.variantKeys = config?.variants ? Object.keys(config.variants) : [];
|
|
53
|
+
return fn;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { classes, cva };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// src/components/polymorphic/Polymorphic.tsx
|
|
2
|
+
import {
|
|
3
|
+
createMemo,
|
|
4
|
+
splitProps,
|
|
5
|
+
untrack
|
|
6
|
+
} from "solid-js";
|
|
7
|
+
import { Dynamic } from "solid-js/web";
|
|
8
|
+
var Polymorphic = (props) => {
|
|
9
|
+
const [localProps, otherProps] = splitProps(props, ["as"]);
|
|
10
|
+
const cached = createMemo(() => localProps.as ?? "div");
|
|
11
|
+
return createMemo(() => {
|
|
12
|
+
const component = cached();
|
|
13
|
+
switch (typeof component) {
|
|
14
|
+
case "function":
|
|
15
|
+
return untrack(() => component(otherProps));
|
|
16
|
+
case "string":
|
|
17
|
+
return <Dynamic
|
|
18
|
+
component={component}
|
|
19
|
+
{...otherProps}
|
|
20
|
+
/>;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
var Polymorphic_default = Polymorphic;
|
|
25
|
+
|
|
26
|
+
// src/lib/iterable.ts
|
|
27
|
+
function chain(callbacks) {
|
|
28
|
+
return (...args) => {
|
|
29
|
+
for (const callback of callbacks) callback?.(...args);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/lib/refs/mergeRefs.ts
|
|
34
|
+
function mergeRefs(...refs) {
|
|
35
|
+
return chain(refs);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/lib/tag/createIsButton.ts
|
|
39
|
+
import { createMemo as createMemo3 } from "solid-js";
|
|
40
|
+
|
|
41
|
+
// src/lib/tag/createTagName.ts
|
|
42
|
+
import { createMemo as createMemo2 } from "solid-js";
|
|
43
|
+
function createTagName(props) {
|
|
44
|
+
return createMemo2(
|
|
45
|
+
() => props.element()?.tagName.toLowerCase() ?? props.fallback
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// src/lib/tag/createIsButton.ts
|
|
50
|
+
var BUTTON_INPUT_TYPES = [
|
|
51
|
+
"button",
|
|
52
|
+
"color",
|
|
53
|
+
"file",
|
|
54
|
+
"image",
|
|
55
|
+
"reset",
|
|
56
|
+
"submit"
|
|
57
|
+
];
|
|
58
|
+
function isButton(tagName, type) {
|
|
59
|
+
if (tagName === "button") {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (tagName === "input" && type !== void 0) {
|
|
63
|
+
return BUTTON_INPUT_TYPES.indexOf(type) !== -1;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
function createIsButton(props) {
|
|
68
|
+
const tagName = createTagName({
|
|
69
|
+
element: props.element,
|
|
70
|
+
fallback: "button"
|
|
71
|
+
});
|
|
72
|
+
return createMemo3(() => isButton(tagName(), props.type));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// src/components/polymorphic/PolymorphicButton.tsx
|
|
76
|
+
import {
|
|
77
|
+
createSignal,
|
|
78
|
+
splitProps as splitProps2
|
|
79
|
+
} from "solid-js";
|
|
80
|
+
var PolymorphicButton = (props) => {
|
|
81
|
+
const [ref, setRef] = createSignal(null);
|
|
82
|
+
const [localProps, otherProps] = splitProps2(props, [
|
|
83
|
+
"ref",
|
|
84
|
+
"type"
|
|
85
|
+
]);
|
|
86
|
+
const isButton2 = createIsButton({
|
|
87
|
+
element: ref,
|
|
88
|
+
type: localProps.type
|
|
89
|
+
});
|
|
90
|
+
return <Polymorphic_default
|
|
91
|
+
as="button"
|
|
92
|
+
ref={mergeRefs(setRef, localProps.ref)}
|
|
93
|
+
type={isButton2() ? "button" : void 0}
|
|
94
|
+
role={!isButton2() ? "button" : void 0}
|
|
95
|
+
{...otherProps}
|
|
96
|
+
/>;
|
|
97
|
+
};
|
|
98
|
+
var PolymorphicButton_default = PolymorphicButton;
|
|
99
|
+
|
|
100
|
+
export {
|
|
101
|
+
Polymorphic_default,
|
|
102
|
+
PolymorphicButton_default
|
|
103
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cva
|
|
3
|
+
} from "./P7WPLZNA.jsx";
|
|
4
|
+
|
|
5
|
+
// src/components/input/Input.tsx
|
|
6
|
+
import {
|
|
7
|
+
createMemo,
|
|
8
|
+
createSignal,
|
|
9
|
+
mergeProps,
|
|
10
|
+
Show,
|
|
11
|
+
splitProps
|
|
12
|
+
} from "solid-js";
|
|
13
|
+
|
|
14
|
+
// src/components/input/Input.styles.ts
|
|
15
|
+
var inputVariants = cva(
|
|
16
|
+
[
|
|
17
|
+
"block w-full appearance-none outline-none bg-transparent",
|
|
18
|
+
"border transition-colors duration-200",
|
|
19
|
+
"disabled:opacity-50 disabled:cursor-not-allowed"
|
|
20
|
+
],
|
|
21
|
+
{
|
|
22
|
+
variants: {
|
|
23
|
+
color: {
|
|
24
|
+
danger: "border-red-500 text-red-600",
|
|
25
|
+
success: "border-green-500 text-green-600",
|
|
26
|
+
warning: "border-orange-500 text-orange-600"
|
|
27
|
+
},
|
|
28
|
+
rounded: {
|
|
29
|
+
true: "rounded-full",
|
|
30
|
+
false: "rounded-md"
|
|
31
|
+
},
|
|
32
|
+
expanded: {
|
|
33
|
+
true: "w-full",
|
|
34
|
+
false: "w-fit"
|
|
35
|
+
},
|
|
36
|
+
loading: {
|
|
37
|
+
true: "opacity-50",
|
|
38
|
+
false: ""
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
defaultVariants: {
|
|
42
|
+
color: void 0,
|
|
43
|
+
rounded: false,
|
|
44
|
+
expanded: true,
|
|
45
|
+
loading: false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// src/components/input/Input.tsx
|
|
51
|
+
var Input = (props) => {
|
|
52
|
+
const defaultedProps = mergeProps({ type: "text" }, props);
|
|
53
|
+
const [localProps, variantProps, otherProps] = splitProps(
|
|
54
|
+
defaultedProps,
|
|
55
|
+
["type", "passwordReveal", "leftIcon", "rightIcon"],
|
|
56
|
+
["class", ...inputVariants.variantKeys]
|
|
57
|
+
);
|
|
58
|
+
const [showPassword, setShowPassword] = createSignal(false);
|
|
59
|
+
const computedType = createMemo(
|
|
60
|
+
() => localProps.passwordReveal && showPassword() ? "text" : defaultedProps.type
|
|
61
|
+
);
|
|
62
|
+
return <div class="relative flex items-center">
|
|
63
|
+
<Show when={localProps.leftIcon}>
|
|
64
|
+
<span class="absolute left-3 top-1/2 -translate-y-1/2">
|
|
65
|
+
{localProps.leftIcon}
|
|
66
|
+
</span>
|
|
67
|
+
</Show>
|
|
68
|
+
|
|
69
|
+
<input
|
|
70
|
+
class={inputVariants(variantProps)}
|
|
71
|
+
type={computedType()}
|
|
72
|
+
aria-invalid={variantProps.color === "danger" ? "true" : void 0}
|
|
73
|
+
{...otherProps}
|
|
74
|
+
/>
|
|
75
|
+
|
|
76
|
+
<Show when={localProps.passwordReveal && localProps.rightIcon}>
|
|
77
|
+
<button
|
|
78
|
+
type="button"
|
|
79
|
+
onClick={() => setShowPassword((prev) => !prev)}
|
|
80
|
+
class="absolute right-3 top-1/2 -translate-y-1/2 outline-none"
|
|
81
|
+
>
|
|
82
|
+
{localProps.rightIcon}
|
|
83
|
+
</button>
|
|
84
|
+
</Show>
|
|
85
|
+
</div>;
|
|
86
|
+
};
|
|
87
|
+
var Input_default = Input;
|
|
88
|
+
|
|
89
|
+
// src/components/input/index.ts
|
|
90
|
+
var input_default = Input_default;
|
|
91
|
+
|
|
92
|
+
export {
|
|
93
|
+
input_default
|
|
94
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// src/lib/style/classes.ts
|
|
2
|
+
function classes(...args) {
|
|
3
|
+
return args.flat().filter(Boolean).join(" ");
|
|
4
|
+
}
|
|
5
|
+
function falsyToString(value) {
|
|
6
|
+
return typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
7
|
+
}
|
|
8
|
+
function cva(base, config) {
|
|
9
|
+
const fn = (props) => {
|
|
10
|
+
if (config?.variants == null) return classes(base, props?.class);
|
|
11
|
+
const { variants, defaultVariants } = config;
|
|
12
|
+
const getVariantClassNames = Object.keys(variants).map((variant) => {
|
|
13
|
+
const variantProp = props?.[variant];
|
|
14
|
+
const defaultVariantProp = defaultVariants?.[variant];
|
|
15
|
+
if (variantProp === null) return null;
|
|
16
|
+
const variantKey = falsyToString(variantProp) || falsyToString(
|
|
17
|
+
defaultVariantProp
|
|
18
|
+
);
|
|
19
|
+
return variants[variant]?.[variantKey];
|
|
20
|
+
});
|
|
21
|
+
const propsWithoutUndefined = Object.entries(props || {}).reduce(
|
|
22
|
+
(acc, [key, value]) => {
|
|
23
|
+
if (value !== void 0) {
|
|
24
|
+
acc[key] = value;
|
|
25
|
+
}
|
|
26
|
+
return acc;
|
|
27
|
+
},
|
|
28
|
+
{}
|
|
29
|
+
);
|
|
30
|
+
const getCompoundVariantClassNames = config?.compoundVariants?.reduce(
|
|
31
|
+
(acc, { class: cvClass, ...compoundVariantOptions }) => {
|
|
32
|
+
const isMatch = Object.entries(compoundVariantOptions).every(
|
|
33
|
+
([key, value]) => {
|
|
34
|
+
const currentValue = {
|
|
35
|
+
...defaultVariants,
|
|
36
|
+
...propsWithoutUndefined
|
|
37
|
+
}[key];
|
|
38
|
+
return Array.isArray(value) ? value.includes(currentValue) : currentValue === value;
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
return isMatch ? [...acc, cvClass] : acc;
|
|
42
|
+
},
|
|
43
|
+
[]
|
|
44
|
+
);
|
|
45
|
+
return classes(
|
|
46
|
+
base,
|
|
47
|
+
getVariantClassNames,
|
|
48
|
+
getCompoundVariantClassNames,
|
|
49
|
+
props?.class
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
fn.variantKeys = config?.variants ? Object.keys(config.variants) : [];
|
|
53
|
+
return fn;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
classes,
|
|
58
|
+
cva
|
|
59
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { cva } from './HKS7ET6T.js';
|
|
2
|
+
import { delegateEvents, template, insert, createComponent, spread, mergeProps as mergeProps$1 } from 'solid-js/web';
|
|
3
|
+
import { mergeProps, splitProps, createSignal, createMemo, Show } from 'solid-js';
|
|
4
|
+
|
|
5
|
+
// src/components/input/Input.styles.ts
|
|
6
|
+
var inputVariants = cva(
|
|
7
|
+
[
|
|
8
|
+
"block w-full appearance-none outline-none bg-transparent",
|
|
9
|
+
"border transition-colors duration-200",
|
|
10
|
+
"disabled:opacity-50 disabled:cursor-not-allowed"
|
|
11
|
+
],
|
|
12
|
+
{
|
|
13
|
+
variants: {
|
|
14
|
+
color: {
|
|
15
|
+
danger: "border-red-500 text-red-600",
|
|
16
|
+
success: "border-green-500 text-green-600",
|
|
17
|
+
warning: "border-orange-500 text-orange-600"
|
|
18
|
+
},
|
|
19
|
+
rounded: {
|
|
20
|
+
true: "rounded-full",
|
|
21
|
+
false: "rounded-md"
|
|
22
|
+
},
|
|
23
|
+
expanded: {
|
|
24
|
+
true: "w-full",
|
|
25
|
+
false: "w-fit"
|
|
26
|
+
},
|
|
27
|
+
loading: {
|
|
28
|
+
true: "opacity-50",
|
|
29
|
+
false: ""
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
color: void 0,
|
|
34
|
+
rounded: false,
|
|
35
|
+
expanded: true,
|
|
36
|
+
loading: false
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// src/components/input/Input.tsx
|
|
42
|
+
var _tmpl$ = /* @__PURE__ */ template(`<span class="absolute left-3 top-1/2 -translate-y-1/2">`);
|
|
43
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<button type=button class="absolute right-3 top-1/2 -translate-y-1/2 outline-none">`);
|
|
44
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<div class="relative flex items-center"><input>`);
|
|
45
|
+
var Input = (props) => {
|
|
46
|
+
const defaultedProps = mergeProps({
|
|
47
|
+
type: "text"
|
|
48
|
+
}, props);
|
|
49
|
+
const [localProps, variantProps, otherProps] = splitProps(defaultedProps, ["type", "passwordReveal", "leftIcon", "rightIcon"], ["class", ...inputVariants.variantKeys]);
|
|
50
|
+
const [showPassword, setShowPassword] = createSignal(false);
|
|
51
|
+
const computedType = createMemo(() => localProps.passwordReveal && showPassword() ? "text" : defaultedProps.type);
|
|
52
|
+
return (() => {
|
|
53
|
+
var _el$ = _tmpl$3(), _el$3 = _el$.firstChild;
|
|
54
|
+
insert(_el$, createComponent(Show, {
|
|
55
|
+
get when() {
|
|
56
|
+
return localProps.leftIcon;
|
|
57
|
+
},
|
|
58
|
+
get children() {
|
|
59
|
+
var _el$2 = _tmpl$();
|
|
60
|
+
insert(_el$2, () => localProps.leftIcon);
|
|
61
|
+
return _el$2;
|
|
62
|
+
}
|
|
63
|
+
}), _el$3);
|
|
64
|
+
spread(_el$3, mergeProps$1({
|
|
65
|
+
get ["class"]() {
|
|
66
|
+
return inputVariants(variantProps);
|
|
67
|
+
},
|
|
68
|
+
get type() {
|
|
69
|
+
return computedType();
|
|
70
|
+
},
|
|
71
|
+
get ["aria-invalid"]() {
|
|
72
|
+
return variantProps.color === "danger" ? "true" : void 0;
|
|
73
|
+
}
|
|
74
|
+
}, otherProps), false, false);
|
|
75
|
+
insert(_el$, createComponent(Show, {
|
|
76
|
+
get when() {
|
|
77
|
+
return localProps.passwordReveal && localProps.rightIcon;
|
|
78
|
+
},
|
|
79
|
+
get children() {
|
|
80
|
+
var _el$4 = _tmpl$2();
|
|
81
|
+
_el$4.$$click = () => setShowPassword((prev) => !prev);
|
|
82
|
+
insert(_el$4, () => localProps.rightIcon);
|
|
83
|
+
return _el$4;
|
|
84
|
+
}
|
|
85
|
+
}), null);
|
|
86
|
+
return _el$;
|
|
87
|
+
})();
|
|
88
|
+
};
|
|
89
|
+
var Input_default = Input;
|
|
90
|
+
delegateEvents(["click"]);
|
|
91
|
+
|
|
92
|
+
// src/components/input/index.ts
|
|
93
|
+
var input_default = Input_default;
|
|
94
|
+
|
|
95
|
+
export { input_default };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { cva } from './HKS7ET6T.js';
|
|
2
|
+
import { template, insert, createComponent, spread, mergeProps as mergeProps$1, effect, className } from 'solid-js/web';
|
|
3
|
+
import { mergeProps, splitProps, createSignal, createEffect, createMemo, Show } from 'solid-js';
|
|
4
|
+
|
|
5
|
+
// src/components/Avatar/Avatar.styles.ts
|
|
6
|
+
var avatarVariants = cva(
|
|
7
|
+
[
|
|
8
|
+
"flex items-center justify-center mx-1",
|
|
9
|
+
"font-medium outline-none select-none transition active:transition-none",
|
|
10
|
+
"not-disabled:cursor-pointer",
|
|
11
|
+
"disabled:cursor-not-allowed disabled:opacity-25",
|
|
12
|
+
"aria-busy:cursor-wait"
|
|
13
|
+
],
|
|
14
|
+
{
|
|
15
|
+
variants: {
|
|
16
|
+
size: {
|
|
17
|
+
sm: "size-8 text-sm",
|
|
18
|
+
md: "size-16 text-base",
|
|
19
|
+
lg: "size-24 text-lg"
|
|
20
|
+
},
|
|
21
|
+
shape: {
|
|
22
|
+
circle: "rounded-full overflow-hidden",
|
|
23
|
+
rounded: "rounded-lg overflow-hidden"
|
|
24
|
+
},
|
|
25
|
+
variant: {
|
|
26
|
+
filled: "bg-gray-200 text-gray-800",
|
|
27
|
+
outlined: "border-2 border-gray-300 text-gray-800",
|
|
28
|
+
ghost: "text-gray-800"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
size: "md",
|
|
33
|
+
shape: "circle",
|
|
34
|
+
variant: "filled"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// src/components/Avatar/utils.ts
|
|
40
|
+
function parseCaption(alt) {
|
|
41
|
+
if (!alt) return "";
|
|
42
|
+
const parts = alt.split(" ");
|
|
43
|
+
if (parts.length >= 2 && parts[0] && parts[1]) {
|
|
44
|
+
return `${parts[0][0] ?? ""}${parts[1][0] ?? ""}`;
|
|
45
|
+
}
|
|
46
|
+
return "";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// src/components/Avatar/Avatar.tsx
|
|
50
|
+
var _tmpl$ = /* @__PURE__ */ template(`<img class="size-full object-cover">`);
|
|
51
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<figure>`);
|
|
52
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<figcaption class=text-lg>`);
|
|
53
|
+
var Avatar = (rawProps) => {
|
|
54
|
+
const props = mergeProps({
|
|
55
|
+
alt: "User Avatar"
|
|
56
|
+
}, rawProps);
|
|
57
|
+
const [variantProps, otherProps] = splitProps(props, ["class", ...avatarVariants.variantKeys]);
|
|
58
|
+
const [source, setSource] = createSignal(props.src || props.dataSrc);
|
|
59
|
+
createEffect(() => {
|
|
60
|
+
if (import.meta.env.PROD && props.dataSrc) {
|
|
61
|
+
setSource(props.dataSrc);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
createMemo(() => source() ? "" : props.class ?? "bg-blue-500");
|
|
65
|
+
createMemo(() => source() ? "" : props.text ?? "text-white");
|
|
66
|
+
const caption = createMemo(() => parseCaption(props.alt));
|
|
67
|
+
return (() => {
|
|
68
|
+
var _el$ = _tmpl$2();
|
|
69
|
+
insert(_el$, createComponent(Show, {
|
|
70
|
+
get when() {
|
|
71
|
+
return source();
|
|
72
|
+
},
|
|
73
|
+
get fallback() {
|
|
74
|
+
return (() => {
|
|
75
|
+
var _el$3 = _tmpl$3();
|
|
76
|
+
insert(_el$3, caption);
|
|
77
|
+
return _el$3;
|
|
78
|
+
})();
|
|
79
|
+
},
|
|
80
|
+
get children() {
|
|
81
|
+
var _el$2 = _tmpl$();
|
|
82
|
+
spread(_el$2, mergeProps$1({
|
|
83
|
+
get src() {
|
|
84
|
+
return source();
|
|
85
|
+
},
|
|
86
|
+
get ["data-src"]() {
|
|
87
|
+
return props.dataSrc;
|
|
88
|
+
}
|
|
89
|
+
}, otherProps), false, false);
|
|
90
|
+
return _el$2;
|
|
91
|
+
}
|
|
92
|
+
}));
|
|
93
|
+
effect(() => className(_el$, avatarVariants(variantProps)));
|
|
94
|
+
return _el$;
|
|
95
|
+
})();
|
|
96
|
+
};
|
|
97
|
+
var Avatar_default = Avatar;
|
|
98
|
+
|
|
99
|
+
// src/components/Avatar/index.ts
|
|
100
|
+
var Avatar_default2 = Avatar_default;
|
|
101
|
+
|
|
102
|
+
export { Avatar_default2 as Avatar_default };
|