fvn-ui 0.1.0-alpha.39 → 0.1.0-alpha.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fvn-ui",
3
- "version": "0.1.0-alpha.39",
3
+ "version": "0.1.0-alpha.40",
4
4
  "description": "Minimalist vanilla JS component library",
5
5
  "type": "module",
6
6
  "sideEffects": [
package/src/fvn-ui/LLM.md CHANGED
@@ -17,17 +17,15 @@ selectComponent({ onChange: (value, item, event) => console.log(value, item) })
17
17
  tabs({ onChange: (value, item, event) => console.log(value, item) })
18
18
  collapsible({ onChange: (isOpen, event) => console.log(isOpen) })
19
19
  toggle({ onChange: (checked, event) => console.log(checked) })
20
+ editable({ onInput: (html, event) => console.log(html, event.target.textContent) })
20
21
 
21
22
  // `this` is bound to the element
22
23
  input({ onInput(value) { console.log(this.id, value) } })
23
24
  ```
24
25
 
25
- **Special cases with object payloads:**
26
+ **Special case - draggable uses object payload:**
26
27
  ```js
27
- // editable - passes object with all context
28
- editable({ onChange: ({ value, html, element, event }) => ... })
29
-
30
- // draggable - passes reorder info
28
+ // draggable - passes reorder info (no event)
31
29
  draggable({ onChange: ({ items, from, to }) => ... })
32
30
  ```
33
31
 
@@ -14,12 +14,12 @@ const bem = bemFactory('editable');
14
14
  * @param {number} [config.rows] - 1 = single line, > 1 = multiline (sets min-height)
15
15
  * @param {boolean} [config.multiline=true] - Allow multiple lines (false = single line)
16
16
  * @param {boolean} [config.plainText=false] - Strip formatting on paste
17
- * @param {Function} [config.onChange] - Called on input with { value, html, element }
18
- * @param {Function} [config.onInput] - Called on every input event
19
- * @param {Function} [config.onFocus] - Called on focus
20
- * @param {Function} [config.onBlur] - Called on blur
21
- * @param {Function} [config.onKeydown] - Called on keydown
22
- * @param {Function} [config.onSubmit] - Called on Enter key (single line mode)
17
+ * @param {Function} [config.onChange] - Called on input with (html, event) - use e.target.textContent for text
18
+ * @param {Function} [config.onInput] - Called on every input with (html, event)
19
+ * @param {Function} [config.onFocus] - Called on focus with (event)
20
+ * @param {Function} [config.onBlur] - Called on blur with (html, event)
21
+ * @param {Function} [config.onKeydown] - Called on keydown with (event)
22
+ * @param {Function} [config.onSubmit] - Called on Enter key with (html, event) - single line mode only
23
23
  * @param {string} [config.id] - Registers to dom.editable[id] and dom[id]
24
24
  * @returns {HTMLDivElement} Wrapper with .value getter/setter for text content
25
25
  * @example
@@ -73,9 +73,9 @@ export function editable(...args) {
73
73
 
74
74
  const handleInput = (e) => {
75
75
  normalizeContent();
76
- const payload = { value: getValue(), html: getHtml(), element: editableEl, event: e };
77
- onInput?.call(editableEl, payload);
78
- onChange?.call(editableEl, payload);
76
+ const html = getHtml();
77
+ onInput?.call(editableEl, html, e);
78
+ onChange?.call(editableEl, html, e);
79
79
  };
80
80
 
81
81
  const handleKeydown = (e) => {
@@ -84,7 +84,7 @@ export function editable(...args) {
84
84
  // Single line: prevent Enter from creating new lines
85
85
  if (isSingleLine && e.key === 'Enter') {
86
86
  e.preventDefault();
87
- onSubmit?.call(editableEl, { value: getValue(), html: getHtml(), element: editableEl, event: e });
87
+ onSubmit?.call(editableEl, getHtml(), e);
88
88
  }
89
89
  };
90
90
 
@@ -117,7 +117,7 @@ export function editable(...args) {
117
117
 
118
118
  const handleBlur = (e) => {
119
119
  normalizeContent();
120
- onBlur?.call(editableEl, { value: getValue(), html: getHtml(), element: editableEl, event: e });
120
+ onBlur?.call(editableEl, getHtml(), e);
121
121
  };
122
122
 
123
123
  const editableDiv = el('div', {