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.
Files changed (46) hide show
  1. package/dist/components/accordion/accordion.svelte +118 -0
  2. package/dist/components/alert/alert.svelte +122 -0
  3. package/dist/components/app/app.svelte +18 -0
  4. package/dist/components/appbar/appbar.css +4 -4
  5. package/dist/components/appbar/appbar.svelte +45 -0
  6. package/dist/components/aspect-ratio/aspect-ratio.svelte +23 -4
  7. package/dist/components/avatar/avatar.svelte +114 -0
  8. package/dist/components/button/button.css +14 -14
  9. package/dist/components/button/button.svelte +230 -0
  10. package/dist/components/card/card.css +4 -4
  11. package/dist/components/card/card.svelte +108 -0
  12. package/dist/components/chip/chip.css +9 -9
  13. package/dist/components/chip/chip.svelte +211 -0
  14. package/dist/components/dialog/dialog.svelte +144 -0
  15. package/dist/components/dropdown/dropdown.svelte +24 -0
  16. package/dist/components/icon/icon.css +5 -3
  17. package/dist/components/icon/icon.svelte +89 -0
  18. package/dist/components/list/list.css +8 -8
  19. package/dist/components/list/list.svelte +199 -0
  20. package/dist/components/list/modules/list-item.svelte +199 -0
  21. package/dist/components/modal/modal.svelte +135 -0
  22. package/dist/components/popover/popover.svelte +24 -0
  23. package/dist/components/separator/separator.svelte +48 -0
  24. package/dist/components/spacer/spacer.svelte +5 -0
  25. package/dist/components/textfield/textfield.css +8 -8
  26. package/dist/components/textfield/textfield.svelte +270 -0
  27. package/dist/components/toolbar/toolbar.css +9 -9
  28. package/dist/components/toolbar/toolbar.svelte +135 -0
  29. package/dist/components/tooltip/tooltip.svelte +127 -0
  30. package/dist/internal/config/presets.d.ts +28 -0
  31. package/dist/internal/config/variables.d.ts +14 -0
  32. package/dist/internal/config/variables.js +15 -1
  33. package/dist/internal/core/formatter/component.d.ts +1 -1
  34. package/dist/internal/core/formatter/component.js +44 -37
  35. package/dist/internal/core/formatter/index.d.ts +1 -0
  36. package/dist/internal/core/formatter/index.js +7 -4
  37. package/dist/internal/core/formatter/styles.d.ts +1 -1
  38. package/dist/internal/core/formatter/styles.js +4 -3
  39. package/dist/internal/core/formatter/theme.d.ts +1 -1
  40. package/dist/internal/core/formatter/theme.js +1 -1
  41. package/dist/internal/core/formatter/typography.d.ts +1 -1
  42. package/dist/internal/core/formatter/typography.js +1 -1
  43. package/dist/internal/helpers/parser.js +19 -20
  44. package/dist/internal/plugins/vite.d.ts +2 -2
  45. package/dist/internal/plugins/vite.js +5 -5
  46. 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 css component files (includes on components folders)
