@nuraly/runtime 0.1.9 → 0.1.11

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 (114) hide show
  1. package/components/ui/components/base/controllers/InputHandlerController.ts +5 -0
  2. package/components/ui/components/inputs/ColorPicker/colorpicker.ts +1 -7
  3. package/components/ui/components/inputs/Form/Form.ts +3 -11
  4. package/components/ui/components/inputs/RadioButton/Radio-button.ts +1 -7
  5. package/components/ui/components/inputs/Select/Select.ts +1 -7
  6. package/components/ui/components/layout/Grid/Col.ts +2 -6
  7. package/components/ui/components/layout/Grid/Row.ts +2 -6
  8. package/components/ui/components/studio/FunctionsPanel/FunctionsPanel.ts +4 -16
  9. package/dist/AIChat-C-wFf4PD.js +220 -0
  10. package/dist/AIChat-Cly-frW6.js +260 -0
  11. package/dist/Badge-BUm76SZ2.js +70 -0
  12. package/dist/Badge-BarGcY8u.js +48 -0
  13. package/dist/{BaseElement-BNBn_IJk.js → BaseElement-wyA58UxT.js} +156 -24
  14. package/dist/Button-BEgayuX9.js +80 -0
  15. package/dist/Button-wgwjzM_f.js +92 -0
  16. package/dist/Card-B4r5RQgn.js +120 -0
  17. package/dist/Card-a1sdDpKe.js +150 -0
  18. package/dist/Checkbox-CC9PkwpC.js +59 -0
  19. package/dist/Checkbox-WVmAN9ZP.js +65 -0
  20. package/dist/Code-Dc66ui4C.js +109 -0
  21. package/dist/Code-kVoVXBbt.js +123 -0
  22. package/dist/{CodeEditor-B1gNuvPb.js → CodeEditor-2QHTZxKN.js} +22 -22
  23. package/dist/Col-BKbQ2o0P.js +217 -0
  24. package/dist/Col-x4rRO4dz.js +193 -0
  25. package/dist/Collapse-Dd2GfevD.js +74 -0
  26. package/dist/Collapse-Xo-jb8zs.js +96 -0
  27. package/dist/Collections-DEqUHWFe.js +151 -0
  28. package/dist/Collections-DsTr-Zt7.js +122 -0
  29. package/dist/Container-C1HjQgb7.js +204 -0
  30. package/dist/DatePicker-DRVwFJmL.js +99 -0
  31. package/dist/DatePicker-oAOJyU3e.js +80 -0
  32. package/dist/Divider-BMA6S7Pd.js +106 -0
  33. package/dist/Divider-zbcO-KF9.js +86 -0
  34. package/dist/Document-BqVezrmJ.js +90 -0
  35. package/dist/Document-C2lg-jdj.js +74 -0
  36. package/dist/Dropdown-BRN-hpgd.js +133 -0
  37. package/dist/Dropdown-j62nqdd-.js +112 -0
  38. package/dist/EmbedURL-Bgr2pdf_.js +114 -0
  39. package/dist/EmbedURL-DFt6rN3J.js +142 -0
  40. package/dist/FileUpload-B5TBQJPC.js +54 -0
  41. package/dist/FileUpload-sYxMn9Rj.js +47 -0
  42. package/dist/Form-7ZWgBVzR.js +286 -0
  43. package/dist/Form-CsN7UMF-.js +339 -0
  44. package/dist/Icon-B_2ZWGd0.js +64 -0
  45. package/dist/Icon-CkLIObME.js +74 -0
  46. package/dist/Image-CcswllGj.js +93 -0
  47. package/dist/Image-CihbGdKt.js +111 -0
  48. package/dist/Link-BEUscah_.js +95 -0
  49. package/dist/Link-C4HV3i5L.js +76 -0
  50. package/dist/Menu-B98hcumz.js +83 -0
  51. package/dist/Menu-BEzo-k-M.js +73 -0
  52. package/dist/MicroApp-BDPSu_XC.js +75 -0
  53. package/dist/MicroApp-DCBOKAJ4.js +100 -0
  54. package/dist/NumberInput-Bbo10XmQ.js +95 -0
  55. package/dist/NumberInput-YJKsJDcd.js +84 -0
  56. package/dist/Panel-C1tcqveD.js +161 -0
  57. package/dist/Panel-DidE5uT5.js +127 -0
  58. package/dist/Radio-button-CuVS3-fC.js +71 -0
  59. package/dist/Radio-button-Cxj0bL8i.js +53 -0
  60. package/dist/RefComponent-BgOcavVg.js +79 -0
  61. package/dist/RefComponent-DTerPZ8J.js +96 -0
  62. package/dist/RichText-BiZgSdNO.js +449 -0
  63. package/dist/RichText-CwMNVuR_.js +485 -0
  64. package/dist/Row-BEx5bGTR.js +202 -0
  65. package/dist/Row-XczXHjOV.js +229 -0
  66. package/dist/Select-Bd16OOiE.js +87 -0
  67. package/dist/Select-D0xinu-U.js +77 -0
  68. package/dist/Slider-BVFPWYh3.js +55 -0
  69. package/dist/Slider-DGulvswN.js +74 -0
  70. package/dist/Table-C44wa8yn.js +159 -0
  71. package/dist/Table-CQiS_Q-s.js +184 -0
  72. package/dist/Tabs-CPQxFISc.js +131 -0
  73. package/dist/Tabs-DW2Su8xF.js +116 -0
  74. package/dist/Tag-BEfAQrjG.js +61 -0
  75. package/dist/Tag-BLxTFDcC.js +47 -0
  76. package/dist/TextInput-BWhdGS3a.js +148 -0
  77. package/dist/TextInput-CV850FvO.js +193 -0
  78. package/dist/TextLabel-CbSGmoVY.js +102 -0
  79. package/dist/Textarea-Bncyxfts.js +83 -0
  80. package/dist/Textarea-SEbx4KI5.js +117 -0
  81. package/dist/Video--shJ014h.js +120 -0
  82. package/dist/Video-CflXfaiK.js +100 -0
  83. package/dist/aitchat-Btz9TPEN.js +23 -0
  84. package/dist/colorpicker-BO_4CeX4.js +64 -0
  85. package/dist/colorpicker-UzXsx6gP.js +75 -0
  86. package/dist/constants-Bs_KQRi_.js +4 -0
  87. package/dist/constants-CXdpxgF2.js +4 -0
  88. package/dist/{cssMode-D82-gS78.js → cssMode-tpaxIZJS.js} +1 -1
  89. package/dist/{freemarker2-CYRLpyjt.js → freemarker2-Nx-tkO9y.js} +1 -1
  90. package/dist/{handlebars-R8Efxi60.js → handlebars-CF3Jmmto.js} +1 -1
  91. package/dist/{html-czhjovcp.js → html-CdZEJTJR.js} +1 -1
  92. package/dist/{htmlMode-DpyKDYYs.js → htmlMode-CztruwTl.js} +1 -1
  93. package/dist/iconbutton-BwuZYQyh.js +53 -0
  94. package/dist/iconbutton-CE0Vxu1G.js +69 -0
  95. package/dist/{javascript-DwqkMEdb.js → javascript-CVODTc2t.js} +1 -1
  96. package/dist/{jsonMode-Cmxxe0W9.js → jsonMode-ChPl6moP.js} +1 -1
  97. package/dist/{liquid-2spuEcBh.js → liquid-BckHw388.js} +1 -1
  98. package/dist/{mdx-BjBXyEeR.js → mdx-DB1fiwuN.js} +1 -1
  99. package/dist/micro-app-entry-BgDXbkmh.js +12042 -0
  100. package/dist/micro-app.bundle.js +1 -1
  101. package/dist/micro-app.js +6 -4969
  102. package/dist/{python-DLI1ji08.js → python-DOQt67t7.js} +1 -1
  103. package/dist/{razor-oAnIJsrL.js → razor-D65ZeXuP.js} +1 -1
  104. package/dist/runtime.js +4 -2
  105. package/dist/{tsMode-D_PMsbjK.js → tsMode-CXrSAnjJ.js} +1 -1
  106. package/dist/{typescript-Bu3ZbtQI.js → typescript-BuKvlC_a.js} +1 -1
  107. package/dist/{xml-CNSSkPqy.js → xml-_nj2r-yt.js} +1 -1
  108. package/dist/{yaml-5RF_PGNe.js → yaml-m8PrW_TL.js} +1 -1
  109. package/package.json +1 -1
  110. package/utils/index.ts +4 -1
  111. package/utils/lazy-component-loader.ts +120 -0
  112. package/utils/register-components.ts +14 -40
  113. package/utils/render-util.ts +84 -0
  114. package/dist/micro-app-entry-DYAnCRDo.js +0 -15860
