@transcodes/ui-components 0.1.0
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 +21 -0
- package/README.md +235 -0
- package/dist/index.d.ts +902 -0
- package/dist/ui-components.css +1 -0
- package/dist/ui-components.js +4372 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Transcodes
|
|
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,235 @@
|
|
|
1
|
+
# @transcodes/ui-components
|
|
2
|
+
|
|
3
|
+
A modern web component library built with [Lit 3.x](https://lit.dev/). Features a comprehensive set of UI primitives, complex widgets, and reusable Reactive Controllers for building beautiful, accessible interfaces.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@transcodes/ui-components)
|
|
6
|
+
[](https://github.com/transcodings/transcodes-ui/blob/main/packages/ui-components/LICENSE)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Web Components** - Framework-agnostic, works with React, Vue, Angular, or vanilla JS
|
|
11
|
+
- **Lit 3.x Powered** - Fast, lightweight, and reactive
|
|
12
|
+
- **Design Token Integration** - Built on [@transcodes/design-tokens](https://www.npmjs.com/package/@transcodes/design-tokens)
|
|
13
|
+
- **Reactive Controllers** - Reusable logic for loading states, forms, animations, and more
|
|
14
|
+
- **TypeScript First** - Full type definitions included
|
|
15
|
+
- **Storybook Documentation** - Interactive component explorer
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @transcodes/ui-components lit
|
|
21
|
+
# or
|
|
22
|
+
yarn add @transcodes/ui-components lit
|
|
23
|
+
# or
|
|
24
|
+
pnpm add @transcodes/ui-components lit
|
|
25
|
+
# or
|
|
26
|
+
bun add @transcodes/ui-components lit
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> **Note:** `lit` is a peer dependency and must be installed separately.
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
### 1. Import and register components
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
// Import all components (registers custom elements automatically)
|
|
37
|
+
import '@transcodes/ui-components';
|
|
38
|
+
|
|
39
|
+
// Import styles
|
|
40
|
+
import '@transcodes/ui-components/styles.css';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 2. Use in your HTML
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<tc-button variant="primary">Click me</tc-button>
|
|
47
|
+
|
|
48
|
+
<tc-input
|
|
49
|
+
type="email"
|
|
50
|
+
placeholder="Enter your email"
|
|
51
|
+
required
|
|
52
|
+
></tc-input>
|
|
53
|
+
|
|
54
|
+
<tc-callout variant="info">
|
|
55
|
+
This is an informational message.
|
|
56
|
+
</tc-callout>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 3. Handle events
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
const button = document.querySelector('tc-button');
|
|
63
|
+
button.addEventListener('tc-click', (e) => {
|
|
64
|
+
console.log('Button clicked!', e.detail);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const input = document.querySelector('tc-input');
|
|
68
|
+
input.addEventListener('tc-change', (e) => {
|
|
69
|
+
console.log('Input value:', e.detail.value);
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Components
|
|
74
|
+
|
|
75
|
+
### Primitives
|
|
76
|
+
|
|
77
|
+
Core UI building blocks with consistent styling and behavior.
|
|
78
|
+
|
|
79
|
+
| Component | Description | Key Props |
|
|
80
|
+
|-----------|-------------|-----------|
|
|
81
|
+
| `<tc-button>` | Interactive button | `variant`, `size`, `disabled`, `loading` |
|
|
82
|
+
| `<tc-input>` | Text input field | `type`, `placeholder`, `required`, `error` |
|
|
83
|
+
| `<tc-otp-input>` | OTP/PIN code input | `length`, `masked` |
|
|
84
|
+
| `<tc-text>` | Typography component | `variant`, `weight`, `color` |
|
|
85
|
+
| `<tc-container>` | Layout container | `maxWidth`, `padding` |
|
|
86
|
+
| `<tc-box>` | Flexible box wrapper | `padding`, `gap` |
|
|
87
|
+
| `<tc-section>` | Page section | `padding` |
|
|
88
|
+
| `<tc-divider>` | Visual separator | `orientation` |
|
|
89
|
+
| `<tc-callout>` | Alert/info box | `variant` (info, warning, error, success) |
|
|
90
|
+
| `<tc-chip>` | Tag/badge | `variant`, `removable` |
|
|
91
|
+
| `<tc-icon>` | Icon display | `name`, `size` |
|
|
92
|
+
| `<tc-spinner>` | Loading indicator | `size` |
|
|
93
|
+
| `<tc-toast>` | Toast notification | `variant`, `duration` |
|
|
94
|
+
|
|
95
|
+
### Widgets
|
|
96
|
+
|
|
97
|
+
Complex components composed of primitives.
|
|
98
|
+
|
|
99
|
+
| Component | Description |
|
|
100
|
+
|-----------|-------------|
|
|
101
|
+
| `<tc-notification-modal>` | Modal dialog for notifications |
|
|
102
|
+
| `<tc-offline-modal>` | Offline state indicator modal |
|
|
103
|
+
| `<tc-floating-action-button>` | FAB with optional menu |
|
|
104
|
+
|
|
105
|
+
### Controllers
|
|
106
|
+
|
|
107
|
+
Reusable logic that can be attached to any Lit component.
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { LoadingController, FormController } from '@transcodes/ui-components';
|
|
111
|
+
|
|
112
|
+
class MyComponent extends LitElement {
|
|
113
|
+
private loading = new LoadingController(this);
|
|
114
|
+
private form = new FormController(this);
|
|
115
|
+
|
|
116
|
+
async handleSubmit() {
|
|
117
|
+
this.loading.start();
|
|
118
|
+
try {
|
|
119
|
+
await submitData();
|
|
120
|
+
} finally {
|
|
121
|
+
this.loading.stop();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
| Controller | Purpose |
|
|
128
|
+
|------------|---------|
|
|
129
|
+
| `LoadingController` | Manage loading states |
|
|
130
|
+
| `FormController` | Form validation and submission |
|
|
131
|
+
| `AnimationController` | Coordinate animations |
|
|
132
|
+
| `MatchMediaController` | Respond to media queries |
|
|
133
|
+
| `StorageController` | Persist data to localStorage/sessionStorage |
|
|
134
|
+
| `MessageBusController` | Cross-component communication |
|
|
135
|
+
|
|
136
|
+
## Styling
|
|
137
|
+
|
|
138
|
+
Components use CSS custom properties from `@transcodes/design-tokens`. You can customize the look by overriding these variables:
|
|
139
|
+
|
|
140
|
+
```css
|
|
141
|
+
:root {
|
|
142
|
+
/* Override brand colors */
|
|
143
|
+
--accent-primary: #your-brand-color;
|
|
144
|
+
|
|
145
|
+
/* Override spacing */
|
|
146
|
+
--space-md: 16px;
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Custom styles per component
|
|
151
|
+
|
|
152
|
+
All components accept an `sx` prop for inline style overrides:
|
|
153
|
+
|
|
154
|
+
```html
|
|
155
|
+
<tc-button
|
|
156
|
+
variant="primary"
|
|
157
|
+
.sx=${{ padding: '1rem 2rem', fontSize: '1.25rem' }}
|
|
158
|
+
>
|
|
159
|
+
Large Button
|
|
160
|
+
</tc-button>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Framework Integration
|
|
164
|
+
|
|
165
|
+
### React
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
import '@transcodes/ui-components';
|
|
169
|
+
|
|
170
|
+
function App() {
|
|
171
|
+
const handleClick = (e: CustomEvent) => {
|
|
172
|
+
console.log('Clicked!');
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<tc-button
|
|
177
|
+
variant="primary"
|
|
178
|
+
onTc-click={handleClick}
|
|
179
|
+
>
|
|
180
|
+
Click me
|
|
181
|
+
</tc-button>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Vue
|
|
187
|
+
|
|
188
|
+
```vue
|
|
189
|
+
<template>
|
|
190
|
+
<tc-button variant="primary" @tc-click="handleClick">
|
|
191
|
+
Click me
|
|
192
|
+
</tc-button>
|
|
193
|
+
</template>
|
|
194
|
+
|
|
195
|
+
<script setup>
|
|
196
|
+
import '@transcodes/ui-components';
|
|
197
|
+
|
|
198
|
+
const handleClick = () => {
|
|
199
|
+
console.log('Clicked!');
|
|
200
|
+
};
|
|
201
|
+
</script>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Browser Support
|
|
205
|
+
|
|
206
|
+
Supports all modern browsers with native Custom Elements v1 support:
|
|
207
|
+
|
|
208
|
+
- Chrome 67+
|
|
209
|
+
- Firefox 63+
|
|
210
|
+
- Safari 10.1+
|
|
211
|
+
- Edge 79+
|
|
212
|
+
|
|
213
|
+
## Development
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# Install dependencies
|
|
217
|
+
bun install
|
|
218
|
+
|
|
219
|
+
# Start Storybook dev server
|
|
220
|
+
bun run dev
|
|
221
|
+
|
|
222
|
+
# Build for production
|
|
223
|
+
bun run build
|
|
224
|
+
|
|
225
|
+
# Type check
|
|
226
|
+
bun run type-check
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Related Packages
|
|
230
|
+
|
|
231
|
+
- [@transcodes/design-tokens](https://www.npmjs.com/package/@transcodes/design-tokens) - Design tokens used by this library
|
|
232
|
+
|
|
233
|
+
## License
|
|
234
|
+
|
|
235
|
+
[MIT](./LICENSE)
|