@gait-financial/react 0.1.0 → 0.1.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.
- package/dist/index.cjs +190 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +114 -0
- package/dist/index.d.ts +114 -0
- package/dist/index.js +159 -0
- package/dist/index.js.map +1 -0
- package/dist/register.cjs +59 -0
- package/dist/register.cjs.map +1 -0
- package/dist/register.d.cts +20 -0
- package/dist/register.d.ts +20 -0
- package/dist/register.js +33 -0
- package/dist/register.js.map +1 -0
- package/dist/wc/button.js +958 -0
- package/package.json +14 -19
- package/wc/button.js +958 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/register.ts
|
|
21
|
+
var register_exports = {};
|
|
22
|
+
__export(register_exports, {
|
|
23
|
+
defineCustomElements: () => defineCustomElements
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(register_exports);
|
|
26
|
+
var import_meta = {};
|
|
27
|
+
async function defineCustomElements(scriptUrl) {
|
|
28
|
+
if (typeof window === "undefined" || typeof customElements === "undefined") {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (customElements.get("gait-button")) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
const script = document.createElement("script");
|
|
36
|
+
script.async = true;
|
|
37
|
+
if (scriptUrl) {
|
|
38
|
+
script.src = scriptUrl;
|
|
39
|
+
} else {
|
|
40
|
+
try {
|
|
41
|
+
script.src = new URL("./wc/button.js", import_meta.url).href;
|
|
42
|
+
} catch {
|
|
43
|
+
reject(new Error("[@gait-financial/react] Could not resolve bundled script. Load the web component via script tag or pass scriptUrl."));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
script.onload = () => resolve();
|
|
48
|
+
script.onerror = () => reject(new Error("[@gait-financial/react] Failed to load Gait web component script."));
|
|
49
|
+
document.head.appendChild(script);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (typeof window !== "undefined" && typeof customElements !== "undefined") {
|
|
53
|
+
void defineCustomElements();
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
defineCustomElements
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=register.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/register.ts"],"sourcesContent":["/**\n * Registers Gait Web Components in the browser.\n * Safe to call in SSR environments - no-op when window/customElements unavailable.\n *\n * Usage:\n * import '@gait-financial/react/register'; // Side-effect: registers when in browser\n * // or\n * import { defineCustomElements } from '@gait-financial/react/register';\n * await defineCustomElements(); // Optional: load from custom URL\n */\n\n/**\n * Loads and registers Gait Web Components.\n * In browser: loads the WC script if not already registered.\n * In SSR: no-op.\n *\n * @param scriptUrl - Optional URL to the button.js script. If omitted, uses the bundled script.\n */\nexport async function defineCustomElements(\n scriptUrl?: string\n): Promise<void> {\n if (typeof window === 'undefined' || typeof customElements === 'undefined') {\n return;\n }\n if (customElements.get('gait-button')) {\n return;\n }\n\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.async = true;\n\n if (scriptUrl) {\n script.src = scriptUrl;\n } else {\n // Use bundled script - path relative to this module\n try {\n script.src = new URL('./wc/button.js', import.meta.url).href;\n } catch {\n reject(new Error('[@gait-financial/react] Could not resolve bundled script. Load the web component via script tag or pass scriptUrl.'));\n return;\n }\n }\n\n script.onload = () => resolve();\n script.onerror = () =>\n reject(new Error('[@gait-financial/react] Failed to load Gait web component script.'));\n document.head.appendChild(script);\n });\n}\n\n// Side-effect: auto-register when imported in browser (SSR-safe)\nif (typeof window !== 'undefined' && typeof customElements !== 'undefined') {\n void defineCustomElements();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,eAAsB,qBACpB,WACe;AACf,MAAI,OAAO,WAAW,eAAe,OAAO,mBAAmB,aAAa;AAC1E;AAAA,EACF;AACA,MAAI,eAAe,IAAI,aAAa,GAAG;AACrC;AAAA,EACF;AAEA,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,QAAQ;AAEf,QAAI,WAAW;AACb,aAAO,MAAM;AAAA,IACf,OAAO;AAEL,UAAI;AACF,eAAO,MAAM,IAAI,IAAI,kBAAkB,YAAY,GAAG,EAAE;AAAA,MAC1D,QAAQ;AACN,eAAO,IAAI,MAAM,oHAAoH,CAAC;AACtI;AAAA,MACF;AAAA,IACF;AAEA,WAAO,SAAS,MAAM,QAAQ;AAC9B,WAAO,UAAU,MACf,OAAO,IAAI,MAAM,mEAAmE,CAAC;AACvF,aAAS,KAAK,YAAY,MAAM;AAAA,EAClC,CAAC;AACH;AAGA,IAAI,OAAO,WAAW,eAAe,OAAO,mBAAmB,aAAa;AAC1E,OAAK,qBAAqB;AAC5B;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers Gait Web Components in the browser.
|
|
3
|
+
* Safe to call in SSR environments - no-op when window/customElements unavailable.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* import '@gait-financial/react/register'; // Side-effect: registers when in browser
|
|
7
|
+
* // or
|
|
8
|
+
* import { defineCustomElements } from '@gait-financial/react/register';
|
|
9
|
+
* await defineCustomElements(); // Optional: load from custom URL
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Loads and registers Gait Web Components.
|
|
13
|
+
* In browser: loads the WC script if not already registered.
|
|
14
|
+
* In SSR: no-op.
|
|
15
|
+
*
|
|
16
|
+
* @param scriptUrl - Optional URL to the button.js script. If omitted, uses the bundled script.
|
|
17
|
+
*/
|
|
18
|
+
declare function defineCustomElements(scriptUrl?: string): Promise<void>;
|
|
19
|
+
|
|
20
|
+
export { defineCustomElements };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers Gait Web Components in the browser.
|
|
3
|
+
* Safe to call in SSR environments - no-op when window/customElements unavailable.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* import '@gait-financial/react/register'; // Side-effect: registers when in browser
|
|
7
|
+
* // or
|
|
8
|
+
* import { defineCustomElements } from '@gait-financial/react/register';
|
|
9
|
+
* await defineCustomElements(); // Optional: load from custom URL
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Loads and registers Gait Web Components.
|
|
13
|
+
* In browser: loads the WC script if not already registered.
|
|
14
|
+
* In SSR: no-op.
|
|
15
|
+
*
|
|
16
|
+
* @param scriptUrl - Optional URL to the button.js script. If omitted, uses the bundled script.
|
|
17
|
+
*/
|
|
18
|
+
declare function defineCustomElements(scriptUrl?: string): Promise<void>;
|
|
19
|
+
|
|
20
|
+
export { defineCustomElements };
|
package/dist/register.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/register.ts
|
|
2
|
+
async function defineCustomElements(scriptUrl) {
|
|
3
|
+
if (typeof window === "undefined" || typeof customElements === "undefined") {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
if (customElements.get("gait-button")) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
const script = document.createElement("script");
|
|
11
|
+
script.async = true;
|
|
12
|
+
if (scriptUrl) {
|
|
13
|
+
script.src = scriptUrl;
|
|
14
|
+
} else {
|
|
15
|
+
try {
|
|
16
|
+
script.src = new URL("./wc/button.js", import.meta.url).href;
|
|
17
|
+
} catch {
|
|
18
|
+
reject(new Error("[@gait-financial/react] Could not resolve bundled script. Load the web component via script tag or pass scriptUrl."));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
script.onload = () => resolve();
|
|
23
|
+
script.onerror = () => reject(new Error("[@gait-financial/react] Failed to load Gait web component script."));
|
|
24
|
+
document.head.appendChild(script);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (typeof window !== "undefined" && typeof customElements !== "undefined") {
|
|
28
|
+
void defineCustomElements();
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
defineCustomElements
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/register.ts"],"sourcesContent":["/**\n * Registers Gait Web Components in the browser.\n * Safe to call in SSR environments - no-op when window/customElements unavailable.\n *\n * Usage:\n * import '@gait-financial/react/register'; // Side-effect: registers when in browser\n * // or\n * import { defineCustomElements } from '@gait-financial/react/register';\n * await defineCustomElements(); // Optional: load from custom URL\n */\n\n/**\n * Loads and registers Gait Web Components.\n * In browser: loads the WC script if not already registered.\n * In SSR: no-op.\n *\n * @param scriptUrl - Optional URL to the button.js script. If omitted, uses the bundled script.\n */\nexport async function defineCustomElements(\n scriptUrl?: string\n): Promise<void> {\n if (typeof window === 'undefined' || typeof customElements === 'undefined') {\n return;\n }\n if (customElements.get('gait-button')) {\n return;\n }\n\n return new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.async = true;\n\n if (scriptUrl) {\n script.src = scriptUrl;\n } else {\n // Use bundled script - path relative to this module\n try {\n script.src = new URL('./wc/button.js', import.meta.url).href;\n } catch {\n reject(new Error('[@gait-financial/react] Could not resolve bundled script. Load the web component via script tag or pass scriptUrl.'));\n return;\n }\n }\n\n script.onload = () => resolve();\n script.onerror = () =>\n reject(new Error('[@gait-financial/react] Failed to load Gait web component script.'));\n document.head.appendChild(script);\n });\n}\n\n// Side-effect: auto-register when imported in browser (SSR-safe)\nif (typeof window !== 'undefined' && typeof customElements !== 'undefined') {\n void defineCustomElements();\n}\n"],"mappings":";AAkBA,eAAsB,qBACpB,WACe;AACf,MAAI,OAAO,WAAW,eAAe,OAAO,mBAAmB,aAAa;AAC1E;AAAA,EACF;AACA,MAAI,eAAe,IAAI,aAAa,GAAG;AACrC;AAAA,EACF;AAEA,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,QAAQ;AAEf,QAAI,WAAW;AACb,aAAO,MAAM;AAAA,IACf,OAAO;AAEL,UAAI;AACF,eAAO,MAAM,IAAI,IAAI,kBAAkB,YAAY,GAAG,EAAE;AAAA,MAC1D,QAAQ;AACN,eAAO,IAAI,MAAM,oHAAoH,CAAC;AACtI;AAAA,MACF;AAAA,IACF;AAEA,WAAO,SAAS,MAAM,QAAQ;AAC9B,WAAO,UAAU,MACf,OAAO,IAAI,MAAM,mEAAmE,CAAC;AACvF,aAAS,KAAK,YAAY,MAAM;AAAA,EAClC,CAAC;AACH;AAGA,IAAI,OAAO,WAAW,eAAe,OAAO,mBAAmB,aAAa;AAC1E,OAAK,qBAAqB;AAC5B;","names":[]}
|