@ton-pay/ui-react 0.2.0 → 0.2.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,7 @@
1
+ type StyleInjectOptions = {
2
+ insertAt?: 'top' | 'bottom';
3
+ attributes?: Record<string, string>;
4
+ };
5
+ declare function styleInject(css: string, options?: StyleInjectOptions): HTMLStyleElement | undefined;
6
+
7
+ export { styleInject as default };
@@ -0,0 +1,7 @@
1
+ type StyleInjectOptions = {
2
+ insertAt?: 'top' | 'bottom';
3
+ attributes?: Record<string, string>;
4
+ };
5
+ declare function styleInject(css: string, options?: StyleInjectOptions): HTMLStyleElement | undefined;
6
+
7
+ export { styleInject as default };
@@ -0,0 +1,30 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/style-inject.ts
2
+ function styleInject(css, options = {}) {
3
+ if (!css) return;
4
+ if (typeof document === "undefined") return;
5
+ const head = document.head || document.getElementsByTagName("head")[0];
6
+ if (!head) return;
7
+ const style = document.createElement("style");
8
+ style.type = "text/css";
9
+ if (options.attributes) {
10
+ for (const [key, value] of Object.entries(options.attributes)) {
11
+ style.setAttribute(key, value);
12
+ }
13
+ }
14
+ if ("styleSheet" in style) {
15
+ style.styleSheet.cssText = css;
16
+ } else {
17
+ style.appendChild(document.createTextNode(css));
18
+ }
19
+ const insertAt = _nullishCoalesce(options.insertAt, () => ( "bottom"));
20
+ if (insertAt === "top" && head.firstChild) {
21
+ head.insertBefore(style, head.firstChild);
22
+ } else {
23
+ head.appendChild(style);
24
+ }
25
+ return style;
26
+ }
27
+
28
+
29
+ exports.default = styleInject;
30
+ //# sourceMappingURL=style-inject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/ilya/work/tonpay/ton-pay/packages/ui-react/dist/style-inject.js","../src/style-inject.ts"],"names":[],"mappings":"AAAA;ACKe,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A;AACE;AACF,8BAAC","file":"/Users/ilya/work/tonpay/ton-pay/packages/ui-react/dist/style-inject.js","sourcesContent":[null,"type StyleInjectOptions = {\n insertAt?: 'top' | 'bottom';\n attributes?: Record<string, string>;\n};\n\nexport default function styleInject(\n css: string,\n options: StyleInjectOptions = {},\n) {\n if (!css) return;\n if (typeof document === 'undefined') return;\n\n const head = document.head || document.getElementsByTagName('head')[0];\n if (!head) return;\n\n const style = document.createElement('style');\n style.type = 'text/css';\n\n if (options.attributes) {\n for (const [key, value] of Object.entries(options.attributes)) {\n style.setAttribute(key, value);\n }\n }\n\n if ('styleSheet' in style) {\n (\n style as unknown as { styleSheet: { cssText: string } }\n ).styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n\n const insertAt = options.insertAt ?? 'bottom';\n if (insertAt === 'top' && head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n\n return style;\n}\n"]}
@@ -0,0 +1,30 @@
1
+ // src/style-inject.ts
2
+ function styleInject(css, options = {}) {
3
+ if (!css) return;
4
+ if (typeof document === "undefined") return;
5
+ const head = document.head || document.getElementsByTagName("head")[0];
6
+ if (!head) return;
7
+ const style = document.createElement("style");
8
+ style.type = "text/css";
9
+ if (options.attributes) {
10
+ for (const [key, value] of Object.entries(options.attributes)) {
11
+ style.setAttribute(key, value);
12
+ }
13
+ }
14
+ if ("styleSheet" in style) {
15
+ style.styleSheet.cssText = css;
16
+ } else {
17
+ style.appendChild(document.createTextNode(css));
18
+ }
19
+ const insertAt = options.insertAt ?? "bottom";
20
+ if (insertAt === "top" && head.firstChild) {
21
+ head.insertBefore(style, head.firstChild);
22
+ } else {
23
+ head.appendChild(style);
24
+ }
25
+ return style;
26
+ }
27
+ export {
28
+ styleInject as default
29
+ };
30
+ //# sourceMappingURL=style-inject.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/style-inject.ts"],"sourcesContent":["type StyleInjectOptions = {\n insertAt?: 'top' | 'bottom';\n attributes?: Record<string, string>;\n};\n\nexport default function styleInject(\n css: string,\n options: StyleInjectOptions = {},\n) {\n if (!css) return;\n if (typeof document === 'undefined') return;\n\n const head = document.head || document.getElementsByTagName('head')[0];\n if (!head) return;\n\n const style = document.createElement('style');\n style.type = 'text/css';\n\n if (options.attributes) {\n for (const [key, value] of Object.entries(options.attributes)) {\n style.setAttribute(key, value);\n }\n }\n\n if ('styleSheet' in style) {\n (\n style as unknown as { styleSheet: { cssText: string } }\n ).styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n\n const insertAt = options.insertAt ?? 'bottom';\n if (insertAt === 'top' && head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n\n return style;\n}\n"],"mappings":";AAKe,SAAR,YACL,KACA,UAA8B,CAAC,GAC/B;AACA,MAAI,CAAC,IAAK;AACV,MAAI,OAAO,aAAa,YAAa;AAErC,QAAM,OAAO,SAAS,QAAQ,SAAS,qBAAqB,MAAM,EAAE,CAAC;AACrE,MAAI,CAAC,KAAM;AAEX,QAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,OAAO;AAEb,MAAI,QAAQ,YAAY;AACtB,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,UAAU,GAAG;AAC7D,YAAM,aAAa,KAAK,KAAK;AAAA,IAC/B;AAAA,EACF;AAEA,MAAI,gBAAgB,OAAO;AACzB,IACE,MACA,WAAW,UAAU;AAAA,EACzB,OAAO;AACL,UAAM,YAAY,SAAS,eAAe,GAAG,CAAC;AAAA,EAChD;AAEA,QAAM,WAAW,QAAQ,YAAY;AACrC,MAAI,aAAa,SAAS,KAAK,YAAY;AACzC,SAAK,aAAa,OAAO,KAAK,UAAU;AAAA,EAC1C,OAAO;AACL,SAAK,YAAY,KAAK;AAAA,EACxB;AAEA,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ton-pay/ui-react",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "React components and hooks for TON Pay SDK",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -15,6 +15,13 @@
15
15
  "require": "./dist/index.js"
16
16
  }
17
17
  },
18
+ "imports": {
19
+ "#style-inject": {
20
+ "types": "./dist/style-inject.d.ts",
21
+ "import": "./dist/style-inject.mjs",
22
+ "require": "./dist/style-inject.js"
23
+ }
24
+ },
18
25
  "scripts": {
19
26
  "build": "tsup",
20
27
  "dev": "tsup --watch",
@@ -26,7 +33,8 @@
26
33
  },
27
34
  "tsup": {
28
35
  "entry": [
29
- "src/index.ts"
36
+ "src/index.ts",
37
+ "src/style-inject.ts"
30
38
  ],
31
39
  "format": [
32
40
  "cjs",
@@ -56,7 +64,7 @@
56
64
  "@tonconnect/ui-react": "^2.2.0",
57
65
  "@ton-pay/api": ">=0.1.0"
58
66
  },
59
- "devDependencies": {
67
+ "devDependencies": {
60
68
  "@tonconnect/sdk": "^3.3.1",
61
69
  "@types/react": "^18.0.0",
62
70
  "@types/react-dom": "^18.0.0",