whale-cmp 0.23.1 → 0.25.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/index.d.ts CHANGED
@@ -1,24 +1,47 @@
1
1
  export type SupportedLanguage = 'ar' | 'de' | 'en' | 'es' | 'fr' | 'it' | 'pt' | 'zh';
2
2
 
3
- export class WhaleCMP {
4
- ele: Element
5
- focusEl: Element
6
- cmpManageId: Element
7
- mainId: string
8
- focus: string
9
- confirmUI: object
10
- agreementUI: object
11
- open: Function
12
- onKeydown: Function
13
- visible: boolean
14
- close: Function
3
+ export interface OpenTouUIOptions {
4
+ /** When true (default), back/OK/exit actions are ignored. */
5
+ blockExit?: boolean;
6
+ touCallback?: () => void;
7
+ }
8
+
9
+ export interface WhaleCMPOptions {
10
+ ele?: Element;
11
+ language?: SupportedLanguage;
12
+ cpId?: string;
13
+ /** @deprecated use cpId */
14
+ cpid?: string;
15
+ [key: string]: unknown;
16
+ }
17
+
18
+ export declare class WhaleCMP {
19
+ ele: Element | null;
20
+ focusEl: Element | null;
21
+ cmpManageId: Element;
22
+ mainId: string;
23
+ focus: string;
24
+ visible: boolean;
15
25
 
16
26
  /**
17
27
  * Create a new WhaleCMP instance
18
- * @param ele - The element to attach to
19
- * @param language - Initial language (default: 'en')
20
28
  */
21
- constructor(WhaleCMPOptions?: object);
29
+ constructor(options?: WhaleCMPOptions);
30
+
31
+ /**
32
+ * Open the CMP UI
33
+ */
34
+ open(callback?: (result?: { language: SupportedLanguage }) => void): void;
35
+
36
+ /**
37
+ * Handle remote/keyboard keydown
38
+ */
39
+ onKeydown(e: KeyboardEvent | { keyCode?: number; which?: number }): void;
40
+
41
+ /**
42
+ * Close the CMP UI
43
+ */
44
+ close(): void;
22
45
 
23
46
  /**
24
47
  * Set the language for the CMP interface
@@ -37,14 +60,39 @@ export class WhaleCMP {
37
60
  */
38
61
  setCpId(cpId: string): void;
39
62
 
63
+ /**
64
+ * Open Terms of Use (TouchUI) directly. Back and exit are blocked by default.
65
+ */
66
+ openTouUI(options?: OpenTouUIOptions): void;
67
+
68
+ /**
69
+ * Force-close TouchUI even when exit blocking is enabled.
70
+ */
71
+ closeTouUI(): void;
72
+
40
73
  /**
41
74
  * Cleanup method to unsubscribe from language changes
42
75
  */
43
76
  destroy(): void;
44
77
  }
45
78
 
79
+ interface QRCodeOptions {
80
+ text: string;
81
+ width?: number;
82
+ height?: number;
83
+ colorDark?: string;
84
+ colorLight?: string;
85
+ correctLevel?: number;
86
+ }
87
+
88
+ interface QRCodeConstructor {
89
+ new (el: string | HTMLElement, options?: QRCodeOptions): unknown;
90
+ }
91
+
46
92
  declare global {
47
93
  interface Window {
48
- QRCode: any
94
+ QRCode?: QRCodeConstructor;
49
95
  }
50
- }
96
+ }
97
+
98
+ export {};
package/index.html CHANGED
@@ -13,13 +13,14 @@
13
13
  </body>
14
14
  <script type="module">
15
15
  import { WhaleCMP } from "./index.js"
16
- const cmp = new WhaleCMP({cpId: "com", ele: document.getElementById("bbb")})
17
- cmp.setLanguage("en")
18
- cmp.open(e => {
19
- if (e && e.language) {
20
- console.log(e.language);
21
- }
16
+ const cmp = new WhaleCMP({
17
+ cpId: "com",
18
+ ele: document.getElementById("bbb"),
22
19
  })
20
+ // cmp.openTouUI({touCallback: e=>{
21
+ // console.log(e)
22
+ // }})
23
+ cmp.open()
23
24
  document.addEventListener("keydown", e => {
24
25
  cmp.onKeydown(e)
25
26
  })