@nuraly/runtime 0.1.8 → 0.1.10

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 (106) hide show
  1. package/dist/AIChat-DP3ZdLL3.js +220 -0
  2. package/dist/AIChat-km1IYaR-.js +260 -0
  3. package/dist/Badge-BR94MUt5.js +48 -0
  4. package/dist/Badge-DzNZFKtC.js +70 -0
  5. package/dist/{BaseElement-BNBn_IJk.js → BaseElement-pS6m_x6Q.js} +153 -24
  6. package/dist/Button-BHAN7npC.js +92 -0
  7. package/dist/Button-DCqgsxrL.js +80 -0
  8. package/dist/Card-B70c8NFb.js +150 -0
  9. package/dist/Card-DhOCsGKC.js +120 -0
  10. package/dist/Checkbox-BZTcPwew.js +59 -0
  11. package/dist/Checkbox-LYTIBAUV.js +65 -0
  12. package/dist/Code-BWbiciC8.js +123 -0
  13. package/dist/Code-Ds0vFclr.js +109 -0
  14. package/dist/{CodeEditor-Bf4L2rO_.js → CodeEditor-ChuFC0ex.js} +22 -22
  15. package/dist/Col-B_wpWUcU.js +217 -0
  16. package/dist/Col-DYs8_65c.js +193 -0
  17. package/dist/Collapse-4kxbQ74u.js +74 -0
  18. package/dist/Collapse-Dkw6Ner6.js +96 -0
  19. package/dist/Collections-BSF-PqBz.js +122 -0
  20. package/dist/Collections-D5rwMFbv.js +151 -0
  21. package/dist/Container-DMNh5U4Y.js +204 -0
  22. package/dist/DatePicker-BmEOONiA.js +99 -0
  23. package/dist/DatePicker-VuUroOT4.js +80 -0
  24. package/dist/Divider-BfxR3rVl.js +86 -0
  25. package/dist/Divider-etMTYU3d.js +106 -0
  26. package/dist/Document-CHBcJciR.js +74 -0
  27. package/dist/Document-Cj-TmjAf.js +90 -0
  28. package/dist/Dropdown-BRtHvDa3.js +133 -0
  29. package/dist/Dropdown-C47Y11dj.js +112 -0
  30. package/dist/EmbedURL-BwbJRnY1.js +142 -0
  31. package/dist/EmbedURL-Ci5X1vQG.js +114 -0
  32. package/dist/FileUpload-BBgPcRag.js +54 -0
  33. package/dist/FileUpload-BgkhxtNe.js +47 -0
  34. package/dist/Form-BLq6U3In.js +339 -0
  35. package/dist/Form-E6zXqgsm.js +286 -0
  36. package/dist/Icon-CcLuhz6B.js +64 -0
  37. package/dist/Icon-_UiLblGb.js +74 -0
  38. package/dist/Image-B_VERIvH.js +111 -0
  39. package/dist/Image-hI8kIx8U.js +93 -0
  40. package/dist/Link-BVTo43Cc.js +76 -0
  41. package/dist/Link-xSrPxOLt.js +95 -0
  42. package/dist/Menu-CembLIjO.js +83 -0
  43. package/dist/Menu-D9ZjIOMg.js +73 -0
  44. package/dist/MicroApp-DI1kQwJk.js +100 -0
  45. package/dist/MicroApp-DJw57sLE.js +75 -0
  46. package/dist/NumberInput-DftAAKEs.js +84 -0
  47. package/dist/NumberInput-eOAk0-fb.js +95 -0
  48. package/dist/Panel-Bso5fv4i.js +127 -0
  49. package/dist/Panel-CwzW9iuA.js +161 -0
  50. package/dist/Radio-button-Sii5iveh.js +71 -0
  51. package/dist/Radio-button-YXsVqipQ.js +53 -0
  52. package/dist/RefComponent-Bwk_I0mK.js +79 -0
  53. package/dist/RefComponent-ZxafRVhZ.js +96 -0
  54. package/dist/RichText-CgYXXC_a.js +485 -0
  55. package/dist/RichText-DV46U7fI.js +449 -0
  56. package/dist/Row-Bb95f5DI.js +229 -0
  57. package/dist/Row-Dmd_61mR.js +202 -0
  58. package/dist/Select-Cma8JHAj.js +77 -0
  59. package/dist/Select-DqA08VYb.js +87 -0
  60. package/dist/Slider-B2_Qecjz.js +74 -0
  61. package/dist/Slider-DVY0N2YX.js +55 -0
  62. package/dist/Table-0WjrBnz-.js +159 -0
  63. package/dist/Table-dEma50kw.js +184 -0
  64. package/dist/Tabs-BDKEv1jn.js +131 -0
  65. package/dist/Tabs-Cvt3Q8vx.js +116 -0
  66. package/dist/Tag-BcZvQkE_.js +47 -0
  67. package/dist/Tag-DMZ0mu8y.js +61 -0
  68. package/dist/TextInput-KI6r9xET.js +193 -0
  69. package/dist/TextInput-hxK-HhJi.js +148 -0
  70. package/dist/TextLabel-DkV26yaL.js +102 -0
  71. package/dist/Textarea-Bzs3jSUm.js +117 -0
  72. package/dist/Textarea-CwK3SYbz.js +83 -0
  73. package/dist/Video-C4uBWCBb.js +100 -0
  74. package/dist/Video-CL1lgcvB.js +120 -0
  75. package/dist/aitchat-DjX5s7_8.js +23 -0
  76. package/dist/colorpicker-B-KETfWw.js +64 -0
  77. package/dist/colorpicker-DhB0AygJ.js +75 -0
  78. package/dist/constants-Bs_KQRi_.js +4 -0
  79. package/dist/constants-CXdpxgF2.js +4 -0
  80. package/dist/{cssMode-DMsdy1N0.js → cssMode-CV7QbFJv.js} +1 -1
  81. package/dist/{freemarker2-D51H9HYi.js → freemarker2-CqQxSEZa.js} +1 -1
  82. package/dist/{handlebars-CF6gdAX4.js → handlebars-a71LdN7X.js} +1 -1
  83. package/dist/{html-c2n_zkM3.js → html-D8UaB7IC.js} +1 -1
  84. package/dist/{htmlMode-9IJTuZUh.js → htmlMode-CqWQMFWX.js} +1 -1
  85. package/dist/iconbutton-DfnrRmmB.js +69 -0
  86. package/dist/iconbutton-DvIQHV8o.js +53 -0
  87. package/dist/{javascript-DhEEBMxD.js → javascript-D_jGqcRD.js} +1 -1
  88. package/dist/{jsonMode-CB6k-4rp.js → jsonMode-C3-m5xts.js} +1 -1
  89. package/dist/{liquid-CwtPiwnW.js → liquid-DLwYj6Te.js} +1 -1
  90. package/dist/{mdx-LewPRYF8.js → mdx-DhYjhxkW.js} +1 -1
  91. package/dist/micro-app-entry-DiNqE6xi.js +12042 -0
  92. package/dist/micro-app.bundle.js +1 -1
  93. package/dist/micro-app.js +6 -4940
  94. package/dist/{python-h5Z2g-yl.js → python-B-WcGqFq.js} +1 -1
  95. package/dist/{razor-D5ep1Doy.js → razor-JGACy1mz.js} +1 -1
  96. package/dist/runtime.js +4 -2
  97. package/dist/{tsMode-B_6LiBE1.js → tsMode-lzBM1oT2.js} +1 -1
  98. package/dist/{typescript-BBG0jH4p.js → typescript-CuL5pdO2.js} +1 -1
  99. package/dist/{xml-DgLB7rE6.js → xml-D1tacAKD.js} +1 -1
  100. package/dist/{yaml-DiI4HpSv.js → yaml-CjPB1g7v.js} +1 -1
  101. package/package.json +4 -1
  102. package/utils/index.ts +4 -1
  103. package/utils/lazy-component-loader.ts +120 -0
  104. package/utils/register-components.ts +14 -40
  105. package/utils/render-util.ts +84 -0
  106. package/dist/micro-app-entry-C3RDIukG.js +0 -15831
package/dist/micro-app.js CHANGED
@@ -1,4948 +1,14 @@
1
- import { ae as BaseElementBlock, bl as EMPTY_STRING, aO as renderComponent, w as $applicationComponents, $ as $components, v as RuntimeHelpers, ap as setContextMenuEvent, ak as setCurrentComponentIdAction, a8 as executeHandler, ba as getNestedAttribute, az as addGeneratedComponents, as as addTempApplication, a0 as $microAppCurrentPage, j as $environment, a4 as ViewMode, n as $resizing, aU as eventDispatcher, q as $pages, aZ as RuntimeContextHelpers, bm as ToastContainer, E as ExecuteInstance, bn as getInitPlatform, t as EditorInstance, a1 as $applicationPages, Z as $currentPage } from './BaseElement-BNBn_IJk.js';
2
- import { css, nothing, html, LitElement as LitElement$1 } from 'lit';
1
+ import { $ as $components, q as $pages, aX as eventDispatcher, b0 as RuntimeContextHelpers, a4 as ViewMode, w as $applicationComponents, bn as ToastContainer, E as ExecuteInstance, bo as getInitPlatform, t as EditorInstance, a0 as $microAppCurrentPage, a1 as $applicationPages, Z as $currentPage, aM as renderComponent } from './BaseElement-pS6m_x6Q.js';
2
+ import { css, LitElement, nothing, html } from 'lit';
3
3
  import { property, state, customElement } from 'lit/decorators.js';
4
+ import './TextLabel-DkV26yaL.js';
5
+ import './Container-DMNh5U4Y.js';
6
+ import { Subscription, merge, Observable } from 'rxjs';
4
7
  import { styleMap } from 'lit/directives/style-map.js';
5
- import { classMap } from 'lit/directives/class-map.js';
6
- import { createRef, ref } from 'lit/directives/ref.js';
7
- import { PanelMode, PanelSize, PanelPosition, MaximizePosition } from '@nuralyui/panel';
8
- import '@nuralyui/grid';
9
- import '@nuralyui/color-picker';
10
- import '@nuralyui/select';
11
- import '@nuralyui/radio-group';
12
- import '@nuralyui/icon';
13
- import '@nuralyui/label';
14
8
  import { v4 } from 'uuid';
15
- import { css as css$1, LitElement, html as html$1 } from 'lit-element';
16
- import { unsafeHTML } from 'lit/directives/unsafe-html.js';
17
- import { Subscription, merge, Observable } from 'rxjs';
18
9
  import { deepMap, map, atom } from 'nanostores';
19
10
  import deepEqual from 'fast-deep-equal';
20
11
 
