simplesvelte 2.5.1 → 2.5.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/README.md +227 -214
- package/dist/AG_GRID_SERVER_API.md +373 -373
- package/dist/Grid.svelte +168 -168
- package/dist/Input.svelte +145 -145
- package/dist/Label.svelte +43 -43
- package/dist/Modal.svelte +39 -39
- package/dist/Select.svelte +697 -696
- package/dist/TextArea.svelte +45 -45
- package/dist/styles.css +15 -15
- package/package.json +73 -69
package/README.md
CHANGED
|
@@ -1,214 +1,227 @@
|
|
|
1
|
-
# SimpleSvelte
|
|
2
|
-
|
|
3
|
-
A lightweight collection of essential Svelte components and utilities for building modern web applications quickly and efficiently.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Form Components**: Ready-to-use Input, Label, Select, and TextArea components with built-in validation support
|
|
8
|
-
- **UI Components**: Modal and Grid components for common layout needs
|
|
9
|
-
- **Popup System**: Easy-to-use Pop class for alerts, confirmations, and notifications (powered by SweetAlert2)
|
|
10
|
-
- **Utility Functions**: FormHelper for form data processing, clickOutside action, and role helpers
|
|
11
|
-
- **TypeScript Support**: Fully typed components and utilities
|
|
12
|
-
- **Lightweight**: Minimal dependencies, maximum functionality
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
bun install simplesvelte
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## CSS Setup
|
|
21
|
-
|
|
22
|
-
SimpleSvelte requires CSS to be imported for proper styling. See [CSS_USAGE.md](./CSS_USAGE.md) for detailed instructions.
|
|
23
|
-
|
|
24
|
-
**Quick setup:**
|
|
25
|
-
|
|
26
|
-
```css
|
|
27
|
-
/* In your main CSS file */
|
|
28
|
-
@import 'simplesvelte/styles.css';
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Or in JavaScript/TypeScript:
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
import 'simplesvelte/styles.css'
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Quick Start
|
|
38
|
-
|
|
39
|
-
```svelte
|
|
40
|
-
<script>
|
|
41
|
-
import { Input, Label, Modal, Pop } from 'simplesvelte'
|
|
42
|
-
|
|
43
|
-
let showModal = false
|
|
44
|
-
let inputValue = ''
|
|
45
|
-
|
|
46
|
-
const handleConfirm = async () => {
|
|
47
|
-
const result = await Pop.confirm('Delete item?', 'This action cannot be undone')
|
|
48
|
-
if (result.isConfirmed) {
|
|
49
|
-
// Handle deletion
|
|
50
|
-
Pop.success('Deleted!', 'Your item has been deleted.')
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
</script>
|
|
54
|
-
|
|
55
|
-
<Label for="email">Email Address</Label>
|
|
56
|
-
<Input name="email" type="email" bind:value={inputValue} placeholder="Enter your email" required />
|
|
57
|
-
|
|
58
|
-
<button on:click={() => (showModal = true)}>Open Modal</button>
|
|
59
|
-
<button on:click={handleConfirm}>Delete Item</button>
|
|
60
|
-
|
|
61
|
-
<Modal bind:show={showModal}>
|
|
62
|
-
<h2>Modal Content</h2>
|
|
63
|
-
<p>Your modal content goes here!</p>
|
|
64
|
-
</Modal>
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Components
|
|
68
|
-
|
|
69
|
-
aa
|
|
70
|
-
|
|
71
|
-
### Form Components
|
|
72
|
-
|
|
73
|
-
- **Input**: Versatile input component supporting text, email, password, number, date, and more
|
|
74
|
-
- **Label**: Accessible label component with built-in styling
|
|
75
|
-
- **Select**: Dropdown select component with custom styling and multi-select support
|
|
76
|
-
- **TextArea**: Multi-line text input with auto-resize options
|
|
77
|
-
|
|
78
|
-
### UI Components
|
|
79
|
-
|
|
80
|
-
- **Modal**: Flexible modal component with backdrop and keyboard controls
|
|
81
|
-
- **Grid**: Responsive grid layout component
|
|
82
|
-
|
|
83
|
-
### Utilities
|
|
84
|
-
|
|
85
|
-
- **Pop**: SweetAlert2-powered popup system for alerts, confirmations, and toasts
|
|
86
|
-
- **FormHelper**: Utility class for processing FormData with type-safe getters
|
|
87
|
-
- **clickOutside**: Svelte action for detecting clicks outside an element
|
|
88
|
-
- **roleHelper**: Accessibility helper for ARIA roles
|
|
89
|
-
|
|
90
|
-
## Examples
|
|
91
|
-
|
|
92
|
-
### Select Component
|
|
93
|
-
|
|
94
|
-
```svelte
|
|
95
|
-
<script>
|
|
96
|
-
import { Select } from 'simplesvelte'
|
|
97
|
-
|
|
98
|
-
let singleValue = ''
|
|
99
|
-
let multipleValues = []
|
|
100
|
-
|
|
101
|
-
const options = [
|
|
102
|
-
{ value: 'apple', label: 'Apple' },
|
|
103
|
-
{ value: 'banana', label: 'Banana' },
|
|
104
|
-
{ value: 'cherry', label: 'Cherry' },
|
|
105
|
-
]
|
|
106
|
-
</script>
|
|
107
|
-
|
|
108
|
-
<!-- Single Select -->
|
|
109
|
-
<Select bind:value={singleValue} {options} label="Choose a fruit" name="fruit" required />
|
|
110
|
-
|
|
111
|
-
<!-- Multi Select -->
|
|
112
|
-
<Select bind:value={multipleValues} {options} label="Choose multiple fruits" name="fruits" multiple />
|
|
113
|
-
|
|
114
|
-
<!-- Disabled Select -->
|
|
115
|
-
<Select value={['apple', 'cherry']} {options} label="Pre-selected fruits" name="preset-fruits" multiple disabled />
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### Using Pop for Notifications
|
|
119
|
-
|
|
120
|
-
```javascript
|
|
121
|
-
import { Pop } from 'simplesvelte'
|
|
122
|
-
|
|
123
|
-
// Success notification
|
|
124
|
-
await Pop.success('Your changes have been saved.')
|
|
125
|
-
|
|
126
|
-
// Error notification
|
|
127
|
-
await Pop.error('Something went wrong.')
|
|
128
|
-
|
|
129
|
-
// Confirmation dialog
|
|
130
|
-
const result = await Pop.confirm('Delete this item?', 'This action cannot be undone')
|
|
131
|
-
if (!res) {
|
|
132
|
-
// User confirmed
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Custom toast
|
|
136
|
-
Pop.toast('Updated!', 'success', 'top-end')
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### Using FormHelper
|
|
140
|
-
|
|
141
|
-
```svelte
|
|
142
|
-
<script>
|
|
143
|
-
import { FormHelper } from 'simplesvelte'
|
|
144
|
-
|
|
145
|
-
function parseFormData(FormData: FormData) {
|
|
146
|
-
const fh = new FormHelper(formData)
|
|
147
|
-
const data = {
|
|
148
|
-
name: fh.string("name")
|
|
149
|
-
optionalPhone: fh.nString("phone")
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
</script>
|
|
155
|
-
|
|
156
|
-
<form use:enhance>
|
|
157
|
-
<!-- Your form inputs here -->
|
|
158
|
-
</form>
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### Using clickOutside Action
|
|
162
|
-
|
|
163
|
-
```svelte
|
|
164
|
-
<script>
|
|
165
|
-
import { clickOutside } from 'simplesvelte'
|
|
166
|
-
|
|
167
|
-
let showDropdown = false
|
|
168
|
-
|
|
169
|
-
function handleClickOutside() {
|
|
170
|
-
showDropdown = false
|
|
171
|
-
}
|
|
172
|
-
</script>
|
|
173
|
-
|
|
174
|
-
<div use:clickOutside={handleClickOutside}>
|
|
175
|
-
<!-- Dropdown content -->
|
|
176
|
-
</div>
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
## Development
|
|
180
|
-
|
|
181
|
-
This library is built with SvelteKit and powered by Vite. To contribute or modify the library:
|
|
182
|
-
|
|
183
|
-
```bash
|
|
184
|
-
# Clone and install dependencies
|
|
185
|
-
git clone <your-repo>
|
|
186
|
-
cd SimpleSvelte
|
|
187
|
-
bun install
|
|
188
|
-
|
|
189
|
-
# Start development server with showcase app
|
|
190
|
-
bun run dev
|
|
191
|
-
|
|
192
|
-
# or open in browser automatically
|
|
193
|
-
bun run dev -- --open
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
The `src/lib` directory contains all library components, while `src/routes` provides a showcase/preview app for testing components.
|
|
197
|
-
|
|
198
|
-
## Building
|
|
199
|
-
|
|
200
|
-
To build your library:
|
|
201
|
-
|
|
202
|
-
```bash
|
|
203
|
-
bun run
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
This will generate the distribution files in the `dist` directory.
|
|
207
|
-
|
|
208
|
-
##
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
1
|
+
# SimpleSvelte
|
|
2
|
+
|
|
3
|
+
A lightweight collection of essential Svelte components and utilities for building modern web applications quickly and efficiently.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Form Components**: Ready-to-use Input, Label, Select, and TextArea components with built-in validation support
|
|
8
|
+
- **UI Components**: Modal and Grid components for common layout needs
|
|
9
|
+
- **Popup System**: Easy-to-use Pop class for alerts, confirmations, and notifications (powered by SweetAlert2)
|
|
10
|
+
- **Utility Functions**: FormHelper for form data processing, clickOutside action, and role helpers
|
|
11
|
+
- **TypeScript Support**: Fully typed components and utilities
|
|
12
|
+
- **Lightweight**: Minimal dependencies, maximum functionality
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
bun install simplesvelte
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## CSS Setup
|
|
21
|
+
|
|
22
|
+
SimpleSvelte requires CSS to be imported for proper styling. See [CSS_USAGE.md](./CSS_USAGE.md) for detailed instructions.
|
|
23
|
+
|
|
24
|
+
**Quick setup:**
|
|
25
|
+
|
|
26
|
+
```css
|
|
27
|
+
/* In your main CSS file */
|
|
28
|
+
@import 'simplesvelte/styles.css';
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or in JavaScript/TypeScript:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import 'simplesvelte/styles.css'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
```svelte
|
|
40
|
+
<script>
|
|
41
|
+
import { Input, Label, Modal, Pop } from 'simplesvelte'
|
|
42
|
+
|
|
43
|
+
let showModal = false
|
|
44
|
+
let inputValue = ''
|
|
45
|
+
|
|
46
|
+
const handleConfirm = async () => {
|
|
47
|
+
const result = await Pop.confirm('Delete item?', 'This action cannot be undone')
|
|
48
|
+
if (result.isConfirmed) {
|
|
49
|
+
// Handle deletion
|
|
50
|
+
Pop.success('Deleted!', 'Your item has been deleted.')
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<Label for="email">Email Address</Label>
|
|
56
|
+
<Input name="email" type="email" bind:value={inputValue} placeholder="Enter your email" required />
|
|
57
|
+
|
|
58
|
+
<button on:click={() => (showModal = true)}>Open Modal</button>
|
|
59
|
+
<button on:click={handleConfirm}>Delete Item</button>
|
|
60
|
+
|
|
61
|
+
<Modal bind:show={showModal}>
|
|
62
|
+
<h2>Modal Content</h2>
|
|
63
|
+
<p>Your modal content goes here!</p>
|
|
64
|
+
</Modal>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Components
|
|
68
|
+
|
|
69
|
+
aa
|
|
70
|
+
|
|
71
|
+
### Form Components
|
|
72
|
+
|
|
73
|
+
- **Input**: Versatile input component supporting text, email, password, number, date, and more
|
|
74
|
+
- **Label**: Accessible label component with built-in styling
|
|
75
|
+
- **Select**: Dropdown select component with custom styling and multi-select support
|
|
76
|
+
- **TextArea**: Multi-line text input with auto-resize options
|
|
77
|
+
|
|
78
|
+
### UI Components
|
|
79
|
+
|
|
80
|
+
- **Modal**: Flexible modal component with backdrop and keyboard controls
|
|
81
|
+
- **Grid**: Responsive grid layout component
|
|
82
|
+
|
|
83
|
+
### Utilities
|
|
84
|
+
|
|
85
|
+
- **Pop**: SweetAlert2-powered popup system for alerts, confirmations, and toasts
|
|
86
|
+
- **FormHelper**: Utility class for processing FormData with type-safe getters
|
|
87
|
+
- **clickOutside**: Svelte action for detecting clicks outside an element
|
|
88
|
+
- **roleHelper**: Accessibility helper for ARIA roles
|
|
89
|
+
|
|
90
|
+
## Examples
|
|
91
|
+
|
|
92
|
+
### Select Component
|
|
93
|
+
|
|
94
|
+
```svelte
|
|
95
|
+
<script>
|
|
96
|
+
import { Select } from 'simplesvelte'
|
|
97
|
+
|
|
98
|
+
let singleValue = ''
|
|
99
|
+
let multipleValues = []
|
|
100
|
+
|
|
101
|
+
const options = [
|
|
102
|
+
{ value: 'apple', label: 'Apple' },
|
|
103
|
+
{ value: 'banana', label: 'Banana' },
|
|
104
|
+
{ value: 'cherry', label: 'Cherry' },
|
|
105
|
+
]
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<!-- Single Select -->
|
|
109
|
+
<Select bind:value={singleValue} {options} label="Choose a fruit" name="fruit" required />
|
|
110
|
+
|
|
111
|
+
<!-- Multi Select -->
|
|
112
|
+
<Select bind:value={multipleValues} {options} label="Choose multiple fruits" name="fruits" multiple />
|
|
113
|
+
|
|
114
|
+
<!-- Disabled Select -->
|
|
115
|
+
<Select value={['apple', 'cherry']} {options} label="Pre-selected fruits" name="preset-fruits" multiple disabled />
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Using Pop for Notifications
|
|
119
|
+
|
|
120
|
+
```javascript
|
|
121
|
+
import { Pop } from 'simplesvelte'
|
|
122
|
+
|
|
123
|
+
// Success notification
|
|
124
|
+
await Pop.success('Your changes have been saved.')
|
|
125
|
+
|
|
126
|
+
// Error notification
|
|
127
|
+
await Pop.error('Something went wrong.')
|
|
128
|
+
|
|
129
|
+
// Confirmation dialog
|
|
130
|
+
const result = await Pop.confirm('Delete this item?', 'This action cannot be undone')
|
|
131
|
+
if (!res) {
|
|
132
|
+
// User confirmed
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Custom toast
|
|
136
|
+
Pop.toast('Updated!', 'success', 'top-end')
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Using FormHelper
|
|
140
|
+
|
|
141
|
+
```svelte
|
|
142
|
+
<script>
|
|
143
|
+
import { FormHelper } from 'simplesvelte'
|
|
144
|
+
|
|
145
|
+
function parseFormData(FormData: FormData) {
|
|
146
|
+
const fh = new FormHelper(formData)
|
|
147
|
+
const data = {
|
|
148
|
+
name: fh.string("name")
|
|
149
|
+
optionalPhone: fh.nString("phone")
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
</script>
|
|
155
|
+
|
|
156
|
+
<form use:enhance>
|
|
157
|
+
<!-- Your form inputs here -->
|
|
158
|
+
</form>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Using clickOutside Action
|
|
162
|
+
|
|
163
|
+
```svelte
|
|
164
|
+
<script>
|
|
165
|
+
import { clickOutside } from 'simplesvelte'
|
|
166
|
+
|
|
167
|
+
let showDropdown = false
|
|
168
|
+
|
|
169
|
+
function handleClickOutside() {
|
|
170
|
+
showDropdown = false
|
|
171
|
+
}
|
|
172
|
+
</script>
|
|
173
|
+
|
|
174
|
+
<div use:clickOutside={handleClickOutside}>
|
|
175
|
+
<!-- Dropdown content -->
|
|
176
|
+
</div>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Development
|
|
180
|
+
|
|
181
|
+
This library is built with SvelteKit and powered by Vite. To contribute or modify the library:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# Clone and install dependencies
|
|
185
|
+
git clone <your-repo>
|
|
186
|
+
cd SimpleSvelte
|
|
187
|
+
bun install
|
|
188
|
+
|
|
189
|
+
# Start development server with showcase app
|
|
190
|
+
bun run dev
|
|
191
|
+
|
|
192
|
+
# or open in browser automatically
|
|
193
|
+
bun run dev -- --open
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The `src/lib` directory contains all library components, while `src/routes` provides a showcase/preview app for testing components.
|
|
197
|
+
|
|
198
|
+
## Building
|
|
199
|
+
|
|
200
|
+
To build your library:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
bun run build
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
This will generate the distribution files in the `dist` directory.
|
|
207
|
+
|
|
208
|
+
## Publishing
|
|
209
|
+
|
|
210
|
+
Publishing is automated through [.github/workflows/bun-publish.yml](.github/workflows/bun-publish.yml):
|
|
211
|
+
|
|
212
|
+
1. Create a GitHub release with a tag like `v2.5.2`
|
|
213
|
+
2. The workflow updates `package.json` to the release tag version
|
|
214
|
+
3. The workflow runs type checks and build packaging
|
|
215
|
+
4. The workflow publishes to npm
|
|
216
|
+
|
|
217
|
+
Required repository secret:
|
|
218
|
+
|
|
219
|
+
- `NPM_TOKEN` with publish access for the `simplesvelte` package
|
|
220
|
+
|
|
221
|
+
## License
|
|
222
|
+
|
|
223
|
+
MIT - see LICENSE file for details.
|
|
224
|
+
|
|
225
|
+
## Contributing
|
|
226
|
+
|
|
227
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|