admin-lib-cms 1.0.5

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/email.js ADDED
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/email.ts
21
+ var email_exports = {};
22
+ __export(email_exports, {
23
+ generateEmailTemplate: () => generateEmailTemplate
24
+ });
25
+ module.exports = __toCommonJS(email_exports);
26
+ function generateEmailTemplate(data, title, description) {
27
+ const items = Object.entries(data).filter(([_, value]) => value !== void 0 && value !== null && value !== "").map(([key, value]) => {
28
+ const label = key.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase());
29
+ const displayValue = Array.isArray(value) ? value.join(", ") : String(value);
30
+ return `
31
+ <div class="detail-item">
32
+ <span class="detail-label">${label}</span>
33
+ <span class="detail-value">${displayValue}</span>
34
+ </div>
35
+ `;
36
+ }).join("");
37
+ return `
38
+ <!DOCTYPE html>
39
+ <html lang="en">
40
+ <head>
41
+ <meta charset="UTF-8">
42
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
43
+ <title>${title}</title>
44
+ <style>
45
+ * { margin: 0; padding: 0; box-sizing: border-box; }
46
+ body {
47
+ background-color: #f4f4f5;
48
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
49
+ color: #18181b;
50
+ line-height: 1.5;
51
+ }
52
+ .wrapper { width: 100%; padding: 40px 20px; }
53
+ .container { max-width: 600px; margin: 0 auto; }
54
+ .card {
55
+ background: #ffffff;
56
+ border-radius: 12px;
57
+ overflow: hidden;
58
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
59
+ border: 1px solid #e4e4e7;
60
+ }
61
+ .header {
62
+ background: #5fa075;
63
+ padding: 40px 32px;
64
+ text-align: center;
65
+ border-bottom: 4px solid #48805c;
66
+ }
67
+ .header h1 {
68
+ color: #ffffff;
69
+ font-size: 24px;
70
+ font-weight: 700;
71
+ margin-bottom: 8px;
72
+ text-transform: uppercase;
73
+ letter-spacing: 0.05em;
74
+ }
75
+ .header p {
76
+ color: rgba(255, 255, 255, 0.9);
77
+ font-size: 14px;
78
+ }
79
+ .content { padding: 32px; }
80
+ .details-grid {
81
+ display: grid;
82
+ gap: 12px;
83
+ margin-bottom: 24px;
84
+ }
85
+ .detail-item {
86
+ background: #fafafa;
87
+ padding: 12px 16px;
88
+ border-radius: 8px;
89
+ border: 1px solid #f1f1f4;
90
+ }
91
+ .detail-label {
92
+ font-size: 11px;
93
+ font-weight: 700;
94
+ color: #71717a;
95
+ text-transform: uppercase;
96
+ letter-spacing: 0.05em;
97
+ display: block;
98
+ margin-bottom: 4px;
99
+ }
100
+ .detail-value {
101
+ font-size: 14px;
102
+ font-weight: 500;
103
+ color: #18181b;
104
+ word-break: break-word;
105
+ }
106
+ .footer {
107
+ padding: 24px 32px;
108
+ background: #f8fafc;
109
+ border-top: 1px solid #e2e8f0;
110
+ text-align: center;
111
+ }
112
+ .footer-text {
113
+ font-size: 12px;
114
+ color: #64748b;
115
+ }
116
+ </style>
117
+ </head>
118
+ <body>
119
+ <div class="wrapper">
120
+ <div class="container">
121
+ <div class="card">
122
+ <div class="header">
123
+ <h1>${title}</h1>
124
+ <p>${description}</p>
125
+ </div>
126
+ <div class="content">
127
+ <div class="details-grid">
128
+ ${items}
129
+ </div>
130
+ </div>
131
+ <div class="footer">
132
+ <p class="footer-text">\xA9 ${(/* @__PURE__ */ new Date()).getFullYear()} Serenity Wellness. This is an automated notification.</p>
133
+ </div>
134
+ </div>
135
+ </div>
136
+ </div>
137
+ </body>
138
+ </html>
139
+ `;
140
+ }
141
+ // Annotate the CommonJS export names for ESM import in node:
142
+ 0 && (module.exports = {
143
+ generateEmailTemplate
144
+ });
package/dist/email.mjs ADDED
@@ -0,0 +1,6 @@
1
+ import {
2
+ generateEmailTemplate
3
+ } from "./chunk-CQW7KMB2.mjs";
4
+ export {
5
+ generateEmailTemplate
6
+ };
@@ -0,0 +1,126 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { CmsConfig, StorageAdapter, OverridesMap, EditableMeta } from './types.mjs';
4
+ export { generateEmailTemplate } from './email.mjs';
5
+
6
+ interface CmsContextValue {
7
+ config: CmsConfig;
8
+ adapter: StorageAdapter;
9
+ overrides: OverridesMap;
10
+ editMode: boolean;
11
+ selectedId: string | null;
12
+ setSelectedId: (id: string | null) => void;
13
+ setOverride: (id: string, value: unknown) => void;
14
+ registerEditable: (meta: EditableMeta) => void;
15
+ unregisterEditable: (id: string) => void;
16
+ getRegistered: () => EditableMeta[];
17
+ save: () => Promise<void>;
18
+ reset: (id?: string) => Promise<void>;
19
+ isDirty: boolean;
20
+ iconMap?: Record<string, React.ComponentType<{
21
+ className?: string;
22
+ }>>;
23
+ uploadImage?: (file: File) => Promise<string>;
24
+ /** Increments whenever a collection entry is saved or deleted — components can use this as a useEffect dep to auto-refresh. */
25
+ collectionChangedAt: number;
26
+ notifyCollectionChanged: () => void;
27
+ }
28
+ declare function useCmsContext(): CmsContextValue;
29
+ declare function useCmsOptional(): CmsContextValue | null;
30
+ interface CmsProviderProps {
31
+ config: CmsConfig;
32
+ adapter: StorageAdapter;
33
+ children: ReactNode;
34
+ iconMap?: Record<string, React.ComponentType<{
35
+ className?: string;
36
+ }>>;
37
+ }
38
+ declare function CmsProvider({ config, adapter, children, iconMap }: CmsProviderProps): react.JSX.Element;
39
+ /** Hook to submit form data to the CMS inbox. */
40
+ declare function useSubmit(formId: string): (data: Record<string, unknown>) => Promise<void>;
41
+
42
+ interface BaseProps {
43
+ id: string;
44
+ label?: string;
45
+ section?: string;
46
+ pageId?: string;
47
+ }
48
+ interface EditableTextProps extends BaseProps {
49
+ children: string;
50
+ as?: "span" | "p" | "h1" | "h2" | "h3" | "h4" | "div";
51
+ className?: string;
52
+ }
53
+ declare function EditableText({ id, label, section, pageId, children, as, className, }: EditableTextProps): react.ReactElement<any, string | react.JSXElementConstructor<any>>;
54
+ interface EditableImageProps extends BaseProps {
55
+ src: string;
56
+ alt?: string;
57
+ className?: string;
58
+ width?: number;
59
+ height?: number;
60
+ }
61
+ declare function EditableImage({ id, label, section, pageId, src, alt, className, width, height, }: EditableImageProps): react.JSX.Element;
62
+ interface EditableLinkProps extends BaseProps {
63
+ href: string;
64
+ children: string;
65
+ className?: string;
66
+ }
67
+ declare function EditableLink({ id, label, section, pageId, href, children, className, }: EditableLinkProps): react.JSX.Element;
68
+ interface EditableListProps<T = any> extends BaseProps {
69
+ initialItems: T[];
70
+ renderItem: (item: T, index: number) => React.ReactNode;
71
+ itemSchema?: {
72
+ key: string;
73
+ type: "text" | "textarea" | "boolean" | "icon" | "image" | "number";
74
+ label?: string;
75
+ options?: string[];
76
+ }[];
77
+ fixedLength?: boolean;
78
+ className?: string;
79
+ listClassName?: string;
80
+ }
81
+ declare function EditableList<T = any>({ id, label, section, pageId, initialItems, renderItem, itemSchema, fixedLength, className, listClassName, }: EditableListProps<T>): react.JSX.Element;
82
+
83
+ declare function AdminApp({ apiUrl, projectId, email }: {
84
+ apiUrl?: string;
85
+ projectId?: string;
86
+ email?: string;
87
+ }): react.JSX.Element;
88
+
89
+ interface AdminLoginProps {
90
+ authApiRoute?: string;
91
+ redirectRoute?: string;
92
+ }
93
+ declare function AdminLogin({ authApiRoute, redirectRoute, }: AdminLoginProps): react.JSX.Element;
94
+
95
+ interface SubscriptionData {
96
+ subscriptionStatus: string;
97
+ currentPeriodEnd?: string;
98
+ customerEmail?: string;
99
+ subscriptionId?: string;
100
+ stripeCustomerId?: string;
101
+ stripePaymentLink?: string;
102
+ valid: boolean;
103
+ }
104
+ interface SubscriptionContextValue {
105
+ subscription: SubscriptionData | null;
106
+ loading: boolean;
107
+ error: string | null;
108
+ refetch: (silent?: boolean) => Promise<void>;
109
+ isSubscriptionActive: boolean;
110
+ config: {
111
+ apiUrl?: string;
112
+ projectId?: string;
113
+ };
114
+ }
115
+ declare function useSubscriptionContext(): SubscriptionContextValue;
116
+ declare function useSubscription(): SubscriptionContextValue;
117
+ declare function SubscriptionProvider({ children, apiUrl, projectId, email, }: {
118
+ children: ReactNode;
119
+ apiUrl?: string;
120
+ projectId?: string;
121
+ email?: string;
122
+ }): react.JSX.Element;
123
+
124
+ declare function SubscriptionPage(): react.JSX.Element;
125
+
126
+ export { AdminApp, AdminLogin, type AdminLoginProps, CmsProvider, EditableImage, EditableLink, EditableList, EditableText, type SubscriptionContextValue, type SubscriptionData, SubscriptionPage, SubscriptionProvider, useCmsContext, useCmsOptional, useSubmit, useSubscription, useSubscriptionContext };
@@ -0,0 +1,126 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { CmsConfig, StorageAdapter, OverridesMap, EditableMeta } from './types.js';
4
+ export { generateEmailTemplate } from './email.js';
5
+
6
+ interface CmsContextValue {
7
+ config: CmsConfig;
8
+ adapter: StorageAdapter;
9
+ overrides: OverridesMap;
10
+ editMode: boolean;
11
+ selectedId: string | null;
12
+ setSelectedId: (id: string | null) => void;
13
+ setOverride: (id: string, value: unknown) => void;
14
+ registerEditable: (meta: EditableMeta) => void;
15
+ unregisterEditable: (id: string) => void;
16
+ getRegistered: () => EditableMeta[];
17
+ save: () => Promise<void>;
18
+ reset: (id?: string) => Promise<void>;
19
+ isDirty: boolean;
20
+ iconMap?: Record<string, React.ComponentType<{
21
+ className?: string;
22
+ }>>;
23
+ uploadImage?: (file: File) => Promise<string>;
24
+ /** Increments whenever a collection entry is saved or deleted — components can use this as a useEffect dep to auto-refresh. */
25
+ collectionChangedAt: number;
26
+ notifyCollectionChanged: () => void;
27
+ }
28
+ declare function useCmsContext(): CmsContextValue;
29
+ declare function useCmsOptional(): CmsContextValue | null;
30
+ interface CmsProviderProps {
31
+ config: CmsConfig;
32
+ adapter: StorageAdapter;
33
+ children: ReactNode;
34
+ iconMap?: Record<string, React.ComponentType<{
35
+ className?: string;
36
+ }>>;
37
+ }
38
+ declare function CmsProvider({ config, adapter, children, iconMap }: CmsProviderProps): react.JSX.Element;
39
+ /** Hook to submit form data to the CMS inbox. */
40
+ declare function useSubmit(formId: string): (data: Record<string, unknown>) => Promise<void>;
41
+
42
+ interface BaseProps {
43
+ id: string;
44
+ label?: string;
45
+ section?: string;
46
+ pageId?: string;
47
+ }
48
+ interface EditableTextProps extends BaseProps {
49
+ children: string;
50
+ as?: "span" | "p" | "h1" | "h2" | "h3" | "h4" | "div";
51
+ className?: string;
52
+ }
53
+ declare function EditableText({ id, label, section, pageId, children, as, className, }: EditableTextProps): react.ReactElement<any, string | react.JSXElementConstructor<any>>;
54
+ interface EditableImageProps extends BaseProps {
55
+ src: string;
56
+ alt?: string;
57
+ className?: string;
58
+ width?: number;
59
+ height?: number;
60
+ }
61
+ declare function EditableImage({ id, label, section, pageId, src, alt, className, width, height, }: EditableImageProps): react.JSX.Element;
62
+ interface EditableLinkProps extends BaseProps {
63
+ href: string;
64
+ children: string;
65
+ className?: string;
66
+ }
67
+ declare function EditableLink({ id, label, section, pageId, href, children, className, }: EditableLinkProps): react.JSX.Element;
68
+ interface EditableListProps<T = any> extends BaseProps {
69
+ initialItems: T[];
70
+ renderItem: (item: T, index: number) => React.ReactNode;
71
+ itemSchema?: {
72
+ key: string;
73
+ type: "text" | "textarea" | "boolean" | "icon" | "image" | "number";
74
+ label?: string;
75
+ options?: string[];
76
+ }[];
77
+ fixedLength?: boolean;
78
+ className?: string;
79
+ listClassName?: string;
80
+ }
81
+ declare function EditableList<T = any>({ id, label, section, pageId, initialItems, renderItem, itemSchema, fixedLength, className, listClassName, }: EditableListProps<T>): react.JSX.Element;
82
+
83
+ declare function AdminApp({ apiUrl, projectId, email }: {
84
+ apiUrl?: string;
85
+ projectId?: string;
86
+ email?: string;
87
+ }): react.JSX.Element;
88
+
89
+ interface AdminLoginProps {
90
+ authApiRoute?: string;
91
+ redirectRoute?: string;
92
+ }
93
+ declare function AdminLogin({ authApiRoute, redirectRoute, }: AdminLoginProps): react.JSX.Element;
94
+
95
+ interface SubscriptionData {
96
+ subscriptionStatus: string;
97
+ currentPeriodEnd?: string;
98
+ customerEmail?: string;
99
+ subscriptionId?: string;
100
+ stripeCustomerId?: string;
101
+ stripePaymentLink?: string;
102
+ valid: boolean;
103
+ }
104
+ interface SubscriptionContextValue {
105
+ subscription: SubscriptionData | null;
106
+ loading: boolean;
107
+ error: string | null;
108
+ refetch: (silent?: boolean) => Promise<void>;
109
+ isSubscriptionActive: boolean;
110
+ config: {
111
+ apiUrl?: string;
112
+ projectId?: string;
113
+ };
114
+ }
115
+ declare function useSubscriptionContext(): SubscriptionContextValue;
116
+ declare function useSubscription(): SubscriptionContextValue;
117
+ declare function SubscriptionProvider({ children, apiUrl, projectId, email, }: {
118
+ children: ReactNode;
119
+ apiUrl?: string;
120
+ projectId?: string;
121
+ email?: string;
122
+ }): react.JSX.Element;
123
+
124
+ declare function SubscriptionPage(): react.JSX.Element;
125
+
126
+ export { AdminApp, AdminLogin, type AdminLoginProps, CmsProvider, EditableImage, EditableLink, EditableList, EditableText, type SubscriptionContextValue, type SubscriptionData, SubscriptionPage, SubscriptionProvider, useCmsContext, useCmsOptional, useSubmit, useSubscription, useSubscriptionContext };