lapikit 0.0.0-insiders.4b1dc48 → 0.0.0-insiders.4ec2a12

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 (215) hide show
  1. package/LICENSE +21 -0
  2. package/bin/configuration.js +303 -0
  3. package/bin/helper.js +59 -0
  4. package/bin/index.js +33 -0
  5. package/bin/presets.js +26 -0
  6. package/bin/prompts.js +67 -0
  7. package/dist/actions/accordion.svelte.d.ts +9 -0
  8. package/dist/actions/accordion.svelte.js +24 -0
  9. package/dist/actions/index.d.ts +2 -0
  10. package/dist/actions/index.js +2 -0
  11. package/dist/actions/use-theme.d.ts +1 -0
  12. package/dist/actions/use-theme.js +18 -0
  13. package/dist/assets/icons/arrow-down.svelte +12 -0
  14. package/dist/assets/icons/arrow-down.svelte.d.ts +18 -0
  15. package/dist/assets/icons/arrow-up.svelte +12 -0
  16. package/dist/assets/icons/arrow-up.svelte.d.ts +18 -0
  17. package/dist/assets/icons/close-fill.svelte +12 -0
  18. package/dist/assets/icons/close-fill.svelte.d.ts +18 -0
  19. package/dist/assets/icons/loading-fill.svelte +31 -0
  20. package/dist/assets/icons/loading-fill.svelte.d.ts +18 -0
  21. package/dist/components/accordion/accordion.css +36 -0
  22. package/dist/components/accordion/accordion.svelte +39 -0
  23. package/dist/components/accordion/accordion.svelte.d.ts +4 -0
  24. package/dist/components/accordion/modules/accordion-item.css +68 -0
  25. package/dist/components/accordion/modules/accordion-item.svelte +94 -0
  26. package/dist/components/accordion/modules/accordion-item.svelte.d.ts +4 -0
  27. package/dist/components/accordion/types.d.ts +33 -0
  28. package/dist/components/accordion/types.js +1 -0
  29. package/dist/components/alert/alert.css +130 -0
  30. package/dist/components/alert/alert.svelte +89 -0
  31. package/dist/components/alert/alert.svelte.d.ts +4 -0
  32. package/dist/components/alert/types.d.ts +28 -0
  33. package/dist/components/alert/types.js +1 -0
  34. package/dist/components/app/app.css +15 -0
  35. package/dist/components/app/app.svelte +61 -0
  36. package/dist/components/app/app.svelte.d.ts +9 -0
  37. package/dist/components/app/types.d.ts +4 -0
  38. package/dist/components/app/types.js +1 -0
  39. package/dist/components/appbar/appbar.css +38 -0
  40. package/dist/components/appbar/appbar.svelte +40 -0
  41. package/dist/components/appbar/appbar.svelte.d.ts +4 -0
  42. package/dist/components/appbar/types.d.ts +15 -0
  43. package/dist/components/appbar/types.js +1 -0
  44. package/dist/components/aspect-ratio/aspect-ratio.css +19 -0
  45. package/dist/components/aspect-ratio/aspect-ratio.svelte +25 -0
  46. package/dist/components/aspect-ratio/aspect-ratio.svelte.d.ts +4 -0
  47. package/dist/components/aspect-ratio/types.d.ts +5 -0
  48. package/dist/components/aspect-ratio/types.js +1 -0
  49. package/dist/components/avatar/avatar.css +102 -0
  50. package/dist/components/avatar/avatar.svelte +46 -0
  51. package/dist/components/avatar/avatar.svelte.d.ts +4 -0
  52. package/dist/components/avatar/types.d.ts +22 -0
  53. package/dist/components/avatar/types.js +1 -0
  54. package/dist/components/button/button.css +240 -0
  55. package/dist/components/button/button.svelte +102 -0
  56. package/dist/components/button/button.svelte.d.ts +4 -0
  57. package/dist/components/button/types.d.ts +29 -0
  58. package/dist/components/button/types.js +1 -0
  59. package/dist/components/card/card.css +105 -0
  60. package/dist/components/card/card.svelte +63 -0
  61. package/dist/components/card/card.svelte.d.ts +4 -0
  62. package/dist/components/card/types.d.ts +18 -0
  63. package/dist/components/card/types.js +1 -0
  64. package/dist/components/chip/chip.css +224 -0
  65. package/dist/components/chip/chip.svelte +131 -0
  66. package/dist/components/chip/chip.svelte.d.ts +4 -0
  67. package/dist/components/chip/types.d.ts +32 -0
  68. package/dist/components/chip/types.js +1 -0
  69. package/dist/components/dialog/dialog.css +129 -0
  70. package/dist/components/dialog/dialog.svelte +67 -0
  71. package/dist/components/dialog/dialog.svelte.d.ts +4 -0
  72. package/dist/components/dialog/types.d.ts +24 -0
  73. package/dist/components/dialog/types.js +1 -0
  74. package/dist/components/dropdown/dropdown.css +13 -0
  75. package/dist/components/dropdown/dropdown.svelte +115 -0
  76. package/dist/components/dropdown/dropdown.svelte.d.ts +4 -0
  77. package/dist/components/dropdown/types.d.ts +26 -0
  78. package/dist/components/dropdown/types.js +1 -0
  79. package/dist/components/icon/icon.css +78 -0
  80. package/dist/components/icon/icon.svelte +49 -0
  81. package/dist/components/icon/icon.svelte.d.ts +4 -0
  82. package/dist/components/icon/types.d.ts +16 -0
  83. package/dist/components/icon/types.js +1 -0
  84. package/dist/components/index.d.ts +22 -0
  85. package/dist/components/index.js +23 -0
  86. package/dist/components/list/list.css +149 -0
  87. package/dist/components/list/list.svelte +44 -0
  88. package/dist/components/list/list.svelte.d.ts +4 -0
  89. package/dist/components/list/modules/list-item.css +67 -0
  90. package/dist/components/list/modules/list-item.svelte +76 -0
  91. package/dist/components/list/modules/list-item.svelte.d.ts +4 -0
  92. package/dist/components/list/types.d.ts +33 -0
  93. package/dist/components/list/types.js +1 -0
  94. package/dist/components/modal/modal.css +137 -0
  95. package/dist/components/modal/modal.svelte +112 -0
  96. package/dist/components/modal/modal.svelte.d.ts +4 -0
  97. package/dist/components/modal/types.d.ts +26 -0
  98. package/dist/components/modal/types.js +1 -0
  99. package/dist/components/popover/popover.css +13 -0
  100. package/dist/components/popover/popover.svelte +73 -0
  101. package/dist/components/popover/popover.svelte.d.ts +4 -0
  102. package/dist/components/popover/types.d.ts +20 -0
  103. package/dist/components/popover/types.js +1 -0
  104. package/dist/components/separator/separator.css +42 -0
  105. package/dist/components/separator/separator.svelte +37 -0
  106. package/dist/components/separator/separator.svelte.d.ts +4 -0
  107. package/dist/components/separator/types.d.ts +11 -0
  108. package/dist/components/separator/types.js +1 -0
  109. package/dist/components/spacer/spacer.css +3 -0
  110. package/dist/components/spacer/spacer.svelte +7 -0
  111. package/dist/components/spacer/spacer.svelte.d.ts +4 -0
  112. package/dist/components/spacer/types.d.ts +4 -0
  113. package/dist/components/spacer/types.js +1 -0
  114. package/dist/components/textfield/textfield.css +298 -0
  115. package/dist/components/textfield/textfield.svelte +193 -0
  116. package/dist/components/textfield/textfield.svelte.d.ts +4 -0
  117. package/dist/components/textfield/types.d.ts +37 -0
  118. package/dist/components/textfield/types.js +1 -0
  119. package/dist/components/toolbar/toolbar.css +106 -0
  120. package/dist/components/toolbar/toolbar.svelte +47 -0
  121. package/dist/components/toolbar/toolbar.svelte.d.ts +4 -0
  122. package/dist/components/toolbar/types.d.ts +27 -0
  123. package/dist/components/toolbar/types.js +1 -0
  124. package/dist/components/tooltip/tooltip.css +116 -0
  125. package/dist/components/tooltip/tooltip.svelte +113 -0
  126. package/dist/components/tooltip/tooltip.svelte.d.ts +4 -0
  127. package/dist/components/tooltip/types.d.ts +23 -0
  128. package/dist/components/tooltip/types.js +1 -0
  129. package/dist/index.d.ts +3 -1
  130. package/dist/index.js +23 -3
  131. package/dist/internal/config/presets.d.ts +149 -0
  132. package/dist/internal/config/presets.js +169 -0
  133. package/dist/internal/config/variables.d.ts +3 -0
  134. package/dist/internal/config/variables.js +3 -0
  135. package/dist/internal/core/actions/assets.svelte.d.ts +8 -0
  136. package/dist/internal/core/actions/assets.svelte.js +54 -0
  137. package/dist/internal/core/actions/dropdown.svelte.d.ts +7 -0
  138. package/dist/internal/core/actions/dropdown.svelte.js +148 -0
  139. package/dist/internal/core/actions/popover.svelte.d.ts +7 -0
  140. package/dist/internal/core/actions/popover.svelte.js +134 -0
  141. package/dist/internal/core/actions/tooltip.svelte.d.ts +7 -0
  142. package/dist/internal/core/actions/tooltip.svelte.js +131 -0
  143. package/dist/internal/core/animations/ripple.d.ts +12 -0
  144. package/dist/internal/core/animations/ripple.js +93 -0
  145. package/dist/{server/modules → internal/core/bin}/ansi.d.ts +0 -1
  146. package/dist/{server/modules → internal/core/bin}/ansi.js +0 -11
  147. package/dist/internal/core/bin/terminal.d.ts +1 -0
  148. package/dist/internal/core/bin/terminal.js +12 -0
  149. package/dist/internal/core/css.d.ts +1 -0
  150. package/dist/internal/core/css.js +16 -0
  151. package/dist/internal/core/formatter/component.d.ts +5 -0
  152. package/dist/internal/core/formatter/component.js +60 -0
  153. package/dist/internal/core/formatter/device.d.ts +5 -0
  154. package/dist/internal/core/formatter/device.js +66 -0
  155. package/dist/internal/core/formatter/index.d.ts +7 -0
  156. package/dist/internal/core/formatter/index.js +35 -0
  157. package/dist/internal/core/formatter/style.d.ts +4 -0
  158. package/dist/internal/core/formatter/style.js +15 -0
  159. package/dist/internal/core/formatter/theme.d.ts +5 -0
  160. package/dist/internal/core/formatter/theme.js +44 -0
  161. package/dist/internal/core/formatter/typography.d.ts +5 -0
  162. package/dist/internal/core/formatter/typography.js +12 -0
  163. package/dist/internal/core/standard-colors.d.ts +75 -0
  164. package/dist/internal/core/standard-colors.js +75 -0
  165. package/dist/{server/modules/x11.d.ts → internal/core/x11-colors.d.ts} +1 -1
  166. package/dist/internal/helpers/colors.d.ts +1 -0
  167. package/dist/{server/modules → internal/helpers}/colors.js +2 -2
  168. package/dist/internal/helpers/convert.d.ts +1 -0
  169. package/dist/internal/helpers/convert.js +17 -0
  170. package/dist/internal/helpers/deep-merge.d.ts +44 -0
  171. package/dist/internal/helpers/deep-merge.js +80 -0
  172. package/dist/internal/helpers/outside.d.ts +9 -0
  173. package/dist/internal/helpers/outside.js +34 -0
  174. package/dist/internal/helpers/parser.d.ts +10 -0
  175. package/dist/internal/helpers/parser.js +93 -0
  176. package/dist/internal/helpers/scroll.d.ts +1 -0
  177. package/dist/internal/helpers/scroll.js +6 -0
  178. package/dist/internal/plugins/vite.d.ts +8 -0
  179. package/dist/internal/plugins/vite.js +33 -0
  180. package/dist/internal/types/components.d.ts +14 -0
  181. package/dist/internal/types/components.js +1 -0
  182. package/dist/internal/types/configuration.d.ts +63 -0
  183. package/dist/internal/types/configuration.js +1 -0
  184. package/dist/internal/types/index.d.ts +2 -0
  185. package/dist/internal/types/index.js +2 -0
  186. package/dist/stores/breakpoints.d.ts +6 -0
  187. package/dist/stores/breakpoints.js +14 -0
  188. package/dist/stores/components.d.ts +8 -0
  189. package/dist/stores/components.js +26 -0
  190. package/dist/stores/devices.d.ts +6 -0
  191. package/dist/stores/devices.js +9 -0
  192. package/dist/stores/index.d.ts +5 -0
  193. package/dist/stores/index.js +5 -0
  194. package/dist/stores/themes.d.ts +2 -0
  195. package/dist/stores/themes.js +4 -0
  196. package/dist/stores/viewport.d.ts +7 -0
  197. package/dist/stores/viewport.js +7 -0
  198. package/dist/styles/animation.css +33 -0
  199. package/dist/styles/keyframes.css +30 -0
  200. package/dist/styles/{normalize.css → reset.css} +15 -5
  201. package/dist/themes.css +0 -0
  202. package/package.json +37 -7
  203. package/dist/server/modules/colors.d.ts +0 -1
  204. package/dist/server/modules/css.d.ts +0 -1
  205. package/dist/server/modules/css.js +0 -141
  206. package/dist/server/modules/importer.d.ts +0 -1
  207. package/dist/server/modules/importer.js +0 -13
  208. package/dist/server/modules/themes.d.ts +0 -4
  209. package/dist/server/modules/themes.js +0 -94
  210. package/dist/server/vite.d.ts +0 -11
  211. package/dist/server/vite.js +0 -17
  212. package/dist/styles/variables.css +0 -7
  213. /package/dist/{server/modules → internal/core}/minify.d.ts +0 -0
  214. /package/dist/{server/modules → internal/core}/minify.js +0 -0
  215. /package/dist/{server/modules/x11.js → internal/core/x11-colors.js} +0 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Nycolaide <https://github.com/Nycolaide>.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,303 @@
