@blocksdiy/blocks-client-sdk 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/dist/Page.js ADDED
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Page class for managing application pages and their URLs
3
+ *
4
+ * This class provides methods to work with application pages, including
5
+ * generating proper URLs and handling URL parameters.
6
+ *
7
+ * @class Page
8
+ * @template PC - Page configuration type
9
+ */
10
+ export class Page {
11
+ pageBlockId;
12
+ pageName;
13
+ appId;
14
+ /**
15
+ * Creates a new Page instance
16
+ * @param {PC} config - Configuration for the page
17
+ * @param {string} appId - The application identifier
18
+ */
19
+ constructor(config, appId) {
20
+ this.pageBlockId = config.pageBlockId;
21
+ this.pageName = config.pageName;
22
+ this.appId = appId;
23
+ }
24
+ /**
25
+ * @deprecated
26
+ * This method is deprecated and will be removed in a future version.
27
+ * Use the new routing utilities for URL generation instead.
28
+ *
29
+ * Generates a URL for this page, including optional search parameters.
30
+ *
31
+ * @param {Record<string, string>} [searchParams={}] - Optional search parameters to append to the URL
32
+ * @returns {string} The generated URL for the page with the given search parameters
33
+ */
34
+ getUrl(searchParams = {}) {
35
+ const searchParamsString = new URLSearchParams(searchParams).toString();
36
+ return `/product/${this.appId}/pages/${this.pageBlockId}${searchParamsString ? `?${searchParamsString}` : ""}`;
37
+ }
38
+ /**
39
+ * @deprecated
40
+ * This method is deprecated and will be removed in a future version.
41
+ * Use a dedicated query parameter parsing utility instead.
42
+ *
43
+ * Parses and returns the current URL's search parameters as an object.
44
+ *
45
+ * @returns {Record<string, string>} An object representation of the URL search parameters
46
+ */
47
+ getParams() {
48
+ const urlSearchParams = new URLSearchParams(window.location.search);
49
+ return Object.fromEntries(urlSearchParams.entries());
50
+ }
51
+ }
52
+ //# sourceMappingURL=Page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Page.js","sourceRoot":"","sources":["../src/Page.ts"],"names":[],"mappings":"AAeA;;;;;;;;GAQG;AACH,MAAM,OAAO,IAAI;IACP,WAAW,CAAS;IACpB,QAAQ,CAAS;IACjB,KAAK,CAAS;IAEtB;;;;OAIG;IACH,YAAY,MAAU,EAAE,KAAa;QACnC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,eAAuC,EAAE;QAC9C,MAAM,kBAAkB,GAAG,IAAI,eAAe,CAAC,YAAsC,CAAC,CAAC,QAAQ,EAAE,CAAC;QAClG,OAAO,YAAY,IAAI,CAAC,KAAK,UAAU,IAAI,CAAC,WAAW,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACjH,CAAC;IAED;;;;;;;;OAQG;IACH,SAAS;QACP,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACpE,OAAO,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IACvD,CAAC;CACF"}