@pelatform/starter.shared 0.2.10 → 0.2.12
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/dist/index.d.ts +10 -5
- package/dist/index.js +80 -30
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { NavItem, LanguageSwitcherProps } from 'pelatform-ui/components';
|
|
|
6
6
|
export { Logo as LogoDefault } from 'pelatform-ui/components';
|
|
7
7
|
import { Config } from '@pelatform/starter.config';
|
|
8
8
|
import { AuthQueryOptions } from '@pelatform/starter.hook';
|
|
9
|
-
import { AnyAuthClient, User, Workspace, ApiKey } from '@pelatform/starter.utils';
|
|
9
|
+
import { AnyAuthClient, ImageOptions, User, Workspace, ApiKey } from '@pelatform/starter.utils';
|
|
10
10
|
import { Toaster, Avatar, buttonVariants, Dialog, Card, Button, Input } from 'pelatform-ui/default';
|
|
11
11
|
import { LucideIcon } from 'lucide-react';
|
|
12
12
|
|
|
@@ -78,19 +78,24 @@ interface LayoutWrapperProps {
|
|
|
78
78
|
sidebarMenu: ReactNode;
|
|
79
79
|
logoHeader?: ReactNode;
|
|
80
80
|
homeUrl?: string;
|
|
81
|
+
studioUrl?: string;
|
|
81
82
|
}
|
|
82
|
-
declare function LayoutWrapper({ children, sidebarHeader, sidebarMenu, logoHeader, homeUrl, }: LayoutWrapperProps): react_jsx_runtime.JSX.Element;
|
|
83
|
+
declare function LayoutWrapper({ children, sidebarHeader, sidebarMenu, logoHeader, homeUrl, studioUrl, }: LayoutWrapperProps): react_jsx_runtime.JSX.Element;
|
|
83
84
|
|
|
84
85
|
/**
|
|
85
86
|
* Props for the ConfigProvider component
|
|
86
87
|
*/
|
|
87
88
|
type ConfigProviderProps = {
|
|
89
|
+
/** Child components that can access the configuration */
|
|
90
|
+
children: ReactNode;
|
|
88
91
|
/** The configuration object to provide to all child components (can be partial, can have extra properties) */
|
|
89
92
|
config: Partial<Config> | Record<string, any>;
|
|
90
93
|
/** AuthClient instance to provide to all child components */
|
|
91
94
|
authClient: AnyAuthClient;
|
|
92
|
-
/**
|
|
93
|
-
|
|
95
|
+
/** Image options for user avatar */
|
|
96
|
+
userAvatar?: Partial<ImageOptions>;
|
|
97
|
+
/** Image options for workspace logo */
|
|
98
|
+
workspaceLogo?: Partial<ImageOptions>;
|
|
94
99
|
} & Partial<AuthQueryOptions>;
|
|
95
100
|
/**
|
|
96
101
|
* Provider component that makes configuration available to all client components
|
|
@@ -121,7 +126,7 @@ type ConfigProviderProps = {
|
|
|
121
126
|
* }
|
|
122
127
|
* ```
|
|
123
128
|
*/
|
|
124
|
-
declare function ConfigProvider({ config, authClient,
|
|
129
|
+
declare function ConfigProvider({ children, config: configProp, authClient: authClientProp, userAvatar: userAvatarProp, workspaceLogo: workspaceLogoProp, ...props }: ConfigProviderProps): react_jsx_runtime.JSX.Element;
|
|
125
130
|
|
|
126
131
|
interface LayoutProviderProps {
|
|
127
132
|
children: ReactNode;
|
package/dist/index.js
CHANGED
|
@@ -215,14 +215,7 @@ import {
|
|
|
215
215
|
import { Fragment as Fragment2, useCallback, useEffect, useState } from "react";
|
|
216
216
|
import Link4 from "next/link";
|
|
217
217
|
import { useRouter as useRouter2 } from "next/navigation";
|
|
218
|
-
import {
|
|
219
|
-
HouseIcon,
|
|
220
|
-
LogOutIcon,
|
|
221
|
-
PlusCircleIcon,
|
|
222
|
-
SettingsIcon,
|
|
223
|
-
ShieldIcon,
|
|
224
|
-
UserStarIcon
|
|
225
|
-
} from "lucide-react";
|
|
218
|
+
import { HouseIcon, LogOutIcon, PlusCircleIcon, SettingsIcon, ShieldIcon } from "lucide-react";
|
|
226
219
|
import { useTranslations as useTranslations7 } from "next-intl";
|
|
227
220
|
import {
|
|
228
221
|
useConfig as useConfig4,
|
|
@@ -577,10 +570,6 @@ function UserMenu({
|
|
|
577
570
|
/* @__PURE__ */ jsx9(ShieldIcon, {}),
|
|
578
571
|
/* @__PURE__ */ jsx9("span", { children: t("ui.navigation.security") })
|
|
579
572
|
] }) }),
|
|
580
|
-
"admin" === userRole && /* @__PURE__ */ jsx9(DropdownMenuItem, { asChild: true, children: /* @__PURE__ */ jsxs7(Link4, { href: path.admin.OVERVIEW, children: [
|
|
581
|
-
/* @__PURE__ */ jsx9(UserStarIcon, {}),
|
|
582
|
-
/* @__PURE__ */ jsx9("span", { children: "Admin Dashboard" })
|
|
583
|
-
] }) }),
|
|
584
573
|
!hiddenSwitcher && /* @__PURE__ */ jsxs7(Fragment3, { children: [
|
|
585
574
|
/* @__PURE__ */ jsx9(DropdownMenuSeparator, {}),
|
|
586
575
|
/* @__PURE__ */ jsx9(
|
|
@@ -1007,6 +996,12 @@ function SiteHeaderSecondary({
|
|
|
1007
996
|
] });
|
|
1008
997
|
}
|
|
1009
998
|
|
|
999
|
+
// src/components/layouts/wrapper.tsx
|
|
1000
|
+
import Link8 from "next/link";
|
|
1001
|
+
import { RocketIcon } from "lucide-react";
|
|
1002
|
+
import { useSession as useSession5 } from "@pelatform/starter.hook";
|
|
1003
|
+
import { Button as Button5 } from "pelatform-ui/default";
|
|
1004
|
+
|
|
1010
1005
|
// src/components/providers/layout.tsx
|
|
1011
1006
|
import { useEffect as useEffect3, useState as useState4 } from "react";
|
|
1012
1007
|
import { LayoutContext } from "@pelatform/starter.hook";
|
|
@@ -1079,12 +1074,18 @@ function LayoutWrapper({
|
|
|
1079
1074
|
sidebarHeader,
|
|
1080
1075
|
sidebarMenu,
|
|
1081
1076
|
logoHeader,
|
|
1082
|
-
homeUrl
|
|
1077
|
+
homeUrl,
|
|
1078
|
+
studioUrl
|
|
1083
1079
|
}) {
|
|
1080
|
+
const { user } = useSession5();
|
|
1084
1081
|
const sidebarContent = /* @__PURE__ */ jsxs12(Fragment6, { children: [
|
|
1085
1082
|
sidebarHeader,
|
|
1086
1083
|
/* @__PURE__ */ jsx15(SidebarContent, { children: sidebarMenu })
|
|
1087
1084
|
] });
|
|
1085
|
+
const studioButton = /* @__PURE__ */ jsx15(Button5, { variant: "ghost", asChild: true, children: /* @__PURE__ */ jsxs12(Link8, { href: studioUrl || "#", target: "_blank", children: [
|
|
1086
|
+
/* @__PURE__ */ jsx15(RocketIcon, {}),
|
|
1087
|
+
" Studio"
|
|
1088
|
+
] }) });
|
|
1088
1089
|
return /* @__PURE__ */ jsxs12(LayoutProvider, { logoHeader, children: [
|
|
1089
1090
|
/* @__PURE__ */ jsxs12(Header, { children: [
|
|
1090
1091
|
/* @__PURE__ */ jsx15(HeaderLeft, {}),
|
|
@@ -1092,6 +1093,7 @@ function LayoutWrapper({
|
|
|
1092
1093
|
HeaderRight,
|
|
1093
1094
|
{
|
|
1094
1095
|
sidebar: /* @__PURE__ */ jsx15(HeaderSidebarMobile, { children: sidebarContent }),
|
|
1096
|
+
button: studioUrl && user?.role === "admin" ? studioButton : null,
|
|
1095
1097
|
homeUrl
|
|
1096
1098
|
}
|
|
1097
1099
|
)
|
|
@@ -1112,14 +1114,51 @@ import {
|
|
|
1112
1114
|
QueryContext
|
|
1113
1115
|
} from "@pelatform/starter.hook";
|
|
1114
1116
|
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1115
|
-
function ConfigProvider({
|
|
1117
|
+
function ConfigProvider({
|
|
1118
|
+
children,
|
|
1119
|
+
config: configProp,
|
|
1120
|
+
authClient: authClientProp,
|
|
1121
|
+
userAvatar: userAvatarProp,
|
|
1122
|
+
workspaceLogo: workspaceLogoProp,
|
|
1123
|
+
...props
|
|
1124
|
+
}) {
|
|
1116
1125
|
const mergedConfig = useMemo2(() => {
|
|
1117
|
-
return mergeConfig(defaultConfig,
|
|
1118
|
-
}, [
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1121
|
-
|
|
1126
|
+
return mergeConfig(defaultConfig, configProp);
|
|
1127
|
+
}, [configProp]);
|
|
1128
|
+
const config = mergedConfig;
|
|
1129
|
+
const authClient = authClientProp;
|
|
1130
|
+
const DEFAULT_IMAGE_OPTIONS = {
|
|
1131
|
+
extension: "png",
|
|
1132
|
+
size: 128
|
|
1122
1133
|
};
|
|
1134
|
+
const userAvatar = useMemo2(() => {
|
|
1135
|
+
if (!userAvatarProp) {
|
|
1136
|
+
return {
|
|
1137
|
+
extension: DEFAULT_IMAGE_OPTIONS.extension,
|
|
1138
|
+
size: DEFAULT_IMAGE_OPTIONS.size
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
return {
|
|
1142
|
+
upload: userAvatarProp.upload,
|
|
1143
|
+
delete: userAvatarProp.delete,
|
|
1144
|
+
extension: userAvatarProp.extension || DEFAULT_IMAGE_OPTIONS.extension,
|
|
1145
|
+
size: userAvatarProp.size || (userAvatarProp.upload ? 256 : DEFAULT_IMAGE_OPTIONS.size)
|
|
1146
|
+
};
|
|
1147
|
+
}, [userAvatarProp]);
|
|
1148
|
+
const workspaceLogo = useMemo2(() => {
|
|
1149
|
+
if (!workspaceLogoProp) {
|
|
1150
|
+
return {
|
|
1151
|
+
extension: DEFAULT_IMAGE_OPTIONS.extension,
|
|
1152
|
+
size: DEFAULT_IMAGE_OPTIONS.size
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
1155
|
+
return {
|
|
1156
|
+
upload: workspaceLogoProp.upload,
|
|
1157
|
+
delete: workspaceLogoProp.delete,
|
|
1158
|
+
extension: workspaceLogoProp.extension || DEFAULT_IMAGE_OPTIONS.extension,
|
|
1159
|
+
size: workspaceLogoProp.size || (workspaceLogoProp.upload ? 256 : DEFAULT_IMAGE_OPTIONS.size)
|
|
1160
|
+
};
|
|
1161
|
+
}, [workspaceLogoProp]);
|
|
1123
1162
|
return /* @__PURE__ */ jsx16(
|
|
1124
1163
|
QueryContext.Provider,
|
|
1125
1164
|
{
|
|
@@ -1127,7 +1166,18 @@ function ConfigProvider({ config, authClient, children, ...props }) {
|
|
|
1127
1166
|
...defaultAuthQueryOptions,
|
|
1128
1167
|
...props
|
|
1129
1168
|
},
|
|
1130
|
-
children: /* @__PURE__ */ jsx16(
|
|
1169
|
+
children: /* @__PURE__ */ jsx16(
|
|
1170
|
+
ConfigContext.Provider,
|
|
1171
|
+
{
|
|
1172
|
+
value: {
|
|
1173
|
+
...config,
|
|
1174
|
+
authClient,
|
|
1175
|
+
userAvatar,
|
|
1176
|
+
workspaceLogo
|
|
1177
|
+
},
|
|
1178
|
+
children
|
|
1179
|
+
}
|
|
1180
|
+
)
|
|
1131
1181
|
}
|
|
1132
1182
|
);
|
|
1133
1183
|
}
|
|
@@ -1159,7 +1209,7 @@ function SharedProviders({
|
|
|
1159
1209
|
|
|
1160
1210
|
// src/components/utils/card.tsx
|
|
1161
1211
|
import { cn as cn7 } from "pelatform-ui";
|
|
1162
|
-
import { Button as
|
|
1212
|
+
import { Button as Button6, Card, CardContent, CardFooter, Skeleton as Skeleton4, Spinner } from "pelatform-ui/default";
|
|
1163
1213
|
import { Fragment as Fragment7, jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1164
1214
|
function CardComponent({
|
|
1165
1215
|
children,
|
|
@@ -1300,7 +1350,7 @@ function CardActionComponent({
|
|
|
1300
1350
|
...props
|
|
1301
1351
|
}) {
|
|
1302
1352
|
return /* @__PURE__ */ jsxs14(
|
|
1303
|
-
|
|
1353
|
+
Button6,
|
|
1304
1354
|
{
|
|
1305
1355
|
type: onClick ? "button" : "submit",
|
|
1306
1356
|
variant: isDestructive ? "destructive" : "primary",
|
|
@@ -1326,7 +1376,7 @@ function CardActionComponent({
|
|
|
1326
1376
|
import { useTranslations as useTranslations11 } from "next-intl";
|
|
1327
1377
|
import { cn as cn8 } from "pelatform-ui";
|
|
1328
1378
|
import {
|
|
1329
|
-
Button as
|
|
1379
|
+
Button as Button7,
|
|
1330
1380
|
Dialog,
|
|
1331
1381
|
DialogContent,
|
|
1332
1382
|
DialogDescription,
|
|
@@ -1394,7 +1444,7 @@ function DialogFooterComponent({
|
|
|
1394
1444
|
const t = useTranslations11();
|
|
1395
1445
|
return /* @__PURE__ */ jsxs15(DialogFooter, { className: cn8(className, classNames?.dialog?.footer), children: [
|
|
1396
1446
|
cancelButton && /* @__PURE__ */ jsx19(
|
|
1397
|
-
|
|
1447
|
+
Button7,
|
|
1398
1448
|
{
|
|
1399
1449
|
type: "button",
|
|
1400
1450
|
variant: "ghost",
|
|
@@ -1434,7 +1484,7 @@ import { CheckIcon, CopyIcon } from "lucide-react";
|
|
|
1434
1484
|
import { useTranslations as useTranslations12 } from "next-intl";
|
|
1435
1485
|
import { cn as cn10 } from "pelatform-ui";
|
|
1436
1486
|
import {
|
|
1437
|
-
Button as
|
|
1487
|
+
Button as Button8,
|
|
1438
1488
|
Input,
|
|
1439
1489
|
Skeleton as Skeleton6,
|
|
1440
1490
|
Tooltip,
|
|
@@ -1480,7 +1530,7 @@ function DisplayIdCard({
|
|
|
1480
1530
|
children: [
|
|
1481
1531
|
/* @__PURE__ */ jsx21(Input, { value: id, ref: inputRef, disabled: true, className: "border-none! bg-transparent!" }),
|
|
1482
1532
|
/* @__PURE__ */ jsx21(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxs17(Tooltip, { children: [
|
|
1483
|
-
/* @__PURE__ */ jsx21(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx21(
|
|
1533
|
+
/* @__PURE__ */ jsx21(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx21(Button8, { variant: "dim", onClick: handleCopy, disabled: copied, children: copied ? /* @__PURE__ */ jsx21(CheckIcon, { className: cn10("stroke-green-600", classNames?.icon) }) : /* @__PURE__ */ jsx21(CopyIcon, { className: classNames?.icon }) }) }),
|
|
1484
1534
|
/* @__PURE__ */ jsx21(TooltipContent, { className: "px-2 py-1 text-xs", children: t("common.actions.copy") })
|
|
1485
1535
|
] }) })
|
|
1486
1536
|
]
|
|
@@ -1491,7 +1541,7 @@ function DisplayIdCard({
|
|
|
1491
1541
|
}
|
|
1492
1542
|
|
|
1493
1543
|
// src/components/empty-state.tsx
|
|
1494
|
-
import
|
|
1544
|
+
import Link9 from "next/link";
|
|
1495
1545
|
import { useTranslations as useTranslations13 } from "next-intl";
|
|
1496
1546
|
import { cn as cn11 } from "pelatform-ui";
|
|
1497
1547
|
import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
@@ -1512,7 +1562,7 @@ function EmptyState({
|
|
|
1512
1562
|
description,
|
|
1513
1563
|
" ",
|
|
1514
1564
|
learnMore && /* @__PURE__ */ jsxs18(
|
|
1515
|
-
|
|
1565
|
+
Link9,
|
|
1516
1566
|
{
|
|
1517
1567
|
href: learnMore,
|
|
1518
1568
|
className: "text-foreground underline underline-offset-2 transition-colors hover:text-primary",
|
|
@@ -1578,7 +1628,7 @@ function OTPInputGroup({ otpSeparators = 0 }) {
|
|
|
1578
1628
|
import { useState as useState5 } from "react";
|
|
1579
1629
|
import { EyeIcon, EyeOffIcon } from "lucide-react";
|
|
1580
1630
|
import { cn as cn12 } from "pelatform-ui";
|
|
1581
|
-
import { Button as
|
|
1631
|
+
import { Button as Button9, Input as Input2 } from "pelatform-ui/default";
|
|
1582
1632
|
import { Fragment as Fragment9, jsx as jsx24, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
1583
1633
|
function PasswordInput({
|
|
1584
1634
|
className,
|
|
@@ -1605,7 +1655,7 @@ function PasswordInput({
|
|
|
1605
1655
|
),
|
|
1606
1656
|
enableToggle && /* @__PURE__ */ jsxs20(Fragment9, { children: [
|
|
1607
1657
|
/* @__PURE__ */ jsx24(
|
|
1608
|
-
|
|
1658
|
+
Button9,
|
|
1609
1659
|
{
|
|
1610
1660
|
type: "button",
|
|
1611
1661
|
variant: "ghost",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pelatform/starter.shared",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "A part of SaaS starter kit for Pelatform applications.",
|
|
5
5
|
"author": "Pelatform",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@pelatform/starter.config": "0.2.2",
|
|
39
|
-
"@pelatform/starter.hook": "0.2.
|
|
40
|
-
"@pelatform/starter.utils": "0.2.
|
|
39
|
+
"@pelatform/starter.hook": "0.2.4",
|
|
40
|
+
"@pelatform/starter.utils": "0.2.7",
|
|
41
41
|
"@pelatform/tsconfig": "^0.1.4",
|
|
42
42
|
"@types/react": "^19.2.7",
|
|
43
43
|
"lucide-react": "^0.562.0",
|
|
44
44
|
"next": "^16.1.1",
|
|
45
45
|
"next-intl": "^4.6.1",
|
|
46
|
-
"pelatform-ui": "^1.1.
|
|
46
|
+
"pelatform-ui": "^1.1.12",
|
|
47
47
|
"react": "^19.2.3",
|
|
48
48
|
"tsup": "^8.5.1"
|
|
49
49
|
},
|