@monolith-forensics/monolith-ui 1.3.19 → 1.3.20

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,6 +1,6 @@
1
1
  import { CSSProperties } from "react";
2
2
  import { Size } from "../core";
3
- interface SwitchProps {
3
+ export type SwitchProps = {
4
4
  className?: string;
5
5
  onChange: (e: any) => void;
6
6
  size?: Size;
@@ -13,6 +13,5 @@ interface SwitchProps {
13
13
  defaultValue?: boolean;
14
14
  value?: boolean;
15
15
  style?: CSSProperties;
16
- }
17
- declare const Switch: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<SwitchProps, never>> & string & Omit<({ className, onChange, size, label, labelPosition, description, error, required, disabled, defaultValue, value, style, ...other }: SwitchProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
18
- export default Switch;
16
+ };
17
+ export declare const Switch: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<SwitchProps, never>> & string & Omit<({ className, onChange, size, label, labelPosition, description, error, required, disabled, defaultValue, value, style, ...other }: SwitchProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
@@ -118,7 +118,7 @@ const StyledThumb = styled(RadixSwitch.Thumb) `
118
118
  : "translateX(17px)"};
119
119
  }
120
120
  `;
121
- const Switch = styled((_a) => {
121
+ export const Switch = styled((_a) => {
122
122
  var { className, onChange, size = "xs", label, labelPosition = "right", description, error, required, disabled = false, defaultValue, value, style = {} } = _a, other = __rest(_a, ["className", "onChange", "size", "label", "labelPosition", "description", "error", "required", "disabled", "defaultValue", "value", "style"]);
123
123
  return (_jsxs("div", { className: className, children: [label && labelPosition === "left" && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, description: description, style: { margin: 0 }, children: label })), _jsx(StyledRoot, Object.assign({ size: size, className: "SwitchRoot", onCheckedChange: onChange, defaultChecked: defaultValue, checked: value, disabled: disabled, style: style }, other, { children: _jsx(StyledThumb, { size: size, className: "SwitchThumb" }) })), label && labelPosition === "right" && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, description: description, style: { margin: 0 }, children: label }))] }));
124
124
  }) `
@@ -127,4 +127,3 @@ const Switch = styled((_a) => {
127
127
  align-items: center;
128
128
  gap: 10px;
129
129
  `;
130
- export default Switch;
@@ -1 +1 @@
1
- export { default } from "./Switch";
1
+ export * from "./Switch";
@@ -1 +1 @@
1
- export { default } from "./Switch";
1
+ export * from "./Switch";
@@ -12,6 +12,7 @@ import { QueryFilter, useQueryFilter, } from "../../QueryFilter";
12
12
  import shortUUID from "short-uuid";
13
13
  import { DefaultOperators } from "../../QueryFilter";
14
14
  import { useEffect, useRef } from "react";
