@schandlergarcia/sf-web-components 1.3.1 → 1.4.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/.a4drules/features/command-center-dashboard-rule.md +1 -1
- package/.a4drules/skills/command-center-project/SKILL.md +4 -4
- package/.a4drules/skills/component-library/SKILL.md +4 -1
- package/dist/components/library/ui/Avatar.d.ts +22 -10
- package/dist/components/library/ui/Avatar.js +40 -17
- package/dist/components/library/ui/Avatar.js.map +1 -1
- package/dist/components/library/ui/Card.d.ts +23 -37
- package/dist/components/library/ui/EmptyState.d.ts +34 -7
- package/dist/components/library/ui/EmptyState.js +5 -6
- package/dist/components/library/ui/EmptyState.js.map +1 -1
- package/dist/components/library/ui/Spinner.d.ts +21 -5
- package/dist/components/library/ui/UIInput.d.ts +4 -5
- package/dist/components/library/ui/UIInput.js +5 -6
- package/dist/components/library/ui/UIInput.js.map +1 -1
- package/dist/components/library/ui/alert.d.ts +23 -21
- package/dist/components/library/ui/alert.js +13 -14
- package/dist/components/library/ui/alert.js.map +1 -1
- package/dist/components/library/ui/card.js +24 -26
- package/dist/components/library/ui/card.js.map +1 -1
- package/dist/components/library/ui/checkbox.d.ts +4 -4
- package/dist/components/library/ui/checkbox.js +4 -5
- package/dist/components/library/ui/checkbox.js.map +1 -1
- package/dist/components/library/ui/label.d.ts +5 -7
- package/dist/components/library/ui/label.js +9 -10
- package/dist/components/library/ui/label.js.map +1 -1
- package/dist/components/library/ui/spinner.js +16 -17
- package/dist/components/library/ui/spinner.js.map +1 -1
- package/package.json +1 -1
- package/scripts/convert-to-typescript.sh +52 -0
- package/src/components/library/ui/{Alert.jsx → Alert.tsx} +17 -7
- package/src/components/library/ui/Avatar.tsx +68 -0
- package/src/components/library/ui/{Card.jsx → Card.tsx} +24 -10
- package/src/components/library/ui/{Checkbox.jsx → Checkbox.tsx} +4 -2
- package/src/components/library/ui/{EmptyState.jsx → EmptyState.tsx} +13 -10
- package/src/components/library/ui/{Label.jsx → Label.tsx} +9 -8
- package/src/components/library/ui/{Spinner.jsx → Spinner.tsx} +12 -10
- package/src/components/library/ui/{UIInput.jsx → UIInput.tsx} +5 -5
- package/src/components/library/ui/Avatar.jsx +0 -44
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const props = htmlFor ? { htmlFor, ...rest } : rest;
|
|
3
|
+
export interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
4
|
+
required?: boolean;
|
|
5
|
+
}
|
|
7
6
|
|
|
7
|
+
export default function Label({ children, htmlFor, required, className = "", ...rest }: LabelProps) {
|
|
8
8
|
return (
|
|
9
|
-
<
|
|
10
|
-
{
|
|
9
|
+
<label
|
|
10
|
+
htmlFor={htmlFor}
|
|
11
11
|
className={[
|
|
12
12
|
"text-sm font-medium text-slate-700 dark:text-slate-200",
|
|
13
13
|
className
|
|
14
14
|
]
|
|
15
15
|
.filter(Boolean)
|
|
16
16
|
.join(" ")}
|
|
17
|
+
{...rest}
|
|
17
18
|
>
|
|
18
19
|
{children}
|
|
19
20
|
{required && <span className="ml-0.5 text-red-500">*</span>}
|
|
20
|
-
</
|
|
21
|
+
</label>
|
|
21
22
|
);
|
|
22
23
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
|
|
3
3
|
const SIZE_CLASSES = {
|
|
4
4
|
xs: "h-3 w-3",
|
|
@@ -6,21 +6,23 @@ const SIZE_CLASSES = {
|
|
|
6
6
|
md: "h-5 w-5",
|
|
7
7
|
lg: "h-6 w-6",
|
|
8
8
|
xl: "h-8 w-8",
|
|
9
|
-
};
|
|
9
|
+
} as const;
|
|
10
10
|
|
|
11
11
|
const TONE_CLASSES = {
|
|
12
12
|
brand: "text-brand-500",
|
|
13
13
|
white: "text-white",
|
|
14
14
|
muted: "text-slate-400 dark:text-slate-500",
|
|
15
15
|
current: "text-current",
|
|
16
|
-
};
|
|
16
|
+
} as const;
|
|
17
|
+
|
|
18
|
+
export interface SpinnerProps extends React.SVGAttributes<SVGSVGElement> {
|
|
19
|
+
size?: keyof typeof SIZE_CLASSES;
|
|
20
|
+
tone?: keyof typeof TONE_CLASSES;
|
|
21
|
+
label?: string;
|
|
22
|
+
}
|
|
17
23
|
|
|
18
24
|
/**
|
|
19
25
|
* Animated spinner.
|
|
20
|
-
*
|
|
21
|
-
* @param {"xs"|"sm"|"md"|"lg"|"xl"} size
|
|
22
|
-
* @param {"brand"|"white"|"muted"|"current"} tone
|
|
23
|
-
* @param {string} label — screen-reader label
|
|
24
26
|
*/
|
|
25
27
|
export default function Spinner({
|
|
26
28
|
size = "md",
|
|
@@ -28,14 +30,14 @@ export default function Spinner({
|
|
|
28
30
|
label = "Loading",
|
|
29
31
|
className = "",
|
|
30
32
|
...rest
|
|
31
|
-
}) {
|
|
33
|
+
}: SpinnerProps) {
|
|
32
34
|
return (
|
|
33
35
|
<svg
|
|
34
36
|
{...rest}
|
|
35
37
|
className={[
|
|
36
38
|
"animate-spin",
|
|
37
|
-
SIZE_CLASSES[size]
|
|
38
|
-
TONE_CLASSES[tone]
|
|
39
|
+
SIZE_CLASSES[size],
|
|
40
|
+
TONE_CLASSES[tone],
|
|
39
41
|
className,
|
|
40
42
|
]
|
|
41
43
|
.filter(Boolean)
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export interface UIInputProps extends React.InputHTMLAttributes<HTMLInputElement> {}
|
|
4
|
+
|
|
5
|
+
export default function UIInput({ className = "", ...rest }: UIInputProps) {
|
|
4
6
|
return (
|
|
5
7
|
<input
|
|
6
|
-
style={style}
|
|
7
8
|
className={[
|
|
8
9
|
"h-10 w-full rounded-lg border border-slate-200 bg-white px-3 text-sm text-slate-900 shadow-sm",
|
|
9
10
|
"placeholder:text-slate-400",
|
|
10
11
|
"focus:outline-none focus:ring-2 focus:ring-brand-500 focus:ring-offset-2 dark:focus:ring-offset-slate-950",
|
|
11
12
|
"dark:border-slate-800 dark:bg-slate-900 dark:text-slate-50 dark:placeholder:text-slate-500",
|
|
13
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
12
14
|
className
|
|
13
15
|
]
|
|
14
16
|
.filter(Boolean)
|
|
@@ -17,5 +19,3 @@ export default function UIInput({ style = undefined, className = "", ...rest })
|
|
|
17
19
|
/>
|
|
18
20
|
);
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
const SIZE_MAP = {
|
|
4
|
-
xs: "h-6 w-6 text-[9px]",
|
|
5
|
-
sm: "h-8 w-8 text-[10px]",
|
|
6
|
-
md: "h-9 w-9 text-xs",
|
|
7
|
-
lg: "h-11 w-11 text-sm",
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const TONE_MAP = {
|
|
11
|
-
slate: "bg-slate-800 text-white",
|
|
12
|
-
brand: "bg-brand-500 text-white",
|
|
13
|
-
neutral: "bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-200",
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default function Avatar({ src, name, initials, icon, size = "sm", tone = "slate", className = "", ...rest }) {
|
|
17
|
-
const sizeClass = SIZE_MAP[size] ?? SIZE_MAP.sm;
|
|
18
|
-
|
|
19
|
-
if (src) {
|
|
20
|
-
return (
|
|
21
|
-
<img
|
|
22
|
-
src={src}
|
|
23
|
-
alt={name ?? ""}
|
|
24
|
-
className={`${sizeClass} shrink-0 rounded-full border border-slate-200 object-cover dark:border-slate-800 ${className}`}
|
|
25
|
-
{...rest}
|
|
26
|
-
/>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (React.isValidElement(icon)) {
|
|
31
|
-
return (
|
|
32
|
-
<div className={`${sizeClass} ${TONE_MAP[tone] ?? TONE_MAP.slate} flex shrink-0 items-center justify-center rounded-full ${className}`} {...rest}>
|
|
33
|
-
{icon}
|
|
34
|
-
</div>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const label = initials ?? (name ? name.split(" ").map(w => w[0]).join("").slice(0, 2).toUpperCase() : "?");
|
|
39
|
-
return (
|
|
40
|
-
<div className={`${sizeClass} ${TONE_MAP[tone] ?? TONE_MAP.slate} flex shrink-0 items-center justify-center rounded-full font-bold ${className}`} {...rest}>
|
|
41
|
-
{label}
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
}
|