@rettangoli/ui 1.0.18 → 1.0.20

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.
@@ -10,6 +10,7 @@
10
10
  * @returns {Function} returns.showAlert - Show an alert dialog
11
11
  * @returns {Function} returns.showConfirm - Show a confirmation dialog
12
12
  * @returns {Function} returns.showFormDialog - Show a form dialog
13
+ * @returns {Function} returns.showComponentDialog - Show a component dialog
13
14
  * @returns {Function} returns.showDropdownMenu - Show a dropdown menu
14
15
  * @returns {Function} returns.closeAll - General-purpose function to close all currently open UI components
15
16
  */
@@ -23,7 +24,7 @@ const createGlobalUI = (globalUIElement) => {
23
24
  *
24
25
  * @param {string} event - The event name to listen for
25
26
  * @param {Function} callback - The callback function to execute
26
- * @returns {void}
27
+ * @returns {Function} Unsubscribe function
27
28
  */
28
29
  once: (event, callback) => {
29
30
  if (!listeners[event]) {
@@ -34,6 +35,9 @@ const createGlobalUI = (globalUIElement) => {
34
35
  listeners[event] = listeners[event].filter(cb => cb !== onceCallback);
35
36
  }
36
37
  listeners[event].push(onceCallback);
38
+ return () => {
39
+ listeners[event] = (listeners[event] ?? []).filter(cb => cb !== onceCallback);
40
+ };
37
41
  },
38
42
 
39
43
  /**
@@ -45,7 +49,7 @@ const createGlobalUI = (globalUIElement) => {
45
49
  */
46
50
  emit: (event, ...args) => {
47
51
  if (listeners[event]) {
48
- listeners[event].forEach(callback => {
52
+ [...listeners[event]].forEach(callback => {
49
53
  callback(...args);
50
54
  });
51
55
  }
@@ -114,6 +118,27 @@ const createGlobalUI = (globalUIElement) => {
114
118
  return globalUIElement.transformedHandlers.handleShowFormDialog(options);
115
119
  },
116
120
 
121
+ /**
122
+ * Shows a dialog containing a custom component body.
123
+ *
124
+ * @param {Object} options - Component dialog configuration options
125
+ * @param {string} options.component - Custom element tag name (required)
126
+ * @param {Object} [options.props] - Initial props assigned onto the body component
127
+ * @param {string} [options.title] - Optional dialog title
128
+ * @param {string} [options.description] - Optional dialog description
129
+ * @param {('sm'|'md'|'lg'|'f')} [options.size] - Dialog size token (default: "md")
130
+ * @param {Object} [options.actions] - Footer action configuration
131
+ * @returns {Promise<Object|null>} Resolves with `{ actionId, values? }` or null on dismiss
132
+ * @throws {Error} If globalUIElement is not initialized
133
+ */
134
+ showComponentDialog: async (options) => {
135
+ if(!globalUIElement)
136
+ {
137
+ throw new Error("globalUIElement is not set. Make sure to initialize the global UI component and pass it to createGlobalUIManager.");
138
+ }
139
+ return globalUIElement.transformedHandlers.handleShowComponentDialog(options);
140
+ },
141
+
117
142
  /**
118
143
  * Shows a dropdown menu at the specified position with the given items.
119
144
  * The dropdown can contain various item types including labels, items, and separators.
@@ -104,7 +104,8 @@ class RettangoliViewElement extends HTMLElement {
104
104
  "av",
105
105
  "wrap",
106
106
  "no-wrap",
107
- "overflow"
107
+ "overflow",
108
+ "stretch"
108
109
  ]),
109
110
  ];
110
111
  }
@@ -300,6 +301,11 @@ class RettangoliViewElement extends HTMLElement {
300
301
  this._styles[size]["flex-wrap"] = "nowrap";
301
302
  }
302
303
 
304
+ // Handle stretch
305
+ if (this.hasAttribute(addSizePrefix("stretch"))) {
306
+ this._styles[size]["align-self"] = "stretch";
307
+ }
308
+
303
309
  // Handle scroll properties
304
310
  const scrollHorizontal = this.hasAttribute(addSizePrefix("sh"));
305
311
  const scrollVertical = this.hasAttribute(addSizePrefix("sv"));