@benqoder/beam 0.4.0 → 0.4.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/README.md CHANGED
@@ -410,7 +410,7 @@ return ctx.drawer(render(<MyDrawer />), { position: 'left', size: 'medium' })
410
410
  | `beam-watch-if` | Condition that must be true to trigger | `beam-watch-if="value.length >= 3"` |
411
411
  | `beam-cast` | Cast input value: `number`, `integer`, `boolean`, `trim` | `beam-cast="number"` |
412
412
  | `beam-loading-class` | Add class to input while request is in progress | `beam-loading-class="loading"` |
413
- | `beam-keep` | Preserve input focus and cursor position after morph | `beam-keep` |
413
+ | `beam-keep` | Prevent element from being morphed during updates | `beam-keep` |
414
414
 
415
415
  ### Dirty Form Tracking
416
416
 
@@ -783,9 +783,9 @@ Add a class to the input while the request is in progress:
783
783
  </style>
784
784
  ```
785
785
 
786
- ### Preserving Focus
786
+ ### Preventing Element Replacement
787
787
 
788
- Use `beam-keep` to preserve focus and cursor position after the response morphs the DOM:
788
+ Use `beam-keep` to prevent an element from being morphed/replaced during updates. This keeps the element exactly as-is, preserving its state (focus, value, etc.):
789
789
 
790
790
  ```html
791
791
  <input
@@ -797,6 +797,8 @@ Use `beam-keep` to preserve focus and cursor position after the response morphs
797
797
  />
798
798
  ```
799
799
 
800
+ Since the input isn't replaced, focus and cursor position are naturally preserved.
801
+
800
802
  ### Auto-Save on Blur
801
803
 
802
804
  Trigger action when the user leaves the field:
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,KAAK,OAAO,EAAE,MAAM,SAAS,CAAA;AA8B9D,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI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not "change" (blur) events
1844
- const shouldRestoreFocus = htmlEl.hasAttribute('beam-keep') && eventType === 'input';
1845
- const activeElement = document.activeElement;
1846
1843
  // Add loading class if specified
1847
1844
  if (loadingClass)
1848
1845
  htmlEl.classList.add(loadingClass);
@@ -1891,19 +1888,6 @@ function setupInputWatcher(el) {
1891
1888
  if (response.script) {
1892
1889
  executeScript(response.script);
1893
1890
  }
1894
- // Restore focus if beam-keep is set and this was an input event (not change/blur)
1895
- if (shouldRestoreFocus && activeElement instanceof HTMLElement) {
1896
- const newEl = document.querySelector(`[name="${name}"]`);
1897
- if (newEl && newEl !== activeElement) {
1898
- newEl.focus();
1899
- if (newEl instanceof HTMLInputElement || newEl instanceof HTMLTextAreaElement) {
1900
- const cursorPos = activeElement.selectionStart;
1901
- if (cursorPos !== null) {
1902
- newEl.setSelectionRange(cursorPos, cursorPos);
1903
- }
1904
- }
1905
- }
1906
- }
1907
1891
  }
1908
1892
  catch (err) {
1909
1893
  console.error('Input watcher error:', err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@benqoder/beam",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org",