@dmsi/wedgekit-react 0.0.487 → 0.0.489
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.
|
@@ -572,8 +572,147 @@ function highlightMatch(text, searchValue) {
|
|
|
572
572
|
);
|
|
573
573
|
}
|
|
574
574
|
|
|
575
|
-
// src/components/
|
|
575
|
+
// src/components/Button.tsx
|
|
576
|
+
var import_clsx6 = __toESM(require("clsx"), 1);
|
|
576
577
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
578
|
+
var Button = (_a) => {
|
|
579
|
+
var _b = _a, {
|
|
580
|
+
variant = "primary",
|
|
581
|
+
as = "button",
|
|
582
|
+
block,
|
|
583
|
+
leftIcon,
|
|
584
|
+
rightIcon,
|
|
585
|
+
className,
|
|
586
|
+
classNameLabel,
|
|
587
|
+
disabled = false,
|
|
588
|
+
children,
|
|
589
|
+
iconOnly = false,
|
|
590
|
+
colorClassName,
|
|
591
|
+
href,
|
|
592
|
+
id,
|
|
593
|
+
testid
|
|
594
|
+
} = _b, props = __objRest(_b, [
|
|
595
|
+
"variant",
|
|
596
|
+
"as",
|
|
597
|
+
"block",
|
|
598
|
+
"leftIcon",
|
|
599
|
+
"rightIcon",
|
|
600
|
+
"className",
|
|
601
|
+
"classNameLabel",
|
|
602
|
+
"disabled",
|
|
603
|
+
"children",
|
|
604
|
+
"iconOnly",
|
|
605
|
+
"colorClassName",
|
|
606
|
+
"href",
|
|
607
|
+
"id",
|
|
608
|
+
"testid"
|
|
609
|
+
]);
|
|
610
|
+
const primaryVariantStyles = variant === "primary" && (0, import_clsx6.default)(
|
|
611
|
+
(colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-on-action-primary-normal",
|
|
612
|
+
"bg-background-action-primary-normal border-background-action-primary-normal",
|
|
613
|
+
"hover:bg-background-action-primary-hover hover:border-background-action-primary-hover",
|
|
614
|
+
"focus:bg-background-action-primary-hover focus:border-background-action-primary-hover focus:outline-0",
|
|
615
|
+
"active:bg-background-action-primary-active active:border-background-action-primary-active",
|
|
616
|
+
"disabled:bg-background-action-primary-disabled disabled:border-background-action-primary-disabled disabled:text-text-on-action-primary-disabled"
|
|
617
|
+
);
|
|
618
|
+
const secondaryVariantStyles = variant === "secondary" && (0, import_clsx6.default)(
|
|
619
|
+
(colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-primary-normal",
|
|
620
|
+
"bg-background-action-secondary-normal border-border-action-normal",
|
|
621
|
+
"hover:bg-background-action-secondary-hover hover:border-border-action-hover hover:text-text-action-primary-hover",
|
|
622
|
+
"focus:bg-background-action-secondary-hover focus:border-border-action-hover focus:text-text-action-primary-hover focus:outline-0",
|
|
623
|
+
"active:bg-background-action-secondary-active active:border-border-action-active active:text-text-action-primary-active",
|
|
624
|
+
"disabled:bg-background-action-primary-disabled disabled:border-border-action-disabled disabled:text-text-action-primary-disabled"
|
|
625
|
+
);
|
|
626
|
+
const tertiaryVariantStyles = variant === "tertiary" && (0, import_clsx6.default)(
|
|
627
|
+
"bg-transparent border-transparent",
|
|
628
|
+
iconOnly ? (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-icon-action-primary-normal" : (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-primary-normal",
|
|
629
|
+
"bg-transparent border-transparent",
|
|
630
|
+
"hover:bg-background-action-secondary-hover hover:border-background-action-secondary-hover hover:text-text-action-primary-hover",
|
|
631
|
+
"focus:bg-background-action-secondary-hover focus:border-background-action-secondary-hover focus:text-text-action-primary-hover focus:outline-0",
|
|
632
|
+
"active:bg-background-action-secondary-active active:border-transparent active:text-text-action-primary-active",
|
|
633
|
+
"disabled:bg-transparent disabled:border-transparent disabled:text-text-action-primary-disabled"
|
|
634
|
+
);
|
|
635
|
+
const primaryCriticalVariantStyles = variant === "primary-critical" && (0, import_clsx6.default)(
|
|
636
|
+
(colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-on-action-primary-normal",
|
|
637
|
+
"bg-background-action-critical-primary-normal border-background-action-critical-primary-normal",
|
|
638
|
+
"hover:bg-background-action-critical-primary-hover hover:border-background-action-critical-primary-hover",
|
|
639
|
+
"focus:bg-background-action-critical-primary-hover focus:border-background-action-critical-primary-hover focus:outline-0",
|
|
640
|
+
"active:bg-background-action-critical-primary-active active:border-background-action-critical-primary-active",
|
|
641
|
+
"disabled:bg-background-action-critical-primary-disabled disabled:border-background-action-critical-primary-disabled disabled:text-text-on-action-primary-disabled"
|
|
642
|
+
);
|
|
643
|
+
const secondaryCriticalVariantStyles = variant === "secondary-critical" && (0, import_clsx6.default)(
|
|
644
|
+
(colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-critical-normal",
|
|
645
|
+
"bg-background-action-critical-secondary-normal border-border-action-critical-normal",
|
|
646
|
+
"hover:bg-background-action-critical-secondary-hover hover:border-border-action-critical-hover hover:text-text-action-critical-hover",
|
|
647
|
+
"focus:bg-background-action-critical-secondary-hover focus:border-border-action-critical-hover focus:text-text-action-critical-hover focus:outline-0",
|
|
648
|
+
"active:bg-background-action-critical-secondary-active active:border-border-action-critical-active active:text-text-action-critical-active",
|
|
649
|
+
"disabled:bg-background-action-critical-disabled disabled:border-border-action-critical-disabled disabled:text-text-action-critical-disabled"
|
|
650
|
+
);
|
|
651
|
+
const tertiaryCriticalVariantStyles = variant === "tertiary-critical" && (0, import_clsx6.default)(
|
|
652
|
+
(colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-critical-normal",
|
|
653
|
+
"bg-transparent border-transparent text-text-action-critical-normal",
|
|
654
|
+
"hover:bg-background-action-critical-secondary-hover hover:border-background-action-critical-secondary-hover hover:text-text-action-critical-hover",
|
|
655
|
+
"focus:bg-background-action-critical-secondary-hover focus:border-background-action-critical-secondary-hover focus:text-text-action-critical-hover focus:outline-0",
|
|
656
|
+
"active:bg-background-action-critical-secondary-active active:border-background-action-critical-secondary-active active:text-text-action-critical-active",
|
|
657
|
+
"disabled:bg-transparent disabled:border-transparent disabled:text-text-action-critical-disabled"
|
|
658
|
+
);
|
|
659
|
+
const navigationVarianStyles = variant === "navigation" && (0, import_clsx6.default)(
|
|
660
|
+
(colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-primary-normal",
|
|
661
|
+
"bg-transparent",
|
|
662
|
+
"hover:bg-background-action-secondary-hover hover:text-text-action-primary-hover",
|
|
663
|
+
"focus:bg-background-action-secondary-hover focus:text-text-action-primary-hover focus:outline-0",
|
|
664
|
+
"active:bg-background-action-secondary-active active:text-text-action-primary-active",
|
|
665
|
+
"disabled:bg-transparent disabled:text-text-on-action-primary-disabled",
|
|
666
|
+
"flex-col",
|
|
667
|
+
paddingUsingComponentGap
|
|
668
|
+
);
|
|
669
|
+
const notNavigationVariantStyles = variant !== "navigation" && (0, import_clsx6.default)("border-2 flex-row", componentPaddingMinus2pxBorder, componentGap);
|
|
670
|
+
const buttonClasses = (0, import_clsx6.default)(
|
|
671
|
+
disabled ? "cursor-default" : "cursor-pointer",
|
|
672
|
+
block ? "w-full" : "w-fit",
|
|
673
|
+
baseTransition,
|
|
674
|
+
"rounded-sm whitespace-nowrap inline-flex items-center justify-center group/btn",
|
|
675
|
+
primaryVariantStyles,
|
|
676
|
+
secondaryVariantStyles,
|
|
677
|
+
tertiaryVariantStyles,
|
|
678
|
+
primaryCriticalVariantStyles,
|
|
679
|
+
secondaryCriticalVariantStyles,
|
|
680
|
+
tertiaryCriticalVariantStyles,
|
|
681
|
+
navigationVarianStyles,
|
|
682
|
+
notNavigationVariantStyles,
|
|
683
|
+
className
|
|
684
|
+
);
|
|
685
|
+
const labelClasses = (0, import_clsx6.default)(
|
|
686
|
+
"min-h-6 flex items-center justify-center",
|
|
687
|
+
classNameLabel,
|
|
688
|
+
componentPaddingXUsingComponentGap,
|
|
689
|
+
typography.buttonLabel
|
|
690
|
+
);
|
|
691
|
+
const Element = href && !as ? "a" : as;
|
|
692
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
693
|
+
Element,
|
|
694
|
+
__spreadProps(__spreadValues({
|
|
695
|
+
id,
|
|
696
|
+
"data-testid": testid,
|
|
697
|
+
type: Element === "button" ? "button" : void 0,
|
|
698
|
+
className: buttonClasses
|
|
699
|
+
}, props), {
|
|
700
|
+
onClick: props.onClick,
|
|
701
|
+
disabled,
|
|
702
|
+
href,
|
|
703
|
+
"data-theme": variant === "navigation" ? "brand" : void 0,
|
|
704
|
+
children: [
|
|
705
|
+
leftIcon && leftIcon,
|
|
706
|
+
!iconOnly && children && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { id: id ? `${id}-label` : void 0, "data-testid": testid ? `${testid}-label` : void 0, className: labelClasses, children }),
|
|
707
|
+
rightIcon && rightIcon
|
|
708
|
+
]
|
|
709
|
+
})
|
|
710
|
+
);
|
|
711
|
+
};
|
|
712
|
+
Button.displayName = "Button";
|
|
713
|
+
|
|
714
|
+
// src/components/NestedMenu.tsx
|
|
715
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
577
716
|
function NestedMenu(props) {
|
|
578
717
|
var _a;
|
|
579
718
|
const { onMenuClick, currentMenu, testid } = props;
|
|
@@ -619,13 +758,13 @@ function NestedMenu(props) {
|
|
|
619
758
|
item && __spreadValues(__spreadValues({}, item), !isPrevious && { previousMenu: currentMenu })
|
|
620
759
|
);
|
|
621
760
|
}
|
|
622
|
-
return /* @__PURE__ */ (0,
|
|
623
|
-
/* @__PURE__ */ (0,
|
|
761
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-col w-full", children: [
|
|
762
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
624
763
|
MenuOption,
|
|
625
764
|
{
|
|
626
765
|
testid: testid ? `${testid}-back` : void 0,
|
|
627
766
|
variant: "normal",
|
|
628
|
-
before: /* @__PURE__ */ (0,
|
|
767
|
+
before: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
629
768
|
Icon,
|
|
630
769
|
{
|
|
631
770
|
name: "chevron_left",
|
|
@@ -638,10 +777,10 @@ function NestedMenu(props) {
|
|
|
638
777
|
return handleMenuClick((_a2 = currentMenu.previousMenu) != null ? _a2 : null, true);
|
|
639
778
|
},
|
|
640
779
|
selected: selectedIndex === -1,
|
|
641
|
-
children: /* @__PURE__ */ (0,
|
|
780
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Label, { color: "text-action-normal", children: currentMenu.previousMenu ? currentMenu.previousMenu.label : "Main Menu" })
|
|
642
781
|
}
|
|
643
782
|
),
|
|
644
|
-
/* @__PURE__ */ (0,
|
|
783
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
645
784
|
MenuOption,
|
|
646
785
|
{
|
|
647
786
|
variant: "action",
|
|
@@ -651,13 +790,26 @@ function NestedMenu(props) {
|
|
|
651
790
|
),
|
|
652
791
|
(currentMenu.subEntries || []).map((item, idx) => {
|
|
653
792
|
var _a2;
|
|
654
|
-
return /* @__PURE__ */ (0,
|
|
793
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
655
794
|
MenuOption,
|
|
656
795
|
{
|
|
657
796
|
testid: testid ? `${testid}-${item.label}` : void 0,
|
|
658
797
|
variant: "normal",
|
|
659
798
|
onClick: () => handleMenuClick(item),
|
|
660
|
-
after: ((_a2 = item.subEntries) == null ? void 0 : _a2.length) && /* @__PURE__ */ (0,
|
|
799
|
+
after: ((_a2 = item.subEntries) == null ? void 0 : _a2.length) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
800
|
+
Button,
|
|
801
|
+
{
|
|
802
|
+
iconOnly: true,
|
|
803
|
+
variant: "tertiary",
|
|
804
|
+
onClick: (e) => {
|
|
805
|
+
e.preventDefault();
|
|
806
|
+
e.stopPropagation();
|
|
807
|
+
onMenuClick(item, "subEntry");
|
|
808
|
+
},
|
|
809
|
+
className: "!p-0 w-full justify-end",
|
|
810
|
+
leftIcon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "chevron_right", className: "icon", size: 24 })
|
|
811
|
+
}
|
|
812
|
+
),
|
|
661
813
|
selected: selectedIndex === idx,
|
|
662
814
|
children: item.label
|
|
663
815
|
},
|
|
@@ -15,6 +15,9 @@ import "../chunk-ZSETMD4A.js";
|
|
|
15
15
|
import {
|
|
16
16
|
Icon
|
|
17
17
|
} from "../chunk-NKUETCDA.js";
|
|
18
|
+
import {
|
|
19
|
+
Button
|
|
20
|
+
} from "../chunk-LPY6PMAY.js";
|
|
18
21
|
import "../chunk-IXR65MOU.js";
|
|
19
22
|
import {
|
|
20
23
|
__spreadValues
|
|
@@ -106,7 +109,20 @@ function NestedMenu(props) {
|
|
|
106
109
|
testid: testid ? `${testid}-${item.label}` : void 0,
|
|
107
110
|
variant: "normal",
|
|
108
111
|
onClick: () => handleMenuClick(item),
|
|
109
|
-
after: ((_a2 = item.subEntries) == null ? void 0 : _a2.length) && /* @__PURE__ */ jsx(
|
|
112
|
+
after: ((_a2 = item.subEntries) == null ? void 0 : _a2.length) && /* @__PURE__ */ jsx(
|
|
113
|
+
Button,
|
|
114
|
+
{
|
|
115
|
+
iconOnly: true,
|
|
116
|
+
variant: "tertiary",
|
|
117
|
+
onClick: (e) => {
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
e.stopPropagation();
|
|
120
|
+
onMenuClick(item, "subEntry");
|
|
121
|
+
},
|
|
122
|
+
className: "!p-0 w-full justify-end",
|
|
123
|
+
leftIcon: /* @__PURE__ */ jsx(Icon, { name: "chevron_right", className: "icon", size: 24 })
|
|
124
|
+
}
|
|
125
|
+
),
|
|
110
126
|
selected: selectedIndex === idx,
|
|
111
127
|
children: item.label
|
|
112
128
|
},
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import { Icon } from "./Icon";
|
|
|
5
5
|
import { MenuOption } from "./MenuOption";
|
|
6
6
|
import { useKeydown } from "../hooks";
|
|
7
7
|
import { Label } from "./Label";
|
|
8
|
+
import { Button } from "./Button";
|
|
8
9
|
|
|
9
10
|
export type NestedMenuEntry = {
|
|
10
11
|
id: string; // Unique identifier for the nested menu entry
|
|
@@ -19,7 +20,10 @@ export type NestedMenuEntry = {
|
|
|
19
20
|
|
|
20
21
|
export type NestedMenuProps = {
|
|
21
22
|
currentMenu: NestedMenuEntry; // Current menu entry, if any
|
|
22
|
-
onMenuClick: (
|
|
23
|
+
onMenuClick: (
|
|
24
|
+
entry: NestedMenuEntry | null,
|
|
25
|
+
action?: "url" | "onClick" | "subEntry",
|
|
26
|
+
) => void; // Callback when a menu item is clicked. tailing
|
|
23
27
|
testid?: string;
|
|
24
28
|
};
|
|
25
29
|
|
|
@@ -102,7 +106,19 @@ export function NestedMenu(props: NestedMenuProps) {
|
|
|
102
106
|
onClick={() => handleMenuClick(item)}
|
|
103
107
|
after={
|
|
104
108
|
item.subEntries?.length && (
|
|
105
|
-
<
|
|
109
|
+
<Button
|
|
110
|
+
iconOnly
|
|
111
|
+
variant="tertiary"
|
|
112
|
+
onClick={(e: React.MouseEvent) => {
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
e.stopPropagation();
|
|
115
|
+
onMenuClick(item, "subEntry");
|
|
116
|
+
}}
|
|
117
|
+
className="!p-0 w-full justify-end"
|
|
118
|
+
leftIcon={
|
|
119
|
+
<Icon name="chevron_right" className="icon" size={24} />
|
|
120
|
+
}
|
|
121
|
+
/>
|
|
106
122
|
)
|
|
107
123
|
}
|
|
108
124
|
selected={selectedIndex === idx}
|