@basestack/flags-wc 0.0.1

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.
@@ -0,0 +1,472 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ /**
4
+ * This is an autogenerated file created by the Stencil compiler.
5
+ * It contains typing information for all components that exist in this project.
6
+ */
7
+ import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
8
+ import { FeedbackPayload } from "./components/feature-flag-feedback-modal/feature-flag-feedback-modal";
9
+ import { FlagSelectionPayload } from "./lib/feature-flags";
10
+ export { FeedbackPayload } from "./components/feature-flag-feedback-modal/feature-flag-feedback-modal";
11
+ export { FlagSelectionPayload } from "./lib/feature-flags";
12
+ export namespace Components {
13
+ interface FeatureFlagFeedbackModal {
14
+ /**
15
+ * Endpoint used to POST feedback. Defaults to the Basestack feedback API.
16
+ * @default DEFAULT_FEEDBACK_ENDPOINT
17
+ */
18
+ "apiEndpoint": string;
19
+ /**
20
+ * Label for the close controls.
21
+ * @default "Close"
22
+ */
23
+ "closeLabel": string;
24
+ /**
25
+ * Environment key header (x-environment-key).
26
+ */
27
+ "environmentKey"?: string;
28
+ /**
29
+ * Human-friendly name of the feature to display in the UI.
30
+ */
31
+ "featureName"?: string;
32
+ /**
33
+ * Label above the textarea input.
34
+ * @default "Share your feedback"
35
+ */
36
+ "feedbackLabel": string;
37
+ /**
38
+ * Placeholder text inside the textarea input.
39
+ * @default "Anything else you’d like to add?"
40
+ */
41
+ "feedbackPlaceholder": string;
42
+ /**
43
+ * The Basestack flag key this feedback is for.
44
+ */
45
+ "flagKey": string;
46
+ /**
47
+ * Dialog heading text.
48
+ * @default "Feedback"
49
+ */
50
+ "heading": string;
51
+ /**
52
+ * Label above the mood selector.
53
+ * @default "How are you feeling after using this feature?"
54
+ */
55
+ "moodPrompt": string;
56
+ /**
57
+ * Controls dialog visibility.
58
+ * @default false
59
+ */
60
+ "open": boolean;
61
+ /**
62
+ * @default "To keep your data safe, avoid sharing personal or sensitive details."
63
+ */
64
+ "privacyPolicyLabel": string;
65
+ /**
66
+ * @default "Learn more"
67
+ */
68
+ "privacyPolicyLinkLabel": string;
69
+ /**
70
+ * @default "https://basestack.co/legal/privacy"
71
+ */
72
+ "privacyPolicyUrl": string;
73
+ /**
74
+ * Project key header (x-project-key).
75
+ */
76
+ "projectKey"?: string;
77
+ /**
78
+ * Label above the rating selector.
79
+ * @default "How satisfied are you with this feature?"
80
+ */
81
+ "ratingPrompt": string;
82
+ /**
83
+ * Label for the submit button.
84
+ * @default "Submit feedback"
85
+ */
86
+ "submitLabel": string;
87
+ /**
88
+ * @default "light"
89
+ */
90
+ "theme": "light" | "dark";
91
+ }
92
+ interface FeatureFlagPreviewModal {
93
+ /**
94
+ * Endpoint used to fetch feature flags. If omitted, defaults to the Basestack preview API.
95
+ * @default DEFAULT_FLAGS_ENDPOINT
96
+ */
97
+ "apiEndpoint": string;
98
+ /**
99
+ * Label for the close button and overlay.
100
+ * @default "Close"
101
+ */
102
+ "closeLabel": string;
103
+ /**
104
+ * Label shown when no previews are available.
105
+ * @default "No feature flags available at the moment."
106
+ */
107
+ "emptyLabel": string;
108
+ /**
109
+ * Label for the primary enable button when a flag is disabled.
110
+ * @default "Enable"
111
+ */
112
+ "enableLabel": string;
113
+ /**
114
+ * Label for the primary enable button when a flag is enabled.
115
+ * @default "Disable"
116
+ */
117
+ "enabledLabel": string;
118
+ /**
119
+ * Environment key header (x-environment-key).
120
+ */
121
+ "environmentKey"?: string;
122
+ /**
123
+ * Label for the expiration badge.
124
+ * @default "Expires soon"
125
+ */
126
+ "expiresSoonLabel": string;
127
+ /**
128
+ * Dialog title.
129
+ * @default "Feature preview"
130
+ */
131
+ "heading": string;
132
+ /**
133
+ * Label for the documentation link.
134
+ * @default "Learn more"
135
+ */
136
+ "learnMoreLabel": string;
137
+ /**
138
+ * Label shown when loading previews.
139
+ * @default "Loading features…"
140
+ */
141
+ "loadingLabel": string;
142
+ /**
143
+ * Controls dialog visibility.
144
+ * @default false
145
+ */
146
+ "open": boolean;
147
+ /**
148
+ * Label for the preview badge.
149
+ * @default "Preview"
150
+ */
151
+ "previewBadgeLabel": string;
152
+ /**
153
+ * Project key header (x-project-key).
154
+ */
155
+ "projectKey"?: string;
156
+ /**
157
+ * Placeholder text shown in the details panel when nothing is selected.
158
+ * @default "Select a feature on the left to see its details."
159
+ */
160
+ "selectionPlaceholder": string;
161
+ /**
162
+ * Title shown when nothing is selected.
163
+ * @default "Choose a feature to view"
164
+ */
165
+ "selectionPrompt": string;
166
+ /**
167
+ * When true, renders the close button.
168
+ * @default true
169
+ */
170
+ "showCloseButton": boolean;
171
+ /**
172
+ * Local storage key used to persist enabled flags.
173
+ * @default DEFAULT_STORAGE_KEY
174
+ */
175
+ "storageKey": string;
176
+ /**
177
+ * Optional supporting copy under the title.
178
+ * @default "Get early access to new features and let us know what you think."
179
+ */
180
+ "subtitle": string;
181
+ /**
182
+ * @default "light"
183
+ */
184
+ "theme": "light" | "dark";
185
+ }
186
+ }
187
+ export interface FeatureFlagFeedbackModalCustomEvent<T> extends CustomEvent<T> {
188
+ detail: T;
189
+ target: HTMLFeatureFlagFeedbackModalElement;
190
+ }
191
+ export interface FeatureFlagPreviewModalCustomEvent<T> extends CustomEvent<T> {
192
+ detail: T;
193
+ target: HTMLFeatureFlagPreviewModalElement;
194
+ }
195
+ declare global {
196
+ interface HTMLFeatureFlagFeedbackModalElementEventMap {
197
+ "feedbackSent": FeedbackPayload;
198
+ "closed": void;
199
+ }
200
+ interface HTMLFeatureFlagFeedbackModalElement extends Components.FeatureFlagFeedbackModal, HTMLStencilElement {
201
+ addEventListener<K extends keyof HTMLFeatureFlagFeedbackModalElementEventMap>(type: K, listener: (this: HTMLFeatureFlagFeedbackModalElement, ev: FeatureFlagFeedbackModalCustomEvent<HTMLFeatureFlagFeedbackModalElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
202
+ addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
203
+ addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
204
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
205
+ removeEventListener<K extends keyof HTMLFeatureFlagFeedbackModalElementEventMap>(type: K, listener: (this: HTMLFeatureFlagFeedbackModalElement, ev: FeatureFlagFeedbackModalCustomEvent<HTMLFeatureFlagFeedbackModalElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
206
+ removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
207
+ removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
208
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
209
+ }
210
+ var HTMLFeatureFlagFeedbackModalElement: {
211
+ prototype: HTMLFeatureFlagFeedbackModalElement;
212
+ new (): HTMLFeatureFlagFeedbackModalElement;
213
+ };
214
+ interface HTMLFeatureFlagPreviewModalElementEventMap {
215
+ "flagChange": FlagSelectionPayload;
216
+ "closed": void;
217
+ }
218
+ interface HTMLFeatureFlagPreviewModalElement extends Components.FeatureFlagPreviewModal, HTMLStencilElement {
219
+ addEventListener<K extends keyof HTMLFeatureFlagPreviewModalElementEventMap>(type: K, listener: (this: HTMLFeatureFlagPreviewModalElement, ev: FeatureFlagPreviewModalCustomEvent<HTMLFeatureFlagPreviewModalElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
220
+ addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
221
+ addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
222
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
223
+ removeEventListener<K extends keyof HTMLFeatureFlagPreviewModalElementEventMap>(type: K, listener: (this: HTMLFeatureFlagPreviewModalElement, ev: FeatureFlagPreviewModalCustomEvent<HTMLFeatureFlagPreviewModalElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
224
+ removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
225
+ removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
226
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
227
+ }
228
+ var HTMLFeatureFlagPreviewModalElement: {
229
+ prototype: HTMLFeatureFlagPreviewModalElement;
230
+ new (): HTMLFeatureFlagPreviewModalElement;
231
+ };
232
+ interface HTMLElementTagNameMap {
233
+ "feature-flag-feedback-modal": HTMLFeatureFlagFeedbackModalElement;
234
+ "feature-flag-preview-modal": HTMLFeatureFlagPreviewModalElement;
235
+ }
236
+ }
237
+ declare namespace LocalJSX {
238
+ type OneOf<K extends string, PropT, AttrT = PropT> = { [P in K]: PropT } & { [P in `attr:${K}` | `prop:${K}`]?: never } | { [P in `attr:${K}`]: AttrT } & { [P in K | `prop:${K}`]?: never } | { [P in `prop:${K}`]: PropT } & { [P in K | `attr:${K}`]?: never };
239
+
240
+ interface FeatureFlagFeedbackModal {
241
+ /**
242
+ * Endpoint used to POST feedback. Defaults to the Basestack feedback API.
243
+ * @default DEFAULT_FEEDBACK_ENDPOINT
244
+ */
245
+ "apiEndpoint"?: string;
246
+ /**
247
+ * Label for the close controls.
248
+ * @default "Close"
249
+ */
250
+ "closeLabel"?: string;
251
+ /**
252
+ * Environment key header (x-environment-key).
253
+ */
254
+ "environmentKey"?: string;
255
+ /**
256
+ * Human-friendly name of the feature to display in the UI.
257
+ */
258
+ "featureName"?: string;
259
+ /**
260
+ * Label above the textarea input.
261
+ * @default "Share your feedback"
262
+ */
263
+ "feedbackLabel"?: string;
264
+ /**
265
+ * Placeholder text inside the textarea input.
266
+ * @default "Anything else you’d like to add?"
267
+ */
268
+ "feedbackPlaceholder"?: string;
269
+ /**
270
+ * The Basestack flag key this feedback is for.
271
+ */
272
+ "flagKey": string;
273
+ /**
274
+ * Dialog heading text.
275
+ * @default "Feedback"
276
+ */
277
+ "heading"?: string;
278
+ /**
279
+ * Label above the mood selector.
280
+ * @default "How are you feeling after using this feature?"
281
+ */
282
+ "moodPrompt"?: string;
283
+ "onClosed"?: (event: FeatureFlagFeedbackModalCustomEvent<void>) => void;
284
+ "onFeedbackSent"?: (event: FeatureFlagFeedbackModalCustomEvent<FeedbackPayload>) => void;
285
+ /**
286
+ * Controls dialog visibility.
287
+ * @default false
288
+ */
289
+ "open"?: boolean;
290
+ /**
291
+ * @default "To keep your data safe, avoid sharing personal or sensitive details."
292
+ */
293
+ "privacyPolicyLabel"?: string;
294
+ /**
295
+ * @default "Learn more"
296
+ */
297
+ "privacyPolicyLinkLabel"?: string;
298
+ /**
299
+ * @default "https://basestack.co/legal/privacy"
300
+ */
301
+ "privacyPolicyUrl"?: string;
302
+ /**
303
+ * Project key header (x-project-key).
304
+ */
305
+ "projectKey"?: string;
306
+ /**
307
+ * Label above the rating selector.
308
+ * @default "How satisfied are you with this feature?"
309
+ */
310
+ "ratingPrompt"?: string;
311
+ /**
312
+ * Label for the submit button.
313
+ * @default "Submit feedback"
314
+ */
315
+ "submitLabel"?: string;
316
+ /**
317
+ * @default "light"
318
+ */
319
+ "theme"?: "light" | "dark";
320
+ }
321
+ interface FeatureFlagPreviewModal {
322
+ /**
323
+ * Endpoint used to fetch feature flags. If omitted, defaults to the Basestack preview API.
324
+ * @default DEFAULT_FLAGS_ENDPOINT
325
+ */
326
+ "apiEndpoint"?: string;
327
+ /**
328
+ * Label for the close button and overlay.
329
+ * @default "Close"
330
+ */
331
+ "closeLabel"?: string;
332
+ /**
333
+ * Label shown when no previews are available.
334
+ * @default "No feature flags available at the moment."
335
+ */
336
+ "emptyLabel"?: string;
337
+ /**
338
+ * Label for the primary enable button when a flag is disabled.
339
+ * @default "Enable"
340
+ */
341
+ "enableLabel"?: string;
342
+ /**
343
+ * Label for the primary enable button when a flag is enabled.
344
+ * @default "Disable"
345
+ */
346
+ "enabledLabel"?: string;
347
+ /**
348
+ * Environment key header (x-environment-key).
349
+ */
350
+ "environmentKey"?: string;
351
+ /**
352
+ * Label for the expiration badge.
353
+ * @default "Expires soon"
354
+ */
355
+ "expiresSoonLabel"?: string;
356
+ /**
357
+ * Dialog title.
358
+ * @default "Feature preview"
359
+ */
360
+ "heading"?: string;
361
+ /**
362
+ * Label for the documentation link.
363
+ * @default "Learn more"
364
+ */
365
+ "learnMoreLabel"?: string;
366
+ /**
367
+ * Label shown when loading previews.
368
+ * @default "Loading features…"
369
+ */
370
+ "loadingLabel"?: string;
371
+ "onClosed"?: (event: FeatureFlagPreviewModalCustomEvent<void>) => void;
372
+ "onFlagChange"?: (event: FeatureFlagPreviewModalCustomEvent<FlagSelectionPayload>) => void;
373
+ /**
374
+ * Controls dialog visibility.
375
+ * @default false
376
+ */
377
+ "open"?: boolean;
378
+ /**
379
+ * Label for the preview badge.
380
+ * @default "Preview"
381
+ */
382
+ "previewBadgeLabel"?: string;
383
+ /**
384
+ * Project key header (x-project-key).
385
+ */
386
+ "projectKey"?: string;
387
+ /**
388
+ * Placeholder text shown in the details panel when nothing is selected.
389
+ * @default "Select a feature on the left to see its details."
390
+ */
391
+ "selectionPlaceholder"?: string;
392
+ /**
393
+ * Title shown when nothing is selected.
394
+ * @default "Choose a feature to view"
395
+ */
396
+ "selectionPrompt"?: string;
397
+ /**
398
+ * When true, renders the close button.
399
+ * @default true
400
+ */
401
+ "showCloseButton"?: boolean;
402
+ /**
403
+ * Local storage key used to persist enabled flags.
404
+ * @default DEFAULT_STORAGE_KEY
405
+ */
406
+ "storageKey"?: string;
407
+ /**
408
+ * Optional supporting copy under the title.
409
+ * @default "Get early access to new features and let us know what you think."
410
+ */
411
+ "subtitle"?: string;
412
+ /**
413
+ * @default "light"
414
+ */
415
+ "theme"?: "light" | "dark";
416
+ }
417
+
418
+ interface FeatureFlagFeedbackModalAttributes {
419
+ "theme": "light" | "dark";
420
+ "flagKey": string;
421
+ "featureName": string;
422
+ "projectKey": string;
423
+ "environmentKey": string;
424
+ "apiEndpoint": string;
425
+ "open": boolean;
426
+ "heading": string;
427
+ "moodPrompt": string;
428
+ "ratingPrompt": string;
429
+ "feedbackLabel": string;
430
+ "feedbackPlaceholder": string;
431
+ "submitLabel": string;
432
+ "privacyPolicyUrl": string;
433
+ "privacyPolicyLabel": string;
434
+ "privacyPolicyLinkLabel": string;
435
+ "closeLabel": string;
436
+ }
437
+ interface FeatureFlagPreviewModalAttributes {
438
+ "theme": "light" | "dark";
439
+ "apiEndpoint": string;
440
+ "projectKey": string;
441
+ "environmentKey": string;
442
+ "storageKey": string;
443
+ "open": boolean;
444
+ "heading": string;
445
+ "subtitle": string;
446
+ "closeLabel": string;
447
+ "showCloseButton": boolean;
448
+ "loadingLabel": string;
449
+ "emptyLabel": string;
450
+ "selectionPrompt": string;
451
+ "selectionPlaceholder": string;
452
+ "enableLabel": string;
453
+ "enabledLabel": string;
454
+ "previewBadgeLabel": string;
455
+ "expiresSoonLabel": string;
456
+ "learnMoreLabel": string;
457
+ }
458
+
459
+ interface IntrinsicElements {
460
+ "feature-flag-feedback-modal": Omit<FeatureFlagFeedbackModal, keyof FeatureFlagFeedbackModalAttributes> & { [K in keyof FeatureFlagFeedbackModal & keyof FeatureFlagFeedbackModalAttributes]?: FeatureFlagFeedbackModal[K] } & { [K in keyof FeatureFlagFeedbackModal & keyof FeatureFlagFeedbackModalAttributes as `attr:${K}`]?: FeatureFlagFeedbackModalAttributes[K] } & { [K in keyof FeatureFlagFeedbackModal & keyof FeatureFlagFeedbackModalAttributes as `prop:${K}`]?: FeatureFlagFeedbackModal[K] } & OneOf<"flagKey", FeatureFlagFeedbackModal["flagKey"], FeatureFlagFeedbackModalAttributes["flagKey"]>;
461
+ "feature-flag-preview-modal": Omit<FeatureFlagPreviewModal, keyof FeatureFlagPreviewModalAttributes> & { [K in keyof FeatureFlagPreviewModal & keyof FeatureFlagPreviewModalAttributes]?: FeatureFlagPreviewModal[K] } & { [K in keyof FeatureFlagPreviewModal & keyof FeatureFlagPreviewModalAttributes as `attr:${K}`]?: FeatureFlagPreviewModalAttributes[K] } & { [K in keyof FeatureFlagPreviewModal & keyof FeatureFlagPreviewModalAttributes as `prop:${K}`]?: FeatureFlagPreviewModal[K] };
462
+ }
463
+ }
464
+ export { LocalJSX as JSX };
465
+ declare module "@stencil/core" {
466
+ export namespace JSX {
467
+ interface IntrinsicElements {
468
+ "feature-flag-feedback-modal": LocalJSX.IntrinsicElements["feature-flag-feedback-modal"] & JSXBase.HTMLAttributes<HTMLFeatureFlagFeedbackModalElement>;
469
+ "feature-flag-preview-modal": LocalJSX.IntrinsicElements["feature-flag-preview-modal"] & JSXBase.HTMLAttributes<HTMLFeatureFlagPreviewModalElement>;
470
+ }
471
+ }
472
+ }
@@ -0,0 +1,29 @@
1
+ export type FeatureFlagState = Record<string, boolean>;
2
+ export interface FeatureFlag {
3
+ slug: string;
4
+ description: string;
5
+ enabled?: boolean;
6
+ expiredAt?: string | null;
7
+ name?: string;
8
+ previewImage?: string;
9
+ documentationLink?: string;
10
+ previewName?: string;
11
+ previewContent?: string;
12
+ }
13
+ export interface FetchFlagsOptions {
14
+ endpoint?: string;
15
+ projectKey?: string;
16
+ environmentKey?: string;
17
+ init?: RequestInit;
18
+ }
19
+ export interface FlagSelectionPayload {
20
+ slug: string;
21
+ enabled: boolean;
22
+ flag?: FeatureFlag;
23
+ }
24
+ export declare const DEFAULT_STORAGE_KEY = "bs-flags-preview-state";
25
+ export declare const DEFAULT_FLAGS_ENDPOINT = "https://flags.basestack.co/api/v1/flags/preview";
26
+ export declare function fetchFeatureFlags(options?: FetchFlagsOptions): Promise<FeatureFlag[]>;
27
+ export declare const readSelectionState: (storageKey?: string) => FeatureFlagState;
28
+ export declare const writeSelectionState: (state: FeatureFlagState, storageKey?: string) => void;
29
+ export declare const toggleFlagState: (flagSlug: string, enabled: boolean, storageKey?: string) => FeatureFlagState;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import { DEFAULT_FLAGS_ENDPOINT, DEFAULT_STORAGE_KEY, type FeatureFlag, type FeatureFlagState, type FlagSelectionPayload, fetchFeatureFlags, readSelectionState, toggleFlagState, writeSelectionState } from "../lib/feature-flags";
2
+ export declare const registerFeatureFlagComponents: () => Promise<void>;
3
+ export declare class FeatureFlagClient {
4
+ private readonly endpoint?;
5
+ private readonly storageKey;
6
+ constructor(endpoint?: string | undefined, storageKey?: string);
7
+ listFlags(params?: {
8
+ projectKey?: string;
9
+ environmentKey?: string;
10
+ }): Promise<FeatureFlag[]>;
11
+ loadSelections(): FeatureFlagState;
12
+ setSelection(flagId: string, enabled: boolean): FeatureFlagState;
13
+ writeSelections(state: FeatureFlagState): void;
14
+ }
15
+ export type { FeatureFlag, FeatureFlagState, FlagSelectionPayload };
16
+ export { DEFAULT_FLAGS_ENDPOINT, DEFAULT_STORAGE_KEY, fetchFeatureFlags, readSelectionState, toggleFlagState, writeSelectionState, };
@@ -0,0 +1 @@
1
+ export {};