@trackunit/react-table 0.0.80 → 0.0.83

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/index.cjs.js CHANGED
@@ -141,7 +141,7 @@ const cvaActionSheet = cssClassVarianceUtilities.cvaMerge([
141
141
  "grid-flow-col",
142
142
  "min-w-20",
143
143
  "gap-1",
144
- "rounded-3xl",
144
+ "rounded-2xl",
145
145
  "items-center",
146
146
  "z-top",
147
147
  "shadow-md",
@@ -159,7 +159,9 @@ const ActionButton = (_a) => {
159
159
  return (jsxRuntime.jsx(reactComponents.Button, Object.assign({ onClick: action.method, variant: "transparent", color: "secondary" }, rest, { children: children })));
160
160
  };
161
161
  /**
162
- * ActionSheet is meant for actions attached to selections in your table.
162
+ * The Action Sheet appears when one or more items are selected from a table.
163
+ * It primarily accommodates 1-3 main actions that represent the most crucial and frequently accessed functions on the specific page.
164
+ * If the page supports more than 3 actions, the ones that are performed less often can be placed in a contextual menu, represented by the ‘three dots’ icon.
163
165
  *
164
166
  * @param {ActionSheetProps} props - The props for the ActionSheet component
165
167
  * @returns {JSX.Element} ActionSheet component
@@ -176,8 +178,15 @@ const ActionSheet = ({ actions, moreActions = [], selections, resetSelection, cl
176
178
  const filteredActions = actions.filter(action => action !== undefined);
177
179
  const actionsFilteredForScreenSize = smallScreen ? [filteredActions[0]] : filteredActions;
178
180
  const moreActionsFilteredForScreenSize = smallScreen ? moreActions === null || moreActions === void 0 ? void 0 : moreActions.concat(filteredActions.slice(1)) : moreActions;
179
- const actionDataToActionButton = (action, moreAction = false) => (jsxRuntime.jsxs(ActionButton, { action: action, disabled: (selections === null || selections === void 0 ? void 0 : selections.length) === 0, dataTestId: action.label, className: "lg:mr-3", children: [jsxRuntime.jsx(reactComponents.Text, { dataTestId: `${containerProps["data-testid"]}-action-label`, className: `${moreAction ? "text-inherit" : "!text-white"} !text-base`, children: action.label }), jsxRuntime.jsx(reactComponents.Icon, { name: action.icon, color: moreAction ? "neutral" : "white", size: action.size, "data-testid": "action-icon", forwardedRef: action.forwardedRef, style: action.style })] }, action.label));
180
- return (jsxRuntime.jsxs("div", { className: cvaActionSheet({ className: containerProps.className }), "data-testid": containerProps["data-testid"], children: [jsxRuntime.jsx(reactComponents.IconButton, { icon: jsxRuntime.jsx(reactComponents.Icon, { name: "XMark", size: "small", color: "white", "data-testid": "close-icon" }), onClick: resetSelection, color: "secondary", variant: "transparent", circular: true, dataTestId: "XButton" }), jsxRuntime.jsxs(reactComponents.Text, { size: "large", className: "!lg:mr-28 !mr-4 w-max !text-white", children: [selections === null || selections === void 0 ? void 0 : selections.length, " ", t("table.actionsheet.selected")] }), actionsFilteredForScreenSize.map(action => action && actionDataToActionButton(action)), moreActionsFilteredForScreenSize && moreActionsFilteredForScreenSize.length > 0 && (jsxRuntime.jsx(reactComponents.MoreMenu, { popoverProps: { placement: "top" }, iconButtonProps: { variant: "transparent", circular: true }, iconProps: { color: "white" }, dataTestId: `${containerProps["data-testid"]}-more-menu`, children: jsxRuntime.jsx("div", { className: "animate-fade-in-fast absolute bottom-12 right-0", children: jsxRuntime.jsx(reactComponents.MenuList, { children: moreActionsFilteredForScreenSize.map(action => actionDataToActionButton(action, true)) }) }) }))] }));
181
+ const actionDataToActionButton = (action, moreAction = false) => (jsxRuntime.jsxs(ActionButton, { action: action, dataTestId: action.label, className: "lg:mr-3", children: [jsxRuntime.jsx(reactComponents.Icon, { name: action.icon, color: moreAction ? "neutral" : "white", size: action.size, "data-testid": "action-icon", forwardedRef: action.forwardedRef, style: action.style }), jsxRuntime.jsx(reactComponents.Text, { dataTestId: `${containerProps["data-testid"]}-action-label`, className: `${moreAction ? "text-inherit" : "!text-white"} !text-base`, children: action.label })] }, action.label));
182
+ const actionDataToMenuItem = (action) => {
183
+ const item = (jsxRuntime.jsx(reactComponents.MenuItem, { onClick: "method" in action ? action.method : undefined, dataTestId: `${containerProps["data-testid"]}-action-label`, label: action.label, className: "lg:mr-3", prefix: jsxRuntime.jsx(reactComponents.Icon, { name: action.icon, size: action.size, "data-testid": "action-icon", forwardedRef: action.forwardedRef, style: action.style }) }, action.label));
184
+ if ("url" in action) {
185
+ return jsxRuntime.jsx(reactRouterDom.Link, { to: action.url, children: item });
186
+ }
187
+ return item;
188
+ };
189
+ return (jsxRuntime.jsxs("div", { className: cvaActionSheet({ className: containerProps.className }), "data-testid": containerProps["data-testid"], children: [jsxRuntime.jsx(reactComponents.IconButton, { icon: jsxRuntime.jsx(reactComponents.Icon, { name: "XMark", size: "small", color: "white", "data-testid": "close-icon" }), onClick: resetSelection, color: "secondary", variant: "transparent", circular: true, dataTestId: "XButton" }), jsxRuntime.jsxs(reactComponents.Text, { size: "large", className: "!lg:mr-28 !mr-4 w-max !text-white", children: [selections === null || selections === void 0 ? void 0 : selections.length, " ", t("table.actionsheet.selected")] }), actionsFilteredForScreenSize.map(action => action && actionDataToActionButton(action)), moreActionsFilteredForScreenSize && moreActionsFilteredForScreenSize.length > 0 && (jsxRuntime.jsx(reactComponents.MoreMenu, { popoverProps: { placement: "top-end" }, className: "p-0", iconButtonProps: { variant: "transparent", circular: true }, iconProps: { color: "white", name: "EllipsisHorizontal" }, dataTestId: `${containerProps["data-testid"]}-more-menu`, children: jsxRuntime.jsx(reactComponents.MenuList, { className: "relative -right-2", children: moreActionsFilteredForScreenSize.map(action => actionDataToMenuItem(action)) }) }))] }));
181
190
  };
182
191
 
183
192
  /**
package/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
3
- import { useContainerProps, IconButton, Icon, Text, MoreMenu, MenuList, Button, Card, EmptyState, Spinner, Tooltip, Popover, PopoverTrigger, PopoverContent } from '@trackunit/react-components';
3
+ import { useContainerProps, IconButton, Icon, Text, MoreMenu, MenuList, MenuItem, Button, Card, EmptyState, Spinner, Tooltip, Popover, PopoverTrigger, PopoverContent } from '@trackunit/react-components';
4
4
  import * as React from 'react';
5
5
  import { useState, useEffect, useCallback, useRef, createContext, memo as memo$2, isValidElement, cloneElement, useLayoutEffect, useMemo, useContext } from 'react';
6
6
  import { Link } from 'react-router-dom';
@@ -118,7 +118,7 @@ const cvaActionSheet = cvaMerge([
118
118
  "grid-flow-col",
119
119
  "min-w-20",
120
120
  "gap-1",
121
- "rounded-3xl",
121
+ "rounded-2xl",
122
122
  "items-center",
123
123
  "z-top",
124
124
  "shadow-md",
@@ -136,7 +136,9 @@ const ActionButton = (_a) => {
136
136
  return (jsx(Button, Object.assign({ onClick: action.method, variant: "transparent", color: "secondary" }, rest, { children: children })));
137
137
  };
138
138
  /**
139
- * ActionSheet is meant for actions attached to selections in your table.
139
+ * The Action Sheet appears when one or more items are selected from a table.
140
+ * It primarily accommodates 1-3 main actions that represent the most crucial and frequently accessed functions on the specific page.
141
+ * If the page supports more than 3 actions, the ones that are performed less often can be placed in a contextual menu, represented by the ‘three dots’ icon.
140
142
  *
141
143
  * @param {ActionSheetProps} props - The props for the ActionSheet component
142
144
  * @returns {JSX.Element} ActionSheet component
@@ -153,8 +155,15 @@ const ActionSheet = ({ actions, moreActions = [], selections, resetSelection, cl
153
155
  const filteredActions = actions.filter(action => action !== undefined);
154
156
  const actionsFilteredForScreenSize = smallScreen ? [filteredActions[0]] : filteredActions;
155
157
  const moreActionsFilteredForScreenSize = smallScreen ? moreActions === null || moreActions === void 0 ? void 0 : moreActions.concat(filteredActions.slice(1)) : moreActions;
156
- const actionDataToActionButton = (action, moreAction = false) => (jsxs(ActionButton, { action: action, disabled: (selections === null || selections === void 0 ? void 0 : selections.length) === 0, dataTestId: action.label, className: "lg:mr-3", children: [jsx(Text, { dataTestId: `${containerProps["data-testid"]}-action-label`, className: `${moreAction ? "text-inherit" : "!text-white"} !text-base`, children: action.label }), jsx(Icon, { name: action.icon, color: moreAction ? "neutral" : "white", size: action.size, "data-testid": "action-icon", forwardedRef: action.forwardedRef, style: action.style })] }, action.label));
157
- return (jsxs("div", { className: cvaActionSheet({ className: containerProps.className }), "data-testid": containerProps["data-testid"], children: [jsx(IconButton, { icon: jsx(Icon, { name: "XMark", size: "small", color: "white", "data-testid": "close-icon" }), onClick: resetSelection, color: "secondary", variant: "transparent", circular: true, dataTestId: "XButton" }), jsxs(Text, { size: "large", className: "!lg:mr-28 !mr-4 w-max !text-white", children: [selections === null || selections === void 0 ? void 0 : selections.length, " ", t("table.actionsheet.selected")] }), actionsFilteredForScreenSize.map(action => action && actionDataToActionButton(action)), moreActionsFilteredForScreenSize && moreActionsFilteredForScreenSize.length > 0 && (jsx(MoreMenu, { popoverProps: { placement: "top" }, iconButtonProps: { variant: "transparent", circular: true }, iconProps: { color: "white" }, dataTestId: `${containerProps["data-testid"]}-more-menu`, children: jsx("div", { className: "animate-fade-in-fast absolute bottom-12 right-0", children: jsx(MenuList, { children: moreActionsFilteredForScreenSize.map(action => actionDataToActionButton(action, true)) }) }) }))] }));
158
+ const actionDataToActionButton = (action, moreAction = false) => (jsxs(ActionButton, { action: action, dataTestId: action.label, className: "lg:mr-3", children: [jsx(Icon, { name: action.icon, color: moreAction ? "neutral" : "white", size: action.size, "data-testid": "action-icon", forwardedRef: action.forwardedRef, style: action.style }), jsx(Text, { dataTestId: `${containerProps["data-testid"]}-action-label`, className: `${moreAction ? "text-inherit" : "!text-white"} !text-base`, children: action.label })] }, action.label));
159
+ const actionDataToMenuItem = (action) => {
160
+ const item = (jsx(MenuItem, { onClick: "method" in action ? action.method : undefined, dataTestId: `${containerProps["data-testid"]}-action-label`, label: action.label, className: "lg:mr-3", prefix: jsx(Icon, { name: action.icon, size: action.size, "data-testid": "action-icon", forwardedRef: action.forwardedRef, style: action.style }) }, action.label));
161
+ if ("url" in action) {
162
+ return jsx(Link, { to: action.url, children: item });
163
+ }
164
+ return item;
165
+ };
166
+ return (jsxs("div", { className: cvaActionSheet({ className: containerProps.className }), "data-testid": containerProps["data-testid"], children: [jsx(IconButton, { icon: jsx(Icon, { name: "XMark", size: "small", color: "white", "data-testid": "close-icon" }), onClick: resetSelection, color: "secondary", variant: "transparent", circular: true, dataTestId: "XButton" }), jsxs(Text, { size: "large", className: "!lg:mr-28 !mr-4 w-max !text-white", children: [selections === null || selections === void 0 ? void 0 : selections.length, " ", t("table.actionsheet.selected")] }), actionsFilteredForScreenSize.map(action => action && actionDataToActionButton(action)), moreActionsFilteredForScreenSize && moreActionsFilteredForScreenSize.length > 0 && (jsx(MoreMenu, { popoverProps: { placement: "top-end" }, className: "p-0", iconButtonProps: { variant: "transparent", circular: true }, iconProps: { color: "white", name: "EllipsisHorizontal" }, dataTestId: `${containerProps["data-testid"]}-more-menu`, children: jsx(MenuList, { className: "relative -right-2", children: moreActionsFilteredForScreenSize.map(action => actionDataToMenuItem(action)) }) }))] }));
158
167
  };
159
168
 
160
169
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-table",
3
- "version": "0.0.80",
3
+ "version": "0.0.83",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -13,12 +13,12 @@
13
13
  "@trackunit/css-core": "0.0.99",
14
14
  "@trackunit/i18n-library-translation": "0.0.89",
15
15
  "@trackunit/iris-app-api": "0.0.126",
16
- "@trackunit/react-components": "0.1.187",
17
- "@trackunit/react-core-contexts-api": "0.2.67",
18
- "@trackunit/react-core-contexts-test": "0.1.124",
19
- "@trackunit/react-form-components": "0.0.187",
20
- "@trackunit/react-table-base-components": "0.0.64",
21
- "@trackunit/shared-utils": "0.0.14",
16
+ "@trackunit/react-components": "0.1.189",
17
+ "@trackunit/react-core-contexts-api": "0.2.68",
18
+ "@trackunit/react-core-contexts-test": "0.1.125",
19
+ "@trackunit/react-form-components": "0.0.189",
20
+ "@trackunit/react-table-base-components": "0.0.66",
21
+ "@trackunit/shared-utils": "0.0.15",
22
22
  "@trackunit/ui-icons": "0.0.78",
23
23
  "immutability-helper": "3.1.1",
24
24
  "react": "18.2.0",
@@ -2,13 +2,27 @@
2
2
  import { CommonProps } from "@trackunit/react-components";
3
3
  import { ActionModel } from "./Actions";
4
4
  export interface ActionSheetProps extends CommonProps {
5
+ /**
6
+ * Actions to be displayed in the ActionSheet as primary actions (normally visible)
7
+ */
5
8
  actions: readonly [ActionModel, ActionModel?, ActionModel?, ActionModel?];
9
+ /**
10
+ * Secondary Actions to be displayed in the ActionSheet via the more menu
11
+ */
6
12
  moreActions?: ActionModel[];
13
+ /**
14
+ * array of selected element-ids is used for calculating the number of selected elements - and available for eventhandlers.
15
+ */
7
16
  selections: string[];
17
+ /**
18
+ * Called when users closes the action sheet - must reset the selection.
19
+ */
8
20
  resetSelection: () => void;
9
21
  }
10
22
  /**
11
- * ActionSheet is meant for actions attached to selections in your table.
23
+ * The Action Sheet appears when one or more items are selected from a table.
24
+ * It primarily accommodates 1-3 main actions that represent the most crucial and frequently accessed functions on the specific page.
25
+ * If the page supports more than 3 actions, the ones that are performed less often can be placed in a contextual menu, represented by the ‘three dots’ icon.
12
26
  *
13
27
  * @param {ActionSheetProps} props - The props for the ActionSheet component
14
28
  * @returns {JSX.Element} ActionSheet component