10
- function loadCSSFiles(directory) {
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 loadCSSFiles(absolutePath);
15
- else if (absolutePath.endsWith('.css') && !absolutePath.includes('/_')) {
14
+ return loadSvelteFiles(absolutePath);
15
+ else if (absolutePath.endsWith('.svelte') && !absolutePath.includes('/_')) {
16
16
  console.log(absolutePath);
17
- let css = '';
18
- const content = parserCSSBreakpoints(fs.readFileSync(absolutePath, 'utf8'));
19
- for (const property in breakpoints) {
20
- if (property !== 'base') {
21
- const name = `.${/^\d/.test(property) ? `\\3${property}` : property}\\:`;
22
- const value = typeof breakpoints[property] === 'number'
23
- ? `${breakpoints[property]}px`
24
- : breakpoints[property];
25
- if (content.base !== '' || content.minmax !== '' || content.min !== '') {
26
- css += `@media screen and (min-width: ${value}) {\n`;
27
- if (content.base !== '')
28
- css += content.base.replaceAll('[breakpoint]', name);
29
- if (content.minmax !== '')
30
- css += content.minmax.replaceAll('[breakpoint]', name);
31
- if (content.min !== '')
32
- css += content.min.replaceAll('[breakpoint]', name);
33
- css += `}\n`;
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
- if (content.max !== '' || content.all !== '') {
36
- css += `@media screen and (max-width: ${value}) {\n`;
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
- else {
45
- css += content.all.replaceAll('[breakpoint]', '.');
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
- loadCSSFiles(path.resolve(__dirname, '../../../components'));
62
+ loadSvelteFiles(path.resolve(__dirname, '../../../components'));
56
63
  }
@@ -2,4 +2,5 @@ import type { DevConfiguration } from '../../types/index.js';
2
2
  export declare function css(config: DevConfiguration): Promise<{
3
3
  themes: string;
4
4
  typography: string;
5
+ styles: string;
5
6
  }>;
@@ -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,4 +1,4 @@
1
1
  import type { FragStyles } from '../../types/configuration.js';
2
2
  export declare function stylesFormatter({ styles }: {
3
3
  styles: FragStyles;
4
- }): string;
4
+ }): Promise<string>;
@@ -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
- css += ` --prism-${name}-${styleName}: ${parserValues(styleValue)};\n`;
7
+ console.log('stylesFormatter', styleName, styleValue);
8
+ css += ` --l-theme-${name}-${styleName}: ${parserValues(styleValue)};\n`;
8
9
  }
9
10
  }
10
11
  else {
11
- css += ` --prism-${name}: ${parserValues(values)};\n`;
12
+ css += ` --l-theme-${name}: ${parserValues(values)};\n`;
12
13
  }
13
14
  }
14
15
  return (css += '}\n');
@@ -2,4 +2,4 @@ import type { FragThemes } from '../../types/index.js';
2
2
  export declare function themesFormatter({ themes, defaultTheme }: {
3
3
  themes: FragThemes;
4
4
  defaultTheme: string;
5
- }): string;
5
+ }): Promise<string>;
@@ -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;
@@ -2,4 +2,4 @@ import type { FragTypography } from '../../types/configuration.js';
2
2
  export declare function typographyFormatter({ typography, defaultTypography }: {
3
3
  typography: FragTypography;
4
4
  defaultTypography: string;
5
- }): string;
5
+ }): Promise<string>;
@@ -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.allExtracted.push(rule);
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.allExtracted
53
- .join('\n\n')
54
- .replaceAll('[breakpoint|min]', '[breakpoint]')
55
- .replaceAll('[breakpoint|max]', '[breakpoint]')
56
- .replaceAll('[breakpoint|all]', '[breakpoint]')
57
- .trim(),
58
- base: extractedByType.defaultExtracted.join('\n\n').trim(),
59
- min: extractedByType.minExtracted
60
- .join('\n\n')
61
- .replaceAll('[breakpoint|min]', '[breakpoint]')
62
- .trim(),
63
- max: extractedByType.maxExtracted
64
- .join('\n\n')
65
- .replaceAll('[breakpoint|max]', '[breakpoint]')
66
- .trim(),
67
- minmax: extractedByType.allModifierExtracted
68
- .join('\n\n')
69
- .replaceAll('[breakpoint|all]', '[breakpoint]')
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 lapikitEvol({ config }?: Lapikit): Promise<{
4
+ export declare function lapikit({ config }?: Lapikit): Promise<{
5
5
  name: string;
6
- configResolved(): Promise<void>;
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 '../../plugin/css.js';
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 lapikitEvol({ config } = {}) {
11
+ export async function lapikit({ config } = {}) {
12
12
  return {
13
13
  name: 'lapikit/vite',
14
- async configResolved() {
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, '../labs.css'), styles?.themes);
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lapikit",
3
- "version": "0.0.0-insiders.da3209a",
3
+ "version": "0.0.0-insiders.dd024f5",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"