@rettangoli/ui 0.1.3 → 0.1.5
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.
- package/dist/rettangoli-iife-ui.min.js +30 -30
- package/package.json +4 -4
- package/src/components/breadcrumb/breadcrumb.handlers.js +2 -1
- package/src/components/dropdownMenu/dropdownMenu.handlers.js +5 -4
- package/src/components/dropdownMenu/dropdownMenu.view.yaml +10 -10
- package/src/components/form/form.handlers.js +25 -14
- package/src/components/globalUi/globalUi.handlers.js +91 -13
- package/src/components/globalUi/globalUi.store.js +38 -2
- package/src/components/globalUi/globalUi.view.yaml +31 -11
- package/src/components/navbar/navbar.handlers.js +2 -1
- package/src/components/popoverInput/popoverInput.handlers.js +11 -7
- package/src/components/select/select.handlers.js +15 -11
- package/src/components/sidebar/sidebar.handlers.js +4 -2
- package/src/components/sliderInput/sliderInput.handlers.js +5 -4
- package/src/components/table/table.handlers.js +4 -2
- package/src/components/tabs/tabs.handlers.js +2 -1
- package/src/components/waveform/waveform.handlers.js +1 -1
- package/src/deps/createGlobalUI.js +77 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export const handleHeaderClick = (deps,
|
|
1
|
+
export const handleHeaderClick = (deps, payload) => {
|
|
2
2
|
const { store, dispatchEvent } = deps;
|
|
3
|
+
const event = payload._event;
|
|
3
4
|
|
|
4
5
|
let path;
|
|
5
6
|
|
|
@@ -22,8 +23,9 @@ export const handleHeaderClick = (deps, event) => {
|
|
|
22
23
|
}));
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
export const handleItemClick = (deps,
|
|
26
|
+
export const handleItemClick = (deps, payload) => {
|
|
26
27
|
const { store, dispatchEvent } = deps;
|
|
28
|
+
const event = payload._event;
|
|
27
29
|
const id = event.currentTarget.id.replace('item-', '');
|
|
28
30
|
const item = store.selectItem(id);
|
|
29
31
|
dispatchEvent(new CustomEvent('itemClick', {
|
|
@@ -3,10 +3,10 @@ export const handleBeforeMount = (deps) => {
|
|
|
3
3
|
store.setValue(attrs.defaultValue || 0);
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
export const handleOnUpdate = (
|
|
7
|
-
const { oldAttrs, newAttrs } =
|
|
6
|
+
export const handleOnUpdate = (deps, payload) => {
|
|
7
|
+
const { oldAttrs, newAttrs } = payload;
|
|
8
8
|
const { store, render, attrs } = deps;
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
// Reset when key changes
|
|
11
11
|
if (oldAttrs?.key !== newAttrs?.key && newAttrs?.key) {
|
|
12
12
|
const defaultValue = newAttrs?.defaultValue || attrs?.defaultValue || 0;
|
|
@@ -20,8 +20,9 @@ export const handleOnUpdate = (changes, deps) => {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export const handleValueChange = (deps,
|
|
23
|
+
export const handleValueChange = (deps, payload) => {
|
|
24
24
|
const { store, render, dispatchEvent } = deps;
|
|
25
|
+
const event = payload._event;
|
|
25
26
|
const newValue = Number(event.detail.value);
|
|
26
27
|
|
|
27
28
|
store.setValue(newValue);
|
|
@@ -2,8 +2,9 @@ export const handleBeforeMount = (deps) => {
|
|
|
2
2
|
// No special initialization needed for basic table
|
|
3
3
|
};
|
|
4
4
|
|
|
5
|
-
export const handleRowClick = (deps,
|
|
5
|
+
export const handleRowClick = (deps, payload) => {
|
|
6
6
|
const { dispatchEvent, props } = deps;
|
|
7
|
+
const event = payload._event;
|
|
7
8
|
const rowIndex = parseInt(event.currentTarget.id.replace("row-", ""));
|
|
8
9
|
const rowData = props.data?.rows?.[rowIndex];
|
|
9
10
|
|
|
@@ -19,8 +20,9 @@ export const handleRowClick = (deps, event) => {
|
|
|
19
20
|
}
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
export const handleHeaderClick = (deps,
|
|
23
|
+
export const handleHeaderClick = (deps, payload) => {
|
|
23
24
|
const { store, render, dispatchEvent } = deps;
|
|
25
|
+
const event = payload._event;
|
|
24
26
|
const columnKey = event.currentTarget.id.replace("header-", "");
|
|
25
27
|
const currentSort = store.selectSortInfo();
|
|
26
28
|
|
|
@@ -11,7 +11,7 @@ export const handleAfterMount = async (deps) => {
|
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export const handleOnUpdate = async (
|
|
14
|
+
export const handleOnUpdate = async (deps, payload) => {
|
|
15
15
|
const { store, render, getRefIds, props } = deps;
|
|
16
16
|
const { waveformData } = props;
|
|
17
17
|
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a GlobalUI manager instance for controlling global UI components.
|
|
3
|
+
* Provides methods for showing alerts, confirm dialogs, and dropdown menus.
|
|
4
|
+
*
|
|
5
|
+
* @param {HTMLElement} globalUIElement - The globalUI component element
|
|
6
|
+
* @returns {Object} GlobalUI manager instance
|
|
7
|
+
* @returns {Function} returns.once - Register a one-time event listener
|
|
8
|
+
* @returns {Function} returns.emit - Emit an event to registered listeners
|
|
9
|
+
* @returns {Function} returns.showAlert - Show an alert dialog
|
|
10
|
+
* @returns {Function} returns.showConfirm - Show a confirmation dialog
|
|
11
|
+
* @returns {Function} returns.showDropdownMenu - Show a dropdown menu
|
|
12
|
+
*/
|
|
1
13
|
const createGlobalUI = (globalUIElement) => {
|
|
2
14
|
let listeners = {};
|
|
3
15
|
|
|
4
16
|
return {
|
|
17
|
+
/**
|
|
18
|
+
* Registers a one-time event listener for the specified event.
|
|
19
|
+
* The listener will be automatically removed after the first event.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} event - The event name to listen for
|
|
22
|
+
* @param {Function} callback - The callback function to execute
|
|
23
|
+
* @returns {void}
|
|
24
|
+
*/
|
|
5
25
|
once: (event, callback) => {
|
|
6
26
|
if (!listeners[event]) {
|
|
7
27
|
listeners[event] = [];
|
|
@@ -12,6 +32,14 @@ const createGlobalUI = (globalUIElement) => {
|
|
|
12
32
|
}
|
|
13
33
|
listeners[event].push(onceCallback);
|
|
14
34
|
},
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Emits an event to all registered listeners for the specified event type.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} event - The event name to emit
|
|
40
|
+
* @param {...any} args - Arguments to pass to the event listeners
|
|
41
|
+
* @returns {void}
|
|
42
|
+
*/
|
|
15
43
|
emit: (event, ...args) => {
|
|
16
44
|
if (listeners[event]) {
|
|
17
45
|
listeners[event].forEach(callback => {
|
|
@@ -19,6 +47,19 @@ const createGlobalUI = (globalUIElement) => {
|
|
|
19
47
|
});
|
|
20
48
|
}
|
|
21
49
|
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Shows an alert dialog with the specified options.
|
|
53
|
+
* The alert displays a message with a single OK button.
|
|
54
|
+
*
|
|
55
|
+
* @param {Object} options - Alert configuration options
|
|
56
|
+
* @param {string} options.message - The alert message (required)
|
|
57
|
+
* @param {string} [options.title] - Optional alert title
|
|
58
|
+
* @param {('info'|'warning'|'error')} [options.status] - Optional status type
|
|
59
|
+
* @param {string} [options.confirmText] - Text for the confirm button (default: "OK")
|
|
60
|
+
* @returns {Promise<void>} Promise that resolves when the alert is closed
|
|
61
|
+
* @throws {Error} If globalUIElement is not initialized
|
|
62
|
+
*/
|
|
22
63
|
showAlert: async (options) => {
|
|
23
64
|
if(!globalUIElement)
|
|
24
65
|
{
|
|
@@ -26,12 +67,48 @@ const createGlobalUI = (globalUIElement) => {
|
|
|
26
67
|
}
|
|
27
68
|
globalUIElement.transformedHandlers.showAlert(options);
|
|
28
69
|
},
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Shows a confirmation dialog with the specified options.
|
|
73
|
+
* The dialog displays a message with confirm and cancel buttons.
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} options - Confirmation dialog configuration options
|
|
76
|
+
* @param {string} options.message - The confirmation message (required)
|
|
77
|
+
* @param {string} [options.title] - Optional dialog title
|
|
78
|
+
* @param {('info'|'warning'|'error')} [options.status] - Optional status type
|
|
79
|
+
* @param {string} [options.confirmText] - Text for the confirm button (default: "Yes")
|
|
80
|
+
* @param {string} [options.cancelText] - Text for the cancel button (default: "Cancel")
|
|
81
|
+
* @returns {Promise<boolean>} Promise that resolves to true if confirmed, false if cancelled
|
|
82
|
+
* @throws {Error} If globalUIElement is not initialized
|
|
83
|
+
*/
|
|
29
84
|
showConfirm: async (options) => {
|
|
30
85
|
if(!globalUIElement)
|
|
31
86
|
{
|
|
32
87
|
throw new Error("globalUIElement is not set. Make sure to initialize the global UI component and pass it to createGlobalUIManager.");
|
|
33
88
|
}
|
|
34
89
|
return globalUIElement.transformedHandlers.showConfirm(options);
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Shows a dropdown menu at the specified position with the given items.
|
|
94
|
+
* The dropdown can contain various item types including labels, items, and separators.
|
|
95
|
+
*
|
|
96
|
+
* @param {Object} options - Dropdown menu configuration options
|
|
97
|
+
* @param {Array<Object>} options.items - Array of dropdown menu items (required)
|
|
98
|
+
* @param {number} options.x - X coordinate position (required)
|
|
99
|
+
* @param {number} options.y - Y coordinate position (required)
|
|
100
|
+
* @param {string} [options.placement] - Dropdown menu placement (default: "bottom-start")
|
|
101
|
+
* @returns {Promise<Object|null>} Promise that resolves with clicked item info or null if closed without selection
|
|
102
|
+
* @returns {Object} [result.index] - Index of the clicked item
|
|
103
|
+
* @returns {Object} [result.item] - The clicked item object
|
|
104
|
+
* @throws {Error} If globalUIElement is not initialized
|
|
105
|
+
*/
|
|
106
|
+
showDropdownMenu: async (options) => {
|
|
107
|
+
if(!globalUIElement)
|
|
108
|
+
{
|
|
109
|
+
throw new Error("globalUIElement is not set. Make sure to initialize the global UI component and pass it to createGlobalUIManager.");
|
|
110
|
+
}
|
|
111
|
+
return globalUIElement.transformedHandlers.showDropdownMenu(options);
|
|
35
112
|
}
|
|
36
113
|
};
|
|
37
114
|
}
|