@programmerg/bs-elements 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.md +9 -0
- package/README.md +148 -0
- package/custom-elements.json +7773 -0
- package/dist/bs-elements.bundle.min.js +8 -0
- package/dist/bs-elements.bundle.min.js.map +1 -0
- package/dist/bs-elements.esm.js +1721 -0
- package/dist/bs-elements.esm.js.map +1 -0
- package/dist/bs-elements.min.js +2 -0
- package/dist/bs-elements.min.js.map +1 -0
- package/package.json +50 -0
- package/src/base/BsAccordion.js +116 -0
- package/src/base/BsAlert.js +91 -0
- package/src/base/BsButton.js +129 -0
- package/src/base/BsCarousel.js +216 -0
- package/src/base/BsCollapse.js +84 -0
- package/src/base/BsDropdown.js +98 -0
- package/src/base/BsModal.js +204 -0
- package/src/base/BsOffcanvas.js +157 -0
- package/src/base/BsPopover.js +31 -0
- package/src/base/BsTab.js +69 -0
- package/src/base/BsToast.js +163 -0
- package/src/base/BsTooltip.js +118 -0
- package/src/core/BsElement.js +81 -0
- package/src/core/ReactiveElement.js +183 -0
- package/src/extra/BsCalendar.js +14 -0
- package/src/extra/BsCombobox.js +14 -0
- package/src/extra/BsForm.js +152 -0
- package/src/extra/BsInput.js +209 -0
- package/src/extra/BsTable.js +210 -0
- package/src/extra/BsTabs.js +0 -0
- package/src/extra/BsToastManager.js +0 -0
- package/src/extra/BsTree.js +14 -0
- package/src/extra/BsUploader.js +154 -0
- package/src/index.js +12 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gelencsér Gergő
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="logo.svg" alt="bs-elements" width="128" height="128">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# bs-elements
|
|
6
|
+
|
|
7
|
+
A **Bootstrap 5–based, framework-agnostic Web Component library** built around the Bootstrap philosophy:
|
|
8
|
+
_class-first markup, minimal abstraction, and a thin DOM wrapper_.
|
|
9
|
+
|
|
10
|
+
bs-elements augments existing Bootstrap HTML and JavaScript with a **declarative Custom Element API**
|
|
11
|
+
— without hiding, replacing, or reinventing Bootstrap.
|
|
12
|
+
|
|
13
|
+
## 🎯 Goals
|
|
14
|
+
|
|
15
|
+
- Expose Bootstrap 5 components as **Custom Elements**
|
|
16
|
+
- Work everywhere: **Vanilla JS, React, Vue, Svelte**
|
|
17
|
+
- Preserve **full Bootstrap compatibility** (HTML, JS API, events)
|
|
18
|
+
- Reduce boilerplate while adding behavior
|
|
19
|
+
|
|
20
|
+
Explicitly not a goal:
|
|
21
|
+
|
|
22
|
+
- Inventing a new design system
|
|
23
|
+
- Replacing Bootstrap CSS
|
|
24
|
+
- Shadow DOM isolation
|
|
25
|
+
|
|
26
|
+
## 🚀 Getting started
|
|
27
|
+
|
|
28
|
+
Good old way
|
|
29
|
+
|
|
30
|
+
1. Follow the [official guide](https://getbootstrap.com/docs/5.3/getting-started/introduction/)
|
|
31
|
+
2. replace `bootstrap.boundle.min.js` with `bs-elements.boundle.min.js`
|
|
32
|
+
3. or add the `<script src="bs-elements.min.js"></script>` next to it
|
|
33
|
+
|
|
34
|
+
ES Modules
|
|
35
|
+
|
|
36
|
+
- Use the `<script src="bs-elements.esm.js" type="module"></script>`
|
|
37
|
+
- or install it with the command: `npm i programmerg/bs-elements`
|
|
38
|
+
- then you can import it as `import * from 'bs-elements'`
|
|
39
|
+
|
|
40
|
+
## 🧠 Design Principles
|
|
41
|
+
|
|
42
|
+
### Bootstrap-first
|
|
43
|
+
|
|
44
|
+
- Bootstrap documentation is the **single source of truth**
|
|
45
|
+
- DOM structure follows Bootstrap, not the component
|
|
46
|
+
- Classes are primary; properties are secondary
|
|
47
|
+
- The original Bootstrap JS API must continue to work unchanged
|
|
48
|
+
|
|
49
|
+
### Thin DOM wrapper
|
|
50
|
+
|
|
51
|
+
- No custom markup generation
|
|
52
|
+
- The Custom Element **is the root element**, not an extra wrapper
|
|
53
|
+
- Components enhance existing DOM with behavior
|
|
54
|
+
- Child markup may be intelligently assisted when missing
|
|
55
|
+
|
|
56
|
+
### Light DOM only
|
|
57
|
+
|
|
58
|
+
- No Shadow DOM
|
|
59
|
+
- Bootstrap CSS, utilities, and overrides work exactly as expected
|
|
60
|
+
|
|
61
|
+
### Attribute → state → option mapping
|
|
62
|
+
|
|
63
|
+
- Attributes initialize internal state
|
|
64
|
+
- Attribute changes update state
|
|
65
|
+
- The imperative JS API is optional and secondary
|
|
66
|
+
- State changes re-initialize the underlying Bootstrap instance
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<bs-modal class="modal" data-bs-backdrop="static" open></bs-modal>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Event compatibility
|
|
73
|
+
|
|
74
|
+
Event names are identical to Bootstrap events
|
|
75
|
+
|
|
76
|
+
`show.bs.modal`, `shown.bs.modal`, ...
|
|
77
|
+
|
|
78
|
+
### Idempotent DOM manipulation
|
|
79
|
+
|
|
80
|
+
- Synchronization is repeatable and safe
|
|
81
|
+
- No duplicated nodes
|
|
82
|
+
- No destructive re-rendering
|
|
83
|
+
- The same HTML remains stable across updates
|
|
84
|
+
|
|
85
|
+
## 🛠️ Technical Decisions
|
|
86
|
+
|
|
87
|
+
### Custom Elements
|
|
88
|
+
|
|
89
|
+
- Not exposed as part of the public API surface
|
|
90
|
+
- Chosen for:
|
|
91
|
+
- reactive attribute handling
|
|
92
|
+
- lifecycle hooks
|
|
93
|
+
- reduced boilerplate
|
|
94
|
+
|
|
95
|
+
### Bootstrap
|
|
96
|
+
|
|
97
|
+
- Bootstrap 5 CSS is an external dependency
|
|
98
|
+
- Bootstrap 5 JS is an internal dependency,
|
|
99
|
+
|
|
100
|
+
We wrap it — we do not reimplement it!
|
|
101
|
+
|
|
102
|
+
## 📦 Component Categories
|
|
103
|
+
|
|
104
|
+
### Base components
|
|
105
|
+
|
|
106
|
+
_Wrappers around native Bootstrap JS behavior:_
|
|
107
|
+
|
|
108
|
+
`bs-alert`, `bs-button`, `bs-carousel`, `bs-collapse`, `bs-dropdown`, `bs-modal`, `bs-offcanvas`, `bs-popover`, `bs-tab`, `bs-toast`, `bs-tooltip`
|
|
109
|
+
|
|
110
|
+
Responsibilities:
|
|
111
|
+
|
|
112
|
+
- Attribute → option mapping
|
|
113
|
+
- Lifecycle synchronization
|
|
114
|
+
- Event forwarding
|
|
115
|
+
|
|
116
|
+
### Extra components
|
|
117
|
+
|
|
118
|
+
_Components not provided by Bootstrap itself._
|
|
119
|
+
|
|
120
|
+
Responsibilities:
|
|
121
|
+
|
|
122
|
+
- Encapsulate higher-level or domain-specific behavior
|
|
123
|
+
|
|
124
|
+
## 🔁 Content Routing
|
|
125
|
+
|
|
126
|
+
- Components do not render templates
|
|
127
|
+
- All children stay in the light DOM
|
|
128
|
+
- The component may:
|
|
129
|
+
- recognize child roles
|
|
130
|
+
- add required classes
|
|
131
|
+
- move nodes when structurally necessary
|
|
132
|
+
|
|
133
|
+
**Auto boilerplate generation**
|
|
134
|
+
|
|
135
|
+
If required Bootstrap structure is missing, BsElements fills the gap.
|
|
136
|
+
|
|
137
|
+
```html
|
|
138
|
+
<bs-modal>
|
|
139
|
+
<div class="modal-header">Title</div>
|
|
140
|
+
<p>This will automatically become the modal-body</p>
|
|
141
|
+
</bs-modal>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## 📡 Lifecycle
|
|
145
|
+
|
|
146
|
+
- `connectedCallback` → initialize Bootstrap instance
|
|
147
|
+
- Attribute changes → synchronize options
|
|
148
|
+
- `disconnectedCallback` → clean up
|