@nuraly/runtime 0.1.9 → 0.1.11

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