@agilant/toga-blox 1.0.36 → 1.0.38
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/components/Badge/Badge.stories.js +8 -8
- package/dist/components/Badge/Badge.test.js +8 -8
- package/dist/components/BaseButton/BaseButton.stories.js +5 -5
- package/dist/components/Card/templates/CounterContentCardTemplate.js +1 -1
- package/dist/components/Card/templates/HorizontalCardTemplate.js +2 -2
- package/dist/components/Dropdown/Dropdown.js +1 -1
- package/dist/components/Dropdown/Dropdown.types.d.ts +6 -5
- package/dist/components/InputAndCheck/InputAndCheck.js +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +22 -4
- package/dist/components/MultiSelect/MultiSelect.stories.js +5 -5
- package/dist/components/MultiSelect/MultiSelect.types.d.ts +5 -1
- package/dist/components/Nav/Nav.js +5 -2
- package/dist/components/SearchInput/SearchDropdownInput.d.ts +20 -0
- package/dist/components/SearchInput/SearchDropdownInput.js +52 -0
- package/dist/components/SearchInput/SearchInput.d.ts +1 -1
- package/dist/components/SearchInput/SearchInput.js +7 -2
- package/dist/components/SearchInput/SearchInput.stories.d.ts +2 -0
- package/dist/components/SearchInput/SearchInput.stories.js +66 -1
- package/dist/components/SearchInput/SearchInput.types.d.ts +12 -3
- package/dist/components/SearchInput/SearchNumberInput.js +1 -1
- package/dist/components/SearchInput/SearchTextInput.js +1 -1
- package/dist/components/SortArrows/SortArrows.js +1 -1
- package/dist/components/SortArrows/SortArrows.stories.js +3 -3
- package/dist/components/Toaster/Toaster.js +1 -1
- package/dist/utils/generateAccordionItem.js +1 -2
- package/dist/utils/getFontAwesomeIcon.d.ts +1 -1
- package/dist/utils/getFontAwesomeIcon.js +1 -1
- package/package.json +2 -1
|
@@ -156,8 +156,8 @@ BadgeWithLeftIcon.args = {
|
|
|
156
156
|
badgeContainerClasses: "px-3 py-1",
|
|
157
157
|
hasMobileStyle: true,
|
|
158
158
|
mobileIconLabel: "Complete",
|
|
159
|
-
mobileIcon: getFontAwesomeIcon("check"),
|
|
160
|
-
icon: getFontAwesomeIcon("check"),
|
|
159
|
+
mobileIcon: getFontAwesomeIcon("check", "regular"),
|
|
160
|
+
icon: getFontAwesomeIcon("check", "regular"),
|
|
161
161
|
hasLeftIcon: true,
|
|
162
162
|
iconSize: "text-sm",
|
|
163
163
|
text: (_jsx(Text, { color: "text-black", fontFamily: "font-serif", text: "Complete", tag: "span", size: "text-sm" })),
|
|
@@ -176,8 +176,8 @@ BadgeWithRightIcon.args = {
|
|
|
176
176
|
badgeContainerClasses: "px-3 py-1",
|
|
177
177
|
hasMobileStyle: true,
|
|
178
178
|
mobileIconLabel: "Incomplete",
|
|
179
|
-
mobileIcon: getFontAwesomeIcon("xmark"),
|
|
180
|
-
icon: getFontAwesomeIcon("xmark"),
|
|
179
|
+
mobileIcon: getFontAwesomeIcon("xmark", "regular"),
|
|
180
|
+
icon: getFontAwesomeIcon("xmark", "regular"),
|
|
181
181
|
hasRightIcon: true,
|
|
182
182
|
iconSize: "text-sm",
|
|
183
183
|
text: (_jsx(Text, { color: "text-black", fontFamily: "font-serif", text: "Incomplete", tag: "span", size: "text-sm" })),
|
|
@@ -222,8 +222,8 @@ SupplyBadge.args = {
|
|
|
222
222
|
backgroundColor: "bg-gray-300",
|
|
223
223
|
borderRadius: "rounded-full",
|
|
224
224
|
badgeContainerClasses: "px-3 py-1",
|
|
225
|
-
mobileIcon: getFontAwesomeIcon("calculator"),
|
|
226
|
-
icon: getFontAwesomeIcon("calculator"),
|
|
225
|
+
mobileIcon: getFontAwesomeIcon("calculator", "regular"),
|
|
226
|
+
icon: getFontAwesomeIcon("calculator", "regular"),
|
|
227
227
|
hasLeftIcon: true,
|
|
228
228
|
text: (_jsx(Text, { color: "text-black", fontFamily: "font-serif", text: "Closed", tag: "span", size: "text-sm" })),
|
|
229
229
|
};
|
|
@@ -239,8 +239,8 @@ StylesBadgeWithClick.args = {
|
|
|
239
239
|
backgroundColor: "bg-gray-300",
|
|
240
240
|
borderRadius: "rounded-full",
|
|
241
241
|
badgeContainerClasses: "px-3 py-1",
|
|
242
|
-
mobileIcon: getFontAwesomeIcon("calculator"),
|
|
243
|
-
icon: getFontAwesomeIcon("calculator"),
|
|
242
|
+
mobileIcon: getFontAwesomeIcon("calculator", "regular"),
|
|
243
|
+
icon: getFontAwesomeIcon("calculator", "regular"),
|
|
244
244
|
hasLeftIcon: true,
|
|
245
245
|
styles: { background: "#F8F8F9", padding: "1.5rem" },
|
|
246
246
|
onClick: () => alert("Clicked!"),
|
|
@@ -6,7 +6,7 @@ import Text from "../Text/Text";
|
|
|
6
6
|
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
7
7
|
describe("<Badge />", () => {
|
|
8
8
|
beforeEach(() => {
|
|
9
|
-
render(_jsx(Badge, { type: "span", borderColor: "border-red-500", hoverColor: "hover:bg-none", testId: "priority-badge", mobileIcon: getFontAwesomeIcon("exclamationCircle"), mobileIconLabel: "Priority", text: _jsx(Text, { size: "text-md", color: "text-black", text: "Priority", fontFamily: "font-serif", tag: "h2", additionalClasses: "font-bold" }) }));
|
|
9
|
+
render(_jsx(Badge, { type: "span", borderColor: "border-red-500", hoverColor: "hover:bg-none", testId: "priority-badge", mobileIcon: getFontAwesomeIcon("exclamationCircle", "regular"), mobileIconLabel: "Priority", text: _jsx(Text, { size: "text-md", color: "text-black", text: "Priority", fontFamily: "font-serif", tag: "h2", additionalClasses: "font-bold" }) }));
|
|
10
10
|
});
|
|
11
11
|
test("renders badge", () => {
|
|
12
12
|
const badge = screen.getByTestId("badge-test-id");
|
|
@@ -22,7 +22,7 @@ describe("<Badge />", () => {
|
|
|
22
22
|
});
|
|
23
23
|
describe("<Badge /> with icon", () => {
|
|
24
24
|
beforeEach(() => {
|
|
25
|
-
render(_jsx(Badge, { type: "span", borderColor: "border-green-500", hoverColor: "hover:bg-none", testId: "icon-badge", cursorPointer: false, icon: getFontAwesomeIcon("xmark"), mobileIcon: getFontAwesomeIcon("xmark"), mobileIconLabel: "Complete", hasLeftIcon: true, text: _jsx(Text, { size: "text-md", color: "text-black", text: "Complete", fontFamily: "font-serif", tag: "h2", additionalClasses: "font-bold" }) }));
|
|
25
|
+
render(_jsx(Badge, { type: "span", borderColor: "border-green-500", hoverColor: "hover:bg-none", testId: "icon-badge", cursorPointer: false, icon: getFontAwesomeIcon("xmark", "regular"), mobileIcon: getFontAwesomeIcon("xmark", "regular"), mobileIconLabel: "Complete", hasLeftIcon: true, text: _jsx(Text, { size: "text-md", color: "text-black", text: "Complete", fontFamily: "font-serif", tag: "h2", additionalClasses: "font-bold" }) }));
|
|
26
26
|
});
|
|
27
27
|
test("renders badge with icon", () => {
|
|
28
28
|
const badge = screen.getByTestId("badge-test-id");
|
|
@@ -38,7 +38,7 @@ describe("<Badge /> with icon", () => {
|
|
|
38
38
|
});
|
|
39
39
|
describe("<Badge /> with Image", () => {
|
|
40
40
|
beforeEach(() => {
|
|
41
|
-
render(_jsx(Badge, { type: "href", href: "#", borderColor: "border-none", hoverColor: "hover:bg-blue-500", cursorPointer: false, icon: getFontAwesomeIcon("check"), mobileIcon: getFontAwesomeIcon("check"), mobileIconLabel: "Complete", text: _jsxs(_Fragment, { children: [_jsx(Text, { size: "text-md", color: "text-black", fontFamily: "font-serif", text: "Contact Us", tag: "h2", additionalClasses: "pl-2 pb-0 font-bold" }), _jsx(Text, { size: "text-md", color: "text-black", fontFamily: "font-serif", text: "1-800-800-8000", tag: "p", additionalClasses: "pl-2 pt-0" })] }), image: _jsx("img", { src: "../../../assets/contact-image.png", alt: "test alt text", className: "flex justify-center w-12 h-12 max-md:hidden" }) }));
|
|
41
|
+
render(_jsx(Badge, { type: "href", href: "#", borderColor: "border-none", hoverColor: "hover:bg-blue-500", cursorPointer: false, icon: getFontAwesomeIcon("check", "regular"), mobileIcon: getFontAwesomeIcon("check", "regular"), mobileIconLabel: "Complete", text: _jsxs(_Fragment, { children: [_jsx(Text, { size: "text-md", color: "text-black", fontFamily: "font-serif", text: "Contact Us", tag: "h2", additionalClasses: "pl-2 pb-0 font-bold" }), _jsx(Text, { size: "text-md", color: "text-black", fontFamily: "font-serif", text: "1-800-800-8000", tag: "p", additionalClasses: "pl-2 pt-0" })] }), image: _jsx("img", { src: "../../../assets/contact-image.png", alt: "test alt text", className: "flex justify-center w-12 h-12 max-md:hidden" }) }));
|
|
42
42
|
});
|
|
43
43
|
test("has correct text", () => {
|
|
44
44
|
expect(screen.getByTestId("badge-test-id")).toHaveTextContent("Contact Us");
|
|
@@ -55,7 +55,7 @@ describe("<Badge /> with Image", () => {
|
|
|
55
55
|
});
|
|
56
56
|
describe("<Badge /> Tests for icons and images", () => {
|
|
57
57
|
test("renders with left icon only", () => {
|
|
58
|
-
render(_jsx(Badge, { icon: getFontAwesomeIcon("xmark"), hasLeftIcon: true, text: _jsx(Text, { text: "With Icon" }), type: "to" }));
|
|
58
|
+
render(_jsx(Badge, { icon: getFontAwesomeIcon("xmark", "regular"), hasLeftIcon: true, text: _jsx(Text, { text: "With Icon" }), type: "to" }));
|
|
59
59
|
const badge = screen.getByTestId("badge-test-id");
|
|
60
60
|
expect(badge).toBeInTheDocument();
|
|
61
61
|
const icon = badge.querySelector('svg[data-icon="xmark"]');
|
|
@@ -71,7 +71,7 @@ describe("<Badge /> Tests for icons and images", () => {
|
|
|
71
71
|
});
|
|
72
72
|
describe("<Badge /> tests for right badges", () => {
|
|
73
73
|
test("renders with left icon only", () => {
|
|
74
|
-
render(_jsx(Badge, { icon: getFontAwesomeIcon("xmark"), hasRightIcon: true, text: _jsx(Text, { text: "With Icon" }), type: "to" }));
|
|
74
|
+
render(_jsx(Badge, { icon: getFontAwesomeIcon("xmark", "regular"), hasRightIcon: true, text: _jsx(Text, { text: "With Icon" }), type: "to" }));
|
|
75
75
|
const badge = screen.getByTestId("badge-test-id");
|
|
76
76
|
expect(badge).toBeInTheDocument();
|
|
77
77
|
const icon = badge.querySelector('svg[data-icon="xmark"]');
|
|
@@ -80,7 +80,7 @@ describe("<Badge /> tests for right badges", () => {
|
|
|
80
80
|
});
|
|
81
81
|
describe("<Badge /> - Mobile Icon Tests", () => {
|
|
82
82
|
test("renders mobile icon when hasMobileStyle is true", () => {
|
|
83
|
-
render(_jsx(Badge, { mobileIcon: getFontAwesomeIcon("check"), hasMobileStyle: true, mobileIconLabel: "Mobile Icon Label", text: "Mobile Icon Badge", type: "span" }));
|
|
83
|
+
render(_jsx(Badge, { mobileIcon: getFontAwesomeIcon("check", "regular"), hasMobileStyle: true, mobileIconLabel: "Mobile Icon Label", text: "Mobile Icon Badge", type: "span" }));
|
|
84
84
|
const badge = screen.getByTestId("badge-test-id");
|
|
85
85
|
expect(badge).toBeInTheDocument();
|
|
86
86
|
const mobileIcon = screen.getByLabelText("Mobile Icon Label");
|
|
@@ -88,14 +88,14 @@ describe("<Badge /> - Mobile Icon Tests", () => {
|
|
|
88
88
|
expect(mobileIcon).toHaveClass("hidden max-md:flex max-md:p-0 mr-2");
|
|
89
89
|
});
|
|
90
90
|
test("does not render mobile icon when hasMobileStyle is false", () => {
|
|
91
|
-
render(_jsx(Badge, { mobileIcon: getFontAwesomeIcon("check"), hasMobileStyle: false, mobileIconLabel: "Mobile Icon Label", text: "No Mobile Style", type: "to" }));
|
|
91
|
+
render(_jsx(Badge, { mobileIcon: getFontAwesomeIcon("check", "regular"), hasMobileStyle: false, mobileIconLabel: "Mobile Icon Label", text: "No Mobile Style", type: "to" }));
|
|
92
92
|
const badge = screen.getByTestId("badge-test-id");
|
|
93
93
|
expect(badge).toBeInTheDocument();
|
|
94
94
|
const mobileIcon = screen.queryByLabelText("Mobile Icon Label");
|
|
95
95
|
expect(mobileIcon).not.toBeInTheDocument();
|
|
96
96
|
});
|
|
97
97
|
test("mobile icon has correct aria attributes", () => {
|
|
98
|
-
render(_jsx(Badge, { mobileIcon: getFontAwesomeIcon("check"), hasMobileStyle: true, mobileIconLabel: "Mobile Icon Accessibility Label", text: "Accessible Mobile Icon Badge", type: "to" }));
|
|
98
|
+
render(_jsx(Badge, { mobileIcon: getFontAwesomeIcon("check", "regular"), hasMobileStyle: true, mobileIconLabel: "Mobile Icon Accessibility Label", text: "Accessible Mobile Icon Badge", type: "to" }));
|
|
99
99
|
const mobileIcon = screen.getByLabelText("Mobile Icon Accessibility Label");
|
|
100
100
|
expect(mobileIcon).toBeInTheDocument();
|
|
101
101
|
expect(mobileIcon).toHaveAttribute("aria-hidden", "false");
|
|
@@ -138,7 +138,7 @@ export const WithIcon = Template.bind({});
|
|
|
138
138
|
WithIcon.args = {
|
|
139
139
|
...Default.args,
|
|
140
140
|
text: (_jsx(Text, { size: "", color: "", text: "Button with icon", fontFamily: "", additionalClasses: "pl-2" })),
|
|
141
|
-
icon: getFontAwesomeIcon("coffee"),
|
|
141
|
+
icon: getFontAwesomeIcon("coffee", "regular"),
|
|
142
142
|
shape: "rounded-none",
|
|
143
143
|
hoverUnderline: false,
|
|
144
144
|
onClick: () => alert("Button clicked!"),
|
|
@@ -150,7 +150,7 @@ IconOnly.args = {
|
|
|
150
150
|
shape: "rounded",
|
|
151
151
|
hoverBackground: "hover:bg-gray-100",
|
|
152
152
|
hoverUnderline: false,
|
|
153
|
-
icon: getFontAwesomeIcon("trash"),
|
|
153
|
+
icon: getFontAwesomeIcon("trash", "regular"),
|
|
154
154
|
additionalClasses: "flex justify-center items-center px-4 py-3 bg-gray-50",
|
|
155
155
|
onClick: () => alert("Icon button clicked!"),
|
|
156
156
|
};
|
|
@@ -163,7 +163,7 @@ ClearCartButton.args = {
|
|
|
163
163
|
hoverFontColor: "hover:text-black",
|
|
164
164
|
hoverBorderColor: "hover:border-red-700",
|
|
165
165
|
hoverUnderline: false,
|
|
166
|
-
icon: getFontAwesomeIcon("trash"),
|
|
166
|
+
icon: getFontAwesomeIcon("trash", "regular"),
|
|
167
167
|
iconClasses: "order-first",
|
|
168
168
|
additionalClasses: "px-5 py-6 bg-gray-50 border-red-500 gap-2",
|
|
169
169
|
onClick: () => alert("Cart Cleared!"),
|
|
@@ -177,7 +177,7 @@ RightIconButton.args = {
|
|
|
177
177
|
hoverFontColor: "hover:text-white",
|
|
178
178
|
hoverBorderColor: "hover:border-blue-700",
|
|
179
179
|
hoverUnderline: false,
|
|
180
|
-
icon: getFontAwesomeIcon("arrowRight"),
|
|
180
|
+
icon: getFontAwesomeIcon("arrowRight", "regular"),
|
|
181
181
|
additionalClasses: "px-6 py-3 flex-row-reverse",
|
|
182
182
|
iconClasses: "ml-2 text-white",
|
|
183
183
|
onClick: () => alert("Next clicked!"),
|
|
@@ -196,5 +196,5 @@ ConfirmRequestButton.args = {
|
|
|
196
196
|
export const FourButtonsRow = Template.bind({});
|
|
197
197
|
FourButtonsRow.args = {};
|
|
198
198
|
FourButtonsRow.decorators = [
|
|
199
|
-
(Story) => (_jsxs("div", { className: "flex divide-x divide-gray-200 rounded-md overflow-hidden border border-gray-200", children: [_jsx(BaseButton, { text: "All", backgroundColor: "bg-teal-600", fontFamily: "font-sans", borderColor: "border-gray-200", shape: "rounded-none", hoverUnderline: false, additionalClasses: "py-2 px-4 text-white", onClick: () => alert("All clicked!") }), _jsx(BaseButton, { text: _jsxs(_Fragment, { children: [getFontAwesomeIcon("boxes", "
|
|
199
|
+
(Story) => (_jsxs("div", { className: "flex divide-x divide-gray-200 rounded-md overflow-hidden border border-gray-200", children: [_jsx(BaseButton, { text: "All", backgroundColor: "bg-teal-600", fontFamily: "font-sans", borderColor: "border-gray-200", shape: "rounded-none", hoverUnderline: false, additionalClasses: "py-2 px-4 text-white", onClick: () => alert("All clicked!") }), _jsx(BaseButton, { text: _jsxs(_Fragment, { children: [getFontAwesomeIcon("boxes", "regular"), "Bundles"] }), backgroundColor: "bg-white", fontFamily: "font-sans", borderColor: "border-gray-200", shape: "rounded-none", hoverBackground: "hover:bg-teal-600", hoverFontColor: "hover:text-white", hoverBorderColor: "hover:border-none", hoverUnderline: false, additionalClasses: "py-2 px-4", onClick: () => alert("Bundles clicked!") }), _jsx(BaseButton, { text: _jsxs(_Fragment, { children: [getFontAwesomeIcon("clipboard", "regular"), "Categories"] }), backgroundColor: "bg-white", fontFamily: "font-sans", borderColor: "border-gray-200", shape: "rounded-none", hoverBackground: "hover:bg-teal-600", hoverFontColor: "hover:text-white", hoverBorderColor: "hover:border-none", hoverUnderline: false, additionalClasses: "py-2 px-4", onClick: () => alert("Categories clicked!") }), _jsx(BaseButton, { text: _jsxs(_Fragment, { children: [getFontAwesomeIcon("plus", "regular"), "Custom Categories"] }), backgroundColor: "bg-white", fontFamily: "font-sans", borderColor: "border-gray-200", shape: "rounded-none", hoverBackground: "hover:bg-teal-600", hoverFontColor: "hover:text-white", hoverBorderColor: "hover:border-none", hoverUnderline: false, additionalClasses: "py-2 px-4", onClick: () => alert("Custom Categories clicked!") })] })),
|
|
200
200
|
];
|
|
@@ -41,6 +41,6 @@ const CounterContentCardTemplate = ({ data }) => {
|
|
|
41
41
|
setInCart(false);
|
|
42
42
|
setCount(0);
|
|
43
43
|
};
|
|
44
|
-
return (_jsxs("div", { className: "flex flex-col items-start w-full sm:w-[300px] h-auto sm:h-[350px] border border-[#DFE4EA] bg-white rounded-lg relative p-4 sm:p-4 hover:border-teal-600 hover:shadow-inner", children: [_jsx("div", { className: "absolute top-3 left-3", children: _jsx(Badge, { text: _jsx(Text, { color: "", fontFamily: "font-serif", tag: "p", text: data.badgeText, size: "text-xs sm:text-sm" }), type: "span", hoverColor: "", backgroundColor: "bg-green-100", badgeContainerClasses: "text-green-800" }) }), _jsx("div", { className: "flex justify-center items-center mt-4 w-full", children: _jsx(Image, { background: false, src: data.imageUrl, alt: data.altText, additionalClasses: "w-[100px] sm:w-[120px] h-[100px] sm:h-[120px] object-contain" }) }), _jsxs("div", { className: "flex flex-col items-start w-full mt-4", children: [_jsx(Text, { tag: data.titleProps.tag, size: "text-md", text: truncateDescription(data.title, 52), color: data.titleProps.fontColor, fontFamily: data.titleProps.fontFamily, additionalClasses: `${data.titleProps.additionalClasses} text-left font-bold` }), _jsx(Text, { tag: "span", size: "text-xs sm:text-sm", text: data.identifier, color: "text-gray-500", fontFamily: "font-sans", additionalClasses: "text-left mt-1" }), _jsx(Text, { tag: "p", size: "text-xs sm:text-sm", text: truncateDescription(data.description, 52), color: "text-gray-700", fontFamily: "font-sans", additionalClasses: "text-left mt-2" })] }), _jsxs("div", { className: "flex justify-between items-center w-full mt-4 sm:mt-auto", children: [_jsx(Text, { tag: data.priceProps.tag, size: "text-sm sm:text-md", text: data.price, color: data.priceProps.fontColor, fontFamily: data.priceProps.fontFamily, additionalClasses: data.priceProps.additionalClasses }), _jsx("div", { className: "flex items-center gap-2 min-w-[120px] sm:min-w-[150px] justify-end", children: inCart ? (_jsxs(_Fragment, { children: [_jsx(BaseButton, { additionalClasses: "w-6 sm:w-8 h-6 sm:h-8 flex items-center justify-center text-red-600", icon: getFontAwesomeIcon("trash"), onClick: handleDeleteClick }), _jsx(CounterButton, { count: count, onIncrementClick: handleIncrementClick, onDecrementClick: handleDecrementClick, onInputChange: handleInputChange, containerClassName: "flex items-center border border-gray-300 rounded-md overflow-hidden", inputClassName: "w-8 h-8 text-center text-xs sm:text-sm border-none outline-none bg-white", buttonClassName: "w-8 h-8 flex items-center justify-center text-gray-600", iconClasses: "fill-current text-gray-600" })] })) : (_jsx(BaseButton, { text: "Add to Cart", backgroundColor: "bg-teal-600", shape: "rounded-md", borderColor: "border-none", additionalClasses: "w-[100px] sm:w-[120px] h-[32px] sm:h-[40px] hover:bg-teal-800", onClick: handleAddToCartClick })) })] })] }));
|
|
44
|
+
return (_jsxs("div", { className: "flex flex-col items-start w-full sm:w-[300px] h-auto sm:h-[350px] border border-[#DFE4EA] bg-white rounded-lg relative p-4 sm:p-4 hover:border-teal-600 hover:shadow-inner", children: [_jsx("div", { className: "absolute top-3 left-3", children: _jsx(Badge, { text: _jsx(Text, { color: "", fontFamily: "font-serif", tag: "p", text: data.badgeText, size: "text-xs sm:text-sm" }), type: "span", hoverColor: "", backgroundColor: "bg-green-100", badgeContainerClasses: "text-green-800" }) }), _jsx("div", { className: "flex justify-center items-center mt-4 w-full", children: _jsx(Image, { background: false, src: data.imageUrl, alt: data.altText, additionalClasses: "w-[100px] sm:w-[120px] h-[100px] sm:h-[120px] object-contain" }) }), _jsxs("div", { className: "flex flex-col items-start w-full mt-4", children: [_jsx(Text, { tag: data.titleProps.tag, size: "text-md", text: truncateDescription(data.title, 52), color: data.titleProps.fontColor, fontFamily: data.titleProps.fontFamily, additionalClasses: `${data.titleProps.additionalClasses} text-left font-bold` }), _jsx(Text, { tag: "span", size: "text-xs sm:text-sm", text: data.identifier, color: "text-gray-500", fontFamily: "font-sans", additionalClasses: "text-left mt-1" }), _jsx(Text, { tag: "p", size: "text-xs sm:text-sm", text: truncateDescription(data.description, 52), color: "text-gray-700", fontFamily: "font-sans", additionalClasses: "text-left mt-2" })] }), _jsxs("div", { className: "flex justify-between items-center w-full mt-4 sm:mt-auto", children: [_jsx(Text, { tag: data.priceProps.tag, size: "text-sm sm:text-md", text: data.price, color: data.priceProps.fontColor, fontFamily: data.priceProps.fontFamily, additionalClasses: data.priceProps.additionalClasses }), _jsx("div", { className: "flex items-center gap-2 min-w-[120px] sm:min-w-[150px] justify-end", children: inCart ? (_jsxs(_Fragment, { children: [_jsx(BaseButton, { additionalClasses: "w-6 sm:w-8 h-6 sm:h-8 flex items-center justify-center text-red-600", icon: getFontAwesomeIcon("trash", "solid"), onClick: handleDeleteClick }), _jsx(CounterButton, { count: count, onIncrementClick: handleIncrementClick, onDecrementClick: handleDecrementClick, onInputChange: handleInputChange, containerClassName: "flex items-center border border-gray-300 rounded-md overflow-hidden", inputClassName: "w-8 h-8 text-center text-xs sm:text-sm border-none outline-none bg-white", buttonClassName: "w-8 h-8 flex items-center justify-center text-gray-600", iconClasses: "fill-current text-gray-600" })] })) : (_jsx(BaseButton, { text: "Add to Cart", backgroundColor: "bg-teal-600", shape: "rounded-md", borderColor: "border-none", additionalClasses: "w-[100px] sm:w-[120px] h-[32px] sm:h-[40px] hover:bg-teal-800", onClick: handleAddToCartClick })) })] })] }));
|
|
45
45
|
};
|
|
46
46
|
export default CounterContentCardTemplate;
|
|
@@ -5,8 +5,8 @@ import Image from "../../Image/Image";
|
|
|
5
5
|
import { getFontAwesomeIcon } from "../../../utils/getFontAwesomeIcon";
|
|
6
6
|
const HorizontalCardTemplate = ({ data }) => {
|
|
7
7
|
return (_jsxs(_Fragment, { children: [_jsx("a", { href: "#", className: `flex justify-center w-72 max-sm:w-full`, "data-testid": "card", children: _jsx(Image, { background: false, src: data.imageUrl, alt: data.altText }) }), _jsxs("div", { className: "flex flex-col justify-between w-3/4 h-full p-3 max-sm:w-full", children: [_jsx("div", { className: "flex h-full mb-12 max-sm:mb-2", children: _jsx("a", { href: data.link, children: _jsx(Text, { tag: data.titleProps.tag, size: data.titleProps.size, text: data.title, color: "black", fontFamily: "", additionalClasses: data.titleProps.additionalClasses }) }) }), _jsxs("div", { className: `flex justify-between mb-12 max-sm:flex-col max-sm:items-end max-sm:mb-2`, children: [_jsx("div", { className: "flex items-center space-x-1 rtl:space-x-reverse max-sm:mb-1", children: _jsx(Text, { tag: data.identifierProps.tag, size: data.identifierProps.size, text: data.identifier, color: "", fontFamily: "", additionalClasses: data.identifierProps.additionalClasses }) }), _jsxs("div", { className: "flex items-center justify-center px-2 max-sm:mb-1", children: [_jsx("div", { className: "pr-2 text-xs", children: data.inStock === true
|
|
8
|
-
? getFontAwesomeIcon(data.inStockProps.inStockIcon)
|
|
9
|
-
: getFontAwesomeIcon(data.inStockProps.outOfStockIcon) }), _jsx(Text, { tag: data.inStockProps.tag, size: data.inStockProps.size, text: data.inStock === true
|
|
8
|
+
? getFontAwesomeIcon(data.inStockProps.inStockIcon, "regular")
|
|
9
|
+
: getFontAwesomeIcon(data.inStockProps.outOfStockIcon, "regular") }), _jsx(Text, { tag: data.inStockProps.tag, size: data.inStockProps.size, text: data.inStock === true
|
|
10
10
|
? "In Stock"
|
|
11
11
|
: "Out of Stock", color: "black", fontFamily: "", additionalClasses: data.inStockProps.additionalClasses })] }), _jsxs("div", { className: "flex px-2 items-center space-x-1 rtl:space-x-reverse max-sm:mb-1", children: [_jsx("svg", { className: "w-4 h-4 text-yellow-300", "aria-hidden": "true", xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 22 20", children: _jsx("path", { d: "M20.924 7.625a1.523 1.523 0 0 0-1.238-1.044l-5.051-.734-2.259-4.577a1.534 1.534 0 0 0-2.752 0L7.365 5.847l-5.051.734A1.535 1.535 0 0 0 1.463 9.2l3.656 3.563-.863 5.031a1.532 1.532 0 0 0 2.226 1.616L11 17.033l4.518 2.375a1.534 1.534 0 0 0 2.226-1.617l-.863-5.03L20.537 9.2a1.523 1.523 0 0 0 .387-1.575Z" }) }), _jsx(Text, { tag: data.ratingProps.tag, size: data.ratingProps.size, text: data.rating, color: "", fontFamily: "", additionalClasses: data.ratingProps.additionalClasses })] })] }), _jsxs("div", { className: "flex items-end flex-col w-full max-sm:flex-row max-sm:justify-between", children: [_jsx("div", { className: "px-2", children: _jsx(Text, { tag: data.priceProps.tag, size: data.priceProps.size, text: data.price, color: "black", fontFamily: "", additionalClasses: data.priceProps.additionalClasses }) }), _jsx(BaseButton, { text: data.buttonProps.text, backgroundColor: data.buttonProps.color, shape: data.buttonProps.shape, borderColor: data.buttonProps.borderColor, hoverBackground: data.buttonProps.hoverBackground, additionalClasses: "w-24" })] })] })] }));
|
|
12
12
|
};
|
|
@@ -9,7 +9,7 @@ const Dropdown = ({ options, selectedOption, onOptionSelect, optionClasses = "fl
|
|
|
9
9
|
}, selectedOptionBgColor = "bg-gray-50", optionHoverBgColor = "hover:bg-gray-50", }) => {
|
|
10
10
|
const [showMenu, setShowMenu] = useState(false);
|
|
11
11
|
const toggleMenu = () => setShowMenu(!showMenu);
|
|
12
|
-
return (_jsxs("div", { className: `flex items-center justify-between relative min-w-32 border-2 ${dropdownClasses}`, children: [_jsxs("div", { onClick: toggleMenu, className: `flex cursor-pointer items-center group h-full `, children: [_jsx("div", { className: `font-bold ${optionClasses}`, children: selectedOption }), _jsx("div", { className: `transform transition-transform duration-200 mx-1 px-1 rounded-full relative ${icon.iconClasses} ${showMenu ? "rotate-180" : "rotate-0"}`, children: _jsx("span", { children: getFontAwesomeIcon(icon.name
|
|
12
|
+
return (_jsxs("div", { className: `flex items-center justify-between relative min-w-32 border-2 ${dropdownClasses}`, children: [_jsxs("div", { onClick: toggleMenu, className: `flex cursor-pointer items-center group h-full `, children: [_jsx("div", { className: `font-bold ${optionClasses}`, children: selectedOption }), _jsx("div", { className: `transform transition-transform duration-200 mx-1 px-1 rounded-full relative ${icon.iconClasses} ${showMenu ? "rotate-180" : "rotate-0"}`, children: _jsx("span", { children: getFontAwesomeIcon(icon.name) }) })] }), showMenu && (_jsx(AnimatePresence, { children: showMenu && (_jsx(motion.div, { initial: { opacity: 0, y: -10 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -10 }, className: `absolute top-0 z-10 right-0 left-0 ${menuClasses}`, children: _jsx("ul", { children: options.map((action) => (_jsxs("li", { className: `text-left px-4 py-2 cursor-pointer border-b ${action === selectedOption
|
|
13
13
|
? `{${selectedOptionBgColor} font-semibold}`
|
|
14
14
|
: `${optionHoverBgColor} text-black`}`, onClick: () => {
|
|
15
15
|
onOptionSelect(action);
|
|
@@ -5,11 +5,12 @@ export type DropdownProps = {
|
|
|
5
5
|
optionClasses?: string;
|
|
6
6
|
menuClasses?: string;
|
|
7
7
|
dropdownClasses?: string;
|
|
8
|
-
icon?:
|
|
9
|
-
name: string;
|
|
10
|
-
weight: "solid" | "regular" | "light" | "duotone" | "brands";
|
|
11
|
-
iconClasses?: string;
|
|
12
|
-
};
|
|
8
|
+
icon?: DropdownIconProps;
|
|
13
9
|
selectedOptionBgColor?: string;
|
|
14
10
|
optionHoverBgColor?: string;
|
|
15
11
|
};
|
|
12
|
+
export type DropdownIconProps = {
|
|
13
|
+
name: string;
|
|
14
|
+
weight: "solid" | "regular" | "light" | "duotone" | "brands";
|
|
15
|
+
iconClasses?: string;
|
|
16
|
+
};
|
|
@@ -69,6 +69,6 @@ function InputAndCheck({ closeOutSearch, setResetSearch, setEditingHeader, colum
|
|
|
69
69
|
handleSubmit();
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
-
return (_jsxs("div", { ref: containerRef, className: "relative", "data-testid": "icon-search-regular", children: [_jsxs("div", { className: "flex flex-col border rounded-md shadow-md", children: [_jsx("div", { className: "flex", children: _jsx(TableHeaderInput, { hasAutoFocus: true, value: localSearchText, onKeyDown: handleKeyDown, required: false, id: "", name: "", type: "text", onChange: handleInputChange, additionalClasses: additionalInputClasses, placeholder: "Search", hasIcons: true, firstIcon: localSearchText === "" ? (_jsx("span", { className: initialIconClasses, children: getFontAwesomeIcon(initialIcon.icon
|
|
72
|
+
return (_jsxs("div", { ref: containerRef, className: "relative", "data-testid": "icon-search-regular", children: [_jsxs("div", { className: "flex flex-col border rounded-md shadow-md", children: [_jsx("div", { className: "flex", children: _jsx(TableHeaderInput, { hasAutoFocus: true, value: localSearchText, onKeyDown: handleKeyDown, required: false, id: "", name: "", type: "text", onChange: handleInputChange, additionalClasses: additionalInputClasses, placeholder: "Search", hasIcons: true, firstIcon: localSearchText === "" ? (_jsx("span", { className: initialIconClasses, children: getFontAwesomeIcon(initialIcon.icon) })) : undefined, iconPosition: "both", secondIcon: localSearchText !== "" && (_jsx("div", { className: secondIconClasses, onClick: handleClearSearch, children: getFontAwesomeIcon(cancelIcon.icon) })) }) }), localSearchText && (_jsx("div", { className: "bg-white flex flex-start px-2", children: _jsx(Badge, { text: localSearchText, type: "span", cursorPointer: true, onClick: handleClearSearch, hasRightIcon: true, backgroundColor: badgeColor, badgeContainerClasses: iconBadgeContainerClasses, icon: getFontAwesomeIcon(badgeIcon.icon) }) }))] }), localSearchText && (_jsx("div", { onClick: handleSubmit, className: searchIconClasses, children: getFontAwesomeIcon(searchIcon.icon) }))] }));
|
|
73
73
|
}
|
|
74
74
|
export default InputAndCheck;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { MultiSelect } from "react-multi-select-component";
|
|
3
|
-
|
|
3
|
+
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
4
|
+
const MultiSelectInput = ({ id, name, options = [], selectedValue = [], onChange, placeholder = {
|
|
5
|
+
text: "Select...",
|
|
6
|
+
icon: "",
|
|
7
|
+
iconStyle: "regular",
|
|
8
|
+
}, isSearchable = true, isOpen, hasSelectAll = false, disabled = false, isLoading = false, onMenuToggle, overrideStrings, className, width = "w-72", otherProps, }) => {
|
|
4
9
|
// Convert your OptionType to the shape expected by react-multi-select-component.
|
|
5
10
|
const multiSelectOptions = options.map((option) => ({
|
|
6
11
|
label: option.name,
|
|
@@ -11,6 +16,19 @@ const MultiSelectInput = ({ id, name, options = [], selectedValue = [], onChange
|
|
|
11
16
|
label: item.name,
|
|
12
17
|
value: item.value,
|
|
13
18
|
}));
|
|
19
|
+
const valueRenderer = (selected, _options) => {
|
|
20
|
+
if (!selected || selected.length === 0) {
|
|
21
|
+
return (_jsxs("span", { className: "flex items-center gap-2 text-gray-500", children: [placeholder?.icon
|
|
22
|
+
? getFontAwesomeIcon(placeholder.icon)
|
|
23
|
+
: null, placeholder?.text] }));
|
|
24
|
+
}
|
|
25
|
+
// If user selected ALL possible options, show "All items selected"
|
|
26
|
+
if (selected.length === multiSelectOptions.length) {
|
|
27
|
+
return "All items selected";
|
|
28
|
+
}
|
|
29
|
+
// Default behavior: comma-separated labels
|
|
30
|
+
return selected.map((s) => s.label).join(", ");
|
|
31
|
+
};
|
|
14
32
|
return (_jsx("div", { className: `${width}`, children: _jsx(MultiSelect, { id: id, name: name, className: className, options: multiSelectOptions, value: multiSelectValue, onChange: (selectedOptions) => {
|
|
15
33
|
// Convert back to OptionType when passing to onChange
|
|
16
34
|
const mapped = selectedOptions.map((opt) => ({
|
|
@@ -23,8 +41,8 @@ const MultiSelectInput = ({ id, name, options = [], selectedValue = [], onChange
|
|
|
23
41
|
disableSearch: !isSearchable,
|
|
24
42
|
// Additional props from react-multi-select-component
|
|
25
43
|
isOpen: isOpen, hasSelectAll: hasSelectAll, disabled: disabled, isLoading: isLoading, onMenuToggle: onMenuToggle, overrideStrings: {
|
|
26
|
-
selectSomeItems: placeholder,
|
|
44
|
+
// selectSomeItems: placeholder,
|
|
27
45
|
...overrideStrings,
|
|
28
|
-
}, labelledBy: "Select", ...otherProps }) }));
|
|
46
|
+
}, labelledBy: "Select", valueRenderer: valueRenderer, ...otherProps }) }));
|
|
29
47
|
};
|
|
30
48
|
export default MultiSelectInput;
|
|
@@ -85,7 +85,7 @@ Default.args = {
|
|
|
85
85
|
{ name: "Option 3", value: "option3" },
|
|
86
86
|
],
|
|
87
87
|
selectedValue: [],
|
|
88
|
-
placeholder: "Select options...",
|
|
88
|
+
placeholder: { text: "Select options..." },
|
|
89
89
|
isSearchable: true,
|
|
90
90
|
hasSelectAll: false,
|
|
91
91
|
disabled: false,
|
|
@@ -102,7 +102,7 @@ WithSelectAll.args = {
|
|
|
102
102
|
{ name: "Grape", value: "grape" },
|
|
103
103
|
],
|
|
104
104
|
selectedValue: [],
|
|
105
|
-
placeholder: "Select fruits...",
|
|
105
|
+
placeholder: { text: "Select fruits..." },
|
|
106
106
|
hasSelectAll: true,
|
|
107
107
|
isSearchable: true,
|
|
108
108
|
};
|
|
@@ -116,7 +116,7 @@ OpenByDefault.args = {
|
|
|
116
116
|
{ name: "Angular", value: "angular" },
|
|
117
117
|
],
|
|
118
118
|
selectedValue: [],
|
|
119
|
-
placeholder: "Pick your JS framework...",
|
|
119
|
+
placeholder: { text: "Pick your JS framework..." },
|
|
120
120
|
isOpen: true,
|
|
121
121
|
hasSelectAll: false,
|
|
122
122
|
};
|
|
@@ -130,7 +130,7 @@ Disabled.args = {
|
|
|
130
130
|
{ name: "Blue", value: "blue" },
|
|
131
131
|
],
|
|
132
132
|
selectedValue: [],
|
|
133
|
-
placeholder: "Disabled...",
|
|
133
|
+
placeholder: { text: "Disabled...", icon: "magnifyingGlass" },
|
|
134
134
|
disabled: true,
|
|
135
135
|
};
|
|
136
136
|
export const LoadingState = Template.bind({});
|
|
@@ -143,7 +143,7 @@ LoadingState.args = {
|
|
|
143
143
|
{ name: "Option C", value: "c" },
|
|
144
144
|
],
|
|
145
145
|
selectedValue: [],
|
|
146
|
-
placeholder: "Loading...",
|
|
146
|
+
placeholder: { text: "Loading..." },
|
|
147
147
|
isLoading: true,
|
|
148
148
|
};
|
|
149
149
|
export const CustomStrings = Template.bind({});
|
|
@@ -9,7 +9,11 @@ export interface MultiSelectInputProps {
|
|
|
9
9
|
options?: OptionType[];
|
|
10
10
|
selectedValue?: OptionType[];
|
|
11
11
|
onChange: (selected: OptionType[]) => void;
|
|
12
|
-
placeholder?:
|
|
12
|
+
placeholder?: {
|
|
13
|
+
text?: string;
|
|
14
|
+
icon?: string;
|
|
15
|
+
iconStyle?: string;
|
|
16
|
+
};
|
|
13
17
|
isSearchable?: boolean;
|
|
14
18
|
isOpen?: boolean;
|
|
15
19
|
hasSelectAll?: boolean;
|
|
@@ -3,7 +3,6 @@ import { useState } from "react";
|
|
|
3
3
|
import data from "./DUMMYNAVDATA.json";
|
|
4
4
|
import Image from "../Image/Image";
|
|
5
5
|
import { Accordion } from "../../utils/generateAccordionItem";
|
|
6
|
-
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
7
6
|
const DUMMYNAVDATA = data.DUMMYNAVDATA;
|
|
8
7
|
const Nav = ({ navData = DUMMYNAVDATA, navBackgroundColor = "bg-white", parentBackground = "bg-white", parentBorderColor = "border-gray-200", parentShape = "rounded-md", parentTextColor = "text-gray-800", parentTextSize = "text-base", parentHoverBackground = "hover:bg-gray-200", parentHoverFontColor = "hover:text-black", parentHoverUnderline = "hover:underline", parentHoverBorderColor = "hover:border-gray-400", submenuBackgroundColor = "bg-white", submenuTextColor = "text-gray-800", submenuTextSize = "text-sm", includeSubmenuImages = false, submenuHoverBackground = "hover:bg-gray-200", submenuHoverTextColor = "hover:text-black", submenuHoverBorderStyle = "hover:border-gray-400", submenuHoverBorderColor = "hover:border-gray-400", mobileBreakpoint = "max-xl", accordionParentStyle = "border-b border-black p-2 w-full", accordionExpandedStyle = "w-full py-3", }) => {
|
|
9
8
|
const [navExpanded, setNavExpanded] = useState(navData.reduce((acc, _, index) => ({
|
|
@@ -26,6 +25,10 @@ const Nav = ({ navData = DUMMYNAVDATA, navBackgroundColor = "bg-white", parentBa
|
|
|
26
25
|
toggleNav(index);
|
|
27
26
|
}
|
|
28
27
|
};
|
|
29
|
-
return (_jsxs("nav", { className: `flex justify-around ${navBackgroundColor}`, "data-testid": "nav", children: [_jsx("ul", { className: `flex w-full items-center ${mobileBreakpoint}:hidden`, "aria-label": "Main Menu", "data-testid": "main-menu", children: navData.map((item, index) => (_jsx("div", { className: `flex w-full justify-center`, children: item.to === "" ? (_jsxs("li", { className: `flex w-auto cursor-pointer relative`, role: "button", onClick: () => handleParentClick(index), "aria-expanded": navExpanded[index], tabIndex: 0, onKeyDown: (event) => handleKeyDown(event, index), "data-testid": "parent-menu-item", children: [_jsx("div", { className: `flex w-full items-center border-2 h-10 ${parentHoverBackground} ${parentHoverBorderColor} ${parentShape} ${parentBackground}`, "data-testid": `parent-button-${item.title}`, children:
|
|
28
|
+
return (_jsxs("nav", { className: `flex justify-around ${navBackgroundColor}`, "data-testid": "nav", children: [_jsx("ul", { className: `flex w-full items-center ${mobileBreakpoint}:hidden`, "aria-label": "Main Menu", "data-testid": "main-menu", children: navData.map((item, index) => (_jsx("div", { className: `flex w-full justify-center`, children: item.to === "" ? (_jsxs("li", { className: `flex w-auto cursor-pointer relative`, role: "button", onClick: () => handleParentClick(index), "aria-expanded": navExpanded[index], tabIndex: 0, onKeyDown: (event) => handleKeyDown(event, index), "data-testid": "parent-menu-item", children: [_jsx("div", { className: `flex w-full items-center border-2 h-10 ${parentHoverBackground} ${parentHoverBorderColor} ${parentShape} ${parentBackground}`, "data-testid": `parent-button-${item.title}`, children: _jsx("div", { className: `flex w-full p-4 justify-between items-center ${parentTextSize} ${parentTextColor} ${parentHoverFontColor} ${parentHoverUnderline}`, children: _jsx("div", { className: "px-2", children: item.title }) }) }), _jsx("div", { className: `absolute min-w-navDropDown top-16 overflow-x-scroll transition-[max-height] duration-500 ease-in-out ${submenuBackgroundColor} ${navExpanded[index]
|
|
29
|
+
? "max-h-60"
|
|
30
|
+
: "max-h-0"}`, "aria-hidden": !navExpanded[index], tabIndex: -1, children: _jsx("ul", { className: "w-full", children: item.links.map((link) => (_jsx("li", { className: `flex py-2 border-4 border-transparent w-auto align-center ${submenuBackgroundColor} ${submenuHoverBackground} ${submenuHoverBorderStyle} ${submenuHoverBorderColor} ${submenuTextSize} ${submenuTextColor}`, children: _jsxs("a", { href: link.link, className: "flex hover:underline w-full justify-start items-center pl-1", "data-testid": link.menuItem, tabIndex: navExpanded[index]
|
|
31
|
+
? 0
|
|
32
|
+
: -1, children: [includeSubmenuImages && (_jsx(Image, { src: link.src, alt: link.alt, background: false, additionalClasses: "w-12 h-12 mr-2", "data-testid": `submenu-image-${link.menuItem}` })), link.menuItem] }) }, link.menuItem))) }) })] })) : (_jsx("li", { className: "w-auto", onKeyDown: (event) => handleKeyDown(event, index), "data-testid": "parent-menu-item", children: _jsx("a", { href: item.to, className: `flex flex-col p-4 w-full border-2 relative items-center h-10 justify-center ${parentHoverBackground} ${parentHoverFontColor} ${parentHoverUnderline} ${parentBackground} ${parentBorderColor} ${parentShape} ${parentTextSize} ${parentTextColor}`, tabIndex: 0, "data-testid": `parent-link-${item.title}`, children: _jsx("div", { className: "px-2", children: item.title }) }) })) }, item.title))) }), _jsx("div", { className: `hidden w-full items-center ${mobileBreakpoint}:flex`, "data-testid": "accordion-nav", children: _jsx(Accordion, { navData: navData, accordionParentStyle: accordionParentStyle, accordionExpandedStyle: accordionExpandedStyle }) })] }));
|
|
30
33
|
};
|
|
31
34
|
export default Nav;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { OptionType } from "../MultiSelect/MultiSelect.types";
|
|
3
|
+
import "./SearchDrowpdown.scss";
|
|
4
|
+
interface SearchDropdownInputProps {
|
|
5
|
+
options?: OptionType[];
|
|
6
|
+
selectedValue?: OptionType[];
|
|
7
|
+
onChange: (selected: OptionType[]) => void;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
hasSelectAll?: boolean;
|
|
11
|
+
bgColor?: string;
|
|
12
|
+
textHighlight?: string;
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A wrapper around MultiSelectInput that appends a special "__footer__" option
|
|
17
|
+
* and uses a custom item renderer to display "Clear" and "Filter" buttons.
|
|
18
|
+
*/
|
|
19
|
+
declare const SearchDropdownInput: React.FC<SearchDropdownInputProps>;
|
|
20
|
+
export default SearchDropdownInput;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import MultiSelectInput from "../MultiSelect/MultiSelect";
|
|
3
|
+
import "./SearchDrowpdown.scss";
|
|
4
|
+
/**
|
|
5
|
+
* A wrapper around MultiSelectInput that appends a special "__footer__" option
|
|
6
|
+
* and uses a custom item renderer to display "Clear" and "Filter" buttons.
|
|
7
|
+
*/
|
|
8
|
+
const SearchDropdownInput = ({ options = [], selectedValue = [], onChange, placeholder = "Select...", disabled = false, hasSelectAll = true, bgColor, textHighlight, ...rest }) => {
|
|
9
|
+
const footerOption = [{ name: "", value: "__footer__" }];
|
|
10
|
+
const extendedOptions = [...options, ...footerOption];
|
|
11
|
+
const itemRenderer = ({ option, checked, disabled, onClick }) => {
|
|
12
|
+
// If it's our footer option, display the custom footer row
|
|
13
|
+
if (option.value === "__footer__") {
|
|
14
|
+
return (_jsxs("div", { className: "footer px-4 py-2 flex justify-between", children: [_jsx("button", { type: "button", className: `${textHighlight}`, onClick: (e) => {
|
|
15
|
+
e.stopPropagation();
|
|
16
|
+
onChange([]); // Clear all selections
|
|
17
|
+
}, children: "Clear" }), _jsx("button", { type: "button", className: `${bgColor} text-white px-3 py-1 rounded`, onClick: (e) => {
|
|
18
|
+
e.stopPropagation();
|
|
19
|
+
console.log("Filter clicked!", selectedValue);
|
|
20
|
+
// ...your custom filter logic
|
|
21
|
+
}, children: "Filter" })] }));
|
|
22
|
+
}
|
|
23
|
+
else if (option.label === "Select All") {
|
|
24
|
+
return (_jsxs("label", { className: "select-all-item", style: {
|
|
25
|
+
display: "flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
padding: "0.5rem 1rem",
|
|
28
|
+
position: "sticky",
|
|
29
|
+
top: 0,
|
|
30
|
+
borderBottom: "1px solid #ccc",
|
|
31
|
+
zIndex: 10,
|
|
32
|
+
}, onClick: (e) => {
|
|
33
|
+
e.stopPropagation();
|
|
34
|
+
onClick(e); // Let the library handle toggling
|
|
35
|
+
}, children: [_jsx("input", { type: "checkbox", checked: checked, readOnly: true, disabled: disabled }), _jsx("span", { style: { marginLeft: "0.5rem" }, children: option.label })] }));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return (_jsxs("div", { className: "item px-4 py-1 cursor-pointer flex items-center", onClick: (e) => onClick(option, e), children: [_jsx("input", { type: "checkbox", checked: checked, readOnly: true, disabled: disabled }), _jsx("span", { className: "ml-2", children: option.label })] }));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return (_jsx(MultiSelectInput, { options: extendedOptions, selectedValue: selectedValue, onChange: onChange, placeholder: {
|
|
42
|
+
text: placeholder,
|
|
43
|
+
icon: "magnifyingGlass",
|
|
44
|
+
iconStyle: "regular",
|
|
45
|
+
}, disabled: disabled, hasSelectAll: hasSelectAll,
|
|
46
|
+
/** Provide the custom item renderer and any additional props via otherProps */
|
|
47
|
+
otherProps: {
|
|
48
|
+
ItemRenderer: itemRenderer,
|
|
49
|
+
...rest.otherProps,
|
|
50
|
+
}, ...rest }));
|
|
51
|
+
};
|
|
52
|
+
export default SearchDropdownInput;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SearchInputProps } from "./SearchInput.types";
|
|
2
|
-
declare const SearchInput: <T extends object>({ closeOutSearch, setResetSearch, setEditingHeader,
|
|
2
|
+
declare const SearchInput: <T extends object>({ closeOutSearch, setResetSearch, setEditingHeader, bgColor, textHighlight, column, inputType, dropdownIconProp, dropdownOptions, selectedDropdownOption, onDropdownOptionSelect, searchItems, setSearchItems, toggleStatus, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, control, valueKey, dynamicDefaultValue, onChange, selectedValue, }: SearchInputProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default SearchInput;
|
|
@@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from "react";
|
|
|
3
3
|
import SearchTextInput from "./SearchTextInput";
|
|
4
4
|
import SearchNumberInput from "./SearchNumberInput";
|
|
5
5
|
import { Controller } from "react-hook-form";
|
|
6
|
+
import SearchDropdownInput from "./SearchDropdownInput";
|
|
6
7
|
// A simple helper function for default values
|
|
7
8
|
function getDefaultValue(dynamicDefaultValue, valueKey) {
|
|
8
9
|
if (typeof dynamicDefaultValue !== "undefined") {
|
|
@@ -10,11 +11,11 @@ function getDefaultValue(dynamicDefaultValue, valueKey) {
|
|
|
10
11
|
}
|
|
11
12
|
return "";
|
|
12
13
|
}
|
|
13
|
-
const SearchInput = ({ closeOutSearch, setResetSearch, setEditingHeader,
|
|
14
|
+
const SearchInput = ({ closeOutSearch, setResetSearch, setEditingHeader, bgColor = "bg-sky-500", textHighlight = "text-sky-500", column, inputType = "text", dropdownIconProp = {
|
|
14
15
|
name: "chevronDown",
|
|
15
16
|
weight: "bold",
|
|
16
17
|
iconClasses: "text-black",
|
|
17
|
-
}, dropdownOptions = [], selectedDropdownOption = "", onDropdownOptionSelect, searchItems = [], setSearchItems, toggleStatus = false, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, control, valueKey, dynamicDefaultValue, }) => {
|
|
18
|
+
}, dropdownOptions = [], selectedDropdownOption = "", onDropdownOptionSelect, searchItems = [], setSearchItems, toggleStatus = false, setToggleStatus, minValue, setMinValue, maxValue, setMaxValue, control, valueKey, dynamicDefaultValue, onChange, selectedValue, }) => {
|
|
18
19
|
const containerRef = useRef(null);
|
|
19
20
|
const [localSearchText, setLocalSearchText] = useState("");
|
|
20
21
|
const inputRef = useRef(null);
|
|
@@ -48,6 +49,10 @@ const SearchInput = ({ closeOutSearch, setResetSearch, setEditingHeader, pillCol
|
|
|
48
49
|
case "number":
|
|
49
50
|
return (_jsx(SearchNumberInput, { closeOutSearch: () => { }, setResetSearch: () => { }, setEditingHeader: () => { }, column: undefined, dropdownIconProp: dropdownIconProp, dropdownOptions: dropdownOptions, selectedDropdownOption: selectedDropdownOption, onDropdownOptionSelect: onDropdownOptionSelect, toggleStatus: toggleStatus, setToggleStatus: setToggleStatus, minValue: minValue, maxValue: maxValue, setMinValue: setMinValue, setMaxValue: setMaxValue }));
|
|
50
51
|
case "multiSelect":
|
|
52
|
+
{
|
|
53
|
+
console.log(dropdownOptions, "dropdownOptions");
|
|
54
|
+
}
|
|
55
|
+
return (_jsx(SearchDropdownInput, { options: dropdownOptions, isSearchable: true, placeholder: "Search", isMulti: true, hideSelectedOptions: true, closeMenuOnSelect: false, inputWidth: "w-full", inputTextSize: "text-sm", additionalClasses: "", customClassNames: {}, onChange: onChange, value: [], selectedValue: selectedValue, bgColor: bgColor, textHighlight: textHighlight }));
|
|
51
56
|
case "boolean":
|
|
52
57
|
case "date":
|
|
53
58
|
// Make sure control & valueKey exist before using them
|
|
@@ -33,6 +33,14 @@ export default {
|
|
|
33
33
|
action: "selected",
|
|
34
34
|
description: "Callback when dropdown option is selected",
|
|
35
35
|
},
|
|
36
|
+
searchItems: {
|
|
37
|
+
control: "array",
|
|
38
|
+
description: "Array of search items",
|
|
39
|
+
},
|
|
40
|
+
selectedValue: {
|
|
41
|
+
control: "array",
|
|
42
|
+
description: "Array of selected values",
|
|
43
|
+
},
|
|
36
44
|
},
|
|
37
45
|
parameters: { layout: "centered" },
|
|
38
46
|
};
|
|
@@ -47,7 +55,15 @@ const Template = (args) => {
|
|
|
47
55
|
const [toggleStatus, setToggleStatus] = useState(false);
|
|
48
56
|
const [minValue, setMinValue] = useState();
|
|
49
57
|
const [maxValue, setMaxValue] = useState();
|
|
50
|
-
|
|
58
|
+
const [selectedValue, setSelectedValue] = useState(args.selectedValue || []);
|
|
59
|
+
// Handle onChange from the multi-select
|
|
60
|
+
const handleOnChange = (newSelected) => {
|
|
61
|
+
setSelectedValue(newSelected);
|
|
62
|
+
// Call the original onChange if provided in the story args
|
|
63
|
+
args.onChange?.(newSelected);
|
|
64
|
+
console.log("Selected items:", newSelected);
|
|
65
|
+
};
|
|
66
|
+
return (_jsx(SearchInput, { ...args, selectedDropdownOption: selectedOption, onDropdownOptionSelect: (option) => setSelectedOption(option), searchItems: searchItems, setSearchItems: setSearchItems, toggleStatus: toggleStatus, setToggleStatus: setToggleStatus, minValue: minValue, maxValue: maxValue, setMinValue: setMinValue, setMaxValue: setMaxValue, onChange: handleOnChange, selectedValue: selectedValue }));
|
|
51
67
|
};
|
|
52
68
|
export const Default = Template.bind({});
|
|
53
69
|
Default.args = {
|
|
@@ -95,6 +111,55 @@ NumberInput.args = {
|
|
|
95
111
|
dropdownOptions: ["Exactly", "Less Than", "Greater Than"],
|
|
96
112
|
selectedDropdownOption: "Exactly",
|
|
97
113
|
};
|
|
114
|
+
export const DropdownInput = Template.bind({});
|
|
115
|
+
DropdownInput.args = {
|
|
116
|
+
inputType: "multiSelect",
|
|
117
|
+
column: mockColumn,
|
|
118
|
+
closeOutSearch: (value) => console.log(`Search cleared: ${value}`),
|
|
119
|
+
setResetSearch: () => console.log("Reset search triggered"),
|
|
120
|
+
setEditingHeader: (value) => console.log(`Editing header: ${value}`),
|
|
121
|
+
placeholder: "Search",
|
|
122
|
+
dropdownOptions: [
|
|
123
|
+
{ uuid: "1", name: "Option 1", value: "option1" },
|
|
124
|
+
{ uuid: "2", name: "Option 2", value: "option2" },
|
|
125
|
+
{ uuid: "3", name: "Option 3", value: "option3" },
|
|
126
|
+
],
|
|
127
|
+
/** For multi-select, `value` is typically an array */
|
|
128
|
+
selectedValue: [],
|
|
129
|
+
// onChange: (selected: OptionType[]) => {
|
|
130
|
+
// console.log("Selected items:", selected);
|
|
131
|
+
// },
|
|
132
|
+
/** Additional props you might want to set */
|
|
133
|
+
isSearchable: true,
|
|
134
|
+
hasSelectAll: true,
|
|
135
|
+
disabled: false,
|
|
136
|
+
isLoading: false,
|
|
137
|
+
type: "multiSelect",
|
|
138
|
+
// etc...
|
|
139
|
+
};
|
|
140
|
+
export const BooleanInput = Template.bind({});
|
|
141
|
+
BooleanInput.args = {
|
|
142
|
+
inputType: "multiSelect",
|
|
143
|
+
column: mockColumn,
|
|
144
|
+
closeOutSearch: (value) => console.log(`Search cleared: ${value}`),
|
|
145
|
+
setResetSearch: () => console.log("Reset search triggered"),
|
|
146
|
+
setEditingHeader: (value) => console.log(`Editing header: ${value}`),
|
|
147
|
+
placeholder: "Search",
|
|
148
|
+
dropdownOptions: [
|
|
149
|
+
{ uuid: "1", name: "True", value: "true" },
|
|
150
|
+
{ uuid: "2", name: "False", value: "false" },
|
|
151
|
+
],
|
|
152
|
+
selectedValue: [],
|
|
153
|
+
// onChange: (selected: OptionType[]) => {
|
|
154
|
+
// console.log("Selected items:", selected);
|
|
155
|
+
// },
|
|
156
|
+
isSearchable: true,
|
|
157
|
+
hasSelectAll: true,
|
|
158
|
+
disabled: false,
|
|
159
|
+
isLoading: false,
|
|
160
|
+
type: "multiSelect",
|
|
161
|
+
// etc...
|
|
162
|
+
};
|
|
98
163
|
export const DisabledInput = Template.bind({});
|
|
99
164
|
DisabledInput.args = {
|
|
100
165
|
inputType: "text",
|
|
@@ -5,17 +5,20 @@ type ColumnWithAccessor<T extends object> = ColumnInstance<T> & {
|
|
|
5
5
|
accessor?: string | number | symbol | Accessor<T>;
|
|
6
6
|
};
|
|
7
7
|
export type SearchInputProps<T extends object> = {
|
|
8
|
+
onChange(newSelected: OptionType[]): unknown;
|
|
9
|
+
selectedValue: any[];
|
|
10
|
+
value: any[];
|
|
8
11
|
closeOutSearch: (value: number | null) => void;
|
|
9
12
|
setResetSearch: React.Dispatch<React.SetStateAction<boolean>>;
|
|
10
13
|
columHeader?: any;
|
|
11
14
|
column: ColumnWithAccessor<T>;
|
|
12
15
|
parentIndex?: number;
|
|
13
16
|
setEditingHeader: (value: number | null) => void;
|
|
14
|
-
|
|
17
|
+
bgColor?: string;
|
|
15
18
|
textHighlight?: string;
|
|
16
19
|
inputType?: string;
|
|
17
|
-
dropdownOptions?: string[];
|
|
18
|
-
selectedDropdownOption?: string;
|
|
20
|
+
dropdownOptions?: string[] | OptionType[] | number[];
|
|
21
|
+
selectedDropdownOption?: string | OptionType | number;
|
|
19
22
|
onDropdownOptionSelect?: (option: string) => void;
|
|
20
23
|
dropdownIconProp?: searchDropdownIconProps;
|
|
21
24
|
searchItems?: string[] | number[];
|
|
@@ -30,6 +33,12 @@ export type SearchInputProps<T extends object> = {
|
|
|
30
33
|
valueKey?: string;
|
|
31
34
|
dynamicDefaultValue?: any;
|
|
32
35
|
};
|
|
36
|
+
export interface OptionType {
|
|
37
|
+
uuid: string;
|
|
38
|
+
name: string;
|
|
39
|
+
value: string;
|
|
40
|
+
label: string;
|
|
41
|
+
}
|
|
33
42
|
export type searchDropdownIconProps = {
|
|
34
43
|
name: string;
|
|
35
44
|
weight: string;
|
|
@@ -53,7 +53,7 @@ const SearchNumberInput = ({ closeOutSearch, setResetSearch, setEditingHeader, t
|
|
|
53
53
|
handleSubmitClick();
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
return (_jsx("div", { ref: containerRef, className: "", children: _jsxs("div", { className: `flex flex-col p-4
|
|
56
|
+
return (_jsx("div", { ref: containerRef, className: "w-[425px]", children: _jsxs("div", { className: `flex flex-col p-4 h-[130px] border-2 border-navy-200 rounded-md`, children: [_jsx("div", { className: `flex flex-[1] ${toggleStatus ? "" : "border-2"} h-full max-h-11 items-center justify-around`, children: toggleStatus ? (_jsxs(_Fragment, { children: [_jsx(Input, { focusRingColor: "focus:ring-2", hasAutoFocus: true, value: minValue, iconColor: "text-navy-400", onKeyDown: handleKeyDown, required: false, id: "", name: "", type: "number", onChange: handleInputChange, additionalClasses: "min-w-[180px] max-w-[180px] h-10 text-gray flex border-2 focus:border-transparent ", placeholder: "Min" }), _jsx(Text, { size: "text-md", tag: "span", text: "to", additionalClasses: "px-2" }), _jsx(Input, { focusRingColor: "focus:ring-2", value: maxValue, iconColor: "text-navy-400", onKeyDown: handleKeyDown, required: false, id: "", name: "", type: "number", onChange: handleMaximumInputChange, additionalClasses: "min-w-[180px] max-w-[180px] h-10 text-gray flex border-2 focus:border-transparent ", placeholder: "Max", hasIcons: true, iconPosition: "both" })] })) : (_jsxs(_Fragment, { children: [_jsx(Dropdown, { options: dropdownOptions, selectedOption: selectedDropdownOption, onOptionSelect: onDropdownOptionSelect, optionClasses: "px-4 h-full flex items-center", menuClasses: "bg-white w-min-[150px] top-[-8px] left-[-2px]", dropdownClasses: "border-0 border-r-2 w-auto", icon: dropdownIconProp }), _jsx(Input, { focusRingColor: "focus:ring-transparent", hasAutoFocus: true, value: minValue, iconColor: "text-navy-400", onKeyDown: handleKeyDown, required: false, id: "", name: "", type: "number", onChange: handleInputChange, additionalClasses: "min-w-[200px] h-10 text-gray flex ", placeholder: "Amount", hasIcons: true, iconPosition: "both" })] })) }), _jsxs("div", { className: "flex flex-[1] justify-between items-end bg-white px-2 rounded-md ", children: [_jsx(ToggleButton, { initialStatus: toggleStatus, onClick: () => {
|
|
57
57
|
setToggleStatus(!toggleStatus);
|
|
58
58
|
}, activeColorBackground: "bg-sky-500", activeColorBorder: "border-sky-500", activeLabel: "Range", activeTextColor: "text-sky-500", additionalClasses: "flex items-center", inactiveColorBackground: "bg-gray-300", inactiveColorBorder: "border-gray-300", inactiveLabel: "Range", inactiveTextColor: "text-gray-500", pillHeight: "h-8", textPosition: "right", textSize: "text-sm", smallToggle: false, borderStyle: false }), _jsx(BaseButton, { text: "Filter", backgroundColor: "bg-sky-500", additionalClasses: "py-1.5 px-6 text-white", borderColor: "border-none", onClick: handleSubmitClick, shape: "rounded-full" })] })] }) }));
|
|
59
59
|
};
|
|
@@ -54,7 +54,7 @@ const SearchTextInput = ({ closeOutSearch, setResetSearch, setEditingHeader, pil
|
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
const pillClassnames = `${pillColor} p-1 max-w-fit min-w-20 rounded-full flex justify-between items-center text-white text-xs px-4 border-none mr-4`;
|
|
57
|
-
return (_jsx("div", { ref: containerRef, className: "", children: _jsxs("div", { className: "flex flex-col border-2 border-navy-200 rounded-md", children: [_jsxs("div", { className: `flex ${searchItems.length ? "border-b-2" : ""} h-full`, children: [_jsx(Dropdown, { options: dropdownOptions, selectedOption: selectedDropdownOption, onOptionSelect: onDropdownOptionSelect, optionClasses: "px-4 py-1 h-full flex items-center", menuClasses: "bg-white min-w-32", icon: dropdownIconProp, dropdownClasses: "border-0 border-r-2" }), _jsx(Input, { focusRingColor: "focus:ring-transparent", hasAutoFocus: true, value: localSearchText, iconColor: "text-navy-400", onKeyDown: handleKeyDown, required: false, id: "", name: "", type: "text", onChange: handleInputChange, additionalClasses: "min-w-[250px]
|
|
57
|
+
return (_jsx("div", { ref: containerRef, className: "w-[425px]", children: _jsxs("div", { className: "flex flex-col border-2 border-navy-200 rounded-md", children: [_jsxs("div", { className: `flex ${searchItems.length ? "border-b-2" : ""} h-full`, children: [_jsx(Dropdown, { options: dropdownOptions, selectedOption: selectedDropdownOption, onOptionSelect: onDropdownOptionSelect, optionClasses: "px-4 py-1 h-full flex items-center", menuClasses: "bg-white min-w-32", icon: dropdownIconProp, dropdownClasses: "border-0 border-r-2 w-auto" }), _jsx(Input, { focusRingColor: "focus:ring-transparent", hasAutoFocus: true, value: localSearchText, iconColor: "text-navy-400", onKeyDown: handleKeyDown, required: false, id: "", name: "", type: "text", onChange: handleInputChange, additionalClasses: " min-w-[250px] min-h-full text-gray flex", placeholder: "Search", hasIcons: true, firstIcon: localSearchText === "" ? (_jsx(AnimatePresence, { children: _jsx(motion.div, { initial: "initial", animate: "animate", exit: "exit", className: "text-navy-400", children: getFontAwesomeIcon("search", "regular") }) })) : undefined, iconPosition: "both", secondIcon: _jsx("div", { className: "border-transparent text-white min-w-9", children: _jsx(AnimatePresence, { children: localSearchText !== "" && (_jsxs(motion.div, { className: "flex justify-between items-center min-w-4 text-navy-400 hover:cursor-pointer hover:text-primary", initial: "initial", animate: "animate", exit: "exit", children: [_jsx("div", { className: "bg-navy-50 pr-2 pl-1 text-gray-500", onClick: () => {
|
|
58
58
|
setLocalSearchText("");
|
|
59
59
|
}, children: getFontAwesomeIcon("xmark", "regular") }), _jsx("div", { className: `${textHighlight} text-sm hover:text-primary`, children: getFontAwesomeIcon("search", "solid") })] })) }) }), onIconClick: () => {
|
|
60
60
|
setLocalSearchText("");
|
|
@@ -26,7 +26,7 @@ const SortArrows = ({ column, setSortColumn, slug, isNested, parentIndex, onSort
|
|
|
26
26
|
setShowArrowContainer(false);
|
|
27
27
|
onRequestClose?.();
|
|
28
28
|
};
|
|
29
|
-
return (_jsxs("div", { "data-testid": `sort-arrows-${slug}`, ref: containerRef, className: arrowContainerClassNames, onClick: handleParentClick, children: [isActive && (_jsxs("div", { className: `${counterIcon.iconClassNames} ${activeDirection === "desc" ? "rotate-180" : ""}`, children:
|
|
29
|
+
return (_jsxs("div", { "data-testid": `sort-arrows-${slug}`, ref: containerRef, className: arrowContainerClassNames, onClick: handleParentClick, children: [isActive && (_jsxs("div", { className: "relative", children: [_jsx("div", { className: `${counterIcon.iconClassNames} ${activeDirection === "desc" ? "rotate-180" : ""}`, children: _jsx("span", { className: `${counterIcon?.numberSize}`, children: getFontAwesomeIcon(counterIcon.icon, counterIcon.weight) }) }), _jsx("span", { className: `${counterIcon.numberClassNames}`, children: sortOrderNumber })] })), !isActive && (_jsxs(_Fragment, { children: [_jsx(SortArrowIcon, { slug: slug, parentIndex: parentIndex, columnName: String(column.render("Header")), direction: "up", setColumn: () => { }, isActive: false }), _jsx(SortArrowIcon, { slug: slug, parentIndex: parentIndex, columnName: String(column.render("Header")), direction: "down", setColumn: () => { }, isActive: false })] })), showArrowContainer && (_jsxs(motion.div, { className: `z-[9989] bg-white rounded flex flex-col border-1 absolute top-6 w-32 ${column.id === "col1" ? "left-[5px]" : ""}`, initial: "initial", animate: "animate", exit: "exit", children: [activeDirection !== "asc" && (_jsxs("div", { className: "flex border-b-1 p-1 hover:bg-blue-50", onClick: () => handleClick("up"), children: [_jsx("span", { className: "pl-1 text-primary", children: getFontAwesomeIcon("arrowUp", "regular") }), _jsx("span", { className: "flex-1 text-left pl-4", children: "Ascending" })] })), activeDirection !== "desc" && (_jsxs("div", { className: "flex p-1 hover:bg-blue-50 border-b-1", onClick: () => handleClick("down"), children: [_jsx("span", { className: "pl-1 text-primary", children: getFontAwesomeIcon("arrowDown", "regular") }), _jsx("span", { className: "flex-1 text-left pl-4", children: "Descending" })] })), isActive && (_jsxs("div", { className: "flex border-b-1 p-1 hover:bg-blue-50", onClick: handleResetSort, children: [_jsx("span", { className: "pl-1 text-primary", children: getFontAwesomeIcon("rotateLeft", "solid") }), _jsx("span", { className: "flex-1 text-left pl-3", children: "Reset" })] }))] })), showArrowContainer &&
|
|
30
30
|
renderPortalOverlay &&
|
|
31
31
|
renderPortalOverlay(handleClose)] }));
|
|
32
32
|
};
|
|
@@ -33,9 +33,9 @@ export const WithOverlayAndIndexCount = {
|
|
|
33
33
|
return (_jsx("div", { className: "size-96", children: _jsx(SortArrows, { counterIcon: {
|
|
34
34
|
icon: "triangle",
|
|
35
35
|
weight: "solid",
|
|
36
|
-
numberClassNames: "
|
|
37
|
-
iconClassNames: "text-
|
|
38
|
-
numberSize: "text-
|
|
36
|
+
numberClassNames: " absolute bottom-1.5 left-[10px] text-xs",
|
|
37
|
+
iconClassNames: "text-green-500 hover:text-red-400 text-2xl",
|
|
38
|
+
numberSize: " text-red-500 top-0",
|
|
39
39
|
}, column: column, setSortColumn: setSortColumn, slug: "products", renderPortalOverlay: (onClose) => (_jsx("div", { className: "absolute top-0 left-0 w-[300px] h-[300px] bg-black bg-opacity-50 flex items-center justify-center", onClick: onClose })) }) }));
|
|
40
40
|
},
|
|
41
41
|
};
|
|
@@ -14,7 +14,7 @@ const Toaster = ({ message, additionalClasses, clearMessage, hasClearButton, clo
|
|
|
14
14
|
const shadowClasses = `shadow-lg shadow-boxShadow`;
|
|
15
15
|
const closeButtonClasses = `cursor-pointer text-xs ${closeIconColor}`;
|
|
16
16
|
return (_jsx("div", { "data-testid": "toaster-test-id", role: "alert", "aria-live": "polite", className: `${shadowClasses} ${containerClasses} ${additionalClasses}`, children: message.map((msg, index) => (_jsxs("div", { className: "flex items-center p-2", children: [_jsx("div", { className: `w-6 flex-none mr-2 ${iconColor} `, children: index === 0 && maybeIcon
|
|
17
|
-
? getFontAwesomeIcon(maybeIcon.icon
|
|
17
|
+
? getFontAwesomeIcon(maybeIcon.icon)
|
|
18
18
|
: null }), _jsx("div", { className: "flex-grow", children: _jsx("p", { className: index === 0 && "font-semibold", children: msg }) }), _jsx("div", { className: "w-6 flex justify-end", children: index === 0 && hasClearButton && (_jsx("div", { "data-testid": "clear-button", className: closeButtonClasses, onClick: handleClearMessage, children: getFontAwesomeIcon("x", "solid") })) })] }, index))) }));
|
|
19
19
|
};
|
|
20
20
|
export default Toaster;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment, useState } from "react";
|
|
3
|
-
import { getFontAwesomeIcon } from "./getFontAwesomeIcon";
|
|
4
3
|
export const Accordion = ({ navData, accordionParentStyle, accordionExpandedStyle, }) => {
|
|
5
4
|
// setting state to be an object, with each key being the index of the accordion item ->
|
|
6
5
|
// allows for multiple accordions to be open at once
|
|
@@ -18,5 +17,5 @@ export const Accordion = ({ navData, accordionParentStyle, accordionExpandedStyl
|
|
|
18
17
|
toggleAccordion(index);
|
|
19
18
|
}
|
|
20
19
|
};
|
|
21
|
-
return (_jsx(_Fragment, { children: navData.map((item, index) => (_jsxs(Fragment, { children: [_jsx("div", { className: `cursor-pointer ${accordionParentStyle}`, role: "button", onClick: () => toggleAccordion(index), "aria-expanded": accordionExpanded[index], tabIndex: 0, onKeyDown: (event) => handleKeyDown(event, index), children: _jsxs("div", { className: "px-6 text-left items-center h-10 select-none flex justify-between flex-row", children: [_jsx("div", { className: "flex w-3/4", children: item.title }), _jsx("div", { className: "flex w-1/2 justify-end"
|
|
20
|
+
return (_jsx(_Fragment, { children: navData.map((item, index) => (_jsxs(Fragment, { children: [_jsx("div", { className: `cursor-pointer ${accordionParentStyle}`, role: "button", onClick: () => toggleAccordion(index), "aria-expanded": accordionExpanded[index], tabIndex: 0, onKeyDown: (event) => handleKeyDown(event, index), children: _jsxs("div", { className: "px-6 text-left items-center h-10 select-none flex justify-between flex-row", children: [_jsx("div", { className: "flex w-3/4", children: item.title }), _jsx("div", { className: "flex w-1/2 justify-end" })] }) }), _jsx("div", { className: `px-6 w-full overflow-hidden transition-[max-height] duration-500 ease-in-out ${accordionExpanded[index] ? "max-h-96" : "max-h-0"}`, "aria-hidden": !accordionExpanded[index], tabIndex: accordionExpanded[index] ? 0 : -1, children: _jsx("ul", { className: `${accordionExpandedStyle}`, children: item.links.map((link) => (_jsx("li", { className: "py-1", children: _jsx("a", { href: link.link, className: "hover:underline", "data-testid": link.menuItem, children: link.menuItem }) }, link.menuItem))) }) })] }, item.title))) }));
|
|
22
21
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const getFontAwesomeIcon: (iconName: string, iconStyle
|
|
2
|
+
export declare const getFontAwesomeIcon: (iconName: string, iconStyle?: "solid" | "regular" | "light" | undefined) => React.ReactElement | null;
|
|
@@ -3,7 +3,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
|
3
3
|
import * as SolidIcons from "@fortawesome/pro-solid-svg-icons";
|
|
4
4
|
import * as RegularIcons from "@fortawesome/pro-regular-svg-icons";
|
|
5
5
|
import * as LightIcons from "@fortawesome/pro-light-svg-icons";
|
|
6
|
-
export const getFontAwesomeIcon = (iconName, iconStyle) => {
|
|
6
|
+
export const getFontAwesomeIcon = (iconName, iconStyle = "solid") => {
|
|
7
7
|
try {
|
|
8
8
|
const iconKey = `fa${iconName.charAt(0).toUpperCase()}${iconName.slice(1)}`;
|
|
9
9
|
let icon;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agilant/toga-blox",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.38",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"react-select": "^5.10.0",
|
|
41
41
|
"react-table": "^7.8.0",
|
|
42
42
|
"react-table-sticky": "^1.1.3",
|
|
43
|
+
"sass": "^1.83.4",
|
|
43
44
|
"storybook-addon-react-router-v6": "^2.0.15",
|
|
44
45
|
"tslib": "^2.3.0"
|
|
45
46
|
},
|