gt-react 8.2.15 → 8.2.17-beta
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/branches/Branch.js +5 -3
- package/dist/branches/Branch.js.map +1 -1
- package/dist/branches/plurals/Plural.js +16 -11
- package/dist/branches/plurals/Plural.js.map +1 -1
- package/dist/branches/plurals/getPluralBranch.js +6 -3
- package/dist/branches/plurals/getPluralBranch.js.map +1 -1
- package/dist/client.js +12 -4
- package/dist/client.js.map +1 -1
- package/dist/hooks/useBrowserLocale.js +13 -10
- package/dist/hooks/useBrowserLocale.js.map +1 -1
- package/dist/hooks/useDefaultLocale.js +9 -3
- package/dist/hooks/useDefaultLocale.js.map +1 -1
- package/dist/hooks/useElement.js +49 -10
- package/dist/hooks/useElement.js.map +1 -1
- package/dist/hooks/useGT.js +11 -5
- package/dist/hooks/useGT.js.map +1 -1
- package/dist/hooks/useLocale.js +9 -3
- package/dist/hooks/useLocale.js.map +1 -1
- package/dist/index.js +30 -13
- package/dist/index.js.map +1 -1
- package/dist/inline/T.d.ts.map +1 -1
- package/dist/inline/T.js +83 -39
- package/dist/inline/T.js.map +1 -1
- package/dist/internal/addGTIdentifier.js +49 -13
- package/dist/internal/addGTIdentifier.js.map +1 -1
- package/dist/internal/flattenDictionary.js +9 -3
- package/dist/internal/flattenDictionary.js.map +1 -1
- package/dist/internal/writeChildrenAsObjects.js +12 -6
- package/dist/internal/writeChildrenAsObjects.js.map +1 -1
- package/dist/internal.d.ts +3 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +68 -14
- package/dist/internal.js.map +1 -1
- package/dist/messages/createMessages.js +32 -16
- package/dist/messages/createMessages.js.map +1 -1
- package/dist/provider/GTContext.js +8 -4
- package/dist/provider/GTContext.js.map +1 -1
- package/dist/provider/GTProvider.d.ts +1 -0
- package/dist/provider/GTProvider.d.ts.map +1 -1
- package/dist/provider/GTProvider.js +57 -58
- package/dist/provider/GTProvider.js.map +1 -1
- package/dist/provider/helpers/extractEntryMetadata.js +4 -1
- package/dist/provider/helpers/extractEntryMetadata.js.map +1 -1
- package/dist/provider/helpers/getDictionaryEntry.d.ts.map +1 -1
- package/dist/provider/helpers/getDictionaryEntry.js +11 -10
- package/dist/provider/helpers/getDictionaryEntry.js.map +1 -1
- package/dist/provider/helpers/getGTProp.js +4 -1
- package/dist/provider/helpers/getGTProp.js.map +1 -1
- package/dist/provider/helpers/isValidDictionaryEntry.js +2 -1
- package/dist/provider/helpers/isVariableObject.js +4 -1
- package/dist/provider/helpers/isVariableObject.js.map +1 -1
- package/dist/provider/rendering/defaultRenderSettings.js +4 -1
- package/dist/provider/rendering/defaultRenderSettings.js.map +1 -1
- package/dist/provider/rendering/renderDefaultChildren.d.ts.map +1 -1
- package/dist/provider/rendering/renderDefaultChildren.js +23 -17
- package/dist/provider/rendering/renderDefaultChildren.js.map +1 -1
- package/dist/provider/rendering/renderSkeleton.js +20 -14
- package/dist/provider/rendering/renderSkeleton.js.map +1 -1
- package/dist/provider/rendering/renderTranslatedChildren.js +42 -36
- package/dist/provider/rendering/renderTranslatedChildren.js.map +1 -1
- package/dist/provider/rendering/renderVariable.js +16 -10
- package/dist/provider/rendering/renderVariable.js.map +1 -1
- package/dist/provider/runtime/useRuntimeTranslation.js +17 -14
- package/dist/provider/runtime/useRuntimeTranslation.js.map +1 -1
- package/dist/types/types.d.ts +3 -12
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +2 -28
- package/dist/types/types.js.map +1 -1
- package/dist/utils/utils.d.ts +1 -2
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +11 -19
- package/dist/utils/utils.js.map +1 -1
- package/dist/variables/Currency.js +13 -8
- package/dist/variables/Currency.js.map +1 -1
- package/dist/variables/DateTime.js +13 -8
- package/dist/variables/DateTime.js.map +1 -1
- package/dist/variables/Num.js +13 -8
- package/dist/variables/Num.js.map +1 -1
- package/dist/variables/Var.d.ts +33 -6
- package/dist/variables/Var.d.ts.map +1 -1
- package/dist/variables/Var.js +38 -9
- package/dist/variables/Var.js.map +1 -1
- package/dist/variables/_getVariableProps.js +9 -3
- package/dist/variables/_getVariableProps.js.map +1 -1
- package/dist/variables/getVariableName.js +9 -4
- package/dist/variables/getVariableName.js.map +1 -1
- package/package.json +1 -1
- package/tsconfig.json +1 -1
package/dist/types/types.d.ts
CHANGED
|
@@ -51,10 +51,7 @@ export type TranslatedElement = {
|
|
|
51
51
|
};
|
|
52
52
|
export type TranslatedChild = TranslatedElement | string | Variable;
|
|
53
53
|
export type TranslatedChildren = TranslatedChild | TranslatedChild[];
|
|
54
|
-
export type TranslatedContent = string | (string |
|
|
55
|
-
key: string;
|
|
56
|
-
variable?: string;
|
|
57
|
-
})[];
|
|
54
|
+
export type TranslatedContent = string | (string | Variable)[];
|
|
58
55
|
export type TranslationError = {
|
|
59
56
|
state: 'error';
|
|
60
57
|
error: string;
|
|
@@ -62,7 +59,7 @@ export type TranslationError = {
|
|
|
62
59
|
};
|
|
63
60
|
export type TranslationSuccess = {
|
|
64
61
|
state: 'success';
|
|
65
|
-
|
|
62
|
+
target: TranslatedChildren | TranslatedContent;
|
|
66
63
|
};
|
|
67
64
|
export type TranslationLoading = {
|
|
68
65
|
state: 'loading';
|
|
@@ -72,7 +69,7 @@ export type TranslationsObject = {
|
|
|
72
69
|
[hash: string]: TranslationSuccess | TranslationLoading | TranslationError;
|
|
73
70
|
};
|
|
74
71
|
};
|
|
75
|
-
export type RenderMethod = 'skeleton' | 'replace' | '
|
|
72
|
+
export type RenderMethod = 'skeleton' | 'replace' | 'default';
|
|
76
73
|
export type TranslateContentCallback = (params: {
|
|
77
74
|
source: any;
|
|
78
75
|
targetLocale: string;
|
|
@@ -95,7 +92,6 @@ export type GTContextType = {
|
|
|
95
92
|
translateChildren: TranslateChildrenCallback;
|
|
96
93
|
locale: string;
|
|
97
94
|
defaultLocale: string;
|
|
98
|
-
dictionary: Dictionary;
|
|
99
95
|
translations: TranslationsObject | null;
|
|
100
96
|
translationRequired: boolean;
|
|
101
97
|
dialectTranslationRequired: boolean;
|
|
@@ -106,9 +102,4 @@ export type GTContextType = {
|
|
|
106
102
|
projectId?: string;
|
|
107
103
|
translationEnabled?: boolean;
|
|
108
104
|
};
|
|
109
|
-
export declare class GTTranslationError extends Error {
|
|
110
|
-
error: string;
|
|
111
|
-
code: number;
|
|
112
|
-
constructor(error: string, code: number);
|
|
113
|
-
}
|
|
114
105
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAI3C,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC;AACpC,MAAM,MAAM,QAAQ,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;AACvC,MAAM,MAAM,MAAM,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACvB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAExB,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,GAAG,aAAa,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG,WAAW,EAAE,GAAG,WAAW,CAAC;AACzD,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAC9E,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAA;AAElE,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,YAAY,CAAC;AAC1C,MAAM,MAAM,QAAQ,GAAG;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,MAAM,CAAC,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C,KAAK,KAAK,CAAC,SAAS,CAAC;IACzF,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C,iBAAiB,EAAE,yBAAyB,CAAC;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACxC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,0BAA0B,EAAE,OAAO,CAAC;IACpC,cAAc,EAAE;QAAE,MAAM,EAAE,YAAY,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAA"}
|
package/dist/types/types.js
CHANGED
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
var GTTranslationError = /** @class */ (function (_super) {
|
|
17
|
-
__extends(GTTranslationError, _super);
|
|
18
|
-
function GTTranslationError(error, code) {
|
|
19
|
-
var _this = _super.call(this, error) || this;
|
|
20
|
-
_this.error = error;
|
|
21
|
-
_this.code = code;
|
|
22
|
-
_this.name = "GTTranslationError";
|
|
23
|
-
_this.code = code;
|
|
24
|
-
return _this;
|
|
25
|
-
}
|
|
26
|
-
return GTTranslationError;
|
|
27
|
-
}(Error));
|
|
28
|
-
export { GTTranslationError };
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
3
|
//# sourceMappingURL=types.js.map
|
package/dist/types/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":""}
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { TaggedElement, TranslatedContent
|
|
1
|
+
import { TaggedElement, TranslatedContent } from "../types/types";
|
|
2
2
|
export declare function isTranslatedContent(target: unknown): target is TranslatedContent;
|
|
3
3
|
export declare function isValidTaggedElement(target: unknown): target is TaggedElement;
|
|
4
|
-
export declare function errorToTranlsationError(error: Error): TranslationError;
|
|
5
4
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAsB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEtF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,iBAAiB,CAsBhF;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,aAAa,CAE7E"}
|
package/dist/utils/utils.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isTranslatedContent = isTranslatedContent;
|
|
7
|
+
exports.isValidTaggedElement = isValidTaggedElement;
|
|
8
|
+
var react_1 = __importDefault(require("react"));
|
|
9
|
+
function isTranslatedContent(target) {
|
|
4
10
|
if (typeof target === 'string') {
|
|
5
11
|
return true;
|
|
6
12
|
}
|
|
@@ -19,21 +25,7 @@ export function isTranslatedContent(target) {
|
|
|
19
25
|
return false;
|
|
20
26
|
});
|
|
21
27
|
}
|
|
22
|
-
|
|
23
|
-
return
|
|
24
|
-
}
|
|
25
|
-
export function errorToTranlsationError(error) {
|
|
26
|
-
if (error instanceof GTTranslationError) {
|
|
27
|
-
return {
|
|
28
|
-
state: 'error',
|
|
29
|
-
error: error.error,
|
|
30
|
-
code: error.code
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
state: 'error',
|
|
35
|
-
error: "".concat(error.name, ": ").concat(error.message),
|
|
36
|
-
code: 500
|
|
37
|
-
};
|
|
28
|
+
function isValidTaggedElement(target) {
|
|
29
|
+
return react_1.default.isValidElement(target);
|
|
38
30
|
}
|
|
39
31
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.tsx"],"names":[],"mappings":";;;;;AAGA,kDAsBC;AAED,oDAEC;AA7BD,gDAA0B;AAG1B,SAAgB,mBAAmB,CAAC,MAAe;IACjD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,UAAA,IAAI;QACtB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAC9C,IAAM,MAAM,GAAG,KAAK,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ,CAAC;YAC7D,IAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,CAAC;YAC1F,OAAO,MAAM,IAAI,gBAAgB,CAAC;QACpC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,oBAAoB,CAAC,MAAe;IAClD,OAAO,eAAK,CAAC,cAAc,CAAqB,MAAM,CAAC,CAAA;AACzD,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __assign = (this && this.__assign) || function () {
|
|
2
3
|
__assign = Object.assign || function(t) {
|
|
3
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -9,10 +10,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
10
|
};
|
|
10
11
|
return __assign.apply(this, arguments);
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
+
var generaltranslation_1 = require("generaltranslation");
|
|
19
|
+
var useLocale_1 = __importDefault(require("../hooks/useLocale"));
|
|
20
|
+
var useDefaultLocale_1 = __importDefault(require("../hooks/useDefaultLocale"));
|
|
16
21
|
/**
|
|
17
22
|
* The `<Currency>` component renders a formatted currency string, allowing customization of name, default value, currency type, and formatting options.
|
|
18
23
|
* Must be used inside a `<GTProvider>`.
|
|
@@ -36,18 +41,18 @@ import useDefaultLocale from '../hooks/useDefaultLocale';
|
|
|
36
41
|
*/
|
|
37
42
|
function Currency(_a) {
|
|
38
43
|
var children = _a.children, value = _a.value, name = _a.name, _b = _a.currency, currency = _b === void 0 ? "USD" : _b, locales = _a.locales, _c = _a.options, options = _c === void 0 ? {} : _c;
|
|
39
|
-
var providerLocales = [
|
|
44
|
+
var providerLocales = [(0, useLocale_1.default)(), (0, useDefaultLocale_1.default)()];
|
|
40
45
|
locales || (locales = providerLocales);
|
|
41
46
|
var renderedValue = (typeof children !== 'undefined' && typeof value === 'undefined') ? children : value;
|
|
42
47
|
renderedValue = (typeof renderedValue === 'string') ? parseFloat(renderedValue) : renderedValue;
|
|
43
48
|
// Format the value using Intl.NumberFormat
|
|
44
49
|
if (typeof renderedValue === 'number') {
|
|
45
|
-
renderedValue = formatCurrency({ value: renderedValue, locales: locales, currency: currency, options: options });
|
|
50
|
+
renderedValue = (0, generaltranslation_1.formatCurrency)({ value: renderedValue, locales: locales, currency: currency, options: options });
|
|
46
51
|
}
|
|
47
|
-
return (
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)("span", { "data-_gt-variable-name": name, "data-_gt-variable-type": "currency", "data-_gt-variable-options": JSON.stringify(__assign({ style: 'currency', currency: currency }, options)), style: { display: 'contents' }, suppressHydrationWarning: true, children: renderedValue }));
|
|
48
53
|
}
|
|
49
54
|
;
|
|
50
55
|
// Static property to indicate the transformation type
|
|
51
56
|
Currency.gtTransformation = "variable-currency";
|
|
52
|
-
|
|
57
|
+
exports.default = Currency;
|
|
53
58
|
//# sourceMappingURL=Currency.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Currency.js","sourceRoot":"","sources":["../../src/variables/Currency.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Currency.js","sourceRoot":"","sources":["../../src/variables/Currency.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,yDAAoD;AACpD,iEAA2C;AAC3C,+EAAyD;AAEzD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,QAAQ,CAAC,EAcjB;QAbG,QAAQ,cAAA,EACR,KAAK,WAAA,EACL,IAAI,UAAA,EACJ,gBAAgB,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAChB,OAAO,aAAA,EACP,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA;IAUZ,IAAM,eAAe,GAAG,CAAC,IAAA,mBAAS,GAAE,EAAE,IAAA,0BAAgB,GAAE,CAAC,CAAA;IACzD,OAAO,KAAP,OAAO,GAAK,eAAe,EAAA;IAE3B,IAAI,aAAa,GAAG,CAAC,OAAO,QAAQ,KAAK,WAAW,IAAI,OAAO,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;IACzG,aAAa,GAAG,CAAC,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IAChG,2CAA2C;IAC3C,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;QACpC,aAAa,GAAG,IAAA,mCAAc,EAAC,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,SAAA,EAAE,QAAQ,UAAA,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC;IACzF,CAAC;IAED,OAAO,CACH,2DAC4B,IAAI,4BACJ,UAAU,+BACP,IAAI,CAAC,SAAS,YAAG,KAAK,EAAE,UAAU,EAAE,QAAQ,UAAA,IAAK,OAAO,EAAG,EACtF,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAC9B,wBAAwB,kBAEvB,aAAa,GACX,CACV,CAAC;AAEN,CAAC;AAAA,CAAC;AAEF,sDAAsD;AACtD,QAAQ,CAAC,gBAAgB,GAAG,mBAAmB,CAAC;AAEhD,kBAAe,QAAQ,CAAC"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
var generaltranslation_1 = require("generaltranslation");
|
|
8
|
+
var useLocale_1 = __importDefault(require("../hooks/useLocale"));
|
|
9
|
+
var useDefaultLocale_1 = __importDefault(require("../hooks/useDefaultLocale"));
|
|
5
10
|
/**
|
|
6
11
|
* The `<DateTime>` component renders a formatted date or time string, allowing customization of the name, default value, and formatting options.
|
|
7
12
|
* It utilizes the current locale and optional format settings to display the date.
|
|
@@ -24,7 +29,7 @@ import useDefaultLocale from '../hooks/useDefaultLocale';
|
|
|
24
29
|
*/
|
|
25
30
|
function DateTime(_a) {
|
|
26
31
|
var children = _a.children, value = _a.value, name = _a.name, locales = _a.locales, _b = _a.options, options = _b === void 0 ? {} : _b;
|
|
27
|
-
var providerLocales = [
|
|
32
|
+
var providerLocales = [(0, useLocale_1.default)(), (0, useDefaultLocale_1.default)()];
|
|
28
33
|
locales || (locales = providerLocales);
|
|
29
34
|
var final;
|
|
30
35
|
var dateValue;
|
|
@@ -39,13 +44,13 @@ function DateTime(_a) {
|
|
|
39
44
|
dateValue = defaultValue;
|
|
40
45
|
}
|
|
41
46
|
if (typeof dateValue !== 'undefined') {
|
|
42
|
-
final = (formatDateTime({ value: dateValue, locales: locales, options: options })).replace(/[\u200F\u202B\u202E]/g, '');
|
|
47
|
+
final = ((0, generaltranslation_1.formatDateTime)({ value: dateValue, locales: locales, options: options })).replace(/[\u200F\u202B\u202E]/g, '');
|
|
43
48
|
}
|
|
44
49
|
// Render the formatted date within a span element
|
|
45
|
-
return (
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)("span", { "data-_gt-variable-name": name, "data-_gt-variable-type": "date", "data-_gt-variable-options": JSON.stringify(options), style: { display: 'contents' }, suppressHydrationWarning: true, children: final }));
|
|
46
51
|
}
|
|
47
52
|
;
|
|
48
53
|
// Static property for transformation type
|
|
49
54
|
DateTime.gtTransformation = "variable-datetime";
|
|
50
|
-
|
|
55
|
+
exports.default = DateTime;
|
|
51
56
|
//# sourceMappingURL=DateTime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTime.js","sourceRoot":"","sources":["../../src/variables/DateTime.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DateTime.js","sourceRoot":"","sources":["../../src/variables/DateTime.tsx"],"names":[],"mappings":";;;;;;AACA,yDAAoD;AACpD,iEAA2C;AAC3C,+EAAyD;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAS,QAAQ,CAAC,EAYjB;QAXG,QAAQ,cAAA,EACR,KAAK,WAAA,EACL,IAAI,UAAA,EACJ,OAAO,aAAA,EACP,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA;IASZ,IAAM,eAAe,GAAG,CAAC,IAAA,mBAAS,GAAE,EAAE,IAAA,0BAAgB,GAAE,CAAC,CAAA;IACzD,OAAO,KAAP,OAAO,GAAK,eAAe,EAAC;IAE5B,IAAI,KAAK,CAAC;IAEV,IAAI,SAA2B,CAAC;IAChC,IAAI,YAAY,GAAG,CAAC,OAAO,QAAQ,KAAK,WAAW,IAAI,OAAO,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;IACxG,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QACnC,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC1C,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,YAAY,YAAY,IAAI,EAAE,CAAC;QACtC,SAAS,GAAG,YAAY,CAAC;IAC7B,CAAC;IACD,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE,CAAC;QACnC,KAAK,GAAG,CAAC,IAAA,mCAAc,EAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,SAAA,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IAC1G,CAAC;IAED,kDAAkD;IAClD,OAAO,CACH,2DAC4B,IAAI,4BACJ,MAAM,+BACH,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAClD,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAC9B,wBAAwB,kBAEvB,KAAK,GACH,CACV,CAAC;AACN,CAAC;AAAA,CAAC;AAEF,0CAA0C;AAC1C,QAAQ,CAAC,gBAAgB,GAAG,mBAAmB,CAAC;AAEhD,kBAAe,QAAQ,CAAC"}
|
package/dist/variables/Num.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
var generaltranslation_1 = require("generaltranslation");
|
|
8
|
+
var useLocale_1 = __importDefault(require("../hooks/useLocale"));
|
|
9
|
+
var useDefaultLocale_1 = __importDefault(require("../hooks/useDefaultLocale"));
|
|
5
10
|
/**
|
|
6
11
|
* The `<Num>` component renders a formatted number string, allowing customization of the name, default value, and formatting options.
|
|
7
12
|
* It formats the number according to the current locale and optionally passed formatting options.
|
|
@@ -25,18 +30,18 @@ import useDefaultLocale from '../hooks/useDefaultLocale';
|
|
|
25
30
|
*/
|
|
26
31
|
function Num(_a) {
|
|
27
32
|
var children = _a.children, value = _a.value, name = _a.name, locales = _a.locales, _b = _a.options, options = _b === void 0 ? {} : _b;
|
|
28
|
-
var providerLocales = [
|
|
33
|
+
var providerLocales = [(0, useLocale_1.default)(), (0, useDefaultLocale_1.default)()];
|
|
29
34
|
locales || (locales = providerLocales);
|
|
30
35
|
var renderedValue = (typeof children !== 'undefined') ? children : value;
|
|
31
36
|
renderedValue = (typeof renderedValue === 'string') ? parseFloat(renderedValue) : renderedValue;
|
|
32
37
|
var formattedValue = renderedValue;
|
|
33
38
|
if (typeof renderedValue === 'number') {
|
|
34
39
|
// Using Intl.NumberFormat for consistent number formatting
|
|
35
|
-
formattedValue = formatNum({ value: renderedValue, locales: locales, options: options });
|
|
40
|
+
formattedValue = (0, generaltranslation_1.formatNum)({ value: renderedValue, locales: locales, options: options });
|
|
36
41
|
}
|
|
37
|
-
return (
|
|
42
|
+
return ((0, jsx_runtime_1.jsx)("span", { "data-_gt-variable-name": name, "data-_gt-variable-type": "number", "data-_gt-variable-options": JSON.stringify(options), style: { display: 'contents' }, suppressHydrationWarning: true, children: formattedValue }));
|
|
38
43
|
}
|
|
39
44
|
;
|
|
40
45
|
Num.gtTransformation = "variable-number";
|
|
41
|
-
|
|
46
|
+
exports.default = Num;
|
|
42
47
|
//# sourceMappingURL=Num.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Num.js","sourceRoot":"","sources":["../../src/variables/Num.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Num.js","sourceRoot":"","sources":["../../src/variables/Num.tsx"],"names":[],"mappings":";;;;;;AAEA,yDAA+C;AAC/C,iEAA2C;AAC3C,+EAAyD;AAEzD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,GAAG,CAAC,EAYZ;QAXG,QAAQ,cAAA,EACR,KAAK,WAAA,EACL,IAAI,UAAA,EACJ,OAAO,aAAA,EACP,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA;IASZ,IAAM,eAAe,GAAG,CAAC,IAAA,mBAAS,GAAE,EAAE,IAAA,0BAAgB,GAAE,CAAC,CAAA;IACzD,OAAO,KAAP,OAAO,GAAK,eAAe,EAAC;IAE5B,IAAI,aAAa,GAAG,CAAC,OAAO,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;IACzE,aAAa,GAAG,CAAC,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IAChG,IAAI,cAAc,GAAG,aAAa,CAAC;IACnC,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;QACpC,2DAA2D;QAC3D,cAAc,GAAG,IAAA,8BAAS,EAAC,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,SAAA,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,CACH,2DAC4B,IAAI,4BACJ,QAAQ,+BACL,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAClD,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAC9B,wBAAwB,kBAEvB,cAAc,GACZ,CACV,CAAC;AACN,CAAC;AAAA,CAAC;AAEF,GAAG,CAAC,gBAAgB,GAAG,iBAAiB,CAAC;AAEzC,kBAAe,GAAG,CAAC"}
|
package/dist/variables/Var.d.ts
CHANGED
|
@@ -3,15 +3,42 @@ import React from "react";
|
|
|
3
3
|
* The `<Var>` component renders a variable value, which can either be passed as `children` or a `value`.
|
|
4
4
|
* If `children` is provided, it will be used; otherwise, the `value` is rendered.
|
|
5
5
|
*
|
|
6
|
-
* @example
|
|
6
|
+
* @example Inline usage:
|
|
7
7
|
* ```jsx
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* >
|
|
11
|
-
*
|
|
12
|
-
* </Var
|
|
8
|
+
* function MyComponent() {
|
|
9
|
+
* return (
|
|
10
|
+
* <T id="user">
|
|
11
|
+
* <p>
|
|
12
|
+
* Hello, <Var> John </Var>!
|
|
13
|
+
* </p>
|
|
14
|
+
* </T>
|
|
15
|
+
* );
|
|
16
|
+
* }
|
|
13
17
|
* ```
|
|
14
18
|
*
|
|
19
|
+
* @example Dictionary Usage:
|
|
20
|
+
* ```jsx
|
|
21
|
+
* // dictionary.jsx
|
|
22
|
+
* const dictionary = {
|
|
23
|
+
* user: (
|
|
24
|
+
* <>
|
|
25
|
+
* Hello, <Var name="user-name" />! Your dog's name is <Var name="dog-name"/>.
|
|
26
|
+
* </>
|
|
27
|
+
* ),
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* // component.jsx
|
|
31
|
+
* function MyComponent() {
|
|
32
|
+
* const t = useGT();
|
|
33
|
+
* return (
|
|
34
|
+
* <p>
|
|
35
|
+
* { t('user', { 'user-name': 'John', 'dog-name': 'Rex' }) }
|
|
36
|
+
* </p>
|
|
37
|
+
* );
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
*
|
|
15
42
|
* @param {any} [children] - The content to render inside the component. If provided, it will take precedence over `value`.
|
|
16
43
|
* @param {string} [name] - Optional name for the variable, used for metadata purposes.
|
|
17
44
|
* @param {any} [value] - The default value to be displayed if `children` is not provided.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Var.d.ts","sourceRoot":"","sources":["../../src/variables/Var.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B
|
|
1
|
+
{"version":3,"file":"Var.d.ts","sourceRoot":"","sources":["../../src/variables/Var.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,iBAAS,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACpC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,GAAG,CAAC;CACf,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAcpB;kBAlBQ,GAAG;;;AAsBZ,eAAe,GAAG,CAAC"}
|
package/dist/variables/Var.js
CHANGED
|
@@ -1,17 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
4
|
/**
|
|
3
5
|
* The `<Var>` component renders a variable value, which can either be passed as `children` or a `value`.
|
|
4
6
|
* If `children` is provided, it will be used; otherwise, the `value` is rendered.
|
|
5
7
|
*
|
|
6
|
-
* @example
|
|
8
|
+
* @example Inline usage:
|
|
7
9
|
* ```jsx
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* >
|
|
11
|
-
*
|
|
12
|
-
* </Var
|
|
10
|
+
* function MyComponent() {
|
|
11
|
+
* return (
|
|
12
|
+
* <T id="user">
|
|
13
|
+
* <p>
|
|
14
|
+
* Hello, <Var> John </Var>!
|
|
15
|
+
* </p>
|
|
16
|
+
* </T>
|
|
17
|
+
* );
|
|
18
|
+
* }
|
|
13
19
|
* ```
|
|
14
20
|
*
|
|
21
|
+
* @example Dictionary Usage:
|
|
22
|
+
* ```jsx
|
|
23
|
+
* // dictionary.jsx
|
|
24
|
+
* const dictionary = {
|
|
25
|
+
* user: (
|
|
26
|
+
* <>
|
|
27
|
+
* Hello, <Var name="user-name" />! Your dog's name is <Var name="dog-name"/>.
|
|
28
|
+
* </>
|
|
29
|
+
* ),
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* // component.jsx
|
|
33
|
+
* function MyComponent() {
|
|
34
|
+
* const t = useGT();
|
|
35
|
+
* return (
|
|
36
|
+
* <p>
|
|
37
|
+
* { t('user', { 'user-name': 'John', 'dog-name': 'Rex' }) }
|
|
38
|
+
* </p>
|
|
39
|
+
* );
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
*
|
|
15
44
|
* @param {any} [children] - The content to render inside the component. If provided, it will take precedence over `value`.
|
|
16
45
|
* @param {string} [name] - Optional name for the variable, used for metadata purposes.
|
|
17
46
|
* @param {any} [value] - The default value to be displayed if `children` is not provided.
|
|
@@ -20,9 +49,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
20
49
|
function Var(_a) {
|
|
21
50
|
var children = _a.children, name = _a.name, value = _a.value;
|
|
22
51
|
var final = typeof children !== 'undefined' ? children : value;
|
|
23
|
-
return (
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)("span", { "data-_gt-variable-name": name, "data-_gt-variable-type": "variable", style: { display: 'contents' }, children: final }));
|
|
24
53
|
}
|
|
25
54
|
;
|
|
26
55
|
Var.gtTransformation = "variable-variable";
|
|
27
|
-
|
|
56
|
+
exports.default = Var;
|
|
28
57
|
//# sourceMappingURL=Var.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Var.js","sourceRoot":"","sources":["../../src/variables/Var.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Var.js","sourceRoot":"","sources":["../../src/variables/Var.tsx"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,SAAS,GAAG,CAAC,EAIZ;QAJc,QAAQ,cAAA,EAAE,IAAI,UAAA,EAAE,KAAK,WAAA;IAMhC,IAAI,KAAK,GAAG,OAAO,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;IAE/D,OAAO,CACH,2DAC4B,IAAI,4BACJ,UAAU,EAClC,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,YAE7B,KAAK,GACH,CACV,CAAC;AAEN,CAAC;AAAA,CAAC;AAEF,GAAG,CAAC,gBAAgB,GAAG,mBAAmB,CAAC;AAE3C,kBAAe,GAAG,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __assign = (this && this.__assign) || function () {
|
|
2
3
|
__assign = Object.assign || function(t) {
|
|
3
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -9,13 +10,18 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
10
|
};
|
|
10
11
|
return __assign.apply(this, arguments);
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.default = getVariableProps;
|
|
18
|
+
var getVariableName_1 = __importDefault(require("./getVariableName"));
|
|
19
|
+
function getVariableProps(props) {
|
|
14
20
|
var _a;
|
|
15
21
|
var variableType = ((_a = props['data-_gt']) === null || _a === void 0 ? void 0 : _a.variableType) || "variable";
|
|
16
22
|
var result = {
|
|
17
23
|
variableType: variableType,
|
|
18
|
-
variableName:
|
|
24
|
+
variableName: (0, getVariableName_1.default)(props, variableType),
|
|
19
25
|
variableValue: (function () {
|
|
20
26
|
if (typeof props.value !== 'undefined')
|
|
21
27
|
return props.value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_getVariableProps.js","sourceRoot":"","sources":["../../src/variables/_getVariableProps.ts"],"names":[],"mappings":"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P,CAAC;IAEF,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.baseVariablePrefix = void 0;
|
|
4
|
+
exports.getFallbackVariableName = getFallbackVariableName;
|
|
5
|
+
exports.default = getVariableName;
|
|
1
6
|
var defaultVariableNames = {
|
|
2
7
|
"variable": "value",
|
|
3
8
|
"number": "n",
|
|
4
9
|
"datetime": "date",
|
|
5
10
|
"currency": "cost"
|
|
6
11
|
};
|
|
7
|
-
|
|
12
|
+
function getFallbackVariableName(variableType) {
|
|
8
13
|
if (variableType === void 0) { variableType = "variable"; }
|
|
9
14
|
return defaultVariableNames[variableType] || "variable";
|
|
10
15
|
}
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
exports.baseVariablePrefix = "_gt_";
|
|
17
|
+
function getVariableName(props, variableType) {
|
|
13
18
|
var _a;
|
|
14
19
|
if (props === void 0) { props = {}; }
|
|
15
20
|
if (props.name)
|
|
@@ -17,6 +22,6 @@ export default function getVariableName(props, variableType) {
|
|
|
17
22
|
if (props['data-_gt-variable-name'])
|
|
18
23
|
return props['data-_gt-variable-name'];
|
|
19
24
|
var baseVariableName = defaultVariableNames[variableType] || "value";
|
|
20
|
-
return "".concat(baseVariablePrefix).concat(baseVariableName, "_").concat((_a = props['data-_gt']) === null || _a === void 0 ? void 0 : _a.id);
|
|
25
|
+
return "".concat(exports.baseVariablePrefix).concat(baseVariableName, "_").concat((_a = props['data-_gt']) === null || _a === void 0 ? void 0 : _a.id);
|
|
21
26
|
}
|
|
22
27
|
//# sourceMappingURL=getVariableName.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getVariableName.js","sourceRoot":"","sources":["../../src/variables/getVariableName.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getVariableName.js","sourceRoot":"","sources":["../../src/variables/getVariableName.ts"],"names":[],"mappings":";;;AAOA,0DAEC;AAID,kCAKC;AAlBD,IAAM,oBAAoB,GAAG;IACzB,UAAU,EAAE,OAAO;IACnB,QAAQ,EAAE,GAAG;IACb,UAAU,EAAE,MAAM;IAClB,UAAU,EAAE,MAAM;CACZ,CAAC;AAEX,SAAgB,uBAAuB,CAAC,YAAiC;IAAjC,6BAAA,EAAA,yBAAiC;IACrE,OAAQ,oBAA4B,CAAC,YAAY,CAAC,IAAI,UAAU,CAAC;AACrE,CAAC;AAEY,QAAA,kBAAkB,GAAG,MAAM,CAAC;AAEzC,SAAwB,eAAe,CAAC,KAA+B,EAAE,YAAoB;;IAArD,sBAAA,EAAA,UAA+B;IACnE,IAAI,KAAK,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC;IAClC,IAAI,KAAK,CAAC,wBAAwB,CAAC;QAAE,OAAO,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5E,IAAM,gBAAgB,GAAI,oBAA4C,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC;IAChG,OAAO,UAAG,0BAAkB,SAAG,gBAAgB,cAAI,MAAA,KAAK,CAAC,UAAU,CAAC,0CAAE,EAAE,CAAE,CAAA;AAC9E,CAAC"}
|
package/package.json
CHANGED