@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 +29 -0
- package/README.md +299 -0
- package/dist/lt.min.js +1 -0
- package/dist/lt.min.js.LICENSE.txt +1 -0
- package/dist/lt.min.js.br +0 -0
- package/dist/lt.min.js.gz +0 -0
- package/package.json +91 -0
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..._
|