15
+ import { Switch } from "../..";
15
16
  const StyledContainer = styled.div `
16
17
  display: flex;
17
18
  flex-direction: column;
@@ -33,7 +34,7 @@ const TableMenu = () => {
33
34
  const inputRef = useRef(null);
34
35
  if ((tableMenuOptions === null || tableMenuOptions === void 0 ? void 0 : tableMenuOptions.enabled) !== true)
35
36
  return null;
36
- const { addButtonOptions, filterOptions, tableCountOptions, exportOptions, compactOptions, columnSelectorOptions, actionOptions, searchOptions, children, } = tableMenuOptions;
37
+ const { addButtonOptions, filterOptions, tableCountOptions, exportOptions, compactOptions, columnSelectorOptions, searchOptions, children, customMenuItems, } = tableMenuOptions;
37
38
  const queryFilter = useQueryFilter({
38
39
  defaultFilter: filterState,
39
40
  filterDefinitions: (filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.filterDefinitions) || [],
@@ -61,6 +62,19 @@ const TableMenu = () => {
61
62
  label: item.label,
62
63
  });
63
64
  };
65
+ const renderCustomMenuItems = (args) => {
66
+ return customMenuItems === null || customMenuItems === void 0 ? void 0 : customMenuItems.filter((item) => (item.postition || "left") === args.position).map((item, index) => {
67
+ if (item.type === "button") {
68
+ return _jsx(Button, Object.assign({ size: "xxs" }, item.options), index);
69
+ }
70
+ if (item.type === "menu") {
71
+ return (_jsx(DropDownMenu, Object.assign({ size: "xxs", arrow: true }, item.options), index));
72
+ }
73
+ if (item.type === "switch") {
74
+ return _jsx(Switch, Object.assign({ size: "xs" }, item.options), index);
75
+ }
76
+ });
77
+ };
64
78
  // simultate
65
79
  useEffect(() => {
66
80
  if (inputRef.current && searchState === "") {
@@ -83,8 +97,8 @@ const TableMenu = () => {
83
97
  leftSection: _jsx(FilterIcon, { size: 12 }),
84
98
  }, onItemSelect: handleSelectFilter, dropDownProps: {
85
99
  style: { width: 175, maxWidth: 400 },
86
- }, searchable: true, children: "Filter" })), (tableCountOptions === null || tableCountOptions === void 0 ? void 0 : tableCountOptions.recordsTotalEnabled) === true && (_jsx(InfoBadge, { total: totalRecords || data.length })), enableSelection === true &&
87
- (tableCountOptions === null || tableCountOptions === void 0 ? void 0 : tableCountOptions.selectionTotalEnabled) === true && (_jsx(InfoBadge, { total: getCalculatedSelectionTotal(), hint: "Selected Items", icon: CheckSquareIcon })), children] }), _jsxs(FlexedRow, { children: [(actionOptions === null || actionOptions === void 0 ? void 0 : actionOptions.enabled) === true && actionOptions.menu, (exportOptions === null || exportOptions === void 0 ? void 0 : exportOptions.enabled) === true && (_jsx(DropDownMenu, { variant: "outlined", size: "xs", data: [
100
+ }, searchable: true, children: "Filter" })), renderCustomMenuItems({ position: "left" }), (tableCountOptions === null || tableCountOptions === void 0 ? void 0 : tableCountOptions.recordsTotalEnabled) === true && (_jsx(InfoBadge, { total: totalRecords || data.length })), enableSelection === true &&
101
+ (tableCountOptions === null || tableCountOptions === void 0 ? void 0 : tableCountOptions.selectionTotalEnabled) === true && (_jsx(InfoBadge, { total: getCalculatedSelectionTotal(), hint: "Selected Items", icon: CheckSquareIcon })), children] }), _jsxs(FlexedRow, { children: [renderCustomMenuItems({ position: "right" }), (exportOptions === null || exportOptions === void 0 ? void 0 : exportOptions.enabled) === true && (_jsx(DropDownMenu, { variant: "outlined", size: "xs", data: [
88
102
  {
89
103
  label: "Export Visible Columns",
90
104
  value: TableExportOptions.ExportVisible,
@@ -4,6 +4,7 @@ import { SelectionStatus, TableExportOptions } from "./enums";
4
4
  import { FilterDefinition, Query } from "../QueryFilter";
5
5
  import { DropDownMenuProps } from "../DropDownMenu";
6
6
  import { ButtonProps } from "../Button";
7
+ import { SwitchProps } from "../Switch";
7
8
  export type StateStorage = {
8
9
  enabled: boolean;
9
10
  type: "localStorage";
@@ -210,6 +211,19 @@ export type TableFilterOptions = {
210
211
  filterDefinitions?: FilterDefinition[];
211
212
  onFilterChange?: (e: Query) => void;
212
213
  };
214
+ export type CustomTableMenuItem = {
215
+ type: "button";
216
+ postition?: "left" | "right";
217
+ options: ButtonProps;
218
+ } | {
219
+ type: "menu";
220
+ postition?: "left" | "right";
221
+ options: DropDownMenuProps;
222
+ } | {
223
+ type: "switch";
224
+ postition?: "left" | "right";
225
+ options: SwitchProps;
226
+ };
213
227
  export type TableMenuOptions = {
214
228
  enabled?: boolean;
215
229
  compactOptions?: {
@@ -227,10 +241,6 @@ export type TableMenuOptions = {
227
241
  recordsTotalEnabled?: boolean;
228
242
  selectionTotalEnabled?: boolean;
229
243
  };
230
- actionOptions?: {
231
- enabled?: boolean;
232
- menu?: React.ReactNode;
233
- };
234
244
  searchOptions?: {
235
245
  enabled?: boolean;
236
246
  placeholder?: string;
@@ -245,6 +255,7 @@ export type TableMenuOptions = {
245
255
  enabled?: boolean;
246
256
  };
247
257
  children?: React.ReactNode;
258
+ customMenuItems?: CustomTableMenuItem[];
248
259
  };
249
260
  export interface TableProps {
250
261
  columnProps: ColumnProps[];
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export * from "./TextInput";
9
9
  export * from "./SelectBox";
10
10
  export * from "./Button";
11
11
  export * from "./DropDownMenu";
12
+ export * from "./Switch";
12
13
  export { default as IconButton } from "./IconButton";
13
14
  export { default as DateInput } from "./DateInput";
14
15
  export { default as TextArea } from "./TextArea";
@@ -20,7 +21,6 @@ export { default as Modal } from "./Modal";
20
21
  export { default as Flyout } from "./Flyout";
21
22
  export { FlyoutHeader, FlyoutTitle } from "./Flyout";
22
23
  export { default as FileInputField } from "./FileInputField";
23
- export { default as Switch } from "./Switch";
24
24
  export { default as CheckBox } from "./CheckBox";
25
25
  export { default as Input } from "./Input";
26
26
  export { default as Tooltip } from "./Tooltip";
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ export * from "./TextInput";
4
4
  export * from "./SelectBox";
5
5
  export * from "./Button";
6
6
  export * from "./DropDownMenu";
7
+ export * from "./Switch";
7
8
  export { default as IconButton } from "./IconButton";
8
9
  export { default as DateInput } from "./DateInput";
9
10
  export { default as TextArea } from "./TextArea";
@@ -14,7 +15,6 @@ export { default as Modal } from "./Modal";
14
15
  export { default as Flyout } from "./Flyout";
15
16
  export { FlyoutHeader, FlyoutTitle } from "./Flyout";
16
17
  export { default as FileInputField } from "./FileInputField";
17
- export { default as Switch } from "./Switch";
18
18
  export { default as CheckBox } from "./CheckBox";
19
19
  export { default as Input } from "./Input";
20
20
  export { default as Tooltip } from "./Tooltip";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.3.19",
3
+ "version": "1.3.20",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",