@pelatform/starter.shared 0.2.10 → 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 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
- /** Child components that can access the configuration */
93
- children: ReactNode;
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, children, ...props }: ConfigProviderProps): react_jsx_runtime.JSX.Element;
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
@@ -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({ config, authClient, children, ...props }) {
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, config);
1118
- }, [config]);
1119
- const configWithAuth = {
1120
- ...mergedConfig,
1121
- authClient
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(ConfigContext.Provider, { value: configWithAuth, children })
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 Button5, Card, CardContent, CardFooter, Skeleton as Skeleton4, Spinner } from "pelatform-ui/default";
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
- Button5,
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 Button6,
1390
+ Button as Button7,
1330
1391
  Dialog,
1331
1392
  DialogContent,
1332
1393
  DialogDescription,
@@ -1394,7 +1455,7 @@ function DialogFooterComponent({
1394
1455
  const t = useTranslations11();
1395
1456
  return /* @__PURE__ */ jsxs15(DialogFooter, { className: cn8(className, classNames?.dialog?.footer), children: [
1396
1457
  cancelButton && /* @__PURE__ */ jsx19(
1397
- Button6,
1458
+ Button7,
1398
1459
  {
1399
1460
  type: "button",
1400
1461
  variant: "ghost",
@@ -1434,7 +1495,7 @@ import { CheckIcon, CopyIcon } from "lucide-react";
1434
1495
  import { useTranslations as useTranslations12 } from "next-intl";
1435
1496
  import { cn as cn10 } from "pelatform-ui";
1436
1497
  import {
1437
- Button as Button7,
1498
+ Button as Button8,
1438
1499
  Input,
1439
1500
  Skeleton as Skeleton6,
1440
1501
  Tooltip,
@@ -1480,7 +1541,7 @@ function DisplayIdCard({
1480
1541
  children: [
1481
1542
  /* @__PURE__ */ jsx21(Input, { value: id, ref: inputRef, disabled: true, className: "border-none! bg-transparent!" }),
1482
1543
  /* @__PURE__ */ jsx21(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxs17(Tooltip, { children: [
1483
- /* @__PURE__ */ jsx21(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx21(Button7, { variant: "dim", onClick: handleCopy, disabled: copied, children: copied ? /* @__PURE__ */ jsx21(CheckIcon, { className: cn10("stroke-green-600", classNames?.icon) }) : /* @__PURE__ */ jsx21(CopyIcon, { className: classNames?.icon }) }) }),
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 }) }) }),
1484
1545
  /* @__PURE__ */ jsx21(TooltipContent, { className: "px-2 py-1 text-xs", children: t("common.actions.copy") })
1485
1546
  ] }) })
1486
1547
  ]
@@ -1491,7 +1552,7 @@ function DisplayIdCard({
1491
1552
  }
1492
1553
 
1493
1554
  // src/components/empty-state.tsx
1494
- import Link8 from "next/link";
1555
+ import Link9 from "next/link";
1495
1556
  import { useTranslations as useTranslations13 } from "next-intl";
1496
1557
  import { cn as cn11 } from "pelatform-ui";
1497
1558
  import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
@@ -1512,7 +1573,7 @@ function EmptyState({
1512
1573
  description,
1513
1574
  " ",
1514
1575
  learnMore && /* @__PURE__ */ jsxs18(
1515
- Link8,
1576
+ Link9,
1516
1577
  {
1517
1578
  href: learnMore,
1518
1579
  className: "text-foreground underline underline-offset-2 transition-colors hover:text-primary",
@@ -1578,7 +1639,7 @@ function OTPInputGroup({ otpSeparators = 0 }) {
1578
1639
  import { useState as useState5 } from "react";
1579
1640
  import { EyeIcon, EyeOffIcon } from "lucide-react";
1580
1641
  import { cn as cn12 } from "pelatform-ui";
1581
- import { Button as Button8, Input as Input2 } from "pelatform-ui/default";
1642
+ import { Button as Button9, Input as Input2 } from "pelatform-ui/default";
1582
1643
  import { Fragment as Fragment9, jsx as jsx24, jsxs as jsxs20 } from "react/jsx-runtime";
1583
1644
  function PasswordInput({
1584
1645
  className,
@@ -1605,7 +1666,7 @@ function PasswordInput({
1605
1666
  ),
1606
1667
  enableToggle && /* @__PURE__ */ jsxs20(Fragment9, { children: [
1607
1668
  /* @__PURE__ */ jsx24(
1608
- Button8,
1669
+ Button9,
1609
1670
  {
1610
1671
  type: "button",
1611
1672
  variant: "ghost",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pelatform/starter.shared",
3
- "version": "0.2.10",
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",
@@ -36,8 +36,8 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "@pelatform/starter.config": "0.2.2",
39
- "@pelatform/starter.hook": "0.2.3",
40
- "@pelatform/starter.utils": "0.2.5",
39
+ "@pelatform/starter.hook": "0.2.4",
40
+ "@pelatform/starter.utils": "0.2.6",
41
41
  "@pelatform/tsconfig": "^0.1.4",
42
42
  "@types/react": "^19.2.7",
43
43
  "lucide-react": "^0.562.0",