Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
185 commits
Select commit Hold shift + click to select a range
8700d18
eslint - update .eslintrc to enforce no-unused-vars rule
kilias07 Oct 19, 2025
2147e7a
chore: update dependencies - install missing @types/lodash
kilias07 Oct 19, 2025
da85108
eslint/prettier - fix components/authentication/protected-route
kilias07 Oct 19, 2025
5b4d944
eslint/prettier - fix components/common/action-menu
kilias07 Oct 19, 2025
d913f68
eslint/prettier - fix components/common/badge-list-summary
kilias07 Oct 19, 2025
36e6cbc
eslint/prettier - fix components/common/conditional-tooltip
kilias07 Oct 19, 2025
7585c07
eslint/prettier - fix components/common/conditional-tooltip
kilias07 Oct 19, 2025
89777a4
eslint/prettier - fix components/common/data-range-display
kilias07 Oct 19, 2025
2951d5a
eslint/prettier - fix components/common/customer-info
kilias07 Oct 19, 2025
5c2d39f
eslint/prettier - fix components/common/chip-group
kilias07 Oct 19, 2025
e3df544
eslint/prettier - fix components/common/empty-table-content
kilias07 Oct 19, 2025
09d78fa
eslint/prettier - fix components/common/file-preview
kilias07 Oct 19, 2025
84a6bf9
eslint/prettier - fix components/common/file-upload
kilias07 Oct 19, 2025
4c92ff6
eslint/prettier - fix components/common/form
kilias07 Oct 19, 2025
9c5e9ac
eslint/prettier - fix components/common/icon-avatar
kilias07 Oct 19, 2025
7bd5a29
eslint/prettier - fix components/common/infinite-list
kilias07 Oct 19, 2025
06674dd
eslint/prettier - fix components/common/json-view-section
kilias07 Oct 19, 2025
9c77ac9
eslint/prettier - fix components/common/link-button
kilias07 Oct 19, 2025
dbf0615
eslint/prettier - fix components/common/listicle
kilias07 Oct 19, 2025
358c936
eslint/prettier - fix components/common/loading-spinner
kilias07 Oct 19, 2025
e97da8f
eslint/prettier - fix components/common/logo-box
kilias07 Oct 19, 2025
6663b18
eslint/prettier - fix components/common/metadata-editor
kilias07 Oct 19, 2025
c7424df
eslint/prettier - fix components/common/metadata-section
kilias07 Oct 19, 2025
4ddd63b
eslint/prettier - fix components/common/progress-bar
kilias07 Oct 19, 2025
57f4d4a
eslint/prettier - fix components/common/section
kilias07 Oct 19, 2025
783154a
eslint/prettier - fix components/common/sidebar-link
kilias07 Oct 19, 2025
dac3b82
eslint/prettier - fix components/common/skeleton
kilias07 Oct 19, 2025
448ad66
eslint/prettier - fix components/common/sortable-list
kilias07 Oct 19, 2025
9917f46
eslint/prettier - fix components/common/sortable-tree
kilias07 Oct 19, 2025
8a76ff4
eslint/prettier - fix components/common/switch-box
kilias07 Oct 19, 2025
fe7637a
eslint/prettier - fix components/common/tax-badge
kilias07 Oct 19, 2025
403861d
eslint/prettier - fix components/common/thumbnail
kilias07 Oct 19, 2025
52bbb05
eslint/prettier - fix components/common/user-link
kilias07 Oct 19, 2025
998a625
eslint/prettier - fix components/data-grid/components
kilias07 Oct 19, 2025
c1a97e1
eslint/prettier - fix components/data-grid/context
kilias07 Oct 19, 2025
4c709b0
eslint/prettier - fix components/data-grid/helpers
kilias07 Oct 19, 2025
ef4728b
eslint/prettier - fix components/data-grid/hooks
kilias07 Oct 19, 2025
76e08fc
eslint/prettier - fix components/data-grid/models
kilias07 Oct 19, 2025
775a1b8
eslint/prettier - fix components/data-grid
kilias07 Oct 19, 2025
43a0bdf
eslint/prettier - fix components/data-table/components/data-table/hel…
kilias07 Oct 19, 2025
2d09116
eslint/prettier - fix components/data-table/components/data-table/com…
kilias07 Oct 19, 2025
a423a80
eslint/prettier - fix components/data-table/components/data-table
kilias07 Oct 19, 2025
bf89a96
eslint/prettier - fix components/filtering/filter-group
kilias07 Oct 19, 2025
7a6ff25
eslint/prettier - fix components/filtering/order-by
kilias07 Oct 19, 2025
4f69208
eslint/prettier - fix components/filtering/query
kilias07 Oct 19, 2025
f7e773c
eslint/prettier - fix components/form/address-form
kilias07 Oct 19, 2025
19fa906
eslint/prettier - fix components/form/email-form
kilias07 Oct 19, 2025
0483c54
eslint/prettier - fix components/form/metadata-form
kilias07 Oct 19, 2025
e3d942d
eslint/prettier - fix components/inputs/chip-input
kilias07 Oct 19, 2025
a192726
eslint/prettier - fix components/inputs/combobox
kilias07 Oct 19, 2025
3b24640
eslint/prettier - fix components/inputs/country-select
kilias07 Oct 19, 2025
0aa3d14
eslint/prettier - fix components/inputs/country/handle-input
kilias07 Oct 19, 2025
f38ad5a
eslint/prettier - fix components/inputs/country/percentage-input
kilias07 Oct 19, 2025
986470a
eslint/prettier - fix components/inputs/country/province-input
kilias07 Oct 19, 2025
dc7032f
eslint/prettier - fix components/layout/main-layout
kilias07 Oct 20, 2025
6f47b6c
eslint/prettier - fix components/layout/nav-item
kilias07 Oct 20, 2025
9da0162
eslint/prettier - fix components/layout/notifications
kilias07 Oct 20, 2025
d446daf
eslint/prettier - fix components/layout/pages
kilias07 Oct 20, 2025
b399d23
eslint/prettier - fix components/layout/public-layout
kilias07 Oct 20, 2025
cf5055e
eslint/prettier - fix components/layout/settings-layout
kilias07 Oct 20, 2025
5d14f20
eslint/prettier - fix components/layout/shell
kilias07 Oct 20, 2025
b0c664d
eslint/prettier - fix components/layout/single-column
kilias07 Oct 20, 2025
04500d3
eslint/prettier - fix components/layout/two-column-layout
kilias07 Oct 20, 2025
ab79b78
eslint/prettier - fix components/layout/user-menu
kilias07 Oct 20, 2025
3bb9533
eslint/prettier - fix components/localization
kilias07 Oct 20, 2025
c292d66
eslint/prettier - fix components/modals/hooks
kilias07 Oct 20, 2025
85f2df5
eslint/prettier - fix components/modals/route-drawer
kilias07 Oct 20, 2025
180d1fa
eslint/prettier - fix components/modals/route-focus-modal
kilias07 Oct 20, 2025
13ddfa5
eslint/prettier - fix components/modals/route-modal-form
kilias07 Oct 20, 2025
3b36089
eslint/prettier - fix components/modals/route-modal-provider
kilias07 Oct 20, 2025
37a5176
eslint/prettier - fix components/modals/stacked-drawer
kilias07 Oct 20, 2025
6432e7a
eslint/prettier - fix components/modals/stacked-modal
kilias07 Oct 20, 2025
9815c34
eslint/prettier - fix components/modals/stacked-modal-provider
kilias07 Oct 20, 2025
75daa4a
eslint/prettier - fix components/modals
kilias07 Oct 20, 2025
0a23f7b
eslint/prettier - fix components/search
kilias07 Oct 20, 2025
f94f7c3
eslint/prettier - fix components/table/configurable-data-table
kilias07 Oct 20, 2025
10840ee
eslint/prettier - fix components/table/data-table-filter
kilias07 Oct 20, 2025
ce7689d
eslint/prettier - fix components/table/save-view-dialog
kilias07 Oct 21, 2025
f276d16
eslint/prettier - fix components/table/table-cells/common/date-cell
kilias07 Oct 21, 2025
44e1b00
eslint/prettier - fix components/table/table-cells/common/created-at-…
kilias07 Oct 21, 2025
77ab591
eslint/prettier - fix components/table/table-cells/common/code-cell
kilias07 Oct 21, 2025
368260b
eslint/prettier - fix components/table/table-cells/common/email-cell
kilias07 Oct 21, 2025
e29de14
eslint/prettier - fix components/table/table-cells/common/money-amoun…
kilias07 Oct 21, 2025
8522ae7
eslint/prettier - fix components/table/table-cells/common/name-cell
kilias07 Oct 21, 2025
aa996bc
eslint/prettier - fix components/table/table-cells/common/placeholder…
kilias07 Oct 21, 2025
c79d245
eslint/prettier - fix components/table/table-cells/common/status-cell
kilias07 Oct 21, 2025
18c38d2
eslint/prettier - fix components/table/table-cells/common/text-cell
kilias07 Oct 21, 2025
9d80402
eslint/prettier - fix components/table/table-cells/customer/first-see…
kilias07 Oct 21, 2025
7de2a46
eslint/prettier - fix components/table/table-cells/customer/account-cell
kilias07 Oct 21, 2025
6b75515
eslint/prettier - fix components/table/table-cells/order/country-cell
kilias07 Oct 21, 2025
2102c51
eslint/prettier - fix components/table/table-cells/order/customer-cell
kilias07 Oct 21, 2025
3b8c30a
eslint/prettier - fix components/table/table-cells/order/display-id-cell
kilias07 Oct 21, 2025
8d1cf92
eslint/prettier - fix components/table/table-cells/order/fulfillment-…
kilias07 Oct 21, 2025
4798cf9
eslint/prettier - fix components/table/table-cells/order/payment-stat…
kilias07 Oct 21, 2025
1dac650
eslint/prettier - fix components/table/table-cells/order/sales-channe…
kilias07 Oct 21, 2025
ae91a53
eslint/prettier - fix components/table/table-cells/order/total-cell
kilias07 Oct 21, 2025
c8b3680
eslint/prettier - fix components/table/table-cells/product/collection…
kilias07 Oct 21, 2025
d2f6bb6
eslint/prettier - fix components/table/table-cells/product/product-cell
kilias07 Oct 21, 2025
ace998e
eslint/prettier - fix components/table/table-cells/product/product-st…
kilias07 Oct 21, 2025
935eca5
eslint/prettier - fix components/table/table-cells/product/sales-chan…
kilias07 Oct 21, 2025
f3461bf
eslint/prettier - fix components/table/table-cells/product/variant-cell
kilias07 Oct 21, 2025
8148fa8
eslint/prettier - fix components/table/table-cells/promotion/status-cell
kilias07 Oct 21, 2025
ca34068
eslint/prettier - fix components/table/table-cells/promotion/region/c…
kilias07 Oct 21, 2025
55a41fb
eslint/prettier - fix components/table/table-cells/promotion/region/f…
kilias07 Oct 21, 2025
624b531
eslint/prettier - fix components/table/table-cells/promotion/region/p…
kilias07 Oct 21, 2025
069c031
eslint/prettier - fix components/table/table-cells/promotion/region/r…
kilias07 Oct 21, 2025
ef14f71
eslint/prettier - fix components/table/table-cells/sales-channel-name…
kilias07 Oct 21, 2025
dc1750b
eslint/prettier - fix components/table/table-cells/sales-channel/desc…
kilias07 Oct 21, 2025
d3a8b14
eslint/prettier - fix components/table/table-cells/shipping-option/ad…
kilias07 Oct 21, 2025
842a96b
eslint/prettier - fix components/table/table-cells/shipping-option/is…
kilias07 Oct 21, 2025
2265a0a
eslint/prettier - fix components/table/table-cells/shipping-option/pr…
kilias07 Oct 21, 2025
f284fd9
eslint/prettier - fix components/table/table-cells/shipping-option/sh…
kilias07 Oct 21, 2025
06ca662
eslint/prettier - fix components/table/table-cells/shipping-option/sh…
kilias07 Oct 21, 2025
dead6e7
eslint/prettier - fix components/table/table-cells/taxes/type-cell
kilias07 Oct 21, 2025
2d3c034
eslint/prettier - fix components/table/view-selector
kilias07 Oct 21, 2025
ce4a0dd
eslint/prettier - fix components/table/view-selector
kilias07 Oct 21, 2025
15c5d39
eslint/prettier - fix components/utilities/error-boundary
kilias07 Oct 21, 2025
8e4d560
eslint/prettier - fix components/utilities/generic-forward-ref
kilias07 Oct 21, 2025
10acbfe
eslint/prettier - fix components/utilities/i18n
kilias07 Oct 21, 2025
89240b9
eslint/prettier - fix components/utilities/keybound-form
kilias07 Oct 21, 2025
d8e5352
eslint/prettier - fix components/utilities/visually-hidden
kilias07 Oct 21, 2025
428d563
eslint/prettier - fix dashboard/forms
kilias07 Oct 21, 2025
e0d65c1
eslint/prettier - fix dashboard/links
kilias07 Oct 21, 2025
5d757df
eslint/prettier - fix dashboard/routes
kilias07 Oct 21, 2025
97db60a
eslint/prettier - fix dashboard
kilias07 Oct 21, 2025
7ae1bb8
eslint/prettier - fix hooks/api
kilias07 Oct 22, 2025
1a3a6d5
eslint/prettier - fix hooks/table/columns
kilias07 Oct 22, 2025
ea35143
eslint/prettier - fix hooks/table/filters
kilias07 Oct 22, 2025
bc679f1
eslint/prettier - fix hooks/table/query
kilias07 Oct 22, 2025
7a568cb
eslint/prettier - fix hooks/table
kilias07 Oct 22, 2025
d5aa559
eslint/prettier - fix hooks
kilias07 Oct 22, 2025
09f576f
eslint/prettier - fix i18n
kilias07 Oct 22, 2025
83d94f4
eslint/prettier - fix lib/clinet
kilias07 Oct 22, 2025
d323f43
eslint/prettier - fix lib/data
kilias07 Oct 22, 2025
52d0bc2
eslint/prettier - fix lib/table
kilias07 Oct 22, 2025
8eb8c61
eslint/prettier - fix lib
kilias07 Oct 22, 2025
3cdfc4a
eslint/prettier - fix providers/extension-provider
kilias07 Oct 22, 2025
3ca4c3e
eslint/prettier - fix providers/feature-fla-provider
kilias07 Oct 22, 2025
71df626
eslint/prettier - fix providers/i18n-provider
kilias07 Oct 22, 2025
2a0baa2
eslint/prettier - fix providers/search-provider
kilias07 Oct 22, 2025
376c31e
eslint/prettier - fix providers/sidebar-provider
kilias07 Oct 22, 2025
06462a4
eslint/prettier - fix providers/theme-provider
kilias07 Oct 22, 2025
2641f97
eslint/prettier - fix providers
kilias07 Oct 22, 2025
e044b79
eslint/prettier - fix routes/api-key-management
kilias07 Oct 22, 2025
86a9d71
eslint/prettier - fix routes/attributes/attributes-create
kilias07 Oct 22, 2025
091c898
eslint/prettier - fix routes/attributes/attributes-detail
kilias07 Oct 22, 2025
9624518
eslint/prettier - fix routes/attributes/attributes-edit
kilias07 Oct 22, 2025
324cfb1
eslint/prettier - fix routes/attributes/attributes-edit-possible-values
kilias07 Oct 22, 2025
9d0d1c0
eslint/prettier - fix routes/attributes/attribute-list
kilias07 Oct 22, 2025
4fd7905
eslint/prettier - fix routes/campaigns
kilias07 Oct 22, 2025
325788a
eslint/prettier - fix routes/campaigns
kilias07 Oct 22, 2025
3ccfa81
eslint/prettier - fix routes/categories
kilias07 Oct 22, 2025
1ebc427
eslint/prettier - fix routes/collections
kilias07 Oct 22, 2025
1b9c612
eslint/prettier - fix routes/customer-groups
kilias07 Oct 22, 2025
edf1814
eslint/prettier - fix routes/customer-groups
kilias07 Oct 22, 2025
bf6a01a
eslint/prettier - fix routes/customers
kilias07 Oct 22, 2025
e977072
eslint/prettier - fix routes/inventory
kilias07 Oct 22, 2025
8fdcf76
eslint/prettier - fix routes/invite
kilias07 Oct 22, 2025
2f6a2dd
eslint/prettier - fix routes/location
kilias07 Oct 22, 2025
bb9df4c
eslint/prettier - fix routes/login
kilias07 Oct 22, 2025
8321d9b
eslint/prettier - fix routes/no-match
kilias07 Oct 22, 2025
807e7d9
eslint/prettier - fix routes/orders
kilias07 Oct 23, 2025
9798951
eslint/prettier - fix hooks/api/exchanges
kilias07 Oct 23, 2025
5290493
eslint/prettier - fix routes/orders
kilias07 Oct 26, 2025
7d3ca8e
eslint/prettier - fix routes/price-lists
kilias07 Oct 26, 2025
fcae1af
eslint/prettier - fix routes/product-tags
kilias07 Oct 26, 2025
2edc343
eslint/prettier - fix routes/product-types
kilias07 Oct 26, 2025
18d682f
eslint/prettier - fix routes/product-variants
kilias07 Oct 26, 2025
fec788b
eslint/prettier - fix routes/products
kilias07 Oct 27, 2025
025e8dc
eslint/prettier - fix routes/profile
kilias07 Oct 27, 2025
3faff5f
eslint/prettier - fix routes/promotions
kilias07 Oct 27, 2025
e5133a8
eslint/prettier - fix routes/refund-reasons
kilias07 Oct 27, 2025
936948c
eslint/prettier - fix routes/regions
kilias07 Oct 27, 2025
33c9322
eslint/prettier - fix routes/requests
kilias07 Oct 27, 2025
48b08ff
eslint/prettier - fix routes/reservations
kilias07 Oct 27, 2025
da34f39
eslint/prettier - fix routes/reset-password
kilias07 Oct 27, 2025
1afa97f
eslint/prettier - fix types
kilias07 Oct 27, 2025
f5b0c91
eslint/prettier - common files
kilias07 Oct 27, 2025
5d4b89f
eslint/prettier - fix routes/return-reasons
kilias07 Oct 30, 2025
0d569e0
eslint/prettier - fix routes/sales-channels
kilias07 Oct 30, 2025
e260f50
eslint/prettier - fix routes/sellers
kilias07 Oct 30, 2025
7b7d282
eslint/prettier - fix routes/shipping-profiles
kilias07 Oct 30, 2025
df7f72b
eslint/prettier - fix routes/tax-regions
kilias07 Oct 30, 2025
4d49445
eslint/prettier - fix routes/users
kilias07 Oct 30, 2025
6868a4a
eslint/prettier - fix routes/workflow-executions
kilias07 Oct 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@
"import/namespace": 0,
"import/default": 0,
"import/export": 0,
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
],
"no-restricted-imports": [
"error",
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"@medusajs/types": "2.10.3",
"@medusajs/ui-preset": "2.10.3",
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
"@types/lodash": "^4.17.20",
"@types/node": "^20.11.15",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
Expand Down
27 changes: 13 additions & 14 deletions src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
import { DashboardApp } from "./dashboard-app"
import { DashboardPlugin } from "./dashboard-app/types"
import displayModule from "virtual:medusa/displays";
import formModule from "virtual:medusa/forms";
import menuItemModule from "virtual:medusa/menu-items";
import routeModule from "virtual:medusa/routes";
import widgetModule from "virtual:medusa/widgets";

import displayModule from "virtual:medusa/displays"
import formModule from "virtual:medusa/forms"
import menuItemModule from "virtual:medusa/menu-items"
import routeModule from "virtual:medusa/routes"
import widgetModule from "virtual:medusa/widgets"

import "./index.css"
import { DashboardApp } from "./dashboard-app";
import type { DashboardPlugin } from "./dashboard-app/types";
import "./index.css";

const localPlugin = {
widgetModule,
routeModule,
displayModule,
formModule,
menuItemModule,
}
};

