@limetech/lime-crm-building-blocks 1.96.0 → 1.98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/{_MapCache-2e84a981.js → _MapCache-8b125fbb.js} +0 -26
  3. package/dist/cjs/{_Uint8Array-1e99726d.js → _Uint8Array-95263550.js} +1 -12
  4. package/dist/cjs/_baseIsEqual-cb7951b0.js +496 -0
  5. package/dist/cjs/_defineProperty-40a6ad5d.js +15 -0
  6. package/dist/cjs/{get-1acf79ce.js → get-932b213e.js} +5 -4
  7. package/dist/cjs/isEqual-e77cce75.js +37 -0
  8. package/dist/cjs/isSymbol-5b36aeee.js +30 -0
  9. package/dist/cjs/lime-crm-building-blocks.cjs.js +1 -1
  10. package/dist/cjs/lime-query.types-bcb63a22.js +61 -0
  11. package/dist/cjs/limebb-component-config.cjs.entry.js +3 -2
  12. package/dist/cjs/limebb-lime-query-builder.cjs.entry.js +378 -150
  13. package/dist/cjs/limebb-lime-query-filter-and_5.cjs.entry.js +278 -0
  14. package/dist/cjs/limebb-lime-query-value-input.cjs.entry.js +239 -0
  15. package/dist/cjs/limebb-limetype-field_2.cjs.entry.js +406 -0
  16. package/dist/cjs/limebb-live-docs-info.cjs.entry.js +2 -2
  17. package/dist/cjs/limebb-locale-picker.cjs.entry.js +13 -498
  18. package/dist/cjs/limebb-mention-group-counter.cjs.entry.js +2 -2
  19. package/dist/cjs/limebb-navigation-button_2.cjs.entry.js +3 -3
  20. package/dist/cjs/limebb-notification-item.cjs.entry.js +1 -1
  21. package/dist/cjs/limebb-percentage-visualizer.cjs.entry.js +2 -2
  22. package/dist/cjs/limebb-property-selector.cjs.entry.js +234 -0
  23. package/dist/cjs/limebb-response-format-item.cjs.entry.js +80 -0
  24. package/dist/cjs/limebb-text-editor.cjs.entry.js +20 -61
  25. package/dist/cjs/limebb-trend-indicator.cjs.entry.js +1 -1
  26. package/dist/cjs/limetype-1fe0207f.js +90 -0
  27. package/dist/cjs/loader.cjs.js +1 -1
  28. package/dist/cjs/property-resolution-fb42a46b.js +66 -0
  29. package/dist/collection/collection-manifest.json +10 -0
  30. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-and.css +121 -0
  31. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-and.js +257 -0
  32. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-comparison.css +39 -0
  33. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-comparison.js +246 -0
  34. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-expression.css +104 -0
  35. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-expression.js +220 -0
  36. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-not.css +107 -0
  37. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-not.js +212 -0
  38. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-or.css +123 -0
  39. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-or.js +237 -0
  40. package/dist/collection/components/lime-query-builder/expressions/lime-query-value-input.css +48 -0
  41. package/dist/collection/components/lime-query-builder/expressions/lime-query-value-input.js +457 -0
  42. package/dist/collection/components/lime-query-builder/filter-conversion.js +118 -21
  43. package/dist/collection/components/lime-query-builder/lime-query-builder.css +30 -17
  44. package/dist/collection/components/lime-query-builder/lime-query-builder.js +253 -27
  45. package/dist/collection/components/lime-query-builder/limetype-field/limetype-field.js +435 -0
  46. package/dist/collection/components/lime-query-builder/property-selection-format.js +158 -0
  47. package/dist/collection/components/lime-query-builder/property-selector/property-selector.css +8 -0
  48. package/dist/collection/components/lime-query-builder/property-selector/property-selector.js +422 -0
  49. package/dist/collection/components/lime-query-builder/response-format-editor.css +72 -0
  50. package/dist/collection/components/lime-query-builder/response-format-editor.js +249 -0
  51. package/dist/collection/components/lime-query-builder/response-format-item.css +61 -0
  52. package/dist/collection/components/lime-query-builder/response-format-item.js +208 -0
  53. package/dist/collection/components/limeobject/file-viewer/live-docs-info.js +2 -2
  54. package/dist/collection/components/locale-picker/locale-picker.js +1 -1
  55. package/dist/collection/components/notification-list/notification-item/notification-item.js +1 -1
  56. package/dist/collection/components/percentage-visualizer/percentage-visualizer.js +2 -2
  57. package/dist/collection/components/summary-popover/summary-popover.js +3 -3
  58. package/dist/collection/components/text-editor/mention-group-counter.js +2 -2
  59. package/dist/collection/components/text-editor/text-editor.js +1 -1
  60. package/dist/collection/components/trend-indicator/trend-indicator.js +1 -1
  61. package/dist/components/_MapCache.js +2 -27
  62. package/dist/components/_Uint8Array.js +2 -12
  63. package/dist/components/_baseIsEqual.js +494 -0
  64. package/dist/components/_defineProperty.js +13 -0
  65. package/dist/components/get.js +2 -1
  66. package/dist/components/isEqual.js +35 -0
  67. package/dist/components/isSymbol.js +28 -0
  68. package/dist/components/lime-query-filter-and.js +408 -0
  69. package/dist/components/lime-query-filter-comparison.js +152 -0
  70. package/dist/components/lime-query-value-input.js +266 -0
  71. package/dist/components/limebb-lime-query-builder.js +437 -149
  72. package/dist/components/limebb-lime-query-filter-and.d.ts +11 -0
  73. package/dist/components/limebb-lime-query-filter-and.js +6 -0
  74. package/dist/components/limebb-lime-query-filter-comparison.d.ts +11 -0
  75. package/dist/components/limebb-lime-query-filter-comparison.js +6 -0
  76. package/dist/components/limebb-lime-query-filter-expression.d.ts +11 -0
  77. package/dist/components/limebb-lime-query-filter-expression.js +6 -0
  78. package/dist/components/limebb-lime-query-filter-not.d.ts +11 -0
  79. package/dist/components/limebb-lime-query-filter-not.js +6 -0
  80. package/dist/components/limebb-lime-query-filter-or.d.ts +11 -0
  81. package/dist/components/limebb-lime-query-filter-or.js +6 -0
  82. package/dist/components/limebb-lime-query-value-input.d.ts +11 -0
  83. package/dist/components/limebb-lime-query-value-input.js +6 -0
  84. package/dist/components/limebb-limetype-field.d.ts +11 -0
  85. package/dist/components/limebb-limetype-field.js +6 -0
  86. package/dist/components/limebb-locale-picker.js +8 -493
  87. package/dist/components/limebb-mention-group-counter.js +2 -2
  88. package/dist/components/limebb-percentage-visualizer.js +2 -2
  89. package/dist/components/limebb-property-selector.d.ts +11 -0
  90. package/dist/components/limebb-property-selector.js +6 -0
  91. package/dist/components/limebb-response-format-editor.d.ts +11 -0
  92. package/dist/components/limebb-response-format-editor.js +6 -0
  93. package/dist/components/limebb-response-format-item.d.ts +11 -0
  94. package/dist/components/limebb-response-format-item.js +6 -0
  95. package/dist/components/limebb-text-editor.js +7 -48
  96. package/dist/components/limebb-trend-indicator.js +1 -1
  97. package/dist/components/limetype-field.js +184 -0
  98. package/dist/components/limetype.js +85 -0
  99. package/dist/components/live-docs-info.js +2 -2
  100. package/dist/components/notification-item.js +1 -1
  101. package/dist/components/property-selector.js +317 -0
  102. package/dist/components/response-format-editor.js +278 -0
  103. package/dist/components/response-format-item.js +104 -0
  104. package/dist/components/summary-popover.js +3 -3
  105. package/dist/esm/{_MapCache-6484495d.js → _MapCache-af496e9d.js} +2 -27
  106. package/dist/esm/{_Uint8Array-e5cac922.js → _Uint8Array-d6ebd526.js} +3 -13
  107. package/dist/esm/_baseIsEqual-28053b81.js +494 -0
  108. package/dist/esm/_defineProperty-e6a185c3.js +13 -0
  109. package/dist/esm/{get-f9e0b2e1.js → get-3e42932b.js} +2 -1
  110. package/dist/esm/isEqual-57d0c223.js +35 -0
  111. package/dist/esm/isSymbol-1c5f65cc.js +28 -0
  112. package/dist/esm/lime-crm-building-blocks.js +1 -1
  113. package/dist/esm/lime-query.types-f72355e1.js +59 -0
  114. package/dist/esm/limebb-component-config.entry.js +3 -2
  115. package/dist/esm/limebb-lime-query-builder.entry.js +375 -147
  116. package/dist/esm/limebb-lime-query-filter-and_5.entry.js +270 -0
  117. package/dist/esm/limebb-lime-query-value-input.entry.js +235 -0
  118. package/dist/esm/limebb-limetype-field_2.entry.js +401 -0
  119. package/dist/esm/limebb-live-docs-info.entry.js +2 -2
  120. package/dist/esm/limebb-locale-picker.entry.js +9 -494
  121. package/dist/esm/limebb-mention-group-counter.entry.js +2 -2
  122. package/dist/esm/limebb-navigation-button_2.entry.js +3 -3
  123. package/dist/esm/limebb-notification-item.entry.js +1 -1
  124. package/dist/esm/limebb-percentage-visualizer.entry.js +2 -2
  125. package/dist/esm/limebb-property-selector.entry.js +230 -0
  126. package/dist/esm/limebb-response-format-item.entry.js +76 -0
  127. package/dist/esm/limebb-text-editor.entry.js +7 -48
  128. package/dist/esm/limebb-trend-indicator.entry.js +1 -1
  129. package/dist/esm/limetype-6e7552a7.js +85 -0
  130. package/dist/esm/loader.js +1 -1
  131. package/dist/esm/property-resolution-fde2375e.js +63 -0
  132. package/dist/lime-crm-building-blocks/lime-crm-building-blocks.esm.js +1 -1
  133. package/dist/lime-crm-building-blocks/{p-88c64360.entry.js → p-00da9b24.entry.js} +1 -1
  134. package/dist/lime-crm-building-blocks/p-02c0cc04.entry.js +1 -0
  135. package/dist/lime-crm-building-blocks/p-0957b2a6.entry.js +1 -0
  136. package/dist/lime-crm-building-blocks/p-123190c3.js +1 -0
  137. package/dist/lime-crm-building-blocks/p-244ee55b.entry.js +1 -0
  138. package/dist/lime-crm-building-blocks/p-35897ec3.js +1 -0
  139. package/dist/lime-crm-building-blocks/{p-85b7291c.entry.js → p-3932077b.entry.js} +1 -1
  140. package/dist/lime-crm-building-blocks/p-3b0a15ec.js +1 -0
  141. package/dist/lime-crm-building-blocks/p-5a6d2e7f.js +1 -0
  142. package/dist/lime-crm-building-blocks/p-60971d64.js +1 -0
  143. package/dist/lime-crm-building-blocks/p-6c1146ca.entry.js +1 -0
  144. package/dist/lime-crm-building-blocks/p-70a28b93.entry.js +1 -0
  145. package/dist/lime-crm-building-blocks/p-7e6fb4af.js +1 -0
  146. package/dist/lime-crm-building-blocks/{p-8664381a.entry.js → p-8c4eb49f.entry.js} +1 -1
  147. package/dist/lime-crm-building-blocks/p-96beaabc.entry.js +1 -0
  148. package/dist/lime-crm-building-blocks/p-a659d55a.js +1 -0
  149. package/dist/lime-crm-building-blocks/p-baf4e428.entry.js +1 -0
  150. package/dist/lime-crm-building-blocks/p-d298b34e.js +1 -0
  151. package/dist/lime-crm-building-blocks/{p-7c4bdc1b.entry.js → p-d89c44ad.entry.js} +1 -1
  152. package/dist/lime-crm-building-blocks/p-e0ab1554.js +1 -0
  153. package/dist/lime-crm-building-blocks/{p-8064cbfb.entry.js → p-e9d23ef7.entry.js} +1 -1
  154. package/dist/lime-crm-building-blocks/p-ef8a5266.entry.js +1 -0
  155. package/dist/lime-crm-building-blocks/{p-c9126885.entry.js → p-f52125a0.entry.js} +1 -1
  156. package/dist/lime-crm-building-blocks/p-f99c611d.entry.js +1 -0
  157. package/dist/lime-crm-building-blocks/p-fe2b91d9.js +1 -0
  158. package/dist/types/components/lime-query-builder/expressions/lime-query-filter-and.d.ts +56 -0
  159. package/dist/types/components/lime-query-builder/expressions/lime-query-filter-comparison.d.ts +64 -0
  160. package/dist/types/components/lime-query-builder/expressions/lime-query-filter-expression.d.ts +53 -0
  161. package/dist/types/components/lime-query-builder/expressions/lime-query-filter-not.d.ts +54 -0
  162. package/dist/types/components/lime-query-builder/expressions/lime-query-filter-or.d.ts +55 -0
  163. package/dist/types/components/lime-query-builder/expressions/lime-query-value-input.d.ts +92 -0
  164. package/dist/types/components/lime-query-builder/filter-conversion.d.ts +18 -0
  165. package/dist/types/components/lime-query-builder/lime-query-builder.d.ts +40 -7
  166. package/dist/types/components/lime-query-builder/limetype-field/limetype-field.d.ts +96 -0
  167. package/dist/types/components/lime-query-builder/property-selection-format.d.ts +23 -0
  168. package/dist/types/components/lime-query-builder/property-selector/property-selector.d.ts +71 -0
  169. package/dist/types/components/lime-query-builder/response-format-editor.d.ts +57 -0
  170. package/dist/types/components/lime-query-builder/response-format-item.d.ts +46 -0
  171. package/dist/types/components.d.ts +1587 -114
  172. package/package.json +1 -1
  173. package/dist/lime-crm-building-blocks/p-00e7e0d4.entry.js +0 -1
  174. package/dist/lime-crm-building-blocks/p-11ac105b.entry.js +0 -1
  175. package/dist/lime-crm-building-blocks/p-5abe3fff.entry.js +0 -1
  176. package/dist/lime-crm-building-blocks/p-8044ffbd.js +0 -1
  177. package/dist/lime-crm-building-blocks/p-92ec9205.entry.js +0 -1
  178. package/dist/lime-crm-building-blocks/p-bcc23575.js +0 -1
  179. package/dist/lime-crm-building-blocks/p-c40a3f4b.js +0 -1
