@sekiui/elements 0.0.45 → 0.0.46

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 (2) hide show
  1. package/README.md +173 -54
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -33,30 +33,19 @@ npm install @sekiui/elements
33
33
 
34
34
  For quick prototyping or projects without a build system, you can load SekiUI directly from a CDN.
35
35
 
36
- **⚠️ Important: You must include BOTH the CSS and JavaScript files.**
37
-
38
36
  **Latest Stable Version (unpkg):**
39
37
  ```html
40
- <!-- 1. Include design tokens CSS in <head> -->
41
- <link rel="stylesheet" href="https://unpkg.com/@sekiui/elements@latest/dist/sekiui/sekiui.css">
42
-
43
- <!-- 2. Load Web Components at end of <body> -->
44
38
  <script type="module" src="https://unpkg.com/@sekiui/elements@latest/dist/sekiui/sekiui.esm.js"></script>
45
39
  ```
46
40
 
47
41
  **Latest Stable Version (jsDelivr):**
48
42
  ```html
49
- <!-- 1. Include design tokens CSS in <head> -->
50
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@sekiui/elements@latest/dist/sekiui/sekiui.css">
51
-
52
- <!-- 2. Load Web Components at end of <body> -->
53
43
  <script type="module" src="https://cdn.jsdelivr.net/npm/@sekiui/elements@latest/dist/sekiui/sekiui.esm.js"></script>
54
44
  ```
55
45
 
56
46
  **Specific Version (recommended for production):**
57
47
  ```html
58
48
  <!-- Replace 0.0.41 with your desired version -->
59
- <link rel="stylesheet" href="https://unpkg.com/@sekiui/elements@0.0.41/dist/sekiui/sekiui.css">
60
49
  <script type="module" src="https://unpkg.com/@sekiui/elements@0.0.41/dist/sekiui/sekiui.esm.js"></script>
61
50
  ```
62
51
 
@@ -68,9 +57,6 @@ For quick prototyping or projects without a build system, you can load SekiUI di
68
57
  <meta charset="UTF-8">
69
58
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
70
59
  <title>SekiUI via CDN</title>
71
-
72
- <!-- STEP 1: Include SekiUI design tokens CSS -->
73
- <link rel="stylesheet" href="https://unpkg.com/@sekiui/elements@latest/dist/sekiui/sekiui.css">
74
60
  </head>
75
61
  <body>
76
62
  <h1>SekiUI Components</h1>
@@ -80,7 +66,7 @@ For quick prototyping or projects without a build system, you can load SekiUI di
80
66
  <seki-button variant="secondary">Secondary</seki-button>
81
67
  <seki-input type="email" placeholder="you@example.com"></seki-input>
82
68
 
83
- <!-- STEP 2: Load SekiUI Web Components -->
69
+ <!-- Load SekiUI Web Components -->
84
70
  <script type="module" src="https://unpkg.com/@sekiui/elements@latest/dist/sekiui/sekiui.esm.js"></script>
85
71
  </body>
86
72
  </html>
@@ -91,28 +77,72 @@ For quick prototyping or projects without a build system, you can load SekiUI di
91
77
  - ✅ CORS headers configured for cross-origin requests
92
78
  - ✅ Versioned URLs cached long-term (immutable)
93
79
  - ✅ Latest URLs cached short-term (updates automatically)
94
- - ⚠️ **You must include both CSS and JS files** for components to render with proper styling
80
+ - Design tokens are integrated within components (no separate CSS file needed)
95
81
  - ⚠️ For production, use versioned URLs to ensure consistency
96
82
 
97
83
  ## Usage
98
84
 
99
- ### Web Components (Vanilla JS)
85
+ SekiUI supports both **lazy-loading all components** (recommended) and **importing individual components** for maximum bundle optimization.
86
+
87
+ ### Import Strategy
88
+
89
+ **Option 1: Lazy-Load All Components (Recommended)**
90
+ - Components are automatically loaded on-demand when used
91
+ - Best developer experience with minimal setup
92
+ - Small initial bundle (~5-10KB), components load as needed
100
93
 
101
- When using npm installation, you need to include both the CSS and JavaScript files:
94
+ **Option 2: Import Individual Components**
95
+ - Maximum tree-shaking and bundle optimization
96
+ - Import only specific components you use
97
+ - Best for performance-critical applications
98
+
99
+ ---
100
+
101
+ ### Vanilla JavaScript / HTML
102
+
103
+ #### Option 1: Using CDN (Recommended for Quick Start)
104
+
105
+ All components are automatically registered when you load the CDN bundle. No additional setup required.
102
106
 
