@promptui-lib/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/index.d.ts +8 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +10 -0
  4. package/dist/tokens/borders.d.ts +31 -0
  5. package/dist/tokens/borders.d.ts.map +1 -0
  6. package/dist/tokens/borders.js +83 -0
  7. package/dist/tokens/colors.d.ts +23 -0
  8. package/dist/tokens/colors.d.ts.map +1 -0
  9. package/dist/tokens/colors.js +73 -0
  10. package/dist/tokens/index.d.ts +5 -0
  11. package/dist/tokens/index.d.ts.map +1 -0
  12. package/dist/tokens/index.js +4 -0
  13. package/dist/tokens/spacing.d.ts +23 -0
  14. package/dist/tokens/spacing.d.ts.map +1 -0
  15. package/dist/tokens/spacing.js +72 -0
  16. package/dist/tokens/typography.d.ts +41 -0
  17. package/dist/tokens/typography.d.ts.map +1 -0
  18. package/dist/tokens/typography.js +91 -0
  19. package/dist/types/ast.types.d.ts +123 -0
  20. package/dist/types/ast.types.d.ts.map +1 -0
  21. package/dist/types/ast.types.js +5 -0
  22. package/dist/types/config.types.d.ts +115 -0
  23. package/dist/types/config.types.d.ts.map +1 -0
  24. package/dist/types/config.types.js +5 -0
  25. package/dist/types/figma.types.d.ts +157 -0
  26. package/dist/types/figma.types.d.ts.map +1 -0
  27. package/dist/types/figma.types.js +5 -0
  28. package/dist/types/index.d.ts +4 -0
  29. package/dist/types/index.d.ts.map +1 -0
  30. package/dist/types/index.js +3 -0
  31. package/dist/utils/classifiers.d.ts +34 -0
  32. package/dist/utils/classifiers.d.ts.map +1 -0
  33. package/dist/utils/classifiers.js +166 -0
  34. package/dist/utils/index.d.ts +3 -0
  35. package/dist/utils/index.d.ts.map +1 -0
  36. package/dist/utils/index.js +2 -0
  37. package/dist/utils/naming.d.ts +72 -0
  38. package/dist/utils/naming.d.ts.map +1 -0
  39. package/dist/utils/naming.js +126 -0
  40. package/package.json +54 -0
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Naming Utilities
3
+ * Funções para conversão de nomes entre diferentes convenções
4
+ */
5
+ /**
6
+ * Converte string para kebab-case
7
+ * @example "PrimaryButton" → "primary-button"
8
+ * @example "Button/Primary/Large" → "button-primary-large"
9
+ */
10
+ export function toKebabCase(str) {
11
+ return str
12
+ .replace(/\//g, '-')
13
+ .replace(/([a-z])([A-Z])/g, '$1-$2')
14
+ .replace(/[\s_]+/g, '-')
15
+ .replace(/[^a-zA-Z0-9-]/g, '')
16
+ .replace(/-+/g, '-')
17
+ .toLowerCase();
18
+ }
19
+ /**
20
+ * Converte string para PascalCase
21
+ * @example "primary-button" → "PrimaryButton"
22
+ * @example "Button/Primary/Large" → "ButtonPrimaryLarge"
23
+ */
24
+ export function toPascalCase(str) {
25
+ return str
26
+ .replace(/[\/\-_\s]+/g, ' ')
27
+ .split(' ')
28
+ .filter(Boolean)
29
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
30
+ .join('');
31
+ }
32
+ /**
33
+ * Converte string para camelCase
34
+ * @example "primary-button" → "primaryButton"
35
+ */
36
+ export function toCamelCase(str) {
37
+ const pascal = toPascalCase(str);
38
+ return pascal.charAt(0).toLowerCase() + pascal.slice(1);
39
+ }
40
+ /**
41
+ * Converte string para SCREAMING_SNAKE_CASE
42
+ * @example "primaryButton" → "PRIMARY_BUTTON"
43
+ */
44
+ export function toScreamingSnakeCase(str) {
45
+ return toKebabCase(str).replace(/-/g, '_').toUpperCase();
46
+ }
47
+ /**
48
+ * Extrai o nome base de um path de componente do Figma
49
+ * @example "Button/Primary/Large" → "Button"
50
+ * @example "#Card/WithHeader" → "Card"
51
+ */
52
+ export function extractBaseName(figmaName) {
53
+ // Remove prefixos especiais
54
+ let name = figmaName.replace(/^[#_$]/, '');
55
+ // Pega primeira parte antes da /
56
+ const parts = name.split('/');
57
+ return parts[0].trim();
58
+ }
59
+ /**
60
+ * Extrai variantes do nome do Figma
61
+ * @example "Button/Primary/Large" → ["Primary", "Large"]
62
+ */
63
+ export function extractVariants(figmaName) {
64
+ // Remove prefixos especiais
65
+ let name = figmaName.replace(/^[#_$]/, '');
66
+ const parts = name.split('/');
67
+ // Remove a primeira parte (nome base)
68
+ return parts.slice(1).map((p) => p.trim()).filter(Boolean);
69
+ }
70
+ /**
71
+ * Gera nome do componente a partir do nome do Figma
72
+ * @example "Button/Primary" → "PrimaryButton"
73
+ * @example "Card/Default" → "Card"
74
+ */
75
+ export function generateComponentName(figmaName) {
76
+ const baseName = extractBaseName(figmaName);
77
+ const variants = extractVariants(figmaName);
78
+ // Se tem variantes, prefixamos com a primeira variante
79
+ if (variants.length > 0 && variants[0].toLowerCase() !== 'default') {
80
+ return toPascalCase(`${variants[0]}-${baseName}`);
81
+ }
82
+ return toPascalCase(baseName);
83
+ }
84
+ /**
85
+ * Gera nome do arquivo a partir do nome do componente
86
+ * @example "PrimaryButton" → "primary-button"
87
+ */
88
+ export function generateFileName(componentName) {
89
+ return toKebabCase(componentName);
90
+ }
91
+ /**
92
+ * Gera classe CSS BEM base
93
+ * @example "PrimaryButton" → "primary-button"
94
+ */
95
+ export function generateBEMBlock(componentName) {
96
+ return toKebabCase(componentName);
97
+ }
98
+ /**
99
+ * Gera classe CSS BEM element
100
+ * @example ("primary-button", "icon") → "primary-button__icon"
101
+ */
102
+ export function generateBEMElement(block, element) {
103
+ return `${block}__${toKebabCase(element)}`;
104
+ }
105
+ /**
106
+ * Gera classe CSS BEM modifier
107
+ * @example ("primary-button", "disabled") → "primary-button--disabled"
108
+ */
109
+ export function generateBEMModifier(block, modifier) {
110
+ return `${block}--${toKebabCase(modifier)}`;
111
+ }
112
+ /**
113
+ * Valida se um nome é válido para componente
114
+ */
115
+ export function isValidComponentName(name) {
116
+ // Deve começar com letra e conter apenas alfanuméricos
117
+ return /^[A-Za-z][A-Za-z0-9]*$/.test(name);
118
+ }
119
+ /**
120
+ * Sanitiza um nome para ser válido
121
+ */
122
+ export function sanitizeName(name) {
123
+ return name
124
+ .replace(/[^a-zA-Z0-9\s\-_\/]/g, '')
125
+ .trim();
126
+ }
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@promptui-lib/core",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "description": "Core types, tokens and utilities for PromptUI",
6
+ "license": "UNLICENSED",
7
+ "author": {
8
+ "name": "Desiree Menezes",
9
+ "url": "https://github.com/desireemenezes"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/desireemenezes/promptUI.git",
14
+ "directory": "packages/core"
15
+ },
16
+ "homepage": "https://github.com/desireemenezes/promptUI#readme",
17
+ "type": "module",
18
+ "main": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js"
27
+ },
28
+ "./types": {
29
+ "types": "./dist/types/index.d.ts",
30
+ "import": "./dist/types/index.js"
31
+ },
32
+ "./tokens": {
33
+ "types": "./dist/tokens/index.d.ts",
34
+ "import": "./dist/tokens/index.js"
35
+ },
36
+ "./utils": {
37
+ "types": "./dist/utils/index.d.ts",
38
+ "import": "./dist/utils/index.js"
39
+ }
40
+ },
41
+ "files": [
42
+ "dist"
43
+ ],
44
+ "devDependencies": {
45
+ "@types/node": "^20.0.0",
46
+ "typescript": "^5.3.0",
47
+ "rimraf": "^5.0.0"
48
+ },
49
+ "scripts": {
50
+ "build": "tsc",
51
+ "dev": "tsc --watch",
52
+ "clean": "rimraf dist"
53
+ }
54
+ }