@@ -0,0 +1,317 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+ import { T as Te } from './index.esm.js';
3
+
4
+ /**
5
+ * Get normalized properties for a limetype
6
+ * Adds system properties (_id, _timestamp, etc.) that map to the actual limeobject attributes
7
+ * @param limetype The limetype to normalize
8
+ * @returns Normalized properties with system properties prefixed with underscore
9
+ */
10
+ function getNormalizedProperties(limetype) {
11
+ if (!(limetype === null || limetype === void 0 ? void 0 : limetype.properties)) {
12
+ return {};
13
+ }
14
+ const properties = Object.assign({}, limetype.properties);
15
+ // System properties that are exposed by the backend
16
+ // Map from internal property name to API property name
17
+ const systemProperties = {
18
+ id: '_id',
19
+ timestamp: '_timestamp',
20
+ descriptive: '_descriptive',
21
+ createduser: '_createduser',
22
+ createdtime: '_createdtime',
23
+ updateduser: '_updateduser',
24
+ };
25
+ // Find and normalize system properties by name
26
+ for (const [propName, systemPropName] of Object.entries(systemProperties)) {
27
+ const property = properties[propName];
28
+ if (property) {
29
+ properties[systemPropName] = property;
30
+ delete properties[propName];
31
+ }
32
+ }
33
+ return properties;
34
+ }
35
+ /**
36
+ * Get property from limetype by path (e.g., "company.name")
37
+ * Supports relation traversal with dot-notation
38
+ * @param limetypes
39
+ * @param limetype
40
+ * @param path
41
+ */
42
+ function getPropertyFromPath(limetypes, limetype, path) {
43
+ if (!path || !limetype || !limetypes) {
44
+ return undefined;
45
+ }
46
+ const parts = path.split('.');
47
+ let currentType = limetypes[limetype];
48
+ let property;
49
+ for (const part of parts) {
50
+ if (!currentType) {
51
+ return undefined;
52
+ }
53
+ const normalizedProperties = getNormalizedProperties(currentType);
54
+ property = normalizedProperties[part];
55
+ if (!property) {
56
+ return undefined;
57
+ }
58
+ // If this is a relation, get the related limetype for next iteration
59
+ if (property.relation) {
60
+ currentType = property.relation.getLimetype();
61
+ }
62
+ }
63
+ return property;
64
+ }
65
+
66
+ const propertySelectorCss = ":host(limebb-property-selector){display:block}limel-menu{display:block;width:100%}";
67
+ const LimebbPropertySelectorStyle0 = propertySelectorCss;
68
+
69
+ var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
70
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
71
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
72
+ r = Reflect.decorate(decorators, target, key, desc);
73
+ else
74
+ for (var i = decorators.length - 1; i >= 0; i--)
75
+ if (d = decorators[i])
76
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
77
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
78
+ };
79
+ const PropertySelector = /*@__PURE__*/ proxyCustomElement(class PropertySelector extends HTMLElement {
80
+ constructor() {
81
+ super();
82
+ this.__registerHost();
83
+ this.__attachShadow();
84
+ this.change = createEvent(this, "change", 7);
85
+ /**
86
+ * Label for the input
87
+ */
88
+ this.label = 'Property';
89
+ /**
90
+ * Whether the field is required
91
+ */
92
+ this.required = false;
93
+ this.isOpen = false;
94
+ this.navigationPath = '';
95
+ this.menuItems = [];
96
+ this.handleChipSetWrapperClick = (event) => {
97
+ // Stop all clicks on the chip-set from bubbling
98
+ // This prevents the menu from opening when clicking chip remove buttons
99
+ event.stopPropagation();
100
+ };
101
+ this.handleChipSetFocus = () => {
102
+ // Open menu when the chip-set input receives focus
103
+ // This happens when user clicks to type/edit
104
+ if (!this.isOpen) {
105
+ this.navigationPath = this.value || '';
106
+ this.loadMenuItems();
107
+ this.isOpen = true;
108
+ }
109
+ };
110
+ this.handleSelect = (event) => {
111
+ event.stopPropagation();
112
+ const selectedPath = event.detail.value;
113
+ if (!selectedPath) {
114
+ return;
115
+ }
116
+ // Check if this is a complete path (leaf property, not a relation)
117
+ const property = getPropertyFromPath(this.limetypes, this.limetype, selectedPath);
118
+ if (property === null || property === void 0 ? void 0 : property.relation) {
119
+ // This is a relation - update navigation but don't emit
120
+ this.navigationPath = selectedPath;
121
+ }
122
+ else {
123
+ // This is a leaf property - emit and close
124
+ this.change.emit(selectedPath);
125
+ this.isOpen = false;
126
+ this.navigationPath = '';
127
+ }
128
+ };
129
+ this.handleNavigateMenu = (event) => {
130
+ var _a;
131
+ event.stopPropagation();
132
+ if ((_a = event.detail) === null || _a === void 0 ? void 0 : _a.value) {
133
+ // Update navigation path when drilling down
134
+ this.navigationPath = event.detail.value;
135
+ }
136
+ };
137
+ this.handleCancel = () => {
138
+ this.isOpen = false;
139
+ this.navigationPath = '';
140
+ };
141
+ this.handleChipSetChange = (event) => {
142
+ event.stopPropagation();
143
+ const detail = event.detail;
144
+ // Handle both single chip and array of chips
145
+ if (!detail) {
146
+ // Clear all was clicked
147
+ this.change.emit('');
148
+ this.navigationPath = '';
149
+ return;
150
+ }
151
+ // Convert to array if it's a single chip
152
+ const chips = Array.isArray(detail) ? detail : [detail];
153
+ if (chips.length === 0) {
154
+ // All chips removed
155
+ this.change.emit('');
156
+ this.navigationPath = '';
157
+ }
158
+ else {
159
+ // A chip was removed - emit the last remaining chip's value
160
+ const lastChip = chips.at(-1);
161
+ if (lastChip) {
162
+ this.change.emit(lastChip.value);
163
+ }
164
+ this.navigationPath = '';
165
+ }
166
+ };
167
+ }
168
+ render() {
169
+ if (!this.limetype || !this.limetypes) {
170
+ return null;
171
+ }
172
+ const chips = this.getChipsForPath(this.navigationPath || this.value || '');
173
+ return (h("limel-menu", { items: this.menuItems, open: this.isOpen, emptyResultMessage: "No available properties", surfaceWidth: "inherit-from-trigger", openDirection: "bottom-end", onSelect: this.handleSelect, onNavigateMenu: this.handleNavigateMenu, onCancel: this.handleCancel }, h("div", { slot: "trigger" }, h("div", { onClick: this.handleChipSetWrapperClick }, h("limel-chip-set", { type: "input", label: this.label, value: chips, required: this.required, helperText: this.helperText, delimiter: "\u203A", maxItems: 1, onChange: this.handleChipSetChange, onFocus: this.handleChipSetFocus })))));
174
+ }
175
+ loadMenuItems() {
176
+ // Get the limetype we're currently navigating in
177
+ const currentLimetype = this.getCurrentLimetype();
178
+ if (!currentLimetype) {
179
+ this.menuItems = [];
180
+ return;
181
+ }
182
+ this.menuItems = this.createMenuItems(currentLimetype, '');
183
+ }
184
+ getCurrentLimetype() {
185
+ if (!this.navigationPath) {
186
+ return this.limetypes[this.limetype];
187
+ }
188
+ // Get the limetype at the current navigation path
189
+ const property = getPropertyFromPath(this.limetypes, this.limetype, this.navigationPath);
190
+ if (property === null || property === void 0 ? void 0 : property.relation) {
191
+ return property.relation.getLimetype();
192
+ }
193
+ return this.limetypes[this.limetype];
194
+ }
195
+ createMenuItems(limetype, pathPrefix) {
196
+ const results = [];
197
+ if (!limetype) {
198
+ return results;
199
+ }
200
+ const normalizedProperties = getNormalizedProperties(limetype);
201
+ for (const [propName, property] of Object.entries(normalizedProperties)) {
202
+ // Skip hasMany and hasAndBelongsToMany relations
203
+ if (property.type === 'hasmany' ||
204
+ property.type === 'hasandbelongstomany') {
205
+ continue;
206
+ }
207
+ const fullPath = pathPrefix
208
+ ? `${pathPrefix}.${propName}`
209
+ : propName;
210
+ const isRelation = !!property.relation;
211
+ let items;
212
+ if (isRelation && property.relation) {
213
+ // Create submenu for relation (only belongsto at this point)
214
+ const relatedLimetype = property.relation.getLimetype();
215
+ if (relatedLimetype) {
216
+ items = async () => this.createMenuItems(relatedLimetype, fullPath);
217
+ }
218
+ }
219
+ results.push({
220
+ text: property.localname || propName,
221
+ secondaryText: this.getSecondaryText(property),
222
+ icon: this.getIconForProperty(property),
223
+ value: fullPath,
224
+ items: items,
225
+ });
226
+ }
227
+ if (results.length === 0) {
228
+ return [
229
+ {
230
+ text: 'No available properties',
231
+ value: '',
232
+ disabled: true,
233
+ },
234
+ ];
235
+ }
236
+ return results;
237
+ }
238
+ getSecondaryText(property) {
239
+ var _a;
240
+ if (property.relation) {
241
+ const relatedLimetype = property.relation.getLimetype();
242
+ return ((_a = relatedLimetype === null || relatedLimetype === void 0 ? void 0 : relatedLimetype.localname) === null || _a === void 0 ? void 0 : _a.singular) || 'Object';
243
+ }
244
+ // Return the property type as the secondary text
245
+ return property.type.charAt(0).toUpperCase() + property.type.slice(1);
246
+ }
247
+ getIconForProperty(property) {
248
+ if (property.relation) {
249
+ return {
250
+ name: 'link',
251
+ color: 'rgb(var(--color-sky-default))',
252
+ };
253
+ }
254
+ // Use generic property icon
255
+ return {
256
+ name: 'decision',
257
+ color: 'rgb(var(--color-gray-default))',
258
+ };
259
+ }
260
+ getChipsForPath(path) {
261
+ if (!path) {
262
+ return [];
263
+ }
264
+ const parts = path.split('.');
265
+ const chips = [];
266
+ let currentLimetype = this.limetypes[this.limetype];
267
+ let currentPath = '';
268
+ for (const part of parts) {
269
+ currentPath = currentPath ? `${currentPath}.${part}` : part;
270
+ // Use getNormalizedProperties to include _id and _timestamp
271
+ const normalizedProperties = getNormalizedProperties(currentLimetype);
272
+ const property = normalizedProperties[part];
273
+ if (property) {
274
+ chips.push({
275
+ id: currentPath,
276
+ text: property.localname || part,
277
+ icon: this.getIconForProperty(property),
278
+ value: currentPath,
279
+ });
280
+ if (property.relation) {
281
+ currentLimetype = property.relation.getLimetype();
282
+ }
283
+ }
284
+ }
285
+ return chips;
286
+ }
287
+ static get style() { return LimebbPropertySelectorStyle0; }
288
+ }, [1, "limebb-property-selector", {
289
+ "platform": [16],
290
+ "context": [16],
291
+ "limetype": [1],
292
+ "value": [1],
293
+ "label": [1],
294
+ "required": [4],
295
+ "helperText": [1, "helper-text"],
296
+ "limetypes": [32],
297
+ "isOpen": [32],
298
+ "navigationPath": [32]
299
+ }]);
300
+ __decorate([
301
+ Te()
302
+ ], PropertySelector.prototype, "limetypes", void 0);
303
+ function defineCustomElement() {
304
+ if (typeof customElements === "undefined") {
305
+ return;
306
+ }
307
+ const components = ["limebb-property-selector"];
308
+ components.forEach(tagName => { switch (tagName) {
309
+ case "limebb-property-selector":
310
+ if (!customElements.get(tagName)) {
311
+ customElements.define(tagName, PropertySelector);
312
+ }
313
+ break;
314
+ } });
315
+ }
316
+
317
+ export { PropertySelector as P, getPropertyFromPath as a, defineCustomElement as d, getNormalizedProperties as g };
@@ -0,0 +1,278 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+ import { d as defineCustomElement$2 } from './property-selector.js';
3
+ import { d as defineCustomElement$1 } from './response-format-item.js';
4
+
5
+ /**
6
+ * Process a single property value and add to items array
7
+ * @param items Array to add items to
8
+ * @param fullPath Full property path
9
+ * @param value Property value to process
10
+ */
11
+ function processPropertyValue(items, fullPath, value) {
12
+ if (value === null) {
13
+ items.push({ path: fullPath });
14
+ return;
15
+ }
16
+ // Cast to record for checking
17
+ const valueObj = value;
18
+ const keys = Object.keys(valueObj);
19
+ const hasAlias = '_alias' in valueObj;
20
+ const hasDescription = '#description' in valueObj;
21
+ const otherKeys = keys.filter((k) => k !== '_alias' && k !== '#description');
22
+ // If it's {} or only has metadata (_alias, #description), treat as simple property
23
+ if (otherKeys.length === 0) {
24
+ const aliasValue = valueObj._alias;
25
+ const descriptionValue = valueObj['#description'];
26
+ if (aliasValue || descriptionValue) {
27
+ items.push({
28
+ path: fullPath,
29
+ alias: aliasValue,
30
+ description: descriptionValue,
31
+ });
32
+ }
33
+ else {
34
+ items.push({ path: fullPath });
35
+ }
36
+ return;
37
+ }
38
+ // If has metadata + other properties, we need to handle both
39
+ // Add the nested properties (metadata is preserved in conversion back)
40
+ if (hasAlias || hasDescription) {
41
+ // Build a PropertySelection without the metadata for recursion
42
+ const nestedSelection = {};
43
+ for (const key of otherKeys) {
44
+ nestedSelection[key] = valueObj[key];
45
+ }
46
+ items.push(...propertySelectionToItems(nestedSelection, fullPath));
47
+ return;
48
+ }
49
+ // Nested property selection without metadata
50
+ items.push(...propertySelectionToItems(value, fullPath));
51
+ }
52
+ /**
53
+ * Convert a nested PropertySelection to a flat list of property items
54
+ * @param selection The nested PropertySelection object
55
+ * @param prefix Current path prefix (used for recursion)
56
+ * @returns Flat array of PropertySelectionItem objects
57
+ */
58
+ function propertySelectionToItems(selection, prefix = '') {
59
+ if (!selection) {
60
+ return [];
61
+ }
62
+ const items = [];
63
+ for (const [key, value] of Object.entries(selection)) {
64
+ const fullPath = prefix ? `${prefix}.${key}` : key;
65
+ if (typeof value === 'object') {
66
+ // NOTE: We want to send null values to the processPropertyValue
67
+ // function but we don't need a special check for null, since
68
+ // `typeof null === 'object'`
69
+ processPropertyValue(items, fullPath, value);
70
+ }
71
+ }
72
+ return items;
73
+ }
74
+ /**
75
+ * Set the final property value (with or without alias/description)
76
+ * @param current Current PropertySelection object
77
+ * @param part Property name/key
78
+ * @param item Property selection item with path and optional alias/description
79
+ */
80
+ function setPropertyValue(current, part, item) {
81
+ // Check if there's already a nested PropertySelection with properties
82
+ const existing = current[part];
83
+ if (existing &&
84
+ typeof existing === 'object' &&
85
+ !('_alias' in existing) &&
86
+ !('#description' in existing)) {
87
+ // There's already a nested PropertySelection object with properties
88
+ // Don't overwrite it - preserve the nested selections
89
+ return;
90
+ }
91
+ // Build metadata object, stripping empty values
92
+ const metadata = {};
93
+ if (item.alias && item.alias.trim() !== '') {
94
+ metadata._alias = item.alias;
95
+ }
96
+ if (item.description && item.description.trim() !== '') {
97
+ metadata['#description'] = item.description;
98
+ }
99
+ // If we have metadata, use it; otherwise use null
100
+ if (Object.keys(metadata).length > 0) {
101
+ current[part] = metadata;
102
+ }
103
+ else {
104
+ current[part] = null;
105
+ }
106
+ }
107
+ /**
108
+ * Ensure a nested object exists and return it
109
+ * Preserves any existing _alias and #description when converting to nested object
110
+ * @param current Current PropertySelection object
111
+ * @param part Property name/key
112
+ * @returns The nested PropertySelection object
113
+ */
114
+ function ensureNestedObject(current, part) {
115
+ const existing = current[part];
116
+ // If doesn't exist or is null, create empty object
117
+ if (!existing) {
118
+ current[part] = {};
119
+ return current[part];
120
+ }
121
+ // If it's already a PropertySelection object, check for metadata
122
+ if (typeof existing === 'object') {
123
+ const existingObj = existing;
124
+ // If it has metadata but no other properties, preserve the metadata
125
+ const keys = Object.keys(existingObj);
126
+ const hasMetadata = '_alias' in existingObj || '#description' in existingObj;
127
+ const otherKeys = keys.filter((k) => k !== '_alias' && k !== '#description');
128
+ if (hasMetadata && otherKeys.length === 0) {
129
+ // Convert { _alias: "...", "#description": "..." } to { _alias: "...", "#description": "...", ...nested }
130
+ // Keep the existing object and return it (caller will add nested props)
131
+ return existingObj;
132
+ }
133
+ // Already has nested properties, return as is
134
+ return existingObj;
135
+ }
136
+ // Shouldn't reach here, but fallback to creating new object
137
+ current[part] = {};
138
+ return current[part];
139
+ }
140
+ /**
141
+ * Convert a flat list of property items to a nested PropertySelection structure
142
+ * @param items Array of PropertySelectionItem objects
143
+ * @returns Nested PropertySelection object
144
+ */
145
+ function itemsToPropertySelection(items) {
146
+ const result = {};
147
+ for (const item of items) {
148
+ const parts = item.path.split('.');
149
+ let current = result;
150
+ for (let i = 0; i < parts.length; i++) {
151
+ const part = parts[i];
152
+ const isLast = i === parts.length - 1;
153
+ if (isLast) {
154
+ setPropertyValue(current, part, item);
155
+ }
156
+ else {
157
+ current = ensureNestedObject(current, part);
158
+ }
159
+ }
160
+ }
161
+ return result;
162
+ }
163
+
164
+ const responseFormatEditorCss = ":host(limebb-response-format-editor){display:block;width:100%}.response-format-editor{display:flex;flex-direction:column;gap:1rem;padding:1rem}.header{display:flex;justify-content:space-between;align-items:center;gap:1rem}.header h4{margin:0;font-size:1rem;font-weight:600;color:rgb(var(--contrast-1000))}.property-list{display:flex;flex-direction:column;gap:1rem;padding:0.5rem;border:1px solid rgb(var(--contrast-300));border-radius:0.25rem;background-color:rgb(var(--contrast-50));min-height:4rem}.property-item{padding:0.5rem;border-radius:0.25rem;transition:background-color 0.2s}.property-item:hover{background-color:rgb(var(--contrast-100))}.actions{display:flex;justify-content:flex-start}.summary{display:flex;justify-content:space-between;align-items:center;padding-top:0.5rem;border-top:1px solid rgb(var(--contrast-300))}.summary .count{font-size:0.875rem;font-weight:500;color:rgb(var(--contrast-900))}.empty-state{padding:2rem;text-align:center;color:rgb(var(--contrast-700));font-style:italic}.empty-state p{margin:0}";
165
+ const LimebbResponseFormatEditorStyle0 = responseFormatEditorCss;
166
+
167
+ const ResponseFormatEditor = /*@__PURE__*/ proxyCustomElement(class ResponseFormatEditor extends HTMLElement {
168
+ constructor() {
169
+ super();
170
+ this.__registerHost();
171
+ this.__attachShadow();
172
+ this.change = createEvent(this, "change", 7);
173
+ /**
174
+ * Optional label
175
+ */
176
+ this.label = 'Select Properties to Return';
177
+ this.items = [{ path: '_id' }];
178
+ this.handleItemChange = (index) => (event) => {
179
+ event.stopPropagation();
180
+ const newItems = [...this.items];
181
+ if (event.detail === null) {
182
+ // Remove item
183
+ newItems.splice(index, 1);
184
+ }
185
+ else {
186
+ // Update item
187
+ newItems[index] = event.detail;
188
+ }
189
+ // Ensure we always have at least _id
190
+ if (newItems.length === 0) {
191
+ newItems.push({ path: '_id' });
192
+ }
193
+ this.items = newItems;
194
+ this.emitChange();
195
+ };
196
+ this.handleAddProperty = () => {
197
+ this.items = [...this.items, { path: '' }];
198
+ this.emitChange();
199
+ };
200
+ }
201
+ componentWillLoad() {
202
+ var _a;
203
+ if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.object) {
204
+ const converted = propertySelectionToItems(this.value.object);
205
+ if (converted.length > 0) {
206
+ this.items = converted;
207
+ }
208
+ }
209
+ }
210
+ componentWillUpdate() {
211
+ var _a;
212
+ if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.object) {
213
+ const currentItems = propertySelectionToItems(this.value.object);
214
+ // Check if items have changed
215
+ const itemsChanged = currentItems.length !== this.items.length ||
216
+ !currentItems.every((item, index) => {
217
+ const current = this.items[index];
218
+ return (current &&
219
+ item.path === current.path &&
220
+ item.alias === current.alias &&
221
+ item.description === current.description);
222
+ });
223
+ if (itemsChanged) {
224
+ this.items =
225
+ currentItems.length > 0 ? currentItems : [{ path: '_id' }];
226
+ }
227
+ }
228
+ }
229
+ render() {
230
+ if (!this.limetype) {
231
+ return (h("div", { class: "empty-state" }, h("p", null, "Select a limetype to choose properties")));
232
+ }
233
+ return (h("div", { class: "response-format-editor" }, h("div", { class: "header" }, h("h4", null, this.label)), h("div", { class: "property-list" }, this.items.map((item, index) => this.renderItem(item, index))), h("div", { class: "actions" }, h("limel-button", { label: "Add Property", icon: "plus_math", onClick: this.handleAddProperty })), h("div", { class: "summary" }, h("span", { class: "count" }, this.items.length, ' ', this.items.length === 1 ? 'property' : 'properties', ' ', "selected"))));
234
+ }
235
+ renderItem(item, index) {
236
+ return (h("limebb-response-format-item", { key: `${item.path}-${index}`, class: "property-item", platform: this.platform, context: this.context, limetype: this.limetype, item: item, onItemChange: this.handleItemChange(index) }));
237
+ }
238
+ emitChange() {
239
+ const propertySelection = itemsToPropertySelection(this.items);
240
+ const responseFormat = {
241
+ object: propertySelection,
242
+ };
243
+ this.change.emit(responseFormat);
244
+ }
245
+ static get style() { return LimebbResponseFormatEditorStyle0; }
246
+ }, [1, "limebb-response-format-editor", {
247
+ "platform": [16],
248
+ "context": [16],
249
+ "limetype": [1],
250
+ "value": [16],
251
+ "label": [1],
252
+ "items": [32]
253
+ }]);
254
+ function defineCustomElement() {
255
+ if (typeof customElements === "undefined") {
256
+ return;
257
+ }
258
+ const components = ["limebb-response-format-editor", "limebb-property-selector", "limebb-response-format-item"];
259
+ components.forEach(tagName => { switch (tagName) {
260
+ case "limebb-response-format-editor":
261
+ if (!customElements.get(tagName)) {
262
+ customElements.define(tagName, ResponseFormatEditor);
263
+ }
264
+ break;
265
+ case "limebb-property-selector":
266
+ if (!customElements.get(tagName)) {
267
+ defineCustomElement$2();
268
+ }
269
+ break;
270
+ case "limebb-response-format-item":
271
+ if (!customElements.get(tagName)) {
272
+ defineCustomElement$1();
273
+ }
274
+ break;
275
+ } });
276
+ }
277
+
278
+ export { ResponseFormatEditor as R, defineCustomElement as d };