cjm-fasthtml-token-selector 0.0.1__py3-none-any.whl → 0.0.2__py3-none-any.whl

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.
@@ -1 +1 @@
1
- __version__ = "0.0.1"
1
+ __version__ = "0.0.2"
@@ -124,21 +124,28 @@ def _generate_settle_handler_js(
124
124
  config:TokenSelectorConfig, # config for this instance
125
125
  ids:TokenSelectorHtmlIds, # HTML IDs
126
126
  ) -> str: # JS code fragment
127
- """Generate htmx:afterSettle handler for swap resilience."""
128
- guard = f"_tsMasterListener_{config.prefix}"
127
+ """Generate htmx:afterSettle handler for swap resilience.
128
+
129
+ Stores the handler reference globally and replaces it on
130
+ re-initialization to avoid stale closure references when
131
+ the IIFE re-runs after HTMX page transitions.
132
+ """
133
+ handler_key = f"_tsSettleHandler_{config.prefix}"
129
134
  return f"""
130
135
  // HTMX afterSettle: re-read word count and update display
131
- if (!window['{guard}']) {{
132
- window['{guard}'] = true;
133
- document.body.addEventListener('htmx:afterSettle', function() {{
134
- var grid = document.getElementById('{ids.token_grid}');
135
- if (grid && ns.active) {{
136
- ns.wordCount = parseInt(grid.dataset.wordCount) || 0;
137
- ns.updateDisplay();
138
- ns.updateInputs();
139
- }}
140
- }});
136
+ // Replace old handler to avoid stale closure references
137
+ if (window['{handler_key}']) {{
138
+ document.body.removeEventListener('htmx:afterSettle', window['{handler_key}']);
141
139
  }}
140
+ window['{handler_key}'] = function() {{
141
+ var grid = document.getElementById('{ids.token_grid}');
142
+ if (grid && ns.active) {{
143
+ ns.wordCount = parseInt(grid.dataset.wordCount) || 0;
144
+ ns.updateDisplay();
145
+ ns.updateInputs();
146
+ }}
147
+ }};
148
+ document.body.addEventListener('htmx:afterSettle', window['{handler_key}']);
142
149
  """
143
150
 
144
151
  # %% ../../nbs/js/core.ipynb #48c0e44b
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cjm-fasthtml-token-selector
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: A token-level interactive text selector for FastHTML with gap, word, and span selection modes, custom key repeat navigation, and HTMX state sync.
5
5
  Home-page: https://github.com/cj-mills/cjm-fasthtml-token-selector
6
6
  Author: Christian J. Mills
@@ -87,24 +87,24 @@ graph LR
87
87
 
88
88
  components_inputs --> core_models
89
89
  components_inputs --> core_html_ids
90
- components_tokens --> core_models
91
90
  components_tokens --> core_constants
91
+ components_tokens --> core_models
92
92
  components_tokens --> core_config
93
93
  components_tokens --> core_html_ids
94
94
  components_tokens --> helpers_tokenizer
95
95
  core_config --> core_constants
96
96
  helpers_tokenizer --> core_models
97
+ js_core --> js_display
97
98
  js_core --> core_models
98
- js_core --> js_repeat
99
99
  js_core --> core_html_ids
100
100
  js_core --> core_config
101
+ js_core --> js_repeat
101
102
  js_core --> js_navigation
102
- js_core --> js_display
103
103
  js_display --> core_constants
104
104
  js_display --> core_html_ids
105
105
  js_display --> core_config
106
- js_navigation --> core_html_ids
107
106
  js_navigation --> core_config
107
+ js_navigation --> core_html_ids
108
108
  js_repeat --> core_config
109
109
  keyboard_actions --> core_html_ids
110
110
  keyboard_actions --> core_config
@@ -335,7 +335,13 @@ def _generate_settle_handler_js(
335
335
  config:TokenSelectorConfig, # config for this instance
336
336
  ids:TokenSelectorHtmlIds, # HTML IDs
337
337
  ) -> str: # JS code fragment
338
- "Generate htmx:afterSettle handler for swap resilience."
338
+ """
339
+ Generate htmx:afterSettle handler for swap resilience.
340
+
341
+ Stores the handler reference globally and replaces it on
342
+ re-initialization to avoid stale closure references when
343
+ the IIFE re-runs after HTMX page transitions.
344
+ """
339
345
  ```
340
346
 
341
347
  ``` python
@@ -1,4 +1,4 @@
1
- cjm_fasthtml_token_selector/__init__.py,sha256=sXLh7g3KC4QCFxcZGBTpG2scR7hmmBsMjq6LqRptkRg,22
1
+ cjm_fasthtml_token_selector/__init__.py,sha256=QvlVh4JTl3JL7jQAja76yKtT-IvF4631ASjWY1wS6AQ,22
2
2
  cjm_fasthtml_token_selector/_modidx.py,sha256=cG1LtoCTGyiZtJ4tPAmfsojfoeUxd96Uw2LLm8zKyRk,17256