103
107
  ```html
104
108
  <!DOCTYPE html>
105
109
  <html>
106
110
  <head>
107
- <!-- Include design tokens CSS -->
108
- <link rel="stylesheet" href="node_modules/@sekiui/elements/dist/sekiui/sekiui.css">
111
+ <meta charset="UTF-8">
112
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
109
113
  </head>
110
114
  <body>
115
+ <!-- Use components directly -->
111
116
  <seki-button variant="primary">Click me</seki-button>
112
117
  <seki-input type="email" placeholder="you@example.com"></seki-input>
113
118
 
114
- <!-- Load Web Components -->
115
- <script type="module" src="node_modules/@sekiui/elements/dist/sekiui/sekiui.esm.js"></script>
119
+ <!-- Load from CDN - components auto-register -->
120
+ <script type="module" src="https://unpkg.com/@sekiui/elements@latest/dist/sekiui/sekiui.esm.js"></script>
121
+ </body>
122
+ </html>
123
+ ```
124
+
125
+ #### Option 2: Using npm with Lazy-Loading
126
+
127
+ Components are loaded on-demand when used in the DOM. Requires calling `defineCustomElements()`.
128
+
129
+ ```html
130
+ <!DOCTYPE html>
131
+ <html>
132
+ <head>
133
+ <meta charset="UTF-8">
134
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
135
+ </head>
136
+ <body>
137
+ <!-- Components load automatically when rendered -->
138
+ <seki-button variant="primary">Click me</seki-button>
139
+ <seki-input type="email" placeholder="you@example.com"></seki-input>
140
+
141
+ <!-- Loader enables lazy-loading -->
142
+ <script type="module">
143
+ import { defineCustomElements } from './node_modules/@sekiui/elements/loader/index.js';
144
+ defineCustomElements();
145
+ </script>
116
146
  </body>
117
147
  </html>
118
148
  ```
@@ -120,26 +150,62 @@ When using npm installation, you need to include both the CSS and JavaScript fil
120
150
  **Or with a bundler (Vite, Webpack, etc.):**
121
151
 
122
152
  ```js
123
- // Import CSS in your main JS/TS file
124
- import '@sekiui/elements/dist/sekiui/sekiui.css';
125
-
126
- // Import and register components
153
+ // main.js - Components lazy-load on-demand
127
154
  import { defineCustomElements } from '@sekiui/elements/loader';
128
155
  defineCustomElements();
129
156
  ```
130
157
 
131
- Then use in your HTML:
158
+ #### Option 3: Import Individual Components
159
+
160
+ For maximum tree-shaking, import only specific components you need.
132
161
 
133
162
  ```html
134
- <seki-button variant="primary">Click me</seki-button>
135
- <seki-input type="email" placeholder="you@example.com"></seki-input>
163
+ <!DOCTYPE html>
164
+ <html>
165
+ <body>
166
+ <seki-button variant="primary">Click me</seki-button>
167
+
168
+ <script type="module">
169
+ // Only imports button component (~3-5KB)
170
+ import { defineCustomElement } from './node_modules/@sekiui/elements/dist/components/seki-button.js';
171
+ defineCustomElement();
172
+ </script>
173
+ </body>
174
+ </html>
136
175
  ```
137
176
 
177
+ **Or with a bundler:**
178
+
179
+ ```js
180
+ // Only button component is bundled
181
+ import { defineCustomElement } from '@sekiui/elements/dist/components/seki-button.js';
182
+ defineCustomElement();
183
+ ```
184
+
185
+ ---
186
+
138
187
  ### React
139
188
 
189
+ #### Using All Components (Lazy-Loaded)
190
+
191
+ ```jsx
192
+ // App.jsx
193
+ import { SekiButton, SekiInput } from '@sekiui/elements/react';
194
+
195
+ function App() {
196
+ return (
197
+ <>
198
+ <SekiButton variant="primary">Click me</SekiButton>
199
+ <SekiInput type="email" placeholder="you@example.com" />
200
+ </>
201
+ );
202
+ }
203
+ ```
204
+
205
+ #### Using Individual Components
206
+
140
207
  ```jsx
141
- // Import CSS in your main index.js or App.js
142
- import '@sekiui/elements/dist/sekiui/sekiui.css';
208
+ // Import only button wrapper
143
209
  import { SekiButton } from '@sekiui/elements/react';
144
210
 
145
211
  function App() {
@@ -147,35 +213,48 @@ function App() {
147
213
  }
148
214
  ```
149
215
 
150
- ### Vue
216
+ **Or use the native custom element directly:**
217
+
218
+ ```jsx
219
+ import { defineCustomElement } from '@sekiui/elements/dist/components/seki-button.js';
220
+
221
+ // Register once at app startup
222
+ defineCustomElement();
223
+
224
+ function App() {
225
+ return <seki-button variant="primary">Click me</seki-button>;
226
+ }
227
+ ```
228
+
229
+ ---
230
+
231
+ ### Vue 3
151
232
 
152
- **Option 1: Global Registration (Recommended)**
233
+ #### Using All Components (Lazy-Loaded)
153
234
 
154
- In your `main.js` or `main.ts`:
235
+ **Global Registration (Recommended):**
155
236
 