interface AppProps {
plugins?: DashboardPlugin[]
plugins?: DashboardPlugin[];
}

function App({ plugins = [] }: AppProps) {
const app = new DashboardApp({
plugins: [localPlugin, ...plugins],
})
});

return <div>{app.render()}</div>
return <div>{app.render()}</div>;
}

export default App
export default App;
2 changes: 1 addition & 1 deletion src/components/authentication/protected-route/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./protected-route"
export * from "./protected-route";
27 changes: 15 additions & 12 deletions src/components/authentication/protected-route/protected-route.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import { Spinner } from "@medusajs/icons"
import { Navigate, Outlet, useLocation } from "react-router-dom"
import { useMe } from "../../../hooks/api/users"
import { SearchProvider } from "../../../providers/search-provider"
import { SidebarProvider } from "../../../providers/sidebar-provider"
import { Spinner } from "@medusajs/icons";

import { Navigate, Outlet, useLocation } from "react-router-dom";

import { useMe } from "@hooks/api";

import { SearchProvider } from "@providers/search-provider";
import { SidebarProvider } from "@providers/sidebar-provider";

export const ProtectedRoute = () => {
const { user, isLoading } = useMe()
const location = useLocation()
const { user, isLoading } = useMe();
const location = useLocation();

if (isLoading) {
return (
<div className="flex min-h-screen items-center justify-center">
<Spinner className="text-ui-fg-interactive animate-spin" />
<Spinner className="animate-spin text-ui-fg-interactive" />
</div>
)
);
}