3
3
  cjm_fasthtml_token_selector/components/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  cjm_fasthtml_token_selector/components/inputs.py,sha256=AlXOGChMiCDJ8JpNZ-ELJ60c5NFtiJlr8gFe3uiV5tE,1622
@@ -11,21 +11,21 @@ cjm_fasthtml_token_selector/core/models.py,sha256=XrOG-dLMpN249oi9P5o6RKglJTnLbL
11
11
  cjm_fasthtml_token_selector/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  cjm_fasthtml_token_selector/helpers/tokenizer.py,sha256=kxjVARXtKGEeYwXEkeTLdFpdPNFia4fcT2tV3pZuBfc,2561
13
13
  cjm_fasthtml_token_selector/js/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- cjm_fasthtml_token_selector/js/core.py,sha256=zcSnxiE5ZZ6uIO7IsGAf4MHkqSVdLaExDTVPUuXPaT8,5956
14
+ cjm_fasthtml_token_selector/js/core.py,sha256=FOPcFKUDRIEBMexX6e1o4_94F-w507AYkBuTxdXRC9k,6282
15
15
  cjm_fasthtml_token_selector/js/display.py,sha256=uUHdC3DnSNvHF6zlJ2QJMRKhfC3uJ3TL_--Lj2Mb9hI,5124
16
16
  cjm_fasthtml_token_selector/js/navigation.py,sha256=htRV_ufZ0s0ioWD2z4MFOz_zLPPbVqu-7B8pxPVsuzE,6344
17
17
  cjm_fasthtml_token_selector/js/repeat.py,sha256=SYMYB_QDNzgs3_TFM0AfdPS_zKhkRP3q3iSgW1MgoH4,3622
18
18
  cjm_fasthtml_token_selector/keyboard/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  cjm_fasthtml_token_selector/keyboard/actions.py,sha256=SK02phw397SFQLvLgu7B68c3iX6TXODnGgUFg665EWE,5901
20
- cjm_fasthtml_token_selector-0.0.1.dist-info/licenses/LICENSE,sha256=xV8xoN4VOL0uw9X8RSs2IMuD_Ss_a9yAbtGNeBWZwnw,11337
20
+ cjm_fasthtml_token_selector-0.0.2.dist-info/licenses/LICENSE,sha256=xV8xoN4VOL0uw9X8RSs2IMuD_Ss_a9yAbtGNeBWZwnw,11337
21
21
  demos/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  demos/data.py,sha256=BhGetK74QwVhnw1x-mo_ttH9dcKLWiRW8ySYwW4yilk,495
23
23
  demos/gap.py,sha256=ukdyeCBOImS6wHFuRHmEKfnCLCTMS83HGT37iQPEA6E,3552
24
24
  demos/shared.py,sha256=icXmXs_EaDRS_1GDBw7ZdPLRU0pAWloR9-LHhDWHf08,5068
25
25
  demos/span.py,sha256=WWRY5fXoGAQsZDgp4eQKVi7Iw_mskk60a2pYQWVG-V4,3491
26
26
  demos/word.py,sha256=Cd8vrF7dCmlztAVduJiCBUENcr9MhCr0KSIWoNySrDw,3240
27
- cjm_fasthtml_token_selector-0.0.1.dist-info/METADATA,sha256=vdwzOiO4jvB980lpuiqNqOy_1orowp5IGlXt0OvRcKY,23384
28
- cjm_fasthtml_token_selector-0.0.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
29
- cjm_fasthtml_token_selector-0.0.1.dist-info/entry_points.txt,sha256=YdIjAcDkZy3Q-mQw8KdEKSSK0TeBPavcBQ4KC0rayOI,76
30
- cjm_fasthtml_token_selector-0.0.1.dist-info/top_level.txt,sha256=Uqc4VZr-zdRjqzX9EYn73rhfX5Q07-iDepEDttnNvac,34
31
- cjm_fasthtml_token_selector-0.0.1.dist-info/RECORD,,
27
+ cjm_fasthtml_token_selector-0.0.2.dist-info/METADATA,sha256=qME0HeFICl0nXFGvr2Vz82C4SjkMhVzndLo8Mrkz65M,23575
28
+ cjm_fasthtml_token_selector-0.0.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
29
+ cjm_fasthtml_token_selector-0.0.2.dist-info/entry_points.txt,sha256=YdIjAcDkZy3Q-mQw8KdEKSSK0TeBPavcBQ4KC0rayOI,76
30
+ cjm_fasthtml_token_selector-0.0.2.dist-info/top_level.txt,sha256=Uqc4VZr-zdRjqzX9EYn73rhfX5Q07-iDepEDttnNvac,34
31
+ cjm_fasthtml_token_selector-0.0.2.dist-info/RECORD,,