@ratiosolver/flick 0.0.1

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 ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # Flick
2
+
3
+ Flick is a tiny and focused UI framework designed for clarity and speed. It provides just the essentials to create reactive, component-based interfaces using clean and predictable patterns.
4
+
5
+ ⚡ Lightweight and fast
6
+
7
+ 🧠 Reactive state management
8
+
9
+ 🧩 Component-driven architecture
10
+
11
+ 💎 Written in TypeScript
12
+
13
+ 🔗 Minimal external dependencies (relies only on Bootstrap)
14
+
15
+ ## Overview
16
+
17
+ Flick provides the basic utilities for managing components, lists, server connections, and user sessions. The framework is designed to be lightweight and flexible, making it easy to integrate into various web applications. It provides essential utilities for handling:
18
+
19
+ - **Component management** – A structured approach to defining and interacting with components.
20
+ - **List management** – Built-in support for managing collections of components.
21
+ - **Server connection** – Tools for handling communication with a server.
22
+ - **User management** – Basic utilities for managing the current user session.
23
+
24
+ ## Installation
25
+
26
+ To install Flick, you can use npm:
27
+
28
+ ```bash
29
+ npm install @ratiosolver/flick
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ Flick provides a set of utilities that can be used to build web applications. Here is an example of how to use the framework to create a simple component:
35
+
36
+ ```javascript
37
+ import { AppComponent } from '@ratiosolver/flick';
38
+
39
+ class MyApp extends AppComponent {
40
+
41
+ count = 0;
42
+ button = document.createElement('button');
43
+
44
+ constructor() {
45
+ super();
46
+ button.textContent = 'Click me';
47
+ button.onclick = () => this.increment();
48
+ this.element.appendChild(button);
49
+ }
50
+
51
+ increment() {
52
+ this.count++;
53
+ this.button.textContent = `Clicked ${this.count} times`;
54
+ }
55
+ }
56
+
57
+ const myApp = new MyApp();
58
+ ```
package/dist/app.d.ts ADDED
@@ -0,0 +1,158 @@
1
+ import { ConnectionListener } from "./utils/connection";
2
+ /**
3
+ * The `App` class implements the singleton pattern and manages the state and behavior of the application.
4
+ * It allows for the selection of components and notifies registered listeners of various events.
5
+ *
6
+ * @implements {AppListener}
7
+ */
8
+ export declare class App implements AppListener {
9
+ private static instance;
10
+ private selected_comp;
11
+ private app_listeners;
12
+ private constructor();
13
+ static get_instance(): App;
14
+ /**
15
+ * Display a toast message.
16
+ *
17
+ * @param {string} info The information to display.
18
+ */
19
+ toast(info: string): void;
20
+ /**
21
+ * Get the selected component.
22
+ *
23
+ * @returns {Component<any, HTMLElement> | null} The selected component.
24
+ */
25
+ get_selected_component(): Component<any, HTMLElement> | null;
26
+ /**
27
+ * Set the selected component.
28
+ *
29
+ * @param {Component<any, HTMLElement> | null} component The component to select.
30
+ */
31
+ selected_component(component: Component<any, HTMLElement> | null): void;
32
+ /**
33
+ * Add an application listener.
34
+ *
35
+ * @param {AppListener} listener The listener to add.
36
+ */
37
+ add_app_listener(listener: AppListener): void;
38
+ /**
39
+ * Remove an application listener.
40
+ *
41
+ * @param {AppListener} listener The listener to remove.
42
+ */
43
+ remove_app_listener(listener: AppListener): void;
44
+ }
45
+ /**
46
+ * The `AppListener` interface defines the methods that an object must implement to listen to application events.
47
+ */
48
+ export interface AppListener {
49
+ /**
50
+ * Request to display a toast message.
51
+ *
52
+ * @param {string} info The information to display.
53
+ */
54
+ toast(info: string): void;
55
+ /**
56
+ * Notification that a component has been selected.
57
+ *
58
+ * @param {Component<any, HTMLElement> | null} component The selected component.
59
+ */
60
+ selected_component(component: Component<any, HTMLElement> | null): void;
61
+ }
62
+ /**
63
+ * The `Component` class represents a component in the application.
64
+ * It manages the payload and element of the component and its children.
65
+ *
66
+ * @template P The type of the payload.
67
+ * @template E The type of the element.
68
+ */
69
+ export declare abstract class Component<P, E extends HTMLElement> {
70
+ payload: P;
71
+ element: E;
72
+ protected child_nodes: Set<Component<any, HTMLElement>>;
73
+ constructor(payload: P, element: E);
74
+ /**
75
+ * Add a child component.
76
+ *
77
+ * @param {Component<any, HTMLElement>} child The child component to add.
78
+ */
79
+ add_child(child: Component<any, HTMLElement>): void;
80
+ /**
81
+ * Remove a child component.
82
+ *
83
+ * @param {Component<any, HTMLElement>} child The child component to remove.
84
+ * @throws {Error} If the child is not found.
85
+ */
86
+ remove_child(child: Component<any, HTMLElement>): void;
87
+ /**
88
+ * Remove the component.
89
+ */
90
+ remove(): void;
91
+ /**
92
+ * Notify that the component has been mounted.
93
+ * Override this method to perform actions when the component is mounted.
94
+ */
95
+ mounted(): void;
96
+ /**
97
+ * Notify that the component is being unmounted.
98
+ * Override this method to perform actions when the component is being unmounted.
99
+ */
100
+ unmounting(): void;
101
+ }
102
+ /**
103
+ * The `ListComponent` class represents a list component in the application.
104
+ * It manages the payload and element of the list component and its children.
105
+ *
106
+ * @template P The type of the payload.
107
+ * @template E The type of the element.
108
+ * @template L The type of the list element.
109
+ */
110
+ export declare abstract class ListComponent<P, E extends HTMLElement, L extends HTMLElement> extends Component<Component<P, E>[], L> {
111
+ compareFn: (a: P, b: P) => number;
112
+ children: Component<P, E>[];
113
+ constructor(payload: Component<P, E>[], element: L, compareFn?: (a: P, b: P) => number);
114
+ add_child(child: Component<P, E>): void;
115
+ remove_child(child: Component<P, E>): void;
116
+ }
117
+ /**
118
+ * The `AppComponent` class represents the main application component.
119
+ * It manages the application element and listens to application and connection events.
120
+ */
121
+ export declare class AppComponent extends Component<App, HTMLDivElement> implements AppListener, ConnectionListener {
122
+ constructor();
123
+ toast(info: string): void;
124
+ selected_component(component: Component<any, HTMLElement> | null): void;
125
+ connected(_info: any): void;
126
+ received_message(_message: any): void;
127
+ disconnected(): void;
128
+ connection_error(_error: any): void;
129
+ populate_navbar(_container: HTMLDivElement): void;
130
+ unmounting(): void;
131
+ }
132
+ /**
133
+ * The `AnchorComponent` class represents an anchor component in the application.
134
+ * It manages the payload and element of the anchor component.
135
+ *
136
+ * @template P The type of the payload.
137
+ */
138
+ export declare class AnchorComponent<P> extends Component<P, HTMLAnchorElement> {
139
+ constructor(payload: P);
140
+ }
141
+ /**
142
+ * The `ButtonComponent` class represents a button component in the application.
143
+ * It manages the payload and element of the button component.
144
+ *
145
+ * @template P The type of the payload.
146
+ */
147
+ export declare class ButtonComponent<P> extends Component<P, HTMLButtonElement> {
148
+ constructor(payload: P);
149
+ }
150
+ /**
151
+ * The `DivComponent` class represents a div component in the application.
152
+ * It manages the payload and element of the div component.
153
+ *
154
+ * @template P The type of the payload.
155
+ */
156
+ export declare class UListComponent<P> extends ListComponent<P, HTMLLIElement, HTMLUListElement> {
157
+ constructor(payload: Component<P, HTMLLIElement>[], compareFn?: (a: P, b: P) => number);
158
+ }
package/dist/app.js ADDED
@@ -0,0 +1,272 @@
1
+ import { Connection } from "./utils/connection";
2
+ /**
3
+ * The `App` class implements the singleton pattern and manages the state and behavior of the application.
4
+ * It allows for the selection of components and notifies registered listeners of various events.
5
+ *
6
+ * @implements {AppListener}
7
+ */
8
+ export class App {
9
+ constructor() {
10
+ this.selected_comp = null;
11
+ this.app_listeners = new Set();
12
+ }
13
+ static get_instance() {
14
+ if (!App.instance)
15
+ App.instance = new App();
16
+ return App.instance;
17
+ }
18
+ /**
19
+ * Display a toast message.
20
+ *
21
+ * @param {string} info The information to display.
22
+ */
23
+ toast(info) { for (const listener of this.app_listeners) {
24
+ listener.toast(info);
25
+ } }
26
+ /**
27
+ * Get the selected component.
28
+ *
29
+ * @returns {Component<any, HTMLElement> | null} The selected component.
30
+ */
31
+ get_selected_component() { return this.selected_comp; }
32
+ /**
33
+ * Set the selected component.
34
+ *
35
+ * @param {Component<any, HTMLElement> | null} component The component to select.
36
+ */
37
+ selected_component(component) {
38
+ if (this.selected_comp)
39
+ this.selected_comp.remove();
40
+ this.selected_comp = component;
41
+ for (const listener of this.app_listeners) {
42
+ listener.selected_component(component);
43
+ }
44
+ }
45
+ /**
46
+ * Add an application listener.
47
+ *
48
+ * @param {AppListener} listener The listener to add.
49
+ */
50
+ add_app_listener(listener) {
51
+ this.app_listeners.add(listener);
52
+ }
53
+ /**
54
+ * Remove an application listener.
55
+ *
56
+ * @param {AppListener} listener The listener to remove.
57
+ */
58
+ remove_app_listener(listener) {
59
+ this.app_listeners.delete(listener);
60
+ }
61
+ }
62
+ /**
63
+ * The `Component` class represents a component in the application.
64
+ * It manages the payload and element of the component and its children.
65
+ *
66
+ * @template P The type of the payload.
67
+ * @template E The type of the element.
68
+ */
69
+ export class Component {
70
+ constructor(payload, element) {
71
+ this.child_nodes = new Set(); // The children of the component
72
+ this.payload = payload;
73
+ this.element = element;
74
+ }
75
+ /**
76
+ * Add a child component.
77
+ *
78
+ * @param {Component<any, HTMLElement>} child The child component to add.
79
+ */
80
+ add_child(child) {
81
+ this.child_nodes.add(child);
82
+ this.element.appendChild(child.element);
83
+ child.mounted();
84
+ }
85
+ /**
86
+ * Remove a child component.
87
+ *
88
+ * @param {Component<any, HTMLElement>} child The child component to remove.
89
+ * @throws {Error} If the child is not found.
90
+ */
91
+ remove_child(child) {
92
+ if (this.child_nodes.has(child)) {
93
+ this.child_nodes.delete(child);
94
+ child.remove();
95
+ }
96
+ else
97
+ throw new Error('Child not found');
98
+ }
99
+ /**
100
+ * Remove the component.
101
+ */
102
+ remove() {
103
+ for (const child of this.child_nodes)
104
+ child.unmounting();
105
+ this.unmounting();
106
+ this.element.remove();
107
+ }
108
+ /**
109
+ * Notify that the component has been mounted.
110
+ * Override this method to perform actions when the component is mounted.
111
+ */
112
+ mounted() { }
113
+ /**
114
+ * Notify that the component is being unmounted.
115
+ * Override this method to perform actions when the component is being unmounted.
116
+ */
117
+ unmounting() { }
118
+ }
119
+ /**
120
+ * The `ListComponent` class represents a list component in the application.
121
+ * It manages the payload and element of the list component and its children.
122
+ *
123
+ * @template P The type of the payload.
124
+ * @template E The type of the element.
125
+ * @template L The type of the list element.
126
+ */
127
+ export class ListComponent extends Component {
128
+ constructor(payload, element, compareFn) {
129
+ super(payload, element);
130
+ this.children = []; // The children of the list component sorted by the comparison function
131
+ this.compareFn = compareFn || ((_a, _b) => 0);
132
+ this.children = payload;
133
+ this.children.sort((a, b) => this.compareFn(a.payload, b.payload));
134
+ const fragment = document.createDocumentFragment();
135
+ for (const child of this.children)
136
+ fragment.appendChild(child.element);
137
+ this.element.appendChild(fragment);
138
+ }
139
+ add_child(child) {
140
+ super.add_child(child);
141
+ this.children.push(child);
142
+ this.children.sort((a, b) => this.compareFn(a.payload, b.payload));
143
+ const index = this.children.indexOf(child);
144
+ if (index === this.children.length - 1)
145
+ this.element.appendChild(child.element);
146
+ else
147
+ this.element.insertBefore(child.element, this.children[index + 1].element);
148
+ }
149
+ remove_child(child) {
150
+ const index = this.children.indexOf(child);
151
+ if (index !== -1) {
152
+ this.children.splice(index, 1);
153
+ super.remove_child(child);
154
+ }
155
+ else
156
+ throw new Error('Child not found');
157
+ }
158
+ }
159
+ /**
160
+ * The `AppComponent` class represents the main application component.
161
+ * It manages the application element and listens to application and connection events.
162
+ */
163
+ export class AppComponent extends Component {
164
+ constructor() {
165
+ super(App.get_instance(), document.querySelector('#app'));
166
+ this.element.classList.add('d-flex', 'flex-column', 'h-100');
167
+ const fragment = document.createDocumentFragment();
168
+ // Add the Navbar..
169
+ const navbar = document.createElement('nav');
170
+ navbar.classList.add('navbar', 'navbar-expand-lg');
171
+ const nav_container = document.createElement('div');
172
+ nav_container.classList.add('container-fluid');
173
+ const toggler = document.createElement('button');
174
+ toggler.classList.add('navbar-toggler');
175
+ toggler.type = 'button';
176
+ toggler.setAttribute('data-bs-toggle', 'collapse');
177
+ toggler.setAttribute('data-bs-target', '#navbarNav');
178
+ toggler.setAttribute('aria-controls', 'navbarNav');
179
+ toggler.setAttribute('aria-expanded', 'false');
180
+ toggler.setAttribute('aria-label', 'Toggle navigation');
181
+ const toggler_span = document.createElement('span');
182
+ toggler_span.classList.add('navbar-toggler-icon');
183
+ toggler.appendChild(toggler_span);
184
+ nav_container.appendChild(toggler);
185
+ const navbar_collapse = document.createElement('div');
186
+ navbar_collapse.classList.add('collapse', 'navbar-collapse');
187
+ navbar_collapse.id = 'navbarNav';
188
+ this.populate_navbar(navbar_collapse);
189
+ nav_container.appendChild(navbar_collapse);
190
+ navbar.appendChild(nav_container);
191
+ fragment.appendChild(navbar);
192
+ // Add the toast container..
193
+ const toast_container = document.createElement('div');
194
+ toast_container.classList.add('toast-container');
195
+ fragment.appendChild(toast_container);
196
+ this.element.appendChild(fragment);
197
+ App.get_instance().add_app_listener(this);
198
+ Connection.get_instance().add_connection_listener(this);
199
+ }
200
+ toast(info) {
201
+ const toast_container = this.element.querySelector('.toast-container');
202
+ const toast = document.createElement('div');
203
+ toast.classList.add('toast');
204
+ toast.setAttribute('role', 'alert');
205
+ toast.setAttribute('aria-live', 'assertive');
206
+ toast.setAttribute('aria-atomic', 'true');
207
+ toast.setAttribute('data-bs-autohide', 'true');
208
+ toast.setAttribute('data-bs-delay', '5000');
209
+ const toast_header = document.createElement('div');
210
+ toast_header.classList.add('toast-header');
211
+ const toast_title = document.createElement('strong');
212
+ toast_title.classList.add('me-auto');
213
+ toast_title.innerText = 'Info';
214
+ toast_header.appendChild(toast_title);
215
+ const toast_button = document.createElement('button');
216
+ toast_button.classList.add('btn-close');
217
+ toast_button.setAttribute('type', 'button');
218
+ toast_button.setAttribute('data-bs-dismiss', 'toast');
219
+ toast_button.setAttribute('aria-label', 'Close');
220
+ toast_header.appendChild(toast_button);
221
+ toast.appendChild(toast_header);
222
+ const toast_body = document.createElement('div');
223
+ toast_body.classList.add('toast-body');
224
+ toast_body.innerText = info;
225
+ toast.appendChild(toast_body);
226
+ toast_container.appendChild(toast);
227
+ setTimeout(() => toast.remove(), 5000);
228
+ }
229
+ selected_component(component) {
230
+ if (component)
231
+ this.add_child(component);
232
+ }
233
+ connected(_info) { }
234
+ received_message(_message) { }
235
+ disconnected() { }
236
+ connection_error(_error) { }
237
+ populate_navbar(_container) { }
238
+ unmounting() {
239
+ App.get_instance().remove_app_listener(this);
240
+ Connection.get_instance().remove_connection_listener(this);
241
+ }
242
+ }
243
+ /**
244
+ * The `AnchorComponent` class represents an anchor component in the application.
245
+ * It manages the payload and element of the anchor component.
246
+ *
247
+ * @template P The type of the payload.
248
+ */
249
+ export class AnchorComponent extends Component {
250
+ constructor(payload) { super(payload, document.createElement('a')); }
251
+ }
252
+ /**
253
+ * The `ButtonComponent` class represents a button component in the application.
254
+ * It manages the payload and element of the button component.
255
+ *
256
+ * @template P The type of the payload.
257
+ */
258
+ export class ButtonComponent extends Component {
259
+ constructor(payload) { super(payload, document.createElement('button')); }
260
+ }
261
+ /**
262
+ * The `DivComponent` class represents a div component in the application.
263
+ * It manages the payload and element of the div component.
264
+ *
265
+ * @template P The type of the payload.
266
+ */
267
+ export class UListComponent extends ListComponent {
268
+ constructor(payload, compareFn) {
269
+ super(payload, document.createElement('ul'), compareFn);
270
+ }
271
+ }
272
+ //# sourceMappingURL=app.js.map