@alquimia-ai/ui 1.9.3 → 2.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/components/atoms/index.d.mts +1 -1
- package/dist/components/atoms/index.d.ts +1 -1
- package/dist/components/atoms/index.js +1848 -1428
- package/dist/components/atoms/index.js.map +1 -1
- package/dist/components/atoms/index.mjs +1453 -1409
- package/dist/components/atoms/index.mjs.map +1 -1
- package/dist/components/hooks/index.d.mts +1 -0
- package/dist/components/hooks/index.d.ts +1 -0
- package/dist/components/hooks/index.js +572 -211
- package/dist/components/hooks/index.js.map +1 -1
- package/dist/components/hooks/index.mjs +505 -193
- package/dist/components/hooks/index.mjs.map +1 -1
- package/dist/components/molecules/documents/index.d.mts +1 -0
- package/dist/components/molecules/documents/index.d.ts +1 -0
- package/dist/components/molecules/documents/index.js +2366 -1884
- package/dist/components/molecules/documents/index.js.map +1 -1
- package/dist/components/molecules/documents/index.mjs +2207 -1764
- package/dist/components/molecules/documents/index.mjs.map +1 -1
- package/dist/components/molecules/index.js +2261 -2095
- package/dist/components/molecules/index.js.map +1 -1
- package/dist/components/molecules/index.mjs +2084 -2075
- package/dist/components/molecules/index.mjs.map +1 -1
- package/dist/components/molecules/viewers/index.js +1303 -1185
- package/dist/components/molecules/viewers/index.js.map +1 -1
- package/dist/components/molecules/viewers/index.mjs +1254 -1167
- package/dist/components/molecules/viewers/index.mjs.map +1 -1
- package/dist/components/organisms/index.d.mts +1 -0
- package/dist/components/organisms/index.d.ts +1 -0
- package/dist/components/organisms/index.js +3074 -2609
- package/dist/components/organisms/index.js.map +1 -1
- package/dist/components/organisms/index.mjs +2999 -2586
- package/dist/components/organisms/index.mjs.map +1 -1
- package/dist/components/templates/index.d.mts +25 -3
- package/dist/components/templates/index.d.ts +25 -3
- package/dist/components/templates/index.js +1490 -1300
- package/dist/components/templates/index.js.map +1 -1
- package/dist/components/templates/index.mjs +1413 -1281
- package/dist/components/templates/index.mjs.map +1 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3951 -2977
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3368 -2950
- package/dist/index.mjs.map +1 -1
- package/dist/lib/index.js +106 -54
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +42 -43
- package/dist/lib/index.mjs.map +1 -1
- package/dist/providers/index.d.mts +17 -0
- package/dist/providers/index.d.ts +17 -0
- package/dist/providers/index.js +177 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/index.mjs +101 -0
- package/dist/providers/index.mjs.map +1 -0
- package/dist/styles.css +68 -0
- package/dist/styles.css.map +1 -0
- package/dist/styles.d.mts +2 -0
- package/dist/styles.d.ts +2 -0
- package/dist/tailwind.config.js +4 -10
- package/dist/types/index.d.mts +5 -5
- package/dist/types/index.d.ts +5 -5
- package/dist/types/index.js +52 -19
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +6 -8
- package/dist/types/index.mjs.map +1 -1
- package/package.json +8 -7
- package/dist/components/index.d.mts +0 -23
- package/dist/components/index.d.ts +0 -23
- package/dist/components/index.js +0 -1734
- package/dist/components/index.js.map +0 -1
- package/dist/components/index.mjs +0 -1702
- package/dist/components/index.mjs.map +0 -1
- package/dist/components/templates/cards/index.d.mts +0 -26
- package/dist/components/templates/cards/index.d.ts +0 -26
- package/dist/components/templates/cards/index.js +0 -1536
- package/dist/components/templates/cards/index.js.map +0 -1
- package/dist/components/templates/cards/index.mjs +0 -1504
- package/dist/components/templates/cards/index.mjs.map +0 -1
package/dist/lib/index.js
CHANGED
|
@@ -1,82 +1,134 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
function _type_of(obj) {
|
|
3
|
+
"@swc/helpers - typeof";
|
|
4
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
5
|
+
}
|
|
2
6
|
var __defProp = Object.defineProperty;
|
|
3
7
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
8
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all)
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
var __export = function(target, all) {
|
|
11
|
+
for(var name in all)__defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = function(to, from, except, desc) {
|
|
17
|
+
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
18
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
19
|
+
try {
|
|
20
|
+
var _loop = function() {
|
|
21
|
+
var key = _step.value;
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[key];
|
|
25
|
+
},
|
|
26
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
30
|
+
} catch (err) {
|
|
31
|
+
_didIteratorError = true;
|
|
32
|
+
_iteratorError = err;
|
|
33
|
+
} finally{
|
|
34
|
+
try {
|
|
35
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
36
|
+
_iterator.return();
|
|
37
|
+
}
|
|
38
|
+
} finally{
|
|
39
|
+
if (_didIteratorError) {
|
|
40
|
+
throw _iteratorError;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to;
|
|
9
46
|
};
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
47
|
+
var __toCommonJS = function(mod) {
|
|
48
|
+
return __copyProps(__defProp({}, "__esModule", {
|
|
49
|
+
value: true
|
|
50
|
+
}), mod);
|
|
17
51
|
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
52
|
// src/lib/index.ts
|
|
21
53
|
var lib_exports = {};
|
|
22
54
|
__export(lib_exports, {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
55
|
+
blobToBase64: function() {
|
|
56
|
+
return blobToBase64;
|
|
57
|
+
},
|
|
58
|
+
cn: function() {
|
|
59
|
+
return cn;
|
|
60
|
+
},
|
|
61
|
+
getCookies: function() {
|
|
62
|
+
return getCookies;
|
|
63
|
+
},
|
|
64
|
+
getErrorMessage: function() {
|
|
65
|
+
return getErrorMessage;
|
|
66
|
+
},
|
|
67
|
+
hasToolResult: function() {
|
|
68
|
+
return hasToolResult;
|
|
69
|
+
},
|
|
70
|
+
parseTextToSpeech: function() {
|
|
71
|
+
return parseTextToSpeech;
|
|
72
|
+
},
|
|
73
|
+
truncateString: function() {
|
|
74
|
+
return truncateString;
|
|
75
|
+
}
|
|
30
76
|
});
|
|
31
77
|
module.exports = __toCommonJS(lib_exports);
|
|
32
|
-
|
|
33
78
|
// src/lib/utils.ts
|
|
34
79
|
var import_clsx = require("clsx");
|
|
35
80
|
var import_tailwind_merge = require("tailwind-merge");
|
|
36
|
-
function cn(
|
|
37
|
-
|
|
81
|
+
function cn() {
|
|
82
|
+
for(var _len = arguments.length, inputs = new Array(_len), _key = 0; _key < _len; _key++){
|
|
83
|
+
inputs[_key] = arguments[_key];
|
|
84
|
+
}
|
|
85
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
38
86
|
}
|
|
39
87
|
function parseTextToSpeech(content) {
|
|
40
|
-
|
|
88
|
+
return content.replace(RegExp("[^\\p{L}\\p{N}\\s.,:]", "gu"), "");
|
|
41
89
|
}
|
|
42
90
|
function blobToBase64(blob) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
91
|
+
return new Promise(function(resolve, reject) {
|
|
92
|
+
var reader = new FileReader();
|
|
93
|
+
reader.onloadend = function() {
|
|
94
|
+
return resolve(reader.result);
|
|
95
|
+
};
|
|
96
|
+
reader.onerror = reject;
|
|
97
|
+
reader.readAsDataURL(blob);
|
|
98
|
+
});
|
|
49
99
|
}
|
|
50
|
-
var truncateString = (str, maxLength)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
100
|
+
var truncateString = function(str, maxLength) {
|
|
101
|
+
if (str.length <= maxLength) {
|
|
102
|
+
return str;
|
|
103
|
+
}
|
|
104
|
+
return str.slice(0, maxLength) + "...";
|
|
55
105
|
};
|
|
56
106
|
function getCookies(name) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
107
|
+
var _parts_pop;
|
|
108
|
+
if (typeof document === "undefined") return void 0;
|
|
109
|
+
var value = "; ".concat(document.cookie);
|
|
110
|
+
var parts = value.split("; ".concat(name, "="));
|
|
111
|
+
if (parts.length === 2) return (_parts_pop = parts.pop()) === null || _parts_pop === void 0 ? void 0 : _parts_pop.split(";").shift();
|
|
61
112
|
}
|
|
62
113
|
function hasToolResult(data) {
|
|
63
|
-
|
|
114
|
+
var _data_tool_output;
|
|
115
|
+
return (data === null || data === void 0 ? void 0 : (_data_tool_output = data.tool_output) === null || _data_tool_output === void 0 ? void 0 : _data_tool_output.result) && Object.keys(data.tool_output.result).length > 0;
|
|
64
116
|
}
|
|
65
117
|
function getErrorMessage(error_code) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
118
|
+
switch(error_code){
|
|
119
|
+
case "STREAM_ERROR":
|
|
120
|
+
return "Connection lost. Please try again.";
|
|
121
|
+
case "REQUEST_ERROR":
|
|
122
|
+
return "There was a problem with your request. Please try again.";
|
|
123
|
+
case "401":
|
|
124
|
+
case "403":
|
|
125
|
+
return "You are not authorized. Please try again.";
|
|
126
|
+
case "404":
|
|
127
|
+
return "Resource not found.";
|
|
128
|
+
case "500":
|
|
129
|
+
return "Server error. Please try again later.";
|
|
130
|
+
default:
|
|
131
|
+
return "We have an internal error, please try again later.";
|
|
132
|
+
}
|
|
81
133
|
}
|
|
82
134
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/index.ts","../../src/lib/utils.ts"],"sourcesContent":["export * from \"./utils\";\n","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport function parseTextToSpeech(content: string) {\n return content.replace(/[^\\p{L}\\p{N}\\s.,:]/gu, '');\n}\n\n\nexport function blobToBase64(blob: Blob): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onloadend = () => resolve(reader.result as string);\n reader.onerror = reject;\n reader.readAsDataURL(blob);\n });\n};\n\nexport const truncateString = (str: string, maxLength: number): string => {\n if (str.length <= maxLength) {\n return str;\n }\n return str.slice(0, maxLength) + \"...\";\n};\n\nexport function getCookies(name: string) {\n if (typeof document === 'undefined') return undefined;\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n if (parts.length === 2) return parts.pop()?.split(\";\").shift();\n}\n\nexport function hasToolResult(data: any) {\n return data?.tool_output?.result && Object.keys(data.tool_output.result).length > 0;\n}\n\nexport function getErrorMessage(error_code?: string) {\n switch (error_code) {\n case \"STREAM_ERROR\":\n return \"Connection lost. Please try again.\";\n case \"REQUEST_ERROR\":\n return \"There was a problem with your request. Please try again.\";\n case \"401\":\n case \"403\":\n return \"You are not authorized. Please try again.\";\n case \"404\":\n return \"Resource not found.\";\n case \"500\":\n return \"Server error. Please try again later.\";\n default:\n return \"We have an internal error, please try again later.\";\n }\n}\n"]
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/sdk-frontend/sdk-frontend/packages/ui/dist/lib/index.js","../../src/lib/index.ts","../../src/lib/utils.ts"],"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","lib_exports","blobToBase64","cn","getCookies","getErrorMessage","hasToolResult","parseTextToSpeech","truncateString","module","exports","import_clsx","require","import_tailwind_merge","inputs","twMerge","clsx","content","replace","blob","Promise","resolve","reject","reader","FileReader","onloadend","result","onerror","readAsDataURL","str","maxLength","length","slice","parts","document","cookie","split","pop","shift","data","tool_output","keys","error_code"],"mappings":"AAAA;;;;;AACA,IAAIA,YAAYC,OAAOC,cAAc;AACrC,IAAIC,mBAAmBF,OAAOG,wBAAwB;AACtD,IAAIC,oBAAoBJ,OAAOK,mBAAmB;AAClD,IAAIC,eAAeN,OAAOO,SAAS,CAACC,cAAc;AAClD,IAAIC,WAAW,SAACC,QAAQC;IACtB,IAAK,IAAIC,QAAQD,IACfZ,UAAUW,QAAQE,MAAM;QAAEC,KAAKF,GAAG,CAACC,KAAK;QAAEE,YAAY;IAAK;AAC/D;AACA,IAAIC,cAAc,SAACC,IAAIC,MAAMC,QAAQC;IACnC,IAAIF,QAAQ,CAAA,OAAOA,qCAAP,SAAOA,KAAG,MAAM,YAAY,OAAOA,SAAS,YAAY;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QACnBD,OAAOE,SAAA,GAAY;mBAAMJ,QAAQE,OAAOG,MAAgB;;QACxDH,OAAOI,OAAA,GAAUL;QACjBC,OAAOK,aAAA,CAAcT;IACvB;AACF;AAEO,IAAMX,iBAAiB,SAACqB,KAAaC;IAC1C,IAAID,IAAIE,MAAA,IAAUD,WAAW;QAC3B,OAAOD;IACT;IACA,OAAOA,IAAIG,KAAA,CAAM,GAAGF,aAAa;AACnC;AAEO,SAAS1B,WAAWhB,IAAA;QAIM6C;IAH/B,IAAI,OAAOC,aAAa,aAAa,OAAO,KAAA;IAC5C,IAAMlC,QAAQ,KAAoB,OAAfkC,SAASC,MAAM;IAClC,IAAMF,QAAQjC,MAAMoC,KAAA,CAAM,KAAS,OAAJhD,MAAI;IACnC,IAAI6C,MAAMF,MAAA,KAAW,GAAG,QAAOE,aAAAA,MAAMI,GAAA,gBAANJ,iCAAAA,WAAaG,KAAA,CAAM,KAAKE,KAAA;AACzD;AAEO,SAAShC,cAAciC,IAAA;QACrBA;IAAP,OAAOA,CAAAA,iBAAAA,4BAAAA,oBAAAA,KAAMC,WAAA,cAAND,wCAAAA,kBAAmBb,MAAA,KAAUlD,OAAOiE,IAAA,CAAKF,KAAKC,WAAA,CAAYd,MAAM,EAAEK,MAAA,GAAS;AACpF;AAEO,SAAS1B,gBAAgBqC,UAAA;IAC9B,OAAQA;QACN,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;QACL,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT;YACE,OAAO;IACX;AACF","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/lib/index.ts\nvar lib_exports = {};\n__export(lib_exports, {\n blobToBase64: () => blobToBase64,\n cn: () => cn,\n getCookies: () => getCookies,\n getErrorMessage: () => getErrorMessage,\n hasToolResult: () => hasToolResult,\n parseTextToSpeech: () => parseTextToSpeech,\n truncateString: () => truncateString\n});\nmodule.exports = __toCommonJS(lib_exports);\n\n// src/lib/utils.ts\nvar import_clsx = require(\"clsx\");\nvar import_tailwind_merge = require(\"tailwind-merge\");\nfunction cn(...inputs) {\n return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));\n}\nfunction parseTextToSpeech(content) {\n return content.replace(/[^\\p{L}\\p{N}\\s.,:]/gu, \"\");\n}\nfunction blobToBase64(blob) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onloadend = () => resolve(reader.result);\n reader.onerror = reject;\n reader.readAsDataURL(blob);\n });\n}\nvar truncateString = (str, maxLength) => {\n if (str.length <= maxLength) {\n return str;\n }\n return str.slice(0, maxLength) + \"...\";\n};\nfunction getCookies(name) {\n if (typeof document === \"undefined\") return void 0;\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n if (parts.length === 2) return parts.pop()?.split(\";\").shift();\n}\nfunction hasToolResult(data) {\n return data?.tool_output?.result && Object.keys(data.tool_output.result).length > 0;\n}\nfunction getErrorMessage(error_code) {\n switch (error_code) {\n case \"STREAM_ERROR\":\n return \"Connection lost. Please try again.\";\n case \"REQUEST_ERROR\":\n return \"There was a problem with your request. Please try again.\";\n case \"401\":\n case \"403\":\n return \"You are not authorized. Please try again.\";\n case \"404\":\n return \"Resource not found.\";\n case \"500\":\n return \"Server error. Please try again later.\";\n default:\n return \"We have an internal error, please try again later.\";\n }\n}\n","export * from \"./utils\";\n","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport function parseTextToSpeech(content: string) {\n return content.replace(/[^\\p{L}\\p{N}\\s.,:]/gu, '');\n}\n\n\nexport function blobToBase64(blob: Blob): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onloadend = () => resolve(reader.result as string);\n reader.onerror = reject;\n reader.readAsDataURL(blob);\n });\n};\n\nexport const truncateString = (str: string, maxLength: number): string => {\n if (str.length <= maxLength) {\n return str;\n }\n return str.slice(0, maxLength) + \"...\";\n};\n\nexport function getCookies(name: string) {\n if (typeof document === 'undefined') return undefined;\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n if (parts.length === 2) return parts.pop()?.split(\";\").shift();\n}\n\nexport function hasToolResult(data: any) {\n return data?.tool_output?.result && Object.keys(data.tool_output.result).length > 0;\n}\n\nexport function getErrorMessage(error_code?: string) {\n switch (error_code) {\n case \"STREAM_ERROR\":\n return \"Connection lost. Please try again.\";\n case \"REQUEST_ERROR\":\n return \"There was a problem with your request. Please try again.\";\n case \"401\":\n case \"403\":\n return \"You are not authorized. Please try again.\";\n case \"404\":\n return \"Resource not found.\";\n case \"500\":\n return \"Server error. Please try again later.\";\n default:\n return \"We have an internal error, please try again later.\";\n }\n}\n"]}
|
package/dist/lib/index.mjs
CHANGED
|
@@ -1,59 +1,58 @@
|
|
|
1
1
|
// src/lib/utils.ts
|
|
2
2
|
import { clsx } from "clsx";
|
|
3
3
|
import { twMerge } from "tailwind-merge";
|
|
4
|
-
function cn(
|
|
5
|
-
|
|
4
|
+
function cn() {
|
|
5
|
+
for(var _len = arguments.length, inputs = new Array(_len), _key = 0; _key < _len; _key++){
|
|
6
|
+
inputs[_key] = arguments[_key];
|
|
7
|
+
}
|
|
8
|
+
return twMerge(clsx(inputs));
|
|
6
9
|
}
|
|
7
10
|
function parseTextToSpeech(content) {
|
|
8
|
-
|
|
11
|
+
return content.replace(RegExp("[^\\p{L}\\p{N}\\s.,:]", "gu"), "");
|
|
9
12
|
}
|
|
10
13
|
function blobToBase64(blob) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
return new Promise(function(resolve, reject) {
|
|
15
|
+
var reader = new FileReader();
|
|
16
|
+
reader.onloadend = function() {
|
|
17
|
+
return resolve(reader.result);
|
|
18
|
+
};
|
|
19
|
+
reader.onerror = reject;
|
|
20
|
+
reader.readAsDataURL(blob);
|
|
21
|
+
});
|
|
17
22
|
}
|
|
18
|
-
var truncateString = (str, maxLength)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
var truncateString = function(str, maxLength) {
|
|
24
|
+
if (str.length <= maxLength) {
|
|
25
|
+
return str;
|
|
26
|
+
}
|
|
27
|
+
return str.slice(0, maxLength) + "...";
|
|
23
28
|
};
|
|
24
29
|
function getCookies(name) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
var _parts_pop;
|
|
31
|
+
if (typeof document === "undefined") return void 0;
|
|
32
|
+
var value = "; ".concat(document.cookie);
|
|
33
|
+
var parts = value.split("; ".concat(name, "="));
|
|
34
|
+
if (parts.length === 2) return (_parts_pop = parts.pop()) === null || _parts_pop === void 0 ? void 0 : _parts_pop.split(";").shift();
|
|
29
35
|
}
|
|
30
36
|
function hasToolResult(data) {
|
|
31
|
-
|
|
37
|
+
var _data_tool_output;
|
|
38
|
+
return (data === null || data === void 0 ? void 0 : (_data_tool_output = data.tool_output) === null || _data_tool_output === void 0 ? void 0 : _data_tool_output.result) && Object.keys(data.tool_output.result).length > 0;
|
|
32
39
|
}
|
|
33
40
|
function getErrorMessage(error_code) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
switch(error_code){
|
|
42
|
+
case "STREAM_ERROR":
|
|
43
|
+
return "Connection lost. Please try again.";
|
|
44
|
+
case "REQUEST_ERROR":
|
|
45
|
+
return "There was a problem with your request. Please try again.";
|
|
46
|
+
case "401":
|
|
47
|
+
case "403":
|
|
48
|
+
return "You are not authorized. Please try again.";
|
|
49
|
+
case "404":
|
|
50
|
+
return "Resource not found.";
|
|
51
|
+
case "500":
|
|
52
|
+
return "Server error. Please try again later.";
|
|
53
|
+
default:
|
|
54
|
+
return "We have an internal error, please try again later.";
|
|
55
|
+
}
|
|
49
56
|
}
|
|
50
|
-
export {
|
|
51
|
-
blobToBase64,
|
|
52
|
-
cn,
|
|
53
|
-
getCookies,
|
|
54
|
-
getErrorMessage,
|
|
55
|
-
hasToolResult,
|
|
56
|
-
parseTextToSpeech,
|
|
57
|
-
truncateString
|
|
58
|
-
};
|
|
57
|
+
export { blobToBase64, cn, getCookies, getErrorMessage, hasToolResult, parseTextToSpeech, truncateString };
|
|
59
58
|
//# sourceMappingURL=index.mjs.map
|
package/dist/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/utils.ts"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport function parseTextToSpeech(content: string) {\n return content.replace(/[^\\p{L}\\p{N}\\s.,:]/gu, '');\n}\n\n\nexport function blobToBase64(blob: Blob): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onloadend = () => resolve(reader.result as string);\n reader.onerror = reject;\n reader.readAsDataURL(blob);\n });\n};\n\nexport const truncateString = (str: string, maxLength: number): string => {\n if (str.length <= maxLength) {\n return str;\n }\n return str.slice(0, maxLength) + \"...\";\n};\n\nexport function getCookies(name: string) {\n if (typeof document === 'undefined') return undefined;\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n if (parts.length === 2) return parts.pop()?.split(\";\").shift();\n}\n\nexport function hasToolResult(data: any) {\n return data?.tool_output?.result && Object.keys(data.tool_output.result).length > 0;\n}\n\nexport function getErrorMessage(error_code?: string) {\n switch (error_code) {\n case \"STREAM_ERROR\":\n return \"Connection lost. Please try again.\";\n case \"REQUEST_ERROR\":\n return \"There was a problem with your request. Please try again.\";\n case \"401\":\n case \"403\":\n return \"You are not authorized. Please try again.\";\n case \"404\":\n return \"Resource not found.\";\n case \"500\":\n return \"Server error. Please try again later.\";\n default:\n return \"We have an internal error, please try again later.\";\n }\n}\n"]
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/sdk-frontend/sdk-frontend/packages/ui/dist/lib/index.mjs","../../src/lib/utils.ts"],"names":["clsx","twMerge","cn","inputs","parseTextToSpeech","content","replace","blobToBase64","blob","Promise","resolve","reject","reader","FileReader","onloadend","result","onerror","readAsDataURL","truncateString","str","maxLength","length","slice","getCookies","name","parts","document","value","cookie","split","pop","shift","hasToolResult","data","tool_output","Object","keys","getErrorMessage","error_code"],"mappings":"AAAA,mBAAmB;ACAnB,SAASA,IAAA,QAA6B,OAAA;AACtC,SAASC,OAAA,QAAe,iBAAA;AAEjB,SAASC;IAAA,IAAA,IAAA,OAAA,UAAA,QAAA,AAAMC,SAAN,UAAA,OAAA,OAAA,GAAA,OAAA,MAAA;QAAMA,OAAN,QAAA,SAAA,CAAA,KAAM;;IACpB,OAAOF,QAAQD,KAAKG;AACtB;AAEO,SAASC,kBAAkBC,OAAA;IAChC,OAAOA,QAAQC,OAAA,CAAQ,uCAAwB;AACjD;AAGO,SAASC,aAAaC,IAAA;IAC3B,OAAO,IAAIC,QAAQ,SAACC,SAASC;QAC3B,IAAMC,SAAS,IAAIC;QACnBD,OAAOE,SAAA,GAAY;mBAAMJ,QAAQE,OAAOG,MAAgB;;QACxDH,OAAOI,OAAA,GAAUL;QACjBC,OAAOK,aAAA,CAAcT;IACvB;AACF;AAEO,IAAMU,iBAAiB,SAACC,KAAaC;IAC1C,IAAID,IAAIE,MAAA,IAAUD,WAAW;QAC3B,OAAOD;IACT;IACA,OAAOA,IAAIG,KAAA,CAAM,GAAGF,aAAa;AACnC;AAEO,SAASG,WAAWC,IAAA;QAIMC;IAH/B,IAAI,OAAOC,aAAa,aAAa,OAAO,KAAA;IAC5C,IAAMC,QAAQ,KAAoB,OAAfD,SAASE,MAAM;IAClC,IAAMH,QAAQE,MAAME,KAAA,CAAM,KAAS,OAAJL,MAAI;IACnC,IAAIC,MAAMJ,MAAA,KAAW,GAAG,QAAOI,aAAAA,MAAMK,GAAA,gBAANL,iCAAAA,WAAaI,KAAA,CAAM,KAAKE,KAAA;AACzD;AAEO,SAASC,cAAcC,IAAA;QACrBA;IAAP,OAAOA,CAAAA,iBAAAA,4BAAAA,oBAAAA,KAAMC,WAAA,cAAND,wCAAAA,kBAAmBlB,MAAA,KAAUoB,OAAOC,IAAA,CAAKH,KAAKC,WAAA,CAAYnB,MAAM,EAAEM,MAAA,GAAS;AACpF;AAEO,SAASgB,gBAAgBC,UAAA;IAC9B,OAAQA;QACN,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;QACL,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT;YACE,OAAO;IACX;AACF;ADNA,SACE/B,YAAY,EACZL,EAAE,EACFqB,UAAU,EACVc,eAAe,EACfL,aAAa,EACb5B,iBAAiB,EACjBc,cAAc,GACd","sourcesContent":["// src/lib/utils.ts\nimport { clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\nfunction cn(...inputs) {\n return twMerge(clsx(inputs));\n}\nfunction parseTextToSpeech(content) {\n return content.replace(/[^\\p{L}\\p{N}\\s.,:]/gu, \"\");\n}\nfunction blobToBase64(blob) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onloadend = () => resolve(reader.result);\n reader.onerror = reject;\n reader.readAsDataURL(blob);\n });\n}\nvar truncateString = (str, maxLength) => {\n if (str.length <= maxLength) {\n return str;\n }\n return str.slice(0, maxLength) + \"...\";\n};\nfunction getCookies(name) {\n if (typeof document === \"undefined\") return void 0;\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n if (parts.length === 2) return parts.pop()?.split(\";\").shift();\n}\nfunction hasToolResult(data) {\n return data?.tool_output?.result && Object.keys(data.tool_output.result).length > 0;\n}\nfunction getErrorMessage(error_code) {\n switch (error_code) {\n case \"STREAM_ERROR\":\n return \"Connection lost. Please try again.\";\n case \"REQUEST_ERROR\":\n return \"There was a problem with your request. Please try again.\";\n case \"401\":\n case \"403\":\n return \"You are not authorized. Please try again.\";\n case \"404\":\n return \"Resource not found.\";\n case \"500\":\n return \"Server error. Please try again later.\";\n default:\n return \"We have an internal error, please try again later.\";\n }\n}\nexport {\n blobToBase64,\n cn,\n getCookies,\n getErrorMessage,\n hasToolResult,\n parseTextToSpeech,\n truncateString\n};\n","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport function parseTextToSpeech(content: string) {\n return content.replace(/[^\\p{L}\\p{N}\\s.,:]/gu, '');\n}\n\n\nexport function blobToBase64(blob: Blob): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onloadend = () => resolve(reader.result as string);\n reader.onerror = reject;\n reader.readAsDataURL(blob);\n });\n};\n\nexport const truncateString = (str: string, maxLength: number): string => {\n if (str.length <= maxLength) {\n return str;\n }\n return str.slice(0, maxLength) + \"...\";\n};\n\nexport function getCookies(name: string) {\n if (typeof document === 'undefined') return undefined;\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n if (parts.length === 2) return parts.pop()?.split(\";\").shift();\n}\n\nexport function hasToolResult(data: any) {\n return data?.tool_output?.result && Object.keys(data.tool_output.result).length > 0;\n}\n\nexport function getErrorMessage(error_code?: string) {\n switch (error_code) {\n case \"STREAM_ERROR\":\n return \"Connection lost. Please try again.\";\n case \"REQUEST_ERROR\":\n return \"There was a problem with your request. Please try again.\";\n case \"401\":\n case \"403\":\n return \"You are not authorized. Please try again.\";\n case \"404\":\n return \"Resource not found.\";\n case \"500\":\n return \"Server error. Please try again later.\";\n default:\n return \"We have an internal error, please try again later.\";\n }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
interface AlquimiaUIProviderProps {
|
|
5
|
+
defaultMode?: 'light' | 'dark' | 'system';
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
declare function AlquimiaUIProvider({ defaultMode, children, }: AlquimiaUIProviderProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
interface ThemeContextValue {
|
|
11
|
+
theme: string;
|
|
12
|
+
setTheme: (theme: string) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const ThemeContext: React.Context<ThemeContextValue>;
|
|
15
|
+
declare function useAlquimiaTheme(): ThemeContextValue;
|
|
16
|
+
|
|
17
|
+
export { AlquimiaUIProvider, type AlquimiaUIProviderProps, ThemeContext, useAlquimiaTheme };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
interface AlquimiaUIProviderProps {
|
|
5
|
+
defaultMode?: 'light' | 'dark' | 'system';
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
declare function AlquimiaUIProvider({ defaultMode, children, }: AlquimiaUIProviderProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
interface ThemeContextValue {
|
|
11
|
+
theme: string;
|
|
12
|
+
setTheme: (theme: string) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const ThemeContext: React.Context<ThemeContextValue>;
|
|
15
|
+
declare function useAlquimiaTheme(): ThemeContextValue;
|
|
16
|
+
|
|
17
|
+
export { AlquimiaUIProvider, type AlquimiaUIProviderProps, ThemeContext, useAlquimiaTheme };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function _iterable_to_array_limit(arr, i) {
|
|
11
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
12
|
+
if (_i == null) return;
|
|
13
|
+
var _arr = [];
|
|
14
|
+
var _n = true;
|
|
15
|
+
var _d = false;
|
|
16
|
+
var _s, _e;
|
|
17
|
+
try {
|
|
18
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
19
|
+
_arr.push(_s.value);
|
|
20
|
+
if (i && _arr.length === i) break;
|
|
21
|
+
}
|
|
22
|
+
} catch (err) {
|
|
23
|
+
_d = true;
|
|
24
|
+
_e = err;
|
|
25
|
+
} finally{
|
|
26
|
+
try {
|
|
27
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
28
|
+
} finally{
|
|
29
|
+
if (_d) throw _e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return _arr;
|
|
33
|
+
}
|
|
34
|
+
function _non_iterable_rest() {
|
|
35
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
36
|
+
}
|
|
37
|
+
function _sliced_to_array(arr, i) {
|
|
38
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
39
|
+
}
|
|
40
|
+
function _type_of(obj) {
|
|
41
|
+
"@swc/helpers - typeof";
|
|
42
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
43
|
+
}
|
|
44
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
45
|
+
if (!o) return;
|
|
46
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
47
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
48
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
49
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
50
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
51
|
+
}
|
|
52
|
+
var __create = Object.create;
|
|
53
|
+
var __defProp = Object.defineProperty;
|
|
54
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
55
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
56
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
57
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
58
|
+
var __export = function(target, all) {
|
|
59
|
+
for(var name in all)__defProp(target, name, {
|
|
60
|
+
get: all[name],
|
|
61
|
+
enumerable: true
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
var __copyProps = function(to, from, except, desc) {
|
|
65
|
+
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
66
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
67
|
+
try {
|
|
68
|
+
var _loop = function() {
|
|
69
|
+
var key = _step.value;
|
|
70
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
71
|
+
get: function() {
|
|
72
|
+
return from[key];
|
|
73
|
+
},
|
|
74
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
78
|
+
} catch (err) {
|
|
79
|
+
_didIteratorError = true;
|
|
80
|
+
_iteratorError = err;
|
|
81
|
+
} finally{
|
|
82
|
+
try {
|
|
83
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
84
|
+
_iterator.return();
|
|
85
|
+
}
|
|
86
|
+
} finally{
|
|
87
|
+
if (_didIteratorError) {
|
|
88
|
+
throw _iteratorError;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return to;
|
|
94
|
+
};
|
|
95
|
+
var __toESM = function(mod, isNodeMode, target) {
|
|
96
|
+
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
97
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
98
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
99
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
100
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
101
|
+
value: mod,
|
|
102
|
+
enumerable: true
|
|
103
|
+
}) : target, mod);
|
|
104
|
+
};
|
|
105
|
+
var __toCommonJS = function(mod) {
|
|
106
|
+
return __copyProps(__defProp({}, "__esModule", {
|
|
107
|
+
value: true
|
|
108
|
+
}), mod);
|
|
109
|
+
};
|
|
110
|
+
// src/providers/index.ts
|
|
111
|
+
var providers_exports = {};
|
|
112
|
+
__export(providers_exports, {
|
|
113
|
+
AlquimiaUIProvider: function() {
|
|
114
|
+
return AlquimiaUIProvider;
|
|
115
|
+
},
|
|
116
|
+
ThemeContext: function() {
|
|
117
|
+
return ThemeContext;
|
|
118
|
+
},
|
|
119
|
+
useAlquimiaTheme: function() {
|
|
120
|
+
return useAlquimiaTheme;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
module.exports = __toCommonJS(providers_exports);
|
|
124
|
+
// src/providers/alquimia-ui-provider.tsx
|
|
125
|
+
var React = __toESM(require("react"));
|
|
126
|
+
// src/providers/theme-context.ts
|
|
127
|
+
var import_react = require("react");
|
|
128
|
+
var ThemeContext = (0, import_react.createContext)({
|
|
129
|
+
theme: "system",
|
|
130
|
+
setTheme: function() {}
|
|
131
|
+
});
|
|
132
|
+
function useAlquimiaTheme() {
|
|
133
|
+
return (0, import_react.useContext)(ThemeContext);
|
|
134
|
+
}
|
|
135
|
+
// src/providers/alquimia-ui-provider.tsx
|
|
136
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
137
|
+
function AlquimiaUIProvider(param) {
|
|
138
|
+
var _param_defaultMode = param.defaultMode, defaultMode = _param_defaultMode === void 0 ? "system" : _param_defaultMode, children = param.children;
|
|
139
|
+
var _React_useState = _sliced_to_array(React.useState(function() {
|
|
140
|
+
if (defaultMode !== "system") return defaultMode;
|
|
141
|
+
if (typeof window !== "undefined") {
|
|
142
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
143
|
+
}
|
|
144
|
+
return "light";
|
|
145
|
+
}), 2), resolvedTheme = _React_useState[0], setResolvedTheme = _React_useState[1];
|
|
146
|
+
function applyTheme(theme) {
|
|
147
|
+
if (typeof document !== "undefined") {
|
|
148
|
+
document.documentElement.classList.toggle("dark", theme === "dark");
|
|
149
|
+
}
|
|
150
|
+
setResolvedTheme(theme);
|
|
151
|
+
}
|
|
152
|
+
React.useEffect(function() {
|
|
153
|
+
if (defaultMode !== "system") {
|
|
154
|
+
applyTheme(defaultMode);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
var mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
158
|
+
var handler = function(e) {
|
|
159
|
+
applyTheme(e.matches ? "dark" : "light");
|
|
160
|
+
};
|
|
161
|
+
applyTheme(mediaQuery.matches ? "dark" : "light");
|
|
162
|
+
mediaQuery.addEventListener("change", handler);
|
|
163
|
+
return function() {
|
|
164
|
+
return mediaQuery.removeEventListener("change", handler);
|
|
165
|
+
};
|
|
166
|
+
}, [
|
|
167
|
+
defaultMode
|
|
168
|
+
]);
|
|
169
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, {
|
|
170
|
+
value: {
|
|
171
|
+
theme: resolvedTheme,
|
|
172
|
+
setTheme: applyTheme
|
|
173
|
+
},
|
|
174
|
+
children: children
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/sdk-frontend/sdk-frontend/packages/ui/dist/providers/index.js","../../src/providers/index.ts","../../src/providers/alquimia-ui-provider.tsx","../../src/providers/theme-context.ts"],"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","providers_exports","AlquimiaUIProvider","ThemeContext","useAlquimiaTheme","module","exports","React","require","import_react","createContext","theme","setTheme","useContext","import_jsx_runtime","defaultMode","children","useState","window","matchMedia","matches","resolvedTheme","setResolvedTheme","applyTheme","document","documentElement","classList","toggle","useEffect","mediaQuery","handler","e","addEventListener","removeEventListener","jsx","Provider"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAWT,OAAA,GAAU,SAAS;QACzCS,WAAWG,gBAAA,CAAiB,UAAUF;QACtC,OAAO;mBAAMD,WAAWI,mBAAA,CAAoB,UAAUH;;IACxD,GAAG;QAACf;KAAY;IAEhB,OACE,aAAA,GAAA,CAAA,GAAAD,mBAAAoB,GAAA,EAAC/B,aAAagC,QAAA,EAAb;QAAsBpC,OAAO;YAAEY,OAAOU;YAAeT,UAAUW;QAAW;QACxEP,UAAAA;IAAA;AAGP","sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/providers/index.ts\nvar providers_exports = {};\n__export(providers_exports, {\n AlquimiaUIProvider: () => AlquimiaUIProvider,\n ThemeContext: () => ThemeContext,\n useAlquimiaTheme: () => useAlquimiaTheme\n});\nmodule.exports = __toCommonJS(providers_exports);\n\n// src/providers/alquimia-ui-provider.tsx\nvar React = __toESM(require(\"react\"));\n\n// src/providers/theme-context.ts\nvar import_react = require(\"react\");\nvar ThemeContext = (0, import_react.createContext)({\n theme: \"system\",\n setTheme: () => {\n }\n});\nfunction useAlquimiaTheme() {\n return (0, import_react.useContext)(ThemeContext);\n}\n\n// src/providers/alquimia-ui-provider.tsx\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nfunction AlquimiaUIProvider({\n defaultMode = \"system\",\n children\n}) {\n const [resolvedTheme, setResolvedTheme] = React.useState(() => {\n if (defaultMode !== \"system\") return defaultMode;\n if (typeof window !== \"undefined\") {\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches ? \"dark\" : \"light\";\n }\n return \"light\";\n });\n function applyTheme(theme) {\n if (typeof document !== \"undefined\") {\n document.documentElement.classList.toggle(\"dark\", theme === \"dark\");\n }\n setResolvedTheme(theme);\n }\n React.useEffect(() => {\n if (defaultMode !== \"system\") {\n applyTheme(defaultMode);\n return;\n }\n const mediaQuery = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const handler = (e) => {\n applyTheme(e.matches ? \"dark\" : \"light\");\n };\n applyTheme(mediaQuery.matches ? \"dark\" : \"light\");\n mediaQuery.addEventListener(\"change\", handler);\n return () => mediaQuery.removeEventListener(\"change\", handler);\n }, [defaultMode]);\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value: { theme: resolvedTheme, setTheme: applyTheme }, children });\n}\n","export { AlquimiaUIProvider } from './alquimia-ui-provider';\nexport type { AlquimiaUIProviderProps } from './alquimia-ui-provider';\nexport { useAlquimiaTheme, ThemeContext } from './theme-context';\n","\"use client\";\nimport * as React from 'react';\nimport { ThemeContext } from './theme-context';\n\nexport interface AlquimiaUIProviderProps {\n defaultMode?: 'light' | 'dark' | 'system';\n children: React.ReactNode;\n}\n\nexport function AlquimiaUIProvider({\n defaultMode = 'system',\n children,\n}: AlquimiaUIProviderProps) {\n const [resolvedTheme, setResolvedTheme] = React.useState<string>(() => {\n if (defaultMode !== 'system') return defaultMode;\n if (typeof window !== 'undefined') {\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n }\n return 'light';\n });\n\n function applyTheme(theme: string) {\n if (typeof document !== 'undefined') {\n document.documentElement.classList.toggle('dark', theme === 'dark');\n }\n setResolvedTheme(theme);\n }\n\n React.useEffect(() => {\n if (defaultMode !== 'system') {\n applyTheme(defaultMode);\n return;\n }\n\n const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n const handler = (e: MediaQueryListEvent) => {\n applyTheme(e.matches ? 'dark' : 'light');\n };\n\n applyTheme(mediaQuery.matches ? 'dark' : 'light');\n mediaQuery.addEventListener('change', handler);\n return () => mediaQuery.removeEventListener('change', handler);\n }, [defaultMode]);\n\n return (\n <ThemeContext.Provider value={{ theme: resolvedTheme, setTheme: applyTheme }}>\n {children}\n </ThemeContext.Provider>\n );\n}\n","\"use client\";\nimport { createContext, useContext } from 'react';\n\ninterface ThemeContextValue {\n theme: string;\n setTheme: (theme: string) => void;\n}\n\nexport const ThemeContext = createContext<ThemeContextValue>({\n theme: 'system',\n setTheme: () => {},\n});\n\nexport function useAlquimiaTheme() {\n return useContext(ThemeContext);\n}\n"]}
|