@lcsng/tools 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,29 @@
1
+ MIT License
2
+
3
+ <<<<<<< HEAD
4
+ <<<<<<< HEAD
5
+ Copyright (c) 2024 LCS by JCFuniverse
6
+ =======
7
+ Copyright (c) 2025 LCS by JCFuniverse
8
+ >>>>>>> 615b8077800d187746f9eada4bbab8ae7207ad25
9
+ =======
10
+ Copyright (c) 2025 LCS by JCFuniverse
11
+ >>>>>>> c843259ca400038abd018ad3ff0c8e1b5e3b373a
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,299 @@
1
+ # ๐Ÿ“ฆ LCS Tools (JavaScript Utilities)
2
+
3
+ **A powerful frontend JavaScript toolkit by [LCS](https://lcs.ng) โ€” utilities for building faster, cleaner, and more interactive web apps.**
4
+
5
+ LCS Tools is a collection of ready-to-use JavaScript tools designed to enhance UX in web apps. These utilities offer common UI enhancements such as OTP input handling, password visibility toggling, and geolocation with reverse geocoding โ€” all implemented in a lightweight, dependency-free manner.
6
+
7
+ ---
8
+
9
+ ## ๐ŸŒ Features
10
+
11
+ - โœ… Easy-to-use utility functions and classes
12
+ - ๐Ÿ› ๏ธ Tools for DOM handling, events, and user interaction
13
+ - ๐Ÿ“ Location detection
14
+ - ๐Ÿ“ค File upload helper (coming soon)
15
+ - ๐Ÿ” Password toggle
16
+ - ๐Ÿ”„ Lightweight and modular
17
+ - ๐Ÿงฉ Browser-friendly (`<script>`) or Node-compatible (`require` / `import`)
18
+ - ๐Ÿ”’ Obfuscated for production use via Webpack
19
+
20
+ ---
21
+
22
+ ## ๐Ÿ“ฆ Installation
23
+
24
+ ### CDN (Browser)
25
+
26
+ ```html
27
+ <script src="https://unpkg.com/lcs_tools@latest/dist/lt.min.js"></script>
28
+ <script>
29
+ // Access via global namespace
30
+ lcsTools.getCurrentLocation().then(console.log);
31
+ </script>
32
+ ```
33
+
34
+ > โœ… When using via CDN, all exports are available under the `lcsTools` global object.
35
+
36
+ ---
37
+
38
+ ### NPM (Node / Build Tools)
39
+
40
+ ```bash
41
+ npm install lcs_tools
42
+ ```
43
+
44
+ Then in your code:
45
+
46
+ ```js
47
+ // ESModule
48
+ import { getCurrentLocation } from 'lcs_tools';
49
+
50
+ // CommonJS
51
+ const { getCurrentLocation } = require('lcs_tools');
52
+ ```
53
+
54
+ ---
55
+
56
+ ## ๐Ÿš€ Usage Examples
57
+
58
+ ### ๐Ÿ“ `getCurrentLocation()`
59
+
60
+ Fetch the current browser location with graceful fallback:
61
+
62
+ ```js
63
+ lcsTools.getCurrentLocation()
64
+ .then((locationText) => {
65
+ console.log('Your location:', locationText);
66
+ })
67
+ .catch((err) => {
68
+ console.warn('Location error:', err);
69
+ });
70
+ ```
71
+
72
+ Returns a promise that resolves to:
73
+
74
+ ```plaintext
75
+ 12 Yemi Car Wash Off Freedom Way, Itedo, Lekki Phase I, Lagos State, Nigeria
76
+ ```
77
+
78
+ ---
79
+
80
+ ## ๐Ÿ”ข OTP Input Validation
81
+
82
+ **Purpose:**
83
+ Manages OTP (One-Time Password) inputs with seamless auto-focus and input aggregation.
84
+
85
+ **Features:**
86
+ - Supports digit-only input
87
+ - Automatically jumps to the next field on valid input
88
+ - Moves to the previous input field on backspace
89
+ - Aggregates all inputs into a hidden field for submission
90
+
91
+ **Expected HTML Structure:**
92
+ ```html
93
+ <div class="_otp_block">
94
+ <div class="_otp_inputs">
95
+ <input type="text" maxlength="1" />
96
+ <input type="text" maxlength="1" />
97
+ <input type="text" maxlength="1" />
98
+ <input type="text" maxlength="1" />
99
+ </div>
100
+ <input type="hidden" name="otp" />
101
+ </div>
102
+ ```
103
+
104
+ **Notes:**
105
+ - The final OTP string is automatically inserted into the hidden input field.
106
+
107
+ ---
108
+
109
+ ## ๐Ÿ” Password Visibility Toggle
110
+
111
+ **Purpose:**
112
+ Allows toggling of password fields between `text` and `password`, improving user experience during login or sign-up.
113
+
114
+ **Features:**
115
+ - Click to show/hide password
116
+ - Dynamically changes the toggle button text (`Show` / `Hide`)
117
+
118
+ **Expected HTML Structure:**
119
+ ```html
120
+ <div class="_form_password_wrapper">
121
+ <input type="password" class="_password_input" />
122
+ <button type="button" class="_show_hide_password">Show</button>
123
+ </div>
124
+ ```
125
+
126
+ **Notes:**
127
+ - The button label updates automatically.
128
+ - Works on dynamically added elements too.
129
+
130
+ ---
131
+
132
+ ## ๐Ÿ“ Geolocation + Reverse Geocoding
133
+
134
+ **Purpose:**
135
+ Fetches the user's current location, converts it to a human-readable address using OpenStreetMapโ€™s **Nominatim API**, and inserts it into a specified field.
136
+
137
+ **Key Features:**
138
+ - Fully custom modal alert for user interaction
139
+ - Geolocation permission awareness
140
+ - Reverse geocoding to address string
141
+ - Compatible with both `input` fields and `contentEditable` elements
142
+ - Input fallback on failure
143
+
144
+ **Expected HTML Structure:**
145
+ ```html
146
+ <input type="text" id="locationInput" placeholder="Your location will appear here">
147
+ <button class="lcsGetCurrentLocation" data-get_value="locationInput">Get Location</button>
148
+ ```
149
+
150
+ **Usage Flow:**
151
+ 1. User clicks the button with class `lcsGetCurrentLocation`.
152
+ 2. A custom modal appears asking for permission (if required).
153
+ 3. On approval, the location is fetched and resolved to a readable address.
154
+ 4. The address is inserted into the targeted input or editable field.
155
+
156
+ **Permissions Handling:**
157
+ - Detects if permission is already granted, denied, or needs to be asked.
158
+ - Displays custom prompts accordingly.
159
+
160
+ **APIs Used:**
161
+ - `navigator.geolocation` for coordinates
162
+ - OpenStreetMap's [Nominatim Reverse Geocoding API](https://nominatim.openstreetmap.org/) for address resolution
163
+
164
+ **Failure Scenarios:**
165
+ - Geolocation unsupported
166
+ - Permission denied or dismissed
167
+ - No internet connection
168
+ - Input field target not found
169
+
170
+ **Fallback:**
171
+ If the address can't be fetched, the input is reset to its previous value.
172
+
173
+ ---
174
+
175
+ ## ๐Ÿ’ก Best Practices
176
+
177
+ - Make sure each tool is wrapped in appropriate HTML structure.
178
+ - These tools rely on event delegation, so dynamic elements are supported out of the box.
179
+ - Use minimal styling overrides to ensure visual consistency if customizing the modals.
180
+
181
+ ---
182
+
183
+ ## ๐Ÿงฉ Integration Example
184
+ ```html
185
+ <!-- OTP -->
186
+ <div class="_otp_block">
187
+ <div class="_otp_inputs">
188
+ <input type="text" maxlength="1">
189
+ <input type="text" maxlength="1">
190
+ <input type="text" maxlength="1">
191
+ <input type="text" maxlength="1">
192
+ </div>
193
+ <input type="hidden" name="otp">
194
+ </div>
195
+
196
+ <!-- Password -->
197
+ <div class="_form_password_wrapper">
198
+ <input type="password" class="_password_input" />
199
+ <button class="_show_hide_password">Show</button>
200
+ </div>
201
+
202
+ <!-- Location -->
203
+ <input type="text" id="locationInput">
204
+ <button class="lcsGetCurrentLocation" data-get_value="locationInput">Get Location</button>
205
+ ```
206
+
207
+ ### ๐Ÿ“ค `lcsUploadFile(...)` _(coming soon)_
208
+
209
+ Will support file upload with:
210
+ - progress tracking
211
+ - size/format validations
212
+ - server endpoint options
213
+
214
+ Stay tuned.
215
+
216
+ ---
217
+
218
+ ## ๐Ÿ“ Project Structure
219
+
220
+ ```
221
+ lcs_tools/
222
+ โ”œโ”€โ”€ dist/ # Bundled, obfuscated output
223
+ โ”‚ โ””โ”€โ”€ lt.min.js
224
+ โ”œโ”€โ”€ src/ # Source modules
225
+ โ”‚ โ”œโ”€โ”€ index.js # Main export entry
226
+ โ”‚ โ”œโ”€โ”€ location.js # Location utility
227
+ โ”‚ โ”œโ”€โ”€ password.js # Password toggle
228
+ โ”‚ โ””โ”€โ”€ ...more coming
229
+ โ”œโ”€โ”€ webpack.config.js # Build + Obfuscation
230
+ โ”œโ”€โ”€ jsdoc.json # Auto documentation
231
+ โ”œโ”€โ”€ package.json
232
+ โ””โ”€โ”€ README.md
233
+ ```
234
+
235
+ ---
236
+
237
+ ## ๐Ÿง‘โ€๐Ÿ’ป Contributing
238
+
239
+ Want to add a utility or improve one?
240
+
241
+ ```bash
242
+ git clone https://github.com/lcsnigeria/lcs_tools.git
243
+ cd lcs_tools
244
+ npm install
245
+ npm run build
246
+ ```
247
+
248
+ All source files live in `/src`. Just export any new functions or classes from `index.js` to include them in the final build.
249
+
250
+ > โœ… Contributions should be modular and documented using JSDoc comments.
251
+
252
+ ---
253
+
254
+ ## ๐Ÿ“„ Documentation
255
+
256
+ Auto-generated from source using `JSDoc`. Build with:
257
+
258
+ ```bash
259
+ npm run build
260
+ ```
261
+
262
+ This will generate the HTML docs in a `docs/` folder (optionally host via GitHub Pages later).
263
+
264
+ ---
265
+
266
+ ## ๐Ÿ“ˆ Versioning
267
+
268
+ Versioned using [standard-version](https://github.com/conventional-changelog/standard-version):
269
+
270
+ ```bash
271
+ npm run release
272
+ ```
273
+
274
+ This will:
275
+ - Bump the version (based on commit types)
276
+ - Tag the commit
277
+ - Generate a changelog
278
+ - Push and publish the release
279
+
280
+ ---
281
+
282
+ ## ๐Ÿ“ƒ License
283
+
284
+ MIT License
285
+
286
+ ---
287
+
288
+ ## ๐Ÿ‘จโ€๐Ÿ’ป Author
289
+ **Chinonso Frewen Justice** โ€” [JCFuniverse](https://lcs.ng/jcfuniverse)
290
+ Founder & CEO, Loaded Channel Solutions (LCS)
291
+ ยฉ 2025 - ๐ŸŒ [https://lcs.ng](https://lcs.ng) | ๐Ÿ“ง justicefrewen@gmail.com
292
+
293
+ ---
294
+
295
+ ## ๐Ÿ”— Links
296
+
297
+ - ๐Ÿงฐ GitHub Repo: [lcsnigeria/lcs_tools](https://github.com/lcsnigeria/lcs_tools)
298
+ - ๐Ÿงช NPM Package: [npmjs.com/package/lcs_tools](https://www.npmjs.com/package/lcs_tools)
299
+ - ๐Ÿ“š Docs: _Coming soon..._