Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/application/charts/charts-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const selectEvenlySpacedItems = <T extends readonly unknown[]>(dataArray:
* @returns The legend content.
*/
export const ChartLegendContent = ({ reversed, payload, align, layout, className }: LegendContentProps & { reversed?: boolean; className?: string }) => {
payload = reversed ? payload?.toReversed() : payload;
payload = reversed && payload ? [...payload].reverse() : payload;

return (
<ul
Expand Down
4 changes: 3 additions & 1 deletion components/application/empty-state/empty-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ const AvatarRadius = ({ avatars = [], ...props }: AvatarRadiusProps) => {

{avatars.slice(0, avatarSlots.length).map((avatar, i) => {
const slot = avatarSlots[i];
if (!slot) return null;

const rad = (slot.angle * Math.PI) / 180;
const x = Math.sin(rad) * slot.ring;
const y = -Math.cos(rad) * slot.ring;
Expand Down Expand Up @@ -205,7 +207,7 @@ const AvatarRow = ({ avatars = [], children, ...props }: AvatarRowProps) => {
const leftAvatars = avatars.slice(0, count);
const rightAvatars = avatars.slice(count, count * 2);

const renderAvatar = (avatar: { src: string; alt?: string }, sizeClass: string, key: number) => (
const renderAvatar = (avatar: { src: string; alt?: string }, sizeClass: string | undefined, key: number) => (
<div
key={key}
className={cx(
Expand Down
8 changes: 4 additions & 4 deletions components/application/table/table.demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,8 @@ export const Table04DividerLine = () => {
<Table.Row id={item.name}>
<Table.Cell>
<div className="flex items-center gap-3">
<FileIcon type={item.name.split(".")[1]} theme="light" className="size-10 dark:hidden" />
<FileIcon type={item.name.split(".")[1]} theme="dark" className="size-10 not-dark:hidden" />
<FileIcon type={item.name.split(".")[1] ?? ""} theme="light" className="size-10 dark:hidden" />
<FileIcon type={item.name.split(".")[1] ?? ""} theme="dark" className="size-10 not-dark:hidden" />

<div className="whitespace-nowrap">
<p className="text-sm font-medium text-primary">{item.name}</p>
Expand Down Expand Up @@ -866,8 +866,8 @@ export const Table04AlternatingFills = () => {
<Table.Row id={item.name} className="odd:bg-secondary">
<Table.Cell>
<div className="flex items-center gap-3">
<FileIcon type={item.name.split(".")[1]} theme="light" className="size-10 dark:hidden" />
<FileIcon type={item.name.split(".")[1]} theme="dark" className="size-10 not-dark:hidden" />
<FileIcon type={item.name.split(".")[1] ?? ""} theme="light" className="size-10 dark:hidden" />
<FileIcon type={item.name.split(".")[1] ?? ""} theme="dark" className="size-10 not-dark:hidden" />

<div className="whitespace-nowrap">
<p className="text-sm font-medium text-primary">{item.name}</p>
Expand Down
2 changes: 1 addition & 1 deletion components/base/avatar/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
* it returns the first character of each word.
*/
export const getInitials = (name: string) => {
const [firstName, lastName] = name.split(" ");
const [firstName = "", lastName] = name.split(" ");
return firstName.charAt(0) + (lastName ? lastName.charAt(0) : "");
};
4 changes: 2 additions & 2 deletions components/base/dropdown/dropdown-button-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const permissions = [
];

export const DropdownButtonLink = () => {
const [selectedPermission, setSelectedPermission] = useState<string>(permissions[1].id);
const [selectedPermission, setSelectedPermission] = useState<string>("can-edit");

return (
<Dropdown.Root>
Expand All @@ -34,7 +34,7 @@ export const DropdownButtonLink = () => {
<Dropdown.Section
selectionMode="single"
selectedKeys={[selectedPermission]}
onSelectionChange={(keys) => setSelectedPermission(typeof keys === "string" ? keys : (keys.keys().toArray()[0] as string))}
onSelectionChange={(keys) => setSelectedPermission(typeof keys === "string" ? keys : (Array.from(keys)[0] as string))}
>
{permissions.map((permission) => (
<Dropdown.Item key={permission.id} id={permission.id}>
Expand Down
16 changes: 9 additions & 7 deletions components/base/input/input-payment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import { Label } from "@/components/base/input/label";
import { AmexIcon, DiscoverIcon, MastercardIcon, UnionPayIcon, VisaIcon } from "@/components/foundations/payment-icons";
import { cx } from "@/utils/cx";

const unknownCardType = {
name: "Unknown",
pattern: /.*/, // Fallback pattern for unknown cards
card: "unknown",
icon: MastercardIcon,
};

const cardTypes = [
{
name: "Visa",
Expand Down Expand Up @@ -39,12 +46,7 @@ const cardTypes = [
card: "unionpay",
icon: UnionPayIcon,
},
{
name: "Unknown",
pattern: /.*/, // Fallback pattern for unknown cards
card: "unknown",
icon: MastercardIcon,
},
unknownCardType,
];

/**
Expand All @@ -59,7 +61,7 @@ const detectCardType = (number: string) => {
// Find the matching card type
const card = cardTypes.find((cardType) => cardType.pattern.test(sanitizedNumber));

return card || cardTypes[cardTypes.length - 1];
return card || unknownCardType;
};

/**
Expand Down
4 changes: 2 additions & 2 deletions components/base/input/input-tags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const InputTags = ({
const focusLastTag = useCallback(() => {
const tagEls = tagGroupRef.current?.querySelectorAll<HTMLElement>('[role="row"]');
if (tagEls && tagEls.length > 0) {
tagEls[tagEls.length - 1].focus();
tagEls[tagEls.length - 1]?.focus();
}
}, []);

Expand Down Expand Up @@ -182,7 +182,7 @@ export const InputTags = ({
const tagEls = tagGroupRef.current?.querySelectorAll<HTMLElement>('[role="row"]');
if (tagEls && tagEls.length > 0) {
const lastTag = tagEls[tagEls.length - 1];
if (document.activeElement === lastTag || lastTag.contains(document.activeElement)) {
if (lastTag && (document.activeElement === lastTag || lastTag.contains(document.activeElement))) {
inputRef.current?.focus();
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/shared-assets/illustrations/box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { HTMLAttributes } from "react";
import { UploadCloud02 } from "@untitledui/icons";
import { cx } from "@/utils/cx";

interface IllustrationProps extends HTMLAttributes<HTMLDivElement> {
export interface IllustrationProps extends HTMLAttributes<HTMLDivElement> {
size?: "sm" | "md" | "lg";
svgClassName?: string;
childrenClassName?: string;
Expand Down
2 changes: 1 addition & 1 deletion components/shared-assets/illustrations/cloud.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { HTMLAttributes } from "react";
import { SearchLg } from "@untitledui/icons";
import { cx } from "@/utils/cx";

interface IllustrationProps extends HTMLAttributes<HTMLDivElement> {
export interface IllustrationProps extends HTMLAttributes<HTMLDivElement> {
size?: "sm" | "md" | "lg";
svgClassName?: string;
childrenClassName?: string;
Expand Down
2 changes: 1 addition & 1 deletion components/shared-assets/illustrations/credit-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { HTMLAttributes } from "react";
import { AlertCircle } from "@untitledui/icons";
import { cx } from "@/utils/cx";

interface IllustrationProps extends HTMLAttributes<HTMLDivElement> {
export interface IllustrationProps extends HTMLAttributes<HTMLDivElement> {
size?: "sm" | "md" | "lg";
svgClassName?: string;
childrenClassName?: string;
Expand Down
2 changes: 1 addition & 1 deletion components/shared-assets/illustrations/documents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { HTMLAttributes } from "react";
import { UploadCloud02 } from "@untitledui/icons";
import { cx } from "@/utils/cx";

interface IllustrationProps extends HTMLAttributes<HTMLDivElement> {
export interface IllustrationProps extends HTMLAttributes<HTMLDivElement> {
size?: "sm" | "md" | "lg";
svgClassName?: string;
childrenClassName?: string;
Expand Down
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"lib": ["dom", "dom.iterable", "es2022"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noUncheckedIndexedAccess": true,
"verbatimModuleSyntax": true,
"erasableSyntaxOnly": true,
"declaration": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
Expand Down
Loading