if (!user) {
return <Navigate to="/login" state={{ from: location }} replace />
return <Navigate to="/login" state={{ from: location }} replace />;
}

return (
Expand All @@ -26,5 +29,5 @@ export const ProtectedRoute = () => {
<Outlet />
</SearchProvider>
</SidebarProvider>
)
}
);
};
2 changes: 1 addition & 1 deletion src/components/common/action-menu/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./action-menu"
export * from "./action-menu";
37 changes: 28 additions & 9 deletions src/components/common/actions-button/actions-button.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
import { Button, DropdownMenu } from "@medusajs/ui"
import { EllipsisHorizontal } from "@medusajs/icons"
import { useState } from "react";

export const ActionsButton = ({actions}: {actions: {label: string, onClick: () => void, icon?: JSX.Element}[]}) => {
import { EllipsisHorizontal } from "@medusajs/icons";
import { Button, DropdownMenu } from "@medusajs/ui";

export const ActionsButton = ({
actions,
}: {
actions: { label: string; onClick: () => void; icon?: JSX.Element }[];
}) => {
const [open, setOpen] = useState(false);

return (
<DropdownMenu open={open} onOpenChange={setOpen}>
<DropdownMenu.Trigger asChild><Button variant="transparent" className="h-8 w-12 p-0" onClick={() => setOpen(true)}><EllipsisHorizontal /></Button></DropdownMenu.Trigger>
<DropdownMenu.Trigger asChild>
<Button
variant="transparent"
className="h-8 w-12 p-0"
onClick={() => setOpen(true)}
>
<EllipsisHorizontal />
</Button>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
{actions.map(({ label, onClick, icon}) => (
<DropdownMenu.Item key={label} onClick={onClick} className="flex items-center gap-2">
{icon}{label}
{actions.map(({ label, onClick, icon }) => (
<DropdownMenu.Item
key={label}
onClick={onClick}
className="flex items-center gap-2"
>
{icon}
{label}
</DropdownMenu.Item>
))}
</DropdownMenu.Content>
</DropdownMenu>
)
}
);
};
31 changes: 16 additions & 15 deletions src/components/common/badge-list-summary/badge-list-summary.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import { Badge, Tooltip, clx } from "@medusajs/ui"
import { useTranslation } from "react-i18next"
import { Badge, Tooltip, clx } from "@medusajs/ui";

import { useTranslation } from "react-i18next";

type BadgeListSummaryProps = {
/**
* Number of initial items to display
* @default 2
*/
n?: number
n?: number;
/**
* List of strings to display as abbreviated list
*/
list: string[]
list: string[];
/**
* Is the summary displayed inline.
* Determines whether the center text is truncated if there is no space in the container
*/
inline?: boolean
inline?: boolean;
/**
* Whether the badges should be rounded
*/
rounded?: boolean
className?: string
}
rounded?: boolean;
className?: string;
};

export const BadgeListSummary = ({
list,
Expand All @@ -30,29 +31,29 @@ export const BadgeListSummary = ({
rounded = false,
n = 2,
}: BadgeListSummaryProps) => {
const { t } = useTranslation()
const { t } = useTranslation();

const title = t("general.plusCount", {
count: list.length - n,
})
});

return (
<div
className={clx(
"text-ui-fg-subtle txt-compact-small gap-x-2 overflow-hidden",
"txt-compact-small gap-x-2 overflow-hidden text-ui-fg-subtle",
{
"inline-flex": inline,
flex: !inline,
},
className
className,
)}
>
{list.slice(0, n).map((item) => {
return (
<Badge rounded={rounded ? "full" : "base"} key={item} size="2xsmall">
{item}
</Badge>
)
);
})}

{list.length > n && (
Expand All @@ -77,5 +78,5 @@ export const BadgeListSummary = ({
</div>
)}
</div>
)
}
);
};
2 changes: 1 addition & 1 deletion src/components/common/badge-list-summary/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./badge-list-summary"
export * from "./badge-list-summary";
73 changes: 39 additions & 34 deletions src/components/common/chip-group/chip-group.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
import { XMarkMini } from "@medusajs/icons"
import { Button, clx } from "@medusajs/ui"
import { Children, PropsWithChildren, createContext, useContext } from "react"
import { useTranslation } from "react-i18next"
import type { PropsWithChildren } from "react";
import { Children, createContext, useContext } from "react";

