@promptui-lib/core 0.1.8 → 0.1.10
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spacing.d.ts","sourceRoot":"","sources":["../../src/tokens/spacing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;
|
|
1
|
+
{"version":3,"file":"spacing.d.ts","sourceRoot":"","sources":["../../src/tokens/spacing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAYD,eAAO,MAAM,sBAAsB,EAAE,aAAa,EASjD,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,aAAa,EAK7C,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,MAAM,EACV,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,CAuBR;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,EACV,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,CAuBR;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,CAoBR"}
|
package/dist/tokens/spacing.js
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
* Spacing Tokens
|
|
3
3
|
* Mapeamento de valores de espaçamento para tokens SCSS
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Arredonda valores de pixel para evitar decimais desnecessários
|
|
7
|
+
*/
|
|
8
|
+
function roundPixelValue(value) {
|
|
9
|
+
if (Math.abs(value - Math.round(value)) < 0.01) {
|
|
10
|
+
return Math.round(value);
|
|
11
|
+
}
|
|
12
|
+
return Math.round(value * 10) / 10;
|
|
13
|
+
}
|
|
5
14
|
export const DEFAULT_SPACING_TOKENS = [
|
|
6
15
|
{ px: 0, token: '0' },
|
|
7
16
|
{ px: 4, token: '$spacing-xs' },
|
|
@@ -22,33 +31,47 @@ export const DEFAULT_GAP_TOKENS = [
|
|
|
22
31
|
* Encontra o token de spacing mais próximo
|
|
23
32
|
*/
|
|
24
33
|
export function findSpacingToken(px, customTokens) {
|
|
34
|
+
// Arredonda para evitar decimais desnecessários
|
|
35
|
+
const rounded = roundPixelValue(px);
|
|
25
36
|
// Token customizado exato
|
|
26
|
-
if (customTokens?.[
|
|
27
|
-
return customTokens[
|
|
37
|
+
if (customTokens?.[rounded]) {
|
|
38
|
+
return customTokens[rounded];
|
|
28
39
|
}
|
|
29
|
-
// Token padrão exato
|
|
30
|
-
const exactMatch = DEFAULT_SPACING_TOKENS.find((t) => t.px ===
|
|
40
|
+
// Token padrão exato (verifica arredondado e próximo)
|
|
41
|
+
const exactMatch = DEFAULT_SPACING_TOKENS.find((t) => t.px === rounded);
|
|
31
42
|
if (exactMatch) {
|
|
32
43
|
return exactMatch.token;
|
|
33
44
|
}
|
|
34
|
-
//
|
|
35
|
-
|
|
45
|
+
// Verifica se está muito próximo de um token (tolerância de 0.5px)
|
|
46
|
+
const closeMatch = DEFAULT_SPACING_TOKENS.find((t) => Math.abs(t.px - rounded) < 0.5);
|
|
47
|
+
if (closeMatch) {
|
|
48
|
+
return closeMatch.token;
|
|
49
|
+
}
|
|
50
|
+
// Se não encontrou exato, retorna o valor arredondado em px
|
|
51
|
+
return Number.isInteger(rounded) ? `${rounded}px` : `${rounded}px`;
|
|
36
52
|
}
|
|
37
53
|
/**
|
|
38
54
|
* Encontra o token de gap mais próximo
|
|
39
55
|
*/
|
|
40
56
|
export function findGapToken(px, customTokens) {
|
|
57
|
+
// Arredonda para evitar decimais desnecessários
|
|
58
|
+
const rounded = roundPixelValue(px);
|
|
41
59
|
// Token customizado exato
|
|
42
|
-
if (customTokens?.[
|
|
43
|
-
return customTokens[
|
|
60
|
+
if (customTokens?.[rounded]) {
|
|
61
|
+
return customTokens[rounded];
|
|
44
62
|
}
|
|
45
63
|
// Token padrão exato
|
|
46
|
-
const exactMatch = DEFAULT_GAP_TOKENS.find((t) => t.px ===
|
|
64
|
+
const exactMatch = DEFAULT_GAP_TOKENS.find((t) => t.px === rounded);
|
|
47
65
|
if (exactMatch) {
|
|
48
66
|
return exactMatch.token;
|
|
49
67
|
}
|
|
68
|
+
// Verifica se está muito próximo de um token (tolerância de 0.5px)
|
|
69
|
+
const closeMatch = DEFAULT_GAP_TOKENS.find((t) => Math.abs(t.px - rounded) < 0.5);
|
|
70
|
+
if (closeMatch) {
|
|
71
|
+
return closeMatch.token;
|
|
72
|
+
}
|
|
50
73
|
// Fallback para spacing token
|
|
51
|
-
return findSpacingToken(
|
|
74
|
+
return findSpacingToken(rounded, customTokens);
|
|
52
75
|
}
|
|
53
76
|
/**
|
|
54
77
|
* Gera string de padding a partir dos 4 valores
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typography.d.ts","sourceRoot":"","sources":["../../src/tokens/typography.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,wBAAwB,EAAE,cAAc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,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,CAOR;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,CAOR;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAmBzD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAM9D;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAexB"}
|
|
@@ -57,12 +57,18 @@ export function findLineHeightToken(value) {
|
|
|
57
57
|
// Se é valor em pixels, converte para ratio aproximado
|
|
58
58
|
if (value > 3) {
|
|
59
59
|
// Provavelmente é lineHeightPx, precisa do fontSize para calcular
|
|
60
|
-
|
|
60
|
+
const rounded = Math.round(value);
|
|
61
|
+
return `${rounded}px`;
|
|
61
62
|
}
|
|
62
63
|
const match = DEFAULT_LINE_HEIGHT_TOKENS.find((t) => {
|
|
63
64
|
return Math.abs(t.value - value) < 0.1;
|
|
64
65
|
});
|
|
65
|
-
|
|
66
|
+
// Arredonda para 2 casas decimais se não encontrar token
|
|
67
|
+
if (!match) {
|
|
68
|
+
const rounded = Math.round(value * 100) / 100;
|
|
69
|
+
return `${rounded}`;
|
|
70
|
+
}
|
|
71
|
+
return match.token;
|
|
66
72
|
}
|
|
67
73
|
/**
|
|
68
74
|
* Encontra token de font-family
|