@pelatform/starter.shared 0.2.9 → 0.2.11
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 +13 -6
- package/dist/index.js +97 -25
- package/package.json +8 -8
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;
|
|
@@ -219,7 +224,9 @@ declare function CardHeaderComponent({ className, classNames, title, description
|
|
|
219
224
|
declare function CardFooterComponent({ className, classNames, instructions, actionLabel, action, disabled, isDestructive, isPending, isSubmitting, }: CardComponentProps): react_jsx_runtime.JSX.Element;
|
|
220
225
|
declare function CardActionComponent({ classNames, actionLabel, onClick, disabled, isDestructive, isSubmitting, ...props }: CardComponentProps & ComponentProps<typeof Button>): react_jsx_runtime.JSX.Element;
|
|
221
226
|
|
|
222
|
-
declare function DialogComponent({ children, classNames, onOpenChange, title, description, disableFooter, cancelButton, cancelButtonDisabled, button, ...props }: DialogComponentProps
|
|
227
|
+
declare function DialogComponent({ children, classNames, onOpenChange, title, description, disableFooter, cancelButton, cancelButtonDisabled, button, showCloseButton, ...props }: DialogComponentProps & {
|
|
228
|
+
showCloseButton?: boolean;
|
|
229
|
+
}): react_jsx_runtime.JSX.Element;
|
|
223
230
|
declare function DialogFooterComponent({ className, classNames, onOpenChange, cancelButton, cancelButtonDisabled, button, }: DialogComponentProps): react_jsx_runtime.JSX.Element;
|
|
224
231
|
|
|
225
232
|
declare function SkeletonViewComponent({ classNames }: {
|
package/dist/index.js
CHANGED
|
@@ -1007,6 +1007,12 @@ function SiteHeaderSecondary({
|
|
|
1007
1007
|
] });
|
|
1008
1008
|
}
|
|
1009
1009
|
|
|
1010
|
+
// src/components/layouts/wrapper.tsx
|
|
1011
|
+
import Link8 from "next/link";
|
|
1012
|
+
import { RocketIcon } from "lucide-react";
|
|
1013
|
+
import { useSession as useSession5 } from "@pelatform/starter.hook";
|
|
1014
|
+
import { Button as Button5 } from "pelatform-ui/default";
|
|
1015
|
+
|
|
1010
1016
|
// src/components/providers/layout.tsx
|
|
1011
1017
|
import { useEffect as useEffect3, useState as useState4 } from "react";
|
|
1012
1018
|
import { LayoutContext } from "@pelatform/starter.hook";
|
|
@@ -1079,12 +1085,18 @@ function LayoutWrapper({
|
|
|
1079
1085
|
sidebarHeader,
|
|
1080
1086
|
sidebarMenu,
|
|
1081
1087
|
logoHeader,
|
|
1082
|
-
homeUrl
|
|
1088
|
+
homeUrl,
|
|
1089
|
+
studioUrl
|
|
1083
1090
|
}) {
|
|
1091
|
+
const { user } = useSession5();
|
|
1084
1092
|
const sidebarContent = /* @__PURE__ */ jsxs12(Fragment6, { children: [
|
|
1085
1093
|
sidebarHeader,
|
|
1086
1094
|
/* @__PURE__ */ jsx15(SidebarContent, { children: sidebarMenu })
|
|
1087
1095
|
] });
|
|
1096
|
+
const studioButton = /* @__PURE__ */ jsx15(Button5, { variant: "ghost", asChild: true, children: /* @__PURE__ */ jsxs12(Link8, { href: studioUrl || "#", target: "_blank", children: [
|
|
1097
|
+
/* @__PURE__ */ jsx15(RocketIcon, {}),
|
|
1098
|
+
" Studio"
|
|
1099
|
+
] }) });
|
|
1088
1100
|
return /* @__PURE__ */ jsxs12(LayoutProvider, { logoHeader, children: [
|
|
1089
1101
|
/* @__PURE__ */ jsxs12(Header, { children: [
|
|
1090
1102
|
/* @__PURE__ */ jsx15(HeaderLeft, {}),
|
|
@@ -1092,6 +1104,7 @@ function LayoutWrapper({
|
|
|
1092
1104
|
HeaderRight,
|
|
1093
1105
|
{
|
|
1094
1106
|
sidebar: /* @__PURE__ */ jsx15(HeaderSidebarMobile, { children: sidebarContent }),
|
|
1107
|
+
button: studioUrl && user?.role === "admin" ? studioButton : null,
|
|
1095
1108
|
homeUrl
|
|
1096
1109
|
}
|
|
1097
1110
|
)
|
|
@@ -1112,14 +1125,51 @@ import {
|
|
|
1112
1125
|
QueryContext
|
|
1113
1126
|
} from "@pelatform/starter.hook";
|
|
1114
1127
|
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1115
|
-
function ConfigProvider({
|
|
1128
|
+
function ConfigProvider({
|
|
1129
|
+
children,
|
|
1130
|
+
config: configProp,
|
|
1131
|
+
authClient: authClientProp,
|
|
1132
|
+
userAvatar: userAvatarProp,
|
|
1133
|
+
workspaceLogo: workspaceLogoProp,
|
|
1134
|
+
...props
|
|
1135
|
+
}) {
|
|
1116
1136
|
const mergedConfig = useMemo2(() => {
|
|
1117
|
-
return mergeConfig(defaultConfig,
|
|
1118
|
-
}, [
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1121
|
-
|
|
1137
|
+
return mergeConfig(defaultConfig, configProp);
|
|
1138
|
+
}, [configProp]);
|
|
1139
|
+
const config = mergedConfig;
|
|
1140
|
+
const authClient = authClientProp;
|
|
1141
|
+
const DEFAULT_IMAGE_OPTIONS = {
|
|
1142
|
+
extension: "png",
|
|
1143
|
+
size: 128
|
|
1122
1144
|
};
|
|
1145
|
+
const userAvatar = useMemo2(() => {
|
|
1146
|
+
if (!userAvatarProp) {
|
|
1147
|
+
return {
|
|
1148
|
+
extension: DEFAULT_IMAGE_OPTIONS.extension,
|
|
1149
|
+
size: DEFAULT_IMAGE_OPTIONS.size
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
return {
|
|
1153
|
+
upload: userAvatarProp.upload,
|
|
1154
|
+
delete: userAvatarProp.delete,
|
|
1155
|
+
extension: userAvatarProp.extension || DEFAULT_IMAGE_OPTIONS.extension,
|
|
1156
|
+
size: userAvatarProp.size || (userAvatarProp.upload ? 256 : DEFAULT_IMAGE_OPTIONS.size)
|
|
1157
|
+
};
|
|
1158
|
+
}, [userAvatarProp]);
|
|
1159
|
+
const workspaceLogo = useMemo2(() => {
|
|
1160
|
+
if (!workspaceLogoProp) {
|
|
1161
|
+
return {
|
|
1162
|
+
extension: DEFAULT_IMAGE_OPTIONS.extension,
|
|
1163
|
+
size: DEFAULT_IMAGE_OPTIONS.size
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
return {
|
|
1167
|
+
upload: workspaceLogoProp.upload,
|
|
1168
|
+
delete: workspaceLogoProp.delete,
|
|
1169
|
+
extension: workspaceLogoProp.extension || DEFAULT_IMAGE_OPTIONS.extension,
|
|
1170
|
+
size: workspaceLogoProp.size || (workspaceLogoProp.upload ? 256 : DEFAULT_IMAGE_OPTIONS.size)
|
|
1171
|
+
};
|
|
1172
|
+
}, [workspaceLogoProp]);
|
|
1123
1173
|
return /* @__PURE__ */ jsx16(
|
|
1124
1174
|
QueryContext.Provider,
|
|
1125
1175
|
{
|
|
@@ -1127,7 +1177,18 @@ function ConfigProvider({ config, authClient, children, ...props }) {
|
|
|
1127
1177
|
...defaultAuthQueryOptions,
|
|
1128
1178
|
...props
|
|
1129
1179
|
},
|
|
1130
|
-
children: /* @__PURE__ */ jsx16(
|
|
1180
|
+
children: /* @__PURE__ */ jsx16(
|
|
1181
|
+
ConfigContext.Provider,
|
|
1182
|
+
{
|
|
1183
|
+
value: {
|
|
1184
|
+
...config,
|
|
1185
|
+
authClient,
|
|
1186
|
+
userAvatar,
|
|
1187
|
+
workspaceLogo
|
|
1188
|
+
},
|
|
1189
|
+
children
|
|
1190
|
+
}
|
|
1191
|
+
)
|
|
1131
1192
|
}
|
|
1132
1193
|
);
|
|
1133
1194
|
}
|
|
@@ -1159,7 +1220,7 @@ function SharedProviders({
|
|
|
1159
1220
|
|
|
1160
1221
|
// src/components/utils/card.tsx
|
|
1161
1222
|
import { cn as cn7 } from "pelatform-ui";
|
|
1162
|
-
import { Button as
|
|
1223
|
+
import { Button as Button6, Card, CardContent, CardFooter, Skeleton as Skeleton4, Spinner } from "pelatform-ui/default";
|
|
1163
1224
|
import { Fragment as Fragment7, jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1164
1225
|
function CardComponent({
|
|
1165
1226
|
children,
|
|
@@ -1300,7 +1361,7 @@ function CardActionComponent({
|
|
|
1300
1361
|
...props
|
|
1301
1362
|
}) {
|
|
1302
1363
|
return /* @__PURE__ */ jsxs14(
|
|
1303
|
-
|
|
1364
|
+
Button6,
|
|
1304
1365
|
{
|
|
1305
1366
|
type: onClick ? "button" : "submit",
|
|
1306
1367
|
variant: isDestructive ? "destructive" : "primary",
|
|
@@ -1326,7 +1387,7 @@ function CardActionComponent({
|
|
|
1326
1387
|
import { useTranslations as useTranslations11 } from "next-intl";
|
|
1327
1388
|
import { cn as cn8 } from "pelatform-ui";
|
|
1328
1389
|
import {
|
|
1329
|
-
Button as
|
|
1390
|
+
Button as Button7,
|
|
1330
1391
|
Dialog,
|
|
1331
1392
|
DialogContent,
|
|
1332
1393
|
DialogDescription,
|
|
@@ -1345,18 +1406,29 @@ function DialogComponent({
|
|
|
1345
1406
|
cancelButton,
|
|
1346
1407
|
cancelButtonDisabled,
|
|
1347
1408
|
button,
|
|
1409
|
+
showCloseButton = false,
|
|
1348
1410
|
...props
|
|
1349
1411
|
}) {
|
|
1350
1412
|
return /* @__PURE__ */ jsx19(Dialog, { onOpenChange, ...props, children: /* @__PURE__ */ jsxs15(
|
|
1351
1413
|
DialogContent,
|
|
1352
1414
|
{
|
|
1353
1415
|
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
1354
|
-
className: classNames?.dialog?.content,
|
|
1416
|
+
className: cn8("bg-muted sm:max-w-md", classNames?.dialog?.content),
|
|
1417
|
+
showCloseButton,
|
|
1355
1418
|
children: [
|
|
1356
|
-
/* @__PURE__ */ jsxs15(
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1419
|
+
/* @__PURE__ */ jsxs15(
|
|
1420
|
+
DialogHeader,
|
|
1421
|
+
{
|
|
1422
|
+
className: cn8(
|
|
1423
|
+
"-ms-6 -me-6 -mt-6 space-y-2 rounded-t-lg bg-background p-6",
|
|
1424
|
+
classNames?.header
|
|
1425
|
+
),
|
|
1426
|
+
children: [
|
|
1427
|
+
/* @__PURE__ */ jsx19(DialogTitle, { className: classNames?.title, children: title }),
|
|
1428
|
+
description && /* @__PURE__ */ jsx19(DialogDescription, { className: classNames?.description, children: description })
|
|
1429
|
+
]
|
|
1430
|
+
}
|
|
1431
|
+
),
|
|
1360
1432
|
children,
|
|
1361
1433
|
!disableFooter && /* @__PURE__ */ jsx19(
|
|
1362
1434
|
DialogFooterComponent,
|
|
@@ -1383,11 +1455,11 @@ function DialogFooterComponent({
|
|
|
1383
1455
|
const t = useTranslations11();
|
|
1384
1456
|
return /* @__PURE__ */ jsxs15(DialogFooter, { className: cn8(className, classNames?.dialog?.footer), children: [
|
|
1385
1457
|
cancelButton && /* @__PURE__ */ jsx19(
|
|
1386
|
-
|
|
1458
|
+
Button7,
|
|
1387
1459
|
{
|
|
1388
1460
|
type: "button",
|
|
1389
|
-
variant: "
|
|
1390
|
-
className: cn8(classNames?.button
|
|
1461
|
+
variant: "ghost",
|
|
1462
|
+
className: cn8(classNames?.button),
|
|
1391
1463
|
onClick: () => onOpenChange?.(false),
|
|
1392
1464
|
disabled: cancelButtonDisabled,
|
|
1393
1465
|
children: t("common.actions.cancel")
|
|
@@ -1423,7 +1495,7 @@ import { CheckIcon, CopyIcon } from "lucide-react";
|
|
|
1423
1495
|
import { useTranslations as useTranslations12 } from "next-intl";
|
|
1424
1496
|
import { cn as cn10 } from "pelatform-ui";
|
|
1425
1497
|
import {
|
|
1426
|
-
Button as
|
|
1498
|
+
Button as Button8,
|
|
1427
1499
|
Input,
|
|
1428
1500
|
Skeleton as Skeleton6,
|
|
1429
1501
|
Tooltip,
|
|
@@ -1469,7 +1541,7 @@ function DisplayIdCard({
|
|
|
1469
1541
|
children: [
|
|
1470
1542
|
/* @__PURE__ */ jsx21(Input, { value: id, ref: inputRef, disabled: true, className: "border-none! bg-transparent!" }),
|
|
1471
1543
|
/* @__PURE__ */ jsx21(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxs17(Tooltip, { children: [
|
|
1472
|
-
/* @__PURE__ */ jsx21(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx21(
|
|
1544
|
+
/* @__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 }) }) }),
|
|
1473
1545
|
/* @__PURE__ */ jsx21(TooltipContent, { className: "px-2 py-1 text-xs", children: t("common.actions.copy") })
|
|
1474
1546
|
] }) })
|
|
1475
1547
|
]
|
|
@@ -1480,7 +1552,7 @@ function DisplayIdCard({
|
|
|
1480
1552
|
}
|
|
1481
1553
|
|
|
1482
1554
|
// src/components/empty-state.tsx
|
|
1483
|
-
import
|
|
1555
|
+
import Link9 from "next/link";
|
|
1484
1556
|
import { useTranslations as useTranslations13 } from "next-intl";
|
|
1485
1557
|
import { cn as cn11 } from "pelatform-ui";
|
|
1486
1558
|
import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
@@ -1501,7 +1573,7 @@ function EmptyState({
|
|
|
1501
1573
|
description,
|
|
1502
1574
|
" ",
|
|
1503
1575
|
learnMore && /* @__PURE__ */ jsxs18(
|
|
1504
|
-
|
|
1576
|
+
Link9,
|
|
1505
1577
|
{
|
|
1506
1578
|
href: learnMore,
|
|
1507
1579
|
className: "text-foreground underline underline-offset-2 transition-colors hover:text-primary",
|
|
@@ -1567,7 +1639,7 @@ function OTPInputGroup({ otpSeparators = 0 }) {
|
|
|
1567
1639
|
import { useState as useState5 } from "react";
|
|
1568
1640
|
import { EyeIcon, EyeOffIcon } from "lucide-react";
|
|
1569
1641
|
import { cn as cn12 } from "pelatform-ui";
|
|
1570
|
-
import { Button as
|
|
1642
|
+
import { Button as Button9, Input as Input2 } from "pelatform-ui/default";
|
|
1571
1643
|
import { Fragment as Fragment9, jsx as jsx24, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
1572
1644
|
function PasswordInput({
|
|
1573
1645
|
className,
|
|
@@ -1594,7 +1666,7 @@ function PasswordInput({
|
|
|
1594
1666
|
),
|
|
1595
1667
|
enableToggle && /* @__PURE__ */ jsxs20(Fragment9, { children: [
|
|
1596
1668
|
/* @__PURE__ */ jsx24(
|
|
1597
|
-
|
|
1669
|
+
Button9,
|
|
1598
1670
|
{
|
|
1599
1671
|
type: "button",
|
|
1600
1672
|
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.11",
|
|
4
4
|
"description": "A part of SaaS starter kit for Pelatform applications.",
|
|
5
5
|
"author": "Pelatform",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
"utilities"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@tanstack/react-query-devtools": "^5.91.
|
|
35
|
+
"@tanstack/react-query-devtools": "^5.91.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@pelatform/starter.config": "0.2.
|
|
39
|
-
"@pelatform/starter.hook": "0.2.
|
|
40
|
-
"@pelatform/starter.utils": "0.2.
|
|
41
|
-
"@pelatform/tsconfig": "^0.1.
|
|
38
|
+
"@pelatform/starter.config": "0.2.2",
|
|
39
|
+
"@pelatform/starter.hook": "0.2.4",
|
|
40
|
+
"@pelatform/starter.utils": "0.2.6",
|
|
41
|
+
"@pelatform/tsconfig": "^0.1.4",
|
|
42
42
|
"@types/react": "^19.2.7",
|
|
43
43
|
"lucide-react": "^0.562.0",
|
|
44
|
-
"next": "^16.1.
|
|
44
|
+
"next": "^16.1.1",
|
|
45
45
|
"next-intl": "^4.6.1",
|
|
46
|
-
"pelatform-ui": "^1.1.
|
|
46
|
+
"pelatform-ui": "^1.1.10",
|
|
47
47
|
"react": "^19.2.3",
|
|
48
48
|
"tsup": "^8.5.1"
|
|
49
49
|
},
|