21
- var __defProp$C = Object.defineProperty;
22
- var __getOwnPropDesc$E = Object.getOwnPropertyDescriptor;
23
- var __decorateClass$E = (decorators, target, key, kind) => {
24
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$E(target, key) : target;
25
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
26
- if (decorator = decorators[i])
27
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
28
- if (kind && result) __defProp$C(target, key, result);
29
- return result;
30
- };
31
- try {
32
- await import('@nuralyui/tabs');
33
- } catch (error) {
34
- console.warn("[@nuralyui/tabs] Package not found or failed to load. Tab functionality may be limited.");
35
- }
36
- let TabsBlock = class extends BaseElementBlock {
37
- constructor() {
38
- super();
39
- this.editableTabs = [];
40
- this.componentsWithChildren = [];
41
- this.registerCallback("tabs", () => {
42
- this.updateComponents();
43
- this.editableTabs = this.generateTabs();
44
- });
45
- }
46
- update(changedProperties) {
47
- super.update(changedProperties);
48
- if (changedProperties.has("component")) {
49
- this.updateComponents();
50
- }
51
- }
52
- renderComponent() {
53
- const tabStyle = this.getStyles();
54
- return html`
55
- ${this.editableTabs?.length > 0 ? html`
56
- <nr-tabs
57
- style=${styleMap({
58
- ...tabStyle
59
- })}
60
- .activeTab=${this.inputHandlersValue.index ?? 0}
61
- .tabs=${this.editableTabs}
62
- size=${this.inputHandlersValue?.size ?? "medium"}
63
- align=${this.inputHandlersValue?.align ?? nothing}
64
- .panelConfig=${this.inputHandlersValue?.panelConfig ?? nothing}
65
- .popOut=${this.inputHandlersValue?.popOut ?? nothing}
66
- @nr-tab-click=${(e) => {
67
- this.executeEvent("onTabChanged", e, {
68
- tab: this.editableTabs.find((tab, index) => index === e.detail.index)
69
- });
70
- }}
71
- @nr-tabs-panel-close=${(e) => {
72
- this.executeEvent("onPanelClose", e);
73
- }}
74
- @nr-tabs-panel-minimize=${(e) => {
75
- this.executeEvent("onPanelMinimize", e);
76
- }}
77
- @nr-tabs-panel-resize=${(e) => {
78
- this.executeEvent("onPanelResize", e);
79
- }}
80
- @nr-tab-pop-out=${(e) => {
81
- this.executeEvent("onTabPopOut", e, {
82
- tab: e.detail.tab,
83
- index: e.detail.index,
84
- popOutId: e.detail.popOutId
85
- });
86
- }}
87
- @nr-tab-pop-in=${(e) => {
88
- this.executeEvent("onTabPopIn", e, {
89
- tab: e.detail.tab,
90
- originalIndex: e.detail.originalIndex,
91
- popOutId: e.detail.popOutId
92
- });
93
- }}
94
- .editable=${{
95
- canDeleteTab: false,
96
- canEditTabTitle: false,
97
- canAddTab: false,
98
- canMove: false
99
- }}
100
- ></nr-tabs>
101
- ` : EMPTY_STRING}
102
- `;
103
- }
104
- generateComponent(childrensIds) {
105
- const childrens = childrensIds?.map(
106
- (id) => this.componentsWithChildren.find((component) => component.uuid === id)
107
- ).filter(Boolean) || [];
108
- return html`${renderComponent(childrens, null, true)}`;
109
- }
110
- generateTabs() {
111
- return this.inputHandlersValue.tabs?.map((tab) => ({
112
- label: tab.label.value,
113
- key: tab.key,
114
- icon: tab.icon?.value || null,
115
- content: html`
116
- <div>${this.generateComponent(tab.childrends.value)}</div>`
117
- }));
118
- }
119
- updateComponents() {
120
- const components = $applicationComponents(this.component.application_id).get();
121
- this.componentsWithChildren = [...components];
122
- }
123
- };
124
- TabsBlock.styles = css`
125
- :host {
126
- display: block;
127
- height: 100%;
128
- /* CSS variables for tab text alignment customization */
129
- --nuraly-tabs-text-align: center; /* Default center alignment */
130
- }
131
- `;
132
- __decorateClass$E([
133
- property({ type: Object, reflect: false })
134
- ], TabsBlock.prototype, "component", 2);
135
- __decorateClass$E([
136
- state()
137
- ], TabsBlock.prototype, "editableTabs", 2);
138
- __decorateClass$E([
139
- state()
140
- ], TabsBlock.prototype, "componentsWithChildren", 2);
141
- TabsBlock = __decorateClass$E([
142
- customElement("tabs-block")
143
- ], TabsBlock);
144
-
145
- const styles$5 = css`
146
- :host{
147
- display: block;
148
- }
149
-
150
- .container {
151
- /* --container-bg-color-local: var(--container-bg-color); */
152
- display: flex;
153
- width: fit-content;
154
- min-height: 300px;
155
- height: 100%;
156
- flex-wrap: wrap;
157
- /* background-color: var(--container-bg-color-local, var(--container-bg-color)); */
158
- }
159
-
160
- .boxed{
161
- margin-inline-start: auto;
162
- margin-inline-end: auto;
163
- }
164
-
165
- .vertical {
166
- flex-direction: column;
167
- }
168
-
169
- .empty-message-container {
170
- display: flex;
171
- justify-content: center;
172
- align-items: center;
173
- width: 100%;
174
- height:100%
175
- }
176
-
177
- .container-placeholder {
178
- display: flex;
179
- flex-direction: column;
180
- align-items: center;
181
- justify-content: center;
182
- color: #64748b;
183
- min-height: 200px;
184
- width: 100%;
185
- border-radius: 8px;
186
- border: 2px dashed #cbd5e1;
187
- gap: 12px;
188
- cursor: pointer;
189
- }
190
-
191
- .container-placeholder nr-icon {
192
- --nuraly-icon-size: 48px;
193
- }
194
- `;
195
-
196
- var __defProp$B = Object.defineProperty;
197
- var __getOwnPropDesc$D = Object.getOwnPropertyDescriptor;
198
- var __decorateClass$D = (decorators, target, key, kind) => {
199
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$D(target, key) : target;
200
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
201
- if (decorator = decorators[i])
202
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
203
- if (kind && result) __defProp$B(target, key, result);
204
- return result;
205
- };
206
- let VerticalContainer = class extends BaseElementBlock {
207
- constructor() {
208
- super(...arguments);
209
- this.isViewMode = false;
210
- this.dragOverSituation = false;
211
- this.wrapperStyle = {};
212
- this.containerRef = createRef();
213
- this.childrenComponents = [];
214
- }
215
- connectedCallback() {
216
- super.connectedCallback();
217
- this.updateChildrenComponents();
218
- }
219
- willUpdate(changedProperties) {
220
- super.willUpdate(changedProperties);
221
- if (changedProperties.has("component")) {
222
- this.updateChildrenComponents();
223
- }
224
- }
225
- updateChildrenComponents() {
226
- this.childrenComponents = this.component?.childrenIds?.map((id) => {
227
- return $components.get()[this.component?.application_id]?.find((component) => component.uuid === id);
228
- }) ?? [];
229
- }
230
- renderView() {
231
- return html`
232
- <div
233
- id=${this.inputHandlersValue.id ?? nothing}
234
- ${ref(this.inputRef)}
235
- data-component-uuid=${this.component?.uuid}
236
- data-component-name=${this.component?.name}
237
- style=${styleMap({
238
- "width": RuntimeHelpers.extractUnit(this.componentStyles?.width) === "%" ? "100%" : this.componentStyles?.width ?? "auto",
239
- ...this.getStyles(),
240
- "min-height": this.childrenComponents.length ? "auto" : "300px"
241
- })}
242
- class=${classMap({
243
- container: true,
244
- vertical: this.inputHandlersValue.direction === "vertical",
245
- boxed: this.inputHandlersValue.layout === "boxed",
246
- "drag-over": this.dragOverSituation
247
- })}
248
- @mouseenter="${(e) => this.executeEvent("onMouseEnter", { ...e, unique: this.uniqueUUID })}"
249
- @mouseleave="${(e) => this.executeEvent("onMouseLeave", { ...e, unique: this.uniqueUUID })}"
250
- @click="${(e) => this.executeEvent("onClick", e)}"
251
- >
252
- ${this.childrenComponents.length ? renderComponent(this.childrenComponents.map((component) => ({ ...component, item: this.item })), this.item, this.isViewMode, { ...this.component, uniqueUUID: this.uniqueUUID }) : html`
253
- <div class="container-placeholder">
254
- <nr-icon name="layout-grid"></nr-icon>
255
- <nr-label>No content</nr-label>
256
- </div>
257
- `}
258
- </div>
259
- `;
260
- }
261
- renderComponent() {
262
- return html`
263
- ${this.isViewMode ? this.renderView() : html`
264
- <div
265
- ${ref(this.inputRef)}
266
- data-component-uuid=${this.component?.uuid}
267
- data-component-name=${this.component?.name}
268
- ${ref(this.containerRef)}
269
- @click="${(e) => {
270
- setContextMenuEvent(null);
271
- this.executeEvent("onClick", e);
272
- }}"
273
- style=${styleMap({
274
- ...this.getStyles(),
275
- "min-height": this.childrenComponents.length ? "auto" : "300px"
276
- })}
277
- class=${classMap({
278
- container: true,
279
- vertical: this.inputHandlersValue.direction === "vertical",
280
- horizontal: this.inputHandlersValue.direction !== "vertical",
281
- boxed: this.inputHandlersValue.layout == "boxed"
282
- })}
283
- >
284
- ${this.childrenComponents.length ? renderComponent(this.childrenComponents.map((component) => ({ ...component, item: this.item })), this.item, this.isViewMode, { ...this.component, uniqueUUID: this.uniqueUUID }) : html`
285
- <div
286
- class="container-placeholder"
287
- @click="${() => setCurrentComponentIdAction(this.component?.uuid)}"
288
- >
289
- <nr-icon name="layout-grid"></nr-icon>
290
- <nr-label>Add or drag an item into this container</nr-label>
291
- <drag-wrapper
292
- .where=${"inside"}
293
- .message=${"Drop inside"}
294
- .component=${{ ...this.component }}
295
- .inputRef=${this.inputRef}
296
- .isDragInitiator=${this.isDragInitiator}
297
- >
298
- </drag-wrapper>
299
- </div>
300
- `}
301
- </div>
302
- `}
303
- `;
304
- }
305
- };
306
- VerticalContainer.styles = styles$5;
307
- __decorateClass$D([
308
- property({ type: Object })
309
- ], VerticalContainer.prototype, "component", 2);
310
- __decorateClass$D([
311
- property({ type: Object })
312
- ], VerticalContainer.prototype, "item", 2);
313
- __decorateClass$D([
314
- property({ type: Object })
315
- ], VerticalContainer.prototype, "draggingComponentInfo", 2);
316
- __decorateClass$D([
317
- property({ type: Boolean })
318
- ], VerticalContainer.prototype, "isViewMode", 2);
319
- __decorateClass$D([
320
- state()
321
- ], VerticalContainer.prototype, "dragOverSituation", 2);
322
- __decorateClass$D([
323
- state()
324
- ], VerticalContainer.prototype, "selectedComponent", 2);
325
- __decorateClass$D([
326
- state()
327
- ], VerticalContainer.prototype, "hoveredComponent", 2);
328
- __decorateClass$D([
329
- state()
330
- ], VerticalContainer.prototype, "wrapperStyle", 2);
331
- __decorateClass$D([
332
- state()
333
- ], VerticalContainer.prototype, "containerRef", 2);
334
- __decorateClass$D([
335
- state()
336
- ], VerticalContainer.prototype, "childrenComponents", 2);
337
- VerticalContainer = __decorateClass$D([
338
- customElement("vertical-container-block")
339
- ], VerticalContainer);
340
-
341
- var __defProp$A = Object.defineProperty;
342
- var __getOwnPropDesc$C = Object.getOwnPropertyDescriptor;
343
- var __decorateClass$C = (decorators, target, key, kind) => {
344
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$C(target, key) : target;
345
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
346
- if (decorator = decorators[i])
347
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
348
- if (kind && result) __defProp$A(target, key, result);
349
- return result;
350
- };
351
- try {
352
- await import('@nuralyui/card');
353
- } catch (error) {
354
- console.warn("[@nuralyui/card] Package not found or failed to load.");
355
- }
356
- let CardBlock = class extends BaseElementBlock {
357
- constructor() {
358
- super(...arguments);
359
- this.isViewMode = false;
360
- this.childrenComponents = [];
361
- this.dragOverSituation = false;
362
- }
363
- connectedCallback() {
364
- super.connectedCallback();
365
- this.updateChildrenComponents();
366
- }
367
- willUpdate(changedProperties) {
368
- super.willUpdate(changedProperties);
369
- if (changedProperties.has("component")) {
370
- this.updateChildrenComponents();
371
- }
372
- }
373
- updateChildrenComponents() {
374
- this.childrenComponents = this.component?.childrenIds?.map((id) => {
375
- return $components.get()[this.component?.application_id]?.find((component) => component.uuid === id);
376
- }) ?? [];
377
- }
378
- renderView() {
379
- const cardStyles = this.component?.style || {};
380
- const title = this.component?.input?.title?.value || this.inputHandlersValue?.title || "";
381
- const bordered = this.component?.input?.bordered?.value ?? this.inputHandlersValue?.bordered ?? true;
382
- const hoverable = this.component?.input?.hoverable?.value ?? this.inputHandlersValue?.hoverable ?? false;
383
- const loading = this.component?.input?.loading?.value ?? this.inputHandlersValue?.loading ?? false;
384
- const size = this.component?.input?.size?.value || this.inputHandlersValue?.size || "default";
385
- return html`
386
- <nr-card
387
- id=${this.inputHandlersValue.id ?? nothing}
388
- ${ref(this.inputRef)}
389
- data-component-uuid=${this.component?.uuid}
390
- data-component-name=${this.component?.name}
391
- style=${styleMap({
392
- "width": RuntimeHelpers.extractUnit(cardStyles?.width) === "%" ? "100%" : cardStyles?.width ?? "auto",
393
- ...cardStyles
394
- })}
395
- class=${classMap({
396
- "drag-over": this.dragOverSituation
397
- })}
398
- .header=${title}
399
- .size=${size}
400
- ?bordered=${bordered}
401
- ?hoverable=${hoverable}
402
- ?loading=${loading}
403
- @mouseenter="${(e) => this.executeEvent("onMouseEnter", { ...e, unique: this.uniqueUUID })}"
404
- @mouseleave="${(e) => this.executeEvent("onMouseLeave", { ...e, unique: this.uniqueUUID })}"
405
- @click=${(e) => this.executeEvent("onClick", e)}
406
- >
407
- <div slot="content">
408
- ${this.childrenComponents.length ? renderComponent(this.childrenComponents.map((component) => ({ ...component, item: this.item })), this.item, this.isViewMode, { ...this.component, uniqueUUID: this.uniqueUUID }) : nothing}
409
- </div>
410
- </nr-card>
411
- `;
412
- }
413
- renderComponent() {
414
- const cardStyles = this.component?.style || {};
415
- const title = this.component?.input?.title?.value || this.inputHandlersValue?.title || "";
416
- const bordered = this.component?.input?.bordered?.value ?? this.inputHandlersValue?.bordered ?? true;
417
- const hoverable = this.component?.input?.hoverable?.value ?? this.inputHandlersValue?.hoverable ?? false;
418
- const loading = this.component?.input?.loading?.value ?? this.inputHandlersValue?.loading ?? false;
419
- const size = this.component?.input?.size?.value || this.inputHandlersValue?.size || "default";
420
- return html`
421
- ${this.isViewMode ? this.renderView() : html`
422
- <nr-card
423
- ${ref(this.inputRef)}
424
- data-component-uuid=${this.component?.uuid}
425
- data-component-name=${this.component?.name}
426
- style=${styleMap(cardStyles)}
427
- class=${classMap({
428
- "drag-over": this.dragOverSituation
429
- })}
430
- .header=${title}
431
- .size=${size}
432
- ?bordered=${bordered}
433
- ?hoverable=${hoverable}
434
- ?loading=${loading}
435
- @click=${(e) => {
436
- setContextMenuEvent(null);
437
- this.executeEvent("onClick", e);
438
- }}
439
- >
440
- <div slot="content" style=${styleMap({ "min-height": this.childrenComponents.length ? "auto" : "100px" })}>
441
- ${this.childrenComponents.length ? renderComponent(this.childrenComponents.map((component) => ({ ...component, item: this.item })), this.item, this.isViewMode, { ...this.component, uniqueUUID: this.uniqueUUID }) : html`
442
- <div
443
- style="padding: 20px; text-align: center; color: #999;"
444
- @click="${() => setCurrentComponentIdAction(this.component?.uuid)}"
445
- >
446
- Add or Drag an item into this card
447
- <drag-wrapper
448
- .where=${"inside"}
449
- .message=${"Drop inside"}
450
- .component=${{ ...this.component }}
451
- .inputRef=${this.inputRef}
452
- .isDragInitiator=${this.isDragInitiator}
453
- >
454
- </drag-wrapper>
455
- </div>
456
- `}
457
- </div>
458
- </nr-card>
459
- `}
460
- `;
461
- }
462
- };
463
- CardBlock.styles = [css``];
464
- __decorateClass$C([
465
- property({ type: Object })
466
- ], CardBlock.prototype, "component", 2);
467
- __decorateClass$C([
468
- property({ type: Object })
469
- ], CardBlock.prototype, "item", 2);
470
- __decorateClass$C([
471
- property({ type: Boolean })
472
- ], CardBlock.prototype, "isViewMode", 2);
473
- __decorateClass$C([
474
- state()
475
- ], CardBlock.prototype, "childrenComponents", 2);
476
- __decorateClass$C([
477
- state()
478
- ], CardBlock.prototype, "dragOverSituation", 2);
479
- CardBlock = __decorateClass$C([
480
- customElement("card-block")
481
- ], CardBlock);
482
-
483
- var __defProp$z = Object.defineProperty;
484
- var __getOwnPropDesc$B = Object.getOwnPropertyDescriptor;
485
- var __decorateClass$B = (decorators, target, key, kind) => {
486
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$B(target, key) : target;
487
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
488
- if (decorator = decorators[i])
489
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
490
- if (kind && result) __defProp$z(target, key, result);
491
- return result;
492
- };
493
- try {
494
- await import('@nuralyui/panel');
495
- } catch (error) {
496
- console.warn("[@nuralyui/panel] Package not found or failed to load. Panel functionality may be limited.");
497
- }
498
- let PanelBlock = class extends BaseElementBlock {
499
- constructor() {
500
- super(...arguments);
501
- this.isViewMode = false;
502
- this.childrenComponents = [];
503
- }
504
- connectedCallback() {
505
- super.connectedCallback();
506
- this.updateChildrenComponents();
507
- }
508
- updated(changedProperties) {
509
- super.updated(changedProperties);
510
- if (changedProperties.has("component")) {
511
- this.updateChildrenComponents();
512
- }
513
- }
514
- updateChildrenComponents() {
515
- this.childrenComponents = this.component?.childrenIds?.map((id) => {
516
- return $components.get()[this.component?.application_id]?.find((component) => component.uuid === id);
517
- }) ?? [];
518
- }
519
- renderComponent() {
520
- const panelStyles = this.component?.style || {};
521
- const mode = this.component?.input?.mode?.value || this.inputHandlersValue?.mode || PanelMode.Panel;
522
- const size = this.component?.input?.size?.value || this.inputHandlersValue?.size || PanelSize.Medium;
523
- const position = this.component?.input?.position?.value || this.inputHandlersValue?.position || PanelPosition.Right;
524
- const maximizePosition = this.component?.input?.maximizePosition?.value || this.inputHandlersValue?.maximizePosition || MaximizePosition.Center;
525
- const draggable = this.component?.input?.draggable?.value ?? this.inputHandlersValue?.draggable ?? true;
526
- const resizable = this.component?.input?.resizable?.value ?? this.inputHandlersValue?.resizable ?? false;
527
- const collapsible = this.component?.input?.collapsible?.value ?? this.inputHandlersValue?.collapsible ?? false;
528
- const minimizable = this.component?.input?.minimizable?.value ?? this.inputHandlersValue?.minimizable ?? true;
529
- const closable = this.component?.input?.closable?.value ?? this.inputHandlersValue?.closable ?? true;
530
- const animated = this.component?.input?.animated?.value ?? this.inputHandlersValue?.animated ?? false;
531
- const title = this.component?.input?.title?.value || this.inputHandlersValue?.title || "";
532
- const icon = this.component?.input?.icon?.value || this.inputHandlersValue?.icon || "";
533
- const width = this.component?.input?.width?.value || this.inputHandlersValue?.width || "";
534
- const height = this.component?.input?.height?.value || this.inputHandlersValue?.height || "";
535
- const open = this.component?.input?.open?.value ?? this.inputHandlersValue?.open ?? true;
536
- return html`
537
- <nr-panel
538
- ${ref(this.inputRef)}
539
- style=${styleMap(panelStyles)}
540
- .mode=${mode}
541
- .size=${size}
542
- .position=${position}
543
- .maximizePosition=${maximizePosition}
544
- ?draggable=${draggable}
545
- ?resizable=${resizable}
546
- ?collapsible=${collapsible}
547
- ?minimizable=${minimizable}
548
- ?closable=${closable}
549
- ?animated=${animated}
550
- .title=${title}
551
- .icon=${icon}
552
- .width=${width}
553
- .height=${height}
554
- ?open=${open}
555
- @panel-mode-change=${(e) => {
556
- this.executeEvent("onPanelModeChange", e);
557
- }}
558
- @panel-close=${(e) => {
559
- this.executeEvent("onPanelClose", e);
560
- }}
561
- @panel-minimize=${(e) => {
562
- this.executeEvent("onPanelMinimize", e);
563
- }}
564
- @panel-maximize=${(e) => {
565
- this.executeEvent("onPanelMaximize", e);
566
- }}
567
- @panel-drag-start=${(e) => {
568
- this.executeEvent("onPanelDragStart", e);
569
- }}
570
- @panel-drag-end=${(e) => {
571
- this.executeEvent("onPanelDragEnd", e);
572
- }}
573
- @panel-resize=${(e) => {
574
- this.executeEvent("onPanelResize", e);
575
- }}
576
- @panel-maximize-embedded=${(e) => {
577
- this.executeEvent("onPanelMaximizeEmbedded", e);
578
- }}
579
- @panel-restore-embedded=${(e) => {
580
- this.executeEvent("onPanelRestoreEmbedded", e);
581
- }}
582
- >
583
- ${this.childrenComponents.length ? renderComponent(
584
- this.childrenComponents.map((component) => ({ ...component, item: this.item })),
585
- this.item,
586
- this.isViewMode,
587
- { ...this.component, uniqueUUID: this.uniqueUUID }
588
- ) : nothing}
589
- ${this.renderHeaderSlot()}
590
- ${this.renderFooterSlot()}
591
- </nr-panel>
592
- `;
593
- }
594
- /**
595
- * Render custom header slot if content is provided
596
- */
597
- renderHeaderSlot() {
598
- const headerContent = this.component?.input?.headerContent?.value || this.inputHandlersValue?.headerContent;
599
- if (!headerContent) return nothing;
600
- return html`
601
- <div slot="header">
602
- ${headerContent}
603
- </div>
604
- `;
605
- }
606
- /**
607
- * Render custom footer slot if content is provided
608
- */
609
- renderFooterSlot() {
610
- const footerContent = this.component?.input?.footerContent?.value || this.inputHandlersValue?.footerContent;
611
- if (!footerContent) return nothing;
612
- return html`
613
- <div slot="footer">
614
- ${footerContent}
615
- </div>
616
- `;
617
- }
618
- };
619
- PanelBlock.styles = [css``];
620
- __decorateClass$B([
621
- property({ type: Object })
622
- ], PanelBlock.prototype, "component", 2);
623
- __decorateClass$B([
624
- property({ type: Object })
625
- ], PanelBlock.prototype, "item", 2);
626
- __decorateClass$B([
627
- property({ type: Boolean })
628
- ], PanelBlock.prototype, "isViewMode", 2);
629
- __decorateClass$B([
630
- state()
631
- ], PanelBlock.prototype, "childrenComponents", 2);
632
- PanelBlock = __decorateClass$B([
633
- customElement("panel-block")
634
- ], PanelBlock);
635
-
636
- const styles$4 = css`
637
- :host {
638
- display: block;
639
- width: 100%;
640
- }
641
-
642
- .grid-row {
643
- display: flex;
644
- flex-flow: row wrap;
645
- min-width: 0;
646
- width: 100%;
647
- }
648
-
649
- .grid-row.no-wrap {
650
- flex-wrap: nowrap;
651
- }
652
-
653
- /* Alignment */
654
- .grid-row.align-top {
655
- align-items: flex-start;
656
- }
657
-
658
- .grid-row.align-middle {
659
- align-items: center;
660
- }
661
-
662
- .grid-row.align-bottom {
663
- align-items: flex-end;
664
- }
665
-
666
- .grid-row.align-stretch {
667
- align-items: stretch;
668
- }
669
-
670
- /* Justify */
671
- .grid-row.justify-start {
672
- justify-content: flex-start;
673
- }
674
-
675
- .grid-row.justify-end {
676
- justify-content: flex-end;
677
- }
678
-
679
- .grid-row.justify-center {
680
- justify-content: center;
681
- }
682
-
683
- .grid-row.justify-space-around {
684
- justify-content: space-around;
685
- }
686
-
687
- .grid-row.justify-space-between {
688
- justify-content: space-between;
689
- }
690
-
691
- .grid-row.justify-space-evenly {
692
- justify-content: space-evenly;
693
- }
694
-
695
- .empty-message {
696
- display: flex;
697
- justify-content: center;
698
- align-items: center;
699
- width: 100%;
700
- min-height: 100px;
701
- border: 2px dashed #ccc;
702
- color: #999;
703
- font-size: 14px;
704
- position: relative;
705
- }
706
- `;
707
-
708
- var __defProp$y = Object.defineProperty;
709
- var __getOwnPropDesc$A = Object.getOwnPropertyDescriptor;
710
- var __decorateClass$A = (decorators, target, key, kind) => {
711
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$A(target, key) : target;
712
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
713
- if (decorator = decorators[i])
714
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
715
- if (kind && result) __defProp$y(target, key, result);
716
- return result;
717
- };
718
- const ROW_INPUT_PROPS = ["gutter", "align", "justify", "wrap"];
719
- let GridRow = class extends BaseElementBlock {
720
- constructor() {
721
- super(...arguments);
722
- this.isViewMode = false;
723
- this.childrenComponents = [];
724
- this.containerRef = createRef();
725
- }
726
- connectedCallback() {
727
- super.connectedCallback();
728
- this.updateChildrenComponents();
729
- ROW_INPUT_PROPS.forEach((prop) => this.registerCallback(prop, () => this.requestUpdate()));
730
- }
731
- willUpdate(changedProperties) {
732
- super.willUpdate(changedProperties);
733
- if (changedProperties.has("component")) {
734
- this.updateChildrenComponents();
735
- }
736
- }
737
- updateChildrenComponents() {
738
- this.childrenComponents = this.component?.childrenIds?.map((id) => {
739
- return $components.get()[this.component?.application_id]?.find((component) => component.uuid === id);
740
- }).filter(Boolean) ?? [];
741
- }
742
- /**
743
- * Parse gutter value - supports number, [h, v] array, or responsive object
744
- */
745
- parseGutter(gutter) {
746
- if (!gutter) return 0;
747
- if (typeof gutter === "number" || Array.isArray(gutter)) return gutter;
748
- if (typeof gutter === "string" && !isNaN(Number(gutter))) return Number(gutter);
749
- return gutter;
750
- }
751
- /**
752
- * Get all row properties from input handlers
753
- */
754
- getRowProps() {
755
- const input = this.inputHandlersValue;
756
- return {
757
- gutter: this.parseGutter(input?.gutter),
758
- align: input?.align || "",
759
- justify: input?.justify || "",
760
- wrap: input?.wrap !== false
761
- };
762
- }
763
- /**
764
- * Render children components
765
- */
766
- renderChildren() {
767
- return this.childrenComponents.length ? renderComponent(
768
- this.childrenComponents.map((component) => ({ ...component, item: this.item })),
769
- this.item,
770
- this.isViewMode,
771
- { ...this.component, uniqueUUID: this.uniqueUUID }
772
- ) : nothing;
773
- }
774
- /**
775
- * Render empty state placeholder for editor mode
776
- */
777
- renderEmptyState() {
778
- return html`
779
- <div
780
- class="empty-message"
781
- @click="${() => setCurrentComponentIdAction(this.component?.uuid)}"
782
- >
783
- Add Grid Columns (nr-col) to this row
784
- <drag-wrapper
785
- .where=${"inside"}
786
- .message=${"Drop inside"}
787
- .component=${{ ...this.component }}
788
- .inputRef=${this.inputRef}
789
- .isDragInitiator=${this.isDragInitiator}
790
- >
791
- </drag-wrapper>
792
- </div>
793
- `;
794
- }
795
- renderComponent() {
796
- const props = this.getRowProps();
797
- if (this.isViewMode) {
798
- return html`
799
- <nr-row
800
- ${ref(this.inputRef)}
801
- data-component-uuid=${this.component?.uuid}
802
- data-component-name=${this.component?.name}
803
- style=${styleMap(this.getStyles())}
804
- .gutter=${props.gutter}
805
- align=${props.align || nothing}
806
- justify=${props.justify || nothing}
807
- ?wrap=${props.wrap}
808
- >
809
- ${this.renderChildren()}
810
- </nr-row>
811
- `;
812
- }
813
- return html`
814
- <nr-row
815
- ${ref(this.inputRef)}
816
- ${ref(this.containerRef)}
817
- data-component-uuid=${this.component?.uuid}
818
- data-component-name=${this.component?.name}
819
- @click="${(e) => {
820
- setContextMenuEvent(null);
821
- this.executeEvent("onClick", e);
822
- }}"
823
- style=${styleMap({
824
- ...this.getStyles(),
825
- "min-height": this.childrenComponents.length ? "auto" : "100px"
826
- })}
827
- .gutter=${props.gutter}
828
- align=${props.align || nothing}
829
- justify=${props.justify || nothing}
830
- ?wrap=${props.wrap}
831
- >
832
- ${this.childrenComponents.length ? this.renderChildren() : this.renderEmptyState()}
833
- </nr-row>
834
- `;
835
- }
836
- };
837
- GridRow.styles = styles$4;
838
- __decorateClass$A([
839
- property({ type: Object })
840
- ], GridRow.prototype, "component", 2);
841
- __decorateClass$A([
842
- property({ type: Object })
843
- ], GridRow.prototype, "item", 2);
844
- __decorateClass$A([
845
- property({ type: Boolean })
846
- ], GridRow.prototype, "isViewMode", 2);
847
- __decorateClass$A([
848
- state()
849
- ], GridRow.prototype, "childrenComponents", 2);
850
- __decorateClass$A([
851
- state()
852
- ], GridRow.prototype, "containerRef", 2);
853
- GridRow = __decorateClass$A([
854
- customElement("grid-row-block")
855
- ], GridRow);
856
-
857
- const styles$3 = css`
858
- :host {
859
- display: block;
860
- }
861
-
862
- .grid-col {
863
- position: relative;
864
- box-sizing: border-box;
865
- width: 100%;
866
- min-height: 1px;
867
- }
868
-
869
- .empty-message {
870
- display: flex;
871
- justify-content: center;
872
- align-items: center;
873
- width: 100%;
874
- min-height: 60px;
875
- border: 1px dashed #ccc;
876
- color: #999;
877
- font-size: 12px;
878
- position: relative;
879
- background: rgba(0, 0, 0, 0.02);
880
- }
881
- `;
882
-
883
- var __defProp$x = Object.defineProperty;
884
- var __getOwnPropDesc$z = Object.getOwnPropertyDescriptor;
885
- var __decorateClass$z = (decorators, target, key, kind) => {
886
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$z(target, key) : target;
887
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
888
- if (decorator = decorators[i])
889
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
890
- if (kind && result) __defProp$x(target, key, result);
891
- return result;
892
- };
893
- const COL_INPUT_PROPS = ["span", "offset", "order", "pull", "push", "flex", "xs", "sm", "md", "lg", "xl", "xxl"];
894
- let GridCol = class extends BaseElementBlock {
895
- constructor() {
896
- super(...arguments);
897
- this.isViewMode = false;
898
- this.childrenComponents = [];
899
- this.containerRef = createRef();
900
- }
901
- connectedCallback() {
902
- super.connectedCallback();
903
- this.updateChildrenComponents();
904
- COL_INPUT_PROPS.forEach((prop) => this.registerCallback(prop, () => this.requestUpdate()));
905
- }
906
- willUpdate(changedProperties) {
907
- super.willUpdate(changedProperties);
908
- if (changedProperties.has("component")) {
909
- this.updateChildrenComponents();
910
- }
911
- }
912
- updateChildrenComponents() {
913
- this.childrenComponents = this.component?.childrenIds?.map((id) => {
914
- return $components.get()[this.component?.application_id]?.find((component) => component.uuid === id);
915
- }).filter(Boolean) ?? [];
916
- }
917
- /**
918
- * Parse numeric value from input (handles string or number)
919
- */
920
- parseNumeric(value, defaultValue) {
921
- if (value === void 0 || value === null || value === "") return defaultValue;
922
- const num = Number(value);
923
- return isNaN(num) ? defaultValue : num;
924
- }
925
- /**
926
- * Parse responsive breakpoint value
927
- * Can be a number or an object { span, offset, order, pull, push }
928
- */
929
- parseBreakpoint(value) {
930
- if (value === void 0 || value === null || value === "") return void 0;
931
- if (typeof value === "number") return value;
932
- if (typeof value === "string" && !isNaN(Number(value))) return Number(value);
933
- if (typeof value === "object") return value;
934
- return void 0;
935
- }
936
- /**
937
- * Get all column properties from input handlers
938
- */
939
- getColProps() {
940
- const input = this.inputHandlersValue;
941
- return {
942
- span: this.parseNumeric(input?.span),
943
- offset: this.parseNumeric(input?.offset, 0),
944
- order: this.parseNumeric(input?.order),
945
- pull: this.parseNumeric(input?.pull, 0),
946
- push: this.parseNumeric(input?.push, 0),
947
- flex: input?.flex || "",
948
- xs: this.parseBreakpoint(input?.xs),
949
- sm: this.parseBreakpoint(input?.sm),
950
- md: this.parseBreakpoint(input?.md),
951
- lg: this.parseBreakpoint(input?.lg),
952
- xl: this.parseBreakpoint(input?.xl),
953
- xxl: this.parseBreakpoint(input?.xxl)
954
- };
955
- }
956
- /**
957
- * Render children components
958
- */
959
- renderChildren() {
960
- return this.childrenComponents.length ? renderComponent(
961
- this.childrenComponents.map((component) => ({ ...component, item: this.item })),
962
- this.item,
963
- this.isViewMode,
964
- { ...this.component, uniqueUUID: this.uniqueUUID }
965
- ) : nothing;
966
- }
967
- /**
968
- * Render empty state placeholder for editor mode
969
- */
970
- renderEmptyState() {
971
- return html`
972
- <div
973
- class="empty-message"
974
- @click="${() => setCurrentComponentIdAction(this.component?.uuid)}"
975
- >
976
- Drop content here
977
- <drag-wrapper
978
- .where=${"inside"}
979
- .message=${"Drop inside"}
980
- .component=${{ ...this.component }}
981
- .inputRef=${this.inputRef}
982
- .isDragInitiator=${this.isDragInitiator}
983
- >
984
- </drag-wrapper>
985
- </div>
986
- `;
987
- }
988
- renderComponent() {
989
- const props = this.getColProps();
990
- if (this.isViewMode) {
991
- return html`
992
- <nr-col
993
- ${ref(this.inputRef)}
994
- data-component-uuid=${this.component?.uuid}
995
- data-component-name=${this.component?.name}
996
- style=${styleMap(this.getStyles())}
997
- span=${props.span ?? nothing}
998
- offset=${props.offset}
999
- order=${props.order ?? nothing}
1000
- pull=${props.pull}
1001
- push=${props.push}
1002
- flex=${props.flex || nothing}
1003
- .xs=${props.xs}
1004
- .sm=${props.sm}
1005
- .md=${props.md}
1006
- .lg=${props.lg}
1007
- .xl=${props.xl}
1008
- .xxl=${props.xxl}
1009
- >
1010
- ${this.renderChildren()}
1011
- </nr-col>
1012
- `;
1013
- }
1014
- return html`
1015
- <nr-col
1016
- ${ref(this.inputRef)}
1017
- ${ref(this.containerRef)}
1018
- data-component-uuid=${this.component?.uuid}
1019
- data-component-name=${this.component?.name}
1020
- @click="${(e) => {
1021
- setContextMenuEvent(null);
1022
- this.executeEvent("onClick", e);
1023
- }}"
1024
- style=${styleMap({
1025
- ...this.getStyles(),
1026
- "min-height": this.childrenComponents.length ? "auto" : "60px"
1027
- })}
1028
- span=${props.span ?? nothing}
1029
- offset=${props.offset}
1030
- order=${props.order ?? nothing}
1031
- pull=${props.pull}
1032
- push=${props.push}
1033
- flex=${props.flex || nothing}
1034
- .xs=${props.xs}
1035
- .sm=${props.sm}
1036
- .md=${props.md}
1037
- .lg=${props.lg}
1038
- .xl=${props.xl}
1039
- .xxl=${props.xxl}
1040
- >
1041
- ${this.childrenComponents.length ? this.renderChildren() : this.renderEmptyState()}
1042
- </nr-col>
1043
- `;
1044
- }
1045
- };
1046
- GridCol.styles = styles$3;
1047
- __decorateClass$z([
1048
- property({ type: Object })
1049
- ], GridCol.prototype, "component", 2);
1050
- __decorateClass$z([
1051
- property({ type: Object })
1052
- ], GridCol.prototype, "item", 2);
1053
- __decorateClass$z([
1054
- property({ type: Boolean })
1055
- ], GridCol.prototype, "isViewMode", 2);
1056
- __decorateClass$z([
1057
- state()
1058
- ], GridCol.prototype, "childrenComponents", 2);
1059
- __decorateClass$z([
1060
- state()
1061
- ], GridCol.prototype, "containerRef", 2);
1062
- GridCol = __decorateClass$z([
1063
- customElement("grid-col-block")
1064
- ], GridCol);
1065
-
1066
- var __defProp$w = Object.defineProperty;
1067
- var __getOwnPropDesc$y = Object.getOwnPropertyDescriptor;
1068
- var __decorateClass$y = (decorators, target, key, kind) => {
1069
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$y(target, key) : target;
1070
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
1071
- if (decorator = decorators[i])
1072
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1073
- if (kind && result) __defProp$w(target, key, result);
1074
- return result;
1075
- };
1076
- try {
1077
- await import('@nuralyui/menu');
1078
- } catch (error) {
1079
- console.warn("[@nuralyui/menu] Package not found or failed to load. Menu functionality may be limited.");
1080
- }
1081
- let MenuBlock = class extends BaseElementBlock {
1082
- constructor() {
1083
- super();
1084
- }
1085
- renderComponent() {
1086
- return html`
1087
-
1088
- <nr-menu
1089
- ${ref(this.inputRef)}
1090
- class="${`drop-${this.component.uuid}`}"
1091
-
1092
-
1093
- placeholder="Select an option"
1094
- size=${this.inputHandlersValue?.size ?? "medium"}
1095
- arrowPosition=${this.inputHandlersValue?.arrowPosition ?? "right"}
1096
- .items=${this.inputHandlersValue?.options ?? []}
1097
- @change="${(e) => {
1098
- const selectedOptionPath = e.detail.path;
1099
- const selectedPage = this.inputHandlersValue.options[selectedOptionPath[0]]?.id;
1100
- const option = selectedOptionPath.reduce((acc, curr) => acc && acc.children && acc.children[curr], { children: this.inputHandlersValue?.options });
1101
- this.executeEvent("onSelect", e, {
1102
- id: option?.id,
1103
- text: option?.text,
1104
- type: option?.type,
1105
- page: selectedPage,
1106
- path: selectedOptionPath,
1107
- value: e.detail.value
1108
- });
1109
- }}"
1110
- @action-click="${(e) => {
1111
- this.executeEvent("onActionClick", e, {
1112
- value: e.detail.additionalData,
1113
- action: e.detail.value
1114
- });
1115
- }}">
1116
- </nr-menu>
1117
- `;
1118
- }
1119
- };
1120
- MenuBlock.styles = [
1121
- css`
1122
- nr-menu {
1123
- --nuraly-menu-width: 100%;
1124
-
1125
- }
1126
- :host {
1127
- display: block;
1128
- }
1129
- .error {
1130
- color: red;
1131
- background-color: black;
1132
- font-size: smaller;
1133
- }
1134
- `
1135
- ];
1136
- __decorateClass$y([
1137
- property({ type: Object, reflect: false })
1138
- ], MenuBlock.prototype, "component", 2);
1139
- MenuBlock = __decorateClass$y([
1140
- customElement("menu-block")
1141
- ], MenuBlock);
1142
-
1143
- var __defProp$v = Object.defineProperty;
1144
- var __getOwnPropDesc$x = Object.getOwnPropertyDescriptor;
1145
- var __decorateClass$x = (decorators, target, key, kind) => {
1146
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$x(target, key) : target;
1147
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
1148
- if (decorator = decorators[i])
1149
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1150
- if (kind && result) __defProp$v(target, key, result);
1151
- return result;
1152
- };
1153
- let EmbedUrlBlock = class extends BaseElementBlock {
1154
- constructor() {
1155
- super();
1156
- this.currentUrl = "";
1157
- this._isUserFocused = false;
1158
- this._focusResetTimeout = null;
1159
- this.iframeRef = ref();
1160
- this.onFocus = (e) => {
1161
- this._isUserFocused = true;
1162
- this.executeEvent("onFocus", e);
1163
- };
1164
- this.onBlur = (e) => {
1165
- this._isUserFocused = false;
1166
- this.executeEvent("onBlur", e);
1167
- };
1168
- }
1169
- firstUpdated(_changedProperties) {
1170
- super.firstUpdated(_changedProperties);
1171
- this.registerCallback("url", (url) => {
1172
- if (!this._isUserFocused && this.currentUrl !== url) {
1173
- this.currentUrl = url ?? "";
1174
- }
1175
- });
1176
- }
1177
- handleIframeLoad(e) {
1178
- this.executeEvent("onLoad", e, {
1179
- url: this.currentUrl || this.inputHandlersValue?.url || ""
1180
- });
1181
- }
1182
- handleIframeError(e) {
1183
- this.executeEvent("onError", e, {
1184
- url: this.currentUrl || this.inputHandlersValue?.url || "",
1185
- error: "Failed to load iframe content"
1186
- });
1187
- }
1188
- resetFocusAfterInactivity() {
1189
- if (this._focusResetTimeout) clearTimeout(this._focusResetTimeout);
1190
- this._focusResetTimeout = setTimeout(() => {
1191
- this._isUserFocused = false;
1192
- }, 3e3);
1193
- }
1194
- disconnectedCallback() {
1195
- super.disconnectedCallback();
1196
- if (this.unsubscribe) this.unsubscribe();
1197
- if (this._focusResetTimeout) clearTimeout(this._focusResetTimeout);
1198
- }
1199
- renderComponent() {
1200
- const embedStyles = this.getStyles() || {};
1201
- const embedStyleHandlers = this.component?.styleHandlers ? Object.fromEntries(
1202
- Object.entries(this.component?.styleHandlers).filter(([key, value]) => value)
1203
- ) : {};
1204
- const url = this.currentUrl || this.inputHandlersValue?.url || "";
1205
- if (!url) {
1206
- return html`
1207
- <div
1208
- ${ref(this.inputRef)}
1209
- class="embed-placeholder"
1210
- style=${styleMap({
1211
- ...this.getStyles(),
1212
- width: embedStyleHandlers?.width || embedStyles?.width || "100%",
1213
- height: embedStyleHandlers?.height || embedStyles?.height || "200px"
1214
- })}
1215
- @click=${(e) => this.executeEvent("onClick", e)}
1216
- >
1217
- <nr-icon name="globe"></nr-icon>
1218
- <nr-label>No URL provided</nr-label>
1219
- </div>
1220
- `;
1221
- }
1222
- return html`
1223
- <div
1224
- ${ref(this.inputRef)}
1225
- tabindex="0"
1226
- @focus=${this.onFocus}
1227
- @blur=${this.onBlur}
1228
- @click=${(e) => this.executeEvent("onClick", e)}
1229
- style=${styleMap(this.getStyles())}
1230
- >
1231
- <iframe
1232
- ${ref(this.iframeRef)}
1233
- src=${url}
1234
- @load=${(e) => this.handleIframeLoad(e)}
1235
- @error=${(e) => this.handleIframeError(e)}
1236
- ></iframe>
1237
- </div>
1238
- `;
1239
- }
1240
- };
1241
- EmbedUrlBlock.styles = [css`
1242
- iframe {
1243
- width: 100%;
1244
- height: 100%;
1245
- border: none;
1246
- }
1247
- .embed-placeholder {
1248
- display: flex;
1249
- flex-direction: column;
1250
- align-items: center;
1251
- justify-content: center;
1252
- color: #64748b;
1253
- min-height: 200px;
1254
- border-radius: 8px;
1255
- border: 2px dashed #cbd5e1;
1256
- gap: 12px;
1257
- }
1258
- .embed-placeholder nr-icon {
1259
- --nuraly-icon-size: 48px;
1260
- }
1261
- `];
1262
- __decorateClass$x([
1263
- property({ type: Object })
1264
- ], EmbedUrlBlock.prototype, "component", 2);
1265
- __decorateClass$x([
1266
- property({ type: Object })
1267
- ], EmbedUrlBlock.prototype, "item", 2);
1268
- __decorateClass$x([
1269
- state()
1270
- ], EmbedUrlBlock.prototype, "currentUrl", 2);
1271
- __decorateClass$x([
1272
- state()
1273
- ], EmbedUrlBlock.prototype, "_isUserFocused", 2);
1274
- EmbedUrlBlock = __decorateClass$x([
1275
- customElement("embed-url-block")
1276
- ], EmbedUrlBlock);
1277
-
1278
- var __defProp$u = Object.defineProperty;
1279
- var __getOwnPropDesc$w = Object.getOwnPropertyDescriptor;
1280
- var __decorateClass$w = (decorators, target, key, kind) => {
1281
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$w(target, key) : target;
1282
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
1283
- if (decorator = decorators[i])
1284
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1285
- if (kind && result) __defProp$u(target, key, result);
1286
- return result;
1287
- };
1288
- let LinkBlock = class extends BaseElementBlock {
1289
- constructor() {
1290
- super();
1291
- this.childrenComponents = [];
1292
- }
1293
- connectedCallback() {
1294
- super.connectedCallback();
1295
- }
1296
- updateChildrenComponents() {
1297
- this.childrenComponents = this.component?.childrenIds?.map((id) => {
1298
- return $components.get()[this.component?.application_id]?.find(
1299
- (component) => component.uuid === id
1300
- );
1301
- }).filter(Boolean) ?? [];
1302
- }
1303
- updated(changedProperties) {
1304
- if (changedProperties.has("component")) {
1305
- this.updateChildrenComponents();
1306
- }
1307
- }
1308
- renderComponent() {
1309
- const url = this.inputHandlersValue?.url ?? "#";
1310
- const target = this.inputHandlersValue?.target ?? "_self";
1311
- const label = this.inputHandlersValue?.label ?? this.inputHandlersValue?.placeholder ?? "";
1312
- return html`
1313
- <a
1314
- ${ref(this.inputRef)}
1315
- href=${this.isViewMode ? url : nothing}
1316
- target=${target}
1317
- style=${styleMap({
1318
- ...this.getStyles()
1319
- })}
1320
- @click=${(e) => {
1321
- if (!this.isViewMode) {
1322
- e.preventDefault();
1323
- }
1324
- this.executeEvent("onClick", e, { url, target });
1325
- }}
1326
- @mouseenter=${(e) => {
1327
- this.executeEvent("onMouseEnter", e);
1328
- }}
1329
- @mouseleave=${(e) => {
1330
- this.executeEvent("onMouseLeave", e);
1331
- }}
1332
- >
1333
- <span>
1334
- ${this.childrenComponents.length ? renderComponent(this.childrenComponents.map((component) => ({ ...component, item: this.item })), this.item, this.isViewMode) : html`
1335
- <nr-label
1336
- style=${styleMap({
1337
- "--resolved-text-label-color": this.getStyles()["title-color"]
1338
- })}
1339
- >${label}</nr-label>
1340
-
1341
- <drag-wrapper
1342
- .where=${"inside"}
1343
- .message=${"Drop inside"}
1344
- .component=${{ ...this.component }}
1345
- .inputRef=${this.inputRef}
1346
- .isDragInitiator=${this.isDragInitiator}
1347
- >
1348
- </drag-wrapper>
1349
-
1350
- `}
1351
- </span>
1352
- </a>
1353
- `;
1354
- }
1355
- };
1356
- __decorateClass$w([
1357
- property({ type: Object })
1358
- ], LinkBlock.prototype, "component", 2);
1359
- __decorateClass$w([
1360
- state()
1361
- ], LinkBlock.prototype, "childrenComponents", 2);
1362
- LinkBlock = __decorateClass$w([
1363
- customElement("link-block")
1364
- ], LinkBlock);
1365
-
1366
- var __defProp$t = Object.defineProperty;
1367
- var __getOwnPropDesc$v = Object.getOwnPropertyDescriptor;
1368
- var __decorateClass$v = (decorators, target, key, kind) => {
1369
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$v(target, key) : target;
1370
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
1371
- if (decorator = decorators[i])
1372
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1373
- if (kind && result) __defProp$t(target, key, result);
1374
- return result;
1375
- };
1376
- let ColorPickerBlock = class extends BaseElementBlock {
1377
- connectedCallback() {
1378
- super.connectedCallback();
1379
- this.registerCallback("value", () => {
1380
- });
1381
- }
1382
- renderComponent() {
1383
- const colorPickerStyles = this.component?.style || {};
1384
- const size = colorPickerStyles.size || "default";
1385
- return html`
1386
- <nr-color-picker
1387
- ${ref(this.inputRef)}
1388
- style=${styleMap({
1389
- width: "28px",
1390
- height: "28px",
1391
- ...this.getStyles()
1392
- })}
1393
- .color=${this.inputHandlersValue.value ?? EMPTY_STRING}
1394
- .disabled=${this.inputHandlersValue?.state == "disabled"}
1395
- .size=${size}
1396
- .trigger=${this.inputHandlersValue?.trigger || "click"}
1397
- .placement=${this.inputHandlersValue?.placement || "auto"}
1398
- .animation=${this.inputHandlersValue?.animation || "fade"}
1399
- .closeOnSelect=${this.inputHandlersValue?.closeOnSelect || false}
1400
- .closeOnOutsideClick=${this.inputHandlersValue?.closeOnOutsideClick !== false}
1401
- .closeOnEscape=${this.inputHandlersValue?.closeOnEscape !== false}
1402
- .showInput=${this.inputHandlersValue?.showInput !== false}
1403
- .showCopyButton=${this.inputHandlersValue?.showCopyButton !== false}
1404
- .format=${this.inputHandlersValue?.format || "hex"}
1405
- .inputPlaceholder=${this.inputHandlersValue?.inputPlaceholder || "Enter color"}
1406
- .label=${this.inputHandlersValue?.label || ""}
1407
- .helperText=${this.inputHandlersValue?.helperText || ""}
1408
- .defaultColorSets=${this.inputHandlersValue?.defaultColorSets || []}
1409
- @nr-color-change=${(e) => {
1410
- this.executeEvent("onChange", e, { value: e.detail.color });
1411
- }}
1412
- @nr-colorpicker-open=${(e) => {
1413
- this.executeEvent("onOpen", e);
1414
- }}
1415
- @nr-colorpicker-close=${(e) => {
1416
- this.executeEvent("onClose", e);
1417
- }}
1418
- ></nr-color-picker>
1419
- `;
1420
- }
1421
- };
1422
- ColorPickerBlock.styles = [
1423
- css``
1424
- ];
1425
- __decorateClass$v([
1426
- property({ type: Object })
1427
- ], ColorPickerBlock.prototype, "component", 2);
1428
- ColorPickerBlock = __decorateClass$v([
1429
- customElement("color-picker-block")
1430
- ], ColorPickerBlock);
1431
-
1432
- var __defProp$s = Object.defineProperty;
1433
- var __getOwnPropDesc$u = Object.getOwnPropertyDescriptor;
1434
- var __decorateClass$u = (decorators, target, key, kind) => {
1435
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$u(target, key) : target;
1436
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
1437
- if (decorator = decorators[i])
1438
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1439
- if (kind && result) __defProp$s(target, key, result);
1440
- return result;
1441
- };
1442
- try {
1443
- await import('@nuralyui/input');
1444
- } catch (error) {
1445
- console.warn("[@nuralyui/input] Package not found or failed to load.");
1446
- }
1447
- let NumberInputBlock = class extends BaseElementBlock {
1448
- render() {
1449
- const inputStyles = this.getStyles();
1450
- const componentStyles = this.component?.style || {};
1451
- const size = componentStyles?.size || "medium";
1452
- return html`
1453
- <span>
1454
- <nr-input
1455
- ${ref(this.inputRef)}
1456
- style=${styleMap({
1457
- ...inputStyles,
1458
- "--nuraly-input-local-border-top-left-radius": inputStyles?.["border-top-left-radius"] ?? "",
1459
- "--nuraly-input-local-border-top-right-radius": inputStyles?.["border-top-right-radius"] ?? "",
1460
- "--nuraly-input-local-border-bottom-left-radius": inputStyles?.["border-bottom-left-radius"] ?? "",
1461
- "--nuraly-input-local-border-bottom-right-radius": inputStyles?.["border-bottom-right-radius"] ?? ""
1462
- })}
1463
- .value=${this.inputHandlersValue?.value ?? nothing}
1464
- .size=${size}
1465
- .state=${this.inputHandlersValue?.status ?? nothing}
1466
- .type=${"number"}
1467
- .variant=${this.inputHandlersValue?.variant ?? nothing}
1468
- .disabled=${this.inputHandlersValue?.state === "disabled"}
1469
- .readonly=${this.inputHandlersValue?.readonly || false}
1470
- .placeholder=${this.inputHandlersValue?.placeholder ?? "Number input"}
1471
- .step=${this.inputHandlersValue?.step ?? nothing}
1472
- .min=${this.inputHandlersValue?.min ?? "0"}
1473
- .max=${this.inputHandlersValue?.max ?? nothing}
1474
- .name=${this.inputHandlersValue?.name ?? nothing}
1475
- .required=${this.inputHandlersValue?.required || false}
1476
- .rules=${this.inputHandlersValue?.rules ?? []}
1477
- .validateOnChangeInput=${this.inputHandlersValue?.validateOnChange !== false}
1478
- .validateOnBlurInput=${this.inputHandlersValue?.validateOnBlur !== false}
1479
- .hasFeedback=${this.inputHandlersValue?.hasFeedback || false}
1480
- @nr-input=${(e) => {
1481
- this.executeEvent("onChange", e, {
1482
- value: e.detail.value,
1483
- oldValue: e.detail.oldValue
1484
- });
1485
- }}
1486
- @nr-focus=${(e) => {
1487
- this.executeEvent("onFocus", e);
1488
- }}
1489
- @nr-blur=${(e) => {
1490
- this.executeEvent("onBlur", e);
1491
- }}
1492
- @nr-enter=${(e) => {
1493
- this.executeEvent("onEnter", e);
1494
- }}
1495
- >
1496
- <span slot="label">
1497
- ${this.inputHandlersValue?.label ?? ""}
1498
- </span>
1499
- <span slot="helper-text">
1500
- ${this.inputHandlersValue?.helper ?? ""}
1501
- </span>
1502
- </nr-input>
1503
- </span>
1504
- `;
1505
- }
1506
- };
1507
- NumberInputBlock.styles = [
1508
- css``
1509
- ];
1510
- __decorateClass$u([
1511
- property({ type: Object })
1512
- ], NumberInputBlock.prototype, "component", 2);
1513
- __decorateClass$u([
1514
- property({ type: Object })
1515
- ], NumberInputBlock.prototype, "item", 2);
1516
- NumberInputBlock = __decorateClass$u([
1517
- customElement("number-input-block")
1518
- ], NumberInputBlock);
1519
-
1520
- function registerWithParentForm(element, nrElement) {
1521
- const name = element.inputHandlersValue?.name;
1522
- if (!name || !nrElement) {
1523
- return;
1524
- }
1525
- element.dispatchEvent(new CustomEvent("nr-field-register", {
1526
- bubbles: true,
1527
- composed: true,
1528
- detail: {
1529
- element: nrElement,
1530
- name,
1531
- blockElement: element
1532
- }
1533
- }));
1534
- }
1535
- function unregisterFromParentForm(element) {
1536
- const name = element.inputHandlersValue?.name;
1537
- if (!name) {
1538
- return;
1539
- }
1540
- element.dispatchEvent(new CustomEvent("nr-field-unregister", {
1541
- bubbles: true,
1542
- composed: true,
1543
- detail: {
1544
- name,
1545
- blockElement: element
1546
- }
1547
- }));
1548
- }
1549
-
1550
- var __defProp$r = Object.defineProperty;
1551
- var __getOwnPropDesc$t = Object.getOwnPropertyDescriptor;
1552
- var __decorateClass$t = (decorators, target, key, kind) => {
1553
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$t(target, key) : target;
1554
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
1555
- if (decorator = decorators[i])
1556
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1557
- if (kind && result) __defProp$r(target, key, result);
1558
- return result;
1559
- };
1560
- try {
1561
- await import('@nuralyui/input');
1562
- } catch (error) {
1563
- console.warn("[@nuralyui/input] Package not found or failed to load.");
1564
- }
1565
- let TextInputBlock$2 = class TextInputBlock extends BaseElementBlock {
1566
- constructor() {
1567
- super();
1568
- this.currentValue = "";
1569
- this._isUserFocused = false;
1570
- this._focusResetTimeout = null;
1571
- this._inputElement = null;
1572
- }
1573
- firstUpdated(_changedProperties) {
1574
- super.firstUpdated(_changedProperties);
1575
- this.registerCallback("value", (value) => {
1576
- if (!this._isUserFocused && this.currentValue !== value) {
1577
- this.currentValue = value ?? "";
1578
- }
1579
- });
1580
- this._inputElement = this.renderRoot.querySelector("nr-input");
1581
- if (this._inputElement && this.inputHandlersValue?.name) {
1582
- registerWithParentForm(this, this._inputElement);
1583
- }
1584
- }
1585
- disconnectedCallback() {
1586
- super.disconnectedCallback();
1587
- if (this.unsubscribe) this.unsubscribe();
1588
- if (this._focusResetTimeout) clearTimeout(this._focusResetTimeout);
1589
- if (this.inputHandlersValue?.name) {
1590
- unregisterFromParentForm(this);
1591
- }
1592
- }
1593
- resetFocusAfterInactivity() {
1594
- if (this._focusResetTimeout) {
1595
- clearTimeout(this._focusResetTimeout);
1596
- }
1597
- this._focusResetTimeout = setTimeout(() => {
1598
- this._isUserFocused = false;
1599
- }, 3e3);
1600
- }
1601
- renderComponent() {
1602
- this.getStyles();
1603
- const componentStyles = this.component?.style || {};
1604
- componentStyles?.size || "medium";
1605
- return html`
1606
- <nr-input
1607
- ${ref(this.inputRef)}
1608
- class="${`drop-${this.component.uuid}`}"
1609
-
1610
- .value=${this.inputHandlersValue?.value ?? nothing}
1611
- .size=${this.inputHandlersValue?.size ?? "medium"}
1612
- .state=${this.inputHandlersValue.status ?? nothing}
1613
- .type=${this.inputHandlersValue.type ?? nothing}
1614
- .variant=${this.inputHandlersValue.variant ?? nothing}
1615
- .disabled=${this.inputHandlersValue.state === "disabled"}
1616
- .readonly=${this.inputHandlersValue.readonly || false}
1617
- .placeholder=${this.inputHandlersValue?.placeholder ?? "Text input"}
1618
- .step=${this.inputHandlersValue?.step ?? nothing}
1619
- .min=${this.inputHandlersValue?.min ?? nothing}
1620
- .max=${this.inputHandlersValue?.max ?? nothing}
1621
- .name=${this.inputHandlersValue?.name ?? nothing}
1622
- .required=${this.inputHandlersValue?.required || false}
1623
- .withCopy=${this.inputHandlersValue?.withCopy || false}
1624
- .allowClear=${this.inputHandlersValue?.allowClear || false}
1625
- .showCount=${this.inputHandlersValue?.showCount || false}
1626
- .maxLength=${this.inputHandlersValue?.maxLength ?? nothing}
1627
- .rules=${this.inputHandlersValue?.rules ?? []}
1628
- .validateOnChangeInput=${this.inputHandlersValue?.validateOnChange !== false}
1629
- .validateOnBlurInput=${this.inputHandlersValue?.validateOnBlur !== false}
1630
- .hasFeedback=${this.inputHandlersValue?.hasFeedback || false}
1631
- .autocomplete=${this.inputHandlersValue?.autocomplete ?? "off"}
1632
- @nr-input=${(e) => {
1633
- this._isUserFocused = true;
1634
- this.executeEvent(
1635
- "onChange",
1636
- e,
1637
- {
1638
- value: e.detail.value,
1639
- oldValue: e.detail.oldValue
1640
- }
1641
- );
1642
- this.resetFocusAfterInactivity();
1643
- }}
1644
- @nr-focus=${(e) => {
1645
- this._isUserFocused = true;
1646
- this.executeEvent("onFocus", e, {
1647
- value: e.detail.value
1648
- });
1649
- }}
1650
- @nr-blur=${(e) => {
1651
- this._isUserFocused = false;
1652
- this.executeEvent("onBlur", e, {
1653
- value: e.detail.value
1654
- });
1655
- }}
1656
- @nr-enter=${(e) => {
1657
- this.executeEvent("onEnter", e, {
1658
- value: e.detail.value
1659
- });
1660
- }}
1661
- @nr-clear=${(e) => {
1662
- this.executeEvent("onClear", e, {
1663
- value: e.detail.value
1664
- });
1665
- }}
1666
- @keydown=${(e) => {
1667
- if (e.key === "ArrowUp") {
1668
- this.executeEvent("onArrowUp", e);
1669
- } else if (e.key === "ArrowDown") {
1670
- this.executeEvent("onArrowDown", e);
1671
- }
1672
- }}
1673
- >
1674
- <span
1675
- slot="label"
1676
-
1677
- >
1678
- ${this.inputHandlersValue?.label ?? ""}
1679
- </span>
1680
- <span
1681
- slot="helper-text"
1682
-
1683
- >
1684
- ${this.inputHandlersValue?.helper ?? ""}
1685
- </span>
1686
- </nr-input>
1687
- `;
1688
- }
1689
- };
1690
- TextInputBlock$2.styles = [css``];
1691
- __decorateClass$t([
1692
- property({ type: Object })
1693
- ], TextInputBlock$2.prototype, "component", 2);
1694
- __decorateClass$t([
1695
- property({ type: Object })
1696
- ], TextInputBlock$2.prototype, "item", 2);
1697
- __decorateClass$t([
1698
- state()
1699
- ], TextInputBlock$2.prototype, "currentValue", 2);
1700
- __decorateClass$t([
1701
- state()
1702
- ], TextInputBlock$2.prototype, "_isUserFocused", 2);
1703
- TextInputBlock$2 = __decorateClass$t([
1704
- customElement("text-input-block")
1705
- ], TextInputBlock$2);
1706
-
1707
- var __defProp$q = Object.defineProperty;
1708
- var __getOwnPropDesc$s = Object.getOwnPropertyDescriptor;
1709
- var __decorateClass$s = (decorators, target, key, kind) => {
1710
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$s(target, key) : target;
1711
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
1712
- if (decorator = decorators[i])
1713
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1714
- if (kind && result) __defProp$q(target, key, result);
1715
- return result;
1716
- };
1717
- try {
1718
- await import('@nuralyui/button');
1719
- } catch (error) {
1720
- console.warn("[@nuralyui/button] Package not found or failed to load.");
1721
- }
1722
- let IconButtonBlock = class extends BaseElementBlock {
1723
- constructor() {
1724
- super(...arguments);
1725
- this.handleClick = () => {
1726
- setTimeout(() => {
1727
- if (this.component?.event?.click) {
1728
- executeHandler(this.component, getNestedAttribute(this.component, `event.click`));
1729
- }
1730
- }, 0);
1731
- };
1732
- }
1733
- renderComponent() {
1734
- const buttonStyles = this.getStyles();
1735
- const { icon } = this.component?.parameters ?? {};
1736
- const iconArray = icon ? [icon] : [];
1737
- const type = this.inputHandlersValue.value || buttonStyles?.type || "default";
1738
- const size = buttonStyles?.size || "medium";
1739
- return html`
1740
- <nr-button
1741
- ${ref(this.inputRef)}
1742
- .size=${size}
1743
- .type=${type}
1744
- .disabled=${this.inputHandlersValue.state == "disabled"}
1745
- .loading=${this.inputHandlersValue.loading || false}
1746
- .block=${this.inputHandlersValue.block || false}
1747
- .dashed=${this.inputHandlersValue.dashed || false}
1748
- .icon=${iconArray}
1749
- .iconPosition=${this.inputHandlersValue.iconPosition || "left"}
1750
- @click=${this.handleClick}
1751
- style=${styleMap({
1752
- ...this.getStyles(),
1753
- width: buttonStyles?.width,
1754
- height: buttonStyles?.height
1755
- })}
1756
- >
1757
- </nr-button>
1758
- `;
1759
- }
1760
- };
1761
- IconButtonBlock.styles = css``;
1762
- __decorateClass$s([
1763
- property({ type: Object })
1764
- ], IconButtonBlock.prototype, "component", 2);
1765
- IconButtonBlock = __decorateClass$s([
1766
- customElement("icon-button-block")
1767
- ], IconButtonBlock);
1768
-
1769
- var __defProp$p = Object.defineProperty;
1770
- var __getOwnPropDesc$r = Object.getOwnPropertyDescriptor;
1771
- var __decorateClass$r = (decorators, target, key, kind) => {
1772
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$r(target, key) : target;
1773
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
1774
- if (decorator = decorators[i])
1775
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1776
- if (kind && result) __defProp$p(target, key, result);
1777
- return result;
1778
- };
1779
- let SelectBlock = class extends BaseElementBlock {
1780
- constructor() {
1781
- super();
1782
- }
1783
- connectedCallback() {
1784
- super.connectedCallback();
1785
- this.registerCallback("value", (v) => {
1786
- this.requestUpdate();
1787
- });
1788
- }
1789
- renderComponent() {
1790
- return html`
1791
- <nr-select
1792
- ${ref(this.inputRef)}
1793
- style=${styleMap({
1794
- ...this.getStyles(),
1795
- "--nuraly-select-width": this.getStyles()["--nuraly-select-width"] ?? this.getStyles().width
1796
- })}
1797
- ?multiple=${this.inputHandlersValue?.selectionMode === "multiple"}
1798
- ?searchable=${this.inputHandlersValue?.searchable ?? false}
1799
- ?clearable=${this.inputHandlersValue?.clearable ?? false}
1800
- ?required=${this.inputHandlersValue?.required ?? false}
1801
- ?block=${this.inputHandlersValue?.block ?? false}
1802
- .options=${this.inputHandlersValue?.options ?? []}
1803
- .value=${this.inputHandlersValue?.value ?? EMPTY_STRING}
1804
- .placeholder=${this.inputHandlersValue?.placeholder || "Select an option"}
1805
- .searchPlaceholder=${this.inputHandlersValue?.searchPlaceholder || "Search options..."}
1806
- .status=${this.inputHandlersValue?.state ?? nothing}
1807
- .size=${this.inputHandlersValue?.size ?? nothing}
1808
- .disabled=${this.inputHandlersValue?.disabled ?? this.inputHandlersValue.state == "disabled"}
1809
- .type=${this.inputHandlersValue?.type || "default"}
1810
- @nr-change=${(e) => {
1811
- this.executeEvent("onChange", e, {
1812
- value: e.detail.value ?? EMPTY_STRING
1813
- });
1814
- }}
1815
- @nr-focus=${(e) => {
1816
- this.executeEvent("onFocus", e);
1817
- }}
1818
- @nr-blur=${(e) => {
1819
- this.executeEvent("onBlur", e);
1820
- }}
1821
- @nr-dropdown-open=${(e) => {
1822
- this.executeEvent("onDropdownOpen", e);
1823
- }}
1824
- @nr-dropdown-close=${(e) => {
1825
- this.executeEvent("onDropdownClose", e);
1826
- }}
1827
- @nr-validation=${(e) => {
1828
- this.executeEvent("onValidation", e, {
1829
- isValid: e.detail.isValid,
1830
- message: e.detail.message
1831
- });
1832
- }}
1833
- >
1834
- <span slot="label">${this.inputHandlersValue.label ?? nothing}</span>
1835
- <span slot="helper-text">${this.inputHandlersValue.helper ?? nothing}</span>
1836
- </nr-select>
1837
- `;
1838
- }
1839
- };
1840
- __decorateClass$r([
1841
- property({ type: Object })
1842
- ], SelectBlock.prototype, "component", 2);
1843
- SelectBlock = __decorateClass$r([
1844
- customElement("select-block")
1845
- ], SelectBlock);
1846
-
1847
- var __getOwnPropDesc$q = Object.getOwnPropertyDescriptor;
1848
- var __decorateClass$q = (decorators, target, key, kind) => {
1849
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$q(target, key) : target;
1850
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
1851
- if (decorator = decorators[i])
1852
- result = (decorator(result)) || result;
1853
- return result;
1854
- };
1855
- try {
1856
- await import('@nuralyui/checkbox');
1857
- } catch (error) {
1858
- console.warn("[@nuralyui/checkbox] Package not found or failed to load.");
1859
- }
1860
- let CheckboxBlock = class extends BaseElementBlock {
1861
- renderComponent() {
1862
- return html`
1863
- <nr-checkbox
1864
- class="${`drop-${this.component.uuid}`}"
1865
- ${ref(this.inputRef)}
1866
- .checked=${this.inputHandlersValue?.value === true}
1867
- .indeterminate=${this.inputHandlersValue?.value === "indeterminate"}
1868
- .disabled=${this.inputHandlersValue?.disabled}
1869
- .size=${this.inputHandlersValue?.size || "medium"}
1870
- .name=${this.inputHandlersValue?.name || ""}
1871
- .value=${this.inputHandlersValue?.value || ""}
1872
- .autoFocus=${this.inputHandlersValue?.autoFocus || false}
1873
- .id=${this.inputHandlersValue?.id || ""}
1874
- .title=${this.inputHandlersValue?.title || ""}
1875
- .tabIndex=${this.inputHandlersValue?.tabIndex || 0}
1876
- @nr-change=${(e) => {
1877
- this.executeEvent("onChange", e, {
1878
- checked: e.detail.checked
1879
- });
1880
- }}
1881
- @nr-focus=${(e) => {
1882
- this.executeEvent("onFocus", e);
1883
- }}
1884
- @nr-blur=${(e) => {
1885
- this.executeEvent("onBlur", e);
1886
- }}
1887
- @nr-keydown=${(e) => {
1888
- this.executeEvent("onKeydown", e);
1889
- }}
1890
- @nr-mouseenter=${(e) => {
1891
- this.executeEvent("onMouseEnter", e);
1892
- }}
1893
- @nr-mouseleave=${(e) => {
1894
- this.executeEvent("onMouseLeave", e);
1895
- }}
1896
- >
1897
- <nr-label .size=${this.inputHandlersValue?.size || "medium"}> ${this.inputHandlersValue?.label ?? ""}</nr-label>
1898
- </nr-checkbox>
1899
- `;
1900
- }
1901
- };
1902
- CheckboxBlock = __decorateClass$q([
1903
- customElement("checkbox-block")
1904
- ], CheckboxBlock);
1905
-
1906
- var __defProp$o = Object.defineProperty;
1907
- var __getOwnPropDesc$p = Object.getOwnPropertyDescriptor;
1908
- var __decorateClass$p = (decorators, target, key, kind) => {
1909
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$p(target, key) : target;
1910
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
1911
- if (decorator = decorators[i])
1912
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1913
- if (kind && result) __defProp$o(target, key, result);
1914
- return result;
1915
- };
1916
- try {
1917
- await import('@nuralyui/dropdown');
1918
- } catch (error) {
1919
- console.warn("[@nuralyui/dropdown] Package not found or failed to load. Dropdown functionality may be limited.");
1920
- }
1921
- let DropdownBlock = class extends BaseElementBlock {
1922
- constructor() {
1923
- super();
1924
- this.childrenComponents = [];
1925
- this.options = [
1926
- { label: "Copy", value: "Copy", icon: "copy" },
1927
- { label: "Paste", value: "Paste", icon: "paste" },
1928
- { label: "Delete", value: "Delete", icon: "trash" },
1929
- { label: "Export", value: "value12" },
1930
- { label: "Import", value: "value12" }
1931
- ];
1932
- }
1933
- connectedCallback() {
1934
- super.connectedCallback();
1935
- this.registerCallback("value", (v) => {
1936
- this.requestUpdate();
1937
- });
1938
- }
1939
- updateChildrenComponents() {
1940
- this.childrenComponents = this.component?.childrenIds?.map((id) => {
1941
- return $components.get()[this.component?.application_id]?.find(
1942
- (component) => component.uuid === id
1943
- );
1944
- }).filter(Boolean) ?? [];
1945
- }
1946
- updated(changedProperties) {
1947
- if (changedProperties.has("component")) {
1948
- this.updateChildrenComponents();
1949
- }
1950
- }
1951
- renderComponent() {
1952
- const options = this.inputHandlersValue?.value?.[0] ?? [];
1953
- const dropdownStyles = this.component?.style || {};
1954
- const size = dropdownStyles.size || "medium";
1955
- const placement = dropdownStyles.placement || "bottom";
1956
- const trigger = dropdownStyles.trigger || "click";
1957
- const animation = dropdownStyles.animation || "fade";
1958
- return html`
1959
- <nr-dropdown
1960
- .open=${this.inputHandlersValue.show || false}
1961
- ${ref(this.inputRef)}
1962
- style=${styleMap({
1963
- ...this.getStyles()
1964
- })}
1965
- .trigger=${trigger}
1966
- .placement=${placement}
1967
- .size=${size}
1968
- .animation=${animation}
1969
- .disabled=${this.inputHandlersValue?.state == "disabled"}
1970
- .items=${this.inputHandlersValue.options || options}
1971
- .arrow=${dropdownStyles.arrow === "true" || this.inputHandlersValue.arrow || false}
1972
- .autoClose=${dropdownStyles.autoClose !== "false" && this.inputHandlersValue.autoClose !== false}
1973
- .closeOnOutsideClick=${dropdownStyles.closeOnOutsideClick !== "false" && this.inputHandlersValue.closeOnOutsideClick !== false}
1974
- .closeOnEscape=${dropdownStyles.closeOnEscape !== "false" && this.inputHandlersValue.closeOnEscape !== false}
1975
- .offset=${this.inputHandlersValue.offset || 4}
1976
- .delay=${this.inputHandlersValue.delay || 50}
1977
- .maxHeight=${this.inputHandlersValue.maxHeight || "300px"}
1978
- .minWidth=${this.inputHandlersValue.minWidth || "auto"}
1979
- .cascadeDirection=${this.inputHandlersValue.cascadeDirection || "auto"}
1980
- .cascadeDelay=${this.inputHandlersValue.cascadeDelay || 50}
1981
- .cascadeOnHover=${this.inputHandlersValue.cascadeOnHover !== false}
1982
- @nr-dropdown-item-click=${(e) => {
1983
- const item = e.detail.item;
1984
- this.executeEvent("onItemClick", e, {
1985
- value: item.value,
1986
- item,
1987
- additionalData: item.additionalData
1988
- });
1989
- }}
1990
- @nr-dropdown-open=${(e) => {
1991
- this.executeEvent("onOpen", e);
1992
- }}
1993
- @nr-dropdown-close=${(e) => {
1994
- this.executeEvent("onClose", e);
1995
- }}
1996
- >
1997
- <span slot="trigger">
1998
- ${this.childrenComponents.length ? renderComponent(this.childrenComponents.map((component) => ({ ...component, item: this.item })), this.item, this.isViewMode) : html`
1999
- <nr-label
2000
- style=${styleMap({
2001
- "--resolved-text-label-color": this.getStyles()["title-color"]
2002
- })}
2003
- >${this.inputHandlersValue?.label ?? this.inputHandlersValue?.placeholder ?? nothing}</nr-label>
2004
-
2005
- <drag-wrapper
2006
- .where=${"inside"}
2007
- .message=${"Drop inside"}
2008
- .component=${{ ...this.component }}
2009
- .inputRef=${this.inputRef}
2010
- .isDragInitiator=${this.isDragInitiator}
2011
- >
2012
- </drag-wrapper>
2013
- `}
2014
- </span>
2015
- </nr-dropdown>
2016
- `;
2017
- }
2018
- };
2019
- __decorateClass$p([
2020
- property({ type: Object })
2021
- ], DropdownBlock.prototype, "component", 2);
2022
- __decorateClass$p([
2023
- state()
2024
- ], DropdownBlock.prototype, "childrenComponents", 2);
2025
- __decorateClass$p([
2026
- state()
2027
- ], DropdownBlock.prototype, "options", 2);
2028
- DropdownBlock = __decorateClass$p([
2029
- customElement("dropdown-block")
2030
- ], DropdownBlock);
2031
-
2032
- var __defProp$n = Object.defineProperty;
2033
- var __getOwnPropDesc$o = Object.getOwnPropertyDescriptor;
2034
- var __decorateClass$o = (decorators, target, key, kind) => {
2035
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$o(target, key) : target;
2036
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
2037
- if (decorator = decorators[i])
2038
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
2039
- if (kind && result) __defProp$n(target, key, result);
2040
- return result;
2041
- };
2042
- try {
2043
- await import('@nuralyui/datepicker');
2044
- } catch (error) {
2045
- console.warn("[@nuralyui/datepicker] Package not found or failed to load.");
2046
- }
2047
- let DatepickertBlock = class extends BaseElementBlock {
2048
- constructor() {
2049
- super(...arguments);
2050
- this.handleDateChange = (customEvent) => {
2051
- this.executeEvent("onDateChange", customEvent, {
2052
- value: customEvent.detail?.value || customEvent.detail?.date || customEvent.detail
2053
- });
2054
- };
2055
- this.handleRangeChange = (customEvent) => {
2056
- this.executeEvent("onRangeChange", customEvent, {
2057
- startDate: customEvent.detail?.startDate,
2058
- endDate: customEvent.detail?.endDate,
2059
- value: customEvent.detail?.value
2060
- });
2061
- };
2062
- this.handleCalendarOpen = (customEvent) => {
2063
- this.executeEvent("onCalendarOpen", customEvent);
2064
- };
2065
- this.handleCalendarClose = (customEvent) => {
2066
- this.executeEvent("onCalendarClose", customEvent);
2067
- };
2068
- this.handleFocus = (customEvent) => {
2069
- this.executeEvent("onFocus", customEvent);
2070
- };
2071
- this.handleBlur = (customEvent) => {
2072
- this.executeEvent("onBlur", customEvent);
2073
- };
2074
- this.handleValidation = (customEvent) => {
2075
- this.executeEvent("onValidation", customEvent, {
2076
- isValid: customEvent.detail?.isValid,
2077
- message: customEvent.detail?.message
2078
- });
2079
- };
2080
- }
2081
- renderComponent() {
2082
- const datePickerStyles = this.component?.style || {};
2083
- const size = datePickerStyles.size || "medium";
2084
- const variant = datePickerStyles.variant || "default";
2085
- const placement = datePickerStyles.placement || "auto";
2086
- const state = datePickerStyles?.state || "default";
2087
- return html`
2088
- <nr-datepicker
2089
- ${ref(this.inputRef)}
2090
- class="${`drop-${this.component.uuid}`}"
2091
-
2092
- .helper=${this.inputHandlersValue.helper || ""}
2093
- .label=${this.inputHandlersValue.label || ""}
2094
- .placeholder=${this.inputHandlersValue.placeholder || ""}
2095
- .locale=${this.inputHandlersValue.locale || "en"}
2096
- .state=${state}
2097
- .size=${this.inputHandlersValue.size ?? size}
2098
- .variant=${variant}
2099
- .placement=${placement}
2100
- ?disabled=${this.inputHandlersValue.disabled ?? false}
2101
- .dateValue=${this.inputHandlersValue.value || ""}
2102
- .fieldFormat=${this.inputHandlersValue.format || "DD/MM/YYYY"}
2103
- ?range=${this.inputHandlersValue.range ?? false}
2104
- .minDate=${this.inputHandlersValue.minDate}
2105
- .maxDate=${this.inputHandlersValue.maxDate}
2106
- ?required=${this.inputHandlersValue.required ?? false}
2107
- @nr-date-change=${this.handleDateChange}
2108
- @nr-range-change=${this.handleRangeChange}
2109
- @nr-calendar-open=${this.handleCalendarOpen}
2110
- @nr-calendar-close=${this.handleCalendarClose}
2111
- @nr-focus=${this.handleFocus}
2112
- @nr-blur=${this.handleBlur}
2113
- @nr-validation=${this.handleValidation}
2114
- ></nr-datepicker>
2115
- `;
2116
- }
2117
- };
2118
- __decorateClass$o([
2119
- property({ type: Object })
2120
- ], DatepickertBlock.prototype, "component", 2);
2121
- DatepickertBlock = __decorateClass$o([
2122
- customElement("date-picker-block")
2123
- ], DatepickertBlock);
2124
-
2125
- var __defProp$m = Object.defineProperty;
2126
- var __getOwnPropDesc$n = Object.getOwnPropertyDescriptor;
2127
- var __decorateClass$n = (decorators, target, key, kind) => {
2128
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$n(target, key) : target;
2129
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
2130
- if (decorator = decorators[i])
2131
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
2132
- if (kind && result) __defProp$m(target, key, result);
2133
- return result;
2134
- };
2135
- let RadioButtonBlock = class extends BaseElementBlock {
2136
- renderComponent() {
2137
- const radioStyles = this.component?.style || {};
2138
- const options = this.inputHandlersValue?.value?.options || [];
2139
- const defaultValue = this.inputHandlersValue?.value?.currentValue ?? "";
2140
- const type = this.inputHandlersValue?.value?.type || "default";
2141
- const direction = this.inputHandlersValue?.direction || "vertical";
2142
- const position = this.inputHandlersValue?.position || "left";
2143
- const size = this.inputHandlersValue?.size?.value || this.inputHandlersValue?.size || "medium";
2144
- const disabled = this.inputHandlersValue?.state === "disabled";
2145
- const required = this.inputHandlersValue?.required || false;
2146
- const name = this.inputHandlersValue?.name || "radioGroup";
2147
- const autoWidth = this.inputHandlersValue?.autoWidth?.value || this.inputHandlersValue?.autoWidth || false;
2148
- return html`
2149
- <span style=${styleMap(radioStyles)}>
2150
- <nr-radio-group
2151
-
2152
- .options=${options}
2153
- .defaultValue=${defaultValue}
2154
- .value=${defaultValue}
2155
- .type=${type}
2156
- .direction=${direction}
2157
- .position=${position}
2158
- .size=${size}
2159
- .name=${name}
2160
- ?disabled=${disabled}
2161
- ?required=${required}
2162
- ?auto-width=${autoWidth}
2163
- @nr-change=${(e) => {
2164
- this.executeEvent("onChange", e, {
2165
- value: e.detail.value,
2166
- option: e.detail.option,
2167
- oldValue: e.detail.oldValue
2168
- });
2169
- }}
2170
- >
2171
- <span slot="helper-text" style="display: block; margin-top: 4px;">
2172
- ${this.inputHandlersValue?.helper ?? ""}
2173
- </span>
2174
- </nr-radio-group>
2175
- </span>
2176
- `;
2177
- }
2178
- };
2179
- __decorateClass$n([
2180
- property({ type: Object })
2181
- ], RadioButtonBlock.prototype, "component", 2);
2182
- __decorateClass$n([
2183
- property({ type: Object })
2184
- ], RadioButtonBlock.prototype, "item", 2);
2185
- RadioButtonBlock = __decorateClass$n([
2186
- customElement("radio-button-block")
2187
- ], RadioButtonBlock);
2188
-
2189
- var __defProp$l = Object.defineProperty;
2190
- var __getOwnPropDesc$m = Object.getOwnPropertyDescriptor;
2191
- var __decorateClass$m = (decorators, target, key, kind) => {
2192
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$m(target, key) : target;
2193
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
2194
- if (decorator = decorators[i])
2195
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
2196
- if (kind && result) __defProp$l(target, key, result);
2197
- return result;
2198
- };
2199
- try {
2200
- await import('@nuralyui/button');
2201
- } catch (error) {
2202
- console.warn("[@nuralyui/button] Package not found or failed to load. Button functionality may be limited.");
2203
- }
2204
- let ButtonBlock = class extends BaseElementBlock {
2205
- constructor() {
2206
- super(...arguments);
2207
- this.display = false;
2208
- }
2209
- connectedCallback() {
2210
- super.connectedCallback();
2211
- this.registerCallback("value", () => {
2212
- });
2213
- }
2214
- renderComponent() {
2215
- const buttonStyles = this.getStyles();
2216
- const iconArray = this.inputHandlersValue.icon ? [this.inputHandlersValue.icon] : [];
2217
- return html`
2218
- <nr-button
2219
- ${ref(this.inputRef)}
2220
- size=${this.inputHandlersValue?.size || nothing}
2221
- type=${this.inputHandlersValue?.type || "default"}
2222
- .shape=${this.inputHandlersValue?.shape || nothing}
2223
- .disabled=${this.inputHandlersValue?.state == "disabled"}
2224
- .loading=${this.inputHandlersValue?.loading || false}
2225
- .block=${this.inputHandlersValue?.block || false}
2226
- .dashed=${this.inputHandlersValue?.dashed || false}
2227
- .icon=${iconArray}
2228
- .iconLeft=${this.inputHandlersValue?.iconLeft || nothing}
2229
- .iconRight=${this.inputHandlersValue?.iconRight || nothing}
2230
- .icons=${this.inputHandlersValue?.icons || nothing}
2231
- .iconPosition=${this.inputHandlersValue?.iconPosition || "left"}
2232
- .href=${this.inputHandlersValue?.href || nothing}
2233
- .target=${this.inputHandlersValue?.target || nothing}
2234
- .ripple=${this.inputHandlersValue?.ripple !== false}
2235
- .buttonAriaLabel=${this.inputHandlersValue?.ariaLabel || nothing}
2236
- .htmlType=${this.inputHandlersValue?.htmlType || nothing}
2237
- @click=${(e) => {
2238
- this.executeEvent("onClick", e);
2239
- }}
2240
- @button-clicked=${(e) => {
2241
- this.executeEvent("onButtonClicked", e);
2242
- }}
2243
- @link-navigation=${(e) => {
2244
- this.executeEvent("onLinkNavigation", e);
2245
- }}
2246
- style=${styleMap({
2247
- ...this.getStyles(),
2248
- width: buttonStyles?.width,
2249
- height: buttonStyles?.height
2250
- })}
2251
- >
2252
- ${this.inputHandlersValue.label ? this.inputHandlersValue.label : this.inputHandlersValue.iconOnly ? "" : "Button"}
2253
- </nr-button>
2254
- `;
2255
- }
2256
- };
2257
- ButtonBlock.styles = [
2258
- css`
2259
- :host {
2260
- --nuraly-button-icon-width: 19px;
2261
- }
2262
- `
2263
- ];
2264
- __decorateClass$m([
2265
- property({ type: Object })
2266
- ], ButtonBlock.prototype, "component", 2);
2267
- __decorateClass$m([
2268
- state()
2269
- ], ButtonBlock.prototype, "display", 2);
2270
- ButtonBlock = __decorateClass$m([
2271
- customElement("button-block")
2272
- ], ButtonBlock);
2273
-
2274
- var __getOwnPropDesc$l = Object.getOwnPropertyDescriptor;
2275
- var __decorateClass$l = (decorators, target, key, kind) => {
2276
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$l(target, key) : target;
2277
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
2278
- if (decorator = decorators[i])
2279
- result = (decorator(result)) || result;
2280
- return result;
2281
- };
2282
- try {
2283
- await import('@nuralyui/file-upload');
2284
- } catch (error) {
2285
- console.warn("[@nuralyui/file-upload] Package not found or failed to load.");
2286
- }
2287
- let FileUploadBlock = class extends BaseElementBlock {
2288
- renderComponent() {
2289
- return html`
2290
- <nr-file-upload
2291
- style=${styleMap({
2292
- ...this.getStyles()
2293
- })}
2294
-
2295
- ${ref(this.inputRef)}
2296
- accept="*/*"
2297
- drag
2298
- limit="5"
2299
- tip="JPG/PNG files up to 500kb"
2300
- @files-changed=${(e) => {
2301
- const files = e.detail;
2302
- this.executeEvent("onFilesChanged", e, {
2303
- files
2304
- });
2305
- }}
2306
- ></nr-file-upload>
2307
- `;
2308
- }
2309
- };
2310
- FileUploadBlock.styles = [
2311
- css`
2312
- :host {
2313
- display: block;
2314
- }
2315
- `
2316
- ];
2317
- FileUploadBlock = __decorateClass$l([
2318
- customElement("file-upload-block")
2319
- ], FileUploadBlock);
2320
-
2321
- var __defProp$k = Object.defineProperty;
2322
- var __getOwnPropDesc$k = Object.getOwnPropertyDescriptor;
2323
- var __decorateClass$k = (decorators, target, key, kind) => {
2324
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$k(target, key) : target;
2325
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
2326
- if (decorator = decorators[i])
2327
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
2328
- if (kind && result) __defProp$k(target, key, result);
2329
- return result;
2330
- };
2331
- try {
2332
- await import('@nuralyui/textarea');
2333
- } catch (error) {
2334
- console.warn("[@nuralyui/textarea] Package not found or failed to load.");
2335
- }
2336
- let TextareaBlock = class extends BaseElementBlock {
2337
- renderComponent() {
2338
- const textareaStyles = this.component?.style || {};
2339
- const value = this.inputHandlersValue?.value ?? "";
2340
- const placeholder = this.inputHandlersValue?.placeholder ?? "";
2341
- const label = this.inputHandlersValue?.label ?? "";
2342
- const helperText = this.inputHandlersValue?.helperText ?? this.inputHandlersValue?.helper ?? "";
2343
- const disabled = this.inputHandlersValue?.disabled ?? (this.inputHandlersValue?.state === "disabled" || false);
2344
- const readonly = this.inputHandlersValue?.readonly ?? false;
2345
- const required = this.inputHandlersValue?.required ?? false;
2346
- const allowClear = this.inputHandlersValue?.allowClear ?? false;
2347
- const showCount = this.inputHandlersValue?.showCount ?? false;
2348
- const autoResize = this.inputHandlersValue?.autoResize ?? false;
2349
- const size = this.inputHandlersValue?.size ?? "medium";
2350
- const variant = this.inputHandlersValue?.variant ?? "";
2351
- const state = this.inputHandlersValue?.state ?? "default";
2352
- const resize = this.inputHandlersValue?.resize ?? "vertical";
2353
- const rows = this.inputHandlersValue?.rows ?? 4;
2354
- const cols = this.inputHandlersValue?.cols;
2355
- const maxLength = this.inputHandlersValue?.maxLength;
2356
- const minHeight = this.inputHandlersValue?.minHeight;
2357
- const maxHeight = this.inputHandlersValue?.maxHeight;
2358
- const rules = this.inputHandlersValue?.rules ?? [];
2359
- const name = this.inputHandlersValue?.name;
2360
- const autocomplete = this.inputHandlersValue?.autocomplete ?? "off";
2361
- const validateOnChange = this.inputHandlersValue?.validateOnChange ?? true;
2362
- const validateOnBlur = this.inputHandlersValue?.validateOnBlur ?? true;
2363
- const hasFeedback = this.inputHandlersValue?.hasFeedback ?? false;
2364
- return html`
2365
- <nr-textarea
2366
- ${ref(this.inputRef)}
2367
- style=${styleMap(textareaStyles)}
2368
- .value=${value}
2369
- .placeholder=${placeholder}
2370
- .label=${label}
2371
- .helperText=${helperText}
2372
- .size=${size}
2373
- .variant=${variant}
2374
- .state=${state}
2375
- .resize=${resize}
2376
- .rows=${rows}
2377
- .cols=${cols}
2378
- .maxLength=${maxLength}
2379
- .minHeight=${minHeight}
2380
- .maxHeight=${maxHeight}
2381
- .rules=${rules}
2382
- .name=${name}
2383
- .autocomplete=${autocomplete}
2384
- ?disabled=${disabled}
2385
- ?readonly=${readonly}
2386
- ?required=${required}
2387
- ?allowClear=${allowClear}
2388
- ?showCount=${showCount}
2389
- ?autoResize=${autoResize}
2390
- ?validateOnChange=${validateOnChange}
2391
- ?validateOnBlur=${validateOnBlur}
2392
- ?hasFeedback=${hasFeedback}
2393
- @nr-textarea-change=${(e) => {
2394
- this.executeEvent("onChange", e, {
2395
- value: e.detail.value,
2396
- characterCount: e.detail.characterCount
2397
- });
2398
- }}
2399
- @nr-focus=${(e) => {
2400
- this.executeEvent("onFocus", e);
2401
- }}
2402
- @nr-blur=${(e) => {
2403
- this.executeEvent("onBlur", e, {
2404
- value: e.detail.value
2405
- });
2406
- }}
2407
- @nr-clear=${(e) => {
2408
- this.executeEvent("onClear", e);
2409
- }}
2410
- @nr-resize=${(e) => {
2411
- this.executeEvent("onResize", e, {
2412
- height: e.detail.height,
2413
- width: e.detail.width
2414
- });
2415
- }}
2416
- ></nr-textarea>
2417
- `;
2418
- }
2419
- };
2420
- TextareaBlock.styles = [css``];
2421
- __decorateClass$k([
2422
- property({ type: Object })
2423
- ], TextareaBlock.prototype, "component", 2);
2424
- __decorateClass$k([
2425
- property({ type: Object })
2426
- ], TextareaBlock.prototype, "item", 2);
2427
- TextareaBlock = __decorateClass$k([
2428
- customElement("textarea-block")
2429
- ], TextareaBlock);
2430
-
2431
- var __defProp$j = Object.defineProperty;
2432
- var __getOwnPropDesc$j = Object.getOwnPropertyDescriptor;
2433
- var __decorateClass$j = (decorators, target, key, kind) => {
2434
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$j(target, key) : target;
2435
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
2436
- if (decorator = decorators[i])
2437
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
2438
- if (kind && result) __defProp$j(target, key, result);
2439
- return result;
2440
- };
2441
- try {
2442
- await import('@nuralyui/slider-input');
2443
- } catch (error) {
2444
- console.warn("[@nuralyui/slider-input] Package not found or failed to load.");
2445
- }
2446
- let SliderBlock = class extends BaseElementBlock {
2447
- renderComponent() {
2448
- const sliderStyles = this.component?.style || {};
2449
- const value = this.component?.input?.value?.value ?? this.inputHandlersValue?.value ?? 0;
2450
- const min = this.component?.input?.min?.value ?? this.inputHandlersValue?.min ?? 0;
2451
- const max = this.component?.input?.max?.value ?? this.inputHandlersValue?.max ?? 100;
2452
- const step = this.component?.input?.step?.value ?? this.inputHandlersValue?.step ?? 1;
2453
- const disabled = this.component?.input?.disabled?.value ?? this.inputHandlersValue?.disabled ?? false;
2454
- const vertical = this.component?.input?.vertical?.value ?? this.inputHandlersValue?.vertical ?? false;
2455
- const showTooltip = this.component?.input?.showTooltip?.value ?? this.inputHandlersValue?.showTooltip ?? true;
2456
- const showMarks = this.component?.input?.showMarks?.value ?? this.inputHandlersValue?.showMarks ?? false;
2457
- const range = this.component?.input?.range?.value ?? this.inputHandlersValue?.range ?? false;
2458
- const marks = this.inputHandlersValue?.marks;
2459
- return html`
2460
- <nr-slider-input
2461
- ${ref(this.inputRef)}
2462
- style=${styleMap(sliderStyles)}
2463
- .value=${value}
2464
- .min=${min}
2465
- .max=${max}
2466
- .step=${step}
2467
- .marks=${marks}
2468
- ?disabled=${disabled}
2469
- ?vertical=${vertical}
2470
- ?showTooltip=${showTooltip}
2471
- ?showMarks=${showMarks}
2472
- ?range=${range}
2473
- @nr-change=${(e) => {
2474
- this.executeEvent("onChange", e, {
2475
- value: e.detail.value
2476
- });
2477
- }}
2478
- @nr-after-change=${(e) => {
2479
- this.executeEvent("onAfterChange", e, {
2480
- value: e.detail.value
2481
- });
2482
- }}
2483
- ></nr-slider-input>
2484
- `;
2485
- }
2486
- };
2487
- SliderBlock.styles = [css``];
2488
- __decorateClass$j([
2489
- property({ type: Object })
2490
- ], SliderBlock.prototype, "component", 2);
2491
- __decorateClass$j([
2492
- property({ type: Object })
2493
- ], SliderBlock.prototype, "item", 2);
2494
- SliderBlock = __decorateClass$j([
2495
- customElement("slider-block")
2496
- ], SliderBlock);
2497
-
2498
- const formStyles = css`
2499
- :host {
2500
- display: block;
2501
- width: 100%;
2502
- }
2503
-
2504
- .form-placeholder {
2505
- display: flex;
2506
- flex-direction: column;
2507
- align-items: center;
2508
- justify-content: center;
2509
- color: #64748b;
2510
- min-height: 200px;
2511
- width: 100%;
2512
- border-radius: 8px;
2513
- border: 2px dashed #cbd5e1;
2514
- gap: 12px;
2515
- cursor: pointer;
2516
- }
2517
-
2518
- .form-placeholder nr-icon {
2519
- --nuraly-icon-size: 48px;
2520
- }
2521
- `;
2522
-
2523
- var __defProp$i = Object.defineProperty;
2524
- var __getOwnPropDesc$i = Object.getOwnPropertyDescriptor;
2525
- var __decorateClass$i = (decorators, target, key, kind) => {
2526
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target;
2527
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
2528
- if (decorator = decorators[i])
2529
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
2530
- if (kind && result) __defProp$i(target, key, result);
2531
- return result;
2532
- };
2533
- try {
2534
- await import('@nuralyui/forms');
2535
- } catch (error) {
2536
- console.warn("[@nuralyui/forms] Package not found or failed to load.");
2537
- }
2538
- let FormBlock = class extends BaseElementBlock {
2539
- constructor() {
2540
- super();
2541
- this._formElement = null;
2542
- this._registeredFields = /* @__PURE__ */ new Map();
2543
- this.childrenComponents = [];
2544
- this._fieldRegisterHandler = this._handleFieldRegister.bind(this);
2545
- this._fieldUnregisterHandler = this._handleFieldUnregister.bind(this);
2546
- this._fieldValueChangeHandler = this._handleFieldValueChange.bind(this);
2547
- }
2548
- connectedCallback() {
2549
- super.connectedCallback();
2550
- this.updateChildrenComponents();
2551
- this.addEventListener("nr-field-register", this._fieldRegisterHandler);
2552
- this.addEventListener("nr-field-unregister", this._fieldUnregisterHandler);
2553
- this.addEventListener("nr-field-value-change", this._fieldValueChangeHandler);
2554
- }
2555
- willUpdate(changedProperties) {
2556
- super.willUpdate(changedProperties);
2557
- if (changedProperties.has("component")) {
2558
- this.updateChildrenComponents();
2559
- }
2560
- }
2561
- updateChildrenComponents() {
2562
- this.childrenComponents = this.component?.childrenIds?.map((id) => {
2563
- return $components.get()[this.component?.application_id]?.find((component) => component.uuid === id);
2564
- }).filter(Boolean) ?? [];
2565
- }
2566
- disconnectedCallback() {
2567
- super.disconnectedCallback();
2568
- this.removeEventListener("nr-field-register", this._fieldRegisterHandler);
2569
- this.removeEventListener("nr-field-unregister", this._fieldUnregisterHandler);
2570
- this.removeEventListener("nr-field-value-change", this._fieldValueChangeHandler);
2571
- this._registeredFields.clear();
2572
- }
2573
- firstUpdated(_changedProperties) {
2574
- super.firstUpdated(_changedProperties);
2575
- this._formElement = this.renderRoot.querySelector("nr-form");
2576
- this.registerCallback("disabled", (value) => {
2577
- if (this._formElement) {
2578
- this._formElement.disabled = value;
2579
- }
2580
- });
2581
- }
2582
- /**
2583
- * Handle field registration from child input blocks
2584
- */
2585
- _handleFieldRegister(event) {
2586
- event.stopPropagation();
2587
- const { element, name, blockElement } = event.detail;
2588
- if (!name || !element) {
2589
- console.warn("[FormBlock] Field registration missing name or element");
2590
- return;
2591
- }
2592
- this._registeredFields.set(name, { element, blockElement });
2593
- if (this._formElement?.validationController) {
2594
- try {
2595
- this._formElement.validationController.registerField(element);
2596
- } catch (error) {
2597
- console.warn("[FormBlock] Failed to register field with validation controller:", error);
2598
- }
2599
- }
2600
- }
2601
- /**
2602
- * Handle field unregistration when child input blocks are removed
2603
- */
2604
- _handleFieldUnregister(event) {
2605
- event.stopPropagation();
2606
- const { name } = event.detail;
2607
- if (name && this._registeredFields.has(name)) {
2608
- if (this._formElement?.validationController) {
2609
- try {
2610
- this._formElement.validationController.unregisterField(name);
2611
- } catch (error) {
2612
- console.warn("[FormBlock] Failed to unregister field:", error);
2613
- }
2614
- }
2615
- this._registeredFields.delete(name);
2616
- }
2617
- }
2618
- /**
2619
- * Handle field value changes for form data collection
2620
- */
2621
- _handleFieldValueChange(event) {
2622
- const { name, value } = event.detail;
2623
- if (name && this._registeredFields.has(name)) {
2624
- const fieldInfo = this._registeredFields.get(name);
2625
- fieldInfo.value = value;
2626
- }
2627
- }
2628
- /**
2629
- * Get all form field values
2630
- */
2631
- getFieldsValue() {
2632
- if (this._formElement?.getFieldsValue) {
2633
- return this._formElement.getFieldsValue();
2634
- }
2635
- const values = {};
2636
- for (const [name, fieldInfo] of this._registeredFields) {
2637
- values[name] = fieldInfo.element?.value ?? fieldInfo.value;
2638
- }
2639
- return values;
2640
- }
2641
- /**
2642
- * Set form field values
2643
- */
2644
- setFieldsValue(values) {
2645
- if (this._formElement?.setFieldsValue) {
2646
- this._formElement.setFieldsValue(values);
2647
- }
2648
- }
2649
- /**
2650
- * Validate all form fields
2651
- */
2652
- async validate() {
2653
- if (this._formElement?.validate) {
2654
- return this._formElement.validate();
2655
- }
2656
- return true;
2657
- }
2658
- /**
2659
- * Submit the form programmatically
2660
- */
2661
- async submit(customData) {
2662
- if (this._formElement?.submit) {
2663
- await this._formElement.submit(customData);
2664
- }
2665
- }
2666
- /**
2667
- * Reset the form
2668
- */
2669
- reset() {
2670
- if (this._formElement?.reset) {
2671
- this._formElement.reset();
2672
- }
2673
- }
2674
- /**
2675
- * Get form state summary
2676
- */
2677
- getFormState() {
2678
- if (this._formElement?.getFormState) {
2679
- return this._formElement.getFormState();
2680
- }
2681
- return {
2682
- isValid: true,
2683
- isSubmitting: false,
2684
- hasErrors: false,
2685
- errorCount: 0,
2686
- fieldCount: this._registeredFields.size
2687
- };
2688
- }
2689
- /**
2690
- * Render placeholder when form is empty in editor mode
2691
- */
2692
- renderPlaceholder() {
2693
- return html`
2694
- <div
2695
- class="form-placeholder"
2696
- @click="${() => setCurrentComponentIdAction(this.component?.uuid)}"
2697
- >
2698
- <nr-icon name="file-text"></nr-icon>
2699
- <nr-label>Add form fields to this form</nr-label>
2700
- <drag-wrapper
2701
- .where=${"inside"}
2702
- .message=${"Drop inside"}
2703
- .component=${{ ...this.component }}
2704
- .inputRef=${this.inputRef}
2705
- .isDragInitiator=${this.isDragInitiator}
2706
- >
2707
- </drag-wrapper>
2708
- </div>
2709
- `;
2710
- }
2711
- /**
2712
- * Render children components
2713
- */
2714
- renderChildren() {
2715
- return renderComponent(
2716
- this.childrenComponents.map((component) => ({ ...component, item: this.item })),
2717
- this.item,
2718
- this.isViewMode,
2719
- { ...this.component, uniqueUUID: this.uniqueUUID }
2720
- );
2721
- }
2722
- renderComponent() {
2723
- const inputStyles = this.getStyles();
2724
- const hasChildren = this.childrenComponents.length > 0;
2725
- if (this.isViewMode) {
2726
- return html`
2727
- <nr-form
2728
- ${ref(this.inputRef)}
2729
- class="${`drop-${this.component.uuid}`}"
2730
- style=${Object.entries(inputStyles).map(([k, v]) => `${k}:${v}`).join(";")}
2731
- .disabled=${this.inputHandlersValue?.disabled || false}
2732
- .validateOnChange=${this.inputHandlersValue?.validateOnChange ?? false}
2733
- .validateOnBlur=${this.inputHandlersValue?.validateOnBlur ?? true}
2734
- .preventInvalidSubmission=${this.inputHandlersValue?.preventInvalidSubmission ?? true}
2735
- .resetOnSuccess=${this.inputHandlersValue?.resetOnSuccess ?? false}
2736
- .action=${this.inputHandlersValue?.action ?? nothing}
2737
- .method=${this.inputHandlersValue?.method ?? "POST"}
2738
- @nr-form-submit-success=${(e) => {
2739
- this.executeEvent("onSubmitSuccess", e, {
2740
- formData: e.detail?.formData,
2741
- values: this.getFieldsValue()
2742
- });
2743
- }}
2744
- @nr-form-submit-error=${(e) => {
2745
- this.executeEvent("onSubmitError", e, {
2746
- error: e.detail?.error
2747
- });
2748
- }}
2749
- @nr-form-validation-changed=${(e) => {
2750
- this.executeEvent("onValidationChange", e, {
2751
- validationResult: e.detail?.validationResult
2752
- });
2753
- }}
2754
- @nr-form-field-changed=${(e) => {
2755
- this.executeEvent("onFieldChange", e, {
2756
- field: e.detail?.field
2757
- });
2758
- }}
2759
- @nr-form-reset=${(e) => {
2760
- this.executeEvent("onReset", e, {});
2761
- }}
2762
- >
2763
- ${hasChildren ? this.renderChildren() : nothing}
2764
- </nr-form>
2765
- `;
2766
- }
2767
- return html`
2768
- <nr-form
2769
- ${ref(this.inputRef)}
2770
- class="${`drop-${this.component.uuid}`}"
2771
- style=${Object.entries(inputStyles).map(([k, v]) => `${k}:${v}`).join(";")}
2772
- .disabled=${this.inputHandlersValue?.disabled || false}
2773
- .validateOnChange=${this.inputHandlersValue?.validateOnChange ?? false}
2774
- .validateOnBlur=${this.inputHandlersValue?.validateOnBlur ?? true}
2775
- .preventInvalidSubmission=${this.inputHandlersValue?.preventInvalidSubmission ?? true}
2776
- .resetOnSuccess=${this.inputHandlersValue?.resetOnSuccess ?? false}
2777
- .action=${this.inputHandlersValue?.action ?? nothing}
2778
- .method=${this.inputHandlersValue?.method ?? "POST"}
2779
- @nr-form-submit-success=${(e) => {
2780
- this.executeEvent("onSubmitSuccess", e, {
2781
- formData: e.detail?.formData,
2782
- values: this.getFieldsValue()
2783
- });
2784
- }}
2785
- @nr-form-submit-error=${(e) => {
2786
- this.executeEvent("onSubmitError", e, {
2787
- error: e.detail?.error
2788
- });
2789
- }}
2790
- @nr-form-validation-changed=${(e) => {
2791
- this.executeEvent("onValidationChange", e, {
2792
- validationResult: e.detail?.validationResult
2793
- });
2794
- }}
2795
- @nr-form-field-changed=${(e) => {
2796
- this.executeEvent("onFieldChange", e, {
2797
- field: e.detail?.field
2798
- });
2799
- }}
2800
- @nr-form-reset=${(e) => {
2801
- this.executeEvent("onReset", e, {});
2802
- }}
2803
- >
2804
- ${hasChildren ? this.renderChildren() : this.renderPlaceholder()}
2805
- </nr-form>
2806
- `;
2807
- }
2808
- };
2809
- FormBlock.styles = [formStyles];
2810
- __decorateClass$i([
2811
- property({ type: Object })
2812
- ], FormBlock.prototype, "component", 2);
2813
- __decorateClass$i([
2814
- property({ type: Object })
2815
- ], FormBlock.prototype, "item", 2);
2816
- __decorateClass$i([
2817
- state()
2818
- ], FormBlock.prototype, "_formElement", 2);
2819
- __decorateClass$i([
2820
- state()
2821
- ], FormBlock.prototype, "_registeredFields", 2);
2822
- __decorateClass$i([
2823
- state()
2824
- ], FormBlock.prototype, "childrenComponents", 2);
2825
- FormBlock = __decorateClass$i([
2826
- customElement("form-block")
2827
- ], FormBlock);
2828
-
2829
- var __defProp$h = Object.defineProperty;
2830
- var __getOwnPropDesc$h = Object.getOwnPropertyDescriptor;
2831
- var __decorateClass$h = (decorators, target, key, kind) => {
2832
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target;
2833
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
2834
- if (decorator = decorators[i])
2835
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
2836
- if (kind && result) __defProp$h(target, key, result);
2837
- return result;
2838
- };
2839
- try {
2840
- await import('@nuralyui/table');
2841
- } catch (error) {
2842
- console.warn("[@nuralyui/table] Package not found or failed to load.");
2843
- }
2844
- let TextInputBlock$1 = class TextInputBlock extends BaseElementBlock {
2845
- constructor() {
2846
- super(...arguments);
2847
- this.headers = [
2848
- {
2849
- name: "Id",
2850
- key: "id"
2851
- },
2852
- {
2853
- name: "Status",
2854
- key: "status"
2855
- },
2856
- {
2857
- name: "Priority",
2858
- key: "priority"
2859
- },
2860
- {
2861
- name: "Title",
2862
- key: "title"
2863
- },
2864
- {
2865
- name: "Assignee",
2866
- key: "assignee"
2867
- }
2868
- ];
2869
- this.rows = [
2870
- {
2871
- id: 1,
2872
- status: "Open",
2873
- priority: "Normal",
2874
- title: "Product Details Page - Variant Component (1)",
2875
- assignee: "William Jones"
2876
- },
2877
- {
2878
- id: 2,
2879
- status: "Open",
2880
- priority: "High",
2881
- title: "Product Details Page - Variant Component (2)",
2882
- assignee: "Natalia Hayward"
2883
- },
2884
- {
2885
- id: 3,
2886
- status: "Closed",
2887
- priority: "Normal",
2888
- title: "Product Details Page - Variant Component (3)",
2889
- assignee: "Jess Plant"
2890
- },
2891
- {
2892
- id: 4,
2893
- status: "Open",
2894
- priority: "Normal",
2895
- title: "Product Details Page - Variant Component (4)",
2896
- assignee: "William Jones"
2897
- },
2898
- {
2899
- id: 5,
2900
- status: "Open",
2901
- priority: "Normal",
2902
- title: "Product Details Page - Variant Component (5)",
2903
- assignee: "Kathleen Knowles"
2904
- },
2905
- {
2906
- id: 6,
2907
- status: "Open",
2908
- priority: "High",
2909
- title: "Product Details Page - Variant Component (6)",
2910
- assignee: "Mel Young"
2911
- },
2912
- {
2913
- id: 7,
2914
- status: "Closed",
2915
- priority: "Normal",
2916
- title: "Product Details Page - Variant Component (7)",
2917
- assignee: "Zahid Allison"
2918
- },
2919
- {
2920
- id: 8,
2921
- status: "Closed",
2922
- priority: "High",
2923
- title: "Product Details Page - Variant Component (8)",
2924
- assignee: "William Jones"
2925
- }
2926
- ];
2927
- }
2928
- disconnectedCallback() {
2929
- super.disconnectedCallback();
2930
- if (this.unsubscribe) this.unsubscribe();
2931
- }
2932
- renderComponent() {
2933
- const tableStyles = this.component?.style || {};
2934
- const tableAutoWidth = this.inputHandlersValue?.width;
2935
- this.inputHandlersValue?.height;
2936
- const headers = this.inputHandlersValue?.data ? this.inputHandlersValue?.data?.headers : this.headers;
2937
- const rows = this.inputHandlersValue?.data ? this.inputHandlersValue?.data?.rows : this.rows;
2938
- const size = tableStyles.size || "normal";
2939
- const selectionModeValue = this.component?.input?.selectionMode?.value || this.inputHandlersValue?.selectionMode;
2940
- const selectionMode = selectionModeValue === "multiple" ? "multiple" : selectionModeValue === "single" ? "single" : void 0;
2941
- const filter = this.inputHandlersValue?.filter;
2942
- const fixedHeader = this.inputHandlersValue?.fixedHeader ?? false;
2943
- const loading = this.inputHandlersValue?.loading ?? false;
2944
- const expandable = this.inputHandlersValue?.expandable ?? false;
2945
- const emptyText = this.inputHandlersValue?.emptyText ?? "No data available";
2946
- const emptyIcon = this.inputHandlersValue?.emptyIcon;
2947
- const expansionRenderer = this.inputHandlersValue?.expansionRenderer;
2948
- const scrollConfig = this.inputHandlersValue?.scrollConfig;
2949
- return html`
2950
- <nr-table
2951
- ${ref(this.inputRef)}
2952
- style=${styleMap({
2953
- ...tableStyles,
2954
- width: tableAutoWidth ? "auto" : tableStyles.width,
2955
- "overflow": "auto"
2956
- })}
2957
- .headers="${headers}"
2958
- .rows="${rows}"
2959
- .size=${size}
2960
- .withFilter=${filter === "filter"}
2961
- .expandable=${expandable ?? nothing}
2962
- .expansionRenderer=${expansionRenderer ?? nothing}
2963
- .selectionMode=${selectionMode}
2964
- .fixedHeader=${fixedHeader}
2965
- .scrollConfig=${scrollConfig ?? nothing}
2966
- .loading=${loading}
2967
- .emptyText=${emptyText}
2968
- .emptyIcon=${emptyIcon ?? nothing}
2969
- @onPaginate=${(e) => {
2970
- this.executeEvent("onPaginate", e);
2971
- }}
2972
- @nr-select=${(e) => {
2973
- this.executeEvent("onSelect", e);
2974
- }}
2975
- @onSearch=${(e) => {
2976
- this.executeEvent("onSearch", e);
2977
- }}
2978
- @onSort=${(e) => {
2979
- this.executeEvent("onSort", e);
2980
- }}
2981
- >
2982
- </nr-table>
2983
-
2984
- `;
2985
- }
2986
- };
2987
- TextInputBlock$1.styles = [
2988
- css``
2989
- ];
2990
- __decorateClass$h([
2991
- property({ type: Object })
2992
- ], TextInputBlock$1.prototype, "component", 2);
2993
- __decorateClass$h([
2994
- property({ type: Object })
2995
- ], TextInputBlock$1.prototype, "item", 2);
2996
- __decorateClass$h([
2997
- state()
2998
- ], TextInputBlock$1.prototype, "headers", 2);
2999
- __decorateClass$h([
3000
- state()
3001
- ], TextInputBlock$1.prototype, "rows", 2);
3002
- TextInputBlock$1 = __decorateClass$h([
3003
- customElement("table-block")
3004
- ], TextInputBlock$1);
3005
-
3006
- var __defProp$g = Object.defineProperty;
3007
- var __getOwnPropDesc$g = Object.getOwnPropertyDescriptor;
3008
- var __decorateClass$g = (decorators, target, key, kind) => {
3009
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target;
3010
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
3011
- if (decorator = decorators[i])
3012
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
3013
- if (kind && result) __defProp$g(target, key, result);
3014
- return result;
3015
- };
3016
- try {
3017
- await import('@nuralyui/icon');
3018
- } catch (error) {
3019
- console.warn("[@nuralyui/icon] Package not found or failed to load.");
3020
- }
3021
- let IconBlock = class extends BaseElementBlock {
3022
- constructor() {
3023
- super();
3024
- this.registerCallback("icon", () => {
3025
- });
3026
- }
3027
- connectedCallback() {
3028
- super.connectedCallback();
3029
- }
3030
- renderComponent() {
3031
- const iconStyles = this.getStyles();
3032
- return html`
3033
- <nr-icon
3034
- ${ref(this.inputRef)}
3035
- .name=${this.inputHandlersValue.icon ?? "smile"}
3036
- .type=${this.inputHandlersValue.type || "solid"}
3037
- .alt=${this.inputHandlersValue.alt || ""}
3038
- .size=${this.inputHandlersValue.size || nothing}
3039
- .color=${this.inputHandlersValue.color || nothing}
3040
- .width=${iconStyles?.width || nothing}
3041
- .height=${iconStyles?.height || nothing}
3042
- .clickable=${this.inputHandlersValue.clickable || false}
3043
- .disabled=${this.inputHandlersValue.state === "disabled"}
3044
- @click=${(e) => {
3045
- this.executeEvent("onClick", e);
3046
- }}
3047
- @icon-click=${(e) => {
3048
- this.executeEvent("onIconClick", e);
3049
- }}
3050
- @icon-keyboard-activation=${(e) => {
3051
- this.executeEvent("onIconKeyboardActivation", e);
3052
- }}
3053
- style=${styleMap({
3054
- display: "block",
3055
- ...this.getStyles(),
3056
- "--nuraly-icon-width": iconStyles?.width,
3057
- "--nuraly-icon-height": iconStyles?.height
3058
- })}>
3059
- </nr-icon>
3060
- `;
3061
- }
3062
- };
3063
- __decorateClass$g([
3064
- property({ type: Object })
3065
- ], IconBlock.prototype, "component", 2);
3066
- __decorateClass$g([
3067
- property({ type: Object })
3068
- ], IconBlock.prototype, "item", 2);
3069
- IconBlock = __decorateClass$g([
3070
- customElement("icon-block")
3071
- ], IconBlock);
3072
-
3073
- var __defProp$f = Object.defineProperty;
3074
- var __getOwnPropDesc$f = Object.getOwnPropertyDescriptor;
3075
- var __decorateClass$f = (decorators, target, key, kind) => {
3076
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target;
3077
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
3078
- if (decorator = decorators[i])
3079
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
3080
- if (kind && result) __defProp$f(target, key, result);
3081
- return result;
3082
- };
3083
- try {
3084
- await import('@nuralyui/image');
3085
- } catch (error) {
3086
- console.warn("[@nuralyui/image] Package not found or failed to load.");
3087
- }
3088
- let ImageBlock = class extends BaseElementBlock {
3089
- connectedCallback() {
3090
- super.connectedCallback();
3091
- this.isDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches;
3092
- window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", (event) => {
3093
- this.isDarkMode = event.matches;
3094
- this.requestUpdate();
3095
- });
3096
- }
3097
- renderComponent() {
3098
- const fallbackStyles = this.getStyles();
3099
- const imageStyles = this.getStyles() || {};
3100
- const imageStyleHandlers = this.component?.styleHandlers ? Object.fromEntries(
3101
- Object.entries(this.component?.styleHandlers).filter(([key, value]) => value)
3102
- ) : {};
3103
- const imageSrc = this.isDarkMode ? this.inputHandlersValue?.darkSrc ?? this.inputHandlersValue?.src : this.inputHandlersValue?.src;
3104
- if (!imageSrc) {
3105
- return html`
3106
- <div
3107
- ${ref(this.inputRef)}
3108
- class="image-placeholder"
3109
- style=${styleMap({
3110
- width: imageStyleHandlers?.width || imageStyles?.width || "100%",
3111
- height: imageStyleHandlers?.height || imageStyles?.height || "200px"
3112
- })}
3113
- @click=${(e) => this.executeEvent("onClick", e)}
3114
- >
3115
- <nr-icon name="image"></nr-icon>
3116
- <nr-label>No image source</nr-label>
3117
- </div>
3118
- `;
3119
- }
3120
- return html`
3121
- <nr-image
3122
- ${ref(this.inputRef)}
3123
- style=${styleMap({
3124
- ...this.getStyles(),
3125
- "display": "block",
3126
- "--nuraly-image-local-border-top-left-radius": fallbackStyles?.["border-top-left-radius"] ?? "",
3127
- "--nuraly-image-local-border-top-right-radius": fallbackStyles?.["border-top-right-radius"] ?? "",
3128
- "--nuraly-image-local-border-bottom-left-radius": fallbackStyles?.["border-bottom-left-radius"] ?? "",
3129
- "--nuraly-image-local-border-bottom-right-radius": fallbackStyles?.["border-bottom-right-radius"] ?? ""
3130
- })}
3131
- .src=${imageSrc}
3132
- .fallback=${this.inputHandlersValue?.fallback ?? nothing}
3133
- .previewable=${this.inputHandlersValue?.previewable ?? false}
3134
- .fit=${this.inputHandlersValue?.fit ?? nothing}
3135
- .block=${this.inputHandlersValue?.block ?? false}
3136
- .width=${imageStyleHandlers?.width || imageStyles?.width}
3137
- .height=${imageStyleHandlers?.height || imageStyles?.height}
3138
- .alt=${this.inputHandlersValue?.alt ?? "image"}
3139
- @click=${(e) => this.executeEvent("onClick", e)}
3140
- @nr-image-error=${(e) => this.executeEvent("onError", e)}
3141
- @nr-image-load=${(e) => this.executeEvent("onLoad", e)}
3142
- @nr-image-preview-open=${(e) => this.executeEvent("onPreviewOpen", e)}
3143
- @nr-image-preview-close=${(e) => this.executeEvent("onPreviewClose", e)}
3144
- >
3145
- </nr-image>
3146
- `;
3147
- }
3148
- };
3149
- ImageBlock.styles = [css`
3150
- :host {
3151
- display: block;
3152
- }
3153
- .image-placeholder {
3154
- display: flex;
3155
- flex-direction: column;
3156
- align-items: center;
3157
- justify-content: center;
3158
- color: #64748b;
3159
- min-height: 200px;
3160
- min-width: 200px;
3161
- border-radius: 8px;
3162
- border: 2px dashed #cbd5e1;
3163
- gap: 12px;
3164
- box-sizing: border-box;
3165
- }
3166
- .image-placeholder nr-icon {
3167
- --nuraly-icon-size: 48px;
3168
- }
3169
- `];
3170
- __decorateClass$f([
3171
- property({ type: Object })
3172
- ], ImageBlock.prototype, "component", 2);
3173
- ImageBlock = __decorateClass$f([
3174
- customElement("image-block")
3175
- ], ImageBlock);
3176
-
3177
- var __defProp$e = Object.defineProperty;
3178
- var __getOwnPropDesc$e = Object.getOwnPropertyDescriptor;
3179
- var __decorateClass$e = (decorators, target, key, kind) => {
3180
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target;
3181
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
3182
- if (decorator = decorators[i])
3183
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
3184
- if (kind && result) __defProp$e(target, key, result);
3185
- return result;
3186
- };
3187
- try {
3188
- await import('@nuralyui/divider');
3189
- } catch (error) {
3190
- console.warn("[@nuralyui/divider] Package not found or failed to load.");
3191
- }
3192
- let DividerBlock = class extends BaseElementBlock {
3193
- connectedCallback() {
3194
- super.connectedCallback();
3195
- this.registerCallback("value", () => {
3196
- });
3197
- this.updateHostAttribute();
3198
- }
3199
- updated(changedProperties) {
3200
- super.updated(changedProperties);
3201
- this.updateHostAttribute();
3202
- }
3203
- updateHostAttribute() {
3204
- const direction = this.inputHandlersValue?.direction ?? "horizontal";
3205
- this.setAttribute("data-type", direction);
3206
- }
3207
- disconnectedCallback() {
3208
- super.disconnectedCallback();
3209
- if (this.unsubscribe) this.unsubscribe();
3210
- }
3211
- render() {
3212
- const dividerStyles = this.component?.style || {};
3213
- const dividerAutoWidth = this.inputHandlersValue?.width;
3214
- const dividerAutoHeight = this.inputHandlersValue?.height;
3215
- const isVertical = (this.inputHandlersValue?.direction ?? "horizontal") === "vertical";
3216
- const filteredStyles = { ...dividerStyles };
3217
- if (isVertical && dividerAutoHeight) {
3218
- delete filteredStyles.height;
3219
- }
3220
- return html`
3221
- ${!this.inputHandlersValue?.display || this.inputHandlersValue.display == "show" ? html`
3222
- <nr-divider
3223
- ${ref(this.inputRef)}
3224
- style=${styleMap({
3225
- ...filteredStyles,
3226
- width: dividerAutoWidth ? "100%" : dividerStyles.width,
3227
- height: !isVertical && dividerAutoHeight ? "auto" : filteredStyles.height
3228
- })}
3229
- type=${this.inputHandlersValue?.direction ?? "horizontal"}
3230
- .variant=${this.inputHandlersValue?.variant || "solid"}
3231
- .orientation=${this.inputHandlersValue?.textOrientation || "center"}
3232
- .orientationMargin=${this.inputHandlersValue?.orientationMargin ?? nothing}
3233
- .plain=${this.inputHandlersValue?.plain !== false}
3234
- .size=${this.inputHandlersValue?.size ?? nothing}
3235
- .dashed=${this.inputHandlersValue?.dashed || false}
3236
- @click=${(e) => {
3237
- this.executeEvent("onClick", e);
3238
- }}
3239
- >
3240
- ${this.inputHandlersValue?.text || ""}
3241
- </nr-divider>
3242
- ` : nothing}
3243
- `;
3244
- }
3245
- };
3246
- DividerBlock.styles = [
3247
- css`
3248
- :host {
3249
- display: block;
3250
- width: 100%;
3251
- }
3252
-
3253
- :host([data-type="vertical"]) {
3254
- display: inline-flex;
3255
- width: auto;
3256
- align-self: stretch; /* This makes it fill the parent's height in flexbox */
3257
- }
3258
-
3259
- :host([data-type="vertical"]) nr-divider {
3260
- height: 100%;
3261
- display: flex;
3262
- align-items: stretch;
3263
- }
3264
- `
3265
- ];
3266
- __decorateClass$e([
3267
- property({ type: Object })
3268
- ], DividerBlock.prototype, "component", 2);
3269
- __decorateClass$e([
3270
- property({ type: Object })
3271
- ], DividerBlock.prototype, "item", 2);
3272
- DividerBlock = __decorateClass$e([
3273
- customElement("divider-block")
3274
- ], DividerBlock);
3275
-
3276
- const textLabelStyles = css`
3277
- label{
3278
- color:var(--text-label-color);
3279
- user-select: none
3280
- }
3281
-
3282
- :host{
3283
- display: flex;
3284
- width:fit-content;
3285
- }
3286
-
3287
- @media (prefers-color-scheme: dark) {
3288
- :host {
3289
- }
3290
- }
3291
-
3292
- `;
3293
- const styles$2 = [textLabelStyles];
3294
-
3295
- var __defProp$d = Object.defineProperty;
3296
- var __getOwnPropDesc$d = Object.getOwnPropertyDescriptor;
3297
- var __decorateClass$d = (decorators, target, key, kind) => {
3298
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target;
3299
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
3300
- if (decorator = decorators[i])
3301
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
3302
- if (kind && result) __defProp$d(target, key, result);
3303
- return result;
3304
- };
3305
- try {
3306
- await import('@nuralyui/label');
3307
- } catch (error) {
3308
- console.warn("[@nuralyui/label] Package not found or failed to load.");
3309
- }
3310
- let TextLabelBlock = class extends BaseElementBlock {
3311
- constructor() {
3312
- super();
3313
- this.isEditable = false;
3314
- this.registerCallback("innerAlignment", (value) => {
3315
- if (this.closestGenericComponentWrapper) {
3316
- if (this.inputHandlersValue?.innerAlignment === "end") {
3317
- this.closestGenericComponentWrapper.style.marginLeft = "auto";
3318
- } else {
3319
- this.closestGenericComponentWrapper.style.marginLeft = "unset";
3320
- }
3321
- }
3322
- });
3323
- }
3324
- renderComponent() {
3325
- return html`
3326
- <nr-label
3327
- class="${`drop-${this.component.uuid}`}"
3328
- @input=${(e) => {
3329
- const eventData = { ["value"]: { type: "string", value: e.target.innerText } };
3330
- this.executeEvent("onInput", e, eventData);
3331
- }}
3332
- ${ref(this.inputRef)}
3333
- id=${this.component.uuid}
3334
- .size=${this.inputHandlersValue.size ?? "medium"}
3335
- .variant=${this.inputHandlersValue.variant || "default"}
3336
- .required=${this.inputHandlersValue.required || false}
3337
- .disabled=${this.inputHandlersValue.state === "disabled"}
3338
- .for=${this.inputHandlersValue.for || nothing}
3339
- .value=${this.inputHandlersValue.value || ""}
3340
- contentEditable="${this.isEditable}"
3341
- @click=${(e) => {
3342
- this.executeEvent("onClick", e);
3343
- }}
3344
- @mouseenter=${(e) => {
3345
- this.executeEvent("onMouseEnter", e);
3346
- }}
3347
- @mouseleave=${(e) => {
3348
- this.executeEvent("onMouseLeave", e);
3349
- }}
3350
-
3351
- @dblclick=${(e) => {
3352
- e.preventDefault();
3353
- this.isEditable = true;
3354
- }}>${this.inputHandlersValue.value || "Text label"}</nr-label>
3355
- `;
3356
- }
3357
- };
3358
- TextLabelBlock.styles = styles$2;
3359
- __decorateClass$d([
3360
- property({ type: Object })
3361
- ], TextLabelBlock.prototype, "component", 2);
3362
- __decorateClass$d([
3363
- property({ type: Object })
3364
- ], TextLabelBlock.prototype, "item", 2);
3365
- __decorateClass$d([
3366
- state()
3367
- ], TextLabelBlock.prototype, "isEditable", 2);
3368
- TextLabelBlock = __decorateClass$d([
3369
- customElement("text-label-block")
3370
- ], TextLabelBlock);
3371
-
3372
- var __defProp$c = Object.defineProperty;
3373
- var __getOwnPropDesc$c = Object.getOwnPropertyDescriptor;
3374
- var __decorateClass$c = (decorators, target, key, kind) => {
3375
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target;
3376
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
3377
- if (decorator = decorators[i])
3378
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
3379
- if (kind && result) __defProp$c(target, key, result);
3380
- return result;
3381
- };
3382
- let TextInputBlock = class extends BaseElementBlock {
3383
- constructor() {
3384
- super(...arguments);
3385
- this.isEditorLoaded = false;
3386
- }
3387
- connectedCallback() {
3388
- super.connectedCallback();
3389
- this.loadEditor();
3390
- }
3391
- async loadEditor() {
3392
- if (!this.isEditorLoaded) {
3393
- await import('./CodeEditor-Cpph-xRc.js');
3394
- this.isEditorLoaded = true;
3395
- }
3396
- }
3397
- disconnectedCallback() {
3398
- super.disconnectedCallback();
3399
- }
3400
- handleCodeEditorChange(event) {
3401
- const value = event.detail.value;
3402
- if (!this.isViewMode) {
3403
- const serializedValue = JSON.stringify(value);
3404
- executeHandler(
3405
- this.component,
3406
- /* js */
3407
- `
3408
- try {
3409
- const selectedComponent = Utils.first($selectedComponents);
3410
- updateInput(selectedComponent, "value", "string", ${serializedValue}, null);
3411
- } catch (error) {
3412
- console.error(error);
3413
- }
3414
- `,
3415
- {}
3416
- );
3417
- }
3418
- this.executeEvent("onChange", event, { value });
3419
- }
3420
- renderComponent() {
3421
- return html`
3422
- ${this.isEditorLoaded ? html`
3423
- <code-editor
3424
- ${ref(this.inputRef)}
3425
- style=${styleMap({
3426
- ...this.getStyles(),
3427
- display: "block"
3428
- })}
3429
- language="${this.inputHandlersValue?.language ?? "javascript"}"
3430
- theme="${this.inputHandlersValue?.theme ?? "vs-dark"}"
3431
- .readonly=${this.inputHandlersValue?.readonly ?? this.isViewMode === true}
3432
- .code=${this.inputHandlersValue?.value ?? ""}
3433
- @click=${(e) => {
3434
- this.executeEvent("onClick", e);
3435
- }}
3436
- @change=${(event) => {
3437
- this.handleCodeEditorChange(event);
3438
- }}
3439
- @editor-keydown=${(event) => {
3440
- this.executeEvent("onKeyDown", event, {
3441
- key: event.detail.key,
3442
- code: event.detail.code,
3443
- ctrlKey: event.detail.ctrlKey,
3444
- shiftKey: event.detail.shiftKey,
3445
- altKey: event.detail.altKey,
3446
- metaKey: event.detail.metaKey
3447
- });
3448
- }}
3449
- @editor-keyup=${(event) => {
3450
- this.executeEvent("onKeyUp", event, {
3451
- key: event.detail.key,
3452
- code: event.detail.code,
3453
- ctrlKey: event.detail.ctrlKey,
3454
- shiftKey: event.detail.shiftKey,
3455
- altKey: event.detail.altKey,
3456
- metaKey: event.detail.metaKey
3457
- });
3458
- }}
3459
- >
3460
- </code-editor>
3461
- ` : html`<p>Loading editor...</p>`}
3462
- `;
3463
- }
3464
- };
3465
- TextInputBlock.styles = [
3466
- css`
3467
- :host {
3468
- }
3469
- code-editor {
3470
- display: block;
3471
- height: 100px;
3472
- }
3473
- `
3474
- ];
3475
- __decorateClass$c([
3476
- property({ type: Object })
3477
- ], TextInputBlock.prototype, "component", 2);
3478
- __decorateClass$c([
3479
- property({ type: Object })
3480
- ], TextInputBlock.prototype, "item", 2);
3481
- __decorateClass$c([
3482
- state()
3483
- ], TextInputBlock.prototype, "isEditorLoaded", 2);
3484
- TextInputBlock = __decorateClass$c([
3485
- customElement("code-block")
3486
- ], TextInputBlock);
3487
-
3488
- var __defProp$b = Object.defineProperty;
3489
- var __getOwnPropDesc$b = Object.getOwnPropertyDescriptor;
3490
- var __decorateClass$b = (decorators, target, key, kind) => {
3491
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target;
3492
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
3493
- if (decorator = decorators[i])
3494
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
3495
- if (kind && result) __defProp$b(target, key, result);
3496
- return result;
3497
- };
3498
- try {
3499
- await import('@nuralyui/video');
3500
- } catch (error) {
3501
- console.warn("[@nuralyui/video] Package not found or failed to load.");
3502
- }
3503
- let VideoBlock = class extends BaseElementBlock {
3504
- renderComponent() {
3505
- const videoStyles = this.getStyles() || {};
3506
- const videoStyleHandlers = this.component?.styleHandlers ? Object.fromEntries(
3507
- Object.entries(this.component?.styleHandlers).filter(([key, value]) => value)
3508
- ) : {};
3509
- const src = this.inputHandlersValue?.src;
3510
- const poster = this.inputHandlersValue?.poster;
3511
- const autoplay = this.inputHandlersValue?.autoplay ?? false;
3512
- const controls = this.inputHandlersValue?.controls ?? true;
3513
- const loop = this.inputHandlersValue?.loop ?? false;
3514
- const muted = this.inputHandlersValue?.muted ?? false;
3515
- const preload = this.inputHandlersValue?.preload ?? "metadata";
3516
- if (!src) {
3517
- return html`
3518
- <div
3519
- ${ref(this.inputRef)}
3520
- class="video-placeholder"
3521
- style=${styleMap({
3522
- ...this.getStyles(),
3523
- width: videoStyleHandlers?.width || videoStyles?.width || "100%",
3524
- height: videoStyleHandlers?.height || videoStyles?.height || "200px"
3525
- })}
3526
- @click=${(e) => this.executeEvent("onClick", e)}
3527
- >
3528
- <nr-icon name="video"></nr-icon>
3529
- <nr-label>No video source</nr-label>
3530
- </div>
3531
- `;
3532
- }
3533
- return html`
3534
- <nr-video-player
3535
- ${ref(this.inputRef)}
3536
- style=${styleMap({
3537
- ...this.getStyles(),
3538
- "display": "block"
3539
- })}
3540
- .src=${src}
3541
- .poster=${poster ?? nothing}
3542
- .autoplay=${autoplay}
3543
- .controls=${controls}
3544
- .loop=${loop}
3545
- .muted=${muted}
3546
- .preload=${preload}
3547
- .width=${videoStyleHandlers?.width || videoStyles?.width}
3548
- .height=${videoStyleHandlers?.height || videoStyles?.height}
3549
- @click=${(e) => this.executeEvent("onClick", e)}
3550
- @play=${(e) => this.executeEvent("onPlay", e)}
3551
- @pause=${(e) => this.executeEvent("onPause", e)}
3552
- @ended=${(e) => this.executeEvent("onEnded", e)}
3553
- @loadeddata=${(e) => this.executeEvent("onLoad", e)}
3554
- @error=${(e) => this.executeEvent("onError", e)}
3555
- @timeupdate=${(e) => {
3556
- const video = e.target;
3557
- this.executeEvent("onTimeUpdate", e, {
3558
- currentTime: video?.currentTime,
3559
- duration: video?.duration
3560
- });
3561
- }}
3562
- @volumechange=${(e) => {
3563
- const video = e.target;
3564
- this.executeEvent("onVolumeChange", e, {
3565
- volume: video?.volume,
3566
- muted: video?.muted
3567
- });
3568
- }}
3569
- >
3570
- </nr-video-player>
3571
- `;
3572
- }
3573
- };
3574
- VideoBlock.styles = [css`
3575
- .video-placeholder {
3576
- display: flex;
3577
- flex-direction: column;
3578
- align-items: center;
3579
- justify-content: center;
3580
- color: #64748b;
3581
- min-height: 200px;
3582
- border-radius: 8px;
3583
- border: 2px dashed #cbd5e1;
3584
- gap: 12px;
3585
- }
3586
- .video-placeholder nr-icon {
3587
- --nuraly-icon-size: 48px;
3588
- }
3589
- .video-placeholder span {
3590
- font-size: 14px;
3591
- font-weight: 500;
3592
- }
3593
- `];
3594
- __decorateClass$b([
3595
- property({ type: Object })
3596
- ], VideoBlock.prototype, "component", 2);
3597
- VideoBlock = __decorateClass$b([
3598
- customElement("video-block")
3599
- ], VideoBlock);
3600
-
3601
- var __defProp$a = Object.defineProperty;
3602
- var __getOwnPropDesc$a = Object.getOwnPropertyDescriptor;
3603
- var __decorateClass$a = (decorators, target, key, kind) => {
3604
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target;
3605
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
3606
- if (decorator = decorators[i])
3607
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
3608
- if (kind && result) __defProp$a(target, key, result);
3609
- return result;
3610
- };
3611
- try {
3612
- await import('@nuralyui/badge');
3613
- } catch (error) {
3614
- console.warn("[@nuralyui/badge] Package not found or failed to load.");
3615
- }
3616
- let BadgeBlock = class extends BaseElementBlock {
3617
- renderComponent() {
3618
- const badgeStyles = this.component?.style || {};
3619
- const count = this.component?.input?.count?.value ?? this.inputHandlersValue?.count;
3620
- const text = this.component?.input?.text?.value || this.inputHandlersValue?.text || "";
3621
- const dot = this.component?.input?.dot?.value ?? this.inputHandlersValue?.dot ?? false;
3622
- const showZero = this.component?.input?.showZero?.value ?? this.inputHandlersValue?.showZero ?? false;
3623
- const overflowCount = this.component?.input?.overflowCount?.value || this.inputHandlersValue?.overflowCount || 99;
3624
- const size = this.component?.input?.size?.value || this.inputHandlersValue?.size || "default";
3625
- const color = this.component?.input?.color?.value || this.inputHandlersValue?.color;
3626
- const status = this.component?.input?.status?.value || this.inputHandlersValue?.status;
3627
- const ribbon = this.component?.input?.ribbon?.value || this.inputHandlersValue?.ribbon;
3628
- const ribbonPlacement = this.component?.input?.ribbonPlacement?.value || this.inputHandlersValue?.ribbonPlacement || "end";
3629
- const offsetX = this.component?.input?.offsetX?.value || this.inputHandlersValue?.offsetX;
3630
- const offsetY = this.component?.input?.offsetY?.value || this.inputHandlersValue?.offsetY;
3631
- const offset = offsetX || offsetY ? [offsetX || 0, offsetY || 0] : void 0;
3632
- return html`
3633
- <nr-badge
3634
- ${ref(this.inputRef)}
3635
- style=${styleMap(badgeStyles)}
3636
- .count=${count}
3637
- .text=${text}
3638
- .size=${size}
3639
- .color=${color}
3640
- .status=${status}
3641
- .ribbon=${ribbon}
3642
- .ribbonPlacement=${ribbonPlacement}
3643
- .overflowCount=${overflowCount}
3644
- .offset=${offset}
3645
- ?dot=${dot}
3646
- ?showZero=${showZero}
3647
- >
3648
- <slot></slot>
3649
- </nr-badge>
3650
- `;
3651
- }
3652
- };
3653
- BadgeBlock.styles = [css``];
3654
- __decorateClass$a([
3655
- property({ type: Object })
3656
- ], BadgeBlock.prototype, "component", 2);
3657
- __decorateClass$a([
3658
- property({ type: Object })
3659
- ], BadgeBlock.prototype, "item", 2);
3660
- BadgeBlock = __decorateClass$a([
3661
- customElement("badge-block")
3662
- ], BadgeBlock);
3663
-
3664
- var __defProp$9 = Object.defineProperty;
3665
- var __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor;
3666
- var __decorateClass$9 = (decorators, target, key, kind) => {
3667
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target;
3668
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
3669
- if (decorator = decorators[i])
3670
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
3671
- if (kind && result) __defProp$9(target, key, result);
3672
- return result;
3673
- };
3674
- try {
3675
- await import('@nuralyui/tag');
3676
- } catch (error) {
3677
- console.warn("[@nuralyui/tag] Package not found or failed to load.");
3678
- }
3679
- let TagBlock = class extends BaseElementBlock {
3680
- renderComponent() {
3681
- const tagStyles = this.component?.style || {};
3682
- const label = this.component?.input?.label?.value || this.inputHandlersValue?.label || "";
3683
- const closable = this.component?.input?.closable?.value ?? this.inputHandlersValue?.closable ?? false;
3684
- const color = this.component?.input?.color?.value || this.inputHandlersValue?.color;
3685
- const icon = this.component?.input?.icon?.value || this.inputHandlersValue?.icon;
3686
- const bordered = this.component?.input?.bordered?.value ?? this.inputHandlersValue?.bordered ?? true;
3687
- return html`
3688
- <nr-tag
3689
- ${ref(this.inputRef)}
3690
- style=${styleMap(tagStyles)}
3691
- .color=${color}
3692
- ?closable=${closable}
3693
- ?bordered=${bordered}
3694
- @nr-tag-close=${(e) => {
3695
- this.executeEvent("onClose", e);
3696
- }}
3697
- @click=${(e) => {
3698
- this.executeEvent("onClick", e);
3699
- }}
3700
- >
3701
- ${icon ? html`<nr-icon slot="icon" .name=${icon}></nr-icon>` : ""}
3702
- ${label}
3703
- </nr-tag>
3704
- `;
3705
- }
3706
- };
3707
- TagBlock.styles = [css``];
3708
- __decorateClass$9([
3709
- property({ type: Object })
3710
- ], TagBlock.prototype, "component", 2);
3711
- __decorateClass$9([
3712
- property({ type: Object })
3713
- ], TagBlock.prototype, "item", 2);
3714
- TagBlock = __decorateClass$9([
3715
- customElement("tag-block")
3716
- ], TagBlock);
3717
-
3718
- const styles$1 = css`
3719
- :host {
3720
- display:flex;
3721
- align-items:center;
3722
- }
3723
- .chat-input-container {
3724
- position: relative;
3725
- display: inline-block;
3726
- width: 100%;
3727
- }
3728
- .chat-input {
3729
- display: flex;
3730
- margin-top: 10px;
3731
- width: 100%;
3732
- }
3733
- .chat-input nr-input {
3734
- flex: 1;
3735
- margin-right: 10px;
3736
- }
3737
- .chat-messages {
3738
- margin-top: 10px;
3739
- max-height: 200px;
3740
- overflow-y: auto;
3741
- background-color: #f9f9f9;
3742
- border: 1px solid #ccc;
3743
- border-radius: 8px;
3744
- padding: 10px;
3745
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
3746
- }
3747
- .chat-message {
3748
- border-radius: 16px;
3749
- padding: 8px 12px;
3750
- margin-bottom: 8px;
3751
- max-width: 80%;
3752
- word-wrap: break-word;
3753
- }
3754
- .ai-message {
3755
- background-color: #d1fae5;
3756
- align-self: flex-start;
3757
- }
3758
- .error-message {
3759
- color: red;
3760
- margin-top: 10px;
3761
- }
3762
- .loading-indicator {
3763
- margin-top: 10px;
3764
- font-size: 14px;
3765
- color: #555;
3766
- }
3767
- `;
3768
-
3769
- function createChat() {
3770
- return fetch("/api/chat", {
3771
- method: "POST",
3772
- headers: {
3773
- "Content-Type": "application/json"
3774
- }
3775
- }).then((response) => {
3776
- if (!response.ok) {
3777
- throw new Error(`HTTP error! status: ${response.status}`);
3778
- }
3779
- return response.json();
3780
- }).then((data) => {
3781
- return data;
3782
- }).catch((error) => {
3783
- console.error("Error creating chat:", error);
3784
- throw error;
3785
- });
3786
- }
3787
-
3788
- function replaceUUIDs(data) {
3789
- const uuidMapping = {};
3790
- data.forEach((item) => {
3791
- const newUUID = v4();
3792
- uuidMapping[item.uuid] = newUUID;
3793
- });
3794
- data.forEach((item) => {
3795
- if (uuidMapping[item.uuid]) {
3796
- item.uuid = uuidMapping[item.uuid];
3797
- }
3798
- if (item.childrenIds) {
3799
- item.childrenIds = item.childrenIds.map((childId) => {
3800
- return uuidMapping[childId] || childId;
3801
- });
3802
- }
3803
- });
3804
- return data;
3805
- }
3806
-
3807
- var __defProp$8 = Object.defineProperty;
3808
- var __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor;
3809
- var __decorateClass$8 = (decorators, target, key, kind) => {
3810
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target;
3811
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
3812
- if (decorator = decorators[i])
3813
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
3814
- if (kind && result) __defProp$8(target, key, result);
3815
- return result;
3816
- };
3817
- try {
3818
- await import('@nuralyui/slider-input');
3819
- } catch (error) {
3820
- console.warn("[@nuralyui/slider-input] Package not found or failed to load.");
3821
- }
3822
- try {
3823
- await import('@nuralyui/button');
3824
- } catch (error) {
3825
- console.warn("[@nuralyui/button] Package not found or failed to load.");
3826
- }
3827
- try {
3828
- await import('@nuralyui/input');
3829
- } catch (error) {
3830
- console.warn("[@nuralyui/input] Package not found or failed to load.");
3831
- }
3832
- let AiChat = class extends BaseElementBlock {
3833
- constructor() {
3834
- super(...arguments);
3835
- this.preview = false;
3836
- this.rootUUID = "";
3837
- this.isChatBoxVisible = false;
3838
- this.chatUuid = "";
3839
- this.messages = [];
3840
- this.errorMessage = "";
3841
- this.inputValue = "";
3842
- this.isLoading = false;
3843
- }
3844
- connectedCallback() {
3845
- super.connectedCallback();
3846
- }
3847
- render() {
3848
- const aiChatStyle = this.component?.style || {};
3849
- return html`
3850
- <div class="chat-input-container" style=${styleMap({ ...aiChatStyle })}>
3851
- <nr-button @click=${this.toggleChatBox}>Ask AI</nr-button>
3852
- ${this.isChatBoxVisible ? html`
3853
- <div class="chat-input">
3854
- <nr-input value=${this.inputValue} placeholder="Type your message" @valueChange=${this.handleInputChange} @keyup=${this.handleKeyUp} ></nr-input>
3855
- <nr-button @click=${this.handleSendMessage}>Send</nr-button>
3856
- </div>
3857
- ${this.messages.length > 0 ? html`
3858
- <div class="chat-messages">
3859
- ${this.preview ? html`<micro-app uuid=${this.chatUuid} componentToRenderUUID=${this.rootUUID}></micro-app>` : ""}
3860
- <nr-button @click=${() => addGeneratedComponents(this.structureComponent)}>Insert</nr-button>
3861
- </div>
3862
- ` : ""}
3863
- ${this.errorMessage ? html`<div class="error-message">${this.errorMessage}</div>` : ""}
3864
- ${this.isLoading ? html`<div class="loading-indicator">Loading...</div>` : ""}
3865
- ` : ""}
3866
- </div>
3867
- `;
3868
- }
3869
- async toggleChatBox() {
3870
- this.isChatBoxVisible = !this.isChatBoxVisible;
3871
- if (this.isChatBoxVisible) {
3872
- await this.getChatUuid();
3873
- } else {
3874
- this.errorMessage = "";
3875
- }
3876
- }
3877
- async getChatUuid() {
3878
- this.isLoading = true;
3879
- createChat().then((data) => {
3880
- this.chatUuid = data.chat_id;
3881
- this.errorMessage = "";
3882
- }).catch((error) => {
3883
- console.error("Error getting chat UUID:", error);
3884
- this.errorMessage = "Cannot connect to server. Please try again.";
3885
- }).finally(() => {
3886
- this.isLoading = false;
3887
- });
3888
- }
3889
- async sendMessage(message) {
3890
- this.isLoading = true;
3891
- try {
3892
- const response = await fetch(`/api/chat/${this.chatUuid}`, {
3893
- method: "POST",
3894
- headers: {
3895
- "Content-Type": "application/json"
3896
- },
3897
- body: JSON.stringify({ query: message })
3898
- });
3899
- const aiResponse = (await response.json()).response;
3900
- this.messages.push({ type: "ai", content: aiResponse });
3901
- this.structureComponent = [];
3902
- const result = aiResponse.components ?? aiResponse;
3903
- if (Array.isArray(result)) {
3904
- this.structureComponent = result.map((component) => {
3905
- component.application_id = this.chatUuid;
3906
- return component;
3907
- });
3908
- }
3909
- this.structureComponent = replaceUUIDs(this.structureComponent);
3910
- const structureComponentRoot = this.structureComponent.find((component) => component.component_type === "vertical-container-block");
3911
- this.rootUUID = structureComponentRoot.uuid;
3912
- addTempApplication(this.chatUuid, [...this.structureComponent]);
3913
- requestAnimationFrame(() => {
3914
- this.preview = true;
3915
- });
3916
- } catch (error) {
3917
- console.error("Error sending message:", error);
3918
- } finally {
3919
- this.isLoading = false;
3920
- }
3921
- }
3922
- handleSendMessage(event) {
3923
- const message = this.inputValue;
3924
- if (message.trim()) {
3925
- this.sendMessage(message);
3926
- this.inputValue = "";
3927
- }
3928
- }
3929
- handleInputChange(event) {
3930
- this.inputValue = event.detail.value;
3931
- }
3932
- handleKeyUp(event) {
3933
- if (event.key === "Enter") {
3934
- this.handleSendMessage(event);
3935
- }
3936
- }
3937
- };
3938
- AiChat.styles = styles$1;
3939
- __decorateClass$8([
3940
- property({ type: Object })
3941
- ], AiChat.prototype, "component", 2);
3942
- __decorateClass$8([
3943
- state()
3944
- ], AiChat.prototype, "preview", 2);
3945
- __decorateClass$8([
3946
- state()
3947
- ], AiChat.prototype, "rootUUID", 2);
3948
- __decorateClass$8([
3949
- state()
3950
- ], AiChat.prototype, "isChatBoxVisible", 2);
3951
- __decorateClass$8([
3952
- state()
3953
- ], AiChat.prototype, "chatUuid", 2);
3954
- __decorateClass$8([
3955
- state()
3956
- ], AiChat.prototype, "messages", 2);
3957
- __decorateClass$8([
3958
- state()
3959
- ], AiChat.prototype, "errorMessage", 2);
3960
- __decorateClass$8([
3961
- state()
3962
- ], AiChat.prototype, "inputValue", 2);
3963
- __decorateClass$8([
3964
- state()
3965
- ], AiChat.prototype, "isLoading", 2);
3966
- AiChat = __decorateClass$8([
3967
- customElement("ai-chat-block")
3968
- ], AiChat);
3969
-
3970
- function debounce(func, wait = 300) {
3971
- let timeout;
3972
- return function(...args) {
3973
- clearTimeout(timeout);
3974
- timeout = setTimeout(() => func.apply(this, args), wait);
3975
- };
3976
- }
3977
-
3978
- var __defProp$7 = Object.defineProperty;
3979
- var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
3980
- var __decorateClass$7 = (decorators, target, key, kind) => {
3981
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target;
3982
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
3983
- if (decorator = decorators[i])
3984
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
3985
- if (kind && result) __defProp$7(target, key, result);
3986
- return result;
3987
- };
3988
- let MicroAppBlock = class extends BaseElementBlock {
3989
- constructor() {
3990
- super();
3991
- }
3992
- connectedCallback() {
3993
- super.connectedCallback();
3994
- const pageUUID = $microAppCurrentPage.get()["84105b5d-49fe-4724-bc0e-325b578cbe17"];
3995
- this.registerCallback("appUUID", debounce((appUUID) => {
3996
- if (appUUID) {
3997
- const appLoaded = $components.get()[appUUID];
3998
- if (appLoaded === void 0) {
3999
- fetch("/api/components/application/" + appUUID).then((response) => response.json()).then((data) => {
4000
- return data.map((component) => component.component);
4001
- }).then((data) => {
4002
- if (pageUUID)
4003
- data = data.filter((component) => component.pageId === pageUUID);
4004
- $components.setKey(appUUID, data);
4005
- this.requestUpdate();
4006
- });
4007
- }
4008
- }
4009
- }, 0));
4010
- this.unsubscribe = $environment.subscribe((environment) => {
4011
- this.mode = environment.mode;
4012
- });
4013
- }
4014
- disconnectedCallback() {
4015
- super.disconnectedCallback();
4016
- this.unregisterCallback("appUUID");
4017
- if (this.unsubscribe) {
4018
- this.unsubscribe();
4019
- }
4020
- }
4021
- render() {
4022
- const isPreviewMode = this.inputHandlersValue.mode === ViewMode.Preview;
4023
- return html`
4024
- ${this.inputHandlersValue.appUUID ? html`
4025
- <micro-app
4026
- uuid=${this.inputHandlersValue.appUUID}
4027
- componentToRenderUUID=${this.inputHandlersValue.componentToRenderUUID ?? nothing}
4028
- style=${styleMap({
4029
- pointerEvents: isPreviewMode ? "auto" : "none"
4030
- })}
4031
- ></micro-app>
4032
- ` : html`
4033
- <div class="no-app-selected">
4034
- No micro-app selected
4035
- </div>
4036
- `}
4037
- `;
4038
- }
4039
- };
4040
- MicroAppBlock.styles = [
4041
- css`
4042
- .no-app-selected {
4043
- display: flex;
4044
- justify-content: center;
4045
- align-items: center;
4046
- height: 200px;
4047
- width:400px;
4048
- border: 2px dashed gray;
4049
- color: gray;
4050
- text-align: center;
4051
- }
4052
- `
4053
- ];
4054
- __decorateClass$7([
4055
- property({ type: Object })
4056
- ], MicroAppBlock.prototype, "component", 2);
4057
- __decorateClass$7([
4058
- property({ type: Object })
4059
- ], MicroAppBlock.prototype, "item", 2);
4060
- MicroAppBlock = __decorateClass$7([
4061
- customElement("micro-app-block")
4062
- ], MicroAppBlock);
4063
-
4064
- var __defProp$6 = Object.defineProperty;
4065
- var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
4066
- var __decorateClass$6 = (decorators, target, key, kind) => {
4067
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target;
4068
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
4069
- if (decorator = decorators[i])
4070
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
4071
- if (kind && result) __defProp$6(target, key, result);
4072
- return result;
4073
- };
4074
- try {
4075
- await import('@nuralyui/collapse');
4076
- } catch (error) {
4077
- console.warn("[@nuralyui/collapse] Package not found or failed to load. Collapse functionality may be limited.");
4078
- }
4079
- let Collapse = class extends BaseElementBlock {
4080
- constructor() {
4081
- super();
4082
- this.sections = [];
4083
- this.openStates = [];
4084
- this.componentsWithChildren = [];
4085
- this.registerCallback("components", () => {
4086
- this.updateComponents();
4087
- });
4088
- }
4089
- updated(changedProperties) {
4090
- super.updated(changedProperties);
4091
- if (changedProperties.has("component")) {
4092
- this.updateComponents();
4093
- }
4094
- }
4095
- firstUpdated(_changedProperties) {
4096
- super.firstUpdated(_changedProperties);
4097
- const application_id = this.component.application_id;
4098
- this.componentsWithChildren = $applicationComponents(application_id).get();
4099
- }
4100
- updateComponents() {
4101
- this.sections = this.generateSection();
4102
- }
4103
- render() {
4104
- return html`
4105
- <nr-collapse
4106
- style=${styleMap(this.component.style)}
4107
- .sections=${[...this.sections]}
4108
- .size=${this.inputHandlersValue?.size ?? nothing}
4109
- @section-toggled=${this.handleSectionToggled}
4110
- ></nr-collapse>
4111
- `;
4112
- }
4113
- handleSectionToggled(e) {
4114
- const index = e.detail.index;
4115
- this.openStates[index] = !this.openStates[index];
4116
- this.sections[index].open = this.openStates[index];
4117
- this.requestUpdate();
4118
- }
4119
- generateComponent(blockName) {
4120
- const children = this.componentsWithChildren.filter(
4121
- (component) => blockName === component.uuid
4122
- );
4123
- return renderComponent(children, null, true);
4124
- }
4125
- generateSection() {
4126
- const components = this.inputHandlersValue?.components;
4127
- if (!components || !Array.isArray(components)) {
4128
- return [];
4129
- }
4130
- return components.map(
4131
- (section, index) => {
4132
- return {
4133
- header: section.label,
4134
- content: html`<div>${this.generateComponent(section.blockName)}</div>`,
4135
- open: this.openStates[index] ?? section.open
4136
- };
4137
- }
4138
- );
4139
- }
4140
- };
4141
- __decorateClass$6([
4142
- state()
4143
- ], Collapse.prototype, "sections", 2);
4144
- __decorateClass$6([
4145
- state()
4146
- ], Collapse.prototype, "openStates", 2);
4147
- __decorateClass$6([
4148
- state()
4149
- ], Collapse.prototype, "componentsWithChildren", 2);
4150
- Collapse = __decorateClass$6([
4151
- customElement("collapse-block")
4152
- ], Collapse);
4153
-
4154
- const styles = css`
4155
- .collection_viewer {
4156
- --columns: 1;
4157
- min-width: 200px;
4158
- max-height: 400px;
4159
- display: flex;
4160
- flex-wrap: wrap; /* Allows items to wrap into new rows */
4161
- }
4162
-
4163
- .vertical {
4164
- flex-direction: column;
4165
- flex-wrap: nowrap
4166
-
4167
- }
4168
-
4169
- .collection{
4170
- flex: 0 0 calc(100% / var(--columns) - 10px); /* Fixed width */
4171
- }
4172
- `;
4173
-
4174
- var __defProp$5 = Object.defineProperty;
4175
- var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
4176
- var __decorateClass$5 = (decorators, target, key, kind) => {
4177
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target;
4178
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
4179
- if (decorator = decorators[i])
4180
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
4181
- if (kind && result) __defProp$5(target, key, result);
4182
- return result;
4183
- };
4184
- let CollectionViewer = class extends BaseElementBlock {
4185
- constructor() {
4186
- super(...arguments);
4187
- this.isViewMode = false;
4188
- this.dropDragPalceHolderStyle = {
4189
- display: "none",
4190
- height: "auto",
4191
- width: "auto",
4192
- minWidth: "80px",
4193
- backgroundColor: "rgb(202 235 255)",
4194
- zIndex: "7",
4195
- borderRadius: "2px"
4196
- };
4197
- this.childrenComponents = [];
4198
- this.containerRef = createRef();
4199
- }
4200
- connectedCallback() {
4201
- super.connectedCallback();
4202
- this.updateChildrenComponents();
4203
- if (this.component?.event?.onInit) {
4204
- executeHandler(
4205
- this.component,
4206
- getNestedAttribute(this.component, "event.onInit")
4207
- );
4208
- }
4209
- }
4210
- updated(changedProperties) {
4211
- if (changedProperties.has("component")) {
4212
- this.updateChildrenComponents();
4213
- }
4214
- }
4215
- updateChildrenComponents() {
4216
- const applicationComponents = $components.get()[this.component?.application_id];
4217
- if (!applicationComponents || !this.component?.childrenIds?.length) {
4218
- this.childrenComponents = [];
4219
- return;
4220
- }
4221
- this.childrenComponents = this.component.childrenIds.map((id) => applicationComponents.find((component) => component.uuid === id)).filter(Boolean);
4222
- }
4223
- handleCollectionClick(e) {
4224
- setContextMenuEvent(null);
4225
- if ($resizing.get()) return;
4226
- setCurrentComponentIdAction(this.component?.uuid);
4227
- e.preventDefault();
4228
- e.stopPropagation();
4229
- }
4230
- renderRow(item) {
4231
- return html`
4232
- <div class="collection" ${ref(this.containerRef)}
4233
- @click="${(e) => this.handleCollectionClick(e)}">
4234
- ${this.childrenComponents.length ? html`${renderComponent(
4235
- this.childrenComponents.map((component) => ({ ...component, item })),
4236
- item,
4237
- this.isViewMode
4238
- )}` : html`<div class="empty-message">Add or Drag an item into this collection</div>`}
4239
- </div>`;
4240
- }
4241
- getData() {
4242
- if (Array.isArray(this.inputHandlersValue.data)) {
4243
- return this.inputHandlersValue.data;
4244
- }
4245
- return this.component.input?.data ? [] : [
4246
- { title: "Function 1" },
4247
- { title: "Function 2" },
4248
- { title: "Function 3" }
4249
- ];
4250
- }
4251
- renderComponent() {
4252
- const isVertical = this.inputHandlersValue.direction?.value === "vertical";
4253
- const data = this.getData();
4254
- return html`
4255
- <div
4256
- ${ref(this.inputRef)}
4257
- style=${styleMap(this.getStyles())}
4258
- class=${classMap({
4259
- collection_viewer: true,
4260
- vertical: isVertical
4261
- })}
4262
- >
4263
- ${data.map((item, index) => this.renderRow({ ...item, index }))}
4264
- </div>
4265
- `;
4266
- }
4267
- };
4268
- CollectionViewer.styles = styles;
4269
- __decorateClass$5([
4270
- property({ type: Object })
4271
- ], CollectionViewer.prototype, "component", 2);
4272
- __decorateClass$5([
4273
- property({ type: Boolean })
4274
- ], CollectionViewer.prototype, "isViewMode", 2);
4275
- __decorateClass$5([
4276
- property({ type: String })
4277
- ], CollectionViewer.prototype, "mode", 2);
4278
- __decorateClass$5([
4279
- state()
4280
- ], CollectionViewer.prototype, "hoveredComponent", 2);
4281
- __decorateClass$5([
4282
- state()
4283
- ], CollectionViewer.prototype, "currentEditingApplication", 2);
4284
- __decorateClass$5([
4285
- state()
4286
- ], CollectionViewer.prototype, "draggingComponentInfo", 2);
4287
- __decorateClass$5([
4288
- state()
4289
- ], CollectionViewer.prototype, "dropDragPalceHolderStyle", 2);
4290
- __decorateClass$5([
4291
- state()
4292
- ], CollectionViewer.prototype, "childrenComponents", 2);
4293
- CollectionViewer = __decorateClass$5([
4294
- customElement("collection-viewer")
4295
- ], CollectionViewer);
4296
-
4297
- var __defProp$4 = Object.defineProperty;
4298
- var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
4299
- var __decorateClass$4 = (decorators, target, key, kind) => {
4300
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target;
4301
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
4302
- if (decorator = decorators[i])
4303
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
4304
- if (kind && result) __defProp$4(target, key, result);
4305
- return result;
4306
- };
4307
- let RefComponentContainer = class extends BaseElementBlock {
4308
- constructor() {
4309
- super();
4310
- this.dragOverSituation = false;
4311
- this.isViewMode = false;
4312
- this.wrapperStyle = {};
4313
- this.containerRef = createRef();
4314
- this.addEventListener("click", (e) => {
4315
- e.preventDefault();
4316
- e.stopPropagation();
4317
- setCurrentComponentIdAction(this.component.uuid);
4318
- });
4319
- }
4320
- connectedCallback() {
4321
- super.connectedCallback();
4322
- }
4323
- firstUpdated(_changedProperties) {
4324
- eventDispatcher.on(`component-property-changed:${String(this.component.name)}`, () => {
4325
- this.requestUpdate();
4326
- });
4327
- $applicationComponents(this.component.application_id).subscribe(
4328
- (components) => {
4329
- this.components = [...components];
4330
- }
4331
- );
4332
- eventDispatcher.on(
4333
- "component:refresh",
4334
- () => {
4335
- this.components = $applicationComponents(this.component.application_id).get();
4336
- }
4337
- );
4338
- }
4339
- renderComponent() {
4340
- const componentToRender = this.components?.find(
4341
- (component) => component.uuid === this.inputHandlersValue?.ref && this.component.uuid !== this.inputHandlersValue?.ref
4342
- );
4343
- return html`
4344
- ${renderComponent(
4345
- [componentToRender],
4346
- {},
4347
- true
4348
- )}
4349
-
4350
- `;
4351
- }
4352
- };
4353
- __decorateClass$4([
4354
- property({ type: Object })
4355
- ], RefComponentContainer.prototype, "component", 2);
4356
- __decorateClass$4([
4357
- property({ type: Object })
4358
- ], RefComponentContainer.prototype, "item", 2);
4359
- __decorateClass$4([
4360
- state()
4361
- ], RefComponentContainer.prototype, "dragOverSituation", 2);
4362
- __decorateClass$4([
4363
- state()
4364
- ], RefComponentContainer.prototype, "selectedComponent", 2);
4365
- __decorateClass$4([
4366
- state()
4367
- ], RefComponentContainer.prototype, "hoveredComponent", 2);
4368
- __decorateClass$4([
4369
- property({ type: Object })
4370
- ], RefComponentContainer.prototype, "draggingComponentInfo", 2);
4371
- __decorateClass$4([
4372
- property({ type: Boolean })
4373
- ], RefComponentContainer.prototype, "isViewMode", 2);
4374
- __decorateClass$4([
4375
- state()
4376
- ], RefComponentContainer.prototype, "wrapperStyle", 2);
4377
- __decorateClass$4([
4378
- state()
4379
- ], RefComponentContainer.prototype, "containerRef", 2);
4380
- __decorateClass$4([
4381
- state()
4382
- ], RefComponentContainer.prototype, "components", 2);
4383
- RefComponentContainer = __decorateClass$4([
4384
- customElement("ref-component-container-block")
4385
- ], RefComponentContainer);
4386
-
4387
- var __defProp$3 = Object.defineProperty;
4388
- var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
4389
- var __decorateClass$3 = (decorators, target, key, kind) => {
4390
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target;
4391
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
4392
- if (decorator = decorators[i])
4393
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
4394
- if (kind && result) __defProp$3(target, key, result);
4395
- return result;
4396
- };
4397
- const svgIcons = {
4398
- format_clear: '<svg viewBox="0 0 24 24"><path d="M3.27 5L2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21 18 19.73 3.55 5.27 3.27 5zM6 5v.18L8.82 8h2.4l-.72 1.68 2.1 2.1L14.21 8H20V5H6z"></path></svg>',
4399
- format_bold: '<svg viewBox="0 0 24 24"><path d="M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"></path></svg>',
4400
- format_italic: '<svg viewBox="0 0 24 24"><path d="M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"></path></svg>',
4401
- format_underlined: '<svg viewBox="0 0 24 24"><path d="M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"></path></svg>',
4402
- format_align_left: '<svg viewBox="0 0 24 24"><path d="M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z"></path></svg>',
4403
- format_align_center: '<svg viewBox="0 0 24 24"><path d="M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z"></path></svg>',
4404
- format_align_right: '<svg viewBox="0 0 24 24"><path d="M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z"></path></svg>',
4405
- format_list_numbered: '<svg viewBox="0 0 24 24"><path d="M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"></path></svg>',
4406
- format_list_bulleted: '<svg viewBox="0 0 24 24"><path d="M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"></path></svg>',
4407
- format_quote: '<svg viewBox="0 0 24 24"><path d="M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"></path></svg>',
4408
- format_indent_decrease: '<svg viewBox="0 0 24 24"><path d="M11 17h10v-2H11v2zm-8-5l4 4V8l-4 4zm0 9h18v-2H3v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z"></path></svg>',
4409
- format_indent_increase: '<svg viewBox="0 0 24 24"><path d="M3 21h18v-2H3v2zM3 8v8l4-4-4-4zm8 9h10v-2H11v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z"></path></svg>',
4410
- link_off: '<svg viewBox="0 0 24 24"><path d="M17 7h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1 0 1.43-.98 2.63-2.31 2.98l1.46 1.46C20.88 15.61 22 13.95 22 12c0-2.76-2.24-5-5-5zm-1 4h-2.19l2 2H16zM2 4.27l3.11 3.11C3.29 8.12 2 9.91 2 12c0 2.76 2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1 0-1.59 1.21-2.9 2.76-3.07L8.73 11H8v2h2.73L13 15.27V17h1.73l4.01 4.01 1.41-1.41L3.41 2.86 2 4.27z"></path></svg>',
4411
- add_link: '<svg viewBox="0 0 24 24"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg>',
4412
- format_color_text: '<svg viewBox="0 0 24 24"><path d="M11 3L5.5 17h2.25l1.12-3h6.25l1.12 3h2.25L13 3h-2zm-1.38 9L12 5.67 14.38 12H9.62z"></path></svg>',
4413
- border_color: '<svg viewBox="0 0 24 24"><path d="M17.75 7L14 3.25l-10 10V17h3.75l10-10zm2.96-2.96c.39-.39.39-1.02 0-1.41L18.37.29c-.39-.39-1.02-.39-1.41 0L15 2.25 18.75 6l1.96-1.96z"></path></svg>',
4414
- title: '<svg viewBox="0 0 24 24"><path d="M5 4v3h5.5v12h3V7H19V4z"></path></svg>',
4415
- text_format: '<svg viewBox="0 0 24 24"><path d="M5 17v2h14v-2H5zm4.5-4.2h5l.9 2.2h2.1L12.75 4h-1.5L6.5 15h2.1l.9-2.2zM12 5.98L13.87 11h-3.74L12 5.98z"></path></svg>',
4416
- format_size: '<svg viewBox="0 0 24 24"><path d="M9 4v3h5v12h3V7h5V4H9zm-6 8h3v7h3v-7h3V9H3v3z"></path></svg>',
4417
- undo: '<svg viewBox="0 0 24 24"><path d="M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"></path></svg>',
4418
- redo: '<svg viewBox="0 0 24 24"><path d="M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"></path></svg>',
4419
- content_cut: '<svg viewBox="0 0 24 24"><path d="M9.64 7.64c.23-.5.36-1.05.36-1.64 0-2.21-1.79-4-4-4S2 3.79 2 6s1.79 4 4 4c.59 0 1.14-.13 1.64-.36L10 12l-2.36 2.36C7.14 14.13 6.59 14 6 14c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.59-.13-1.14-.36-1.64L12 14l7 7h3v-1L9.64 7.64zM6 8c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm0 12c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm6-7.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM19 3l-6 6 2 2 7-7V3z"></path></svg>',
4420
- content_copy: '<svg viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg>',
4421
- content_paste: '<svg viewBox="0 0 24 24"><path d="M19 2h-4.18C14.4.84 13.3 0 12 0c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm7 18H5V4h2v3h10V4h2v16z"></path></svg>'
4422
- };
4423
- let RichTextEditor = class extends LitElement {
4424
- constructor() {
4425
- super(...arguments);
4426
- this.content = "";
4427
- this.root = null;
4428
- }
4429
- render() {
4430
- return html$1`<main>
4431
-
4432
- <div id="editor-actions">
4433
- <div id="toolbar">
4434
- ${toolbar(this.shadowRoot, this.getSelection(), (command, val) => {
4435
- document.execCommand(command, false, val);
4436
- })}
4437
- <input id="bg" type="color" style="display: none" />
4438
- <input id="fg" type="color" style="display: none" />
4439
- </div>
4440
- </div>
4441
- <div id="editor" @input=${(e) => {
4442
- this.dispatchEvent(new CustomEvent("content-change", {
4443
- detail: {
4444
- value: this.root?.innerHTML
4445
- }
4446
- }));
4447
- }}>${this.root}</div>
4448
- </main> `;
4449
- }
4450
- async firstUpdated() {
4451
- this.parentElement?.querySelector("rich-text-editor template");
4452
- this.reset();
4453
- }
4454
- reset() {
4455
- const parser = new DOMParser();
4456
- const doc = parser.parseFromString(this.content, "text/html");
4457
- document.execCommand("defaultParagraphSeparator", false, "br");
4458
- document.addEventListener("selectionchange", () => {
4459
- this.requestUpdate();
4460
- });
4461
- const root = doc.querySelector("body");
4462
- root.setAttribute("contenteditable", "true");
4463
- this.root = root;
4464
- this.root.style.height = "100%";
4465
- }
4466
- getSelection() {
4467
- if (this.shadowRoot?.getSelection) return this.shadowRoot?.getSelection();
4468
- return null;
4469
- }
4470
- };
4471
- RichTextEditor.styles = css$1`
4472
- :host {
4473
- /* --editor-width: 600px; */
4474
- /* --editor-height: 600px; */
4475
- /* --editor-background: #f1f1f1; */
4476
- --editor-toolbar-height: 33px;
4477
- --editor-toolbar-background: #454545;
4478
- --editor-toolbar-on-background: white;
4479
- /* --editor-toolbar-on-active-background: #a4a4a4; */
4480
- }
4481
- main {
4482
- width: var(--editor-width);
4483
- height: var(--editor-height);
4484
- display: grid;
4485
- grid-template-areas:
4486
- "toolbar toolbar"
4487
- "editor editor";
4488
- grid-template-rows: auto 1fr;
4489
- grid-template-columns: auto auto;
4490
- }
4491
- #editor-actions {
4492
- grid-area: toolbar;
4493
- width: var(--editor-width);
4494
- /* height: var(--editor-toolbar-height); */
4495
- background-color: var(--editor-toolbar-background);
4496
- color: var(--editor-toolbar-on-background);
4497
- overscroll-behavior: contain;
4498
- /* overflow-y: auto; */
4499
- -ms-overflow-style: none;
4500
- scrollbar-width: none;
4501
- overflow:auto;
4502
-
4503
- /* Add these lines for vertical alignment */
4504
- display: flex;
4505
- align-items: center; /* vertically center items */
4506
- }
4507
- #editor-actions::-webkit-scrollbar {
4508
- display: none;
4509
- }
4510
- #editor {
4511
- width: var(--editor-width);
4512
- grid-area: editor;
4513
- background-color: var(--editor-background);
4514
- border: 1px solid var(--editor-toolbar-background);
4515
- }
4516
- #toolbar {
4517
- width: 1080px;
4518
- height: var(--editor-toolbar-height);
4519
- }
4520
- [contenteditable] {
4521
- outline: 0px solid transparent;
4522
- }
4523
- .icon-button {
4524
- display: inline-flex;
4525
- align-items: center;
4526
- justify-content: center;
4527
- width: 30px;
4528
- height: 30px;
4529
- border: none;
4530
- background: transparent;
4531
- cursor: pointer;
4532
- padding: 0;
4533
- color: var(--editor-toolbar-on-background);
4534
- }
4535
- .icon-button svg {
4536
- width: 20px;
4537
- height: 20px;
4538
- fill: currentColor;
4539
- }
4540
- .icon-button.active {
4541
- color: var(--editor-toolbar-on-active-background);
4542
- }
4543
- select {
4544
- margin-top: -5px;
4545
- height: calc(var(--editor-toolbar-height) - 10px);
4546
- vertical-align: middle;
4547
- }
4548
- input[type="color"] {
4549
- height: calc(var(--editor-toolbar-height) - 15px);
4550
- -webkit-appearance: none;
4551
- border: none;
4552
- width: 22px;
4553
- }
4554
- input[type="color"]::-webkit-color-swatch-wrapper {
4555
- padding: 0;
4556
- }
4557
- input[type="color"]::-webkit-color-swatch {
4558
- border: none;
4559
- }
4560
- `;
4561
- __decorateClass$3([
4562
- property()
4563
- ], RichTextEditor.prototype, "content", 2);
4564
- __decorateClass$3([
4565
- state()
4566
- ], RichTextEditor.prototype, "root", 2);
4567
- RichTextEditor = __decorateClass$3([
4568
- customElement("rich-text-editor-block")
4569
- ], RichTextEditor);
4570
- function toolbar(shadowRoot, selection, command) {
4571
- const tags = [];
4572
- if (selection?.type === "Range") {
4573
- let parentNode = selection?.baseNode;
4574
- if (parentNode) {
4575
- const checkNode = () => {
4576
- const parentTagName = parentNode?.tagName?.toLowerCase()?.trim();
4577
- if (parentTagName) tags.push(parentTagName);
4578
- };
4579
- while (parentNode != null) {
4580
- checkNode();
4581
- parentNode = parentNode?.parentNode;
4582
- }
4583
- }
4584
- }
4585
- const commands = [
4586
- {
4587
- icon: "format_clear",
4588
- command: "removeFormat"
4589
- },
4590
- {
4591
- icon: "format_bold",
4592
- command: "bold",
4593
- active: tags.includes("b")
4594
- },
4595
- {
4596
- icon: "format_italic",
4597
- command: "italic",
4598
- active: tags.includes("i")
4599
- },
4600
- {
4601
- icon: "format_underlined",
4602
- command: "underline",
4603
- active: tags.includes("u")
4604
- },
4605
- {
4606
- icon: "format_align_left",
4607
- command: "justifyleft"
4608
- },
4609
- {
4610
- icon: "format_align_center",
4611
- command: "justifycenter"
4612
- },
4613
- {
4614
- icon: "format_align_right",
4615
- command: "justifyright"
4616
- },
4617
- {
4618
- icon: "format_list_numbered",
4619
- command: "insertorderedlist",
4620
- active: tags.includes("ol")
4621
- },
4622
- {
4623
- icon: "format_list_bulleted",
4624
- command: "insertunorderedlist",
4625
- active: tags.includes("ul")
4626
- },
4627
- {
4628
- icon: "format_quote",
4629
- command: "formatblock",
4630
- command_value: "blockquote"
4631
- },
4632
- {
4633
- icon: "format_indent_decrease",
4634
- command: "outdent"
4635
- },
4636
- {
4637
- icon: "format_indent_increase",
4638
- command: "indent"
4639
- },
4640
- tags.includes("a") ? { icon: "link_off", command: "unlink" } : {
4641
- icon: "add_link",
4642
- command: () => {
4643
- const newLink = prompt("Write the URL here", "http://");
4644
- if (newLink && newLink != "" && newLink != "http://") {
4645
- command("createlink", newLink);
4646
- }
4647
- }
4648
- },
4649
- {
4650
- icon: "format_color_text",
4651
- command: () => {
4652
- const input = shadowRoot.querySelector("#fg");
4653
- input.addEventListener("input", (e) => {
4654
- const val = e.target.value;
4655
- command("forecolor", val);
4656
- });
4657
- input.click();
4658
- },
4659
- type: "color"
4660
- },
4661
- {
4662
- icon: "border_color",
4663
- command: () => {
4664
- const input = shadowRoot.querySelector("#bg");
4665
- input.addEventListener("input", (e) => {
4666
- const val = e.target.value;
4667
- command("backcolor", val);
4668
- });
4669
- input.click();
4670
- },
4671
- type: "color"
4672
- },
4673
- {
4674
- icon: "format_size",
4675
- command: "fontsize",
4676
- values: [
4677
- { name: "Font Size", value: "--" },
4678
- { name: "Very Small", value: "1" },
4679
- { name: "Small", value: "2" },
4680
- { name: "Normal", value: "3" },
4681
- { name: "Medium Large", value: "4" },
4682
- { name: "Large", value: "5" },
4683
- { name: "Very Large", value: "6" },
4684
- { name: "Maximum", value: "7" }
4685
- ]
4686
- },
4687
- {
4688
- icon: "undo",
4689
- command: "undo"
4690
- },
4691
- {
4692
- icon: "redo",
4693
- command: "redo"
4694
- },
4695
- {
4696
- icon: "content_cut",
4697
- command: "cut"
4698
- },
4699
- {
4700
- icon: "content_copy",
4701
- command: "copy"
4702
- },
4703
- {
4704
- icon: "content_paste",
4705
- command: "paste"
4706
- }
4707
- ];
4708
- return html$1`
4709
- ${commands.map((n) => {
4710
- if (n.values) {
4711
- return html$1`
4712
- <select
4713
- id="${n.icon}"
4714
- @change=${(e) => {
4715
- const val = e.target.value;
4716
- if (val === "--") {
4717
- command("removeFormat", void 0);
4718
- } else if (typeof n.command === "string") {
4719
- command(n.command, val);
4720
- }
4721
- }}
4722
- >
4723
- ${n.values.map(
4724
- (v) => html$1`<option value=${v.value}>${v.name}</option>`
4725
- )}
4726
- </select>
4727
- `;
4728
- } else {
4729
- return html$1`
4730
- <button
4731
- class="icon-button ${n.active ? "active" : ""}"
4732
- @click=${() => {
4733
- if (typeof n.command === "string") {
4734
- command(n.command, n.command_value);
4735
- } else {
4736
- n.command();
4737
- }
4738
- }}
4739
- .innerHTML=${svgIcons[n.icon]}
4740
- ></button>
4741
- `;
4742
- }
4743
- })}
4744
- `;
4745
- }
4746
-
4747
- var __defProp$2 = Object.defineProperty;
4748
- var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
4749
- var __decorateClass$2 = (decorators, target, key, kind) => {
4750
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
4751
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
4752
- if (decorator = decorators[i])
4753
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
4754
- if (kind && result) __defProp$2(target, key, result);
4755
- return result;
4756
- };
4757
- let RichTextContainer = class extends BaseElementBlock {
4758
- constructor() {
4759
- super();
4760
- this.isViewMode = false;
4761
- this.dragOverSituation = false;
4762
- this.wrapperStyle = {};
4763
- this.editing = false;
4764
- this.handleKeyDown = (e) => {
4765
- if (e.key === "Escape" && this.editing) {
4766
- this.editing = false;
4767
- e.preventDefault();
4768
- e.stopPropagation();
4769
- }
4770
- };
4771
- this.handleDoubleClick = () => {
4772
- this.editing = true;
4773
- };
4774
- }
4775
- connectedCallback() {
4776
- super.connectedCallback();
4777
- window.addEventListener("keydown", this.handleKeyDown);
4778
- }
4779
- disconnectedCallback() {
4780
- super.disconnectedCallback();
4781
- window.removeEventListener("keydown", this.handleKeyDown);
4782
- }
4783
- handleCodeEditorChange(value) {
4784
- if (!this.isViewMode) {
4785
- const serializedValue = JSON.stringify(value);
4786
- executeHandler(
4787
- this.component,
4788
- /* js */
4789
- `
4790
- try {
4791
- const selectedComponent = Utils.first($selectedComponents);
4792
- updateInput(selectedComponent, "value", "string", ${serializedValue}, null);
4793
- } catch (error) {
4794
- console.error(error);
4795
- }
4796
- `,
4797
- {}
4798
- );
4799
- }
4800
- }
4801
- renderComponent() {
4802
- return html`
4803
-
4804
- <div ${ref(this.inputRef)}
4805
- class="${`drop-${this.component.uuid}`}"
4806
- style=${styleMap({
4807
- width: this.editing ? "auto" : this.getStyles().width,
4808
- display: "block"
4809
- })}
4810
- >
4811
- ${this.editing && !this.isViewMode ? html`
4812
- <rich-text-editor-block
4813
- @content-change=${(e) => {
4814
- this.handleCodeEditorChange(e.detail.value);
4815
- }}
4816
- .content=${this.inputHandlersValue.value}
4817
- ></rich-text-editor-block>
4818
- ` : html`
4819
- <p @dblclick=${this.handleDoubleClick}>
4820
- ${unsafeHTML(this.inputHandlersValue.value)}
4821
- </p>
4822
- `}
4823
- </div>
4824
- `;
4825
- }
4826
- firstUpdated(_changedProperties) {
4827
- }
4828
- };
4829
- __decorateClass$2([
4830
- property({ type: Object })
4831
- ], RichTextContainer.prototype, "component", 2);
4832
- __decorateClass$2([
4833
- property({ type: Object })
4834
- ], RichTextContainer.prototype, "item", 2);
4835
- __decorateClass$2([
4836
- property({ type: Object })
4837
- ], RichTextContainer.prototype, "draggingComponentInfo", 2);
4838
- __decorateClass$2([
4839
- property({ type: Boolean })
4840
- ], RichTextContainer.prototype, "isViewMode", 2);
4841
- __decorateClass$2([
4842
- state()
4843
- ], RichTextContainer.prototype, "dragOverSituation", 2);
4844
- __decorateClass$2([
4845
- state()
4846
- ], RichTextContainer.prototype, "selectedComponent", 2);
4847
- __decorateClass$2([
4848
- state()
4849
- ], RichTextContainer.prototype, "hoveredComponent", 2);
4850
- __decorateClass$2([
4851
- state()
4852
- ], RichTextContainer.prototype, "wrapperStyle", 2);
4853
- __decorateClass$2([
4854
- state()
4855
- ], RichTextContainer.prototype, "components", 2);
4856
- __decorateClass$2([
4857
- state()
4858
- ], RichTextContainer.prototype, "editing", 2);
4859
- RichTextContainer = __decorateClass$2([
4860
- customElement("rich-text-block")
4861
- ], RichTextContainer);
4862
-
4863
- var __defProp$1 = Object.defineProperty;
4864
- var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
4865
- var __decorateClass$1 = (decorators, target, key, kind) => {
4866
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
4867
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
4868
- if (decorator = decorators[i])
4869
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
4870
- if (kind && result) __defProp$1(target, key, result);
4871
- return result;
4872
- };
4873
- try {
4874
- await import('@nuralyui/document');
4875
- } catch (error) {
4876
- console.warn("[@nuralyui/document] Package not found or failed to load.");
4877
- }
4878
- let DocumentBlock = class extends BaseElementBlock {
4879
- renderComponent() {
4880
- const documentStyles = this.getStyles() || {};
4881
- const documentStyleHandlers = this.component?.styleHandlers ? Object.fromEntries(
4882
- Object.entries(this.component?.styleHandlers).filter(([key, value]) => value)
4883
- ) : {};
4884
- const src = this.inputHandlersValue?.src;
4885
- const type = this.inputHandlersValue?.type ?? "pdf";
4886
- const previewable = this.inputHandlersValue?.previewable ?? false;
4887
- if (!src) {
4888
- return html`
4889
- <div
4890
- ${ref(this.inputRef)}
4891
- class="document-placeholder"
4892
- style=${styleMap({
4893
- ...this.getStyles(),
4894
- width: documentStyleHandlers?.width || documentStyles?.width || "100%",
4895
- height: documentStyleHandlers?.height || documentStyles?.height || "200px"
4896
- })}
4897
- @click=${(e) => this.executeEvent("onClick", e)}
4898
- >
4899
- <nr-icon name="file-text"></nr-icon>
4900
- <nr-label>No document source</nr-label>
4901
- </div>
4902
- `;
4903
- }
4904
- return html`
4905
- <nr-document-viewer
4906
- ${ref(this.inputRef)}
4907
- style=${styleMap({
4908
- ...this.getStyles()
4909
- })}
4910
- .src=${src}
4911
- .type=${type}
4912
- .previewable=${previewable}
4913
- .width=${documentStyleHandlers?.width || documentStyles?.width}
4914
- .height=${documentStyleHandlers?.height || documentStyles?.height}
4915
- @click=${(e) => this.executeEvent("onClick", e)}
4916
- @load=${(e) => this.executeEvent("onLoad", e, { src })}
4917
- @error=${(e) => this.executeEvent("onError", e, { src, error: "Failed to load document" })}
4918
- >
4919
- </nr-document-viewer>
4920
- `;
4921
- }
4922
- };
4923
- DocumentBlock.styles = [css`
4924
- .document-placeholder {
4925
- display: flex;
4926
- flex-direction: column;
4927
- align-items: center;
4928
- justify-content: center;
4929
- color: #64748b;
4930
- min-height: 200px;
4931
- border-radius: 8px;
4932
- border: 2px dashed #cbd5e1;
4933
- gap: 12px;
4934
- }
4935
- .document-placeholder nr-icon {
4936
- --nuraly-icon-size: 48px;
4937
- }
4938
- `];
4939
- __decorateClass$1([
4940
- property({ type: Object })
4941
- ], DocumentBlock.prototype, "component", 2);
4942
- DocumentBlock = __decorateClass$1([
4943
- customElement("document-block")
4944
- ], DocumentBlock);
4945
-
4946
12
  var VariableScope = /* @__PURE__ */ ((VariableScope2) => {
4947
13
  VariableScope2["LOCAL"] = "local";
4948
14
  VariableScope2["GLOBAL"] = "global";
@@ -6387,7 +1453,7 @@ var __decorateClass = (decorators, target, key, kind) => {
6387
1453
  return result;
6388
1454
  };
6389
1455
  const STUDIO_APP_UUID = "1";
6390
- let MicroApp = class extends LitElement$1 {
1456
+ let MicroApp = class extends LitElement {
6391
1457
  constructor() {
6392
1458
  super();
6393
1459
  this.subscription = new Subscription();