@miozu/jera 0.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Nicholas Glazer <info@nicgl.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # Jera
package/jera.js ADDED
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from 'commander';
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+
11
+ // Find the components directory relative to the package
12
+ function findComponentsDir() {
13
+ // Try to locate the components directory
14
+ const possiblePaths = [
15
+ // When running from the installed package
16
+ path.join(__dirname, 'src', 'components'),
17
+ // When running from the project root
18
+ path.join(__dirname, 'components'),
19
+ // When running from a cloned repo
20
+ path.join(__dirname, '..', 'src', 'components')
21
+ ];
22
+
23
+ for (const dir of possiblePaths) {
24
+ if (fs.existsSync(dir)) {
25
+ return dir;
26
+ }
27
+ }
28
+
29
+ // If components directory not found, return null
30
+ return null;
31
+ }
32
+
33
+ const COMPONENTS_DIR = findComponentsDir();
34
+
35
+ // List available components in the components directory
36
+ function listAvailableComponents() {
37
+ if (!COMPONENTS_DIR) {
38
+ return [];
39
+ }
40
+
41
+ try {
42
+ return fs.readdirSync(COMPONENTS_DIR)
43
+ .filter(file => file.endsWith('.svelte'))
44
+ .map(file => file.replace('.svelte', ''));
45
+ } catch (error) {
46
+ console.error('Error reading components directory:', error);
47
+ return [];
48
+ }
49
+ }
50
+
51
+ const program = new Command();
52
+
53
+ program
54
+ .name('jera')
55
+ .description('Install Jera components to your project')
56
+ .version('0.0.1');
57
+
58
+ program
59
+ .command('list')
60
+ .description('List all available components')
61
+ .action(() => {
62
+ const components = listAvailableComponents();
63
+
64
+ if (components.length === 0) {
65
+ console.log('No components found.');
66
+ return;
67
+ }
68
+
69
+ console.log('Available components:');
70
+ components.forEach(comp => console.log(`- ${comp}`));
71
+ });
72
+
73
+ program
74
+ .command('add')
75
+ .description('Add a component to your project')
76
+ .argument('<component>', 'Component to add (e.g. Input)')
77
+ .option('-d, --dir <directory>', 'Target directory', 'src/lib/components')
78
+ .action((component, options) => {
79
+ console.log(`Adding ${component} to ${options.dir}...`);
80
+
81
+ const componentFile = component.endsWith('.svelte')
82
+ ? component
83
+ : `${component}.svelte`;
84
+
85
+ // Check if components directory exists
86
+ if (!COMPONENTS_DIR) {
87
+ console.error('Error: Components directory not found.');
88
+ console.error('This could happen if you\'re running the CLI in development mode');
89
+ console.error('or if the package structure has changed.');
90
+ return;
91
+ }
92
+
93
+ // Check if component exists
94
+ const sourceComponentPath = path.join(COMPONENTS_DIR, componentFile);
95
+ if (!fs.existsSync(sourceComponentPath)) {
96
+ console.error(`Error: Component "${component}" not found.`);
97
+ console.error('Available components:');
98
+ listAvailableComponents().forEach(comp => console.error(`- ${comp}`));
99
+ return;
100
+ }
101
+
102
+ // Create target directory if it doesn't exist
103
+ const targetDir = path.resolve(options.dir);
104
+ if (!fs.existsSync(targetDir)) {
105
+ fs.mkdirSync(targetDir, { recursive: true });
106
+ }
107
+
108
+ // Copy the component file
109
+ const componentContent = fs.readFileSync(sourceComponentPath, 'utf-8');
110
+ fs.writeFileSync(path.join(targetDir, componentFile), componentContent);
111
+
112
+ console.log(`Component ${component} added to ${options.dir}`);
113
+ console.log('\nUsage:');
114
+ console.log('\nNOTE: This component uses the Miozu theme.');
115
+ console.log('Make sure you have installed @miozu/js-theme and configured it in your Tailwind config.');
116
+ });
117
+
118
+ // Add init command to set up the repository structure
119
+ program
120
+ .command('init')
121
+ .description('Initialize a new project with Jera components')
122
+ .action(() => {
123
+ console.log('Initializing Jera components...');
124
+
125
+ const componentsDir = path.resolve('src/lib/components');
126
+
127
+ if (!fs.existsSync(componentsDir)) {
128
+ fs.mkdirSync(componentsDir, { recursive: true });
129
+ }
130
+
131
+ console.log('Project initialized! You can now add components with:');
132
+ console.log(' jera add <component>');
133
+ });
134
+
135
+ program.parse();
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@miozu/jera",
3
+ "version": "0.0.2",
4
+ "description": "Svelte 5 component library",
5
+ "main": "jera.js",
6
+ "bin": {
7
+ "jera": "./jera.js"
8
+ },
9
+ "type": "module",
10
+ "scripts": {
11
+ "test": "echo \"Error: no test specified\" && exit 1"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://codeberg.org/miozu/jera"
16
+ },
17
+ "keywords": ["component library", "svelte 5", "sveltekit"],
18
+ "author": "Nicholas Glazer <info@nicgl.com>",
19
+ "license": "MIT",
20
+ "packageManager": "pnpm@10.6.5",
21
+ "dependencies": {
22
+ "commander": "^13.1.0"
23
+ }
24
+ }
@@ -0,0 +1,63 @@
1
+ <script>
2
+ let {
3
+ value = '',
4
+ ref = $bindable(),
5
+ type = 'text',
6
+ placeholder = '',
7
+ disabled = false,
8
+ required = false,
9
+ name = '',
10
+ id = '',
11
+ autocomplete = 'on',
12
+ autocorrect = 'off',
13
+ autocapitalize = 'off',
14
+ spellcheck = 'false',
15
+ maxlength = undefined,
16
+ minlength = undefined,
17
+ inputmode,
18
+ class: className = '',
19
+ unstyled = false,
20
+ disableBrowserFeatures = false,
21
+ oninput = () => {},
22
+ onchange = () => {},
23
+ onkeydown = () => {},
24
+ ...others
25
+ } = $props();
26
+
27
+ const finalAutocomplete = disableBrowserFeatures ? 'new-password' : autocomplete;
28
+ const finalClassName = $derived(unstyled ? className : `base-input ${className}`);
29
+ </script>
30
+
31
+ <input
32
+ class={finalClassName}
33
+ bind:this={ref}
34
+ {id}
35
+ {name}
36
+ {type}
37
+ {value}
38
+ {placeholder}
39
+ {disabled}
40
+ {required}
41
+ {inputmode}
42
+ {maxlength}
43
+ {minlength}
44
+ autocomplete={finalAutocomplete}
45
+ autocorrect={disableBrowserFeatures ? 'off' : autocorrect}
46
+ autocapitalize={disableBrowserFeatures ? 'off' : autocapitalize}
47
+ spellcheck={disableBrowserFeatures ? 'false' : spellcheck}
48
+ data-form-type={disableBrowserFeatures ? 'other' : undefined}
49
+ data-lpignore={disableBrowserFeatures ? 'true' : undefined}
50
+ {oninput}
51
+ {onchange}
52
+ {onkeydown}
53
+ {...others}
54
+ />
55
+
56
+ <style>
57
+ .input-wrapper {
58
+ @apply relative;
59
+ }
60
+ .input-label {
61
+ @apply font-bold inline-block;
62
+ }
63
+ </style>
@@ -0,0 +1 @@
1
+ export { default } from './Input.svelte';