type ChipGroupVariant = "base" | "component"
import { XMarkMini } from "@medusajs/icons";
import { Button, clx } from "@medusajs/ui";

import { useTranslation } from "react-i18next";

type ChipGroupVariant = "base" | "component";

type ChipGroupProps = PropsWithChildren<{
onClearAll?: () => void
onRemove?: (index: number) => void
variant?: ChipGroupVariant
className?: string
}>
onClearAll?: () => void;
onRemove?: (index: number) => void;
variant?: ChipGroupVariant;
className?: string;
}>;

type GroupContextValue = {
onRemove?: (index: number) => void
variant: ChipGroupVariant
}
onRemove?: (index: number) => void;
variant: ChipGroupVariant;
};

const GroupContext = createContext<GroupContextValue | null>(null)
const GroupContext = createContext<GroupContextValue | null>(null);

const useGroupContext = () => {
const context = useContext(GroupContext)
const context = useContext(GroupContext);

if (!context) {
throw new Error("useGroupContext must be used within a ChipGroup component")
throw new Error(
"useGroupContext must be used within a ChipGroup component",
);
}

return context
}
return context;
};

const Group = ({
onClearAll,
Expand All @@ -36,9 +41,9 @@ const Group = ({
className,
children,
}: ChipGroupProps) => {
const { t } = useTranslation()
const { t } = useTranslation();

const showClearAll = !!onClearAll && Children.count(children) > 0
const showClearAll = !!onClearAll && Children.count(children) > 0;

return (
<GroupContext.Provider value={{ onRemove, variant }}>
Expand All @@ -62,50 +67,50 @@ const Group = ({
)}
</ul>
</GroupContext.Provider>
)
}
);
};