@@ -0,0 +1,114 @@
1
+ import { B as p, n as l, o as h, b as a, i as m, c as d, d as f, t as b } from "./micro-app-entry-BgDXbkmh.js";
2
+ var y = Object.defineProperty, v = Object.getOwnPropertyDescriptor, n = (e, s, o, t) => {
3
+ for (var r = t > 1 ? void 0 : t ? v(s, o) : s, c = e.length - 1, u; c >= 0; c--)
4
+ (u = e[c]) && (r = (t ? u(s, o, r) : u(r)) || r);
5
+ return t && r && y(s, o, r), r;
6
+ };
7
+ let i = class extends p {
8
+ constructor() {
9
+ super(), this.currentUrl = "", this._isUserFocused = !1, this._focusResetTimeout = null, this.iframeRef = l(), this.onFocus = (e) => {
10
+ this._isUserFocused = !0, this.executeEvent("onFocus", e);
11
+ }, this.onBlur = (e) => {
12
+ this._isUserFocused = !1, this.executeEvent("onBlur", e);
13
+ };
14
+ }
15
+ firstUpdated(e) {
16
+ super.firstUpdated(e), this.registerCallback("url", (s) => {
17
+ !this._isUserFocused && this.currentUrl !== s && (this.currentUrl = s ?? "");
18
+ });
19
+ }
20
+ handleIframeLoad(e) {
21
+ this.executeEvent("onLoad", e, {
22
+ url: this.currentUrl || this.inputHandlersValue?.url || ""
23
+ });
24
+ }
25
+ handleIframeError(e) {
26
+ this.executeEvent("onError", e, {
27
+ url: this.currentUrl || this.inputHandlersValue?.url || "",
28
+ error: "Failed to load iframe content"
29
+ });
30
+ }
31
+ resetFocusAfterInactivity() {
32
+ this._focusResetTimeout && clearTimeout(this._focusResetTimeout), this._focusResetTimeout = setTimeout(() => {
33
+ this._isUserFocused = !1;
34
+ }, 3e3);
35
+ }
36
+ disconnectedCallback() {
37
+ super.disconnectedCallback(), this.unsubscribe && this.unsubscribe(), this._focusResetTimeout && clearTimeout(this._focusResetTimeout);
38
+ }
39
+ renderComponent() {
40
+ const e = this.getStyles() || {}, s = this.component?.styleHandlers ? Object.fromEntries(
41
+ Object.entries(this.component?.styleHandlers).filter(([t, r]) => r)
42
+ ) : {}, o = this.currentUrl || this.inputHandlersValue?.url || "";
43
+ return o ? a`
44
+ <div
45
+ ${l(this.inputRef)}
46
+ tabindex="0"
47
+ @focus=${this.onFocus}
48
+ @blur=${this.onBlur}
49
+ @click=${(t) => this.executeEvent("onClick", t)}
50
+ style=${h(this.getStyles())}
51
+ >
52
+ <iframe
53
+ ${l(this.iframeRef)}
54
+ src=${o}
55
+ @load=${(t) => this.handleIframeLoad(t)}
56
+ @error=${(t) => this.handleIframeError(t)}
57
+ ></iframe>
58
+ </div>
59
+ ` : a`
60
+ <div
61
+ ${l(this.inputRef)}
62
+ class="embed-placeholder"
63
+ style=${h({
64
+ ...this.getStyles(),
65
+ width: s?.width || e?.width || "100%",
66
+ height: s?.height || e?.height || "200px"
67
+ })}
68
+ @click=${(t) => this.executeEvent("onClick", t)}
69
+ >
70
+ <nr-icon name="globe"></nr-icon>
71
+ <nr-label>No URL provided</nr-label>
72
+ </div>
73
+ `;
74
+ }
75
+ };
76
+ i.styles = [m`
77
+ iframe {
78
+ width: 100%;
79
+ height: 100%;
80
+ border: none;
81
+ }
82
+ .embed-placeholder {
83
+ display: flex;
84
+ flex-direction: column;
85
+ align-items: center;
86
+ justify-content: center;
87
+ color: #64748b;
88
+ min-height: 200px;
89
+ border-radius: 8px;
90
+ border: 2px dashed #cbd5e1;
91
+ gap: 12px;
92
+ }
93
+ .embed-placeholder nr-icon {
94
+ --nuraly-icon-size: 48px;
95
+ }
96
+ `];
97
+ n([
98
+ d({ type: Object })
99
+ ], i.prototype, "component", 2);
100
+ n([
101
+ d({ type: Object })
102
+ ], i.prototype, "item", 2);
103
+ n([
104
+ f()
105
+ ], i.prototype, "currentUrl", 2);
106
+ n([
107
+ f()
108
+ ], i.prototype, "_isUserFocused", 2);
109
+ i = n([
110
+ b("embed-url-block")
111
+ ], i);
112
+ export {
113
+ i as EmbedUrlBlock
114
+ };
@@ -0,0 +1,142 @@
1
+ import { html, css } from 'lit';
2
+ import { property, state, customElement } from 'lit/decorators.js';
3
+ import { styleMap } from 'lit/directives/style-map.js';
4
+ import { ref } from 'lit/directives/ref.js';
5
+ import { ae as BaseElementBlock } from './BaseElement-wyA58UxT.js';
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __decorateClass = (decorators, target, key, kind) => {
10
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
11
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
12
+ if (decorator = decorators[i])
13
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
14
+ if (kind && result) __defProp(target, key, result);
15
+ return result;
16
+ };
17
+ let EmbedUrlBlock = class extends BaseElementBlock {
18
+ constructor() {
19
+ super();
20
+ this.currentUrl = "";
21
+ this._isUserFocused = false;
22
+ this._focusResetTimeout = null;
23
+ this.iframeRef = ref();
24
+ this.onFocus = (e) => {
25
+ this._isUserFocused = true;
26
+ this.executeEvent("onFocus", e);
27
+ };
28
+ this.onBlur = (e) => {
29
+ this._isUserFocused = false;
30
+ this.executeEvent("onBlur", e);
31
+ };
32
+ }
33
+ firstUpdated(_changedProperties) {
34
+ super.firstUpdated(_changedProperties);
35
+ this.registerCallback("url", (url) => {
36
+ if (!this._isUserFocused && this.currentUrl !== url) {
37
+ this.currentUrl = url ?? "";
38
+ }
39
+ });
40
+ }
41
+ handleIframeLoad(e) {
42
+ this.executeEvent("onLoad", e, {
43
+ url: this.currentUrl || this.inputHandlersValue?.url || ""
44
+ });
45
+ }
46
+ handleIframeError(e) {
47
+ this.executeEvent("onError", e, {
48
+ url: this.currentUrl || this.inputHandlersValue?.url || "",
49
+ error: "Failed to load iframe content"
50
+ });
51
+ }
52
+ resetFocusAfterInactivity() {
53
+ if (this._focusResetTimeout) clearTimeout(this._focusResetTimeout);
54
+ this._focusResetTimeout = setTimeout(() => {
55
+ this._isUserFocused = false;
56
+ }, 3e3);
57
+ }
58
+ disconnectedCallback() {
59
+ super.disconnectedCallback();
60
+ if (this.unsubscribe) this.unsubscribe();
61
+ if (this._focusResetTimeout) clearTimeout(this._focusResetTimeout);
62
+ }
63
+ renderComponent() {
64
+ const embedStyles = this.getStyles() || {};
65
+ const embedStyleHandlers = this.component?.styleHandlers ? Object.fromEntries(
66
+ Object.entries(this.component?.styleHandlers).filter(([key, value]) => value)
67
+ ) : {};
68
+ const url = this.currentUrl || this.inputHandlersValue?.url || "";
69
+ if (!url) {
70
+ return html`
71
+ <div
72
+ ${ref(this.inputRef)}
73
+ class="embed-placeholder"
74
+ style=${styleMap({
75
+ ...this.getStyles(),
76
+ width: embedStyleHandlers?.width || embedStyles?.width || "100%",
77
+ height: embedStyleHandlers?.height || embedStyles?.height || "200px"
78
+ })}
79
+ @click=${(e) => this.executeEvent("onClick", e)}
80
+ >
81
+ <nr-icon name="globe"></nr-icon>
82
+ <nr-label>No URL provided</nr-label>
83
+ </div>
84
+ `;
85
+ }
86
+ return html`
87
+ <div
88
+ ${ref(this.inputRef)}
89
+ tabindex="0"
90
+ @focus=${this.onFocus}
91
+ @blur=${this.onBlur}
92
+ @click=${(e) => this.executeEvent("onClick", e)}
93
+ style=${styleMap(this.getStyles())}
94
+ >
95
+ <iframe
96
+ ${ref(this.iframeRef)}
97
+ src=${url}
98
+ @load=${(e) => this.handleIframeLoad(e)}
99
+ @error=${(e) => this.handleIframeError(e)}
100
+ ></iframe>
101
+ </div>
102
+ `;
103
+ }
104
+ };
105
+ EmbedUrlBlock.styles = [css`
106
+ iframe {
107
+ width: 100%;
108
+ height: 100%;
109
+ border: none;
110
+ }
111
+ .embed-placeholder {
112
+ display: flex;
113
+ flex-direction: column;
114
+ align-items: center;
115
+ justify-content: center;
116
+ color: #64748b;
117
+ min-height: 200px;
118
+ border-radius: 8px;
119
+ border: 2px dashed #cbd5e1;
120
+ gap: 12px;
121
+ }
122
+ .embed-placeholder nr-icon {
123
+ --nuraly-icon-size: 48px;
124
+ }
125
+ `];
126
+ __decorateClass([
127
+ property({ type: Object })
128
+ ], EmbedUrlBlock.prototype, "component", 2);
129
+ __decorateClass([
130
+ property({ type: Object })
131
+ ], EmbedUrlBlock.prototype, "item", 2);
132
+ __decorateClass([
133
+ state()
134
+ ], EmbedUrlBlock.prototype, "currentUrl", 2);
135
+ __decorateClass([
136
+ state()
137
+ ], EmbedUrlBlock.prototype, "_isUserFocused", 2);
138
+ EmbedUrlBlock = __decorateClass([
139
+ customElement("embed-url-block")
140
+ ], EmbedUrlBlock);
141
+
142
+ export { EmbedUrlBlock };
@@ -0,0 +1,54 @@
1
+ import { customElement } from 'lit/decorators.js';
2
+ import { html, css } from 'lit';
3
+ import { ae as BaseElementBlock } from './BaseElement-wyA58UxT.js';
4
+ import { ref } from 'lit/directives/ref.js';
5
+ import { styleMap } from 'lit/directives/style-map.js';
6
+
7
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
+ var __decorateClass = (decorators, target, key, kind) => {
9
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
10
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
11
+ if (decorator = decorators[i])
12
+ result = (decorator(result)) || result;
13
+ return result;
14
+ };
15
+ try {
16
+ await import('@nuralyui/file-upload');
17
+ } catch (error) {
18
+ console.warn("[@nuralyui/file-upload] Package not found or failed to load.");
19
+ }
20
+ let FileUploadBlock = class extends BaseElementBlock {
21
+ renderComponent() {
22
+ return html`
23
+ <nr-file-upload
24
+ style=${styleMap({
25
+ ...this.getStyles()
26
+ })}
27
+
28
+ ${ref(this.inputRef)}
29
+ accept="*/*"
30
+ drag
31
+ limit="5"
32
+ tip="JPG/PNG files up to 500kb"
33
+ @files-changed=${(e) => {
34
+ const files = e.detail;
35
+ this.executeEvent("onFilesChanged", e, {
36
+ files
37
+ });
38
+ }}
39
+ ></nr-file-upload>
40
+ `;
41
+ }
42
+ };
43
+ FileUploadBlock.styles = [
44
+ css`
45
+ :host {
46
+ display: block;
47
+ }
48
+ `
49
+ ];
50
+ FileUploadBlock = __decorateClass([
51
+ customElement("file-upload-block")
52
+ ], FileUploadBlock);
53
+
54
+ export { FileUploadBlock };
@@ -0,0 +1,47 @@
1
+ import { B as n, o as p, n as c, b as d, i as f, t as u } from "./micro-app-entry-BgDXbkmh.js";
2
+ var h = Object.getOwnPropertyDescriptor, g = (e, t, s, a) => {
3
+ for (var l = a > 1 ? void 0 : a ? h(t, s) : t, o = e.length - 1, i; o >= 0; o--)
4
+ (i = e[o]) && (l = i(l) || l);
5
+ return l;
6
+ };
7
+ try {
8
+ await import("@nuralyui/file-upload");
9
+ } catch {
10
+ console.warn("[@nuralyui/file-upload] Package not found or failed to load.");
11
+ }
12
+ let r = class extends n {
13
+ renderComponent() {
14
+ return d`
15
+ <nr-file-upload
16
+ style=${p({
17
+ ...this.getStyles()
18
+ })}
19
+
20
+ ${c(this.inputRef)}
21
+ accept="*/*"
22
+ drag
23
+ limit="5"
24
+ tip="JPG/PNG files up to 500kb"
25
+ @files-changed=${(e) => {
26
+ const t = e.detail;
27
+ this.executeEvent("onFilesChanged", e, {
28
+ files: t
29
+ });
30
+ }}
31
+ ></nr-file-upload>
32
+ `;
33
+ }
34
+ };
35
+ r.styles = [
36
+ f`
37
+ :host {
38
+ display: block;
39
+ }
40
+ `
41
+ ];
42
+ r = g([
43
+ u("file-upload-block")
44
+ ], r);
45
+ export {
46
+ r as FileUploadBlock
47
+ };
@@ -0,0 +1,286 @@
1
+ import { i as f, B as p, $ as g, s as v, b as d, r as _, n as m, A as h, c, d as u, t as $ } from "./micro-app-entry-BgDXbkmh.js";
2
+ import "@nuralyui/icon";
3
+ import "@nuralyui/label";
4
+ const b = f`
5
+ :host {
6
+ display: block;
7
+ width: 100%;
8
+ }
9
+
10
+ .form-placeholder {
11
+ display: flex;
12
+ flex-direction: column;
13
+ align-items: center;
14
+ justify-content: center;
15
+ color: #64748b;
16
+ min-height: 200px;
17
+ width: 100%;
18
+ border-radius: 8px;
19
+ border: 2px dashed #cbd5e1;
20
+ gap: 12px;
21
+ cursor: pointer;
22
+ }
23
+
24
+ .form-placeholder nr-icon {
25
+ --nuraly-icon-size: 48px;
26
+ }
27
+ `;
28
+ var C = Object.defineProperty, E = Object.getOwnPropertyDescriptor, l = (t, i, e, r) => {
29
+ for (var n = r > 1 ? void 0 : r ? E(i, e) : i, a = t.length - 1, o; a >= 0; a--)
30
+ (o = t[a]) && (n = (r ? o(i, e, n) : o(n)) || n);
31
+ return r && n && C(i, e, n), n;
32
+ };
33
+ try {
34
+ await import("@nuralyui/forms");
35
+ } catch {
36
+ console.warn("[@nuralyui/forms] Package not found or failed to load.");
37
+ }
38
+ let s = class extends p {
39
+ constructor() {
40
+ super(), this._formElement = null, this._registeredFields = /* @__PURE__ */ new Map(), this.childrenComponents = [], this._fieldRegisterHandler = this._handleFieldRegister.bind(this), this._fieldUnregisterHandler = this._handleFieldUnregister.bind(this), this._fieldValueChangeHandler = this._handleFieldValueChange.bind(this);
41
+ }
42
+ connectedCallback() {
43
+ super.connectedCallback(), this.updateChildrenComponents(), this.addEventListener("nr-field-register", this._fieldRegisterHandler), this.addEventListener("nr-field-unregister", this._fieldUnregisterHandler), this.addEventListener("nr-field-value-change", this._fieldValueChangeHandler);
44
+ }
45
+ willUpdate(t) {
46
+ super.willUpdate(t), t.has("component") && this.updateChildrenComponents();
47
+ }
48
+ updateChildrenComponents() {
49
+ this.childrenComponents = this.component?.childrenIds?.map((t) => g.get()[this.component?.application_id]?.find((i) => i.uuid === t)).filter(Boolean) ?? [];
50
+ }
51
+ disconnectedCallback() {
52
+ super.disconnectedCallback(), this.removeEventListener("nr-field-register", this._fieldRegisterHandler), this.removeEventListener("nr-field-unregister", this._fieldUnregisterHandler), this.removeEventListener("nr-field-value-change", this._fieldValueChangeHandler), this._registeredFields.clear();
53
+ }
54
+ firstUpdated(t) {
55
+ super.firstUpdated(t), this._formElement = this.renderRoot.querySelector("nr-form"), this.registerCallback("disabled", (i) => {
56
+ this._formElement && (this._formElement.disabled = i);
57
+ });
58
+ }
59
+ /**
60
+ * Handle field registration from child input blocks
61
+ */
62
+ _handleFieldRegister(t) {
63
+ t.stopPropagation();
64
+ const { element: i, name: e, blockElement: r } = t.detail;
65
+ if (!e || !i) {
66
+ console.warn("[FormBlock] Field registration missing name or element");
67
+ return;
68
+ }
69
+ if (this._registeredFields.set(e, { element: i, blockElement: r }), this._formElement?.validationController)
70
+ try {
71
+ this._formElement.validationController.registerField(i);
72
+ } catch (n) {
73
+ console.warn("[FormBlock] Failed to register field with validation controller:", n);
74
+ }
75
+ }
76
+ /**
77
+ * Handle field unregistration when child input blocks are removed
78
+ */
79
+ _handleFieldUnregister(t) {
80
+ t.stopPropagation();
81
+ const { name: i } = t.detail;
82
+ if (i && this._registeredFields.has(i)) {
83
+ if (this._formElement?.validationController)
84
+ try {
85
+ this._formElement.validationController.unregisterField(i);
86
+ } catch (e) {
87
+ console.warn("[FormBlock] Failed to unregister field:", e);
88
+ }
89
+ this._registeredFields.delete(i);
90
+ }
91
+ }
92
+ /**
93
+ * Handle field value changes for form data collection
94
+ */
95
+ _handleFieldValueChange(t) {
96
+ const { name: i, value: e } = t.detail;
97
+ if (i && this._registeredFields.has(i)) {
98
+ const r = this._registeredFields.get(i);
99
+ r.value = e;
100
+ }
101
+ }
102
+ /**
103
+ * Get all form field values
104
+ */
105
+ getFieldsValue() {
106
+ if (this._formElement?.getFieldsValue)
107
+ return this._formElement.getFieldsValue();
108
+ const t = {};
109
+ for (const [i, e] of this._registeredFields)
110
+ t[i] = e.element?.value ?? e.value;
111
+ return t;
112
+ }
113
+ /**
114
+ * Set form field values
115
+ */
116
+ setFieldsValue(t) {
117
+ this._formElement?.setFieldsValue && this._formElement.setFieldsValue(t);
118
+ }
119
+ /**
120
+ * Validate all form fields
121
+ */
122
+ async validate() {
123
+ return this._formElement?.validate ? this._formElement.validate() : !0;
124
+ }
125
+ /**
126
+ * Submit the form programmatically
127
+ */
128
+ async submit(t) {
129
+ this._formElement?.submit && await this._formElement.submit(t);
130
+ }
131
+ /**
132
+ * Reset the form
133
+ */
134
+ reset() {
135
+ this._formElement?.reset && this._formElement.reset();
136
+ }
137
+ /**
138
+ * Get form state summary
139
+ */
140
+ getFormState() {
141
+ return this._formElement?.getFormState ? this._formElement.getFormState() : {
142
+ isValid: !0,
143
+ isSubmitting: !1,
144
+ hasErrors: !1,
145
+ errorCount: 0,
146
+ fieldCount: this._registeredFields.size
147
+ };
148
+ }
149
+ /**
150
+ * Render placeholder when form is empty in editor mode
151
+ */
152
+ renderPlaceholder() {
153
+ return d`
154
+ <div
155
+ class="form-placeholder"
156
+ @click="${() => v(this.component?.uuid)}"
157
+ >
158
+ <nr-icon name="file-text"></nr-icon>
159
+ <nr-label>Add form fields to this form</nr-label>
160
+ <drag-wrapper
161
+ .where=${"inside"}
162
+ .message=${"Drop inside"}
163
+ .component=${{ ...this.component }}
164
+ .inputRef=${this.inputRef}
165
+ .isDragInitiator=${this.isDragInitiator}
166
+ >
167
+ </drag-wrapper>
168
+ </div>
169
+ `;
170
+ }
171
+ /**
172
+ * Render children components
173
+ */
174
+ renderChildren() {
175
+ return _(
176
+ this.childrenComponents.map((t) => ({ ...t, item: this.item })),
177
+ this.item,
178
+ this.isViewMode,
179
+ { ...this.component, uniqueUUID: this.uniqueUUID }
180
+ );
181
+ }
182
+ renderComponent() {
183
+ const t = this.getStyles(), i = this.childrenComponents.length > 0;
184
+ return this.isViewMode ? d`
185
+ <nr-form
186
+ ${m(this.inputRef)}
187
+ class="${`drop-${this.component.uuid}`}"
188
+ style=${Object.entries(t).map(([e, r]) => `${e}:${r}`).join(";")}
189
+ .disabled=${this.inputHandlersValue?.disabled || !1}
190
+ .validateOnChange=${this.inputHandlersValue?.validateOnChange ?? !1}
191
+ .validateOnBlur=${this.inputHandlersValue?.validateOnBlur ?? !0}
192
+ .preventInvalidSubmission=${this.inputHandlersValue?.preventInvalidSubmission ?? !0}
193
+ .resetOnSuccess=${this.inputHandlersValue?.resetOnSuccess ?? !1}
194
+ .action=${this.inputHandlersValue?.action ?? h}
195
+ .method=${this.inputHandlersValue?.method ?? "POST"}
196
+ @nr-form-submit-success=${(e) => {
197
+ this.executeEvent("onSubmitSuccess", e, {
198
+ formData: e.detail?.formData,
199
+ values: this.getFieldsValue()
200
+ });
201
+ }}
202
+ @nr-form-submit-error=${(e) => {
203
+ this.executeEvent("onSubmitError", e, {
204
+ error: e.detail?.error
205
+ });
206
+ }}
207
+ @nr-form-validation-changed=${(e) => {
208
+ this.executeEvent("onValidationChange", e, {
209
+ validationResult: e.detail?.validationResult
210
+ });
211
+ }}
212
+ @nr-form-field-changed=${(e) => {
213
+ this.executeEvent("onFieldChange", e, {
214
+ field: e.detail?.field
215
+ });
216
+ }}
217
+ @nr-form-reset=${(e) => {
218
+ this.executeEvent("onReset", e, {});
219
+ }}
220
+ >
221
+ ${i ? this.renderChildren() : h}
222
+ </nr-form>
223
+ ` : d`
224
+ <nr-form
225
+ ${m(this.inputRef)}
226
+ class="${`drop-${this.component.uuid}`}"
227
+ style=${Object.entries(t).map(([e, r]) => `${e}:${r}`).join(";")}
228
+ .disabled=${this.inputHandlersValue?.disabled || !1}
229
+ .validateOnChange=${this.inputHandlersValue?.validateOnChange ?? !1}
230
+ .validateOnBlur=${this.inputHandlersValue?.validateOnBlur ?? !0}
231
+ .preventInvalidSubmission=${this.inputHandlersValue?.preventInvalidSubmission ?? !0}
232
+ .resetOnSuccess=${this.inputHandlersValue?.resetOnSuccess ?? !1}
233
+ .action=${this.inputHandlersValue?.action ?? h}
234
+ .method=${this.inputHandlersValue?.method ?? "POST"}
235
+ @nr-form-submit-success=${(e) => {
236
+ this.executeEvent("onSubmitSuccess", e, {
237
+ formData: e.detail?.formData,
238
+ values: this.getFieldsValue()
239
+ });
240
+ }}
241
+ @nr-form-submit-error=${(e) => {
242
+ this.executeEvent("onSubmitError", e, {
243
+ error: e.detail?.error
244
+ });
245
+ }}
246
+ @nr-form-validation-changed=${(e) => {
247
+ this.executeEvent("onValidationChange", e, {
248
+ validationResult: e.detail?.validationResult
249
+ });
250
+ }}
251
+ @nr-form-field-changed=${(e) => {
252
+ this.executeEvent("onFieldChange", e, {
253
+ field: e.detail?.field
254
+ });
255
+ }}
256
+ @nr-form-reset=${(e) => {
257
+ this.executeEvent("onReset", e, {});
258
+ }}
259
+ >
260
+ ${i ? this.renderChildren() : this.renderPlaceholder()}
261
+ </nr-form>
262
+ `;
263
+ }
264
+ };
265
+ s.styles = [b];
266
+ l([
267
+ c({ type: Object })
268
+ ], s.prototype, "component", 2);
269
+ l([
270
+ c({ type: Object })
271
+ ], s.prototype, "item", 2);
272
+ l([
273
+ u()
274
+ ], s.prototype, "_formElement", 2);
275
+ l([
276
+ u()
277
+ ], s.prototype, "_registeredFields", 2);
278
+ l([
279
+ u()
280
+ ], s.prototype, "childrenComponents", 2);
281
+ s = l([
282
+ $("form-block")
283
+ ], s);
284
+ export {
285
+ s as FormBlock
286
+ };