Skip to content

Commit 98cdba5

Browse files
committed
Chore: Changelog
1 parent a016904 commit 98cdba5

File tree

3 files changed

+68
-6
lines changed

3 files changed

+68
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Please note after `1.0` Semver will be followed using normal protocols.
1717

1818
## Features
1919
* **Utils** - Clone now has a new setting `preserveDOM` which will not clone DOM nodes if present. This can be useful in scenarios where you want to clone an object with references to the live DOM you want to maintain
20+
* **Utils** - Added `log()` function for flexible logging with formatting, namespacing, timestamps, and JSON output support
21+
* **Utils** - Renamed `errors.js` module to `debug.js` to better reflect its logging and debugging capabilities
2022

2123
## Breaking Changes
2224
* **Utils** - `deepExtend` now preserves non clonables by default. This is to prevent very common scenarios where extend is used with custom classes or dom elements where the original reference should be maintained. Note this still can be overwritten using `deepExtend(obj1, obj2, { preserveNonCloneable: false });`

ai/packages/query.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ The Query class provides a comprehensive set of methods organized into logical c
174174
- `clippingParent()` - Get element that clips visual bounds
175175
- `containingParent()` - Get simple containing parent (offsetParent)
176176
- `positioningParent(options)` - Get accurate positioning context parent
177+
- `scrollParent(options)` - Get nearest scrollable container or all scroll parents in hierarchy
177178

178179
### Visibility and Display
179180
- `show(options)` - Show hidden elements using natural display value
@@ -951,6 +952,40 @@ function positionTooltip($tooltip, $trigger) {
951952
$tooltip.css({ top: `${top}px`, left: `${left}px` });
952953
}
953954

955+
// Position tooltip within scrollable container
956+
function positionTooltipInScroller($tooltip, $trigger) {
957+
const $scrollContainer = $trigger.scrollParent();
958+
959+
if ($scrollContainer[0] !== window) {
960+
// Element is within a scrollable container
961+
const scrollBounds = $scrollContainer.bounds();
962+
const triggerPos = $trigger.position({ relativeTo: $scrollContainer });
963+
964+
// Position tooltip within scroll container bounds
965+
$tooltip.css({
966+
position: 'absolute',
967+
top: triggerPos.top + $trigger.height() + 5,
968+
left: Math.min(triggerPos.left, scrollBounds.width - $tooltip.width())
969+
});
970+
971+
// Append to scroll container to inherit scrolling
972+
$scrollContainer.append($tooltip);
973+
} else {
974+
// Use viewport positioning
975+
positionTooltip($tooltip, $trigger);
976+
}
977+
}
978+
979+
// Handle scroll events on appropriate containers
980+
function setupScrollAwareTooltip($trigger, $tooltip) {
981+
const $allScrollers = $trigger.scrollParent({ all: true });
982+
983+
$allScrollers.on('scroll', () => {
984+
// Hide tooltip when any parent scrolls
985+
$tooltip.hide();
986+
});
987+
}
988+
954989
// Relative positioning for connected elements
955990
$('#draggable').on('drag', (event) => {
956991
// Position connected indicator relative to draggable

ai/packages/utils.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The package is organized into **17 specialized modules**, each focused on a spec
2626
├── crypto.js ← Hashing and ID generation
2727
├── equality.js ← Deep equality comparison
2828
├── cloning.js ← Deep cloning of objects and arrays
29-
├── errors.js ← Error handling and async error throwing
29+
├── debug.js ← Logging, debugging, and error handling
3030
├── environment.js ← Environment detection (server/client/dev/CI)
3131
└── regexp.js ← Regular expression and HTML escaping
3232
```
@@ -553,14 +553,39 @@ cloned.b.c = 99;
553553
console.log(obj1.b.c); // 2 (original unchanged)
554554
```
555555

556-
## Error Handling (errors.js)
556+
## Debug Utilities (debug.js)
557557

558-
### Error Management
558+
### Logging and Error Management
559559
```javascript
560-
import { fatal } from '@semantic-ui/utils';
560+
import { log, fatal } from '@semantic-ui/utils';
561561

562-
// Fatal error handling with custom messages
563-
fatal('Critical system error', { exit: true });
562+
// Flexible logging with levels and formatting
563+
log('Application started', 'info'); // Basic info log
564+
log('User action', 'debug', { // Debug with namespace
565+
namespace: 'UserService',
566+
data: [{ action: 'login', userId: 123 }]
567+
});
568+
569+
// JSON format for structured logging
570+
log('API response', 'info', { // Structured output
571+
format: 'json',
572+
namespace: 'ApiClient',
573+
timestamp: true,
574+
data: [{ status: 200, endpoint: '/api/users' }]
575+
});
576+
577+
// Custom styling and colors
578+
log('Important notice', 'warn', { // Custom title styling
579+
title: 'SYSTEM',
580+
titleColor: '#FF6B35',
581+
timestamp: true
582+
});
583+
584+
// Fatal error handling with metadata
585+
fatal('Critical system error', { // Async error throwing
586+
errorType: TypeError,
587+
metadata: { code: 'SYS_ERROR' }
588+
});
564589
```
565590

566591
## Iteration Utilities (looping.js)

0 commit comments

Comments
 (0)