@agilant/toga-blox 1.0.172 → 1.0.174

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.
Files changed (30) hide show
  1. package/dist/utils/formaTableData.js +18 -3
  2. package/package.json +1 -2
  3. package/dist/components/FormButton/FormButton.d.ts +0 -4
  4. package/dist/components/FormButton/FormButton.js +0 -49
  5. package/dist/components/FormButton/FormButton.stories.d.ts +0 -12
  6. package/dist/components/FormButton/FormButton.stories.js +0 -200
  7. package/dist/components/FormButton/FormButton.test.d.ts +0 -1
  8. package/dist/components/FormButton/FormButton.test.js +0 -27
  9. package/dist/components/FormButton/FormButton.types.d.ts +0 -24
  10. package/dist/components/FormButton/FormButton.types.js +0 -1
  11. package/dist/components/FormButton/index.d.ts +0 -2
  12. package/dist/components/FormButton/index.js +0 -2
  13. package/dist/components/GenericList/DUMMYLISTDATA.json +0 -560
  14. package/dist/components/GenericList/templates/DummyDataList.d.ts +0 -6
  15. package/dist/components/GenericList/templates/DummyDataList.js +0 -6
  16. package/dist/components/GenericList/templates/DynamicIconList.d.ts +0 -32
  17. package/dist/components/GenericList/templates/DynamicIconList.js +0 -7
  18. package/dist/components/MagnifyingIcon/MagnifyingIcon.d.ts +0 -4
  19. package/dist/components/MagnifyingIcon/MagnifyingIcon.js +0 -58
  20. package/dist/components/MagnifyingIcon/MagnifyingIcon.stories.d.ts +0 -9
  21. package/dist/components/MagnifyingIcon/MagnifyingIcon.stories.js +0 -74
  22. package/dist/components/MagnifyingIcon/MagnifyingIcon.test.d.ts +0 -1
  23. package/dist/components/MagnifyingIcon/MagnifyingIcon.test.js +0 -107
  24. package/dist/components/MagnifyingIcon/index.d.ts +0 -2
  25. package/dist/components/MagnifyingIcon/index.js +0 -2
  26. package/dist/components/MagnifyingIcon/types.d.ts +0 -18
  27. package/dist/components/MagnifyingIcon/types.js +0 -1
  28. package/dist/main.css +0 -1
  29. package/dist/utils/fromatTableData.d.ts +0 -46
  30. package/dist/utils/fromatTableData.js +0 -107
