@miozu/jera 0.0.2 → 0.4.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.
Files changed (82) hide show
  1. package/CLAUDE.md +734 -0
  2. package/README.md +219 -1
  3. package/llms.txt +97 -0
  4. package/package.json +54 -14
  5. package/src/actions/index.js +375 -0
  6. package/src/components/docs/CodeBlock.svelte +203 -0
  7. package/src/components/docs/DocSection.svelte +120 -0
  8. package/src/components/docs/PropsTable.svelte +136 -0
  9. package/src/components/docs/SplitPane.svelte +98 -0
  10. package/src/components/docs/index.js +14 -0
  11. package/src/components/feedback/Alert.svelte +234 -0
  12. package/src/components/feedback/EmptyState.svelte +179 -0
  13. package/src/components/feedback/ProgressBar.svelte +116 -0
  14. package/src/components/feedback/Skeleton.svelte +107 -0
  15. package/src/components/feedback/Spinner.svelte +77 -0
  16. package/src/components/feedback/Toast.svelte +261 -0
  17. package/src/components/forms/Checkbox.svelte +147 -0
  18. package/src/components/forms/Dropzone.svelte +248 -0
  19. package/src/components/forms/FileUpload.svelte +266 -0
  20. package/src/components/forms/IconInput.svelte +184 -0
  21. package/src/components/forms/Input.svelte +121 -0
  22. package/src/components/forms/NumberInput.svelte +225 -0
  23. package/src/components/forms/PinInput.svelte +169 -0
  24. package/src/components/forms/Radio.svelte +143 -0
  25. package/src/components/forms/RadioGroup.svelte +62 -0
  26. package/src/components/forms/RangeSlider.svelte +212 -0
  27. package/src/components/forms/SearchInput.svelte +175 -0
  28. package/src/components/forms/Select.svelte +324 -0
  29. package/src/components/forms/Switch.svelte +159 -0
  30. package/src/components/forms/Textarea.svelte +122 -0
  31. package/src/components/navigation/Accordion.svelte +65 -0
  32. package/src/components/navigation/AccordionItem.svelte +146 -0
  33. package/src/components/navigation/NavigationContainer.svelte +344 -0
  34. package/src/components/navigation/Sidebar.svelte +334 -0
  35. package/src/components/navigation/SidebarAccountGroup.svelte +495 -0
  36. package/src/components/navigation/SidebarAccountItem.svelte +492 -0
  37. package/src/components/navigation/SidebarGroup.svelte +230 -0
  38. package/src/components/navigation/SidebarGroupSwitcher.svelte +262 -0
  39. package/src/components/navigation/SidebarItem.svelte +210 -0
  40. package/src/components/navigation/SidebarNavigationItem.svelte +470 -0
  41. package/src/components/navigation/SidebarPopover.svelte +145 -0
  42. package/src/components/navigation/SidebarSearch.svelte +236 -0
  43. package/src/components/navigation/SidebarSection.svelte +158 -0
  44. package/src/components/navigation/SidebarToggle.svelte +86 -0
  45. package/src/components/navigation/Tabs.svelte +239 -0
  46. package/src/components/navigation/WorkspaceMenu.svelte +416 -0
  47. package/src/components/navigation/blocks/NavigationAccountGroup.svelte +396 -0
  48. package/src/components/navigation/blocks/NavigationCustomBlock.svelte +74 -0
  49. package/src/components/navigation/blocks/NavigationGroupSwitcher.svelte +277 -0
  50. package/src/components/navigation/blocks/NavigationSearch.svelte +300 -0
  51. package/src/components/navigation/blocks/NavigationSection.svelte +230 -0
  52. package/src/components/navigation/index.js +22 -0
  53. package/src/components/overlays/ConfirmDialog.svelte +272 -0
  54. package/src/components/overlays/Dropdown.svelte +153 -0
  55. package/src/components/overlays/DropdownDivider.svelte +23 -0
  56. package/src/components/overlays/DropdownItem.svelte +97 -0
  57. package/src/components/overlays/Modal.svelte +232 -0
  58. package/src/components/overlays/Popover.svelte +206 -0
  59. package/src/components/primitives/Avatar.svelte +132 -0
  60. package/src/components/primitives/Badge.svelte +118 -0
  61. package/src/components/primitives/Button.svelte +214 -0
  62. package/src/components/primitives/Card.svelte +104 -0
  63. package/src/components/primitives/Divider.svelte +105 -0
  64. package/src/components/primitives/LazyImage.svelte +104 -0
  65. package/src/components/primitives/Link.svelte +122 -0
  66. package/src/components/primitives/Stat.svelte +197 -0
  67. package/src/components/primitives/StatusBadge.svelte +122 -0
  68. package/src/index.js +183 -0
  69. package/src/tokens/colors.css +157 -0
  70. package/src/tokens/effects.css +128 -0
  71. package/src/tokens/index.css +81 -0
  72. package/src/tokens/spacing.css +49 -0
  73. package/src/tokens/typography.css +79 -0
  74. package/src/utils/cn.svelte.js +175 -0
  75. package/src/utils/highlighter.js +124 -0
  76. package/src/utils/index.js +22 -0
  77. package/src/utils/navigation.svelte.js +423 -0
  78. package/src/utils/reactive.svelte.js +328 -0
  79. package/src/utils/sidebar.svelte.js +211 -0
  80. package/jera.js +0 -135
  81. package/www/components/jera/Input/Input.svelte +0 -63
  82. package/www/components/jera/Input/index.js +0 -1
