@lvce-editor/virtual-dom 7.5.0 → 8.1.0

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/dist/index.js CHANGED
@@ -472,6 +472,22 @@ const attachEvent = ($Node, eventMap, key, value, newEventMap) => {
472
472
  $Node.addEventListener(keyLower, wrapped, options);
473
473
  };
474
474
 
475
+ const STYLE_REGEX = /([^:;]+):\s*([^;]+)/g;
476
+ const KEBAB_CASE_REGEX = /-([a-z])/g;
477
+ const setStyle = ($Element, styleString) => {
478
+ if (typeof styleString !== 'string') {
479
+ return;
480
+ }
481
+ let match;
482
+ while ((match = STYLE_REGEX.exec(styleString)) !== null) {
483
+ const key = match[1].trim();
484
+ const value = match[2].trim();
485
+ // Convert kebab-case to camelCase for CSS properties with dashes
486
+ const camelCaseKey = key.replaceAll(KEBAB_CASE_REGEX, (_, char) => char.toUpperCase());
487
+ $Element.style[camelCaseKey] = value;
488
+ }
489
+ };
490
+
475
491
  const setProp = ($Element, key, value, eventMap, newEventMap) => {
476
492
  switch (key) {
477
493
  case 'ariaActivedescendant':
@@ -495,6 +511,9 @@ const setProp = ($Element, key, value, eventMap, newEventMap) => {
495
511
  $Element.removeAttribute('aria-owns');
496
512
  }
497
513
  break;
514
+ case 'childCount':
515
+ case 'type':
516
+ break;
498
517
  case 'height':
499
518
  case 'width':
500
519
  if ($Element instanceof HTMLImageElement) {
@@ -542,8 +561,10 @@ const setProp = ($Element, key, value, eventMap, newEventMap) => {
542
561
  case 'onFocusIn':
543
562
  case 'onFocusOut':
544
563
  case 'onInput':
564
+ case 'onKeydown':
545
565
  case 'onKeyDown':
546
566
  case 'onMouseDown':
567
+ case 'onMouseMove':
547
568
  case 'onMouseOut':
548
569
  case 'onMouseOver':
549
570
  case 'onPointerDown':
@@ -560,9 +581,7 @@ const setProp = ($Element, key, value, eventMap, newEventMap) => {
560
581
  attachEvent($Element, eventMap, eventName, value, newEventMap);
561
582
  break;
562
583
  case 'style':
563
- throw new Error('style property is not supported');
564
- case 'childCount':
565
- case 'type':
584
+ setStyle($Element, value);
566
585
  break;
567
586
  case 'translate':
568
587
  $Element.style[key] = value;
@@ -0,0 +1 @@
1
+ export declare const setStyle: ($Element: HTMLElement, styleString: string) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/virtual-dom",
3
- "version": "7.5.0",
3
+ "version": "8.1.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/virtual-dom.git"