@attrx/role-morphic 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +151 -84
- package/dist/cast.d.mts +678 -0
- package/dist/cast.d.ts +678 -0
- package/dist/cast.js +3569 -0
- package/dist/cast.js.map +1 -0
- package/dist/cast.mjs +3536 -0
- package/dist/cast.mjs.map +1 -0
- package/dist/constants-BZdBwuvJ.d.mts +168 -0
- package/dist/constants-BZdBwuvJ.d.ts +168 -0
- package/dist/convert.d.mts +1157 -0
- package/dist/convert.d.ts +1157 -0
- package/dist/convert.js +2244 -0
- package/dist/convert.js.map +1 -0
- package/dist/convert.mjs +2148 -0
- package/dist/convert.mjs.map +1 -0
- package/dist/format-Be15LzfS.d.ts +668 -0
- package/dist/format-o4Y3jPH-.d.mts +668 -0
- package/dist/format.d.mts +3 -0
- package/dist/format.d.ts +3 -0
- package/dist/format.js +2303 -0
- package/dist/format.js.map +1 -0
- package/dist/format.mjs +2286 -0
- package/dist/format.mjs.map +1 -0
- package/dist/index.d.mts +200 -601
- package/dist/index.d.ts +200 -601
- package/dist/index.js +5536 -2493
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5349 -2494
- package/dist/index.mjs.map +1 -1
- package/dist/types-mbeS1e-k.d.mts +312 -0
- package/dist/types-mbeS1e-k.d.ts +312 -0
- package/dist/validate.d.mts +884 -0
- package/dist/validate.d.ts +884 -0
- package/dist/validate.js +713 -0
- package/dist/validate.js.map +1 -0
- package/dist/validate.mjs +669 -0
- package/dist/validate.mjs.map +1 -0
- package/package.json +21 -1
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
import { A as AreaUnit, L as LengthUnit, M as MassUnit, V as VolumeUnit, S as SpeedUnit, E as EnergyUnit, P as PowerUnit, b as PressureUnit, F as FrequencyUnit, a as AngleUnit, T as TimeUnit, D as DigitalUnit } from './constants-BZdBwuvJ.js';
|
|
2
|
+
import { T as TemperatureUnit, r as ColorVariant, e as ColorFormatOptions, o as DateVariant, c as DateFormatOptions } from './types-mbeS1e-k.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Area Role - Format Pillar
|
|
6
|
+
*
|
|
7
|
+
* Formata valores de área para apresentação.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* import { formatArea } from '@attrx/role-morphic/area/format';
|
|
11
|
+
*
|
|
12
|
+
* formatArea('hectare', 2.5); // "2.5 ha"
|
|
13
|
+
* formatArea('hectare', 2.5, { verbose: true }); // "2.5 hectares"
|
|
14
|
+
* formatArea('hectare', 1000, { locale: 'pt-BR' }); // "1.000 ha"
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
interface AreaFormatOptions {
|
|
18
|
+
/** Casas decimais (default: 2) */
|
|
19
|
+
decimals?: number;
|
|
20
|
+
/** Usa nome completo ao invés de símbolo */
|
|
21
|
+
verbose?: boolean;
|
|
22
|
+
/** Locale para formatação de número */
|
|
23
|
+
locale?: string;
|
|
24
|
+
/** Notação numérica */
|
|
25
|
+
notation?: "standard" | "scientific" | "compact";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Formata valor de área para apresentação
|
|
29
|
+
*
|
|
30
|
+
* @param variant - Unidade do valor
|
|
31
|
+
* @param value - Valor numérico
|
|
32
|
+
* @param options - Opções de formatação
|
|
33
|
+
* @returns String formatada
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* formatArea('hectare', 2.5); // "2.5 ha"
|
|
37
|
+
* formatArea('hectare', 2.5, { verbose: true }); // "2.5 hectares"
|
|
38
|
+
* formatArea('hectare', 1, { verbose: true }); // "1 hectare"
|
|
39
|
+
* formatArea('hectare', 1000, { locale: 'pt-BR' }); // "1.000 ha"
|
|
40
|
+
* formatArea('hectare', 1500, { decimals: 0 }); // "1500 ha"
|
|
41
|
+
*/
|
|
42
|
+
declare function formatArea(variant: AreaUnit, value: number, options?: AreaFormatOptions): string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Length Role - Format Pillar
|
|
46
|
+
*
|
|
47
|
+
* Formata valores de comprimento para apresentação.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* import { formatLength } from '@attrx/role-morphic/length/format';
|
|
51
|
+
*
|
|
52
|
+
* formatLength('kilometer', 42.195); // "42.2 km"
|
|
53
|
+
* formatLength('kilometer', 42.195, { verbose: true }); // "42.2 kilometers"
|
|
54
|
+
* formatLength('meter', 1000, { locale: 'pt-BR' }); // "1.000 m"
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
interface LengthFormatOptions {
|
|
58
|
+
/** Casas decimais (default: 2) */
|
|
59
|
+
decimals?: number;
|
|
60
|
+
/** Usa nome completo ao invés de símbolo */
|
|
61
|
+
verbose?: boolean;
|
|
62
|
+
/** Locale para formatação de número */
|
|
63
|
+
locale?: string;
|
|
64
|
+
/** Notação numérica */
|
|
65
|
+
notation?: "standard" | "scientific" | "compact";
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Formata valor de comprimento para apresentação
|
|
69
|
+
*
|
|
70
|
+
* @param variant - Unidade do valor
|
|
71
|
+
* @param value - Valor numérico
|
|
72
|
+
* @param options - Opções de formatação
|
|
73
|
+
* @returns String formatada
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* formatLength('kilometer', 42.195); // "42.2 km"
|
|
77
|
+
* formatLength('kilometer', 42.195, { verbose: true }); // "42.2 kilometers"
|
|
78
|
+
* formatLength('kilometer', 1, { verbose: true }); // "1 kilometer"
|
|
79
|
+
* formatLength('meter', 1000, { locale: 'pt-BR' }); // "1.000 m"
|
|
80
|
+
* formatLength('meter', 1500, { decimals: 0 }); // "1500 m"
|
|
81
|
+
*/
|
|
82
|
+
declare function formatLength(variant: LengthUnit, value: number, options?: LengthFormatOptions): string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Mass Role - Format Pillar
|
|
86
|
+
*
|
|
87
|
+
* Formata valores de massa para apresentação.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* import { formatMass } from '@attrx/role-morphic/mass/format';
|
|
91
|
+
*
|
|
92
|
+
* formatMass('kilogram', 75.5); // "75.5 kg"
|
|
93
|
+
* formatMass('kilogram', 75.5, { verbose: true }); // "75.5 kilograms"
|
|
94
|
+
* formatMass('pound', 1000, { locale: 'en-US' }); // "1,000 lb"
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
interface MassFormatOptions {
|
|
98
|
+
/** Casas decimais (default: 2) */
|
|
99
|
+
decimals?: number;
|
|
100
|
+
/** Usa nome completo ao invés de símbolo */
|
|
101
|
+
verbose?: boolean;
|
|
102
|
+
/** Locale para formatação de número */
|
|
103
|
+
locale?: string;
|
|
104
|
+
/** Notação numérica */
|
|
105
|
+
notation?: "standard" | "scientific" | "compact";
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Formata valor de massa para apresentação
|
|
109
|
+
*
|
|
110
|
+
* @param variant - Unidade do valor
|
|
111
|
+
* @param value - Valor numérico
|
|
112
|
+
* @param options - Opções de formatação
|
|
113
|
+
* @returns String formatada
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* formatMass('kilogram', 75.5); // "75.5 kg"
|
|
117
|
+
* formatMass('kilogram', 75.5, { verbose: true }); // "75.5 kilograms"
|
|
118
|
+
* formatMass('kilogram', 1, { verbose: true }); // "1 kilogram"
|
|
119
|
+
* formatMass('pound', 1000, { locale: 'en-US' }); // "1,000 lb"
|
|
120
|
+
* formatMass('gram', 1500, { decimals: 0 }); // "1500 g"
|
|
121
|
+
*/
|
|
122
|
+
declare function formatMass(variant: MassUnit, value: number, options?: MassFormatOptions): string;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Temperature Role - Format Pillar
|
|
126
|
+
*
|
|
127
|
+
* Formata valores de temperatura para apresentação.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* import { formatTemperature } from '@attrx/role-morphic/temperature/format';
|
|
131
|
+
*
|
|
132
|
+
* formatTemperature('celsius', 37); // "37°C"
|
|
133
|
+
* formatTemperature('fahrenheit', 98.6, { verbose: true }); // "98.6 degrees Fahrenheit"
|
|
134
|
+
* formatTemperature('kelvin', 273.15); // "273.15 K"
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
interface TemperatureFormatOptions {
|
|
138
|
+
/** Casas decimais (default: 2) */
|
|
139
|
+
decimals?: number;
|
|
140
|
+
/** Usa nome completo ao invés de símbolo */
|
|
141
|
+
verbose?: boolean;
|
|
142
|
+
/** Locale para formatação de número */
|
|
143
|
+
locale?: string;
|
|
144
|
+
/** Notação numérica */
|
|
145
|
+
notation?: "standard" | "scientific" | "compact";
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Formata valor de temperatura para apresentação
|
|
149
|
+
*
|
|
150
|
+
* @param variant - Unidade do valor
|
|
151
|
+
* @param value - Valor numérico
|
|
152
|
+
* @param options - Opções de formatação
|
|
153
|
+
* @returns String formatada
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* formatTemperature('celsius', 37); // "37°C"
|
|
157
|
+
* formatTemperature('fahrenheit', 98.6); // "98.6°F"
|
|
158
|
+
* formatTemperature('kelvin', 273.15); // "273.15 K"
|
|
159
|
+
* formatTemperature('celsius', 37, { verbose: true }); // "37 degrees Celsius"
|
|
160
|
+
* formatTemperature('celsius', 1000, { locale: 'pt-BR' }); // "1.000°C"
|
|
161
|
+
*/
|
|
162
|
+
declare function formatTemperature(variant: TemperatureUnit, value: number, options?: TemperatureFormatOptions): string;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Volume Role - Format Pillar
|
|
166
|
+
*
|
|
167
|
+
* Formata valores de volume para apresentação.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* import { formatVolume } from '@attrx/role-morphic/volume/format';
|
|
171
|
+
*
|
|
172
|
+
* formatVolume('liter', 2.5); // "2.5 L"
|
|
173
|
+
* formatVolume('liter', 2.5, { verbose: true }); // "2.5 liters"
|
|
174
|
+
* formatVolume('milliliter', 1000, { locale: 'pt-BR' }); // "1.000 mL"
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
interface VolumeFormatOptions {
|
|
178
|
+
/** Casas decimais (default: 2) */
|
|
179
|
+
decimals?: number;
|
|
180
|
+
/** Usa nome completo ao invés de símbolo */
|
|
181
|
+
verbose?: boolean;
|
|
182
|
+
/** Locale para formatação de número */
|
|
183
|
+
locale?: string;
|
|
184
|
+
/** Notação numérica */
|
|
185
|
+
notation?: "standard" | "scientific" | "compact";
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Formata valor de volume para apresentação
|
|
189
|
+
*
|
|
190
|
+
* @param variant - Unidade do valor
|
|
191
|
+
* @param value - Valor numérico
|
|
192
|
+
* @param options - Opções de formatação
|
|
193
|
+
* @returns String formatada
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* formatVolume('liter', 2.5); // "2.5 L"
|
|
197
|
+
* formatVolume('liter', 2.5, { verbose: true }); // "2.5 liters"
|
|
198
|
+
* formatVolume('liter', 1, { verbose: true }); // "1 liter"
|
|
199
|
+
* formatVolume('milliliter', 1000, { locale: 'pt-BR' }); // "1.000 mL"
|
|
200
|
+
* formatVolume('gallon_us', 5, { decimals: 0 }); // "5 gal"
|
|
201
|
+
*/
|
|
202
|
+
declare function formatVolume(variant: VolumeUnit, value: number, options?: VolumeFormatOptions): string;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Speed Role - Format Pillar
|
|
206
|
+
*
|
|
207
|
+
* Formata valores de velocidade para apresentação.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* import { formatSpeed } from '@attrx/role-morphic/speed/format';
|
|
211
|
+
*
|
|
212
|
+
* formatSpeed('kilometer_per_hour', 120); // "120 km/h"
|
|
213
|
+
* formatSpeed('kilometer_per_hour', 120, { verbose: true }); // "120 kilometers per hour"
|
|
214
|
+
* formatSpeed('mile_per_hour', 60); // "60 mph"
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
interface SpeedFormatOptions {
|
|
218
|
+
/** Casas decimais (default: 2) */
|
|
219
|
+
decimals?: number;
|
|
220
|
+
/** Usa nome completo ao invés de símbolo */
|
|
221
|
+
verbose?: boolean;
|
|
222
|
+
/** Locale para formatação de número */
|
|
223
|
+
locale?: string;
|
|
224
|
+
/** Notação numérica */
|
|
225
|
+
notation?: "standard" | "scientific" | "compact";
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Formata valor de velocidade para apresentação
|
|
229
|
+
*
|
|
230
|
+
* @param variant - Unidade do valor
|
|
231
|
+
* @param value - Valor numérico
|
|
232
|
+
* @param options - Opções de formatação
|
|
233
|
+
* @returns String formatada
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* formatSpeed('kilometer_per_hour', 120); // "120 km/h"
|
|
237
|
+
* formatSpeed('kilometer_per_hour', 120, { verbose: true }); // "120 kilometers per hour"
|
|
238
|
+
* formatSpeed('kilometer_per_hour', 1, { verbose: true }); // "1 kilometer per hour"
|
|
239
|
+
* formatSpeed('mile_per_hour', 1000, { locale: 'en-US' }); // "1,000 mph"
|
|
240
|
+
*/
|
|
241
|
+
declare function formatSpeed(variant: SpeedUnit, value: number, options?: SpeedFormatOptions): string;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Energy Role - Format Pillar
|
|
245
|
+
*
|
|
246
|
+
* Formata valores de energia para apresentação.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* import { formatEnergy } from '@attrx/role-morphic/energy/format';
|
|
250
|
+
*
|
|
251
|
+
* formatEnergy('kilowatt_hour', 2.5); // "2.5 kWh"
|
|
252
|
+
* formatEnergy('kilowatt_hour', 2.5, { verbose: true }); // "2.5 kilowatt-hours"
|
|
253
|
+
* formatEnergy('joule', 1000, { locale: 'pt-BR' }); // "1.000 J"
|
|
254
|
+
*/
|
|
255
|
+
|
|
256
|
+
interface EnergyFormatOptions {
|
|
257
|
+
/** Casas decimais (default: 2) */
|
|
258
|
+
decimals?: number;
|
|
259
|
+
/** Usa nome completo ao invés de símbolo */
|
|
260
|
+
verbose?: boolean;
|
|
261
|
+
/** Locale para formatação de número */
|
|
262
|
+
locale?: string;
|
|
263
|
+
/** Notação numérica */
|
|
264
|
+
notation?: "standard" | "scientific" | "compact";
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Formata valor de energia para apresentação
|
|
268
|
+
*
|
|
269
|
+
* @param variant - Unidade do valor
|
|
270
|
+
* @param value - Valor numérico
|
|
271
|
+
* @param options - Opções de formatação
|
|
272
|
+
* @returns String formatada
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* formatEnergy('kilowatt_hour', 2.5); // "2.5 kWh"
|
|
276
|
+
* formatEnergy('kilowatt_hour', 2.5, { verbose: true }); // "2.5 kilowatt-hours"
|
|
277
|
+
* formatEnergy('kilowatt_hour', 1, { verbose: true }); // "1 kilowatt-hour"
|
|
278
|
+
* formatEnergy('joule', 1000, { locale: 'pt-BR' }); // "1.000 J"
|
|
279
|
+
* formatEnergy('kilocalorie', 1500, { decimals: 0 }); // "1500 kcal"
|
|
280
|
+
*/
|
|
281
|
+
declare function formatEnergy(variant: EnergyUnit, value: number, options?: EnergyFormatOptions): string;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Power Role - Format Pillar
|
|
285
|
+
*
|
|
286
|
+
* Formatação de valores de potência para exibição.
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* import { formatPower, getPowerSymbol, getPowerName } from '@attrx/role-morphic/power/format';
|
|
290
|
+
*
|
|
291
|
+
* formatPower('kilowatt', 2.5); // "2.5 kW"
|
|
292
|
+
* formatPower('kilowatt', 2.5, { verbose: true }); // "2.5 kilowatts"
|
|
293
|
+
* getPowerSymbol('kilowatt'); // "kW"
|
|
294
|
+
* getPowerName('kilowatt', 2); // "kilowatts"
|
|
295
|
+
*/
|
|
296
|
+
|
|
297
|
+
interface PowerFormatOptions {
|
|
298
|
+
/** Número de casas decimais */
|
|
299
|
+
decimals?: number;
|
|
300
|
+
/** Usar nome completo ao invés de símbolo */
|
|
301
|
+
verbose?: boolean;
|
|
302
|
+
/** Locale para formatação numérica */
|
|
303
|
+
locale?: string;
|
|
304
|
+
/** Notação: standard, scientific, compact */
|
|
305
|
+
notation?: "standard" | "scientific" | "compact";
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Formata valor de potência para exibição
|
|
309
|
+
*
|
|
310
|
+
* @param variant - Unidade
|
|
311
|
+
* @param value - Valor numérico
|
|
312
|
+
* @param options - Opções de formatação
|
|
313
|
+
* @returns String formatada
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* formatPower('kilowatt', 2.5); // "2.5 kW"
|
|
317
|
+
* formatPower('kilowatt', 2.5, { verbose: true }); // "2.5 kilowatts"
|
|
318
|
+
* formatPower('kilowatt', 1, { verbose: true }); // "1 kilowatt"
|
|
319
|
+
* formatPower('watt', 1000, { decimals: 0 }); // "1000 W"
|
|
320
|
+
*/
|
|
321
|
+
declare function formatPower(variant: PowerUnit, value: number, options?: PowerFormatOptions): string;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Pressure Role - Format Pillar
|
|
325
|
+
*
|
|
326
|
+
* Formatação de valores de pressão para exibição.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* import { formatPressure, getPressureSymbol, getPressureName } from '@attrx/role-morphic/pressure/format';
|
|
330
|
+
*
|
|
331
|
+
* formatPressure('bar', 2.5); // "2.5 bar"
|
|
332
|
+
* formatPressure('bar', 2.5, { verbose: true }); // "2.5 bar"
|
|
333
|
+
* getPressureSymbol('pascal'); // "Pa"
|
|
334
|
+
* getPressureName('atmosphere', 2); // "atmospheres"
|
|
335
|
+
*/
|
|
336
|
+
|
|
337
|
+
interface PressureFormatOptions {
|
|
338
|
+
/** Número de casas decimais */
|
|
339
|
+
decimals?: number;
|
|
340
|
+
/** Usar nome completo ao invés de símbolo */
|
|
341
|
+
verbose?: boolean;
|
|
342
|
+
/** Locale para formatação numérica */
|
|
343
|
+
locale?: string;
|
|
344
|
+
/** Notação: standard, scientific, compact */
|
|
345
|
+
notation?: "standard" | "scientific" | "compact";
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Formata valor de pressão para exibição
|
|
349
|
+
*
|
|
350
|
+
* @param variant - Unidade
|
|
351
|
+
* @param value - Valor numérico
|
|
352
|
+
* @param options - Opções de formatação
|
|
353
|
+
* @returns String formatada
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* formatPressure('bar', 2.5); // "2.5 bar"
|
|
357
|
+
* formatPressure('bar', 2.5, { verbose: true }); // "2.5 bar"
|
|
358
|
+
* formatPressure('atmosphere', 1, { verbose: true }); // "1 atmosphere"
|
|
359
|
+
* formatPressure('pascal', 1000, { decimals: 0 }); // "1000 Pa"
|
|
360
|
+
*/
|
|
361
|
+
declare function formatPressure(variant: PressureUnit, value: number, options?: PressureFormatOptions): string;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Frequency Role - Format Pillar
|
|
365
|
+
*
|
|
366
|
+
* Formatação de valores de frequência para exibição.
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* import { formatFrequency, getFrequencySymbol, getFrequencyName } from '@attrx/role-morphic/frequency/format';
|
|
370
|
+
*
|
|
371
|
+
* formatFrequency('gigahertz', 2.4); // "2.4 GHz"
|
|
372
|
+
* formatFrequency('gigahertz', 2.4, { verbose: true }); // "2.4 gigahertz"
|
|
373
|
+
* getFrequencySymbol('megahertz'); // "MHz"
|
|
374
|
+
* getFrequencyName('hertz', 2); // "hertz"
|
|
375
|
+
*/
|
|
376
|
+
|
|
377
|
+
interface FrequencyFormatOptions {
|
|
378
|
+
/** Número de casas decimais */
|
|
379
|
+
decimals?: number;
|
|
380
|
+
/** Usar nome completo ao invés de símbolo */
|
|
381
|
+
verbose?: boolean;
|
|
382
|
+
/** Locale para formatação numérica */
|
|
383
|
+
locale?: string;
|
|
384
|
+
/** Notação: standard, scientific, compact */
|
|
385
|
+
notation?: "standard" | "scientific" | "compact";
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Formata valor de frequência para exibição
|
|
389
|
+
*
|
|
390
|
+
* @param variant - Unidade
|
|
391
|
+
* @param value - Valor numérico
|
|
392
|
+
* @param options - Opções de formatação
|
|
393
|
+
* @returns String formatada
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* formatFrequency('gigahertz', 2.4); // "2.4 GHz"
|
|
397
|
+
* formatFrequency('gigahertz', 2.4, { verbose: true }); // "2.4 gigahertz"
|
|
398
|
+
* formatFrequency('hertz', 1, { verbose: true }); // "1 hertz"
|
|
399
|
+
* formatFrequency('megahertz', 100, { decimals: 0 }); // "100 MHz"
|
|
400
|
+
*/
|
|
401
|
+
declare function formatFrequency(variant: FrequencyUnit, value: number, options?: FrequencyFormatOptions): string;
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Angle Role - Format Pillar
|
|
405
|
+
*
|
|
406
|
+
* Formatação de valores de ângulo para exibição.
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* import { formatAngle, getAngleSymbol, getAngleName } from '@attrx/role-morphic/angle/format';
|
|
410
|
+
*
|
|
411
|
+
* formatAngle('degree', 45); // "45°"
|
|
412
|
+
* formatAngle('degree', 45, { verbose: true }); // "45 degrees"
|
|
413
|
+
* getAngleSymbol('degree'); // "°"
|
|
414
|
+
* getAngleName('degree', 2); // "degrees"
|
|
415
|
+
*/
|
|
416
|
+
|
|
417
|
+
interface AngleFormatOptions {
|
|
418
|
+
/** Número de casas decimais */
|
|
419
|
+
decimals?: number;
|
|
420
|
+
/** Usar nome completo ao invés de símbolo */
|
|
421
|
+
verbose?: boolean;
|
|
422
|
+
/** Locale para formatação numérica */
|
|
423
|
+
locale?: string;
|
|
424
|
+
/** Notação: standard, scientific, compact */
|
|
425
|
+
notation?: "standard" | "scientific" | "compact";
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Formata valor de ângulo para exibição
|
|
429
|
+
*
|
|
430
|
+
* @param variant - Unidade
|
|
431
|
+
* @param value - Valor numérico
|
|
432
|
+
* @param options - Opções de formatação
|
|
433
|
+
* @returns String formatada
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* formatAngle('degree', 45); // "45°"
|
|
437
|
+
* formatAngle('degree', 45, { verbose: true }); // "45 degrees"
|
|
438
|
+
* formatAngle('radian', 3.14159); // "3.14159 rad"
|
|
439
|
+
* formatAngle('degree', 90, { decimals: 0 }); // "90°"
|
|
440
|
+
*/
|
|
441
|
+
declare function formatAngle(variant: AngleUnit, value: number, options?: AngleFormatOptions): string;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Time Role - Format Pillar
|
|
445
|
+
*
|
|
446
|
+
* Formatação de valores de tempo para exibição.
|
|
447
|
+
*
|
|
448
|
+
* @example
|
|
449
|
+
* import { formatTime, getTimeSymbol, getTimeName } from '@attrx/role-morphic/time/format';
|
|
450
|
+
*
|
|
451
|
+
* formatTime('hour', 2.5); // "2.5 h"
|
|
452
|
+
* formatTime('hour', 2.5, { verbose: true }); // "2.5 hours"
|
|
453
|
+
* getTimeSymbol('minute'); // "min"
|
|
454
|
+
* getTimeName('hour', 2); // "hours"
|
|
455
|
+
*/
|
|
456
|
+
|
|
457
|
+
interface TimeFormatOptions {
|
|
458
|
+
/** Número de casas decimais */
|
|
459
|
+
decimals?: number;
|
|
460
|
+
/** Usar nome completo ao invés de símbolo */
|
|
461
|
+
verbose?: boolean;
|
|
462
|
+
/** Locale para formatação numérica */
|
|
463
|
+
locale?: string;
|
|
464
|
+
/** Notação: standard, scientific, compact */
|
|
465
|
+
notation?: "standard" | "scientific" | "compact";
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Formata valor de tempo para exibição
|
|
469
|
+
*
|
|
470
|
+
* @param variant - Unidade
|
|
471
|
+
* @param value - Valor numérico
|
|
472
|
+
* @param options - Opções de formatação
|
|
473
|
+
* @returns String formatada
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* formatTime('hour', 2.5); // "2.5 h"
|
|
477
|
+
* formatTime('hour', 2.5, { verbose: true }); // "2.5 hours"
|
|
478
|
+
* formatTime('second', 1, { verbose: true }); // "1 second"
|
|
479
|
+
* formatTime('millisecond', 100, { decimals: 0 }); // "100 ms"
|
|
480
|
+
*/
|
|
481
|
+
declare function formatTime(variant: TimeUnit, value: number, options?: TimeFormatOptions): string;
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Digital Role - Format Pillar
|
|
485
|
+
*
|
|
486
|
+
* Formatação de valores de armazenamento digital para exibição.
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* import { formatDigital, getDigitalSymbol, getDigitalName } from '@attrx/role-morphic/digital/format';
|
|
490
|
+
*
|
|
491
|
+
* formatDigital('gigabyte', 2.5); // "2.5 GB"
|
|
492
|
+
* formatDigital('gigabyte', 2.5, { verbose: true }); // "2.5 gigabytes"
|
|
493
|
+
* getDigitalSymbol('mebibyte'); // "MiB"
|
|
494
|
+
* getDigitalName('byte', 2); // "bytes"
|
|
495
|
+
*/
|
|
496
|
+
|
|
497
|
+
interface DigitalFormatOptions {
|
|
498
|
+
/** Número de casas decimais */
|
|
499
|
+
decimals?: number;
|
|
500
|
+
/** Usar nome completo ao invés de símbolo */
|
|
501
|
+
verbose?: boolean;
|
|
502
|
+
/** Locale para formatação numérica */
|
|
503
|
+
locale?: string;
|
|
504
|
+
/** Notação: standard, scientific, compact */
|
|
505
|
+
notation?: "standard" | "scientific" | "compact";
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Formata valor de armazenamento digital para exibição
|
|
509
|
+
*
|
|
510
|
+
* @param variant - Unidade
|
|
511
|
+
* @param value - Valor numérico
|
|
512
|
+
* @param options - Opções de formatação
|
|
513
|
+
* @returns String formatada
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
* formatDigital('gigabyte', 2.5); // "2.5 GB"
|
|
517
|
+
* formatDigital('gigabyte', 2.5, { verbose: true }); // "2.5 gigabytes"
|
|
518
|
+
* formatDigital('byte', 1, { verbose: true }); // "1 byte"
|
|
519
|
+
* formatDigital('mebibyte', 100, { decimals: 0 }); // "100 MiB"
|
|
520
|
+
*/
|
|
521
|
+
declare function formatDigital(variant: DigitalUnit, value: number, options?: DigitalFormatOptions): string;
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Color Role - Format Pillar
|
|
525
|
+
*
|
|
526
|
+
* Formatação de cores para apresentação.
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* import { formatColor } from '@attrx/role-morphic/color/format';
|
|
530
|
+
*
|
|
531
|
+
* formatColor('hex', '#ff0000', { uppercase: true }); // '#FF0000'
|
|
532
|
+
* formatColor('rgb_string', { r: 255, g: 0, b: 0 }); // 'rgb(255, 0, 0)'
|
|
533
|
+
*/
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Formata cor para apresentação
|
|
537
|
+
*
|
|
538
|
+
* @param variant - Variante de saída
|
|
539
|
+
* @param value - Valor da cor (qualquer variante)
|
|
540
|
+
* @param options - Opções de formatação
|
|
541
|
+
* @returns String formatada
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* formatColor('hex', '#ff0000', { uppercase: true });
|
|
545
|
+
* // '#FF0000'
|
|
546
|
+
*
|
|
547
|
+
* formatColor('rgb_string', { r: 255, g: 0, b: 0 });
|
|
548
|
+
* // 'rgb(255, 0, 0)'
|
|
549
|
+
*
|
|
550
|
+
* formatColor('hex', '#ff0000', { compact: true });
|
|
551
|
+
* // '#f00'
|
|
552
|
+
*/
|
|
553
|
+
declare function formatColor(variant: ColorVariant, value: unknown, options?: ColorFormatOptions): string;
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Date Role - Format Pillar
|
|
557
|
+
*
|
|
558
|
+
* Formatação de datas para apresentação.
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* import { formatDate, formatIso, formatTimestamp } from '@attrx/role-morphic/date/format';
|
|
562
|
+
*
|
|
563
|
+
* formatDate('iso', '2024-12-05T19:30:00.000Z', { dateStyle: 'full', locale: 'pt-BR' });
|
|
564
|
+
* // "quinta-feira, 5 de dezembro de 2024"
|
|
565
|
+
*/
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Formata data para apresentação
|
|
569
|
+
*
|
|
570
|
+
* @param variant - Variante da data ("iso", "timestamp", "epoch")
|
|
571
|
+
* @param value - Valor da data
|
|
572
|
+
* @param options - Opções de formatação
|
|
573
|
+
* @returns String formatada
|
|
574
|
+
*
|
|
575
|
+
* @example
|
|
576
|
+
* formatDate('iso', '2024-12-05T19:30:00.000Z', { dateStyle: 'full', locale: 'pt-BR' });
|
|
577
|
+
* // 'quinta-feira, 5 de dezembro de 2024'
|
|
578
|
+
*
|
|
579
|
+
* formatDate('timestamp', 1733425800000, { dateOnly: true, dateStyle: 'medium' });
|
|
580
|
+
* // 'Dec 5, 2024'
|
|
581
|
+
*/
|
|
582
|
+
declare function formatDate(variant: DateVariant, value: unknown, options?: DateFormatOptions): string;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Currency Role - Constants
|
|
586
|
+
*
|
|
587
|
+
* Códigos de moeda, símbolos e configurações de formatação.
|
|
588
|
+
*
|
|
589
|
+
* Currency é sobre VALOR MONETÁRIO, não sobre tipos de moeda.
|
|
590
|
+
* O código da moeda (BRL, USD, etc) é METADATA usado apenas para formatação.
|
|
591
|
+
*
|
|
592
|
+
* NÃO há conversão entre moedas - isso é operação de negócio com taxas externas.
|
|
593
|
+
*/
|
|
594
|
+
/**
|
|
595
|
+
* Códigos de moeda ISO 4217
|
|
596
|
+
*/
|
|
597
|
+
type CurrencyCode = "USD" | "EUR" | "GBP" | "JPY" | "CHF" | "CNY" | "CAD" | "AUD" | "BRL" | "MXN" | "ARS" | "CLP" | "COP" | "INR" | "KRW" | "RUB" | "TRY" | "ZAR";
|
|
598
|
+
/**
|
|
599
|
+
* Configuração de uma moeda para formatação
|
|
600
|
+
*/
|
|
601
|
+
interface CurrencyConfig {
|
|
602
|
+
/** Código ISO 4217 */
|
|
603
|
+
code: CurrencyCode;
|
|
604
|
+
/** Símbolo da moeda */
|
|
605
|
+
symbol: string;
|
|
606
|
+
/** Nome singular */
|
|
607
|
+
singular: string;
|
|
608
|
+
/** Nome plural */
|
|
609
|
+
plural: string;
|
|
610
|
+
/** Casas decimais padrão */
|
|
611
|
+
decimals: number;
|
|
612
|
+
/** Símbolo vem antes do valor? */
|
|
613
|
+
symbolFirst: boolean;
|
|
614
|
+
/** Separador de milhares */
|
|
615
|
+
thousandsSeparator: string;
|
|
616
|
+
/** Separador decimal */
|
|
617
|
+
decimalSeparator: string;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Currency Role - Format Pillar
|
|
622
|
+
*
|
|
623
|
+
* Formata valores monetários para apresentação.
|
|
624
|
+
* Usa metadata (código da moeda) para determinar formatação.
|
|
625
|
+
*
|
|
626
|
+
* @example
|
|
627
|
+
* import { formatCurrency } from '@attrx/role-morphic/currency/format';
|
|
628
|
+
*
|
|
629
|
+
* formatCurrency(1500.50, { currency: 'BRL' }); // "R$ 1.500,50"
|
|
630
|
+
* formatCurrency(1000, { currency: 'USD' }); // "$1,000.00"
|
|
631
|
+
* formatCurrency(99.99, { currency: 'EUR' }); // "99,99 €"
|
|
632
|
+
*/
|
|
633
|
+
|
|
634
|
+
interface CurrencyFormatOptions {
|
|
635
|
+
/** Código da moeda (obrigatório) */
|
|
636
|
+
currency: CurrencyCode;
|
|
637
|
+
/** Casas decimais (default: decimais padrão da moeda) */
|
|
638
|
+
decimals?: number;
|
|
639
|
+
/** Usa nome completo ao invés de símbolo */
|
|
640
|
+
verbose?: boolean;
|
|
641
|
+
/** Esconde símbolo, retorna só o número formatado */
|
|
642
|
+
hideSymbol?: boolean;
|
|
643
|
+
/** Força símbolo antes do valor */
|
|
644
|
+
symbolFirst?: boolean;
|
|
645
|
+
/** Usa Intl.NumberFormat com locale */
|
|
646
|
+
locale?: string;
|
|
647
|
+
/** Mostra sinal de positivo para valores positivos */
|
|
648
|
+
showPositiveSign?: boolean;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Formata valor monetário para apresentação
|
|
652
|
+
*
|
|
653
|
+
* @param value - Valor numérico
|
|
654
|
+
* @param options - Opções de formatação (currency obrigatório)
|
|
655
|
+
* @returns String formatada
|
|
656
|
+
*
|
|
657
|
+
* @example
|
|
658
|
+
* formatCurrency(1500.50, { currency: 'BRL' }); // "R$ 1.500,50"
|
|
659
|
+
* formatCurrency(1000, { currency: 'USD' }); // "$1,000.00"
|
|
660
|
+
* formatCurrency(99.99, { currency: 'EUR' }); // "99,99 €"
|
|
661
|
+
* formatCurrency(1500, { currency: 'JPY' }); // "¥1,500"
|
|
662
|
+
* formatCurrency(1500.50, { currency: 'BRL', verbose: true }); // "1.500,50 Brazilian reais"
|
|
663
|
+
* formatCurrency(1500.50, { currency: 'BRL', hideSymbol: true }); // "1.500,50"
|
|
664
|
+
* formatCurrency(1500.50, { currency: 'BRL', locale: 'pt-BR' }); // "R$ 1.500,50" (via Intl)
|
|
665
|
+
*/
|
|
666
|
+
declare function formatCurrency(value: number, options: CurrencyFormatOptions): string;
|
|
667
|
+
|
|
668
|
+
export { type CurrencyFormatOptions as C, type CurrencyCode as a, formatLength as b, formatMass as c, formatTemperature as d, formatVolume as e, formatArea as f, formatSpeed as g, formatEnergy as h, formatPower as i, formatPressure as j, formatFrequency as k, formatAngle as l, formatTime as m, formatDigital as n, formatColor as o, formatDate as p, formatCurrency as q, type CurrencyConfig as r };
|