@rovula/ui 0.1.23 → 0.1.24
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/cjs/bundle.js +1 -1
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/patterns/menu/Menu.d.ts +2 -0
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/patterns/menu/Menu.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/patterns/menu/Menu.js +3 -3
- package/package.json +1 -1
- package/src/patterns/menu/Menu.tsx +5 -0
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ function renderMenuItems(items, selectedValues, onSelect) {
|
|
|
23
23
|
onSelect === null || onSelect === void 0 ? void 0 : onSelect(val, opt);
|
|
24
24
|
(_a = opt.onClick) === null || _a === void 0 ? void 0 : _a.call(opt);
|
|
25
25
|
}
|
|
26
|
-
}, children: buffer.map((opt) => (_jsx(DropdownMenuRadioItem, { value: opt.value, disabled: opt.disabled, icon: opt.icon, children: opt.label }, opt.value))) }, key));
|
|
26
|
+
}, children: buffer.map((opt) => (_jsx(DropdownMenuRadioItem, { value: opt.value, disabled: opt.disabled, icon: opt.icon, "data-testid": opt.testId, children: opt.label }, opt.value))) }, key));
|
|
27
27
|
};
|
|
28
28
|
items.forEach((item, index) => {
|
|
29
29
|
var _a;
|
|
@@ -54,7 +54,7 @@ function renderMenuItems(items, selectedValues, onSelect) {
|
|
|
54
54
|
const opt = item.item;
|
|
55
55
|
const isSelected = (_a = opt.checked) !== null && _a !== void 0 ? _a : selectedValues.includes(opt.value);
|
|
56
56
|
if (opt.type === "checkbox") {
|
|
57
|
-
result.push(_jsx(DropdownMenuCheckboxItem, { checked: isSelected, disabled: opt.disabled, onCheckedChange: () => {
|
|
57
|
+
result.push(_jsx(DropdownMenuCheckboxItem, { checked: isSelected, disabled: opt.disabled, "data-testid": opt.testId, onCheckedChange: () => {
|
|
58
58
|
var _a;
|
|
59
59
|
onSelect === null || onSelect === void 0 ? void 0 : onSelect(opt.value, opt);
|
|
60
60
|
(_a = opt.onClick) === null || _a === void 0 ? void 0 : _a.call(opt);
|
|
@@ -62,7 +62,7 @@ function renderMenuItems(items, selectedValues, onSelect) {
|
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
// default item
|
|
65
|
-
result.push(_jsx(DropdownMenuItem, { selected: isSelected, icon: opt.icon, disabled: opt.disabled, className: cn(opt.danger && "text-red-500"), onSelect: () => {
|
|
65
|
+
result.push(_jsx(DropdownMenuItem, { selected: isSelected, icon: opt.icon, disabled: opt.disabled, className: cn(opt.danger && "text-red-500"), "data-testid": opt.testId, onSelect: () => {
|
|
66
66
|
var _a;
|
|
67
67
|
onSelect === null || onSelect === void 0 ? void 0 : onSelect(opt.value, opt);
|
|
68
68
|
(_a = opt.onClick) === null || _a === void 0 ? void 0 : _a.call(opt);
|
package/package.json
CHANGED
|
@@ -36,6 +36,8 @@ export type MenuOption = {
|
|
|
36
36
|
danger?: boolean;
|
|
37
37
|
checked?: boolean;
|
|
38
38
|
onClick?: () => void;
|
|
39
|
+
/** data-testid attached to the item element */
|
|
40
|
+
testId?: string;
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
export type MenuItemType =
|
|
@@ -121,6 +123,7 @@ function renderMenuItems(
|
|
|
121
123
|
value={opt.value}
|
|
122
124
|
disabled={opt.disabled}
|
|
123
125
|
icon={opt.icon as React.ReactNode}
|
|
126
|
+
data-testid={opt.testId}
|
|
124
127
|
>
|
|
125
128
|
{opt.label}
|
|
126
129
|
</DropdownMenuRadioItem>
|
|
@@ -187,6 +190,7 @@ function renderMenuItems(
|
|
|
187
190
|
key={opt.value}
|
|
188
191
|
checked={isSelected}
|
|
189
192
|
disabled={opt.disabled}
|
|
193
|
+
data-testid={opt.testId}
|
|
190
194
|
onCheckedChange={() => {
|
|
191
195
|
onSelect?.(opt.value, opt);
|
|
192
196
|
opt.onClick?.();
|
|
@@ -206,6 +210,7 @@ function renderMenuItems(
|
|
|
206
210
|
icon={opt.icon as React.ReactNode}
|
|
207
211
|
disabled={opt.disabled}
|
|
208
212
|
className={cn(opt.danger && "text-red-500")}
|
|
213
|
+
data-testid={opt.testId}
|
|
209
214
|
onSelect={() => {
|
|
210
215
|
onSelect?.(opt.value, opt);
|
|
211
216
|
opt.onClick?.();
|