lapikit 0.0.0-insiders.90a2698 → 0.0.0-insiders.90eb48b

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/helper.js CHANGED
@@ -1,3 +1,6 @@
1
+ import { promises as fs } from 'fs';
2
+ import path from 'path';
3
+
1
4
  const color = {
2
5
  red: (text) => `\x1b[31m${text}\x1b[0m`,
3
6
  green: (text) => `\x1b[32m${text}\x1b[0m`,
@@ -63,6 +66,26 @@ export function getCssPathFromArgs() {
63
66
  return args[1] || 'src/app.css';
64
67
  }
65
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
+
66
89
  export async function envTypescript() {
67
90
  const directory = process.cwd();
68
91
  try {
package/bin/lapikit.js CHANGED
@@ -1,9 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import { promises as fs } from 'fs';
3
3
  import path from 'path';
4
- import { ansi, terminal, envTypescript } from './helper.js';
4
+ import {
5
+ ansi,
6
+ terminal,
7
+ envTypescript,
8
+ getLapikitPathFromArgs,
9
+ validatePluginPath
10
+ } from './helper.js';
5
11
  import { preset } from './modules/preset.js';
6
12
  import { adapterCSSConfig, adapterViteConfig } from './modules/adapter.js';
13
+ import { createPluginStructure, setupSvelteKitIntegration } from './modules/plugin.js';
7
14
 
8
15
  const [, , command] = process.argv;
9
16
  const typescriptEnabled = envTypescript();
@@ -11,8 +18,9 @@ const typescriptEnabled = envTypescript();
11
18
  if (process.argv.includes('--help') || process.argv.includes('-h')) {
12
19
  terminal(
13
20
  'info',
14
- `usage: ${ansi.color.yellow('npx lapikit init {cssPath}')}\n\n ${ansi.variant.bold('options:')}\n
15
- - {cssPath}: (${ansi.color.cyan('src/app.css')}) customize path on your origin css file.\n\n`
21
+ `usage: ${ansi.color.yellow('npx lapikit init {cssPath} [--plugin-path {pluginPath}]')}\n\n ${ansi.variant.bold('options:')}\n
22
+ - {cssPath}: (${ansi.color.cyan('src/app.css')}) customize path on your origin css file.
23
+ - --plugin-path, -p: (${ansi.color.cyan('src/plugin')}) customize path for the plugin directory.\n\n`
16
24
  );
17
25
  process.exit(0);
18
26
  } else if (command === 'init') {
@@ -27,6 +35,15 @@ if (process.argv.includes('--help') || process.argv.includes('-h')) {
27
35
 
28
36
  terminal('none', `${ansi.bold.blue('LAPIKIT')} - Component Library for Svelte\n\n`);
29
37
 
38
+ // Get Path
39
+ const pluginPath = getLapikitPathFromArgs();
40
+ const pathValidation = validatePluginPath(pluginPath);
41
+
42
+ if (!pathValidation.valid) {
43
+ terminal('error', `Invalid path: ${pathValidation.error}`);
44
+ process.exit(1);
45
+ }
46
+
30
47
  const configPath = path.resolve(process.cwd(), 'lapikit.config.js');
31
48
  try {
32
49
  await fs.writeFile(configPath, preset.trim() + '\n', 'utf8');
@@ -35,18 +52,33 @@ if (process.argv.includes('--help') || process.argv.includes('-h')) {
35
52
  terminal('error', `failed to create configuration file:\n\n ${error}`);
36
53
  terminal(
37
54
  'warn',
38
- `you can create lapikit.config.js manually, please visite https://localhost:3000/docs for more information`
55
+ `you can create lapikit.config.js manually, please visite https://lapikit.dev/docs/getting-started for more information`
39
56
  );
40
57
  }
41
58
 
59
+ // Create plugin structure
60
+ try {
61
+ await createPluginStructure(pluginPath, typescriptEnabled);
62
+ } catch (error) {
63
+ terminal('error', `Create plugin structure not working : ${error.message}`);
64
+ }
65
+
66
+ // Setup SvelteKit integration
67
+ try {
68
+ await setupSvelteKitIntegration(pluginPath, typescriptEnabled);
69
+ } catch (error) {
70
+ terminal('error', `SvelteKit integration setup failed: ${error.message}`);
71
+ }
72
+
42
73
  await adapterViteConfig(typescriptEnabled);
43
74
  await adapterCSSConfig();
44
75
 
45
76
  terminal(
46
77
  'info',
47
- `${ansi.bold.blue('Thank to use lapikit, discover all posibility with lapikit on https://localhost:3000/docs')}\n\n`
78
+ `${ansi.bold.blue('Thank to use lapikit, discover all posibility with lapikit on https://lapikit.dev')}\n\n`
48
79
  );
49
80
 
81
+ console.log('Website: https://lapikit.dev');
50
82
  console.log('Github: https://github.com/nycolaide/lapikit');
51
83
  console.log('Support the developement: https://buymeacoffee.com/nycolaide');
52
84
  } else {
@@ -0,0 +1,223 @@
1
+ import { promises as fs } from 'fs';
2
+ import path from 'path';
3
+ import { terminal } from '../helper.js';
4
+
5
+ const lapikitTsTemplate = `import type { Config } from 'lapikit';
6
+
7
+ /**
8
+ * Custom configuration for Lapikit
9
+ * @see https://lapikit.dev/docs/customize
10
+ */
11
+ const config: Config = {
12
+ theme: {
13
+ colorScheme: 'light',
14
+ colors: {
15
+ primary: '#3b82f6',
16
+ secondary: '#6b7280'
17
+ }
18
+ }
19
+ };
20
+
21
+ export default config;
22
+ `;
23
+
24
+ const lapikitJsTemplate = `/**
25
+ * Custom configuration for Lapikit
26
+ * @see https://lapikit.dev/docs/customize
27
+ * @type {import('lapikit').Config}
28
+ */
29
+ const config = {
30
+ theme: {
31
+ colorScheme: 'light',
32
+ colors: {
33
+ primary: '#3b82f6',
34
+ secondary: '#6b7280'
35
+ }
36
+ }
37
+ };
38
+
39
+ export default config;
40
+ `;
41
+
42
+ export async function createPluginStructure(pluginPath, isTypescript) {
43
+ const resolvedPluginPath = path.resolve(process.cwd(), pluginPath);
44
+ const lapikitFileName = isTypescript ? 'lapikit.ts' : 'lapikit.js';
45
+ const lapikitFilePath = path.join(resolvedPluginPath, lapikitFileName);
46
+
47
+ try {
48
+ // Verify plugin directory
49
+ try {
50
+ await fs.access(resolvedPluginPath);
51
+ terminal('info', `The folder ${pluginPath} already exists.`);
52
+ } catch {
53
+ await fs.mkdir(resolvedPluginPath, { recursive: true });
54
+ terminal('success', `Folder ${pluginPath} created successfully.`);
55
+ }
56
+
57
+ // Create lapikit.ts or lapikit.js
58
+ const template = isTypescript ? lapikitTsTemplate : lapikitJsTemplate;
59
+ await fs.writeFile(lapikitFilePath, template.trim() + '\n', 'utf8');
60
+
61
+ terminal('success', `File ${lapikitFileName} created in ${pluginPath}.`);
62
+ } catch (error) {
63
+ terminal('error', `Error creating plugin structure: ${error.message}`);
64
+ throw error;
65
+ }
66
+ }
67
+
68
+ export async function setupSvelteKitIntegration(pluginPath, isTypescript) {
69
+ const srcRoutesPath = path.resolve(process.cwd(), 'src/routes');
70
+
71
+ try {
72
+ // Check if the src/routes directory exists
73
+ await fs.access(srcRoutesPath);
74
+ terminal('info', 'Folder src/routes found, configuring SvelteKit...');
75
+ } catch {
76
+ terminal('info', 'Folder src/routes not found, no SvelteKit configuration needed.');
77
+ return;
78
+ }
79
+
80
+ const layoutPath = path.join(srcRoutesPath, '+layout.svelte');
81
+ const pagePath = path.join(srcRoutesPath, '+page.svelte');
82
+
83
+ let targetFile = null;
84
+ let targetFileName = '';
85
+
86
+ try {
87
+ await fs.access(layoutPath);
88
+ targetFile = layoutPath;
89
+ targetFileName = '+layout.svelte';
90
+ } catch {
91
+ try {
92
+ await fs.access(pagePath);
93
+ targetFile = pagePath;
94
+ targetFileName = '+page.svelte';
95
+ } catch {
96
+ terminal('warn', 'No +layout.svelte or +page.svelte file found in src/routes.');
97
+ return;
98
+ }
99
+ }
100
+
101
+ // Read content
102
+ let fileContent = await fs.readFile(targetFile, 'utf8');
103
+
104
+ // Get Path
105
+ const relativePath = path.relative(
106
+ path.dirname(targetFile),
107
+ path.resolve(process.cwd(), pluginPath)
108
+ );
109
+ const lapikitFileName = isTypescript ? 'lapikit' : 'lapikit.js';
110
+ const configImportPath = `${relativePath}/${lapikitFileName}`.replace(/\\/g, '/');
111
+
112
+ // Imports
113
+ const createLapikitImport = `\n\timport { createLapikit } from 'lapikit';`;
114
+ const configImport = `\timport config from '${configImportPath}';`;
115
+
116
+ const scriptLang = isTypescript ? ' lang="ts"' : '';
117
+ const effectCode = `\n\t$effect.pre(() => {\n\t\tcreateLapikit(config);\n\t});`;
118
+
119
+ // search balise
120
+ const scriptRegex = /<script(\s+lang="ts")?>([\s\S]*?)<\/script>/;
121
+ const scriptMatch = fileContent.match(scriptRegex);
122
+
123
+ if (scriptMatch) {
124
+ // If have script balise , add import
125
+ let scriptContent = scriptMatch[2];
126
+
127
+ // Add imports if they don't already exist
128
+ if (!scriptContent.includes('createLapikit')) {
129
+ scriptContent = `${createLapikitImport}\n${configImport}\n${scriptContent}`;
130
+ }
131
+
132
+ // Add effect
133
+ if (!scriptContent.includes('createLapikit(config)')) {
134
+ scriptContent += effectCode;
135
+ }
136
+
137
+ // Replace script balise
138
+ const newScript = `<script${scriptMatch[1] || scriptLang}>${scriptContent}\n</script>`;
139
+ fileContent = fileContent.replace(scriptRegex, newScript);
140
+ } else {
141
+ // If no script tag exists, create one
142
+ const newScript = `<script${scriptLang}>\n${createLapikitImport}\n${configImport}${effectCode}\n</script>\n\n`;
143
+ fileContent = newScript + fileContent;
144
+ }
145
+
146
+ // Write the modified file
147
+ await fs.writeFile(targetFile, fileContent, 'utf8');
148
+ terminal('success', `Config added ${targetFileName}.`);
149
+ }
150
+
151
+ const [, , command] = process.argv;
152
+ const typescriptEnabled = envTypescript();
153
+ const args = process.argv.slice(2);
154
+ const previewMode = args.includes('--preview');
155
+
156
+ if (process.argv.includes('--help') || process.argv.includes('-h')) {
157
+ terminal(
158
+ 'info',
159
+ `usage: ${ansi.color.yellow('npx lapikit init {cssPath} [--plugin-path {pluginPath}] [--preview]')}\n\n ${ansi.variant.bold('options:')}\n
160
+ - {cssPath}: (${ansi.color.cyan('src/app.css')}) customize path on your origin css file.
161
+ - --plugin-path, -p: (${ansi.color.cyan('src/plugin')}) customize path for the plugin directory.
162
+ - --preview: active preview mode (plugin + SvelteKit integration)\n\n`
163
+ );
164
+ process.exit(0);
165
+ } else if (command === 'init') {
166
+ console.log(' _ _ _ _ _ ');
167
+ console.log(' | | (_) | (_) | ');
168
+ console.log(' | | __ _ _ __ _| | ___| |_ ');
169
+ console.log(" | | / _` | '_ \\| | |/ / | __|");
170
+ console.log(' | |___| (_| | |_) | | <| | |_ ');
171
+ console.log(' |______\\__,_| .__/|_|_|\\_\\_|\\__|');
172
+ console.log(' | | ');
173
+ console.log(' |_| \n');
174
+
175
+ terminal('none', `${ansi.bold.blue('LAPIKIT')} - Component Library for Svelte\n\n`);
176
+
177
+ if (previewMode) {
178
+ // Mode preview
179
+ const pluginPath = getLapikitPathFromArgs();
180
+ const pathValidation = validatePluginPath(pluginPath);
181
+ if (!pathValidation.valid) {
182
+ terminal('error', `Invalid path: ${pathValidation.error}`);
183
+ process.exit(1);
184
+ }
185
+ try {
186
+ await createPluginStructure(pluginPath, typescriptEnabled);
187
+ } catch (error) {
188
+ terminal('error', `Create plugin structure not working : ${error.message}`);
189
+ }
190
+ try {
191
+ await setupSvelteKitIntegration(pluginPath, typescriptEnabled);
192
+ } catch (error) {
193
+ terminal('error', `SvelteKit integration setup failed: ${error.message}`);
194
+ }
195
+ } else {
196
+ // Mode classic
197
+ const configPath = path.resolve(process.cwd(), 'lapikit.config.js');
198
+ try {
199
+ await fs.writeFile(configPath, preset.trim() + '\n', 'utf8');
200
+ terminal('success', `has create lapikit.config.js on your project.`);
201
+ } catch (error) {
202
+ terminal('error', `failed to create configuration file:\n\n ${error}`);
203
+ terminal(
204
+ 'warn',
205
+ `you can create lapikit.config.js manually, please visite https://lapikit.dev/docs/getting-started for more information`
206
+ );
207
+ }
208
+ await adapterCSSConfig();
209
+ }
210
+
211
+ await adapterViteConfig(typescriptEnabled);
212
+
213
+ terminal(
214
+ 'info',
215
+ `${ansi.bold.blue('Thank to use lapikit, discover all posibility with lapikit on https://lapikit.dev')}\n\n`
216
+ );
217
+
218
+ console.log('Website: https://lapikit.dev');
219
+ console.log('Github: https://github.com/nycolaide/lapikit');
220
+ console.log('Support the developement: https://buymeacoffee.com/nycolaide');
221
+ } else {
222
+ terminal('error', `Command not recognized. Try 'npx lapikit -h'`);
223
+ }
@@ -1,23 +1,24 @@
1
+ /* root */
1
2
  .kit-alert {
2
3
  --alert-color: var(--on, var(--kit-on-container));
3
4
  --alert-background: var(--base, var(--kit-container));
4
5
  --alert-radius: var(--shape, var(--kit-radius-md));
6
+ }
5
7
 
8
+ .kit-alert {
6
9
  display: grid;
7
10
  flex: 1 1;
8
11
  grid-template-areas:
9
12
  'prepend content append close'
10
13
  '. content . .';
11
- /* grid-template-columns: max-content auto max-content max-content; */ /* bug */
14
+ grid-template-columns: max-content minmax(0, 1fr) max-content max-content;
12
15
  position: relative;
13
16
  padding: 1rem;
14
17
  overflow: hidden;
15
18
  color: var(--alert-color);
16
19
  background-color: var(--alert-background);
17
20
  border-radius: var(--alert-radius);
18
- /* transition:
19
- color 0.5s,
20
- background-color 0.5s; */
21
+ line-height: 0;
21
22
  }
22
23
 
23
24
  .kit-alert .kit-alert--underlay {
@@ -53,7 +54,7 @@
53
54
  padding-top: 0.75rem;
54
55
  }
55
56
 
56
- .kit-alert .kit-alert-prepend {
57
+ .kit-alert .kit-alert--prepend {
57
58
  align-self: flex-start;
58
59
  display: flex;
59
60
  align-items: center;
@@ -61,10 +62,11 @@
61
62
  margin-inline-end: 1rem;
62
63
  }
63
64
 
64
- .kit-alert .kit-alert-content {
65
- align-self: center;
65
+ .kit-alert .kit-alert--content {
66
+ align-self: flex-start;
66
67
  grid-area: content;
67
68
  overflow: hidden;
69
+ line-height: normal;
68
70
  }
69
71
 
70
72
  .kit-alert .kit-alert--close {
@@ -74,6 +76,14 @@
74
76
  grid-area: close;
75
77
  }
76
78
 
79
+ .kit-alert .kit-alert--append {
80
+ align-self: flex-start;
81
+ display: flex;
82
+ align-items: center;
83
+ grid-area: append;
84
+ margin-inline-start: 1rem;
85
+ }
86
+
77
87
  /* state */
78
88
  .kit-alert.kit-alert--info:not([class*='alert--variant-']) {
79
89
  --on: var(--kit-on-info);
@@ -4,7 +4,7 @@
4
4
  left: 0;
5
5
  height: 100%;
6
6
  width: 100%;
7
- background-color: color-mix(in oklab, var(--kit-shadow) 45%, transparent);
7
+ background-color: color-mix(in oklab, var(--kit-shadow) 70%, transparent);
8
8
  z-index: 9000;
9
9
  cursor: default;
10
10
  }
@@ -23,7 +23,6 @@
23
23
  this={is}
24
24
  bind:this={ref}
25
25
  {...rest}
26
- role="heading"
27
26
  class={[
28
27
  'kit-appbar',
29
28
  light && 'light',
@@ -17,6 +17,7 @@
17
17
  border-radius: var(--button-radius);
18
18
  color: var(--button-color);
19
19
  font-weight: 500;
20
+ text-decoration: none;
20
21
  }
21
22
 
22
23
  .kit-button,
@@ -146,8 +147,8 @@
146
147
  }
147
148
 
148
149
  .kit-button[breakpoint]kit-button--variant-outline {
149
- --button-color: var(--base, var(--kit-on-container));
150
- background-color: transparent;
150
+ --button-color: var(--on, var(--kit-on-container));
151
+ background-color: var(--button-background);
151
152
  }
152
153
  .kit-button[breakpoint]kit-button--variant-outline::before {
153
154
  content: '';
@@ -65,6 +65,7 @@
65
65
  disabled={href ? undefined : disabled}
66
66
  type={href ? undefined : type}
67
67
  use:ripple={{
68
+ component: 'button',
68
69
  disabled: noRipple || disabled
69
70
  }}
70
71
  style:--base={assets.color(background)}
@@ -52,6 +52,7 @@
52
52
  ]}
53
53
  disabled={href ? undefined : disabled}
54
54
  use:ripple={{
55
+ component: 'card',
55
56
  disabled: noRipple || disabled || !isClickable
56
57
  }}
57
58
  style:--base={assets.color(background)}
@@ -17,6 +17,7 @@
17
17
  border-radius: var(--chip-radius);
18
18
  color: var(--chip-color);
19
19
  font-weight: 500;
20
+ text-decoration: none;
20
21
  }
21
22
 
22
23
  .kit-chip:not(div):not(span) {
@@ -35,6 +36,7 @@
35
36
  white-space: nowrap;
36
37
  gap: calc(var(--kit-spacing) * var(--chip-multiplier-gap));
37
38
  font-size: calc(var(--kit-spacing) * var(--chip-multiplier-font-size));
39
+ line-height: 0;
38
40
  }
39
41
 
40
42
  .kit-chip:not(div):not(span)::after {
@@ -114,8 +116,8 @@
114
116
  }
115
117
 
116
118
  .kit-chip[breakpoint]kit-chip--variant-outline {
117
- --chip-color: var(--base, var(--kit-oncontainer));
118
- background-color: transparent;
119
+ --chip-color: var(--on, var(--kit-on-container));
120
+ background-color: var(--chip-background);
119
121
  }
120
122
  .kit-chip[breakpoint]kit-chip--variant-outline::before {
121
123
  content: '';
@@ -76,6 +76,7 @@
76
76
  disabled={href ? undefined : disabled}
77
77
  type={href ? undefined : type}
78
78
  use:ripple={{
79
+ component: 'chip',
79
80
  disabled: noRipple || disabled || is === 'div' || is === 'span'
80
81
  }}
81
82
  style:--base={assets.color(background)}
@@ -19,3 +19,4 @@ export { default as Card } from './card/card.svelte';
19
19
  export { default as Toolbar } from './toolbar/toolbar.svelte';
20
20
  export { default as Appbar } from './appbar/appbar.svelte';
21
21
  export { default as Spacer } from './spacer/spacer.svelte';
22
+ export { default as Textfield } from './textfield/textfield.svelte';
@@ -20,3 +20,4 @@ export { default as Card } from './card/card.svelte';
20
20
  export { default as Toolbar } from './toolbar/toolbar.svelte';
21
21
  export { default as Appbar } from './appbar/appbar.svelte';
22
22
  export { default as Spacer } from './spacer/spacer.svelte';
23
+ export { default as Textfield } from './textfield/textfield.svelte';
@@ -29,6 +29,7 @@
29
29
  color: var(--list-item-color);
30
30
  border-radius: var(--list-item-radius);
31
31
  font-weight: 500;
32
+ text-decoration: none;
32
33
  }
33
34
 
34
35
  .kit-list-item:not(div) {
@@ -47,6 +47,7 @@
47
47
  rest.class
48
48
  ]}
49
49
  use:ripple={{
50
+ component: 'list-item',
50
51
  disabled: noRipple || disabled || is === 'div'
51
52
  }}
52
53
  role={is === 'button' ? 'listitem' : undefined}
@@ -10,6 +10,7 @@
10
10
  .kit-modal {
11
11
  width: 100%;
12
12
  height: 100%;
13
+ position: absolute;
13
14
  }
14
15
 
15
16
  .kit-modal-container {
@@ -80,6 +80,7 @@
80
80
  {#if open}
81
81
  <div
82
82
  bind:this={ref}
83
+ {...rest}
83
84
  class={['kit-modal', contain && 'kit-modal--contain', rest.class]}
84
85
  role="dialog"
85
86
  >
@@ -0,0 +1,305 @@
1
+ /* root */
2
+ .kit-textfield {
3
+ --textfield-color: var(--on, var(--kit-on-container));
4
+ --textfield-background: var(--base, var(--kit-container));
5
+ --textfield-radius: var(--shape, var(--kit-radius-md));
6
+ }
7
+
8
+ .kit-textfield {
9
+ flex: 1 1 auto;
10
+ font-size: 1rem;
11
+ display: grid;
12
+ grid-template-areas:
13
+ 'prepend control append'
14
+ 'a messages b';
15
+ grid-template-columns: max-content minmax(0, 1fr) max-content;
16
+ grid-template-rows: 1fr auto;
17
+ }
18
+
19
+ /* variant */
20
+ .kit-textfield[breakpoint]kit-textfield--variant-filled .kit-field {
21
+ --textfield-border-color: var(--textfield-background);
22
+ background-color: var(--textfield-background);
23
+ border-radius: var(--textfield-radius);
24
+ color: var(--textfield-color);
25
+ }
26
+
27
+ .kit-textfield[breakpoint]kit-textfield--variant-outline .kit-field {
28
+ --textfield-border-color: var(--textfield-color);
29
+ background-color: var(--textfield-background);
30
+ border-radius: var(--textfield-radius);
31
+ color: var(--textfield-color);
32
+ }
33
+
34
+ .kit-textfield[breakpoint]kit-textfield--variant-filled .kit-textfield-outline,
35
+ .kit-textfield[breakpoint]kit-textfield--variant-outline .kit-textfield-outline {
36
+ border-bottom: 1px solid var(--textfield-border-color);
37
+ border-top: 1px solid var(--textfield-border-color);
38
+ border-right: 1px solid var(--textfield-border-color);
39
+ border-left: 1px solid var(--textfield-border-color);
40
+ border-radius: var(--textfield-radius);
41
+ }
42
+
43
+ .kit-textfield[breakpoint]kit-textfield--variant-text .kit-field {
44
+ --textfield-border-color: var(--textfield-color);
45
+ background-color: transparent;
46
+ border-radius: 0;
47
+ color: var(--textfield-color);
48
+ }
49
+
50
+ .kit-textfield[breakpoint]kit-textfield--variant-text .kit-textfield-outline {
51
+ border-bottom: 1px solid var(--textfield-border-color);
52
+ border-top: 0;
53
+ border-right: 0;
54
+ border-left: 0;
55
+ border-radius: 0;
56
+ }
57
+
58
+ .kit-textfield--hide-spin-buttons input[type='number'] {
59
+ -moz-appearance: textfield;
60
+ appearance: textfield;
61
+ }
62
+ .kit-textfield--hide-spin-buttons input[type='number']::-webkit-inner-spin-button,
63
+ .kit-textfield--hide-spin-buttons input[type='number']::-webkit-outer-spin-button {
64
+ display: none;
65
+ -webkit-appearance: none;
66
+ }
67
+
68
+ .kit-textfield--disabled {
69
+ opacity: 0.5;
70
+ pointer-events: none;
71
+ }
72
+
73
+ .kit-textfield--readonly {
74
+ pointer-events: none;
75
+ }
76
+
77
+ .kit-textfield--error .kit-textfield-outline {
78
+ border: 1px solid var(--kit-error);
79
+ }
80
+
81
+ .kit-textfield-outline {
82
+ align-items: stretch;
83
+ contain: layout;
84
+ display: flex;
85
+ height: 100%;
86
+ left: 0;
87
+ pointer-events: none;
88
+ position: absolute;
89
+ right: 0;
90
+ width: 100%;
91
+ }
92
+
93
+ .kit-textfield .kit-textfield-prepend {
94
+ display: flex;
95
+ grid-area: prepend;
96
+ margin-inline-end: 16px;
97
+ align-items: center;
98
+ padding-top: 0;
99
+ }
100
+
101
+ .kit-textfield .kit-textfield-append {
102
+ display: flex;
103
+ grid-area: append;
104
+ margin-inline-start: 16px;
105
+ align-items: center;
106
+ padding-top: 0;
107
+ }
108
+
109
+ /* control */
110
+ .kit-textfield-control {
111
+ display: flex;
112
+ grid-area: control;
113
+ }
114
+
115
+ .kit-textfield-control .kit-textfield-prepend-inner {
116
+ grid-area: prepend-inner;
117
+ display: flex;
118
+ align-items: center;
119
+ padding-top: 0;
120
+ }
121
+ .kit-textfield-control .kit-textfield-clearable {
122
+ cursor: pointer;
123
+ display: flex;
124
+ align-items: center;
125
+ padding-top: 0;
126
+ overflow: hidden;
127
+ margin-inline: 4px;
128
+ grid-area: clear;
129
+ opacity: 0;
130
+ }
131
+
132
+ .kit-textfield-clearable.kit-textfield-clearable--visible {
133
+ opacity: 1;
134
+ }
135
+
136
+ .kit-textfield-control .kit-textfield-append-inner {
137
+ grid-area: append-inner;
138
+ display: flex;
139
+ align-items: center;
140
+ padding-top: 0;
141
+ }
142
+
143
+ /* field prefix suffix */
144
+ .kit-field .kit-field--field .kit-field--field-prefix,
145
+ .kit-field .kit-field--field .kit-field--field-suffix {
146
+ align-items: center;
147
+ cursor: default;
148
+ display: flex;
149
+ transition: inherit;
150
+ white-space: nowrap;
151
+ }
152
+
153
+ /* field */
154
+ .kit-textfield-control .kit-field {
155
+ display: grid;
156
+ grid-template-areas: 'prepend-inner field clear append-inner';
157
+ grid-template-columns: max-content minmax(0, 1fr) max-content max-content;
158
+ font-size: calc(var(--kit-spacing) * var(--textfield-multiplier-font-size));
159
+ max-width: 100%;
160
+ contain: layout;
161
+ flex: 1 0;
162
+ grid-area: control;
163
+ position: relative;
164
+ padding: calc(var(--kit-spacing) * var(--textfield-multiplier-x))
165
+ calc(var(--kit-spacing) * var(--textfield-multiplier-y));
166
+ gap: calc(var(--kit-spacing) * var(--textfield-multiplier-gap));
167
+ }
168
+
169
+ .kit-textfield-control .kit-field .kit-field--field {
170
+ flex: 1 0;
171
+ grid-area: field;
172
+ position: relative;
173
+ align-items: flex-start;
174
+ display: flex;
175
+ }
176
+
177
+ .kit-field .kit-field--field input {
178
+ font: inherit;
179
+ border-radius: 0;
180
+ color: inherit;
181
+ flex: 1;
182
+ min-width: 0;
183
+ align-items: center;
184
+ color: inherit;
185
+ column-gap: 2px;
186
+ display: flex;
187
+ flex-wrap: wrap;
188
+ position: relative;
189
+ width: 100%;
190
+ row-gap: 8px;
191
+ }
192
+
193
+ .kit-field .kit-field--field input:focus,
194
+ .kit-field .kit-field--field input:focus-visible,
195
+ .kit-field .kit-field--field input:active {
196
+ outline: none;
197
+ box-shadow: none;
198
+ }
199
+
200
+ /* message */
201
+ .kit-textfield-message {
202
+ padding-inline: var(--textfield-spacing-y);
203
+ align-items: flex-end;
204
+ display: flex;
205
+ font-size: 0.75rem;
206
+ grid-area: messages;
207
+ min-height: 22px;
208
+ padding-top: var(--textfield-spacing-x);
209
+ overflow: hidden;
210
+ justify-content: space-between;
211
+ opacity: 0;
212
+ }
213
+
214
+ .kit-textfield-message.kit-textfield-message--visible {
215
+ opacity: 1;
216
+ }
217
+
218
+ .kit-message {
219
+ flex: 1 1 auto;
220
+ font-size: 12px;
221
+ min-height: 14px;
222
+ min-width: 1px;
223
+ position: relative;
224
+ display: grid;
225
+ gap: calc(var(--kit-spacing) * var(--textfield-multiplier-gap));
226
+ grid-template-areas: 'message-prepend message message-append ';
227
+ grid-template-columns: max-content minmax(0, 1fr) max-content;
228
+ }
229
+
230
+ .kit-message.kit-message--message-error {
231
+ color: var(--kit-error);
232
+ }
233
+
234
+ .kit-message .kit-message--message {
235
+ line-height: 12px;
236
+ word-break: break-word;
237
+ overflow-wrap: break-word;
238
+ word-wrap: break-word;
239
+ hyphens: auto;
240
+ grid-area: message;
241
+ }
242
+
243
+ .kit-message .kit-message--prepend,
244
+ .kit-message .kit-message--append {
245
+ line-height: 12px;
246
+ }
247
+
248
+ .kit-message .kit-message--prepend {
249
+ grid-area: message-prepend;
250
+ }
251
+ .kit-message .kit-message--append {
252
+ grid-area: message-append;
253
+ }
254
+
255
+ /* size */
256
+ .kit-textfield[breakpoint]kit-textfield--size-xs {
257
+ --textfield-multiplier-x: 2;
258
+ --textfield-multiplier-y: 2;
259
+ --textfield-multiplier-gap: 1;
260
+ --textfield-multiplier-font-size: 6;
261
+ }
262
+
263
+ .kit-textfield[breakpoint]kit-textfield--size-sm {
264
+ --textfield-multiplier-x: 3;
265
+ --textfield-multiplier-y: 4;
266
+ --textfield-multiplier-gap: 2;
267
+ --textfield-multiplier-font-size: 7;
268
+ }
269
+
270
+ .kit-textfield[breakpoint]kit-textfield--size-md {
271
+ --textfield-multiplier-x: 4;
272
+ --textfield-multiplier-y: 6;
273
+ --textfield-multiplier-gap: 2;
274
+ --textfield-multiplier-font-size: 8;
275
+ }
276
+
277
+ .kit-textfield[breakpoint]kit-textfield--size-lg {
278
+ --textfield-multiplier-x: 5;
279
+ --textfield-multiplier-y: 6;
280
+ --textfield-multiplier-gap: 2;
281
+ --textfield-multiplier-font-size: 9;
282
+ }
283
+
284
+ .kit-textfield[breakpoint]kit-textfield--size-xl {
285
+ --textfield-multiplier-x: 6;
286
+ --textfield-multiplier-y: 8;
287
+ --textfield-multiplier-gap: 3;
288
+ --textfield-multiplier-font-size: 10;
289
+ }
290
+
291
+ /*density */
292
+ .kit-textfield[breakpoint]kit-textfield--density-default {
293
+ --textfield-spacing-x: 0;
294
+ --textfield-spacing-y: calc(var(--kit-spacing) * var(--textfield-multiplier-y));
295
+ }
296
+
297
+ .kit-textfield[breakpoint]kit-textfield--density-compact {
298
+ --textfield-spacing-x: calc(0 - 0.5rem);
299
+ --textfield-spacing-y: calc(var(--kit-spacing) * var(--textfield-multiplier-y) - 0.5rem);
300
+ }
301
+
302
+ .kit-textfield[breakpoint]kit-textfield--density-comfortable {
303
+ --textfield-spacing-x: calc(0 + 0.5rem);
304
+ --textfield-spacing-y: calc(var(--kit-spacing) * var(--textfield-multiplier-y) + 0.5rem);
305
+ }
@@ -0,0 +1,193 @@
1
+ <script lang="ts">
2
+ import { getAssets } from '../../internal/index.js';
3
+ import type { TextfieldProps } from './types.js';
4
+
5
+ //external
6
+ import { Icon } from '../index.js';
7
+
8
+ let {
9
+ ref = $bindable(),
10
+ prepend,
11
+ append,
12
+ prependInner,
13
+ appendInner,
14
+ value = $bindable(),
15
+ type = 'text',
16
+ density = 'default',
17
+ size = 'md',
18
+ variant = 'filled',
19
+ placeholder,
20
+ light,
21
+ dark,
22
+ counter,
23
+ min,
24
+ max,
25
+ prefix,
26
+ suffix,
27
+ message,
28
+ messagePrefix,
29
+ messageSuffix,
30
+ clearable,
31
+ persistentClear,
32
+ disabled,
33
+ error,
34
+ errorMessage,
35
+ persistentMessage,
36
+ hideSpinButtons, // only type="number"
37
+ readonly,
38
+ color,
39
+ background,
40
+ rounded,
41
+ ...rest
42
+ }: TextfieldProps = $props();
43
+
44
+ const assets = getAssets();
45
+
46
+ let counterValue: number = $state(0);
47
+ let displayMessage: boolean = $state(false);
48
+ let displayClear: boolean = $state(false);
49
+
50
+ const inputClear = () => {
51
+ value = undefined;
52
+ };
53
+
54
+ const handleFocus = () => {
55
+ if (!error && !persistentMessage) displayMessage = true;
56
+ };
57
+
58
+ const handleBlur = () => {
59
+ if (!error && !persistentMessage) displayMessage = false;
60
+ };
61
+
62
+ $effect(() => {
63
+ if (persistentClear) displayClear = true;
64
+ if (persistentMessage) displayMessage = true;
65
+ else if (error) displayMessage = true;
66
+ else if (!error) displayMessage = false;
67
+ });
68
+
69
+ $effect(() => {
70
+ const valueStr = value?.toString() || '';
71
+
72
+ if (valueStr && typeof max === 'number' && max > 0 && valueStr.length > max) {
73
+ const truncated = valueStr.slice(0, max);
74
+ if (typeof value === 'number') {
75
+ const numValue = Number(truncated);
76
+ value = isNaN(numValue) ? undefined : numValue;
77
+ } else {
78
+ value = truncated;
79
+ }
80
+ }
81
+
82
+ counterValue = valueStr.length;
83
+ });
84
+
85
+ $effect(() => {
86
+ if (!persistentClear) {
87
+ if (value) displayClear = true;
88
+ else displayClear = false;
89
+ }
90
+ });
91
+ </script>
92
+
93
+ <div
94
+ bind:this={ref}
95
+ {...rest}
96
+ class={[
97
+ 'kit-textfield',
98
+ light && 'light',
99
+ dark && 'dark',
100
+ size && assets.className('textfield', 'size', size),
101
+ variant && assets.className('textfield', 'variant', variant),
102
+ density && assets.className('textfield', 'density', density),
103
+ disabled && 'kit-textfield--disabled',
104
+ readonly && 'kit-textfield--readonly',
105
+ error && 'kit-textfield--error',
106
+ type === 'number' && hideSpinButtons && 'kit-textfield--hide-spin-buttons',
107
+ rest.class
108
+ ]}
109
+ style:--base={assets.color(background)}
110
+ style:--on={assets.color(color)}
111
+ style:--shape={assets.shape(rounded)}
112
+ >
113
+ {#if prepend}
114
+ <div class="kit-textfield-prepend">
115
+ {@render prepend?.()}
116
+ </div>
117
+ {/if}
118
+ <div class="kit-textfield-control">
119
+ <div class="kit-field">
120
+ {#if prependInner}
121
+ <div class="kit-textfield-prepend-inner">
122
+ {@render prependInner?.()}
123
+ </div>
124
+ {/if}
125
+ <div class="kit-field--field">
126
+ {#if prefix}
127
+ <span class="kit-field--field-prefix">
128
+ <span class="kit-textfield--field-prefix--text">{prefix}</span>
129
+ </span>
130
+ {/if}
131
+ <input
132
+ {type}
133
+ size="1"
134
+ {placeholder}
135
+ bind:value
136
+ onfocus={handleFocus}
137
+ onblur={handleBlur}
138
+ {...max && { maxlength: max }}
139
+ {...min && { minlength: min }}
140
+ {...disabled && { disabled: true }}
141
+ {...readonly && { readonly: true }}
142
+ />
143
+ {#if suffix}
144
+ <span class="kit-field--field-suffix">
145
+ <span class="kit-textfield--field-suffix--text">{suffix}</span>
146
+ </span>
147
+ {/if}
148
+ </div>
149
+ {#if clearable}
150
+ <div
151
+ class={['kit-textfield-clearable', displayClear && 'kit-textfield-clearable--visible']}
152
+ >
153
+ <Icon icon="mgc_close_circle_fill" onclick={() => inputClear()} />
154
+ </div>
155
+ {/if}
156
+
157
+ {#if appendInner}
158
+ <div class="kit-textfield-append-inner">
159
+ {@render appendInner?.()}
160
+ </div>
161
+ {/if}
162
+
163
+ <div class="kit-textfield-outline"></div>
164
+ </div>
165
+ </div>
166
+ {#if append}
167
+ <div class="kit-textfield-append">
168
+ {@render append?.()}
169
+ </div>
170
+ {/if}
171
+
172
+ <div class={['kit-textfield-message', displayMessage && 'kit-textfield-message--visible']}>
173
+ <div class={['kit-message', error && 'kit-message--message-error']}>
174
+ {#if messagePrefix}
175
+ <div class="kit-message--prepend">{messagePrefix}</div>
176
+ {/if}
177
+ {#if message || error}
178
+ <div class="kit-message--message">
179
+ {error ? errorMessage || message : message}
180
+ </div>
181
+ {/if}
182
+ {#if counter || messageSuffix}
183
+ <div class="kit-message--append">
184
+ {#if counter}
185
+ {counterValue}{max ? `/${max}` : ''}
186
+ {:else if messageSuffix}
187
+ {messageSuffix}
188
+ {/if}
189
+ </div>
190
+ {/if}
191
+ </div>
192
+ </div>
193
+ </div>
@@ -0,0 +1,4 @@
1
+ import type { TextfieldProps } from './types.js';
2
+ declare const Textfield: import("svelte").Component<TextfieldProps, {}, "value" | "ref">;
3
+ type Textfield = ReturnType<typeof Textfield>;
4
+ export default Textfield;
@@ -0,0 +1,37 @@
1
+ import type { Component } from '../../internal/types.js';
2
+ import type { Snippet } from 'svelte';
3
+ export interface TextfieldProps extends Component {
4
+ ref?: HTMLElement | null;
5
+ dark?: boolean;
6
+ light?: boolean;
7
+ value?: string | number;
8
+ type?: 'text' | 'email' | 'password' | 'number';
9
+ placeholder?: string;
10
+ counter?: boolean;
11
+ min?: number;
12
+ max?: number;
13
+ variant?: 'outline' | 'text' | 'filled';
14
+ density?: 'compact' | 'comfortable' | 'default';
15
+ error?: boolean;
16
+ errorMessage?: string;
17
+ disabled?: boolean;
18
+ color?: string;
19
+ background?: string;
20
+ size?: string | {
21
+ [key: string]: string;
22
+ };
23
+ readonly?: boolean;
24
+ hideSpinButtons?: boolean;
25
+ persistentMessage?: boolean;
26
+ persistentClear?: boolean;
27
+ clearable?: boolean;
28
+ message?: string;
29
+ messagePrefix?: string;
30
+ messageSuffix?: string;
31
+ append?: Snippet;
32
+ prepend?: Snippet;
33
+ prependInner?: Snippet;
34
+ appendInner?: Snippet;
35
+ prefix?: string;
36
+ suffix?: string;
37
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -5,7 +5,7 @@
5
5
 
6
6
  display: flex;
7
7
  align-items: center;
8
- min-width: max-content;
8
+ /* min-width: max-content; */
9
9
  border-style: solid;
10
10
  /* transition:
11
11
  color 0.5s,
@@ -1,4 +1,5 @@
1
1
  interface RippleOptions {
2
+ component?: string;
2
3
  center?: boolean;
3
4
  color?: string;
4
5
  duration?: number;
@@ -26,6 +26,9 @@ export function ripple(el, options = {}) {
26
26
  if (options.duration && options.duration < 0) {
27
27
  options.duration = undefined;
28
28
  }
29
+ if (options.component) {
30
+ rippleContainer.style.setProperty('--ripple-radius', `var(--${options.component}-radius)`);
31
+ }
29
32
  if (options.color) {
30
33
  rippleContainer.style.setProperty('--ripple-color', options.color);
31
34
  }
@@ -29,6 +29,7 @@
29
29
  transition: 0.6s;
30
30
  -webkit-animation: lapikit-ripple var(--ripple-duration, 0.4s) cubic-bezier(0.4, 0, 0.2, 1);
31
31
  animation: lapikit-ripple var(--ripple-duration, 0.4s) cubic-bezier(0.4, 0, 0.2, 1);
32
+ border-radius: var(--ripple-radius);
32
33
  }
33
34
 
34
35
  .kit-ripple--center {
@@ -47,6 +48,7 @@
47
48
  background: none;
48
49
  pointer-events: none;
49
50
  z-index: 999;
51
+ border-radius: var(--ripple-radius);
50
52
  }
51
53
 
52
54
  @keyframes lapikit-ripple {
@@ -38,7 +38,7 @@ export const colors = (config) => {
38
38
  }
39
39
  cssVariables += `}\n`;
40
40
  cssVariables += `.${inversed} {\n`;
41
- cssVariables += `color-scheme: ${used};\n`;
41
+ cssVariables += `color-scheme: ${inversed};\n`;
42
42
  for (const [colorName, colorValue] of Object.entries(schemes[inversed])) {
43
43
  cssVariables += `--kit-${colorName}: ${colorValue};\n`;
44
44
  }
@@ -56,7 +56,7 @@ export const colors = (config) => {
56
56
  }
57
57
  cssVariables += `}\n`;
58
58
  cssVariables += `.${inversed} {\n`;
59
- cssVariables += `color-scheme: ${used};\n`;
59
+ cssVariables += `color-scheme: ${inversed};\n`;
60
60
  for (const [colorName, colorValue] of Object.entries(schemes[inversed])) {
61
61
  cssVariables += `--kit-${colorName}: ${colorValue};\n`;
62
62
  }
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "lapikit",
3
- "version": "0.0.0-insiders.90a2698",
3
+ "version": "0.0.0-insiders.90eb48b",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
+ "homepage": "https://lapikit.dev",
8
9
  "repository": {
9
10
  "type": "git",
10
11
  "url": "git+https://github.com/Nycolaide/lapikit.git",