type ChipProps = PropsWithChildren<{
index: number
className?: string
}>
index: number;
className?: string;
}>;

const Chip = ({ index, className, children }: ChipProps) => {
const { onRemove, variant } = useGroupContext()
const { onRemove, variant } = useGroupContext();

return (
<li
className={clx(
"bg-ui-bg-component shadow-borders-base flex items-stretch divide-x overflow-hidden rounded-md",
"flex items-stretch divide-x overflow-hidden rounded-md bg-ui-bg-component shadow-borders-base",
{
"bg-ui-bg-component": variant === "component",
"bg-ui-bg-base-": variant === "base",
},
className
className,
)}
>
<span className="txt-compact-small-plus text-ui-fg-subtle flex items-center justify-center px-2 py-1">
<span className="txt-compact-small-plus flex items-center justify-center px-2 py-1 text-ui-fg-subtle">
{children}
</span>
{!!onRemove && (
<button
onClick={() => onRemove(index)}
type="button"
className={clx(
"text-ui-fg-muted active:text-ui-fg-subtle transition-fg flex items-center justify-center p-1",
"flex items-center justify-center p-1 text-ui-fg-muted transition-fg active:text-ui-fg-subtle",
{
"hover:bg-ui-bg-component-hover active:bg-ui-bg-component-pressed":
variant === "component",
"hover:bg-ui-bg-base-hover active:bg-ui-bg-base-pressed":
variant === "base",
}
},
)}
>
<XMarkMini />
</button>
)}
</li>
)
}
);
};

export const ChipGroup = Object.assign(Group, { Chip })
export const ChipGroup = Object.assign(Group, { Chip });
2 changes: 1 addition & 1 deletion src/components/common/chip-group/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./chip-group"
export * from "./chip-group";
Loading