@agilant/toga-blox 1.0.35 → 1.0.36
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SortArrowsProps } from "./types";
|
|
2
|
-
declare const SortArrows: <T extends object>({ column, setSortColumn, slug, isNested, parentIndex, onSortChange, renderPortalOverlay, onRequestClose, counterIcon,
|
|
2
|
+
declare const SortArrows: <T extends object>({ column, setSortColumn, slug, isNested, parentIndex, onSortChange, renderPortalOverlay, onRequestClose, counterIcon, }: SortArrowsProps<T> & {
|
|
3
3
|
getFontAwesomeIconFn?: (iconName: string, iconStyle: string) => React.ReactElement | null;
|
|
4
4
|
}) => JSX.Element | null;
|
|
5
5
|
export default SortArrows;
|
|
@@ -2,17 +2,15 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { useRef } from "react";
|
|
3
3
|
import { motion } from "framer-motion";
|
|
4
4
|
import { useSortArrowsViewModel } from "./useSortArrowsViewModel";
|
|
5
|
-
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
6
5
|
import SortArrowIcon from "../SortArrowIcon";
|
|
6
|
+
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
7
7
|
const SortArrows = ({ column, setSortColumn, slug, isNested, parentIndex, onSortChange, renderPortalOverlay, onRequestClose, counterIcon = {
|
|
8
|
-
icon: "
|
|
8
|
+
icon: "triangle",
|
|
9
9
|
weight: "solid",
|
|
10
10
|
numberClassNames: "absolute text-xs top-1.5 right-0 left-0",
|
|
11
11
|
iconClassNames: "text-lg text-blue-400 relative hover:text-red-400",
|
|
12
12
|
numberSize: "text-xl",
|
|
13
|
-
},
|
|
14
|
-
// New optional prop for icon rendering; defaults to the local getFontAwesomeIcon.
|
|
15
|
-
getFontAwesomeIconFn = getFontAwesomeIcon, }) => {
|
|
13
|
+
}, }) => {
|
|
16
14
|
const containerRef = useRef(null);
|
|
17
15
|
const { showArrowContainer, handleParentClick, handleResetSort, handleClick, isActive, activeDirection, sortOrderNumber, setShowArrowContainer, } = useSortArrowsViewModel({
|
|
18
16
|
columnId: String(column.accessor),
|
|
@@ -28,7 +26,7 @@ getFontAwesomeIconFn = getFontAwesomeIcon, }) => {
|
|
|
28
26
|
setShowArrowContainer(false);
|
|
29
27
|
onRequestClose?.();
|
|
30
28
|
};
|
|
31
|
-
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: [_jsx("span", { className: `${counterIcon?.numberSize}`, children:
|
|
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: [_jsx("span", { className: `${counterIcon?.numberSize}`, children: getFontAwesomeIcon(counterIcon.icon, counterIcon.weight) }), _jsx("div", { className: `${activeDirection === "desc" ? "rotate-180" : ""} ${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 &&
|
|
32
30
|
renderPortalOverlay &&
|
|
33
31
|
renderPortalOverlay(handleClose)] }));
|
|
34
32
|
};
|
|
@@ -31,7 +31,7 @@ export const WithOverlayAndIndexCount = {
|
|
|
31
31
|
const [_, setSortColumn] = useState({});
|
|
32
32
|
const column = mockColumn("category", "Category");
|
|
33
33
|
return (_jsx("div", { className: "size-96", children: _jsx(SortArrows, { counterIcon: {
|
|
34
|
-
icon: "
|
|
34
|
+
icon: "triangle",
|
|
35
35
|
weight: "solid",
|
|
36
36
|
numberClassNames: "text-white text-[20px] text-red-400 rounded-full top-1.5 right-0 left-0",
|
|
37
37
|
iconClassNames: "text-blue-400 hover:text-red-400 p-4",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const getFontAwesomeIcon: (iconName: string,
|
|
2
|
+
export declare const getFontAwesomeIcon: (iconName: string, iconStyle: "solid" | "regular" | "light" | undefined) => React.ReactElement | null;
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
3
|
-
import * as
|
|
4
|
-
|
|
3
|
+
import * as SolidIcons from "@fortawesome/pro-solid-svg-icons";
|
|
4
|
+
import * as RegularIcons from "@fortawesome/pro-regular-svg-icons";
|
|
5
|
+
import * as LightIcons from "@fortawesome/pro-light-svg-icons";
|
|
6
|
+
export const getFontAwesomeIcon = (iconName, iconStyle) => {
|
|
5
7
|
try {
|
|
6
8
|
const iconKey = `fa${iconName.charAt(0).toUpperCase()}${iconName.slice(1)}`;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
let icon;
|
|
10
|
+
switch (iconStyle) {
|
|
11
|
+
case "solid":
|
|
12
|
+
icon = SolidIcons[iconKey];
|
|
13
|
+
break;
|
|
14
|
+
case "regular":
|
|
15
|
+
icon = RegularIcons[iconKey];
|
|
16
|
+
break;
|
|
17
|
+
case "light":
|
|
18
|
+
icon = LightIcons[iconKey];
|
|
19
|
+
break;
|
|
20
|
+
default:
|
|
21
|
+
throw new Error(`Unknown icon style: ${iconStyle}`);
|
|
10
22
|
}
|
|
11
|
-
|
|
12
|
-
throw new Error(`Icon not found
|
|
23
|
+
if (!icon) {
|
|
24
|
+
throw new Error(`Icon not found: ${iconKey}`);
|
|
13
25
|
}
|
|
26
|
+
return _jsx(FontAwesomeIcon, { icon: icon });
|
|
14
27
|
}
|
|
15
28
|
catch (error) {
|
|
16
29
|
console.error(`Error loading Font Awesome icon: ${iconName}`, error);
|
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.36",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@emotion/is-prop-valid": "^1.1.3",
|
|
26
|
+
"@fortawesome/pro-light-svg-icons": "^6.7.2",
|
|
27
|
+
"@fortawesome/pro-regular-svg-icons": "^6.7.2",
|
|
28
|
+
"@fortawesome/pro-solid-svg-icons": "^6.7.2",
|
|
26
29
|
"@storybook/addon-docs": "^7.6.6",
|
|
27
30
|
"@storybook/addon-viewport": "^7.6.10",
|
|
28
31
|
"@tanstack/react-virtual": "^3.1.3",
|