package/README.md CHANGED
@@ -1 +1,219 @@
1
- # Jera
1
+ # @miozu/jera
2
+
3
+ A minimal, reactive component library for Svelte 5.
4
+
5
+ **Jera** (ᛃ) — the rune of harvest and cycles. Build on foundations, yield results.
6
+
7
+ ## Features
8
+
9
+ - **Miozu Design Tokens** — Base16 color system, spacing, typography, effects
10
+ - **Reactive Utilities** — `cn()`, `cv()` for class composition with Svelte 5 runes
11
+ - **Accessible Components** — Button, Input, Select, Badge, Checkbox, Switch, Toast
12
+ - **Svelte Actions** — clickOutside, focusTrap, portal, escapeKey, and more
13
+ - **AI-First Documentation** — Optimized for LLM-assisted development
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pnpm add @miozu/jera
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```svelte
24
+ <script>
25
+ import { Button, Input, Badge } from '@miozu/jera';
26
+ import '@miozu/jera/tokens';
27
+
28
+ let email = $state('');
29
+ </script>
30
+
31
+ <Input bind:value={email} type="email" placeholder="Enter email" />
32
+ <Button onclick={() => console.log(email)}>Submit</Button>
33
+ <Badge variant="success">Active</Badge>
34
+ ```
35
+
36
+ ## Design Tokens
37
+
38
+ Import tokens for consistent styling:
39
+
40
+ ```css
41
+ /* All tokens */
42
+ @import '@miozu/jera/tokens';
43
+
44
+ /* Individual token sets */
45
+ @import '@miozu/jera/tokens/colors';
46
+ @import '@miozu/jera/tokens/spacing';
47
+ @import '@miozu/jera/tokens/typography';
48
+ @import '@miozu/jera/tokens/effects';
49
+ ```
50
+
51
+ ### Miozu Base16 Color Palette
52
+
53
+ Standard Base16 naming: `base00`-`base0F` (hex digits).
54
+
55
+ | Grayscale | Usage | Accents | Usage |
56
+ |-----------|-------|---------|-------|
57
+ | `base00` | Background | `base08` | Error (Red) |
58
+ | `base01` | Surface | `base09` | Warning (Orange) |
59
+ | `base02` | Selection | `base0A` | Highlight (Yellow) |
60
+ | `base03` | Muted | `base0B` | Success (Green) |
61
+ | `base04` | Secondary text | `base0C` | Info (Cyan) |
62
+ | `base05` | Primary text | `base0D` | Primary (Blue) |
63
+ | `base06` | High emphasis | `base0E` | Accent (Purple) |
64
+ | `base07` | Maximum contrast | `base0F` | Secondary accent |
65
+
66
+ ## Components
67
+
68
+ ### Button
69
+
70
+ ```svelte
71
+ <Button variant="primary|secondary|ghost|outline|danger|success" size="xs|sm|md|lg|xl">
72
+ Click me
73
+ </Button>
74
+ <Button href="/about">Link Button</Button>
75
+ <Button loading>Loading...</Button>
76
+ ```
77
+
78
+ ### Input
79
+
80
+ ```svelte
81
+ <Input bind:value={text} placeholder="Enter text" />
82
+ <Input type="password" disableBrowserFeatures />
83
+ <Input error={!isValid} />
84
+ ```
85
+
86
+ ### Select
87
+
88
+ ```svelte
89
+ <Select
90
+ options={[{ value: '1', label: 'Option 1' }]}
91
+ bind:value={selected}
92
+ placeholder="Choose..."
93
+ />
94
+ ```
95
+
96
+ ### Badge
97
+
98
+ ```svelte
99
+ <Badge variant="default|primary|secondary|success|warning|error|info">
100
+ Status
101
+ </Badge>
102
+ ```
103
+
104
+ ### Checkbox & Switch
105
+
106
+ ```svelte
107
+ <Checkbox bind:checked={agreed}>I agree</Checkbox>
108
+ <Switch bind:checked={enabled}>Enable notifications</Switch>
109
+ ```
110
+
111
+ ### Toast
112
+
113
+ ```svelte
114
+ <!-- Root layout -->
115
+ <script>
116
+ import { Toast, createToastContext } from '@miozu/jera';
117
+ createToastContext();
118
+ </script>
119
+ <Toast />
120
+
121
+ <!-- Any component -->
122
+ <script>
123
+ import { getToastContext } from '@miozu/jera';
124
+ const toast = getToastContext();
125
+ toast.success('Saved!');
126
+ </script>
127
+ ```
128
+
129
+ ## Utilities
130
+
131
+ ### cn() — Class concatenation
132
+
133
+ ```javascript
134
+ import { cn } from '@miozu/jera';
135
+
136
+ cn('base', condition && 'conditional', ['array', 'classes']);
137
+ // => "base conditional array classes"
138
+ ```
139
+
140
+ ### cv() — Class variants
141
+
142
+ ```javascript
143
+ import { cv } from '@miozu/jera';
144
+
145
+ const button = cv({
146
+ base: 'inline-flex items-center',
147
+ variants: {
148
+ variant: { primary: 'bg-primary', secondary: 'bg-surface' },
149
+ size: { sm: 'h-8', md: 'h-10' }
150
+ },
151
+ defaults: { variant: 'primary', size: 'md' }
152
+ });
153
+
154
+ button({ variant: 'secondary' }); // => "inline-flex items-center bg-surface h-10"
155
+ ```
156
+
157
+ ## Actions
158
+
159
+ ```svelte
160
+ <script>
161
+ import { clickOutside, focusTrap, escapeKey, portal } from '@miozu/jera/actions';
162
+ </script>
163
+
164
+ <div use:clickOutside={() => close()}>
165
+ <dialog use:focusTrap={{ enabled: isOpen }}>
166
+ <div use:escapeKey={() => close()}>
167
+ Content
168
+ </div>
169
+ </dialog>
170
+ </div>
171
+
172
+ <div use:portal={'body'}>Renders at body level</div>
173
+ ```
174
+
175
+ ## Theming
176
+
177
+ Dark theme is default. Uses singleton pattern with `miozu-theme` storage key.
178
+
179
+ ```javascript
180
+ // In root +layout.svelte
181
+ import { getTheme } from '@miozu/jera';
182
+ import { onMount } from 'svelte';
183
+
184
+ const theme = getTheme();
185
+ onMount(() => theme.init());
186
+ ```
187
+
188
+ ```javascript
189
+ // Anywhere in your app
190
+ import { getTheme } from '@miozu/jera';
191
+
192
+ const theme = getTheme();
193
+ theme.toggle(); // Switch between light/dark
194
+ theme.set('system'); // Follow system preference
195
+ theme.isDark; // boolean reactive property
196
+ ```
197
+
198
+ Data-theme values: `miozu-dark` (default) or `miozu-light`.
199
+
200
+ ## AI-First Design
201
+
202
+ This library includes AI-optimized documentation:
203
+
204
+ - `llms.txt` — Structured index for LLM consumption
205
+ - `CLAUDE.md` — Detailed context for AI assistants
206
+ - JSDoc comments throughout the codebase
207
+
208
+ ## Browser Support
209
+
210
+ - Chrome 88+
211
+ - Firefox 78+
212
+ - Safari 14+
213
+ - Edge 88+
214
+
215
+ Requires Svelte 5.0+
216
+
217
+ ## License
218
+
219
+ MIT © [Nicholas Glazer](https://miozu.com)
package/llms.txt ADDED
@@ -0,0 +1,97 @@
1
+ # @miozu/jera
2
+
3
+ > A minimal, reactive component library for Svelte 5. Provides design tokens (Miozu Base16 color system), utility functions (cn, cv), Svelte actions, and accessible components. Designed for AI-assisted development with clear, predictable APIs.
4
+
5
+ ## Quick Start
6
+ - [Installation](#installation): `pnpm add @miozu/jera`
7
+ - [Basic Usage](#usage): Import components and tokens
8
+
9
+ ## Design Tokens
10
+ - [Colors](/src/tokens/colors.css): Miozu Base16 palette with dark/light themes
11
+ - [Spacing](/src/tokens/spacing.css): 4px-based spacing scale
12
+ - [Typography](/src/tokens/typography.css): Font scales and weights
13
+ - [Effects](/src/tokens/effects.css): Shadows, radius, transitions, z-index
14
+
15
+ ## Utilities
16
+ - [cn()](/src/utils/cn.svelte.js): Class name concatenation with falsy filtering
17
+ - [cv()](/src/utils/cn.svelte.js): Class variants for type-safe variant composition
18
+ - [ThemeState](/src/utils/reactive.svelte.js): SSR-safe theme management
19
+
20
+ ## Components
21
+ - [Button](/src/components/primitives/Button.svelte): Polymorphic button with 6 variants, 5 sizes
22
+ - [Input](/src/components/forms/Input.svelte): Text input with validation support
23
+ - [Select](/src/components/forms/Select.svelte): Accessible dropdown with keyboard navigation
24
+ - [Badge](/src/components/primitives/Badge.svelte): Status tags with semantic variants
25
+ - [Checkbox](/src/components/forms/Checkbox.svelte): Checkbox input
26
+ - [Switch](/src/components/forms/Switch.svelte): Toggle switch
27
+ - [Toast](/src/components/feedback/Toast.svelte): Notification system
28
+
29
+ ## Actions
30
+ - [clickOutside](/src/actions/index.js): Detect clicks outside element
31
+ - [focusTrap](/src/actions/index.js): Trap focus within element
32
+ - [portal](/src/actions/index.js): Render element in different DOM location
33
+ - [escapeKey](/src/actions/index.js): Handle escape key press
34
+
35
+ ## API Patterns
36
+
37
+ ### Component Props Pattern
38
+ All components accept these common props:
39
+ - `class`: Additional CSS classes (always merged)
40
+ - `disabled`: Boolean to disable interaction
41
+ - Event handlers: `onclick`, `onchange`, etc.
42
+
43
+ ### Class Variants Pattern
44
+ ```javascript
45
+ import { cv } from '@miozu/jera';
46
+
47
+ const button = cv({
48
+ base: 'inline-flex items-center',
49
+ variants: {
50
+ variant: { primary: 'bg-primary', secondary: 'bg-surface' },
51
+ size: { sm: 'h-8 px-3', md: 'h-10 px-4' }
52
+ },
53
+ defaults: { variant: 'primary', size: 'md' }
54
+ });
55
+
56
+ // Usage: button({ variant: 'secondary', size: 'sm' })
57
+ ```
58
+
59
+ ### Theme Usage Pattern (Single Source of Truth)
60
+
61
+ **SvelteKit Execution Order:**
62
+ 1. +layout.server.js (server only)
63
+ 2. +layout.js (server + client, runs on EVERY navigation)
64
+ 3. +layout.svelte script (runs once on mount)
65
+ 4. onMount() (client only, after hydration)
66
+
67
+ **Recommended: Initialize in +layout.svelte** (for singletons):
68
+ ```svelte
69
+ <!-- +layout.svelte -->
70
+ <script>
71
+ import { getTheme } from '@miozu/jera';
72
+ import { onMount } from 'svelte';
73
+
74
+ const themeState = getTheme(); // Call ONCE
75
+ onMount(() => {
76
+ themeState.sync(); // Hydrate from DOM
77
+ themeState.init(); // Setup media query listener
78
+ });
79
+ </script>
80
+
81
+ <!-- Pass to children as props -->
82
+ <Sidebar {themeState} />
83
+ ```
84
+
85
+ **Child components receive as prop:**
86
+ ```javascript
87
+ let { themeState } = $props(); // DON'T call getTheme()
88
+ themeState.toggle(); // Switch light/dark
89
+ themeState.isDark; // Reactive boolean
90
+ ```
91
+
92
+ **Why +layout.svelte over +layout.js for singletons?**
93
+ - Runs once per mount (not on every navigation)
94
+ - onMount clearly separates SSR from client code
95
+ - More efficient for global state that doesn't change
96
+
97
+ Storage key: `miozu-theme`. Data-theme values: `miozu-dark` | `miozu-light`.
package/package.json CHANGED
@@ -1,24 +1,64 @@
1
1
  {
2
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
- },
3
+ "version": "0.4.2",
4
+ "description": "Minimal, reactive component library for Svelte 5",
9
5
  "type": "module",
10
6
  "scripts": {
11
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "prepublishOnly": "echo 'Publishing @miozu/jera...' && test -f src/index.js"
8
+ },
9
+ "svelte": "./src/index.js",
10
+ "exports": {
11
+ ".": {
12
+ "svelte": "./src/index.js",
13
+ "default": "./src/index.js"
14
+ },
15
+ "./tokens": "./src/tokens/index.css",
16
+ "./tokens/colors": "./src/tokens/colors.css",
17
+ "./tokens/spacing": "./src/tokens/spacing.css",
18
+ "./tokens/typography": "./src/tokens/typography.css",
19
+ "./tokens/effects": "./src/tokens/effects.css",
20
+ "./utils": "./src/utils/index.js",
21
+ "./actions": "./src/actions/index.js"
22
+ },
23
+ "files": [
24
+ "src",
25
+ "llms.txt",
26
+ "CLAUDE.md"
27
+ ],
28
+ "peerDependencies": {
29
+ "svelte": "^5.0.0",
30
+ "shiki": "^3.0.0",
31
+ "@lucide/svelte": "^0.500.0"
32
+ },
33
+ "peerDependenciesMeta": {
34
+ "shiki": {
35
+ "optional": true
36
+ },
37
+ "@lucide/svelte": {
38
+ "optional": true
39
+ }
12
40
  },
41
+ "devDependencies": {
42
+ "svelte": "^5.41.0"
43
+ },
44
+ "keywords": [
45
+ "svelte",
46
+ "svelte5",
47
+ "components",
48
+ "design-system",
49
+ "ui",
50
+ "miozu",
51
+ "base16",
52
+ "dark-theme"
53
+ ],
54
+ "author": "Nicholas Glazer <glazer.nicholas@gmail.com>",
55
+ "license": "MIT",
13
56
  "repository": {
14
57
  "type": "git",
15
- "url": "https://codeberg.org/miozu/jera"
58
+ "url": "https://github.com/miozu-com/jera"
16
59
  },
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"
60
+ "homepage": "https://miozu.com",
61
+ "bugs": {
62
+ "url": "https://github.com/miozu-com/jera/issues"
23
63
  }
24
64
  }