@customviews-js/customviews 1.0.0
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/README.md +78 -0
- package/dist/custom-views.cjs.js +1564 -0
- package/dist/custom-views.cjs.js.map +1 -0
- package/dist/custom-views.esm.js +1556 -0
- package/dist/custom-views.esm.js.map +1 -0
- package/dist/custom-views.umd.js +1570 -0
- package/dist/custom-views.umd.js.map +1 -0
- package/dist/custom-views.umd.min.js +7 -0
- package/dist/custom-views.umd.min.js.map +1 -0
- package/dist/types/core/core.d.ts +52 -0
- package/dist/types/core/core.d.ts.map +1 -0
- package/dist/types/core/persistence.d.ts +22 -0
- package/dist/types/core/persistence.d.ts.map +1 -0
- package/dist/types/core/render.d.ts +3 -0
- package/dist/types/core/render.d.ts.map +1 -0
- package/dist/types/core/url-state-manager.d.ts +32 -0
- package/dist/types/core/url-state-manager.d.ts.map +1 -0
- package/dist/types/core/visibility-manager.d.ts +28 -0
- package/dist/types/core/visibility-manager.d.ts.map +1 -0
- package/dist/types/core/widget.d.ts +93 -0
- package/dist/types/core/widget.d.ts.map +1 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/models/AssetsManager.d.ts +10 -0
- package/dist/types/models/AssetsManager.d.ts.map +1 -0
- package/dist/types/models/Config.d.ts +10 -0
- package/dist/types/models/Config.d.ts.map +1 -0
- package/dist/types/styles/styles.d.ts +5 -0
- package/dist/types/styles/styles.d.ts.map +1 -0
- package/dist/types/styles/widget-styles.d.ts +13 -0
- package/dist/types/styles/widget-styles.d.ts.map +1 -0
- package/dist/types/types/types.d.ts +27 -0
- package/dist/types/types/types.d.ts.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { CustomViewsCore } from "./core";
|
|
2
|
+
export interface WidgetOptions {
|
|
3
|
+
/** The CustomViews core instance to control */
|
|
4
|
+
core: CustomViewsCore;
|
|
5
|
+
/** Container element where the widget should be rendered */
|
|
6
|
+
container?: HTMLElement;
|
|
7
|
+
/** Widget position: 'top-right', 'top-left', 'bottom-right', 'bottom-left', 'middle-left', 'middle-right' */
|
|
8
|
+
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'middle-left' | 'middle-right';
|
|
9
|
+
/** Widget theme: 'light' or 'dark' */
|
|
10
|
+
theme?: 'light' | 'dark';
|
|
11
|
+
/** Whether to show reset button */
|
|
12
|
+
showReset?: boolean;
|
|
13
|
+
/** Widget title */
|
|
14
|
+
title?: string;
|
|
15
|
+
/** Widget description text */
|
|
16
|
+
description?: string;
|
|
17
|
+
/** Whether to show welcome modal on first visit */
|
|
18
|
+
showWelcome?: boolean;
|
|
19
|
+
/** Welcome modal title (only used if showWelcome is true) */
|
|
20
|
+
welcomeTitle?: string;
|
|
21
|
+
/** Welcome modal message (only used if showWelcome is true) */
|
|
22
|
+
welcomeMessage?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare class CustomViewsWidget {
|
|
25
|
+
private core;
|
|
26
|
+
private container;
|
|
27
|
+
private widgetIcon;
|
|
28
|
+
private options;
|
|
29
|
+
private modal;
|
|
30
|
+
constructor(options: WidgetOptions);
|
|
31
|
+
/**
|
|
32
|
+
* Render the widget
|
|
33
|
+
*/
|
|
34
|
+
render(): HTMLElement;
|
|
35
|
+
/**
|
|
36
|
+
* Create the simple widget icon
|
|
37
|
+
*/
|
|
38
|
+
private createWidgetIcon;
|
|
39
|
+
/**
|
|
40
|
+
* Remove the widget from DOM
|
|
41
|
+
*/
|
|
42
|
+
destroy(): void;
|
|
43
|
+
private attachEventListeners;
|
|
44
|
+
/**
|
|
45
|
+
* Close the modal
|
|
46
|
+
*/
|
|
47
|
+
private closeModal;
|
|
48
|
+
/**
|
|
49
|
+
* Open the custom state creator
|
|
50
|
+
*/
|
|
51
|
+
private openStateModal;
|
|
52
|
+
/**
|
|
53
|
+
* Create the custom state creator modal
|
|
54
|
+
*/
|
|
55
|
+
private createCustomStateModal;
|
|
56
|
+
/**
|
|
57
|
+
* Attach event listeners for custom state creator
|
|
58
|
+
*/
|
|
59
|
+
private attachStateModalEventListeners;
|
|
60
|
+
/**
|
|
61
|
+
* Apply theme class to the modal overlay based on options
|
|
62
|
+
*/
|
|
63
|
+
private applyThemeToModal;
|
|
64
|
+
/**
|
|
65
|
+
* Get current state from form values
|
|
66
|
+
*/
|
|
67
|
+
private getCurrentCustomStateFromModal;
|
|
68
|
+
/**
|
|
69
|
+
* Copy shareable URL to clipboard
|
|
70
|
+
*/
|
|
71
|
+
private copyShareableURL;
|
|
72
|
+
/**
|
|
73
|
+
* Load current state into form based on currently active toggles
|
|
74
|
+
*/
|
|
75
|
+
private loadCurrentStateIntoForm;
|
|
76
|
+
/**
|
|
77
|
+
* Format toggle name for display
|
|
78
|
+
*/
|
|
79
|
+
private formatToggleName;
|
|
80
|
+
/**
|
|
81
|
+
* Check if this is the first visit and show welcome modal
|
|
82
|
+
*/
|
|
83
|
+
private showWelcomeModalIfFirstVisit;
|
|
84
|
+
/**
|
|
85
|
+
* Create and show the welcome modal
|
|
86
|
+
*/
|
|
87
|
+
private createWelcomeModal;
|
|
88
|
+
/**
|
|
89
|
+
* Attach event listeners for welcome modal
|
|
90
|
+
*/
|
|
91
|
+
private attachWelcomeModalEventListeners;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../../src/core/widget.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAI9C,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,IAAI,EAAE,eAAe,CAAC;IAEtB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,WAAW,CAAC;IAExB,6GAA6G;IAC7G,QAAQ,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,cAAc,GAAG,aAAa,GAAG,aAAa,GAAG,cAAc,CAAC;IAEtG,sCAAsC;IACtC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAEzB,mCAAmC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,8BAA8B;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,mDAAmD;IACnD,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,6DAA6D;IAC7D,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,IAAI,CAAkB;IAC9B,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,OAAO,CAA0B;IAGzC,OAAO,CAAC,KAAK,CAA4B;gBAG7B,OAAO,EAAE,aAAa;IAqBlC;;OAEG;IACI,MAAM,IAAI,WAAW;IAe5B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAaxB;;OAEG;IACI,OAAO,IAAI,IAAI;IAatB,OAAO,CAAC,oBAAoB;IAO5B;;OAEG;IACH,OAAO,CAAC,UAAU;IAOlB;;OAEG;IACH,OAAO,CAAC,cAAc;IAOtB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAkD9B;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAsDtC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAUzB;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAkBtC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IA0BhC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAiBpC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAiC1B;;OAEG;IACH,OAAO,CAAC,gCAAgC;CAqCzC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CustomViewsCore } from "core/core";
|
|
2
|
+
import { Config } from "models/Config";
|
|
3
|
+
export type InitFromJsonOptions = {
|
|
4
|
+
assetsJsonPath?: string;
|
|
5
|
+
rootEl?: HTMLElement;
|
|
6
|
+
config?: Config;
|
|
7
|
+
configPath?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class CustomViews {
|
|
10
|
+
static initFromJson(opts: InitFromJsonOptions): Promise<CustomViewsCore | null>;
|
|
11
|
+
}
|
|
12
|
+
export { CustomViewsCore } from "core/core";
|
|
13
|
+
export type { CustomViewsOptions } from "core/core";
|
|
14
|
+
export { CustomViewsWidget } from "core/widget";
|
|
15
|
+
export type { WidgetOptions } from "core/widget";
|
|
16
|
+
export { PersistenceManager } from "core/persistence";
|
|
17
|
+
export { URLStateManager } from "core/url-state-manager";
|
|
18
|
+
export { AssetsManager } from "models/AssetsManager";
|
|
19
|
+
export { Config as LocalConfig } from "models/Config";
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA2B,MAAM,WAAW,CAAC;AAIrE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAA;AAED,qBAAa,WAAW;WAGT,YAAY,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;CAqCtF;AAGD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,YAAY,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CustomViewAsset } from "types/types";
|
|
2
|
+
export declare class AssetsManager {
|
|
3
|
+
assets: Record<string, CustomViewAsset>;
|
|
4
|
+
constructor(assets: Record<string, CustomViewAsset>);
|
|
5
|
+
validate(): boolean;
|
|
6
|
+
get(assetId: string): CustomViewAsset | undefined;
|
|
7
|
+
loadFromJSON(json: Record<string, CustomViewAsset>): void;
|
|
8
|
+
loadAdditionalAssets(additionalAssets: Record<string, CustomViewAsset>): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=AssetsManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssetsManager.d.ts","sourceRoot":"","sources":["../../../src/models/AssetsManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,qBAAa,aAAa;IACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;gBAE5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAQnD,QAAQ,IAAI,OAAO;IAInB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIjD,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAIlD,oBAAoB,CAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;CAIvE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { State } from "types/types";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for the site, has default state and list of toggles
|
|
4
|
+
*/
|
|
5
|
+
export declare class Config {
|
|
6
|
+
defaultState: State;
|
|
7
|
+
allToggles?: string[] | undefined;
|
|
8
|
+
constructor(defaultState: State, allToggles?: string[] | undefined);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=Config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../../src/models/Config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC;;GAEG;AACH,qBAAa,MAAM;IAER,YAAY,EAAE,KAAK;IACnB,UAAU,CAAC,EAAE,MAAM,EAAE;gBADrB,YAAY,EAAE,KAAK,EACnB,UAAU,CAAC,EAAE,MAAM,EAAE,YAAA;CAE/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/styles/styles.ts"],"names":[],"mappings":"AA8BA;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAOvC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Widget styles for CustomViews
|
|
3
|
+
* Extracted from widget.ts for better maintainability
|
|
4
|
+
*
|
|
5
|
+
* Note: Styles are kept as a TypeScript string for compatibility with the build system.
|
|
6
|
+
* This approach ensures the styles are properly bundled and don't require separate CSS file handling.
|
|
7
|
+
*/
|
|
8
|
+
export declare const WIDGET_STYLES = "\n/* Rounded rectangle widget icon styles */\n.cv-widget-icon {\n position: fixed;\n background: white;\n color: black;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 18px;\n font-weight: bold;\n cursor: pointer;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n z-index: 9998;\n transition: all 0.3s ease;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n.cv-widget-icon:hover {\n background: white;\n color: black;\n}\n\n/* Top-right: rounded end on left, sticks out leftward on hover */\n.cv-widget-top-right {\n top: 20px;\n right: 0;\n border-radius: 18px 0 0 18px;\n padding-left: 8px;\n justify-content: flex-start;\n}\n\n/* Top-left: rounded end on right, sticks out rightward on hover */\n.cv-widget-top-left {\n top: 20px;\n left: 0;\n border-radius: 0 18px 18px 0;\n padding-right: 8px;\n justify-content: flex-end;\n}\n\n/* Bottom-right: rounded end on left, sticks out leftward on hover */\n.cv-widget-bottom-right {\n bottom: 20px;\n right: 0;\n border-radius: 18px 0 0 18px;\n padding-left: 8px;\n justify-content: flex-start;\n}\n\n/* Bottom-left: rounded end on right, sticks out rightward on hover */\n.cv-widget-bottom-left {\n bottom: 20px;\n left: 0;\n border-radius: 0 18px 18px 0;\n padding-right: 8px;\n justify-content: flex-end;\n}\n\n/* Middle-left: rounded end on right, sticks out rightward on hover */\n.cv-widget-middle-left {\n top: 50%;\n left: 0;\n transform: translateY(-50%);\n border-radius: 0 18px 18px 0;\n padding-right: 8px;\n justify-content: flex-end;\n}\n\n/* Middle-right: rounded end on left, sticks out leftward on hover */\n.cv-widget-middle-right {\n top: 50%;\n right: 0;\n transform: translateY(-50%);\n border-radius: 18px 0 0 18px;\n padding-left: 8px;\n justify-content: flex-start;\n}\n\n.cv-widget-top-right,\n.cv-widget-middle-right,\n.cv-widget-bottom-right,\n.cv-widget-top-left,\n.cv-widget-middle-left,\n.cv-widget-bottom-left {\n height: 36px;\n width: 36px;\n}\n\n.cv-widget-middle-right:hover,\n.cv-widget-top-right:hover,\n.cv-widget-bottom-right:hover,\n.cv-widget-top-left:hover,\n.cv-widget-middle-left:hover,\n.cv-widget-bottom-left:hover {\n width: 55px;\n}\n\n/* Modal content styles */\n.cv-widget-section {\n margin-bottom: 16px;\n}\n\n.cv-widget-section:last-child {\n margin-bottom: 0;\n}\n\n.cv-widget-section label {\n display: block;\n margin-bottom: 4px;\n font-weight: 500;\n color: #555;\n}\n\n.cv-widget-profile-select,\n.cv-widget-state-select {\n width: 100%;\n padding: 8px 12px;\n border: 1px solid #ddd;\n border-radius: 4px;\n background: white;\n font-size: 14px;\n}\n\n.cv-widget-profile-select:focus,\n.cv-widget-state-select:focus {\n outline: none;\n border-color: #007bff;\n box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);\n}\n\n.cv-widget-profile-select:disabled,\n.cv-widget-state-select:disabled {\n background: #f8f9fa;\n color: #6c757d;\n cursor: not-allowed;\n}\n\n.cv-widget-current {\n margin: 16px 0;\n padding: 12px;\n background: #f8f9fa;\n border-radius: 4px;\n border-left: 4px solid #007bff;\n}\n\n.cv-widget-current label {\n font-size: 12px;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: #666;\n margin-bottom: 4px;\n}\n\n.cv-widget-current-view {\n font-weight: 500;\n color: #333;\n}\n\n.cv-widget-reset {\n width: 100%;\n padding: 8px 16px;\n background: #dc3545;\n color: white;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n}\n\n.cv-widget-reset:hover {\n background: #c82333;\n}\n\n.cv-widget-reset:active {\n background: #bd2130;\n}\n\n/* Responsive design for mobile */\n@media (max-width: 768px) {\n .cv-widget-top-right,\n .cv-widget-top-left {\n top: 10px;\n }\n\n .cv-widget-bottom-right,\n .cv-widget-bottom-left {\n bottom: 10px;\n }\n\n /* All widgets stay flush with screen edges */\n .cv-widget-top-right,\n .cv-widget-bottom-right,\n .cv-widget-middle-right {\n right: 0;\n }\n\n .cv-widget-top-left,\n .cv-widget-bottom-left,\n .cv-widget-middle-left {\n left: 0;\n }\n\n /* Slightly smaller on mobile */\n .cv-widget-icon {\n width: 60px;\n height: 32px;\n }\n\n .cv-widget-icon:hover {\n width: 75px;\n }\n}\n\n/* Modal styles */\n.cv-widget-modal-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10002;\n animation: fadeIn 0.2s ease;\n}\n\n@keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n.cv-widget-modal {\n background: white;\n border-radius: 8px;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);\n max-width: 400px;\n width: 90vw;\n max-height: 80vh;\n overflow-y: auto;\n animation: slideIn 0.2s ease;\n}\n\n@keyframes slideIn {\n from { \n opacity: 0;\n transform: scale(0.9) translateY(-20px);\n }\n to { \n opacity: 1;\n transform: scale(1) translateY(0);\n }\n}\n\n.cv-widget-modal-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 16px 20px;\n border-bottom: 1px solid #e9ecef;\n background: #f8f9fa;\n border-radius: 8px 8px 0 0;\n}\n\n.cv-widget-modal-header h3 {\n margin: 0;\n font-size: 18px;\n font-weight: 600;\n color: #333;\n}\n\n.cv-widget-modal-close {\n background: none;\n border: none;\n font-size: 24px;\n cursor: pointer;\n padding: 0;\n width: 32px;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n color: #666;\n}\n\n.cv-widget-modal-close:hover {\n background: #e9ecef;\n}\n\n.cv-widget-modal-content {\n padding: 20px;\n}\n\n.cv-widget-modal-actions {\n margin-top: 20px;\n padding-top: 16px;\n border-top: 1px solid #e9ecef;\n}\n\n.cv-widget-restore {\n width: 100%;\n padding: 10px 16px;\n background: #28a745;\n color: white;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n}\n\n.cv-widget-restore:hover {\n background: #218838;\n}\n\n.cv-widget-create-state {\n width: 100%;\n padding: 10px 16px;\n background: #007bff;\n color: white;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n margin-bottom: 10px;\n}\n\n.cv-widget-create-state:hover {\n background: #0056b3;\n}\n\n/* Dark theme modal styles */\n.cv-widget-theme-dark .cv-widget-modal {\n background: #2d3748;\n color: #e2e8f0;\n}\n\n.cv-widget-theme-dark .cv-widget-modal-header {\n background: #1a202c;\n border-color: #4a5568;\n}\n\n.cv-widget-theme-dark .cv-widget-modal-header h3 {\n color: #e2e8f0;\n}\n\n.cv-widget-theme-dark .cv-widget-modal-close {\n color: #a0aec0;\n}\n\n.cv-widget-theme-dark .cv-widget-modal-close:hover {\n background: #4a5568;\n}\n\n.cv-widget-theme-dark .cv-widget-modal-actions {\n border-color: #4a5568;\n}\n\n/* Custom state creator styles */\n.cv-custom-state-modal {\n max-width: 500px;\n}\n\n.cv-custom-state-form h4 {\n margin: 20px 0 10px 0;\n font-size: 16px;\n font-weight: 600;\n color: #333;\n border-bottom: 1px solid #e9ecef;\n padding-bottom: 5px;\n}\n\n.cv-custom-state-section {\n margin-bottom: 16px;\n}\n\n.cv-custom-state-section label {\n display: block;\n margin-bottom: 4px;\n font-weight: 500;\n color: #555;\n}\n\n.cv-custom-state-input {\n width: 100%;\n padding: 8px 12px;\n border: 1px solid #ddd;\n border-radius: 4px;\n background: white;\n font-size: 14px;\n}\n\n.cv-custom-state-input:focus {\n outline: none;\n border-color: #007bff;\n box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);\n}\n\n.cv-custom-toggles {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));\n gap: 10px;\n}\n\n.cv-custom-state-toggle {\n display: flex;\n align-items: center;\n}\n\n.cv-custom-state-toggle label {\n display: flex;\n align-items: center;\n cursor: pointer;\n font-weight: normal;\n margin: 0;\n}\n\n.cv-custom-toggle-checkbox {\n margin-right: 8px;\n width: auto;\n}\n\n.cv-custom-state-actions {\n display: flex;\n gap: 10px;\n margin-top: 20px;\n padding-top: 16px;\n border-top: 1px solid #e9ecef;\n}\n\n.cv-custom-state-cancel,\n.cv-custom-state-copy-url {\n flex: 1;\n padding: 10px 16px;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n}\n\n.cv-custom-state-reset {\n flex: 1;\n padding: 10px 16px;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n background: #dc3545;\n color: white;\n}\n\n.cv-custom-state-reset:hover {\n background: #c82333;\n}\n\n.cv-custom-state-cancel {\n background: #6c757d;\n color: white;\n}\n\n.cv-custom-state-cancel:hover {\n background: #5a6268;\n}\n\n.cv-custom-state-copy-url {\n background: #28a745;\n color: white;\n}\n\n.cv-custom-state-copy-url:hover {\n background: #218838;\n}\n\n/* Dark theme custom state styles */\n.cv-widget-theme-dark .cv-custom-state-form h4 {\n color: #e2e8f0;\n border-color: #4a5568;\n}\n\n.cv-widget-theme-dark .cv-custom-state-section label {\n color: #a0aec0;\n}\n\n.cv-widget-theme-dark .cv-custom-state-input {\n background: #1a202c;\n border-color: #4a5568;\n color: #e2e8f0;\n}\n\n.cv-widget-theme-dark .cv-custom-state-actions {\n border-color: #4a5568;\n}\n\n/* Welcome modal styles */\n.cv-welcome-modal {\n max-width: 500px;\n}\n\n.cv-welcome-content {\n text-align: center;\n}\n\n.cv-welcome-content p {\n font-size: 15px;\n line-height: 1.6;\n color: #555;\n margin-bottom: 24px;\n}\n\n.cv-welcome-widget-preview {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n padding: 20px;\n background: #f8f9fa;\n border-radius: 8px;\n margin-bottom: 24px;\n}\n\n.cv-welcome-widget-icon {\n width: 36px;\n height: 36px;\n background: white;\n color: black;\n border-radius: 0 18px 18px 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 18px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n}\n\n.cv-welcome-widget-label {\n font-size: 14px;\n color: #666;\n margin: 0;\n font-weight: 500;\n}\n\n.cv-welcome-got-it {\n width: 100%;\n padding: 12px 24px;\n background: #007bff;\n color: white;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n font-size: 16px;\n font-weight: 600;\n transition: background 0.2s ease;\n}\n\n.cv-welcome-got-it:hover {\n background: #0056b3;\n}\n\n.cv-welcome-got-it:active {\n background: #004494;\n}\n\n/* Dark theme welcome modal styles */\n.cv-widget-theme-dark .cv-welcome-content p {\n color: #cbd5e0;\n}\n\n.cv-widget-theme-dark .cv-welcome-widget-preview {\n background: #1a202c;\n}\n\n.cv-widget-theme-dark .cv-welcome-widget-label {\n color: #a0aec0;\n}\n";
|
|
9
|
+
/**
|
|
10
|
+
* Inject widget styles into the document head
|
|
11
|
+
*/
|
|
12
|
+
export declare function injectWidgetStyles(): void;
|
|
13
|
+
//# sourceMappingURL=widget-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-styles.d.ts","sourceRoot":"","sources":["../../../src/styles/widget-styles.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,aAAa,6nVAokBzB,CAAC;AAEF;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAQzC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an individual asset that can be rendered in a custom view.
|
|
3
|
+
*/
|
|
4
|
+
export interface CustomViewAsset {
|
|
5
|
+
/** Optional type. If not provided, auto-detected from src/content. */
|
|
6
|
+
type?: 'image' | 'text' | 'html' | string;
|
|
7
|
+
/** Image source URL */
|
|
8
|
+
src?: string;
|
|
9
|
+
/** Alt text for images */
|
|
10
|
+
alt?: string;
|
|
11
|
+
/** Text or HTML content */
|
|
12
|
+
content?: string;
|
|
13
|
+
/** CSS class name(s) to apply */
|
|
14
|
+
className?: string;
|
|
15
|
+
/** Inline CSS styles to apply */
|
|
16
|
+
style?: string;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Represents a specific state of a custom view.
|
|
21
|
+
* States contain the list of toggle categories that should be displayed in this state.
|
|
22
|
+
*/
|
|
23
|
+
export interface State {
|
|
24
|
+
toggles: ToggleId[];
|
|
25
|
+
}
|
|
26
|
+
export type ToggleId = string;
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sEAAsE;IACtE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC1C,uBAAuB;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,QAAQ,EAAE,CAAC;CACrB;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@customviews-js/customviews",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A JavaScript dynamic custom views Library.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"main": "dist/custom-views.cjs.js",
|
|
8
|
+
"module": "dist/custom-views.esm.js",
|
|
9
|
+
"browser": "dist/custom-views.umd.js",
|
|
10
|
+
"unpkg": "dist/custom-views.umd.min.js",
|
|
11
|
+
"jsdelivr": "dist/custom-views.umd.min.js",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/customviews-js/customviews.git"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/"
|
|
18
|
+
],
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/custom-views.esm.js",
|
|
23
|
+
"require": "./dist/custom-views.cjs.js",
|
|
24
|
+
"browser": "./dist/custom-views.umd.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"clean": "rimraf dist",
|
|
29
|
+
"build:types": "tsc --project tsconfig.json",
|
|
30
|
+
"build:js": "rollup -c",
|
|
31
|
+
"build": "npm run clean && npm run build:types && npm run build:js",
|
|
32
|
+
"dev": "rollup -c -w",
|
|
33
|
+
"test": "vitest"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"javascript",
|
|
37
|
+
"library",
|
|
38
|
+
"custom views"
|
|
39
|
+
],
|
|
40
|
+
"author": "Chan Ger Teck",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
44
|
+
"@rollup/plugin-typescript": "^12.1.4",
|
|
45
|
+
"@types/node": "^24.3.1",
|
|
46
|
+
"jsdom": "^27.0.0",
|
|
47
|
+
"rimraf": "^6.0.1",
|
|
48
|
+
"rollup": "^4.46.2",
|
|
49
|
+
"tslib": "^2.8.1",
|
|
50
|
+
"typescript": "^5.9.2",
|
|
51
|
+
"vitest": "^3.2.4"
|
|
52
|
+
},
|
|
53
|
+
"bugs": {
|
|
54
|
+
"url": "https://github.com/customviews-js/customviews/issues"
|
|
55
|
+
},
|
|
56
|
+
"homepage": "https://github.com/customviews-js/customviews#readme"
|
|
57
|
+
}
|