156
237
  ```js
238
+ // main.js
157
239
  import { createApp } from 'vue';
158
240
  import App from './App.vue';
159
241
  import { defineCustomElements } from '@sekiui/elements/loader';
160
242
 
161
- // Import CSS once globally
162
- import '@sekiui/elements/dist/sekiui/sekiui.css';
163
-
164
- // Register custom elements once globally
243
+ // Components lazy-load on-demand
165
244
  defineCustomElements();
166
245
 
167
246
  createApp(App).mount('#app');
168
247
  ```
169
248
 
170
- Then use anywhere in your components:
171
-
172
249
  ```vue
250
+ <!-- Any component can now use SekiUI -->
173
251
  <template>
174
252
  <seki-button variant="primary">Click me</seki-button>
253
+ <seki-input type="email" placeholder="you@example.com"></seki-input>
175
254
  </template>
176
255
  ```
177
256
 
178
- **Option 2: Component-level Registration**
257
+ **Component-level Registration:**
179
258
 
180
259
  ```vue
181
260
  <template>
@@ -183,12 +262,25 @@ Then use anywhere in your components:
183
262
  </template>
184
263
 
185
264
  <script setup>
186
- import '@sekiui/elements/dist/sekiui/sekiui.css';
187
265
  import { defineCustomElements } from '@sekiui/elements/loader';
188
266
  defineCustomElements();
189
267
  </script>
190
268
  ```
191
269
 
270
+ #### Using Individual Components
271
+
272
+ ```vue
273
+ <template>
274
+ <seki-button variant="primary">Click me</seki-button>
275
+ </template>
276
+
277
+ <script setup>
278
+ // Only imports button component
279
+ import { defineCustomElement } from '@sekiui/elements/dist/components/seki-button.js';
280
+ defineCustomElement();
281
+ </script>
282
+ ```
283
+
192
284
  **Vue 3 Config (Optional):**
193
285
 
194
286
  To prevent Vue warnings about unknown custom elements, add to `vite.config.js`:
@@ -205,39 +297,66 @@ export default {
205
297
  }
206
298
  ```
207
299
 
208
- ### Angular
209
-
210
- **Step 1:** Import CSS in `styles.css` or `styles.scss`:
300
+ ---
211
301
 
212
- ```css
213
- /* src/styles.css */
214
- @import '@sekiui/elements/dist/sekiui/sekiui.css';
215
- ```
302
+ ### Angular
216
303
 
217
- **Step 2:** Register custom elements in `app.module.ts`:
304
+ #### Using All Components (Lazy-Loaded)
218
305
 
219
306
  ```typescript
307
+ // app.module.ts
220
308
  import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
221
309
  import { BrowserModule } from '@angular/platform-browser';
222
310
  import { defineCustomElements } from '@sekiui/elements/loader';
223
311
 
224
- // Register custom elements
312
+ // Register all components (lazy-loaded)
225
313
  defineCustomElements();
226
314
 
227
315
  @NgModule({
228
- schemas: [CUSTOM_ELEMENTS_SCHEMA], // Tell Angular to allow custom elements
316
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
229
317
  imports: [BrowserModule],
230
318
  // ...
231
319
  })
232
320
  export class AppModule { }
233
321
  ```
234
322
 
235
- **Step 3:** Use in your templates:
236
-
237
323
  ```html
324
+ <!-- app.component.html -->
238
325
  <seki-button variant="primary">Click me</seki-button>
326
+ <seki-input type="email" placeholder="you@example.com"></seki-input>
239
327
  ```
240
328
 
329
+ #### Using Individual Components
330
+
331
+ ```typescript
332
+ // app.component.ts
333
+ import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
334
+ import { defineCustomElement } from '@sekiui/elements/dist/components/seki-button.js';
335
+
336
+ // Only imports button component
337
+ defineCustomElement();
338
+
339
+ @Component({
340
+ selector: 'app-root',
341
+ template: '<seki-button variant="primary">Click me</seki-button>',
342
+ schemas: [CUSTOM_ELEMENTS_SCHEMA]
343
+ })
344
+ export class AppComponent {}
345
+ ```
346
+
347
+ ---
348
+
349
+ ### Bundle Size Comparison
350
+
351
+ | Import Method | Initial Bundle | Notes |
352
+ |--------------|----------------|-------|
353
+ | **CDN (lazy-loaded)** | ~5-10KB | Components download on first use |
354
+ | **Loader (all components)** | ~5-10KB | Lazy-loads components as needed |
355
+ | **Individual component** | ~3-5KB | Only `seki-button` + shared runtime |
356
+ | **Multiple individual** | Varies | Each component ~2-4KB + shared runtime |
357
+
358
+ **Recommendation:** Use the loader approach for most projects. It provides excellent performance through automatic lazy-loading while maintaining the best developer experience.
359
+
241
360
  ## License
242
361
 
243
362
  MIT © SekiUI Team
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sekiui/elements",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "description": "Modern, accessible Web Components with shadcn/ui-inspired design",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",