lapikit 0.0.0-insiders.e552ce3 → 0.0.0-insiders.e63b6f9
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/bin/configuration.js +165 -14
- package/bin/helper.js +0 -38
- package/bin/index.js +5 -13
- package/bin/presets.js +11 -8
- package/bin/prompts.js +49 -83
- package/dist/actions/accordion.svelte.d.ts +9 -0
- package/dist/actions/index.d.ts +2 -1
- package/dist/actions/index.js +2 -1
- package/dist/actions/use-theme.d.ts +1 -0
- package/dist/actions/use-theme.js +18 -0
- package/dist/components/accordion/accordion.css +0 -77
- package/dist/components/accordion/accordion.svelte +5 -3
- package/dist/components/accordion/modules/accordion-item.css +68 -0
- package/dist/components/accordion/modules/accordion-item.svelte +4 -4
- package/dist/components/accordion/types.d.ts +1 -1
- package/dist/components/alert/alert.css +11 -18
- package/dist/components/alert/alert.svelte +4 -4
- package/dist/components/alert/types.d.ts +1 -1
- package/dist/components/app/app.css +1 -2
- package/dist/components/app/app.svelte +39 -21
- package/dist/components/app/app.svelte.d.ts +2 -0
- package/dist/components/appbar/appbar.css +8 -18
- package/dist/components/appbar/appbar.svelte +4 -4
- package/dist/components/appbar/types.d.ts +1 -1
- package/dist/components/aspect-ratio/aspect-ratio.svelte +0 -22
- package/dist/components/aspect-ratio/types.d.ts +1 -1
- package/dist/components/avatar/avatar.css +7 -14
- package/dist/components/avatar/avatar.svelte +4 -4
- package/dist/components/avatar/types.d.ts +1 -1
- package/dist/components/button/button.css +29 -36
- package/dist/components/button/button.svelte +5 -5
- package/dist/components/button/types.d.ts +1 -1
- package/dist/components/card/card.css +10 -20
- package/dist/components/card/card.svelte +9 -5
- package/dist/components/card/types.d.ts +3 -1
- package/dist/components/chip/chip.css +30 -37
- package/dist/components/chip/chip.svelte +10 -8
- package/dist/components/chip/types.d.ts +2 -1
- package/dist/components/dialog/dialog.css +15 -20
- package/dist/components/dialog/dialog.svelte +5 -5
- package/dist/components/dialog/types.d.ts +1 -1
- package/dist/components/dropdown/dropdown.css +3 -12
- package/dist/components/dropdown/dropdown.svelte +6 -7
- package/dist/components/dropdown/types.d.ts +1 -1
- package/dist/components/icon/icon.css +11 -12
- package/dist/components/icon/icon.svelte +2 -2
- package/dist/components/icon/types.d.ts +1 -1
- package/dist/components/list/list.css +19 -91
- package/dist/components/list/list.svelte +4 -4
- package/dist/components/list/modules/list-item.css +67 -0
- package/dist/components/list/modules/list-item.svelte +5 -5
- package/dist/components/list/types.d.ts +1 -1
- package/dist/components/modal/modal.css +22 -29
- package/dist/components/modal/modal.svelte +4 -5
- package/dist/components/modal/types.d.ts +1 -1
- package/dist/components/popover/popover.css +3 -12
- package/dist/components/popover/popover.svelte +6 -6
- package/dist/components/popover/types.d.ts +1 -1
- package/dist/components/separator/separator.css +19 -23
- package/dist/components/separator/separator.svelte +6 -6
- package/dist/components/separator/types.d.ts +6 -2
- package/dist/components/spacer/types.d.ts +1 -1
- package/dist/components/textfield/textfield.css +16 -23
- package/dist/components/textfield/textfield.svelte +4 -4
- package/dist/components/textfield/types.d.ts +1 -1
- package/dist/components/toolbar/toolbar.css +11 -34
- package/dist/components/toolbar/toolbar.svelte +4 -4
- package/dist/components/toolbar/types.d.ts +1 -1
- package/dist/components/tooltip/tooltip.css +5 -13
- package/dist/components/tooltip/tooltip.svelte +5 -5
- package/dist/components/tooltip/types.d.ts +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +23 -3
- package/dist/internal/config/presets.d.ts +149 -0
- package/dist/internal/config/presets.js +169 -0
- package/dist/internal/config/variables.d.ts +3 -0
- package/dist/internal/config/variables.js +3 -0
- package/dist/internal/{assets.svelte.js → core/actions/assets.svelte.js} +4 -4
- package/dist/internal/core/actions/dropdown.svelte.d.ts +7 -0
- package/dist/internal/core/actions/popover.svelte.d.ts +7 -0
- package/dist/internal/core/actions/tooltip.svelte.d.ts +7 -0
- package/dist/internal/{ripple.js → core/animations/ripple.js} +3 -3
- package/dist/internal/core/css.d.ts +1 -0
- package/dist/internal/core/css.js +16 -0
- package/dist/internal/core/formatter/component.d.ts +5 -0
- package/dist/internal/core/formatter/component.js +60 -0
- package/dist/internal/core/formatter/device.d.ts +5 -0
- package/dist/internal/core/formatter/device.js +66 -0
- package/dist/internal/core/formatter/index.d.ts +7 -0
- package/dist/internal/core/formatter/index.js +35 -0
- package/dist/internal/core/formatter/style.d.ts +4 -0
- package/dist/internal/core/formatter/style.js +15 -0
- package/dist/internal/core/formatter/theme.d.ts +5 -0
- package/dist/internal/core/formatter/theme.js +44 -0
- package/dist/internal/core/formatter/typography.d.ts +5 -0
- package/dist/internal/core/formatter/typography.js +12 -0
- package/dist/internal/core/standard-colors.d.ts +75 -0
- package/dist/internal/core/standard-colors.js +75 -0
- package/dist/internal/helpers/colors.d.ts +1 -0
- package/dist/internal/{colors.js → helpers/colors.js} +2 -2
- package/dist/internal/helpers/convert.d.ts +1 -0
- package/dist/internal/helpers/convert.js +17 -0
- package/dist/internal/helpers/deep-merge.d.ts +44 -0
- package/dist/internal/helpers/deep-merge.js +80 -0
- package/dist/internal/helpers/parser.d.ts +10 -0
- package/dist/internal/helpers/parser.js +93 -0
- package/dist/internal/plugins/vite.d.ts +8 -0
- package/dist/internal/plugins/vite.js +33 -0
- package/dist/internal/types/components.d.ts +14 -0
- package/dist/internal/types/configuration.d.ts +63 -0
- package/dist/internal/types/configuration.js +1 -0
- package/dist/internal/types/index.d.ts +2 -0
- package/dist/internal/types/index.js +2 -0
- package/dist/stores/breakpoints.d.ts +6 -0
- package/dist/stores/breakpoints.js +14 -0
- package/dist/stores/components.d.ts +8 -0
- package/dist/stores/components.js +26 -0
- package/dist/stores/devices.d.ts +6 -0
- package/dist/stores/devices.js +9 -0
- package/dist/stores/index.d.ts +5 -10
- package/dist/stores/index.js +5 -47
- package/dist/stores/themes.d.ts +2 -0
- package/dist/stores/themes.js +4 -0
- package/dist/stores/viewport.d.ts +7 -0
- package/dist/stores/viewport.js +7 -0
- package/dist/styles/animation.css +33 -0
- package/dist/styles/keyframes.css +30 -0
- package/dist/{style/normalize.css → styles/reset.css} +15 -7
- package/dist/themes.css +0 -0
- package/package.json +7 -3
- package/bin/lapikit.js +0 -86
- package/bin/legacy.js +0 -34
- package/bin/modules/adapter.js +0 -52
- package/bin/modules/plugin.js +0 -223
- package/bin/modules/preset.js +0 -11
- package/dist/internal/colors.d.ts +0 -1
- package/dist/internal/index.d.ts +0 -4
- package/dist/internal/index.js +0 -4
- package/dist/internal/types.d.ts +0 -57
- package/dist/internal/unit.d.ts +0 -1
- package/dist/internal/unit.js +0 -11
- package/dist/plugin/modules/config.d.ts +0 -2
- package/dist/plugin/modules/config.js +0 -54
- package/dist/plugin/modules/importer.d.ts +0 -1
- package/dist/plugin/modules/importer.js +0 -15
- package/dist/plugin/vitejs.d.ts +0 -6
- package/dist/plugin/vitejs.js +0 -26
- package/dist/preset.d.ts +0 -2
- package/dist/preset.js +0 -92
- package/dist/style/animation.css +0 -62
- package/dist/style/css.d.ts +0 -2
- package/dist/style/css.js +0 -34
- package/dist/style/parser/color.d.ts +0 -5
- package/dist/style/parser/color.js +0 -88
- package/dist/style/parser/component.d.ts +0 -2
- package/dist/style/parser/component.js +0 -115
- package/dist/style/parser/device.d.ts +0 -2
- package/dist/style/parser/device.js +0 -40
- package/dist/style/parser/index.d.ts +0 -4
- package/dist/style/parser/index.js +0 -4
- package/dist/style/parser/variable.d.ts +0 -2
- package/dist/style/parser/variable.js +0 -25
- package/dist/style/variable.css +0 -12
- /package/dist/{components/accordion → actions}/accordion.svelte.js +0 -0
- /package/dist/internal/{assets.svelte.d.ts → core/actions/assets.svelte.d.ts} +0 -0
- /package/dist/{components/dropdown → internal/core/actions}/dropdown.svelte.js +0 -0
- /package/dist/{components/popover → internal/core/actions}/popover.svelte.js +0 -0
- /package/dist/{components/tooltip → internal/core/actions}/tooltip.svelte.js +0 -0
- /package/dist/internal/{ripple.d.ts → core/animations/ripple.d.ts} +0 -0
- /package/dist/internal/{ansi.d.ts → core/bin/ansi.d.ts} +0 -0
- /package/dist/internal/{ansi.js → core/bin/ansi.js} +0 -0
- /package/dist/internal/{terminal.d.ts → core/bin/terminal.d.ts} +0 -0
- /package/dist/internal/{terminal.js → core/bin/terminal.js} +0 -0
- /package/dist/internal/{minify.d.ts → core/minify.d.ts} +0 -0
- /package/dist/internal/{minify.js → core/minify.js} +0 -0
- /package/dist/{utils/x11.d.ts → internal/core/x11-colors.d.ts} +0 -0
- /package/dist/{utils/x11.js → internal/core/x11-colors.js} +0 -0
- /package/dist/internal/{clickOutside.d.ts → helpers/outside.d.ts} +0 -0
- /package/dist/internal/{clickOutside.js → helpers/outside.js} +0 -0
- /package/dist/internal/{scroll.d.ts → helpers/scroll.d.ts} +0 -0
- /package/dist/internal/{scroll.js → helpers/scroll.js} +0 -0
- /package/dist/internal/{types.js → types/components.js} +0 -0
package/bin/configuration.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { promises as fs } from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
import { terminal } from './helper.js';
|
|
4
5
|
import presets from './presets.js';
|
|
5
6
|
|
|
6
7
|
async function findReferenceFile(projectPath) {
|
|
@@ -9,7 +10,7 @@ async function findReferenceFile(projectPath) {
|
|
|
9
10
|
try {
|
|
10
11
|
await fs.access(routesPath);
|
|
11
12
|
} catch {
|
|
12
|
-
|
|
13
|
+
terminal('error', `Lapikit cannot find the routes/ directory.`);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
const layoutFile = path.join(routesPath, '+layout.svelte');
|
|
@@ -65,7 +66,7 @@ async function addImportToReferenceFile(targetFile, referenceFile) {
|
|
|
65
66
|
const importStatement = `import "${relativePath.startsWith('.') ? relativePath : './' + relativePath}";\n`;
|
|
66
67
|
|
|
67
68
|
if (content.includes(`import "${relativePath}"`)) {
|
|
68
|
-
|
|
69
|
+
terminal('info', `Import statement already exists in ${referenceFile}`);
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
72
|
|
|
@@ -103,16 +104,150 @@ async function addImportToReferenceFile(targetFile, referenceFile) {
|
|
|
103
104
|
const newContent = lines.join('\n');
|
|
104
105
|
|
|
105
106
|
await fs.writeFile(referenceFile, newContent);
|
|
106
|
-
|
|
107
|
+
terminal('info', `Import has been added to ${referenceFile}`);
|
|
107
108
|
} catch (error) {
|
|
108
|
-
|
|
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}`);
|
|
109
245
|
throw error;
|
|
110
246
|
}
|
|
111
247
|
}
|
|
112
248
|
|
|
113
249
|
export async function initConfiguration(options) {
|
|
114
|
-
|
|
115
|
-
const { typescript, pathConfig, formatCSS } = options;
|
|
250
|
+
const { typescript, pathConfig, formatCSS, pathCSS } = options;
|
|
116
251
|
const ext = typescript ? 'ts' : 'js';
|
|
117
252
|
const targetDir = path.resolve(process.cwd(), pathConfig);
|
|
118
253
|
const targetFile = path.join(targetDir, `lapikit.${ext}`);
|
|
@@ -120,33 +255,49 @@ export async function initConfiguration(options) {
|
|
|
120
255
|
await fs.mkdir(targetDir, { recursive: true });
|
|
121
256
|
|
|
122
257
|
let fileCreated = false;
|
|
258
|
+
|
|
259
|
+
// Create Lapikit config
|
|
123
260
|
try {
|
|
124
|
-
console.log(`Trying to access ${targetFile}`);
|
|
125
261
|
await fs.access(targetFile);
|
|
126
|
-
|
|
262
|
+
terminal('info', `File ${targetFile} already exists.`);
|
|
127
263
|
} catch {
|
|
128
|
-
|
|
264
|
+
terminal('info', `Creating file: ${targetFile}`);
|
|
129
265
|
const content = presets({
|
|
130
|
-
|
|
266
|
+
adapterCSS: formatCSS
|
|
131
267
|
});
|
|
132
268
|
await fs.writeFile(targetFile, content);
|
|
133
|
-
|
|
269
|
+
terminal('info', `File created: ${targetFile}`);
|
|
134
270
|
fileCreated = true;
|
|
135
271
|
}
|
|
272
|
+
|
|
273
|
+
// Add Import Lapikit plugin
|
|
136
274
|
try {
|
|
137
275
|
const referenceFile = await findReferenceFile(process.cwd());
|
|
138
276
|
await addImportToReferenceFile(targetFile, referenceFile);
|
|
139
277
|
} catch (error) {
|
|
140
|
-
|
|
141
|
-
|
|
278
|
+
terminal('error', `Error adding import: ${error.message}`);
|
|
279
|
+
|
|
142
280
|
if (fileCreated) {
|
|
143
281
|
try {
|
|
144
282
|
await fs.unlink(targetFile);
|
|
145
|
-
|
|
283
|
+
terminal('info', `File ${targetFile} deleted due to error.`);
|
|
146
284
|
} catch {
|
|
147
285
|
// Ignore deletion error
|
|
148
286
|
}
|
|
149
287
|
}
|
|
150
288
|
throw error;
|
|
151
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
|
+
}
|
|
152
303
|
}
|
package/bin/helper.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { promises as fs } from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
1
|
const color = {
|
|
5
2
|
red: (text) => `\x1b[31m${text}\x1b[0m`,
|
|
6
3
|
green: (text) => `\x1b[32m${text}\x1b[0m`,
|
|
@@ -60,38 +57,3 @@ export const terminal = (type = 'info', msg) => {
|
|
|
60
57
|
else if (type === 'none') console.log(msg);
|
|
61
58
|
else console.log(name, ansi.bold.blue('[info]'), msg);
|
|
62
59
|
};
|
|
63
|
-
|
|
64
|
-
export function getCssPathFromArgs() {
|
|
65
|
-
const args = process.argv.slice(2);
|
|
66
|
-
return args[1] || 'src/app.css';
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function getLapikitPathFromArgs() {
|
|
70
|
-
const args = process.argv.slice(2);
|
|
71
|
-
// Search argument after --plugin-path or -p
|
|
72
|
-
const pluginPathIndex = args.findIndex((arg) => arg === '--plugin-path' || arg === '-p');
|
|
73
|
-
if (pluginPathIndex !== -1 && args[pluginPathIndex + 1]) {
|
|
74
|
-
return args[pluginPathIndex + 1];
|
|
75
|
-
}
|
|
76
|
-
return 'src/plugin';
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function validatePluginPath(pluginPath) {
|
|
80
|
-
if (!pluginPath.startsWith('src/')) {
|
|
81
|
-
return {
|
|
82
|
-
valid: false,
|
|
83
|
-
error: 'The path must start with "src/"'
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
return { valid: true };
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export async function envTypescript() {
|
|
90
|
-
const directory = process.cwd();
|
|
91
|
-
try {
|
|
92
|
-
await fs.readFile(path.resolve(directory, 'tsconfig.json'), 'utf-8');
|
|
93
|
-
return true;
|
|
94
|
-
} catch {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
}
|
package/bin/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { initConfiguration } from './configuration.js';
|
|
3
3
|
import { ansi, terminal } from './helper.js';
|
|
4
|
-
import { legacyConfiguration } from './legacy.js';
|
|
5
4
|
import { initPrompts } from './prompts.js';
|
|
6
5
|
|
|
7
6
|
async function run() {
|
|
@@ -18,24 +17,17 @@ async function run() {
|
|
|
18
17
|
|
|
19
18
|
const promptsConfig = await initPrompts();
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
await legacyConfiguration(promptsConfig);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (promptsConfig.env === 'experimental') {
|
|
26
|
-
terminal('warn', `Experimental mode is not yet implemented.`);
|
|
27
|
-
await initConfiguration(promptsConfig);
|
|
28
|
-
}
|
|
20
|
+
await initConfiguration(promptsConfig);
|
|
29
21
|
}
|
|
30
22
|
|
|
31
23
|
run()
|
|
32
24
|
.then(() => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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`);
|
|
36
28
|
process.exit(0);
|
|
37
29
|
})
|
|
38
30
|
.catch((error) => {
|
|
39
|
-
|
|
31
|
+
terminal('error', `Error: ${error}`);
|
|
40
32
|
process.exit(1);
|
|
41
33
|
});
|
package/bin/presets.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
function presets({
|
|
1
|
+
function presets({ adapterCSS }) {
|
|
2
2
|
let content = '';
|
|
3
3
|
|
|
4
4
|
content += `/**\n`;
|
|
5
|
-
content +=
|
|
6
|
-
content +=
|
|
5
|
+
content += ` * Lapikit\n`;
|
|
6
|
+
content += ` * Library documentation: https://lapikit.dev\n`;
|
|
7
7
|
content += ` */\n\n`;
|
|
8
8
|
|
|
9
|
-
if (
|
|
10
|
-
content += `//
|
|
11
|
-
content += `import 'lapikit/
|
|
9
|
+
if (adapterCSS === 'css') {
|
|
10
|
+
content += `// Styles\n`;
|
|
11
|
+
content += `import 'lapikit/styles';\n`;
|
|
12
|
+
content += `import 'lapikit/themes';\n\n`;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
content += `// Composables\n`;
|
|
15
|
-
content += `import
|
|
16
|
+
content += `import createLapikit from 'lapikit';\n\n`;
|
|
16
17
|
|
|
17
18
|
content += `// https://lapikit.dev/docs/getting-started\n`;
|
|
18
|
-
content += `export default
|
|
19
|
+
content += `export default createLapikit({\n`;
|
|
20
|
+
content += `\tadapterCSS: "${adapterCSS}",\n`;
|
|
21
|
+
content += `\n});`;
|
|
19
22
|
|
|
20
23
|
return content;
|
|
21
24
|
}
|
package/bin/prompts.js
CHANGED
|
@@ -1,101 +1,67 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import prompts from 'prompts';
|
|
3
|
+
import { terminal } from './helper.js';
|
|
3
4
|
|
|
4
5
|
export async function initPrompts() {
|
|
5
6
|
const { confirm } = await prompts({
|
|
6
7
|
type: 'toggle',
|
|
7
8
|
name: 'confirm',
|
|
8
|
-
message: '
|
|
9
|
+
message: 'Launch install Lapikit on your project?',
|
|
9
10
|
initial: true,
|
|
10
11
|
active: 'Yes',
|
|
11
12
|
inactive: 'No'
|
|
12
13
|
});
|
|
13
14
|
|
|
14
15
|
if (!confirm) {
|
|
15
|
-
|
|
16
|
+
terminal('warn', `installation canceled.`);
|
|
16
17
|
process.exit(0);
|
|
17
18
|
}
|
|
18
|
-
// temps with legacy and new process install
|
|
19
|
-
const { type } = await prompts({
|
|
20
|
-
type: 'select',
|
|
21
|
-
name: 'type',
|
|
22
|
-
message: 'Select installation type:',
|
|
23
|
-
choices: [
|
|
24
|
-
{ title: 'Classic install with lapikit.config.js', value: 'current' },
|
|
25
|
-
{
|
|
26
|
-
title: 'Preview install with new plugin/lapikit.(js|ts) <experimental>',
|
|
27
|
-
value: 'experimental'
|
|
28
|
-
}
|
|
29
|
-
]
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
if (type === 'current') {
|
|
33
|
-
// Classic install
|
|
34
|
-
const settings = await prompts([
|
|
35
|
-
{
|
|
36
|
-
type: 'text',
|
|
37
|
-
name: 'pathCSS',
|
|
38
|
-
message: 'Where would you like to import the lapikit CSS files?',
|
|
39
|
-
initial: 'src/app.css',
|
|
40
|
-
validate: (value) =>
|
|
41
|
-
value.startsWith('src/') ? true : 'Please provide a valid path starting with src/'
|
|
42
|
-
}
|
|
43
|
-
]);
|
|
44
19
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
initial: 'src/app.css',
|
|
89
|
-
validate: (value) =>
|
|
90
|
-
value.startsWith('src/') ? true : 'Please provide a valid path starting with src/'
|
|
91
|
-
}
|
|
92
|
-
]);
|
|
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
|
+
]);
|
|
93
63
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
...settings,
|
|
98
|
-
env: 'experimental'
|
|
99
|
-
};
|
|
100
|
-
}
|
|
64
|
+
return {
|
|
65
|
+
...settings
|
|
66
|
+
};
|
|
101
67
|
}
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from './accordion.svelte.js';
|
|
2
|
+
export * from './use-theme.js';
|
package/dist/actions/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from '
|
|
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
|
+
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
.kit-accordion {
|
|
2
|
-
--accordion-color: var(--on, var(--kit-on-container));
|
|
3
|
-
--accordion-background: var(--base, var(--kit-container));
|
|
4
|
-
--accordion-radius: var(--shape, var(--kit-radius-md));
|
|
5
|
-
|
|
6
2
|
display: flex;
|
|
7
3
|
flex-wrap: wrap;
|
|
8
4
|
justify-content: center;
|
|
@@ -38,76 +34,3 @@
|
|
|
38
34
|
pointer-events: none;
|
|
39
35
|
user-select: none;
|
|
40
36
|
}
|
|
41
|
-
|
|
42
|
-
/* item */
|
|
43
|
-
.kit-accordion .kit-accordion-item {
|
|
44
|
-
flex: 1 0 100%;
|
|
45
|
-
max-width: 100%;
|
|
46
|
-
position: relative;
|
|
47
|
-
transition: 0.3s all cubic-bezier(0.4, 0, 0.2, 1);
|
|
48
|
-
transition-property: margin-top, border-radius, border, max-width;
|
|
49
|
-
border-radius: var(--shape, var(--accordion-radius, var(--kit-radius-md)));
|
|
50
|
-
color: var(--on, var(--accordion-color, var(--kit-on-container)));
|
|
51
|
-
background-color: var(--base, var(--accordion-background, var(--kit-container)));
|
|
52
|
-
/* transition:
|
|
53
|
-
color 0.5s,
|
|
54
|
-
background-color 0.5s; */
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.kit-accordion .kit-accordion-item > button,
|
|
58
|
-
.kit-accordion .kit-accordion-item > [type='button'] {
|
|
59
|
-
font: inherit;
|
|
60
|
-
overflow: visible;
|
|
61
|
-
background-color: transparent;
|
|
62
|
-
border-style: none;
|
|
63
|
-
cursor: pointer;
|
|
64
|
-
color: inherit;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.kit-accordion .kit-accordion-item .kit-accordion-item--title {
|
|
68
|
-
align-items: center;
|
|
69
|
-
text-align: start;
|
|
70
|
-
border-radius: inherit;
|
|
71
|
-
display: flex;
|
|
72
|
-
font-size: 0.9375rem;
|
|
73
|
-
min-height: 3rem;
|
|
74
|
-
outline: none;
|
|
75
|
-
padding: 1rem 1.5rem;
|
|
76
|
-
position: relative;
|
|
77
|
-
transition: 0.3s min-height margin-bottom margin-top border-radius cubic-bezier(0.4, 0, 0.2, 1);
|
|
78
|
-
width: 100%;
|
|
79
|
-
justify-content: space-between;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.kit-accordion .kit-accordion-item .kit-accordion-item--text {
|
|
83
|
-
display: flex;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.kit-accordion .kit-accordion-item .kit-accordion-item--text .kit-accordion-item--text-wrapper {
|
|
87
|
-
padding: 0.5rem 1.5rem 1rem;
|
|
88
|
-
flex: 1 1 auto;
|
|
89
|
-
max-width: 100%;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.kit-accordion .kit-accordion-item .kit-accordion-item--icon {
|
|
93
|
-
display: inline-flex;
|
|
94
|
-
margin-bottom: -0.25rem;
|
|
95
|
-
margin-top: -0.25rem;
|
|
96
|
-
-webkit-user-select: none;
|
|
97
|
-
user-select: none;
|
|
98
|
-
margin-inline-start: auto;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/* disabled */
|
|
102
|
-
.kit-accordion .kit-accordion-item .kit-accordion-item--title.kit-accordion-item--disabled,
|
|
103
|
-
.kit-accordion .kit-accordion-item .kit-accordion-item--title[disabled],
|
|
104
|
-
.kit-accordion .kit-accordion-item .kit-accordion-item--title:disabled {
|
|
105
|
-
pointer-events: none;
|
|
106
|
-
user-select: none;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.kit-accordion .kit-accordion-item .kit-accordion-item--title.kit-accordion-item--disabled > *,
|
|
110
|
-
.kit-accordion .kit-accordion-item .kit-accordion-item--title[disabled] > *,
|
|
111
|
-
.kit-accordion .kit-accordion-item .kit-accordion-item--title:disabled > * {
|
|
112
|
-
opacity: 0.6;
|
|
113
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { getAssets } from '../../internal/assets.svelte.js';
|
|
2
|
+
import { getAssets } from '../../internal/core/actions/assets.svelte.js';
|
|
3
3
|
import type { AccordionProps } from './types.js';
|
|
4
4
|
|
|
5
5
|
let {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
background,
|
|
13
13
|
spacer,
|
|
14
14
|
hideIcon,
|
|
15
|
+
rounded,
|
|
15
16
|
...rest
|
|
16
17
|
}: AccordionProps = $props();
|
|
17
18
|
|
|
@@ -30,8 +31,9 @@
|
|
|
30
31
|
dark && 'dark',
|
|
31
32
|
rest.class
|
|
32
33
|
]}
|
|
33
|
-
style:--
|
|
34
|
-
style:--
|
|
34
|
+
style:--accordion-shape={assets.shape(rounded)}
|
|
35
|
+
style:--accordion-background={assets.color(background)}
|
|
36
|
+
style:--accordion-color={assets.color(color)}
|
|
35
37
|
>
|
|
36
38
|
{@render children?.()}
|
|
37
39
|
</svelte:element>
|