@spinajs/templates-handlebars 2.0.426 → 2.0.427
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/lib/cjs/helpers/comparison.d.ts +106 -0
- package/lib/cjs/helpers/comparison.d.ts.map +1 -0
- package/lib/cjs/helpers/comparison.js +201 -0
- package/lib/cjs/helpers/comparison.js.map +1 -0
- package/lib/cjs/helpers/date.d.ts +113 -0
- package/lib/cjs/helpers/date.d.ts.map +1 -0
- package/lib/cjs/helpers/date.js +438 -0
- package/lib/cjs/helpers/date.js.map +1 -0
- package/lib/cjs/helpers/index.d.ts +6 -0
- package/lib/cjs/helpers/index.d.ts.map +1 -0
- package/lib/cjs/helpers/index.js +22 -0
- package/lib/cjs/helpers/index.js.map +1 -0
- package/lib/cjs/helpers/math.d.ts +117 -0
- package/lib/cjs/helpers/math.d.ts.map +1 -0
- package/lib/cjs/helpers/math.js +206 -0
- package/lib/cjs/helpers/math.js.map +1 -0
- package/lib/cjs/helpers/text.d.ts +142 -0
- package/lib/cjs/helpers/text.d.ts.map +1 -0
- package/lib/cjs/helpers/text.js +271 -0
- package/lib/cjs/helpers/text.js.map +1 -0
- package/lib/cjs/helpers/translation.d.ts +21 -0
- package/lib/cjs/helpers/translation.d.ts.map +1 -0
- package/lib/cjs/helpers/translation.js +36 -0
- package/lib/cjs/helpers/translation.js.map +1 -0
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +6 -31
- package/lib/cjs/index.js.map +1 -1
- package/lib/mjs/helpers/comparison.d.ts +106 -0
- package/lib/mjs/helpers/comparison.d.ts.map +1 -0
- package/lib/mjs/helpers/comparison.js +178 -0
- package/lib/mjs/helpers/comparison.js.map +1 -0
- package/lib/mjs/helpers/date.d.ts +113 -0
- package/lib/mjs/helpers/date.d.ts.map +1 -0
- package/lib/mjs/helpers/date.js +415 -0
- package/lib/mjs/helpers/date.js.map +1 -0
- package/lib/mjs/helpers/index.d.ts +6 -0
- package/lib/mjs/helpers/index.d.ts.map +1 -0
- package/lib/mjs/helpers/index.js +6 -0
- package/lib/mjs/helpers/index.js.map +1 -0
- package/lib/mjs/helpers/math.d.ts +117 -0
- package/lib/mjs/helpers/math.d.ts.map +1 -0
- package/lib/mjs/helpers/math.js +181 -0
- package/lib/mjs/helpers/math.js.map +1 -0
- package/lib/mjs/helpers/text.d.ts +142 -0
- package/lib/mjs/helpers/text.d.ts.map +1 -0
- package/lib/mjs/helpers/text.js +243 -0
- package/lib/mjs/helpers/text.js.map +1 -0
- package/lib/mjs/helpers/translation.d.ts +21 -0
- package/lib/mjs/helpers/translation.d.ts.map +1 -0
- package/lib/mjs/helpers/translation.js +30 -0
- package/lib/mjs/helpers/translation.js.map +1 -0
- package/lib/mjs/index.d.ts.map +1 -1
- package/lib/mjs/index.js +7 -32
- package/lib/mjs/index.js.map +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.add = add;
|
|
4
|
+
exports.subtract = subtract;
|
|
5
|
+
exports.multiply = multiply;
|
|
6
|
+
exports.divide = divide;
|
|
7
|
+
exports.modulo = modulo;
|
|
8
|
+
exports.abs = abs;
|
|
9
|
+
exports.round = round;
|
|
10
|
+
exports.floor = floor;
|
|
11
|
+
exports.ceil = ceil;
|
|
12
|
+
exports.toFixed = toFixed;
|
|
13
|
+
exports.toInt = toInt;
|
|
14
|
+
exports.pow = pow;
|
|
15
|
+
exports.sqrt = sqrt;
|
|
16
|
+
exports.min = min;
|
|
17
|
+
exports.max = max;
|
|
18
|
+
exports.avg = avg;
|
|
19
|
+
exports.sum = sum;
|
|
20
|
+
exports.random = random;
|
|
21
|
+
exports.randomInt = randomInt;
|
|
22
|
+
exports.clamp = clamp;
|
|
23
|
+
exports.percentage = percentage;
|
|
24
|
+
exports.formatNumber = formatNumber;
|
|
25
|
+
exports.currency = currency;
|
|
26
|
+
/**
|
|
27
|
+
* Addition
|
|
28
|
+
* Usage: {{add 5 3}} → 8
|
|
29
|
+
*/
|
|
30
|
+
function add(...args) {
|
|
31
|
+
const values = args.slice(0, -1).map(v => Number(v) || 0);
|
|
32
|
+
return values.reduce((sum, val) => sum + val, 0);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Subtraction
|
|
36
|
+
* Usage: {{subtract 10 3}} → 7
|
|
37
|
+
*/
|
|
38
|
+
function subtract(a, b) {
|
|
39
|
+
return (Number(a) || 0) - (Number(b) || 0);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Multiplication
|
|
43
|
+
* Usage: {{multiply 5 3}} → 15
|
|
44
|
+
*/
|
|
45
|
+
function multiply(...args) {
|
|
46
|
+
const values = args.slice(0, -1).map(v => Number(v) || 0);
|
|
47
|
+
return values.reduce((product, val) => product * val, 1);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Division
|
|
51
|
+
* Usage: {{divide 10 2}} → 5
|
|
52
|
+
*/
|
|
53
|
+
function divide(a, b) {
|
|
54
|
+
const divisor = Number(b) || 1;
|
|
55
|
+
return (Number(a) || 0) / divisor;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Modulo (remainder)
|
|
59
|
+
* Usage: {{modulo 10 3}} → 1
|
|
60
|
+
*/
|
|
61
|
+
function modulo(a, b) {
|
|
62
|
+
return (Number(a) || 0) % (Number(b) || 1);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Absolute value
|
|
66
|
+
* Usage: {{abs -5}} → 5
|
|
67
|
+
*/
|
|
68
|
+
function abs(value) {
|
|
69
|
+
return Math.abs(Number(value) || 0);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Round to nearest integer
|
|
73
|
+
* Usage: {{round 3.7}} → 4
|
|
74
|
+
*/
|
|
75
|
+
function round(value) {
|
|
76
|
+
return Math.round(Number(value) || 0);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Round down (floor)
|
|
80
|
+
* Usage: {{floor 3.7}} → 3
|
|
81
|
+
*/
|
|
82
|
+
function floor(value) {
|
|
83
|
+
return Math.floor(Number(value) || 0);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Round up (ceiling)
|
|
87
|
+
* Usage: {{ceil 3.2}} → 4
|
|
88
|
+
*/
|
|
89
|
+
function ceil(value) {
|
|
90
|
+
return Math.ceil(Number(value) || 0);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Fixed decimal places
|
|
94
|
+
* Usage: {{toFixed 3.14159 2}} → "3.14"
|
|
95
|
+
*/
|
|
96
|
+
function toFixed(value, decimals) {
|
|
97
|
+
return (Number(value) || 0).toFixed(decimals);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Convert to integer (parse as int)
|
|
101
|
+
* Usage: {{toInt "42"}} → 42
|
|
102
|
+
* Usage: {{toInt 3.7}} → 3
|
|
103
|
+
*/
|
|
104
|
+
function toInt(value, radix = 10) {
|
|
105
|
+
return parseInt(String(value), radix) || 0;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Power (exponentiation)
|
|
109
|
+
* Usage: {{pow 2 3}} → 8
|
|
110
|
+
*/
|
|
111
|
+
function pow(base, exponent) {
|
|
112
|
+
return Math.pow(Number(base) || 0, Number(exponent) || 0);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Square root
|
|
116
|
+
* Usage: {{sqrt 16}} → 4
|
|
117
|
+
*/
|
|
118
|
+
function sqrt(value) {
|
|
119
|
+
return Math.sqrt(Number(value) || 0);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Minimum value from arguments
|
|
123
|
+
* Usage: {{min 5 2 8 1}} → 1
|
|
124
|
+
*/
|
|
125
|
+
function min(...args) {
|
|
126
|
+
const values = args.slice(0, -1).map(v => Number(v) || 0);
|
|
127
|
+
return Math.min(...values);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Maximum value from arguments
|
|
131
|
+
* Usage: {{max 5 2 8 1}} → 8
|
|
132
|
+
*/
|
|
133
|
+
function max(...args) {
|
|
134
|
+
const values = args.slice(0, -1).map(v => Number(v) || 0);
|
|
135
|
+
return Math.max(...values);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Average (mean) of values
|
|
139
|
+
* Usage: {{avg 10 20 30}} → 20
|
|
140
|
+
*/
|
|
141
|
+
function avg(...args) {
|
|
142
|
+
const values = args.slice(0, -1).map(v => Number(v) || 0);
|
|
143
|
+
if (values.length === 0)
|
|
144
|
+
return 0;
|
|
145
|
+
return values.reduce((sum, val) => sum + val, 0) / values.length;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Sum of values
|
|
149
|
+
* Usage: {{sum 10 20 30}} → 60
|
|
150
|
+
*/
|
|
151
|
+
function sum(...args) {
|
|
152
|
+
const values = args.slice(0, -1).map(v => Number(v) || 0);
|
|
153
|
+
return values.reduce((sum, val) => sum + val, 0);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Random number between 0 and 1
|
|
157
|
+
* Usage: {{random}}
|
|
158
|
+
*/
|
|
159
|
+
function random() {
|
|
160
|
+
return Math.random();
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Random integer between min and max (inclusive)
|
|
164
|
+
* Usage: {{randomInt 1 10}}
|
|
165
|
+
*/
|
|
166
|
+
function randomInt(min, max) {
|
|
167
|
+
const minVal = Math.ceil(Number(min) || 0);
|
|
168
|
+
const maxVal = Math.floor(Number(max) || 0);
|
|
169
|
+
return Math.floor(Math.random() * (maxVal - minVal + 1)) + minVal;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Clamp value between min and max
|
|
173
|
+
* Usage: {{clamp 15 0 10}} → 10
|
|
174
|
+
*/
|
|
175
|
+
function clamp(value, min, max) {
|
|
176
|
+
const val = Number(value) || 0;
|
|
177
|
+
const minVal = Number(min) || 0;
|
|
178
|
+
const maxVal = Number(max) || 0;
|
|
179
|
+
return Math.min(Math.max(val, minVal), maxVal);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Percentage calculation
|
|
183
|
+
* Usage: {{percentage 25 200}} → 12.5
|
|
184
|
+
*/
|
|
185
|
+
function percentage(value, total) {
|
|
186
|
+
const totalNum = Number(total) || 1;
|
|
187
|
+
return ((Number(value) || 0) / totalNum) * 100;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Format number with thousand separators
|
|
191
|
+
* Usage: {{formatNumber 1234567}} → "1,234,567"
|
|
192
|
+
*/
|
|
193
|
+
function formatNumber(value, locale = 'en-US') {
|
|
194
|
+
return (Number(value) || 0).toLocaleString(locale);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Format as currency
|
|
198
|
+
* Usage: {{currency 1234.56 "USD"}} → "$1,234.56"
|
|
199
|
+
*/
|
|
200
|
+
function currency(value, currencyCode = 'USD', locale = 'en-US') {
|
|
201
|
+
return (Number(value) || 0).toLocaleString(locale, {
|
|
202
|
+
style: 'currency',
|
|
203
|
+
currency: currencyCode,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=math.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.js","sourceRoot":"","sources":["../../../src/helpers/math.ts"],"names":[],"mappings":";;AAIA,kBAGC;AAMD,4BAEC;AAMD,4BAGC;AAMD,wBAGC;AAMD,wBAEC;AAMD,kBAEC;AAMD,sBAEC;AAMD,sBAEC;AAMD,oBAEC;AAMD,0BAEC;AAOD,sBAEC;AAMD,kBAEC;AAMD,oBAEC;AAMD,kBAGC;AAMD,kBAGC;AAMD,kBAIC;AAMD,kBAGC;AAMD,wBAEC;AAMD,8BAIC;AAMD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CAAC,IAAI,CAAC,CAAC;IACpC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,GAAG,CAAC;AACjD,CAAC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAC,KAAU,EAAE,SAAiB,OAAO;IAC/D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,SAAgB,QAAQ,CAAC,KAAU,EAAE,eAAuB,KAAK,EAAE,SAAiB,OAAO;IACzF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE;QACjD,KAAK,EAAE,UAAU;QACjB,QAAQ,EAAE,YAAY;KACvB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Right-aligns text by padding with spaces on the left
|
|
3
|
+
* Usage: {{__textRight "hello" 10}}
|
|
4
|
+
* Result: " hello"
|
|
5
|
+
*
|
|
6
|
+
* @param context - The text to align
|
|
7
|
+
* @param length - The total length of the output string
|
|
8
|
+
* @returns Right-aligned text, truncated if longer than length
|
|
9
|
+
*/
|
|
10
|
+
export declare function __textRight(context: string, length: number): string;
|
|
11
|
+
/**
|
|
12
|
+
* Center-aligns text by padding with spaces on both sides
|
|
13
|
+
* Usage: {{__textCenter "hello" 10}}
|
|
14
|
+
* Result: " hello "
|
|
15
|
+
*
|
|
16
|
+
* @param context - The text to center
|
|
17
|
+
* @param length - The total length of the output string
|
|
18
|
+
* @returns Center-aligned text, truncated if longer than length
|
|
19
|
+
*/
|
|
20
|
+
export declare function __textCenter(context: string, length: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* Convert string to uppercase
|
|
23
|
+
* Usage: {{uppercase "hello"}} → "HELLO"
|
|
24
|
+
*/
|
|
25
|
+
export declare function uppercase(str: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Convert string to lowercase
|
|
28
|
+
* Usage: {{lowercase "HELLO"}} → "hello"
|
|
29
|
+
*/
|
|
30
|
+
export declare function lowercase(str: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Capitalize first letter of string
|
|
33
|
+
* Usage: {{capitalize "hello world"}} → "Hello world"
|
|
34
|
+
*/
|
|
35
|
+
export declare function capitalize(str: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Capitalize first letter of each word
|
|
38
|
+
* Usage: {{capitalizeWords "hello world"}} → "Hello World"
|
|
39
|
+
*/
|
|
40
|
+
export declare function capitalizeWords(str: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Truncate string to specified length with optional suffix
|
|
43
|
+
* Usage: {{truncate "Hello World" 5}} → "Hello..."
|
|
44
|
+
* Usage: {{truncate "Hello World" 5 "…"}} → "Hello…"
|
|
45
|
+
*/
|
|
46
|
+
export declare function truncate(str: string, length: number, suffix?: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Truncate string by word boundary
|
|
49
|
+
* Usage: {{truncateWords "The quick brown fox" 2}} → "The quick..."
|
|
50
|
+
*/
|
|
51
|
+
export declare function truncateWords(str: string, count: number, suffix?: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Reverse string
|
|
54
|
+
* Usage: {{reverse "hello"}} → "olleh"
|
|
55
|
+
*/
|
|
56
|
+
export declare function reverse(str: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Repeat string n times
|
|
59
|
+
* Usage: {{repeat "hi" 3}} → "hihihi"
|
|
60
|
+
*/
|
|
61
|
+
export declare function repeat(str: string, count: number): string;
|
|
62
|
+
/**
|
|
63
|
+
* Replace all occurrences in string
|
|
64
|
+
* Usage: {{replace "hello world" "world" "universe"}} → "hello universe"
|
|
65
|
+
*/
|
|
66
|
+
export declare function replace(str: string, search: string, replacement: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* Trim whitespace from both ends
|
|
69
|
+
* Usage: {{trim " hello "}} → "hello"
|
|
70
|
+
*/
|
|
71
|
+
export declare function trim(str: string): string;
|
|
72
|
+
/**
|
|
73
|
+
* Trim whitespace from left
|
|
74
|
+
* Usage: {{trimLeft " hello"}} → "hello"
|
|
75
|
+
*/
|
|
76
|
+
export declare function trimLeft(str: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* Trim whitespace from right
|
|
79
|
+
* Usage: {{trimRight "hello "}} → "hello"
|
|
80
|
+
*/
|
|
81
|
+
export declare function trimRight(str: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* Split string into array
|
|
84
|
+
* Usage: {{split "a,b,c" ","}} → ["a", "b", "c"]
|
|
85
|
+
*/
|
|
86
|
+
export declare function split(str: string, separator: string): string[];
|
|
87
|
+
/**
|
|
88
|
+
* Join array into string
|
|
89
|
+
* Usage: {{join items ", "}}
|
|
90
|
+
*/
|
|
91
|
+
export declare function join(arr: any[], separator?: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* Get substring
|
|
94
|
+
* Usage: {{substring "hello world" 0 5}} → "hello"
|
|
95
|
+
*/
|
|
96
|
+
export declare function substring(str: string, start: number, end?: number): string;
|
|
97
|
+
/**
|
|
98
|
+
* Get string length
|
|
99
|
+
* Usage: {{length "hello"}} → 5
|
|
100
|
+
*/
|
|
101
|
+
export declare function length(str: string | any[]): number;
|
|
102
|
+
/**
|
|
103
|
+
* Pad string on the left
|
|
104
|
+
* Usage: {{padLeft "5" 3 "0"}} → "005"
|
|
105
|
+
*/
|
|
106
|
+
export declare function padLeft(str: string, length: number, char?: string): string;
|
|
107
|
+
/**
|
|
108
|
+
* Pad string on the right
|
|
109
|
+
* Usage: {{padRight "5" 3 "0"}} → "500"
|
|
110
|
+
*/
|
|
111
|
+
export declare function padRight(str: string, length: number, char?: string): string;
|
|
112
|
+
/**
|
|
113
|
+
* Remove HTML tags from string
|
|
114
|
+
* Usage: {{stripHtml "<p>Hello</p>"}} → "Hello"
|
|
115
|
+
*/
|
|
116
|
+
export declare function stripHtml(str: string): string;
|
|
117
|
+
/**
|
|
118
|
+
* Escape HTML special characters
|
|
119
|
+
* Usage: {{escapeHtml "<div>"}} → "<div>"
|
|
120
|
+
*/
|
|
121
|
+
export declare function escapeHtml(str: string): string;
|
|
122
|
+
/**
|
|
123
|
+
* Convert string to URL-friendly slug
|
|
124
|
+
* Usage: {{slugify "Hello World!"}} → "hello-world"
|
|
125
|
+
*/
|
|
126
|
+
export declare function slugify(str: string): string;
|
|
127
|
+
/**
|
|
128
|
+
* Convert string to camelCase
|
|
129
|
+
* Usage: {{camelCase "hello world"}} → "helloWorld"
|
|
130
|
+
*/
|
|
131
|
+
export declare function camelCase(str: string): string;
|
|
132
|
+
/**
|
|
133
|
+
* Convert string to snake_case
|
|
134
|
+
* Usage: {{snakeCase "helloWorld"}} → "hello_world"
|
|
135
|
+
*/
|
|
136
|
+
export declare function snakeCase(str: string): string;
|
|
137
|
+
/**
|
|
138
|
+
* Convert string to kebab-case
|
|
139
|
+
* Usage: {{kebabCase "helloWorld"}} → "hello-world"
|
|
140
|
+
*/
|
|
141
|
+
export declare function kebabCase(str: string): string;
|
|
142
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/helpers/text.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAKnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CASpE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;GAGG;AACH,wBA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AG,MAAM,CAE1E;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,GAAG,MAAM,CAGlD;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,MAAY,GAAG,MAAM,CAE/E;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,MAAY,GAAG,MAAM,CAEhF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAU9C;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO3C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI7C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM7C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM7C"}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.__textRight = __textRight;
|
|
4
|
+
exports.__textCenter = __textCenter;
|
|
5
|
+
exports.uppercase = uppercase;
|
|
6
|
+
exports.lowercase = lowercase;
|
|
7
|
+
exports.capitalize = capitalize;
|
|
8
|
+
exports.capitalizeWords = capitalizeWords;
|
|
9
|
+
exports.truncate = truncate;
|
|
10
|
+
exports.truncateWords = truncateWords;
|
|
11
|
+
exports.reverse = reverse;
|
|
12
|
+
exports.repeat = repeat;
|
|
13
|
+
exports.replace = replace;
|
|
14
|
+
exports.trim = trim;
|
|
15
|
+
exports.trimLeft = trimLeft;
|
|
16
|
+
exports.trimRight = trimRight;
|
|
17
|
+
exports.split = split;
|
|
18
|
+
exports.join = join;
|
|
19
|
+
exports.substring = substring;
|
|
20
|
+
exports.length = length;
|
|
21
|
+
exports.padLeft = padLeft;
|
|
22
|
+
exports.padRight = padRight;
|
|
23
|
+
exports.stripHtml = stripHtml;
|
|
24
|
+
exports.escapeHtml = escapeHtml;
|
|
25
|
+
exports.slugify = slugify;
|
|
26
|
+
exports.camelCase = camelCase;
|
|
27
|
+
exports.snakeCase = snakeCase;
|
|
28
|
+
exports.kebabCase = kebabCase;
|
|
29
|
+
/**
|
|
30
|
+
* Right-aligns text by padding with spaces on the left
|
|
31
|
+
* Usage: {{__textRight "hello" 10}}
|
|
32
|
+
* Result: " hello"
|
|
33
|
+
*
|
|
34
|
+
* @param context - The text to align
|
|
35
|
+
* @param length - The total length of the output string
|
|
36
|
+
* @returns Right-aligned text, truncated if longer than length
|
|
37
|
+
*/
|
|
38
|
+
function __textRight(context, length) {
|
|
39
|
+
if (context.length > length) {
|
|
40
|
+
return context.substring(0, length);
|
|
41
|
+
}
|
|
42
|
+
return context.padStart(length, ' ');
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Center-aligns text by padding with spaces on both sides
|
|
46
|
+
* Usage: {{__textCenter "hello" 10}}
|
|
47
|
+
* Result: " hello "
|
|
48
|
+
*
|
|
49
|
+
* @param context - The text to center
|
|
50
|
+
* @param length - The total length of the output string
|
|
51
|
+
* @returns Center-aligned text, truncated if longer than length
|
|
52
|
+
*/
|
|
53
|
+
function __textCenter(context, length) {
|
|
54
|
+
if (context.length > length) {
|
|
55
|
+
return context.substring(0, length);
|
|
56
|
+
}
|
|
57
|
+
else if (context.length === length) {
|
|
58
|
+
return context;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const leftPadding = Math.floor((length - context.length) / 2);
|
|
62
|
+
return context.padStart(leftPadding + context.length, ' ').padEnd(length, ' ');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Convert string to uppercase
|
|
67
|
+
* Usage: {{uppercase "hello"}} → "HELLO"
|
|
68
|
+
*/
|
|
69
|
+
function uppercase(str) {
|
|
70
|
+
return String(str || '').toUpperCase();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Convert string to lowercase
|
|
74
|
+
* Usage: {{lowercase "HELLO"}} → "hello"
|
|
75
|
+
*/
|
|
76
|
+
function lowercase(str) {
|
|
77
|
+
return String(str || '').toLowerCase();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Capitalize first letter of string
|
|
81
|
+
* Usage: {{capitalize "hello world"}} → "Hello world"
|
|
82
|
+
*/
|
|
83
|
+
function capitalize(str) {
|
|
84
|
+
const text = String(str || '');
|
|
85
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Capitalize first letter of each word
|
|
89
|
+
* Usage: {{capitalizeWords "hello world"}} → "Hello World"
|
|
90
|
+
*/
|
|
91
|
+
function capitalizeWords(str) {
|
|
92
|
+
return String(str || '')
|
|
93
|
+
.split(' ')
|
|
94
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
95
|
+
.join(' ');
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Truncate string to specified length with optional suffix
|
|
99
|
+
* Usage: {{truncate "Hello World" 5}} → "Hello..."
|
|
100
|
+
* Usage: {{truncate "Hello World" 5 "…"}} → "Hello…"
|
|
101
|
+
*/
|
|
102
|
+
function truncate(str, length, suffix = '...') {
|
|
103
|
+
const text = String(str || '');
|
|
104
|
+
if (text.length <= length)
|
|
105
|
+
return text;
|
|
106
|
+
return text.substring(0, length) + suffix;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Truncate string by word boundary
|
|
110
|
+
* Usage: {{truncateWords "The quick brown fox" 2}} → "The quick..."
|
|
111
|
+
*/
|
|
112
|
+
function truncateWords(str, count, suffix = '...') {
|
|
113
|
+
const words = String(str || '').split(' ');
|
|
114
|
+
if (words.length <= count)
|
|
115
|
+
return str;
|
|
116
|
+
return words.slice(0, count).join(' ') + suffix;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Reverse string
|
|
120
|
+
* Usage: {{reverse "hello"}} → "olleh"
|
|
121
|
+
*/
|
|
122
|
+
function reverse(str) {
|
|
123
|
+
return String(str || '').split('').reverse().join('');
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Repeat string n times
|
|
127
|
+
* Usage: {{repeat "hi" 3}} → "hihihi"
|
|
128
|
+
*/
|
|
129
|
+
function repeat(str, count) {
|
|
130
|
+
return String(str || '').repeat(Math.max(0, count));
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Replace all occurrences in string
|
|
134
|
+
* Usage: {{replace "hello world" "world" "universe"}} → "hello universe"
|
|
135
|
+
*/
|
|
136
|
+
function replace(str, search, replacement) {
|
|
137
|
+
return String(str || '').split(search).join(replacement);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Trim whitespace from both ends
|
|
141
|
+
* Usage: {{trim " hello "}} → "hello"
|
|
142
|
+
*/
|
|
143
|
+
function trim(str) {
|
|
144
|
+
return String(str || '').trim();
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Trim whitespace from left
|
|
148
|
+
* Usage: {{trimLeft " hello"}} → "hello"
|
|
149
|
+
*/
|
|
150
|
+
function trimLeft(str) {
|
|
151
|
+
return String(str || '').trimStart();
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Trim whitespace from right
|
|
155
|
+
* Usage: {{trimRight "hello "}} → "hello"
|
|
156
|
+
*/
|
|
157
|
+
function trimRight(str) {
|
|
158
|
+
return String(str || '').trimEnd();
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Split string into array
|
|
162
|
+
* Usage: {{split "a,b,c" ","}} → ["a", "b", "c"]
|
|
163
|
+
*/
|
|
164
|
+
function split(str, separator) {
|
|
165
|
+
return String(str || '').split(separator);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Join array into string
|
|
169
|
+
* Usage: {{join items ", "}}
|
|
170
|
+
*/
|
|
171
|
+
function join(arr, separator = ', ') {
|
|
172
|
+
if (!Array.isArray(arr))
|
|
173
|
+
return '';
|
|
174
|
+
return arr.join(separator);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Get substring
|
|
178
|
+
* Usage: {{substring "hello world" 0 5}} → "hello"
|
|
179
|
+
*/
|
|
180
|
+
function substring(str, start, end) {
|
|
181
|
+
return String(str || '').substring(start, end);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get string length
|
|
185
|
+
* Usage: {{length "hello"}} → 5
|
|
186
|
+
*/
|
|
187
|
+
function length(str) {
|
|
188
|
+
if (Array.isArray(str))
|
|
189
|
+
return str.length;
|
|
190
|
+
return String(str || '').length;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Pad string on the left
|
|
194
|
+
* Usage: {{padLeft "5" 3 "0"}} → "005"
|
|
195
|
+
*/
|
|
196
|
+
function padLeft(str, length, char = ' ') {
|
|
197
|
+
return String(str || '').padStart(length, char);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Pad string on the right
|
|
201
|
+
* Usage: {{padRight "5" 3 "0"}} → "500"
|
|
202
|
+
*/
|
|
203
|
+
function padRight(str, length, char = ' ') {
|
|
204
|
+
return String(str || '').padEnd(length, char);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Remove HTML tags from string
|
|
208
|
+
* Usage: {{stripHtml "<p>Hello</p>"}} → "Hello"
|
|
209
|
+
*/
|
|
210
|
+
function stripHtml(str) {
|
|
211
|
+
return String(str || '').replace(/<[^>]*>/g, '');
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Escape HTML special characters
|
|
215
|
+
* Usage: {{escapeHtml "<div>"}} → "<div>"
|
|
216
|
+
*/
|
|
217
|
+
function escapeHtml(str) {
|
|
218
|
+
const text = String(str || '');
|
|
219
|
+
const map = {
|
|
220
|
+
'&': '&',
|
|
221
|
+
'<': '<',
|
|
222
|
+
'>': '>',
|
|
223
|
+
'"': '"',
|
|
224
|
+
"'": ''',
|
|
225
|
+
};
|
|
226
|
+
return text.replace(/[&<>"']/g, char => map[char]);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Convert string to URL-friendly slug
|
|
230
|
+
* Usage: {{slugify "Hello World!"}} → "hello-world"
|
|
231
|
+
*/
|
|
232
|
+
function slugify(str) {
|
|
233
|
+
return String(str || '')
|
|
234
|
+
.toLowerCase()
|
|
235
|
+
.trim()
|
|
236
|
+
.replace(/[^\w\s-]/g, '')
|
|
237
|
+
.replace(/[\s_-]+/g, '-')
|
|
238
|
+
.replace(/^-+|-+$/g, '');
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Convert string to camelCase
|
|
242
|
+
* Usage: {{camelCase "hello world"}} → "helloWorld"
|
|
243
|
+
*/
|
|
244
|
+
function camelCase(str) {
|
|
245
|
+
return String(str || '')
|
|
246
|
+
.toLowerCase()
|
|
247
|
+
.replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase());
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Convert string to snake_case
|
|
251
|
+
* Usage: {{snakeCase "helloWorld"}} → "hello_world"
|
|
252
|
+
*/
|
|
253
|
+
function snakeCase(str) {
|
|
254
|
+
return String(str || '')
|
|
255
|
+
.replace(/([A-Z])/g, '_$1')
|
|
256
|
+
.toLowerCase()
|
|
257
|
+
.replace(/[^a-z0-9]+/g, '_')
|
|
258
|
+
.replace(/^_|_$/g, '');
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Convert string to kebab-case
|
|
262
|
+
* Usage: {{kebabCase "helloWorld"}} → "hello-world"
|
|
263
|
+
*/
|
|
264
|
+
function kebabCase(str) {
|
|
265
|
+
return String(str || '')
|
|
266
|
+
.replace(/([A-Z])/g, '-$1')
|
|
267
|
+
.toLowerCase()
|
|
268
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
269
|
+
.replace(/^-|-$/g, '');
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/helpers/text.ts"],"names":[],"mappings":";;AASA,kCAKC;AAWD,oCASC;AAMD,8BAEC;AAMD,8BAEC;AAMD,gCAGC;AAMD,0CAKC;AAOD,4BAIC;AAMD,sCAIC;AAMD,0BAEC;AAMD,wBAEC;AAMD,0BAEC;AAMD,oBAEC;AAMD,4BAEC;AAMD,8BAEC;AAMD,sBAEC;AAMD,oBAGC;AAMD,8BAEC;AAMD,wBAGC;AAMD,0BAEC;AAMD,4BAEC;AAMD,8BAEC;AAMD,gCAUC;AAMD,0BAOC;AAMD,8BAIC;AAMD,8BAMC;AAMD,8BAMC;AApQD;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAAC,OAAe,EAAE,MAAc;IACzD,IAAI,OAAO,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;QAC5B,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,YAAY,CAAC,OAAe,EAAE,MAAc;IAC1D,IAAI,OAAO,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;QAC5B,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;SAAM,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM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,SAAgB,SAAS,CAAC,GAAW;IACnC,OAAO,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC;SACrB,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;SAC1B,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,GAAW;IACnC,OAAO,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC;SACrB,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;SAC1B,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translation helper - translates a key to the current language
|
|
3
|
+
* Usage: {{__ "hello"}}
|
|
4
|
+
*/
|
|
5
|
+
export declare function __(context: string, options: any): string;
|
|
6
|
+
/**
|
|
7
|
+
* Pluralization helper - translates with count-based pluralization
|
|
8
|
+
* Usage: {{__n "items" 5}}
|
|
9
|
+
*/
|
|
10
|
+
export declare function __n(context: string, count: number, options: any): string;
|
|
11
|
+
/**
|
|
12
|
+
* Translation helper for lowercase
|
|
13
|
+
* Usage: {{__l "HELLO"}}
|
|
14
|
+
*/
|
|
15
|
+
export declare function __l(context: string): string[];
|
|
16
|
+
/**
|
|
17
|
+
* Translation helper for HTML content
|
|
18
|
+
* Usage: {{__h "html_content"}}
|
|
19
|
+
*/
|
|
20
|
+
export declare function __h(context: string): any[];
|
|
21
|
+
//# sourceMappingURL=translation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../../src/helpers/translation.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,UAE/C;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,UAE/D;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,YAElC;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,SAElC"}
|