1
+ #!/usr/bin/env node
2
+ import { promises as fs } from 'fs';
3
+ import path from 'path';
4
+ import { terminal } from './helper.js';
5
+ import presets from './presets.js';
6
+
7
+ async function findReferenceFile(projectPath) {
8
+ const routesPath = path.join(projectPath, 'src', 'routes');
9
+
10
+ try {
11
+ await fs.access(routesPath);
12
+ } catch {
13
+ terminal('error', `Lapikit cannot find the routes/ directory.`);
14
+ }
15
+
16
+ const layoutFile = path.join(routesPath, '+layout.svelte');
17
+ try {
18
+ await fs.access(layoutFile);
19
+ return layoutFile;
20
+ } catch {
21
+ // +layout.svelte not found in routes/
22
+ }
23
+
24
+ const pageFile = path.join(routesPath, '+page.svelte');
25
+ try {
26
+ await fs.access(pageFile);
27
+ return pageFile;
28
+ } catch {
29
+ // +page.svelte not found in routes/
30
+ }
31
+
32
+ try {
33
+ const entries = await fs.readdir(routesPath, { withFileTypes: true });
34
+ const subDirectories = entries.filter((entry) => entry.isDirectory());
35
+
36
+ for (const dir of subDirectories) {
37
+ const subDirPath = path.join(routesPath, dir.name);
38
+
39
+ const subLayoutFile = path.join(subDirPath, '+layout.svelte');
40
+ try {
41
+ await fs.access(subLayoutFile);
42
+ return subLayoutFile;
43
+ } catch {
44
+ // +layout.svelte not found in subdirectory
45
+ }
46
+
47
+ const subPageFile = path.join(subDirPath, '+page.svelte');
48
+ try {
49
+ await fs.access(subPageFile);
50
+ return subPageFile;
51
+ } catch {
52
+ // +page.svelte not found in subdirectory
53
+ }
54
+ }
55
+ } catch {
56
+ // Error reading routes directory
57
+ }
58
+
59
+ throw new Error('Not found +layout or +page main on your project.');
60
+ }
61
+
62
+ async function addImportToReferenceFile(targetFile, referenceFile) {
63
+ try {
64
+ const content = await fs.readFile(referenceFile, 'utf-8');
65
+ const relativePath = path.relative(path.dirname(referenceFile), targetFile);
66
+ const importStatement = `import "${relativePath.startsWith('.') ? relativePath : './' + relativePath}";\n`;
67
+
68
+ if (content.includes(`import "${relativePath}"`)) {
69
+ terminal('info', `Import statement already exists in ${referenceFile}`);
70
+ return;
71
+ }
72
+
73
+ const lines = content.split('\n');
74
+ let insertIndex = -1;
75
+
76
+ for (let i = 0; i < lines.length; i++) {
77
+ const line = lines[i].trim();
78
+ if (line.startsWith('<script>') || line.startsWith('<script lang="ts">')) {
79
+ insertIndex = i + 1;
80
+ break;
81
+ }
82
+ }
83
+
84
+ if (insertIndex === -1) {
85
+ throw new Error(`No found balise <script> ou <script lang="ts"> ${referenceFile}`);
86
+ }
87
+
88
+ let finalInsertIndex = insertIndex;
89
+ for (let i = insertIndex; i < lines.length; i++) {
90
+ const line = lines[i].trim();
91
+
92
+ if (line === '</script>') {
93
+ break;
94
+ }
95
+
96
+ if (line === '' || line.startsWith('import ') || line.startsWith('//')) {
97
+ finalInsertIndex = i + 1;
98
+ } else {
99
+ break;
100
+ }
101
+ }
102
+
103
+ lines.splice(finalInsertIndex, 0, `\t${importStatement.trim()}`);
104
+ const newContent = lines.join('\n');
105
+
106
+ await fs.writeFile(referenceFile, newContent);
107
+ terminal('info', `Import has been added to ${referenceFile}`);
108
+ } catch (error) {
109
+ terminal('error', `Error adding import: ${error.message}`);
110
+ throw error;
111
+ }
112
+ }
113
+
114
+ async function findViteConfigFile(projectPath, typescript) {
115
+ const ext = typescript ? 'ts' : 'js';
116
+ const viteConfigFile = path.join(projectPath, `vite.config.${ext}`);
117
+
118
+ try {
119
+ await fs.access(viteConfigFile);
120
+ return viteConfigFile;
121
+ } catch {
122
+ // Try the other extension if the preferred one doesn't exist
123
+ const alternativeExt = typescript ? 'js' : 'ts';
124
+ const alternativeFile = path.join(projectPath, `vite.config.${alternativeExt}`);
125
+
126
+ try {
127
+ await fs.access(alternativeFile);
128
+ return alternativeFile;
129
+ } catch {
130
+ throw new Error(`No vite.config.js or vite.config.ts file found in ${projectPath}`);
131
+ }
132
+ }
133
+ }
134
+
135
+ async function addLapikitToViteConfig(viteConfigFile, pathConfig, typescript) {
136
+ try {
137
+ const content = await fs.readFile(viteConfigFile, 'utf-8');
138
+ const lapikitImport = `import { lapikit } from 'lapikit/vite';`;
139
+ const configPath = `${pathConfig}/lapikit.${typescript ? 'ts' : 'js'}`;
140
+ const lapikitPlugin = `lapikit({ config: '${configPath}' })`;
141
+
142
+ // Check if lapikit import already exists
143
+ if (content.includes(lapikitImport) || content.includes(`from 'lapikit/vite'`)) {
144
+ terminal('info', `Lapikit import already exists in ${viteConfigFile}`);
145
+ return;
146
+ }
147
+
148
+ const lines = content.split('\n');
149
+ let importInsertIndex = -1;
150
+ let pluginAdded = false;
151
+
152
+ // Find where to insert the import (after other imports)
153
+ for (let i = 0; i < lines.length; i++) {
154
+ const line = lines[i].trim();
155
+
156
+ if (line.startsWith('import ') && !line.includes('type ')) {
157
+ importInsertIndex = i + 1;
158
+ } else if (
159
+ line === '' &&
160
+ importInsertIndex !== -1 &&
161
+ lines[i + 1] &&
162
+ !lines[i + 1].trim().startsWith('import ')
163
+ ) {
164
+ importInsertIndex = i;
165
+ break;
166
+ }
167
+ }
168
+
169
+ // If no imports found, insert at the beginning
170
+ if (importInsertIndex === -1) {
171
+ importInsertIndex = 0;
172
+ }
173
+
174
+ // Insert the lapikit import
175
+ lines.splice(importInsertIndex, 0, lapikitImport);
176
+
177
+ // Find and update the plugins array
178
+ for (let i = 0; i < lines.length; i++) {
179
+ const line = lines[i].trim();
180
+
181
+ if (line.includes('plugins:') && line.includes('[') && line.includes(']')) {
182
+ // Single line plugins array
183
+ if (line.includes('sveltekit()')) {
184
+ const pluginMatch = line.match(/plugins:\s*\[(.*)\]/);
185
+ if (pluginMatch) {
186
+ const pluginsContent = pluginMatch[1];
187
+ if (!pluginsContent.includes('lapikit')) {
188
+ const newPluginsContent = pluginsContent.replace(
189
+ /sveltekit\(\)/,
190
+ `sveltekit(), ${lapikitPlugin}`
191
+ );
192
+ lines[i] = line.replace(pluginsContent, newPluginsContent);
193
+ pluginAdded = true;
194
+ }
195
+ }
196
+ }
197
+ break;
198
+ } else if (line.includes('plugins:') && line.includes('[') && !line.includes(']')) {
199
+ // Multi-line plugins array start
200
+ for (let j = i; j < lines.length; j++) {
201
+ const pluginLine = lines[j].trim();
202
+
203
+ if (pluginLine.includes('sveltekit()') && !pluginAdded) {
204
+ // Check if lapikit is not already present
205
+ let hasLapikit = false;
206
+ for (let k = i; k < lines.length && !lines[k].includes(']'); k++) {
207
+ if (lines[k].includes('lapikit')) {
208
+ hasLapikit = true;
209
+ break;
210
+ }
211
+ }
212
+
213
+ if (!hasLapikit) {
214
+ // Add lapikit after sveltekit()
215
+ if (pluginLine.includes(',')) {
216
+ lines[j] = lines[j].replace('sveltekit()', `sveltekit(), ${lapikitPlugin}`);
217
+ } else {
218
+ lines[j] = lines[j].replace('sveltekit()', 'sveltekit(),');
219
+ // Insert lapikit on the next line with proper indentation
220
+ const indentation = lines[j].match(/^\s*/)[0];
221
+ lines.splice(j + 1, 0, `${indentation}${lapikitPlugin}`);
222
+ }
223
+ pluginAdded = true;
224
+ }
225
+ break;
226
+ }
227
+
228
+ if (pluginLine.includes(']')) {
229
+ break;
230
+ }
231
+ }
232
+ break;
233
+ }
234
+ }
235
+
236
+ if (!pluginAdded) {
237
+ terminal('warn', `Could not find sveltekit() in plugins array to add lapikit() after it`);
238
+ }
239
+
240
+ const newContent = lines.join('\n');
241
+ await fs.writeFile(viteConfigFile, newContent);
242
+ terminal('info', `Lapikit import and plugin added to ${viteConfigFile}`);
243
+ } catch (error) {
244
+ terminal('error', `Error adding lapikit to vite config: ${error.message}`);
245
+ throw error;
246
+ }
247
+ }
248
+
249
+ export async function initConfiguration(options) {
250
+ const { typescript, pathConfig, formatCSS, pathCSS } = options;
251
+ const ext = typescript ? 'ts' : 'js';
252
+ const targetDir = path.resolve(process.cwd(), pathConfig);
253
+ const targetFile = path.join(targetDir, `lapikit.${ext}`);
254
+
255
+ await fs.mkdir(targetDir, { recursive: true });
256
+
257
+ let fileCreated = false;
258
+
259
+ // Create Lapikit config
260
+ try {
261
+ await fs.access(targetFile);
262
+ terminal('info', `File ${targetFile} already exists.`);
263
+ } catch {
264
+ terminal('info', `Creating file: ${targetFile}`);
265
+ const content = presets({
266
+ adapterCSS: formatCSS
267
+ });
268
+ await fs.writeFile(targetFile, content);
269
+ terminal('info', `File created: ${targetFile}`);
270
+ fileCreated = true;
271
+ }
272
+
273
+ // Add Import Lapikit plugin
274
+ try {
275
+ const referenceFile = await findReferenceFile(process.cwd());
276
+ await addImportToReferenceFile(targetFile, referenceFile);
277
+ } catch (error) {
278
+ terminal('error', `Error adding import: ${error.message}`);
279
+
280
+ if (fileCreated) {
281
+ try {
282
+ await fs.unlink(targetFile);
283
+ terminal('info', `File ${targetFile} deleted due to error.`);
284
+ } catch {
285
+ // Ignore deletion error
286
+ }
287
+ }
288
+ throw error;
289
+ }
290
+
291
+ // Add Import Lapikit css
292
+ if (formatCSS !== 'css') {
293
+ console.log('need custom import (Preview)', pathCSS);
294
+ }
295
+ // Add lapikit to vite.config file
296
+ try {
297
+ const viteConfigFile = await findViteConfigFile(process.cwd(), typescript);
298
+ await addLapikitToViteConfig(viteConfigFile, pathConfig, typescript);
299
+ } catch (error) {
300
+ terminal('warn', `Warning: Could not update vite.config file: ${error.message}`);
301
+ terminal('error', `Error adding lapikit to vite config: ${error.message}`);
302
+ }
303
+ }
package/bin/helper.js ADDED
@@ -0,0 +1,59 @@
1
+ const color = {
2
+ red: (text) => `\x1b[31m${text}\x1b[0m`,
3
+ green: (text) => `\x1b[32m${text}\x1b[0m`,
4
+ yellow: (text) => `\x1b[33m${text}\x1b[0m`,
5
+ blue: (text) => `\x1b[34m${text}\x1b[0m`,
6
+ purple: (text) => `\x1b[35m${text}\x1b[0m`,
7
+ cyan: (text) => `\x1b[36m${text}\x1b[0m`
8
+ };
9
+
10
+ const variant = {
11
+ bold: (text) => `\x1b[1m${text}\x1b[0m`,
12
+ underline: (text) => `\x1b[4m${text}\x1b[0m`,
13
+ inverse: (text) => `\x1b[7m${text}\x1b[0m`
14
+ };
15
+
16
+ const bold = {
17
+ red: (text) => `\x1b[1m\x1b[31m${text}\x1b[0m`,
18
+ green: (text) => `\x1b[1m\x1b[32m${text}\x1b[0m`,
19
+ yellow: (text) => `\x1b[1m\x1b[33m${text}\x1b[0m`,
20
+ blue: (text) => `\x1b[1m\x1b[34m${text}\x1b[0m`,
21
+ purple: (text) => `\x1b[1m\x1b[35m${text}\x1b[0m`,
22
+ cyan: (text) => `\x1b[1m\x1b[36m${text}\x1b[0m`
23
+ };
24
+
25
+ const inverse = {
26
+ red: (text) => `\x1b[7m\x1b[31m${text}\x1b[0m`,
27
+ green: (text) => `\x1b[7m\x1b[32m${text}\x1b[0m`,
28
+ yellow: (text) => `\x1b[7m\x1b[33m${text}\x1b[0m`,
29
+ blue: (text) => `\x1b[7m\x1b[34m${text}\x1b[0m`,
30
+ purple: (text) => `\x1b[7m\x1b[35m${text}\x1b[0m`,
31
+ cyan: (text) => `\x1b[7m\x1b[36m${text}\x1b[0m`
32
+ };
33
+
34
+ const underline = {
35
+ red: (text) => `\x1b[4m\x1b[31m${text}\x1b[0m`,
36
+ green: (text) => `\x1b[4m\x1b[32m${text}\x1b[0m`,
37
+ yellow: (text) => `\x1b[4m\x1b[33m${text}\x1b[0m`,
38
+ blue: (text) => `\x1b[4m\x1b[34m${text}\x1b[0m`,
39
+ purple: (text) => `\x1b[4m\x1b[35m${text}\x1b[0m`,
40
+ cyan: (text) => `\x1b[4m\x1b[36m${text}\x1b[0m`
41
+ };
42
+
43
+ export const ansi = {
44
+ color,
45
+ variant,
46
+ bold,
47
+ inverse,
48
+ underline
49
+ };
50
+
51
+ export const terminal = (type = 'info', msg) => {
52
+ const name = ansi.color.cyan('lapikit');
53
+
54
+ if (type === 'error') console.error(name, ansi.bold.red('[error]'), msg);
55
+ else if (type === 'warn') console.warn(name, ansi.bold.yellow('[warn]'), msg);
56
+ else if (type === 'success') console.warn(name, ansi.bold.green('[success]'), msg);
57
+ else if (type === 'none') console.log(msg);
58
+ else console.log(name, ansi.bold.blue('[info]'), msg);
59
+ };
package/bin/index.js ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ import { initConfiguration } from './configuration.js';
3
+ import { ansi, terminal } from './helper.js';
4
+ import { initPrompts } from './prompts.js';
5
+
6
+ async function run() {
7
+ console.log(' _ _ _ _ _ ');
8
+ console.log(' | | (_) | (_) | ');
9
+ console.log(' | | __ _ _ __ _| | ___| |_ ');
10
+ console.log(" | | / _` | '_ \\| | |/ / | __|");
11
+ console.log(' | |___| (_| | |_) | | <| | |_ ');
12
+ console.log(' |______\\__,_| .__/|_|_|\\_\\_|\\__|');
13
+ console.log(' | | ');
14
+ console.log(' |_| \n');
15
+
16
+ terminal('none', `${ansi.bold.blue('Lapikit')} - Component Library for Svelte\n\n`);
17
+
18
+ const promptsConfig = await initPrompts();
19
+
20
+ await initConfiguration(promptsConfig);
21
+ }
22
+
23
+ run()
24
+ .then(() => {
25
+ terminal('none', `\n\n\n\nWebsite: https://lapikit.dev`);
26
+ terminal('none', `Github: https://github.com/nycolaide/lapikit`);
27
+ terminal('none', `Support the developement: https://buymeacoffee.com/nycolaide`);
28
+ process.exit(0);
29
+ })
30
+ .catch((error) => {
31
+ terminal('error', `Error: ${error}`);
32
+ process.exit(1);
33
+ });
package/bin/presets.js ADDED
@@ -0,0 +1,26 @@
1
+ function presets({ adapterCSS }) {
2
+ let content = '';
3
+
4
+ content += `/**\n`;
5
+ content += ` * Lapikit\n`;
6
+ content += ` * Library documentation: https://lapikit.dev\n`;
7
+ content += ` */\n\n`;
8
+
9
+ if (adapterCSS === 'css') {
10
+ content += `// Styles\n`;
11
+ content += `import 'lapikit/styles';\n`;
12
+ content += `import 'lapikit/themes';\n\n`;
13
+ }
14
+
15
+ content += `// Composables\n`;
16
+ content += `import createLapikit from 'lapikit';\n\n`;
17
+
18
+ content += `// https://lapikit.dev/docs/getting-started\n`;
19
+ content += `export default createLapikit({\n`;
20
+ content += `\tadapterCSS: "${adapterCSS}",\n`;
21
+ content += `\n});`;
22
+
23
+ return content;
24
+ }
25
+
26
+ export default presets;
package/bin/prompts.js ADDED
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ import prompts from 'prompts';
3
+ import { terminal } from './helper.js';
4
+
5
+ export async function initPrompts() {
6
+ const { confirm } = await prompts({
7
+ type: 'toggle',
8
+ name: 'confirm',
9
+ message: 'Launch install Lapikit on your project?',
10
+ initial: true,
11
+ active: 'Yes',
12
+ inactive: 'No'
13
+ });
14
+
15
+ if (!confirm) {
16
+ terminal('warn', `installation canceled.`);
17
+ process.exit(0);
18
+ }
19
+
20
+ // Preview install
21
+ let settings = await prompts([
22
+ {
23
+ type: 'text',
24
+ name: 'pathConfig',
25
+ message: 'Where would you like to install the lapikit configuration files?',
26
+ initial: 'src/plugins',
27
+ validate: (value) =>
28
+ value.startsWith('src/') ? true : 'Please provide a valid path starting with src/'
29
+ },
30
+ {
31
+ type: 'toggle',
32
+ name: 'typescript',
33
+ message: 'Use TypeScript?',
34
+ initial: true,
35
+ active: 'Yes',
36
+ inactive: 'No'
37
+ },
38
+ {
39
+ type: 'select',
40
+ name: 'formatCSS',
41
+ message: 'What is your CSS format used on your app?',
42
+ choices: [
43
+ { title: 'Basic (classic import)', value: 'css' },
44
+ {
45
+ title: 'TailwindCSS (v4)',
46
+ value: 'tailwind-v4'
47
+ },
48
+ {
49
+ title: 'UnoCSS',
50
+ value: 'unocss'
51
+ }
52
+ ]
53
+ },
54
+ {
55
+ type: (prev) => (prev !== 'css' ? 'text' : null),
56
+ name: 'pathCSS',
57
+ message: 'Where would you like to import the lapikit CSS files?',
58
+ initial: 'src/app.css',
59
+ validate: (value) =>
60
+ value.startsWith('src/') ? true : 'Please provide a valid path starting with src/'
61
+ }
62
+ ]);
63
+
64
+ return {
65
+ ...settings
66
+ };
67
+ }
@@ -0,0 +1,9 @@
1
+ type AccordionOptions = {
2
+ multiple?: boolean;
3
+ readOnly?: boolean;
4
+ };
5
+ export declare function useAccordion({ multiple, readOnly }?: AccordionOptions): {
6
+ readonly values: (string | number)[];
7
+ toggle(id: string | number): void;
8
+ };
9
+ export {};
@@ -0,0 +1,24 @@
1
+ export function useAccordion({ multiple = false, readOnly = false } = {}) {
2
+ // state
3
+ let openIndex = $state([10]);
4
+ return {
5
+ get values() {
6
+ return openIndex;
7
+ },
8
+ toggle(id) {
9
+ if (!readOnly) {
10
+ if (multiple) {
11
+ if (openIndex.includes(id)) {
12
+ openIndex = openIndex.filter((i) => i !== id);
13
+ }
14
+ else {
15
+ openIndex = [...openIndex, id];
16
+ }
17
+ }
18
+ else {
19
+ openIndex = openIndex.includes(id) ? [] : [id];
20
+ }
21
+ }
22
+ }
23
+ };
24
+ }
@@ -0,0 +1,2 @@
1
+ export * from './accordion.svelte.js';
2
+ export * from './use-theme.js';
@@ -0,0 +1,2 @@
1
+ export * from './accordion.svelte.js';
2
+ export * from './use-theme.js';
@@ -0,0 +1 @@
1
+ export declare function useTheme(name: string, key?: string): void;
@@ -0,0 +1,18 @@
1
+ import { theme } from '../stores/themes.js';
2
+ // states
3
+ const isBrowser = typeof window !== 'undefined';
4
+ export function useTheme(name, key = '@lapikit/theme') {
5
+ theme.update(() => {
6
+ if (isBrowser) {
7
+ const html = document.documentElement;
8
+ html.classList.forEach((cls) => {
9
+ if (cls.startsWith('kit-theme--')) {
10
+ html.classList.remove(cls);
11
+ }
12
+ });
13
+ html.classList.add(`kit-theme--${name}`);
14
+ localStorage.setItem(key, name);
15
+ }
16
+ return name;
17
+ });
18
+ }
@@ -0,0 +1,12 @@
1
+ <script lang="ts"></script>
2
+
3
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
4
+ ><path
5
+ fill="none"
6
+ stroke="currentColor"
7
+ stroke-linecap="round"
8
+ stroke-linejoin="round"
9
+ stroke-width="2.5"
10
+ d="m7 10l5 5m0 0l5-5"
11
+ /></svg
12
+ >
@@ -0,0 +1,18 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const ArrowDown: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, string>;
17
+ type ArrowDown = InstanceType<typeof ArrowDown>;
18
+ export default ArrowDown;
@@ -0,0 +1,12 @@
1
+ <script lang="ts"></script>
2
+
3
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
4
+ ><path
5
+ fill="none"
6
+ stroke="currentColor"
7
+ stroke-linecap="round"
8
+ stroke-linejoin="round"
9
+ stroke-width="2.5"
10
+ d="m17 14l-5-5m0 0l-5 5"
11
+ /></svg
12
+ >
@@ -0,0 +1,18 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const ArrowUp: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, string>;
17
+ type ArrowUp = InstanceType<typeof ArrowUp>;
18
+ export default ArrowUp;
@@ -0,0 +1,12 @@
1
+ <script lang="ts"></script>
2
+
3
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
4
+ ><title>close_fill</title><g id="close_fill" fill="none" fill-rule="evenodd"
5
+ ><path
6
+ d="M24 0v24H0V0zM12.593 23.258l-.011.002-.071.035-.02.004-.014-.004-.071-.035c-.01-.004-.019-.001-.024.005l-.004.01-.017.428.005.02.01.013.104.074.015.004.012-.004.104-.074.012-.016.004-.017-.017-.427c-.002-.01-.009-.017-.017-.018m.265-.113-.013.002-.185.093-.01.01-.003.011.018.43.005.012.008.007.201.093c.012.004.023 0 .029-.008l.004-.014-.034-.614c-.003-.012-.01-.02-.02-.022m-.715.002a.023.023 0 0 0-.027.006l-.006.014-.034.614c0 .012.007.02.017.024l.015-.002.201-.093.01-.008.004-.011.017-.43-.003-.012-.01-.01z"
7
+ /><path
8
+ fill="currentColor"
9
+ d="m12 14.122 5.303 5.303a1.5 1.5 0 0 0 2.122-2.122L14.12 12l5.304-5.303a1.5 1.5 0 1 0-2.122-2.121L12 9.879 6.697 4.576a1.5 1.5 0 1 0-2.122 2.12L9.88 12l-5.304 5.304a1.5 1.5 0 1 0 2.122 2.12z"
10
+ /></g
11
+ ></svg
12
+ >
@@ -0,0 +1,18 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const CloseFill: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, string>;
17
+ type CloseFill = InstanceType<typeof CloseFill>;
18
+ export default CloseFill;