@@ -81,16 +81,31 @@ export function baseFormatTableData(columnTitles, accessors, columnConfigs, rend
81
81
  return columnTitles.map((title, i) => {
82
82
  const accessor = accessors[i];
83
83
  const key = `col${i + 1}`;
84
- // Find the config by `key`
85
- const rawConfig = columnConfigs.find((c) => c.key === key) || {
84
+ /* ------------------------------------------------------------
85
+ Build a *complete* config object for this column:
86
+ - start with safe defaults
87
+ - override with whatever came from columnConfigs
88
+ ------------------------------------------------------------ */
89
+ const cfg = {
86
90
  key,
87
91
  type: "DEFAULT",
92
+ isFilterable: false,
93
+ isSortable: false,
94
+ isCopyable: false,
95
+ ...columnConfigs.find((c) => c.key === key),
88
96
  };
89
- const Cell = createCellRenderer(rawConfig);
97
+ const Cell = createCellRenderer(cfg);
98
+ /* ------------------------------------------------------------
99
+ Expose the flags + type so the app layer can read them later
100
+ ------------------------------------------------------------ */
90
101
  return {
91
102
  Header: title,
92
103
  accessor,
93
104
  Cell: ({ value }) => _jsx(Cell, { value: value }),
105
+ type: cfg.type,
106
+ isFilterable: !!cfg.isFilterable,
107
+ isSortable: !!cfg.isSortable,
108
+ isCopyable: !!cfg.isCopyable,
94
109
  };
95
110
  });
96
111
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agilant/toga-blox",
3
3
  "private": false,
4
- "version": "1.0.172",
4
+ "version": "1.0.174",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -22,7 +22,6 @@
22
22
  "README.md"
23
23
  ],
24
24
  "dependencies": {
25
- "@agilant/toga-blox": "^1.0.171",
26
25
  "@emotion/is-prop-valid": "^1.1.3",
27
26
  "@fortawesome/pro-light-svg-icons": "^6.7.2",
28
27
  "@fortawesome/pro-regular-svg-icons": "^6.7.2",
@@ -1,4 +0,0 @@
1
- import React from "react";
2
- import type { FormButtonProps } from "./FormButton.types";
3
- declare const FormButton: React.FC<FormButtonProps>;
4
- export default FormButton;
@@ -1,49 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- const FormButton = ({ onClick, text, fontFamily, backgroundColor, customWidth, customHeight, shape, borderColor, icon, additionalClasses, type = "button", to, href, isDisabled = false, hasShadow, as: Element = "button", hoverBackground, hoverFontColor, hoverUnderline = false, hoverBorderColor, iconClasses, ...props }) => {
3
- const baseFormButtonClasses = "flex items-center justify-center";
4
- const hoverClasses = !isDisabled
5
- ? `${hoverBackground} ${hoverFontColor} ${hoverUnderline ? "underline underline-offset-4" : ""} ${hoverBorderColor}`
6
- : "";
7
- const buttonColorClasses = `${backgroundColor} ${borderColor}`;
8
- const cursorClasses = isDisabled
9
- ? "cursor-not-allowed opacity-50"
10
- : "cursor-pointer";
11
- const textStyleClasses = `${fontFamily}`;
12
- const buttonShapeClasses = shape;
13
- const buttonClasses = `
14
- ${baseFormButtonClasses}
15
- ${buttonColorClasses}
16
- ${buttonShapeClasses}
17
- ${textStyleClasses}
18
- ${hoverClasses}
19
- ${cursorClasses}
20
- ${hasShadow ? "shadow-md" : ""}
21
- ${customWidth}
22
- ${customHeight}
23
- ${additionalClasses}
24
- `.trim();
25
- const handleClick = (e) => {
26
- if (isDisabled) {
27
- e.preventDefault();
28
- return;
29
- }
30
- onClick?.(e);
31
- };
32
- const baseProps = {
33
- className: buttonClasses,
34
- onClick: handleClick,
35
- "aria-disabled": isDisabled ? "true" : "false",
36
- };
37
- let ElementProps = { ...baseProps };
38
- if (Element === "a" && href) {
39
- ElementProps = { ...baseProps, href };
40
- }
41
- else if (Element === "button") {
42
- ElementProps = { ...baseProps, type };
43
- }
44
- else {
45
- ElementProps = { ...baseProps };
46
- }
47
- return (_jsxs(Element, { ...ElementProps, ...props, children: [icon && _jsx("span", { className: iconClasses, children: icon }), text] }));
48
- };
49
- export default FormButton;
@@ -1,12 +0,0 @@
1
- import { Meta } from "@storybook/react";
2
- declare const _default: Meta;
3
- export default _default;
4
- export declare const Default: any;
5
- export declare const Compass: any;
6
- export declare const Disabled: any;
7
- export declare const WithIcon: any;
8
- export declare const IconOnly: any;
9
- export declare const ClearCartButton: any;
10
- export declare const RightIconButton: any;
11
- export declare const ConfirmRequestButton: any;
12
- export declare const FourButtonsRow: any;
@@ -1,200 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import FormButton from "./FormButton";
3
- import Text from "../Text/Text";
4
- import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
5
- export default {
6
- title: "Components/FormButton",
7
- component: FormButton,
8
- argTypes: {
9
- onClick: {
10
- table: {
11
- disable: true,
12
- },
13
- control: "none",
14
- },
15
- text: {
16
- control: "none",
17
- description: "The main text displayed on the button.",
18
- },
19
- fontFamily: {
20
- control: "none",
21
- description: "The font family of the button text.",
22
- },
23
- backgroundColor: {
24
- control: "none",
25
- description: "The background color of the button. Use Tailwind CSS color classes.",
26
- },
27
- borderColor: {
28
- control: "none",
29
- description: "The color of the border of the button. Use Tailwind CSS border color classes.",
30
- },
31
- shape: {
32
- control: "none",
33
- description: "The shape of the button. Use Tailwind CSS border radius classes.",
34
- },
35
- hoverBackground: {
36
- control: "none",
37
- description: "The background color of the button on hover. Use Tailwind CSS color classes.",
38
- },
39
- hoverFontColor: {
40
- control: "none",
41
- description: "The text color of the button on hover. Use Tailwind CSS color classes.",
42
- },
43
- hoverUnderline: {
44
- control: "none",
45
- description: "Whether the text is underlined on hover.",
46
- },
47
- hoverBorderColor: {
48
- control: "none",
49
- description: "The border color of the button on hover. Use Tailwind CSS border color classes.",
50
- },
51
- isDisabled: {
52
- control: "none",
53
- description: "Whether the button is disabled and cannot be clicked.",
54
- },
55
- hasShadow: {
56
- control: "none",
57
- description: "Tailwind CSS class to add a shadow to the button.",
58
- },
59
- customWidth: {
60
- control: "none",
61
- description: "Custom width for the button. Can be a Tailwind CSS class.",
62
- },
63
- customHeight: {
64
- control: "none",
65
- description: "Custom height for the button. Can be a Tailwind CSS class.",
66
- },
67
- additionalClasses: {
68
- control: "none",
69
- description: "Additional Tailwind CSS classes to apply to the button.",
70
- },
71
- icon: {
72
- control: "none",
73
- description: "An optional icon element to display inside the button.",
74
- },
75
- iconClasses: {
76
- control: "none",
77
- description: "Classes for styling the icon inside the button.",
78
- },
79
- as: {
80
- control: "none",
81
- description: "Defines the type of element to render, such as a 'button', 'a', or a React Router 'Link'.",
82
- },
83
- href: {
84
- control: "none",
85
- description: "If 'as' is 'a', this specifies the 'href' for an anchor element.",
86
- },
87
- to: {
88
- control: "none",
89
- description: "If 'as' is 'Link', this specifies the 'to' prop for React Router 'Link'.",
90
- },
91
- },
92
- tags: ['autodocs'],
93
- parameters: {
94
- docs: {
95
- description: {
96
- component: "The `FormButton` component is a versatile button component that supports different types of elements like `button`, `a`, and `Link` from React Router. It's highly customizable with Tailwind CSS classes."
97
- },
98
- },
99
- layout: "centered",
100
- },
101
- };
102
- const Template = (args) => _jsx(FormButton, { ...args });
103
- export const Default = Template.bind({});
104
- Default.args = {
105
- text: "Default Button",
106
- backgroundColor: "bg-blue-600",
107
- fontFamily: "font-sans",
108
- borderColor: "border-none",
109
- shape: "rounded-md",
110
- hoverBackground: "hover:bg-blue-700",
111
- hoverFontColor: "hover:text-black",
112
- onClick: () => alert("Button clicked!"),
113
- additionalClasses: "p-2",
114
- };
115
- export const Compass = Template.bind({});
116
- Compass.args = {
117
- text: _jsx(Text, { size: "", color: "", text: "Compass Button", fontFamily: "" }),
118
- backgroundColor: "bg-green-400",
119
- fontFamily: "font-sans",
120
- shape: "rounded-md",
121
- borderColor: "border-none",
122
- hoverBackground: "hover:bg-green-700",
123
- hoverFontColor: "hover:text-white",
124
- hoverBorderColor: "hover:border-green-900",
125
- hoverUnderline: false,
126
- onClick: () => alert("Button clicked!"),
127
- as: "a",
128
- href: "#",
129
- additionalClasses: "p-2",
130
- };
131
- export const Disabled = Template.bind({});
132
- Disabled.args = {
133
- ...Default.args,
134
- text: _jsx(Text, { size: "", color: "", text: "Disabled Button", fontFamily: "" }),
135
- isDisabled: true,
136
- };
137
- export const WithIcon = Template.bind({});
138
- WithIcon.args = {
139
- ...Default.args,
140
- text: (_jsx(Text, { size: "", color: "", text: "Button with icon", fontFamily: "", additionalClasses: "pl-2" })),
141
- icon: getFontAwesomeIcon("coffee"),
142
- shape: "rounded-none",
143
- hoverUnderline: false,
144
- onClick: () => alert("Button clicked!"),
145
- iconClasses: "pl-2",
146
- };
147
- export const IconOnly = Template.bind({});
148
- IconOnly.args = {
149
- fontFamily: "font-sans",
150
- shape: "rounded",
151
- hoverBackground: "hover:bg-gray-100",
152
- hoverUnderline: false,
153
- icon: getFontAwesomeIcon("trash"),
154
- additionalClasses: "flex justify-center items-center px-4 py-3 bg-gray-50",
155
- onClick: () => alert("Icon button clicked!"),
156
- };
157
- export const ClearCartButton = Template.bind({});
158
- ClearCartButton.args = {
159
- text: _jsx(Text, { size: "", color: "", text: "Clear Cart", fontFamily: "" }),
160
- fontFamily: "font-sans",
161
- shape: "rounded-md",
162
- hoverBackground: "hover:bg-gray-100",
163
- hoverFontColor: "hover:text-black",
164
- hoverBorderColor: "hover:border-red-700",
165
- hoverUnderline: false,
166
- icon: getFontAwesomeIcon("trash"),
167
- iconClasses: "order-first",
168
- additionalClasses: "px-5 py-6 bg-gray-50 border-red-500 gap-2",
169
- onClick: () => alert("Cart Cleared!"),
170
- };
171
- export const RightIconButton = Template.bind({});
172
- RightIconButton.args = {
173
- text: _jsx(Text, { size: "", color: "text-white", text: "Next", fontFamily: "" }),
174
- backgroundColor: "bg-gray-500",
175
- shape: "rounded-md",
176
- hoverBackground: "hover:bg-gray-700",
177
- hoverFontColor: "hover:text-white",
178
- hoverBorderColor: "hover:border-blue-700",
179
- hoverUnderline: false,
180
- icon: getFontAwesomeIcon("arrow-right"),
181
- additionalClasses: "px-6 py-3 flex-row-reverse",
182
- iconClasses: "ml-2",
183
- onClick: () => alert("Next clicked!"),
184
- };
185
- export const ConfirmRequestButton = Template.bind({});
186
- ConfirmRequestButton.args = {
187
- text: _jsx(Text, { size: "", color: "", text: "CONFIRM REQUEST", fontFamily: "" }),
188
- backgroundColor: "bg-[#9ca3af]",
189
- fontFamily: "font-sans",
190
- borderColor: "border-none",
191
- shape: "rounded-md",
192
- hoverUnderline: false,
193
- isDisabled: true,
194
- additionalClasses: "py-3 px-6",
195
- };
196
- export const FourButtonsRow = Template.bind({});
197
- FourButtonsRow.args = {};
198
- FourButtonsRow.decorators = [
199
- (Story) => (_jsxs("div", { className: "flex divide-x divide-gray-200 rounded-md overflow-hidden border border-gray-200", children: [_jsx(FormButton, { 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(FormButton, { text: _jsxs(_Fragment, { children: [getFontAwesomeIcon("boxes", "mr-2"), "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(FormButton, { text: _jsxs(_Fragment, { children: [getFontAwesomeIcon("clipboard", "mr-2"), "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(FormButton, { text: _jsxs(_Fragment, { children: [getFontAwesomeIcon("plus", "mr-2"), "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
- ];
@@ -1 +0,0 @@
1
- export {};
@@ -1,27 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render, screen, fireEvent } from "@testing-library/react";
3
- import { describe, expect, test, vi } from "vitest";
4
- import Button from "./FormButton";
5
- import { MemoryRouter } from "react-router-dom";
6
- describe("Button", () => {
7
- test("renders correctly", () => {
8
- render(_jsx(MemoryRouter, { children: _jsx(Button, { text: "Default Button", backgroundColor: "green", shape: "outline" }) }));
9
- expect(screen.getByText("Default Button")).toBeInTheDocument();
10
- });
11
- test("is clickable", () => {
12
- const mockOnClick = vi.fn();
13
- render(_jsx(MemoryRouter, { children: _jsx(Button, { text: "Clickable Button", backgroundColor: "green", shape: "outline", onClick: mockOnClick }) }));
14
- fireEvent.click(screen.getByText("Clickable Button"));
15
- expect(mockOnClick).toHaveBeenCalled();
16
- });
17
- test("has correct text", () => {
18
- render(_jsx(MemoryRouter, { children: _jsx(Button, { text: "Default Button", backgroundColor: "green", shape: "outline" }) }));
19
- expect(screen.getByText("Default Button")).toHaveTextContent("Default Button");
20
- });
21
- });
22
- describe("Disabled Button", () => {
23
- test("is disabled", () => {
24
- render(_jsx(MemoryRouter, { children: _jsx(Button, { text: "Disabled Button", backgroundColor: "green", shape: "outline", isDisabled: true }) }));
25
- expect(screen.getByText("Disabled Button")).toHaveAttribute("aria-disabled", "true");
26
- });
27
- });
@@ -1,24 +0,0 @@
1
- import React, { ElementType } from "react";
2
- export interface FormButtonProps {
3
- onClick?: (e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void;
4
- text?: string | JSX.Element;
5
- fontFamily?: string;
6
- backgroundColor?: string;
7
- borderColor?: string;
8
- customWidth?: string;
9
- customHeight?: string;
10
- shape?: string;
11
- icon?: JSX.Element | null;
12
- additionalClasses?: string;
13
- type?: "button" | "submit" | "reset";
14
- to?: string;
15
- href?: string;
16
- isDisabled?: boolean;
17
- hasShadow?: string;
18
- as?: ElementType | string;
19
- hoverBackground?: string;
20
- hoverFontColor?: string;
21
- hoverUnderline?: boolean;
22
- hoverBorderColor?: string;
23
- iconClasses?: string;
24
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- export { default } from "./FormButton";
2
- export * from "./FormButton.types";
@@ -1,2 +0,0 @@
1
- export { default } from "./FormButton";
2
- export * from "./FormButton.types";