lapikit 0.0.0-insiders.da3209a → 0.0.0-insiders.dd024f5
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/dist/components/accordion/accordion.svelte +118 -0
- package/dist/components/alert/alert.svelte +122 -0
- package/dist/components/app/app.svelte +18 -0
- package/dist/components/appbar/appbar.css +4 -4
- package/dist/components/appbar/appbar.svelte +45 -0
- package/dist/components/aspect-ratio/aspect-ratio.svelte +23 -4
- package/dist/components/avatar/avatar.svelte +114 -0
- package/dist/components/button/button.css +14 -14
- package/dist/components/button/button.svelte +230 -0
- package/dist/components/card/card.css +4 -4
- package/dist/components/card/card.svelte +108 -0
- package/dist/components/chip/chip.css +9 -9
- package/dist/components/chip/chip.svelte +211 -0
- package/dist/components/dialog/dialog.svelte +144 -0
- package/dist/components/dropdown/dropdown.svelte +24 -0
- package/dist/components/icon/icon.css +5 -3
- package/dist/components/icon/icon.svelte +89 -0
- package/dist/components/list/list.css +8 -8
- package/dist/components/list/list.svelte +199 -0
- package/dist/components/list/modules/list-item.svelte +199 -0
- package/dist/components/modal/modal.svelte +135 -0
- package/dist/components/popover/popover.svelte +24 -0
- package/dist/components/separator/separator.svelte +48 -0
- package/dist/components/spacer/spacer.svelte +5 -0
- package/dist/components/textfield/textfield.css +8 -8
- package/dist/components/textfield/textfield.svelte +270 -0
- package/dist/components/toolbar/toolbar.css +9 -9
- package/dist/components/toolbar/toolbar.svelte +135 -0
- package/dist/components/tooltip/tooltip.svelte +127 -0
- package/dist/internal/config/presets.d.ts +28 -0
- package/dist/internal/config/variables.d.ts +14 -0
- package/dist/internal/config/variables.js +15 -1
- package/dist/internal/core/formatter/component.d.ts +1 -1
- package/dist/internal/core/formatter/component.js +44 -37
- package/dist/internal/core/formatter/index.d.ts +1 -0
- package/dist/internal/core/formatter/index.js +7 -4
- package/dist/internal/core/formatter/styles.d.ts +1 -1
- package/dist/internal/core/formatter/styles.js +4 -3
- package/dist/internal/core/formatter/theme.d.ts +1 -1
- package/dist/internal/core/formatter/theme.js +1 -1
- package/dist/internal/core/formatter/typography.d.ts +1 -1
- package/dist/internal/core/formatter/typography.js +1 -1
- package/dist/internal/helpers/parser.js +19 -20
- package/dist/internal/plugins/vite.d.ts +2 -2
- package/dist/internal/plugins/vite.js +5 -5
- package/package.json +1 -1
|
@@ -5,52 +5,59 @@ import path from 'path';
|
|
|
5
5
|
import { parserCSSBreakpoints } from '../../helpers/parser.js';
|
|
6
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = dirname(__filename);
|
|
8
|
-
export function componentFormatter({ breakpoints }) {
|
|
9
|
-
// load
|
|
10
|
-
function
|
|
8
|
+
export async function componentFormatter({ breakpoints }) {
|
|
9
|
+
// load svelte component files (includes on components folders)
|
|
10
|
+
function loadSvelteFiles(directory) {
|
|
11
11
|
fs.readdirSync(directory).forEach((File) => {
|
|
12
12
|
const absolutePath = path.join(directory, File);
|
|
13
13
|
if (fs.statSync(absolutePath).isDirectory())
|
|
14
|
-
return
|
|
15
|
-
else if (absolutePath.endsWith('.
|
|
14
|
+
return loadSvelteFiles(absolutePath);
|
|
15
|
+
else if (absolutePath.endsWith('.svelte') && !absolutePath.includes('/_')) {
|
|
16
16
|
console.log(absolutePath);
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
const fileContent = fs.readFileSync(absolutePath, 'utf8');
|
|
18
|
+
const styleRegex = /<style[^>]*>([\s\S]*?)<\/style>/gi;
|
|
19
|
+
const styleMatch = styleRegex.exec(fileContent);
|
|
20
|
+
if (styleMatch) {
|
|
21
|
+
const originalStyleContent = styleMatch[1];
|
|
22
|
+
const content = parserCSSBreakpoints(originalStyleContent);
|
|
23
|
+
let css = '';
|
|
24
|
+
for (const property in breakpoints) {
|
|
25
|
+
if (property !== 'base') {
|
|
26
|
+
const name = `.${/^\d/.test(property) ? `\\3${property}` : property}\\:`;
|
|
27
|
+
const value = typeof breakpoints[property] === 'number'
|
|
28
|
+
? `${breakpoints[property]}px`
|
|
29
|
+
: breakpoints[property];
|
|
30
|
+
if (content.base !== '' || content.minmax !== '' || content.min !== '') {
|
|
31
|
+
css += `@media screen and (min-width: ${value}) {\n`;
|
|
32
|
+
if (content.base !== '')
|
|
33
|
+
css += content.base.replaceAll('[breakpoint]', name);
|
|
34
|
+
if (content.minmax !== '')
|
|
35
|
+
css += content.minmax.replaceAll('[breakpoint]', name);
|
|
36
|
+
if (content.min !== '')
|
|
37
|
+
css += content.min.replaceAll('[breakpoint]', name);
|
|
38
|
+
css += `}\n`;
|
|
39
|
+
}
|
|
40
|
+
if (content.max !== '' || content.all !== '') {
|
|
41
|
+
css += `@media screen and (max-width: ${value}) {\n`;
|
|
42
|
+
if (content.max !== '')
|
|
43
|
+
css += content.max.replaceAll('[breakpoint]', name);
|
|
44
|
+
if (content.all !== '')
|
|
45
|
+
css += content.all.replaceAll('[breakpoint]', name);
|
|
46
|
+
css += `}\n`;
|
|
47
|
+
}
|
|
34
48
|
}
|
|
35
|
-
|
|
36
|
-
css +=
|
|
37
|
-
if (content.max !== '')
|
|
38
|
-
css += content.max.replaceAll('[breakpoint]', name);
|
|
39
|
-
if (content.all !== '')
|
|
40
|
-
css += content.all.replaceAll('[breakpoint]', name);
|
|
41
|
-
css += `}\n`;
|
|
49
|
+
else {
|
|
50
|
+
css += content.all.replaceAll('[breakpoint]', '.');
|
|
42
51
|
}
|
|
43
52
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
let formattedCSS = css;
|
|
54
|
+
formattedCSS = formattedCSS.trim().replace(/\n{3,}/g, '\n\n');
|
|
55
|
+
console.log(formattedCSS);
|
|
56
|
+
const updatedFileContent = fileContent.replace(styleRegex, `<style>${formattedCSS}</style>`);
|
|
57
|
+
fs.writeFileSync(absolutePath, updatedFileContent, 'utf8');
|
|
47
58
|
}
|
|
48
|
-
let formattedCSS = css;
|
|
49
|
-
formattedCSS = formattedCSS.trim().replace(/\n{3,}/g, '\n\n');
|
|
50
|
-
console.log(formattedCSS);
|
|
51
|
-
fs.writeFileSync(absolutePath, formattedCSS, 'utf8');
|
|
52
59
|
}
|
|
53
60
|
});
|
|
54
61
|
}
|
|
55
|
-
|
|
62
|
+
loadSvelteFiles(path.resolve(__dirname, '../../../components'));
|
|
56
63
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { preset } from '../../config/presets.js';
|
|
2
2
|
import { deepMerge } from '../../deepMerge.js';
|
|
3
3
|
import { componentFormatter } from './component.js';
|
|
4
|
+
import { stylesFormatter } from './styles.js';
|
|
4
5
|
import { themesFormatter } from './theme.js';
|
|
5
6
|
import { typographyFormatter } from './typography.js';
|
|
6
7
|
export async function css(config) {
|
|
@@ -8,20 +9,22 @@ export async function css(config) {
|
|
|
8
9
|
const defaultTheme = config?.theme?.defaultTheme || preset.theme.defaultTheme;
|
|
9
10
|
const defaultTypography = config?.typography?.defaultTypography || preset.typography.defaultTypography;
|
|
10
11
|
// formatter
|
|
11
|
-
const themes = themesFormatter({
|
|
12
|
+
const themes = await themesFormatter({
|
|
12
13
|
themes: deepMerge(preset.theme.themes, config?.theme?.themes || {}),
|
|
13
14
|
defaultTheme
|
|
14
15
|
});
|
|
15
|
-
const typography = typographyFormatter({
|
|
16
|
+
const typography = await typographyFormatter({
|
|
16
17
|
typography: deepMerge(preset.typography.fonts, config?.typography?.fonts || {}),
|
|
17
18
|
defaultTypography
|
|
18
19
|
});
|
|
20
|
+
const styles = await stylesFormatter({ styles: deepMerge(preset.styles, config?.styles || {}) });
|
|
19
21
|
// components
|
|
20
|
-
componentFormatter({
|
|
22
|
+
await componentFormatter({
|
|
21
23
|
breakpoints: deepMerge(preset.breakpoints.thresholds, config?.breakpoints?.thresholds || {})
|
|
22
24
|
});
|
|
23
25
|
return {
|
|
24
26
|
themes: themes,
|
|
25
|
-
typography: typography
|
|
27
|
+
typography: typography,
|
|
28
|
+
styles: styles
|
|
26
29
|
};
|
|
27
30
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { parserValues } from '../../helpers/parser.js';
|
|
2
|
-
export function stylesFormatter({ styles }) {
|
|
2
|
+
export async function stylesFormatter({ styles }) {
|
|
3
3
|
let css = `:root {\n`;
|
|
4
4
|
for (const [name, values] of Object.entries(styles)) {
|
|
5
5
|
if (values && typeof values === 'object') {
|
|
6
6
|
for (const [styleName, styleValue] of Object.entries(values || {})) {
|
|
7
|
-
|
|
7
|
+
console.log('stylesFormatter', styleName, styleValue);
|
|
8
|
+
css += ` --l-theme-${name}-${styleName}: ${parserValues(styleValue)};\n`;
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
else {
|
|
11
|
-
css += ` --
|
|
12
|
+
css += ` --l-theme-${name}: ${parserValues(values)};\n`;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
return (css += '}\n');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { preset } from '../../config/presets.js';
|
|
2
2
|
import { deepMerge } from '../../deepMerge.js';
|
|
3
|
-
export function themesFormatter({ themes, defaultTheme = 'light' }) {
|
|
3
|
+
export async function themesFormatter({ themes, defaultTheme = 'light' }) {
|
|
4
4
|
let css = '';
|
|
5
5
|
for (const [name, values] of Object.entries(themes)) {
|
|
6
6
|
const ref = values?.dark ? preset.theme.themes.dark : preset.theme.themes.light;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parserValues } from '../../helpers/parser.js';
|
|
2
|
-
export function typographyFormatter({ typography, defaultTypography = 'default' }) {
|
|
2
|
+
export async function typographyFormatter({ typography, defaultTypography = 'default' }) {
|
|
3
3
|
let css = '';
|
|
4
4
|
for (const [name, values] of Object.entries(typography)) {
|
|
5
5
|
let cssTypo = defaultTypography === name ? `:root {\n` : `.${name} {\n`;
|
|
@@ -39,7 +39,7 @@ export const parserCSSBreakpoints = (css) => {
|
|
|
39
39
|
}
|
|
40
40
|
if (matchedType) {
|
|
41
41
|
const rule = `${selectors} {\n${body}\n}`;
|
|
42
|
-
extractedByType.
|
|
42
|
+
extractedByType.all.push(rule);
|
|
43
43
|
extractedByType[matchedType].push(rule);
|
|
44
44
|
matchesToRemove.push(fullMatch);
|
|
45
45
|
}
|
|
@@ -49,25 +49,24 @@ export const parserCSSBreakpoints = (css) => {
|
|
|
49
49
|
cleaned = cleaned.replace(rule, '').replace(/\n{2,}/g, '\n\n');
|
|
50
50
|
}
|
|
51
51
|
return {
|
|
52
|
-
all: extractedByType.
|
|
53
|
-
.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
.trim()
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
.replaceAll('[breakpoint|max]', '[breakpoint]')
|
|
66
|
-
|
|
67
|
-
minmax: extractedByType.
|
|
68
|
-
.join('\n\n')
|
|
69
|
-
|
|
70
|
-
.trim(),
|
|
52
|
+
all: extractedByType.all
|
|
53
|
+
? extractedByType.all
|
|
54
|
+
.join('\n\n')
|
|
55
|
+
.replaceAll('[breakpoint|min]', '[breakpoint]')
|
|
56
|
+
.replaceAll('[breakpoint|max]', '[breakpoint]')
|
|
57
|
+
.replaceAll('[breakpoint|all]', '[breakpoint]')
|
|
58
|
+
.trim()
|
|
59
|
+
: '',
|
|
60
|
+
base: extractedByType.base ? extractedByType.base.join('\n\n').trim() : '',
|
|
61
|
+
min: extractedByType.min
|
|
62
|
+
? extractedByType.min.join('\n\n').replaceAll('[breakpoint|min]', '[breakpoint]').trim()
|
|
63
|
+
: '',
|
|
64
|
+
max: extractedByType.max
|
|
65
|
+
? extractedByType.max.join('\n\n').replaceAll('[breakpoint|max]', '[breakpoint]').trim()
|
|
66
|
+
: '',
|
|
67
|
+
minmax: extractedByType.minmax
|
|
68
|
+
? extractedByType.minmax.join('\n\n').replaceAll('[breakpoint|all]', '[breakpoint]').trim()
|
|
69
|
+
: '',
|
|
71
70
|
cleaned: cleaned.trim()
|
|
72
71
|
};
|
|
73
72
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
type Lapikit = {
|
|
2
2
|
config?: string;
|
|
3
3
|
};
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function lapikit({ config }?: Lapikit): Promise<{
|
|
5
5
|
name: string;
|
|
6
|
-
|
|
6
|
+
config(): Promise<void>;
|
|
7
7
|
}>;
|
|
8
8
|
export {};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
2
|
import { dirname } from 'path';
|
|
3
3
|
import { terminal } from '../terminal.js';
|
|
4
|
-
import { css } from '
|
|
4
|
+
import { css } from '../core/formatter/index.js';
|
|
5
5
|
import { parserConfigLapikit } from '../helpers/parser.js';
|
|
6
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = dirname(__filename);
|
|
8
8
|
import fsPromises from 'fs/promises';
|
|
9
9
|
import path from 'path';
|
|
10
10
|
const app = process.cwd();
|
|
11
|
-
export async function
|
|
11
|
+
export async function lapikit({ config } = {}) {
|
|
12
12
|
return {
|
|
13
13
|
name: 'lapikit/vite',
|
|
14
|
-
async
|
|
14
|
+
async config() {
|
|
15
15
|
if (config) {
|
|
16
16
|
const configuration = await parserConfigLapikit(app, config);
|
|
17
17
|
// generate styles
|
|
18
18
|
const styles = await css(configuration);
|
|
19
|
-
fsPromises.writeFile(path.resolve(__dirname, '
|
|
20
|
-
console.log('styles', styles);
|
|
19
|
+
fsPromises.writeFile(path.resolve(__dirname, '../../labs.css'), styles?.themes + '\n\n' + styles?.typography + '\n\n' + styles?.styles || '');
|
|
20
|
+
console.log('styles', styles, __dirname);
|
|
21
21
|
}
|
|
22
22
|
terminal('info', 'lapikit is up!');
|
|
23
23
|
}
|