@dooboostore/simple-web-component 1.0.23 → 1.0.24

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.
Files changed (78) hide show
  1. package/README.md +238 -44
  2. package/dist/cjs/decorators/applyNode.js +129 -34
  3. package/dist/cjs/decorators/applyNode.js.map +2 -2
  4. package/dist/cjs/decorators/attribute.js +21 -2
  5. package/dist/cjs/decorators/attribute.js.map +2 -2
  6. package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
  7. package/dist/cjs/decorators/classList.js +60 -17
  8. package/dist/cjs/decorators/classList.js.map +2 -2
  9. package/dist/cjs/decorators/query.js +77 -2
  10. package/dist/cjs/decorators/query.js.map +2 -2
  11. package/dist/cjs/decorators/queryAll.js +77 -2
  12. package/dist/cjs/decorators/queryAll.js.map +2 -2
  13. package/dist/cjs/decorators/setAttribute.js +4 -4
  14. package/dist/cjs/decorators/setAttribute.js.map +2 -2
  15. package/dist/cjs/decorators/style.js +46 -15
  16. package/dist/cjs/decorators/style.js.map +2 -2
  17. package/dist/cjs/index.js +4 -4
  18. package/dist/cjs/index.js.map +2 -2
  19. package/dist/cjs/utils/Utils.js +140 -1
  20. package/dist/cjs/utils/Utils.js.map +2 -2
  21. package/dist/esm/decorators/applyNode.js +129 -34
  22. package/dist/esm/decorators/applyNode.js.map +2 -2
  23. package/dist/esm/decorators/attribute.js +21 -2
  24. package/dist/esm/decorators/attribute.js.map +2 -2
  25. package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
  26. package/dist/esm/decorators/classList.js +60 -17
  27. package/dist/esm/decorators/classList.js.map +2 -2
  28. package/dist/esm/decorators/query.js +77 -2
  29. package/dist/esm/decorators/query.js.map +2 -2
  30. package/dist/esm/decorators/queryAll.js +77 -2
  31. package/dist/esm/decorators/queryAll.js.map +2 -2
  32. package/dist/esm/decorators/setAttribute.js +4 -4
  33. package/dist/esm/decorators/setAttribute.js.map +2 -2
  34. package/dist/esm/decorators/style.js +46 -15
  35. package/dist/esm/decorators/style.js.map +2 -2
  36. package/dist/esm/index.js +4 -4
  37. package/dist/esm/index.js.map +2 -2
  38. package/dist/esm/utils/Utils.js +140 -1
  39. package/dist/esm/utils/Utils.js.map +2 -2
  40. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +542 -155
  41. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  42. package/dist/types/decorators/applyNode.d.ts +49 -27
  43. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  44. package/dist/types/decorators/attribute.d.ts +11 -4
  45. package/dist/types/decorators/attribute.d.ts.map +1 -1
  46. package/dist/types/decorators/classList.d.ts +15 -5
  47. package/dist/types/decorators/classList.d.ts.map +1 -1
  48. package/dist/types/decorators/query.d.ts +68 -4
  49. package/dist/types/decorators/query.d.ts.map +1 -1
  50. package/dist/types/decorators/queryAll.d.ts +70 -1
  51. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  52. package/dist/types/decorators/setAttribute.d.ts.map +1 -1
  53. package/dist/types/decorators/style.d.ts +17 -8
  54. package/dist/types/decorators/style.d.ts.map +1 -1
  55. package/dist/types/index.d.ts +1 -2
  56. package/dist/types/index.d.ts.map +1 -1
  57. package/dist/types/utils/Utils.d.ts +49 -0
  58. package/dist/types/utils/Utils.d.ts.map +1 -1
  59. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +542 -155
  60. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  61. package/package.json +3 -3
  62. package/src/decorators/applyNode.ts +179 -60
  63. package/src/decorators/attribute.ts +43 -10
  64. package/src/decorators/changedAttributeHost.ts +1 -1
  65. package/src/decorators/classList.ts +79 -17
  66. package/src/decorators/query.ts +147 -5
  67. package/src/decorators/queryAll.ts +148 -2
  68. package/src/decorators/setAttribute.ts +6 -5
  69. package/src/decorators/style.ts +67 -22
  70. package/src/index.ts +6 -6
  71. package/src/utils/Utils.ts +144 -0
  72. package/dist/cjs/utils/TemplateUtils.js +0 -109
  73. package/dist/cjs/utils/TemplateUtils.js.map +0 -7
  74. package/dist/esm/utils/TemplateUtils.js +0 -90
  75. package/dist/esm/utils/TemplateUtils.js.map +0 -7
  76. package/dist/types/utils/TemplateUtils.d.ts +0 -59
  77. package/dist/types/utils/TemplateUtils.d.ts.map +0 -1
  78. package/src/utils/TemplateUtils.ts +0 -92
