@seriphxyz/solid 0.1.7 → 0.1.10
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 +165 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +224 -14
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -30,10 +30,14 @@
|
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
import { type Accessor } from "solid-js";
|
|
33
|
-
import { type SeriphConfig, type Comment, type ControllerStatus } from "@seriphxyz/core";
|
|
34
|
-
export type { SeriphConfig, SubscribeState, FormState, ReactionsState, CommentsState, Comment, ReactionCounts, SeriphPost, FetchPostsOptions, FetchPostOptions, ControllerStatus, } from "@seriphxyz/core";
|
|
35
|
-
export { fetchPosts, fetchPost, DEFAULT_ENDPOINT, API_PATH, } from "@seriphxyz/core";
|
|
36
|
-
|
|
33
|
+
import { type SeriphConfig, type Comment, type Announcement, type PollWithResults, type FeedbackType, type ControllerStatus } from "@seriphxyz/core";
|
|
34
|
+
export type { SeriphConfig, SubscribeState, FormState, ReactionsState, CommentsState, WaitlistState, ViewCountsState, FeedbackState, PollState, AnnouncementsState, Comment, Announcement, PollWithResults, FeedbackType, ReactionCounts, SeriphPost, FetchPostsOptions, FetchPostOptions, ControllerStatus, } from "@seriphxyz/core";
|
|
35
|
+
export { fetchPosts, fetchPost, getConfigFromMeta, resolveConfig, DEFAULT_ENDPOINT, API_PATH, } from "@seriphxyz/core";
|
|
36
|
+
type OptionalSiteKey<T extends SeriphConfig> = Omit<T, "siteKey"> & {
|
|
37
|
+
/** Site key - optional if <meta name="seriph-site-key"> is set */
|
|
38
|
+
siteKey?: string;
|
|
39
|
+
};
|
|
40
|
+
export interface CreateSubscribeOptions extends OptionalSiteKey<SeriphConfig> {
|
|
37
41
|
}
|
|
38
42
|
export interface CreateSubscribeReturn {
|
|
39
43
|
status: Accessor<ControllerStatus>;
|
|
@@ -47,15 +51,16 @@ export interface CreateSubscribeReturn {
|
|
|
47
51
|
*
|
|
48
52
|
* @example
|
|
49
53
|
* ```tsx
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* });
|
|
54
|
+
* // With explicit siteKey:
|
|
55
|
+
* const { subscribe, status } = createSubscribe({ siteKey: 'your-key' });
|
|
53
56
|
*
|
|
54
|
-
*
|
|
57
|
+
* // Or with meta tag (add to document head):
|
|
58
|
+
* // <meta name="seriph-site-key" content="your-key" />
|
|
59
|
+
* const { subscribe, status } = createSubscribe({});
|
|
55
60
|
* ```
|
|
56
61
|
*/
|
|
57
62
|
export declare function createSubscribe(options: CreateSubscribeOptions): CreateSubscribeReturn;
|
|
58
|
-
export interface CreateFormOptions extends SeriphConfig {
|
|
63
|
+
export interface CreateFormOptions extends OptionalSiteKey<SeriphConfig> {
|
|
59
64
|
/** Form slug/identifier */
|
|
60
65
|
formSlug: string;
|
|
61
66
|
}
|
|
@@ -72,7 +77,7 @@ export interface CreateFormReturn {
|
|
|
72
77
|
* @example
|
|
73
78
|
* ```tsx
|
|
74
79
|
* const { submit, status, error } = createForm({
|
|
75
|
-
* siteKey: 'your-site-key',
|
|
80
|
+
* siteKey: 'your-site-key', // optional with meta tag
|
|
76
81
|
* formSlug: 'contact',
|
|
77
82
|
* });
|
|
78
83
|
*
|
|
@@ -84,7 +89,7 @@ export interface CreateFormReturn {
|
|
|
84
89
|
* ```
|
|
85
90
|
*/
|
|
86
91
|
export declare function createForm(options: CreateFormOptions): CreateFormReturn;
|
|
87
|
-
export interface CreateReactionsOptions extends SeriphConfig {
|
|
92
|
+
export interface CreateReactionsOptions extends OptionalSiteKey<SeriphConfig> {
|
|
88
93
|
/** Content identifier (e.g., post slug) */
|
|
89
94
|
contentId: string;
|
|
90
95
|
/** Auto-fetch reactions on mount (default: true) */
|
|
@@ -105,7 +110,6 @@ export interface CreateReactionsReturn {
|
|
|
105
110
|
* @example
|
|
106
111
|
* ```tsx
|
|
107
112
|
* const { counts, userReactions, addReaction, removeReaction } = createReactions({
|
|
108
|
-
* siteKey: 'your-site-key',
|
|
109
113
|
* contentId: 'my-post-slug',
|
|
110
114
|
* });
|
|
111
115
|
*
|
|
@@ -115,7 +119,7 @@ export interface CreateReactionsReturn {
|
|
|
115
119
|
* ```
|
|
116
120
|
*/
|
|
117
121
|
export declare function createReactions(options: CreateReactionsOptions): CreateReactionsReturn;
|
|
118
|
-
export interface CreateCommentsOptions extends SeriphConfig {
|
|
122
|
+
export interface CreateCommentsOptions extends OptionalSiteKey<SeriphConfig> {
|
|
119
123
|
/** Content identifier (e.g., post slug) */
|
|
120
124
|
contentId: string;
|
|
121
125
|
/** Auto-fetch comments on mount (default: true) */
|
|
@@ -137,7 +141,6 @@ export interface CreateCommentsReturn {
|
|
|
137
141
|
* @example
|
|
138
142
|
* ```tsx
|
|
139
143
|
* const { comments, status, postComment } = createComments({
|
|
140
|
-
* siteKey: 'your-site-key',
|
|
141
144
|
* contentId: 'my-post-slug',
|
|
142
145
|
* });
|
|
143
146
|
*
|
|
@@ -155,4 +158,152 @@ export interface CreateCommentsReturn {
|
|
|
155
158
|
* ```
|
|
156
159
|
*/
|
|
157
160
|
export declare function createComments(options: CreateCommentsOptions): CreateCommentsReturn;
|
|
161
|
+
export interface CreateWaitlistOptions extends OptionalSiteKey<SeriphConfig> {
|
|
162
|
+
}
|
|
163
|
+
export interface CreateWaitlistReturn {
|
|
164
|
+
status: Accessor<ControllerStatus>;
|
|
165
|
+
message: Accessor<string | null>;
|
|
166
|
+
position: Accessor<number | null>;
|
|
167
|
+
error: Accessor<Error | null>;
|
|
168
|
+
join: (email: string, options?: {
|
|
169
|
+
name?: string;
|
|
170
|
+
source?: string;
|
|
171
|
+
}) => Promise<void>;
|
|
172
|
+
reset: () => void;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Primitive for handling waitlist signups.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```tsx
|
|
179
|
+
* const { join, status, position } = createWaitlist({});
|
|
180
|
+
*
|
|
181
|
+
* <button onClick={() => join('user@example.com')}>Join Waitlist</button>
|
|
182
|
+
* {status() === 'success' && <p>You're #{position()} on the list!</p>}
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
export declare function createWaitlist(options: CreateWaitlistOptions): CreateWaitlistReturn;
|
|
186
|
+
export interface CreateViewsOptions extends OptionalSiteKey<SeriphConfig> {
|
|
187
|
+
/** Page identifier (e.g., slug or URL path) */
|
|
188
|
+
pageId: string;
|
|
189
|
+
/** Auto-record view on mount (default: true) */
|
|
190
|
+
autoRecord?: boolean;
|
|
191
|
+
}
|
|
192
|
+
export interface CreateViewsReturn {
|
|
193
|
+
views: Accessor<number>;
|
|
194
|
+
uniqueVisitors: Accessor<number>;
|
|
195
|
+
status: Accessor<ControllerStatus>;
|
|
196
|
+
error: Accessor<Error | null>;
|
|
197
|
+
record: () => Promise<void>;
|
|
198
|
+
refresh: () => Promise<void>;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Primitive for tracking and displaying page views.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```tsx
|
|
205
|
+
* const { views, uniqueVisitors } = createViews({
|
|
206
|
+
* pageId: '/blog/my-post',
|
|
207
|
+
* });
|
|
208
|
+
*
|
|
209
|
+
* <span>{views()} views ({uniqueVisitors()} unique)</span>
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
export declare function createViews(options: CreateViewsOptions): CreateViewsReturn;
|
|
213
|
+
export interface CreateFeedbackOptions extends OptionalSiteKey<SeriphConfig> {
|
|
214
|
+
}
|
|
215
|
+
export interface CreateFeedbackReturn {
|
|
216
|
+
status: Accessor<ControllerStatus>;
|
|
217
|
+
message: Accessor<string | null>;
|
|
218
|
+
error: Accessor<Error | null>;
|
|
219
|
+
submit: (type: FeedbackType, content: string, options?: {
|
|
220
|
+
email?: string;
|
|
221
|
+
pageUrl?: string;
|
|
222
|
+
}) => Promise<void>;
|
|
223
|
+
reset: () => void;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Primitive for handling feedback submissions.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```tsx
|
|
230
|
+
* const { submit, status } = createFeedback({});
|
|
231
|
+
*
|
|
232
|
+
* <button onClick={() => submit('feature', 'Add dark mode!')}>
|
|
233
|
+
* Submit Feedback
|
|
234
|
+
* </button>
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
export declare function createFeedback(options: CreateFeedbackOptions): CreateFeedbackReturn;
|
|
238
|
+
export interface CreatePollOptions extends OptionalSiteKey<SeriphConfig> {
|
|
239
|
+
/** Poll slug */
|
|
240
|
+
slug: string;
|
|
241
|
+
/** Auto-fetch poll on mount (default: true) */
|
|
242
|
+
autoFetch?: boolean;
|
|
243
|
+
}
|
|
244
|
+
export interface CreatePollReturn {
|
|
245
|
+
poll: Accessor<PollWithResults | null>;
|
|
246
|
+
status: Accessor<ControllerStatus>;
|
|
247
|
+
error: Accessor<Error | null>;
|
|
248
|
+
vote: (selectedOptions: string[]) => Promise<void>;
|
|
249
|
+
hasVoted: Accessor<boolean>;
|
|
250
|
+
refresh: () => Promise<void>;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Primitive for displaying and voting on polls.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```tsx
|
|
257
|
+
* // With meta tag: <meta name="seriph-site-key" content="your-key" />
|
|
258
|
+
* const { poll, vote, hasVoted } = createPoll({ slug: 'favorite-framework' });
|
|
259
|
+
*
|
|
260
|
+
* <Show when={poll()}>
|
|
261
|
+
* {(p) => (
|
|
262
|
+
* <div>
|
|
263
|
+
* <h3>{p().question}</h3>
|
|
264
|
+
* <For each={p().options}>
|
|
265
|
+
* {(opt) => (
|
|
266
|
+
* <button onClick={() => vote([opt.id])} disabled={hasVoted()}>
|
|
267
|
+
* {opt.text} ({p().results[opt.id] || 0} votes)
|
|
268
|
+
* </button>
|
|
269
|
+
* )}
|
|
270
|
+
* </For>
|
|
271
|
+
* </div>
|
|
272
|
+
* )}
|
|
273
|
+
* </Show>
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
export declare function createPoll(options: CreatePollOptions): CreatePollReturn;
|
|
277
|
+
export interface CreateAnnouncementsOptions extends OptionalSiteKey<SeriphConfig> {
|
|
278
|
+
/** Auto-fetch announcements on mount (default: true) */
|
|
279
|
+
autoFetch?: boolean;
|
|
280
|
+
}
|
|
281
|
+
export interface CreateAnnouncementsReturn {
|
|
282
|
+
announcements: Accessor<Announcement[]>;
|
|
283
|
+
status: Accessor<ControllerStatus>;
|
|
284
|
+
error: Accessor<Error | null>;
|
|
285
|
+
dismiss: (announcementId: number) => Promise<void>;
|
|
286
|
+
refresh: () => Promise<void>;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Primitive for displaying site announcements.
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```tsx
|
|
293
|
+
* // With meta tag: <meta name="seriph-site-key" content="your-key" />
|
|
294
|
+
* const { announcements, dismiss } = createAnnouncements({});
|
|
295
|
+
*
|
|
296
|
+
* <For each={announcements()}>
|
|
297
|
+
* {(ann) => (
|
|
298
|
+
* <div class={`announcement-${ann.announcementType}`}>
|
|
299
|
+
* {ann.content}
|
|
300
|
+
* {ann.isDismissible && (
|
|
301
|
+
* <button onClick={() => dismiss(ann.id)}>Dismiss</button>
|
|
302
|
+
* )}
|
|
303
|
+
* </div>
|
|
304
|
+
* )}
|
|
305
|
+
* </For>
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
export declare function createAnnouncements(options: CreateAnnouncementsOptions): CreateAnnouncementsReturn;
|
|
158
309
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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aAAa,EAAE,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC;IACxC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IACnC,KAAK,EAAE,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IAC9B,OAAO,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,yBAAyB,CAiClG"}
|
package/dist/index.js
CHANGED
|
@@ -30,26 +30,28 @@
|
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
import { createSignal, createEffect, onCleanup } from "solid-js";
|
|
33
|
-
import { SubscribeController, FormController, ReactionsController, CommentsController, } from "@seriphxyz/core";
|
|
34
|
-
// Re-export API functions from core
|
|
35
|
-
export { fetchPosts, fetchPost, DEFAULT_ENDPOINT, API_PATH, } from "@seriphxyz/core";
|
|
33
|
+
import { SubscribeController, FormController, ReactionsController, CommentsController, WaitlistController, ViewCountsController, FeedbackController, PollController, AnnouncementsController, resolveConfig, } from "@seriphxyz/core";
|
|
34
|
+
// Re-export API functions and helpers from core
|
|
35
|
+
export { fetchPosts, fetchPost, getConfigFromMeta, resolveConfig, DEFAULT_ENDPOINT, API_PATH, } from "@seriphxyz/core";
|
|
36
36
|
/**
|
|
37
37
|
* Primitive for handling email subscriptions.
|
|
38
38
|
*
|
|
39
39
|
* @example
|
|
40
40
|
* ```tsx
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* });
|
|
41
|
+
* // With explicit siteKey:
|
|
42
|
+
* const { subscribe, status } = createSubscribe({ siteKey: 'your-key' });
|
|
44
43
|
*
|
|
45
|
-
*
|
|
44
|
+
* // Or with meta tag (add to document head):
|
|
45
|
+
* // <meta name="seriph-site-key" content="your-key" />
|
|
46
|
+
* const { subscribe, status } = createSubscribe({});
|
|
46
47
|
* ```
|
|
47
48
|
*/
|
|
48
49
|
export function createSubscribe(options) {
|
|
49
50
|
const [status, setStatus] = createSignal("idle");
|
|
50
51
|
const [message, setMessage] = createSignal(null);
|
|
51
52
|
const [error, setError] = createSignal(null);
|
|
52
|
-
const
|
|
53
|
+
const config = resolveConfig(options);
|
|
54
|
+
const controller = new SubscribeController(config);
|
|
53
55
|
createEffect(() => {
|
|
54
56
|
const unsubscribe = controller.subscribe((state) => {
|
|
55
57
|
setStatus(state.status);
|
|
@@ -72,7 +74,7 @@ export function createSubscribe(options) {
|
|
|
72
74
|
* @example
|
|
73
75
|
* ```tsx
|
|
74
76
|
* const { submit, status, error } = createForm({
|
|
75
|
-
* siteKey: 'your-site-key',
|
|
77
|
+
* siteKey: 'your-site-key', // optional with meta tag
|
|
76
78
|
* formSlug: 'contact',
|
|
77
79
|
* });
|
|
78
80
|
*
|
|
@@ -87,7 +89,8 @@ export function createForm(options) {
|
|
|
87
89
|
const [status, setStatus] = createSignal("idle");
|
|
88
90
|
const [message, setMessage] = createSignal(null);
|
|
89
91
|
const [error, setError] = createSignal(null);
|
|
90
|
-
const
|
|
92
|
+
const config = resolveConfig(options);
|
|
93
|
+
const controller = new FormController(config, options.formSlug);
|
|
91
94
|
createEffect(() => {
|
|
92
95
|
const unsubscribe = controller.subscribe((state) => {
|
|
93
96
|
setStatus(state.status);
|
|
@@ -110,7 +113,6 @@ export function createForm(options) {
|
|
|
110
113
|
* @example
|
|
111
114
|
* ```tsx
|
|
112
115
|
* const { counts, userReactions, addReaction, removeReaction } = createReactions({
|
|
113
|
-
* siteKey: 'your-site-key',
|
|
114
116
|
* contentId: 'my-post-slug',
|
|
115
117
|
* });
|
|
116
118
|
*
|
|
@@ -124,7 +126,8 @@ export function createReactions(options) {
|
|
|
124
126
|
const [userReactions, setUserReactions] = createSignal([]);
|
|
125
127
|
const [status, setStatus] = createSignal("idle");
|
|
126
128
|
const [error, setError] = createSignal(null);
|
|
127
|
-
const
|
|
129
|
+
const config = resolveConfig(options);
|
|
130
|
+
const controller = new ReactionsController(config, options.contentId);
|
|
128
131
|
createEffect(() => {
|
|
129
132
|
const unsubscribe = controller.subscribe((state) => {
|
|
130
133
|
setCounts(state.counts);
|
|
@@ -155,7 +158,6 @@ export function createReactions(options) {
|
|
|
155
158
|
* @example
|
|
156
159
|
* ```tsx
|
|
157
160
|
* const { comments, status, postComment } = createComments({
|
|
158
|
-
* siteKey: 'your-site-key',
|
|
159
161
|
* contentId: 'my-post-slug',
|
|
160
162
|
* });
|
|
161
163
|
*
|
|
@@ -176,7 +178,8 @@ export function createComments(options) {
|
|
|
176
178
|
const [comments, setComments] = createSignal([]);
|
|
177
179
|
const [status, setStatus] = createSignal("idle");
|
|
178
180
|
const [error, setError] = createSignal(null);
|
|
179
|
-
const
|
|
181
|
+
const config = resolveConfig(options);
|
|
182
|
+
const controller = new CommentsController(config, options.contentId);
|
|
180
183
|
createEffect(() => {
|
|
181
184
|
const unsubscribe = controller.subscribe((state) => {
|
|
182
185
|
setComments(state.comments);
|
|
@@ -197,3 +200,210 @@ export function createComments(options) {
|
|
|
197
200
|
};
|
|
198
201
|
return { comments, status, error, postComment, refresh };
|
|
199
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Primitive for handling waitlist signups.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```tsx
|
|
208
|
+
* const { join, status, position } = createWaitlist({});
|
|
209
|
+
*
|
|
210
|
+
* <button onClick={() => join('user@example.com')}>Join Waitlist</button>
|
|
211
|
+
* {status() === 'success' && <p>You're #{position()} on the list!</p>}
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
export function createWaitlist(options) {
|
|
215
|
+
const [status, setStatus] = createSignal("idle");
|
|
216
|
+
const [message, setMessage] = createSignal(null);
|
|
217
|
+
const [position, setPosition] = createSignal(null);
|
|
218
|
+
const [error, setError] = createSignal(null);
|
|
219
|
+
const config = resolveConfig(options);
|
|
220
|
+
const controller = new WaitlistController(config);
|
|
221
|
+
createEffect(() => {
|
|
222
|
+
const unsubscribe = controller.subscribe((state) => {
|
|
223
|
+
setStatus(state.status);
|
|
224
|
+
setMessage(state.message);
|
|
225
|
+
setPosition(state.position);
|
|
226
|
+
setError(state.error);
|
|
227
|
+
});
|
|
228
|
+
onCleanup(unsubscribe);
|
|
229
|
+
});
|
|
230
|
+
const join = async (email, opts) => {
|
|
231
|
+
await controller.join(email, opts);
|
|
232
|
+
};
|
|
233
|
+
const reset = () => {
|
|
234
|
+
controller.reset();
|
|
235
|
+
};
|
|
236
|
+
return { status, message, position, error, join, reset };
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Primitive for tracking and displaying page views.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```tsx
|
|
243
|
+
* const { views, uniqueVisitors } = createViews({
|
|
244
|
+
* pageId: '/blog/my-post',
|
|
245
|
+
* });
|
|
246
|
+
*
|
|
247
|
+
* <span>{views()} views ({uniqueVisitors()} unique)</span>
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
export function createViews(options) {
|
|
251
|
+
const [views, setViews] = createSignal(0);
|
|
252
|
+
const [uniqueVisitors, setUniqueVisitors] = createSignal(0);
|
|
253
|
+
const [status, setStatus] = createSignal("idle");
|
|
254
|
+
const [error, setError] = createSignal(null);
|
|
255
|
+
const config = resolveConfig(options);
|
|
256
|
+
const controller = new ViewCountsController(config, options.pageId);
|
|
257
|
+
createEffect(() => {
|
|
258
|
+
const unsubscribe = controller.subscribe((state) => {
|
|
259
|
+
setViews(state.views);
|
|
260
|
+
setUniqueVisitors(state.uniqueVisitors);
|
|
261
|
+
setStatus(state.status);
|
|
262
|
+
setError(state.error);
|
|
263
|
+
});
|
|
264
|
+
// Auto-record view on mount (default: true)
|
|
265
|
+
if (options.autoRecord !== false) {
|
|
266
|
+
controller.record();
|
|
267
|
+
}
|
|
268
|
+
onCleanup(unsubscribe);
|
|
269
|
+
});
|
|
270
|
+
const record = async () => {
|
|
271
|
+
await controller.record();
|
|
272
|
+
};
|
|
273
|
+
const refresh = async () => {
|
|
274
|
+
await controller.fetch();
|
|
275
|
+
};
|
|
276
|
+
return { views, uniqueVisitors, status, error, record, refresh };
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Primitive for handling feedback submissions.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```tsx
|
|
283
|
+
* const { submit, status } = createFeedback({});
|
|
284
|
+
*
|
|
285
|
+
* <button onClick={() => submit('feature', 'Add dark mode!')}>
|
|
286
|
+
* Submit Feedback
|
|
287
|
+
* </button>
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
export function createFeedback(options) {
|
|
291
|
+
const [status, setStatus] = createSignal("idle");
|
|
292
|
+
const [message, setMessage] = createSignal(null);
|
|
293
|
+
const [error, setError] = createSignal(null);
|
|
294
|
+
const config = resolveConfig(options);
|
|
295
|
+
const controller = new FeedbackController(config);
|
|
296
|
+
createEffect(() => {
|
|
297
|
+
const unsubscribe = controller.subscribe((state) => {
|
|
298
|
+
setStatus(state.status);
|
|
299
|
+
setMessage(state.message);
|
|
300
|
+
setError(state.error);
|
|
301
|
+
});
|
|
302
|
+
onCleanup(unsubscribe);
|
|
303
|
+
});
|
|
304
|
+
const submit = async (type, content, opts) => {
|
|
305
|
+
await controller.submit(type, content, opts);
|
|
306
|
+
};
|
|
307
|
+
const reset = () => {
|
|
308
|
+
controller.reset();
|
|
309
|
+
};
|
|
310
|
+
return { status, message, error, submit, reset };
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Primitive for displaying and voting on polls.
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```tsx
|
|
317
|
+
* // With meta tag: <meta name="seriph-site-key" content="your-key" />
|
|
318
|
+
* const { poll, vote, hasVoted } = createPoll({ slug: 'favorite-framework' });
|
|
319
|
+
*
|
|
320
|
+
* <Show when={poll()}>
|
|
321
|
+
* {(p) => (
|
|
322
|
+
* <div>
|
|
323
|
+
* <h3>{p().question}</h3>
|
|
324
|
+
* <For each={p().options}>
|
|
325
|
+
* {(opt) => (
|
|
326
|
+
* <button onClick={() => vote([opt.id])} disabled={hasVoted()}>
|
|
327
|
+
* {opt.text} ({p().results[opt.id] || 0} votes)
|
|
328
|
+
* </button>
|
|
329
|
+
* )}
|
|
330
|
+
* </For>
|
|
331
|
+
* </div>
|
|
332
|
+
* )}
|
|
333
|
+
* </Show>
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
export function createPoll(options) {
|
|
337
|
+
const [poll, setPoll] = createSignal(null);
|
|
338
|
+
const [status, setStatus] = createSignal("idle");
|
|
339
|
+
const [error, setError] = createSignal(null);
|
|
340
|
+
const config = resolveConfig(options);
|
|
341
|
+
const controller = new PollController(config, options.slug);
|
|
342
|
+
createEffect(() => {
|
|
343
|
+
const unsubscribe = controller.subscribe((state) => {
|
|
344
|
+
setPoll(state.poll);
|
|
345
|
+
setStatus(state.status);
|
|
346
|
+
setError(state.error);
|
|
347
|
+
});
|
|
348
|
+
// Auto-fetch on mount (default: true)
|
|
349
|
+
if (options.autoFetch !== false) {
|
|
350
|
+
controller.fetch();
|
|
351
|
+
}
|
|
352
|
+
onCleanup(unsubscribe);
|
|
353
|
+
});
|
|
354
|
+
const vote = async (selectedOptions) => {
|
|
355
|
+
await controller.vote(selectedOptions);
|
|
356
|
+
};
|
|
357
|
+
const refresh = async () => {
|
|
358
|
+
await controller.fetch();
|
|
359
|
+
};
|
|
360
|
+
const hasVoted = () => controller.hasVoted();
|
|
361
|
+
return { poll, status, error, vote, hasVoted, refresh };
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Primitive for displaying site announcements.
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```tsx
|
|
368
|
+
* // With meta tag: <meta name="seriph-site-key" content="your-key" />
|
|
369
|
+
* const { announcements, dismiss } = createAnnouncements({});
|
|
370
|
+
*
|
|
371
|
+
* <For each={announcements()}>
|
|
372
|
+
* {(ann) => (
|
|
373
|
+
* <div class={`announcement-${ann.announcementType}`}>
|
|
374
|
+
* {ann.content}
|
|
375
|
+
* {ann.isDismissible && (
|
|
376
|
+
* <button onClick={() => dismiss(ann.id)}>Dismiss</button>
|
|
377
|
+
* )}
|
|
378
|
+
* </div>
|
|
379
|
+
* )}
|
|
380
|
+
* </For>
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
export function createAnnouncements(options) {
|
|
384
|
+
const [announcements, setAnnouncements] = createSignal([]);
|
|
385
|
+
const [status, setStatus] = createSignal("idle");
|
|
386
|
+
const [error, setError] = createSignal(null);
|
|
387
|
+
const config = resolveConfig(options);
|
|
388
|
+
const controller = new AnnouncementsController(config);
|
|
389
|
+
createEffect(() => {
|
|
390
|
+
const unsubscribe = controller.subscribe((state) => {
|
|
391
|
+
// Only show non-dismissed announcements
|
|
392
|
+
setAnnouncements(controller.getVisibleAnnouncements());
|
|
393
|
+
setStatus(state.status);
|
|
394
|
+
setError(state.error);
|
|
395
|
+
});
|
|
396
|
+
// Auto-fetch on mount (default: true)
|
|
397
|
+
if (options.autoFetch !== false) {
|
|
398
|
+
controller.fetch();
|
|
399
|
+
}
|
|
400
|
+
onCleanup(unsubscribe);
|
|
401
|
+
});
|
|
402
|
+
const dismiss = async (announcementId) => {
|
|
403
|
+
await controller.dismiss(announcementId);
|
|
404
|
+
};
|
|
405
|
+
const refresh = async () => {
|
|
406
|
+
await controller.fetch();
|
|
407
|
+
};
|
|
408
|
+
return { announcements, status, error, dismiss, refresh };
|
|
409
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seriphxyz/solid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "SolidJS primitives for Seriph widgets (forms, comments, reactions, subscriptions)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
],
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@seriphxyz/core": "0.1.
|
|
35
|
+
"@seriphxyz/core": "0.1.10"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"solid-js": "^1.8.0"
|