package/README.md CHANGED
@@ -260,19 +260,26 @@ class StyledCard extends HTMLElement {
260
260
 
261
261
  ### Attribute & Property Decorators
262
262
 
263
- #### 10. `@attributeHost(name, options?)`
264
- Bidirectional attribute binding with automatic type conversion.
263
+ #### 10. `@attributeHost`
264
+ Bidirectional attribute binding with automatic type conversion on `:host` element.
265
+
266
+ All usage patterns support automatic field-name-to-attribute-name conversion:
267
+ - Without parentheses: `@attributeHost` - uses field name as attribute name
268
+ - Empty parentheses: `@attributeHost()` - uses field name as attribute name
269
+ - Options only: `@attributeHost({ connectedInitialize: true })` - uses field name as attribute name
270
+ - Custom name: `@attributeHost('custom-name')` - explicit attribute name
271
+ - Custom name + options: `@attributeHost('custom-name', { type: Boolean })` - both specified
265
272
 
266
273
  ```typescript
267
274
  @elementDefine('input-field')
268
275
  class InputField extends HTMLElement {
269
- @attributeHost('value', { connectedInitialize: true })
276
+ @attributeHost
270
277
  value: string = '';
271
278
 
272
279
  @attributeHost('disabled')
273
280
  disabled: boolean = false;
274
281
 
275
- @attributeHost('count')
282
+ @attributeHost({ type: Number })
276
283
  count: number = 0;
277
284
 
278
285
  @onConnectedInnerHtml
@@ -544,11 +551,54 @@ class TodoList extends HTMLElement {
544
551
  - Remove temporary overlays
545
552
  - Clean up modal dialogs
546
553
 
554
+ #### 15. `@queryHost` - Query :host Element
555
+ Specialized query for the component element itself. Supports automatic or explicit usage.
556
+
557
+ All usage patterns automatically set the element reference:
558
+ - Without parentheses: `@queryHost` self?: HTMLElement;
559
+ - Empty parentheses: `@queryHost()` self?: HTMLElement;
560
+ - With options: `@queryHost({ root: 'shadow' })` self?: HTMLElement;
561
+
562
+ ```typescript
563
+ @elementDefine('custom-card')
564
+ class CustomCard extends HTMLElement {
565
+ @queryHost
566
+ self?: HTMLElement;
567
+
568
+ @queryHost()
569
+ selfExplicit?: HTMLElement;
570
+
571
+ printTag() {
572
+ console.log(this.self?.tagName); // Logs: CUSTOM-CARD
573
+ }
574
+ }
575
+ ```
576
+
577
+ #### 16. `@queryAllHost` - Query All :host Children
578
+ Returns all children of the component element. Useful for accessing direct children.
579
+
580
+ All usage patterns automatically set the children array:
581
+ - Without parentheses: `@queryAllHost` children?: HTMLElement[];
582
+ - Empty parentheses: `@queryAllHost()` children?: HTMLElement[];
583
+ - With options: `@queryAllHost({ root: 'shadow' })` children?: HTMLElement[];
584
+
585
+ ```typescript
586
+ @elementDefine('card-container')
587
+ class CardContainer extends HTMLElement {
588
+ @queryAllHost
589
+ allChildren?: HTMLElement[];
590
+
591
+ getChildCount() {
592
+ return this.allChildren?.length ?? 0;
593
+ }
594
+ }
595
+ ```
596
+
547
597
  ---
548
598
 
549
599
  ### Event & Messaging Decorators
550
600
 
551
- #### 15. `@addEventListener(selector, event, options?)`
601
+ #### 17. `@addEventListener(selector, event, options?)`
552
602
  Declarative event binding with automatic delegation.
553
603
 
554
604
  ```typescript
@@ -605,7 +655,7 @@ class TodoApp extends HTMLElement {
605
655
  - ✅ Parent communication (`:parentHost`, `:appHost`)
606
656
  - ✅ Auto-cleanup on `disconnectedCallback`
607
657
 
608
- #### 16. `@emitCustomEvent(target, type, options?)`
658
+ #### 18. `@emitCustomEvent(target, type, options?)`
609
659
  Emit custom events to component hierarchy or global targets.
610
660
 
611
661
  ```typescript
@@ -683,40 +733,42 @@ class UserWidget extends HTMLElement {
683
733
 
684
734
  ### DOM Manipulation Decorators
685
735
 
686
- #### 17. `@applyNode(selector, options?)`
736
+ #### 19. `@applyNode(selector, options?)`
687
737
  Surgically add, update, or replace DOM nodes at specific positions.
688
738
 
689
739
  ```typescript
740
+ import { htmlDivElement, htmlFragment, htmlSpanElement } from '@dooboostore/simple-web-component';
741
+
690
742
  @elementDefine('counter-display')
691
743
  class CounterDisplay extends HTMLElement {
692
744
  private count = 0;
693
745
  private errorMessage = '';
694
746
 
695
- // Replace all children with new content
747
+ // Replace all children with new content (return Node)
696
748
  @applyNode('#display', { position: 'replaceChildren' })
697
749
  updateDisplayCount() {
698
- return `<span>${this.count}</span>`;
750
+ return htmlSpanElement(`${this.count}`);
699
751
  }
700
752
 
701
- // Append to container
753
+ // Append to container (return Node)
702
754
  @applyNode('#history', { position: 'beforeEnd' })
703
755
  addHistoryEntry() {
704
- return `<p>Count was: ${this.count}</p>`;
756
+ return htmlFragment(`<p>Count was: ${this.count}</p>`);
705
757
  }
706
758
 
707
- // Set HTML content
759
+ // Set HTML content (return string)
708
760
  @applyNode('#status', { position: 'innerHtml' })
709
761
  setStatus() {
710
762
  return `<strong>Status: Active</strong>`;
711
763
  }
712
764
 
713
- // Set text content
765
+ // Set text content (return string)
714
766
  @applyNode('#counter', { position: 'innerText' })
715
767
  updateCounter() {
716
768
  return this.count.toString();
717
769
  }
718
770
 
719
- // Remove element if condition is truthy
771
+ // Remove element if condition is truthy (return boolean)
720
772
  @applyNode('#error-banner', { position: 'remove' })
721
773
  dismissError() {
722
774
  return this.errorMessage === ''; // Remove if no error
@@ -759,34 +811,160 @@ Control which DOM tree is searched with the `root` option:
759
811
  Shorthand decorators for common position-specific operations:
760
812
 
761
813
  **Position-Specific Variants:**
814
+
815
+ Return **DOM Nodes** for position-based insertion. Use DOM creation functions:
816
+
762
817
  ```typescript
763
- @applyBeforeBeginNode('#target') prependTarget() { return `<div>Before</div>`; }
764
- @applyAfterBeginNode('#target') afterBeginTarget() { return `<div>After Begin</div>`; }
765
- @applyBeforeEndNode('#target') beforeEndTarget() { return `<div>Before End</div>`; }
766
- @applyAfterEndNode('#target') afterEndTarget() { return `<div>After</div>`; }
767
- @applyReplaceNode('#target') replaceTarget() { return `<div>Replaced</div>`; }
768
- @applyReplaceChildrenNode('#target') replaceChildrenTarget() { return `<div>New Children</div>`; }
769
- @applyInnerHtmlNode('#target') setInnerHtml() { return `<b>Bold</b>`; }
770
- @applyInnerTextNode('#target') setInnerText() { return 'Plain text'; }
771
- @applyRemoveNode('#target') removeTarget() { return true; }
818
+ import {
819
+ htmlFragment, htmlDivElement, htmlSpanElement,
820
+ createElement, textNode
821
+ } from '@dooboostore/simple-web-component';
822
+
823
+ @elementDefine('my-component')
824
+ class MyComponent extends HTMLElement {
825
+ // Method 1: Using htmlFragment (DocumentFragment)
826
+ @applyBeforeBeginNode('#target') prependTarget() {
827
+ return htmlFragment('<div>Before</div>');
828
+ }
829
+
830
+ // Method 2: Using htmlDivElement (single element)
831
+ @applyAfterBeginNode('#target') afterBeginTarget() {
832
+ return htmlDivElement('After Begin');
833
+ }
834
+
835
+ // Method 3: Manual createElement (full control)
836
+ @applyBeforeEndNode('#target') beforeEndTarget() {
837
+ return htmlDivElement('Before End');
838
+ }
839
+
840
+ @applyAfterEndNode('#target') afterEndTarget() {
841
+ const el = htmlDivElement('After');
842
+ el.classList.add('highlight');
843
+ return el;
844
+ }
845
+
846
+ @applyReplaceNode('#target') replaceTarget() {
847
+ return htmlFragment('<div class="replaced">Replaced</div>');
848
+ }
849
+
850
+ // Multiple nodes: return array
851
+ @applyReplaceChildrenNode('#target') replaceChildrenTarget() {
852
+ return [
853
+ htmlDivElement('Item 1'),
854
+ htmlDivElement('Item 2'),
855
+ htmlDivElement('Item 3')
856
+ ];
857
+ }
858
+
859
+ // String return for innerHtml
860
+ @applyInnerHtmlNode('#target') setInnerHtml() {
861
+ return `<b>Bold</b> <i>Italic</i>`;
862
+ }
863
+
864
+ // String return for innerText
865
+ @applyInnerTextNode('#target') setInnerText() {
866
+ return 'Plain text';
867
+ }
868
+
869
+ // Boolean return for remove
870
+ @applyRemoveNode('#target') removeTarget() {
871
+ return this.shouldHideTarget;
872
+ }
873
+ }
874
+ ```
875
+
876
+ **SSR Support (with custom Document):**
877
+
878
+ ```typescript
879
+ // Browser
880
+ return htmlDivElement('Content'); // Uses global document
881
+
882
+ // SSR (e.g. Node.js with jsdom)
883
+ const ssrDocument = new JSDOM().window.document;
884
+ return htmlDivElement('Content', ssrDocument); // Pass custom doc
772
885
  ```
773
886
 
774
887
  **Host-Targeted Variants (`:host` selector):**
888
+
889
+ All Host variants support three usage patterns:
890
+ - Without parentheses: `@applyBeforeBeginNodeHost` prependHost() { ... }
891
+ - With empty parentheses: `@applyBeforeBeginNodeHost()` prependHost() { ... }
892
+ - With options: `@applyBeforeBeginNodeHost({ ... })` prependHost() { ... }
893
+
775
894
  ```typescript
776
- @applyBeforeBeginNodeHost() prependHost() { return `<div>Before Host</div>`; }
777
- @applyAfterBeginNodeHost() afterBeginHost() { return `<div>After Begin</div>`; }
778
- @applyBeforeEndNodeHost() beforeEndHost() { return `<div>Before End</div>`; }
779
- @applyAfterEndNodeHost({ root: 'shadow' }) afterEndHost() { return `<div>After Host</div>`; }
780
- @applyReplaceNodeHost() replaceHost() { return `<div>Replaced Host</div>`; }
781
- @applyReplaceChildrenNodeHost() replaceChildrenHost() { return `<div>Shadow Children</div>`; }
782
- @applyInnerHtmlNodeHost() setHostInnerHtml() { return `<b>Host Content</b>`; }
783
- @applyInnerTextNodeHost() setHostInnerText() { return 'Host text'; }
784
- @applyRemoveNodeHost() removeHost() { return this.shouldRemove; }
895
+ @elementDefine('my-component')
896
+ class MyComponent extends HTMLElement {
897
+ @applyBeforeBeginNodeHost
898
+ prependHost() {
899
+ return htmlFragment('<div>Before Host</div>');
900
+ }
901
+
902
+ @applyAfterBeginNodeHost() afterBeginHost() {
903
+ return htmlSpanElement('After Begin');
904
+ }
905
+
906
+ @applyBeforeEndNodeHost beforeEndHost() {
907
+ const el = htmlDivElement('Before End');
908
+ return el;
909
+ }
910
+
911
+ @applyAfterEndNodeHost afterEndHost() {
912
+ return htmlFragment('After Host');
913
+ }
914
+
915
+ @applyReplaceNodeHost replaceHost() {
916
+ return htmlFragment('<div>Replaced Host</div>');
917
+ }
918
+
919
+ // Multiple children in shadow DOM
920
+ @applyReplaceChildrenNodeHost() replaceChildrenHost() {
921
+ return [
922
+ htmlDivElement('Shadow Child 1'),
923
+ htmlDivElement('Shadow Child 2')
924
+ ];
925
+ }
926
+
927
+ @applyInnerHtmlNodeHost setHostInnerHtml() {
928
+ return `<h1>Host Content</h1>`;
929
+ }
930
+
931
+ @applyInnerTextNodeHost() setHostInnerText() {
932
+ return 'Host text content';
933
+ }
934
+
935
+ @applyRemoveNodeHost removeHost() {
936
+ return this.isRemoved;
937
+ }
938
+ }
785
939
  ```
786
940
 
787
- ---
941
+ **Return Types by Position:**
942
+ - `beforeBegin`, `afterBegin`, `beforeEnd`, `afterEnd`: **Node | Node[]**
943
+ - `replace`: **Node**
944
+ - `replaceChildren`: **Node | Node[]**
945
+ - `innerHtml`: **string**
946
+ - `innerText`: **string**
947
+ - `remove`: **boolean** (truthy = remove)
948
+
949
+ **Available DOM Functions:**
950
+ - `htmlFragment(html, doc?)` - Create DocumentFragment from HTML
951
+ - `textNode(text, doc?)` - Create Text node
952
+ - `commentNode(comment, doc?)` - Create Comment node
953
+ - `createElement(tagName, options?, doc?)` - Create any element with attributes
954
+ - `htmlDivElement(html, doc?)` - Create div element
955
+ - `htmlSpanElement(html, doc?)` - Create span element
956
+ - `htmlButtonElement(html, doc?)` - Create button element
957
+ - `htmlAElement(html, href?, doc?)` - Create anchor element
958
+ - `htmlPElement(html, doc?)` - Create paragraph element
959
+ - `htmlLiElement(html, doc?)` - Create list item element
960
+ - `htmlUlElement(doc?)` - Create unordered list
961
+ - `htmlHeadingElement(level, html, doc?)` - Create h1-h6
962
+ - `htmlSectionElement(doc?)` - Create section
963
+ - `htmlArticleElement(doc?)` - Create article
788
964
 
789
- #### 18. `@setStyle(selector, options?)` / `@updateStyle(selector, options?)` / `@removeStyle(selector, options?)`
965
+ **All functions accept optional `doc` parameter for SSR support.**
966
+
967
+ #### 20. `@setStyle(selector, options?)` / `@updateStyle(selector, options?)` / `@removeStyle(selector, options?)`
790
968
 
791
969
  Manipulate CSS styles on elements with full Shadow DOM support.
792
970
 
@@ -839,18 +1017,26 @@ class StyledComponent extends HTMLElement {
839
1017
  ```
840
1018
 
841
1019
  **Host-Targeted Variants:**
1020
+
1021
+ Note: `:host` selector targets the component itself (boundary), so `root` option is ignored.
1022
+
1023
+ All Host variants support three usage patterns:
1024
+ - Without parentheses: `@setStyleHost` setHostStyle() { ... }
1025
+ - With empty parentheses: `@setStyleHost()` setHostStyle() { ... }
1026
+ - With options: `@setStyleHost({ ... })` setHostStyle() { ... }
1027
+
842
1028
  ```typescript
843
- @setStyleHost({ root: 'shadow' })
1029
+ @setStyleHost
844
1030
  setHostStyle() {
845
1031
  return { display: 'flex', gap: '10px' };
846
1032
  }
847
1033
 
848
- @updateStyleHost({ root: 'shadow' })
1034
+ @updateStyleHost()
849
1035
  updateHostStyle() {
850
1036
  return { backgroundColor: '#f0f0f0' };
851
1037
  }
852
1038
 
853
- @removeStyleHost({ root: 'shadow' })
1039
+ @removeStyleHost()
854
1040
  clearHostStyle() {
855
1041
  return ['backgroundColor'];
856
1042
  }
@@ -858,7 +1044,7 @@ clearHostStyle() {
858
1044
 
859
1045
  ---
860
1046
 
861
- #### 19. `@setClassList(selector, options?)` / `@addClassList(selector, options?)` / `@removeClassList(selector, options?)` / `@toggleClassList(selector, options?)` / `@updateClassList(selector, options?)`
1047
+ #### 21. `@setClassList(selector, options?)` / `@addClassList(selector, options?)` / `@removeClassList(selector, options?)` / `@toggleClassList(selector, options?)` / `@updateClassList(selector, options?)`
862
1048
 
863
1049
  Manipulate CSS classes on elements declaratively with Shadow DOM support.
864
1050
 
@@ -914,28 +1100,36 @@ class TabComponent extends HTMLElement {
914
1100
  ```
915
1101
 
916
1102
  **Host-Targeted Variants:**
1103
+
1104
+ Note: `:host` selector targets the component itself (boundary), so `root` option is ignored.
1105
+
1106
+ All Host variants support three usage patterns:
1107
+ - Without parentheses: `@setClassListHost` setHostClasses() { ... }
1108
+ - With empty parentheses: `@setClassListHost()` setHostClasses() { ... }
1109
+ - With options: `@setClassListHost({ ... })` setHostClasses() { ... }
1110
+
917
1111
  ```typescript
918
- @addClassListHost({ root: 'shadow' })
1112
+ @addClassListHost
919
1113
  addHostClasses() {
920
1114
  return ['component', 'interactive'];
921
1115
  }
922
1116
 
923
- @removeClassListHost({ root: 'shadow' })
1117
+ @removeClassListHost()
924
1118
  removeHostClasses() {
925
1119
  return ['loading'];
926
1120
  }
927
1121
 
928
- @toggleClassListHost({ root: 'shadow' })
1122
+ @toggleClassListHost()
929
1123
  toggleHostClass() {
930
1124
  return this.isOpen; // Apply 'open' class if true
931
1125
  }
932
1126
 
933
- @setClassListHost({ root: 'shadow' })
1127
+ @setClassListHost
934
1128
  setHostClasses() {
935
1129
  return this.isOpen ? ['open', 'expanded'] : ['closed'];
936
1130
  }
937
1131
 
938
- @updateClassListHost({ root: 'shadow' })
1132
+ @updateClassListHost()
939
1133
  updateHostClasses() {
940
1134
  return ['visible'];
941
1135
  }
@@ -945,7 +1139,7 @@ updateHostClasses() {
945
1139
 
946
1140
  ### Dependency Injection & Singleton
947
1141
 
948
- #### 20. `@Sim`
1142
+ #### 22. `@Sim`
949
1143
  Marks a class as a **Singleton** in the `<swc-app>` DI container for **constructor injection**.
950
1144
 
951
1145
  **Two DI Mechanisms:**
@@ -43,6 +43,7 @@ __export(applyNode_exports, {
43
43
  module.exports = __toCommonJS(applyNode_exports);
44
44
  var import_core = require("@dooboostore/core");
45
45
  var import_elementDefine = require("./elementDefine");
46
+ var import_Utils = require("../utils/Utils");
46
47
  const APPLY_NODE_METADATA_KEY = Symbol("simple-web-component:apply-node");
47
48
  const normalizeNodes = (res, doc) => {
48
49
  const items = Array.isArray(res) ? res : [res];
@@ -71,15 +72,20 @@ function applyNode(selector, options = { position: "beforeEnd" }) {
71
72
  const currentDoc = currentWin.document;
72
73
  const pos = options.position || "beforeEnd";
73
74
  const r = options.root || "auto";
74
- const getTargetRoot = () => {
75
+ const applyRoot = (t) => {
76
+ if (!t || !(t instanceof HTMLElement))
77
+ return t;
78
+ if (r === "auto")
79
+ return t.shadowRoot || t;
75
80
  if (r === "shadow")
76
- return this.shadowRoot;
81
+ return t.shadowRoot;
77
82
  if (r === "light")
78
- return this;
83
+ return t;
79
84
  if (r === "all")
80
- return this.shadowRoot || this;
81
- return this.shadowRoot || this;
85
+ return t.shadowRoot || t;
86
+ return t;
82
87
  };
88
+ const hostSet = import_Utils.SwcUtils.getHostSet(this);
83
89
  if (pos === "remove") {
84
90
  if (res) {
85
91
  if (selector === ":host" || !selector) {
@@ -89,7 +95,7 @@ function applyNode(selector, options = { position: "beforeEnd" }) {
89
95
  this.remove();
90
96
  }
91
97
  } else {
92
- const targetRoot = getTargetRoot();
98
+ const targetRoot = applyRoot(this);
93
99
  if (targetRoot) {
94
100
  const targets = targetRoot.querySelectorAll(selector);
95
101
  targets.forEach((el) => el.remove());
@@ -98,14 +104,22 @@ function applyNode(selector, options = { position: "beforeEnd" }) {
98
104
  }
99
105
  } else {
100
106
  let targetEl = null;
101
- if (selector === ":host" || !selector) {
102
- if (r === "shadow") {
103
- targetEl = this.shadowRoot;
104
- } else {
105
- targetEl = this;
106
- }
107
+ if (selector === ":host") {
108
+ targetEl = applyRoot(this);
109
+ } else if (selector === ":parentHost") {
110
+ targetEl = applyRoot(hostSet.$parentHost);
111
+ } else if (selector === ":appHost") {
112
+ targetEl = applyRoot(hostSet.$appHost);
113
+ } else if (selector === ":firstHost") {
114
+ targetEl = applyRoot(hostSet.$firstHost);
115
+ } else if (selector === ":lastHost") {
116
+ targetEl = applyRoot(hostSet.$lastHost);
117
+ } else if (selector === ":firstAppHost") {
118
+ targetEl = applyRoot(hostSet.$firstHost);
119
+ } else if (selector === ":lastAppHost") {
120
+ targetEl = applyRoot(hostSet.$lastAppHost);
107
121
  } else {
108
- const targetRoot = getTargetRoot();
122
+ const targetRoot = applyRoot(this);
109
123
  targetEl = targetRoot ? targetRoot.querySelector(selector) : null;
110
124
  }
111
125
  if (targetEl) {
@@ -150,25 +164,106 @@ const findAllApplyNodeMetadata = (target) => {
150
164
  });
151
165
  return result;
152
166
  };
153
- function applyNodeHost(options = { position: "beforeEnd" }) {
154
- return applyNode(":host", options);
155
- }
156
- const applyBeforeBeginNode = (selector, options = {}) => applyNode(selector, { ...options, position: "beforeBegin" });
157
- const applyAfterBeginNode = (selector, options = {}) => applyNode(selector, { ...options, position: "afterBegin" });
158
- const applyBeforeEndNode = (selector, options = {}) => applyNode(selector, { ...options, position: "beforeEnd" });
159
- const applyAfterEndNode = (selector, options = {}) => applyNode(selector, { ...options, position: "afterEnd" });
160
- const applyReplaceNode = (selector, options = {}) => applyNode(selector, { ...options, position: "replace" });
161
- const applyReplaceChildrenNode = (selector, options = {}) => applyNode(selector, { ...options, position: "replaceChildren" });
162
- const applyInnerHtmlNode = (selector, options = {}) => applyNode(selector, { ...options, position: "innerHtml" });
163
- const applyInnerTextNode = (selector, options = {}) => applyNode(selector, { ...options, position: "innerText" });
164
- const applyRemoveNode = (selector, options = {}) => applyNode(selector, { ...options, position: "remove" });
165
- const applyBeforeBeginNodeHost = (options = {}) => applyNode(":host", { ...options, position: "beforeBegin" });
166
- const applyAfterBeginNodeHost = (options = {}) => applyNode(":host", { ...options, position: "afterBegin" });
167
- const applyBeforeEndNodeHost = (options = {}) => applyNode(":host", { ...options, position: "beforeEnd" });
168
- const applyAfterEndNodeHost = (options = {}) => applyNode(":host", { ...options, position: "afterEnd" });
169
- const applyReplaceNodeHost = (options = {}) => applyNode(":host", { ...options, position: "replace" });
170
- const applyReplaceChildrenNodeHost = (options = {}) => applyNode(":host", { ...options, position: "replaceChildren" });
171
- const applyInnerHtmlNodeHost = (options = {}) => applyNode(":host", { ...options, position: "innerHtml" });
172
- const applyInnerTextNodeHost = (options = {}) => applyNode(":host", { ...options, position: "innerText" });
173
- const applyRemoveNodeHost = (options = {}) => applyNode(":host", { ...options, position: "remove" });
167
+ function applyNodeHost(targetOrOptions, propertyKey, descriptor) {
168
+ console.log("vvvvv");
169
+ if (propertyKey !== void 0 && typeof propertyKey === "string" || typeof propertyKey === "symbol") {
170
+ return applyNode(":host", { position: "beforeEnd" })(targetOrOptions, propertyKey, descriptor);
171
+ }
172
+ if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
173
+ const options = targetOrOptions;
174
+ return applyNode(":host", { ...options, position: options.position || "beforeEnd" });
175
+ } else {
176
+ return applyNode(":host", { position: "beforeEnd" });
177
+ }
178
+ }
179
+ function applyBeforeBeginNode(selector, options) {
180
+ return applyNode(selector, { ...options, position: "beforeBegin" });
181
+ }
182
+ function applyAfterBeginNode(selector, options) {
183
+ return applyNode(selector, { ...options, position: "afterBegin" });
184
+ }
185
+ function applyBeforeEndNode(selector, options) {
186
+ return applyNode(selector, { ...options, position: "beforeEnd" });
187
+ }
188
+ function applyAfterEndNode(selector, options) {
189
+ return applyNode(selector, { ...options, position: "afterEnd" });
190
+ }
191
+ function applyReplaceNode(selector, options) {
192
+ return applyNode(selector, { ...options, position: "replace" });
193
+ }
194
+ function applyReplaceChildrenNode(selector, options) {
195
+ return applyNode(selector, { ...options, position: "replaceChildren" });
196
+ }
197
+ function applyInnerHtmlNode(selector, options) {
198
+ return applyNode(selector, { ...options, position: "innerHtml" });
199
+ }
200
+ function applyInnerTextNode(selector, options) {
201
+ return applyNode(selector, { ...options, position: "innerText" });
202
+ }
203
+ function applyRemoveNode(selector, options) {
204
+ return applyNode(selector, { ...options, position: "remove" });
205
+ }
206
+ function applyBeforeBeginNodeHost(targetOrOptions, propertyKey, descriptor) {
207
+ if (propertyKey !== void 0) {
208
+ const decorator = applyNode(":host", { position: "beforeBegin" });
209
+ return decorator(targetOrOptions, propertyKey, descriptor);
210
+ }
211
+ return applyNode(":host", { ...targetOrOptions || {}, position: "beforeBegin" });
212
+ }
213
+ function applyAfterBeginNodeHost(optionsOrTarget, propertyKey, descriptor) {
214
+ if (propertyKey !== void 0) {
215
+ const decorator = applyNode(":host", { position: "afterBegin" });
216
+ return decorator(optionsOrTarget, propertyKey, descriptor);
217
+ }
218
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "afterBegin" });
219
+ }
220
+ function applyBeforeEndNodeHost(optionsOrTarget, propertyKey, descriptor) {
221
+ if (propertyKey !== void 0) {
222
+ const decorator = applyNode(":host", { position: "beforeEnd" });
223
+ return decorator(optionsOrTarget, propertyKey, descriptor);
224
+ }
225
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "beforeEnd" });
226
+ }
227
+ function applyAfterEndNodeHost(optionsOrTarget, propertyKey, descriptor) {
228
+ if (propertyKey !== void 0) {
229
+ const decorator = applyNode(":host", { position: "afterEnd" });
230
+ return decorator(optionsOrTarget, propertyKey, descriptor);
231
+ }
232
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "afterEnd" });
233
+ }
234
+ function applyReplaceNodeHost(optionsOrTarget, propertyKey, descriptor) {
235
+ if (propertyKey !== void 0) {
236
+ const decorator = applyNode(":host", { position: "replace" });
237
+ return decorator(optionsOrTarget, propertyKey, descriptor);
238
+ }
239
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "replace" });
240
+ }
241
+ function applyReplaceChildrenNodeHost(optionsOrTarget, propertyKey, descriptor) {
242
+ if (propertyKey !== void 0) {
243
+ const decorator = applyNode(":host", { position: "replaceChildren" });
244
+ return decorator(optionsOrTarget, propertyKey, descriptor);
245
+ }
246
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "replaceChildren" });
247
+ }
248
+ function applyInnerHtmlNodeHost(optionsOrTarget, propertyKey, descriptor) {
249
+ if (propertyKey !== void 0) {
250
+ const decorator = applyNode(":host", { position: "innerHtml" });
251
+ return decorator(optionsOrTarget, propertyKey, descriptor);
252
+ }
253
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "innerHtml" });
254
+ }
255
+ function applyInnerTextNodeHost(optionsOrTarget, propertyKey, descriptor) {
256
+ if (propertyKey !== void 0) {
257
+ const decorator = applyNode(":host", { position: "innerText" });
258
+ return decorator(optionsOrTarget, propertyKey, descriptor);
259
+ }
260
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "innerText" });
261
+ }
262
+ function applyRemoveNodeHost(optionsOrTarget, propertyKey, descriptor) {
263
+ if (propertyKey !== void 0) {
264
+ const decorator = applyNode(":host", { position: "remove" });
265
+ return decorator(optionsOrTarget, propertyKey, descriptor);
266
+ }
267
+ return applyNode(":host", { ...optionsOrTarget || {}, position: "remove" });
268
+ }
174
269
  //# sourceMappingURL=applyNode.js.map