@stella-source/stellasource-dsl 1.5.3 → 3.0.0
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/cjs/index.js +241 -37
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/styles.css +2 -0
- package/dist/cjs/types/components/Table/Table.d.ts +1 -1
- package/dist/cjs/types/components/Table/styles.d.ts +4 -1
- package/dist/cjs/types/components/Table/types.d.ts +9 -1
- package/dist/cjs/types/components/Tabs/Styles.d.ts +12 -2
- package/dist/cjs/types/components/Tabs/Tab.d.ts +6 -2
- package/dist/cjs/types/components/Tabs/Tabs.d.ts +1 -1
- package/dist/cjs/types/components/Tabs/Tabs.stories.d.ts +10 -3
- package/dist/cjs/types/components/Tabs/types.d.ts +22 -2
- package/dist/cjs/types/shared/tokens/index.d.ts +2 -0
- package/dist/cjs/types/shared/tokens/storybook/color.d.ts +4 -0
- package/dist/cjs/types/shared/utils/useDebounceCallback.d.ts +10 -0
- package/dist/esm/index.esm.js +242 -38
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/styles.css +2 -0
- package/dist/esm/types/components/Table/Table.d.ts +1 -1
- package/dist/esm/types/components/Table/styles.d.ts +4 -1
- package/dist/esm/types/components/Table/types.d.ts +9 -1
- package/dist/esm/types/components/Tabs/Styles.d.ts +12 -2
- package/dist/esm/types/components/Tabs/Tab.d.ts +6 -2
- package/dist/esm/types/components/Tabs/Tabs.d.ts +1 -1
- package/dist/esm/types/components/Tabs/Tabs.stories.d.ts +10 -3
- package/dist/esm/types/components/Tabs/types.d.ts +22 -2
- package/dist/esm/types/shared/tokens/index.d.ts +2 -0
- package/dist/esm/types/shared/tokens/storybook/color.d.ts +4 -0
- package/dist/esm/types/shared/utils/useDebounceCallback.d.ts +10 -0
- package/dist/index.d.ts +33 -4
- package/package.json +1 -1
package/dist/cjs/styles.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TableProps } from "./types";
|
|
3
|
-
declare function Table<T>({ columns, data, isLoading, serverSide, onPageChange, onSortChange, onFilterChange, onRowSelect, onRowClick, rowStatuses, showSelection, showRowOptions, showPagination, variant, paginationDetails, selectionMenuItems, dataAuto, dataTestId, id, className, htmlProps, resetTrigger, emptyTableState, }: TableProps<T>): React.JSX.Element;
|
|
3
|
+
declare function Table<T>({ columns, data, isLoading, serverSide, onPageChange, onSortChange, onFilterChange, onRowSelect, onRowClick, rowStatuses, showSelection, showRowOptions, showPagination, variant, paginationDetails, selectionMenuItems, dataAuto, dataTestId, id, className, htmlProps, resetTrigger, emptyTableState, defaultFilters, staticFilters, }: TableProps<T>): React.JSX.Element;
|
|
4
4
|
export default Table;
|
|
@@ -3,6 +3,9 @@ interface HeaderIconButtonProps {
|
|
|
3
3
|
$active: boolean;
|
|
4
4
|
$sort?: false | SortDirection;
|
|
5
5
|
}
|
|
6
|
+
interface PaginationProps {
|
|
7
|
+
$hasData?: boolean;
|
|
8
|
+
}
|
|
6
9
|
declare const HeaderCell: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>, {
|
|
7
10
|
$isPinnedLeft?: boolean;
|
|
8
11
|
$isPinnedRight?: boolean;
|
|
@@ -41,7 +44,7 @@ declare const LoadingShimmer: import("styled-components/dist/types").IStyledComp
|
|
|
41
44
|
$width?: string;
|
|
42
45
|
$height?: string;
|
|
43
46
|
}>> & string;
|
|
44
|
-
declare const CustomPagination: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").
|
|
47
|
+
declare const CustomPagination: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("../Pagination/types").PaginationProps, PaginationProps>> & string & Omit<({ isLoading, rowsPerPage, totalRows, ariaLabel, onPageChange, startingPage, id, className, htmlProps, }: import("../Pagination/types").PaginationProps) => import("react").JSX.Element, keyof import("react").Component<any, {}, any>>;
|
|
45
48
|
declare const KebabAlign: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
46
49
|
declare const EmptyTableCell: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, never>> & string;
|
|
47
50
|
declare const EmptyTableSection: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, {
|
|
@@ -45,6 +45,14 @@ export interface TableProps<T> {
|
|
|
45
45
|
showClearFilterButton?: boolean;
|
|
46
46
|
onClearFilters?: () => void;
|
|
47
47
|
};
|
|
48
|
+
defaultFilters?: {
|
|
49
|
+
id: string;
|
|
50
|
+
value: unknown;
|
|
51
|
+
}[];
|
|
52
|
+
staticFilters?: {
|
|
53
|
+
id: string;
|
|
54
|
+
value: unknown;
|
|
55
|
+
}[];
|
|
48
56
|
}
|
|
49
57
|
export interface CustomColumnMeta {
|
|
50
58
|
headerAlign?: "left" | "right";
|
|
@@ -52,7 +60,7 @@ export interface CustomColumnMeta {
|
|
|
52
60
|
dataType?: "string" | "number";
|
|
53
61
|
pin?: "left" | "right";
|
|
54
62
|
filterOptions?: string[] | number[];
|
|
55
|
-
|
|
63
|
+
filterMode?: "singleSelect" | "multiSelect" | "search";
|
|
56
64
|
}
|
|
57
65
|
export type RowStatus = "action-pending" | "completed";
|
|
58
66
|
export {};
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { TabsVariant } from "./types";
|
|
2
|
+
interface TabsStylesProps {
|
|
3
|
+
$variant: `${TabsVariant}`;
|
|
4
|
+
$isPill?: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface NotificationBubbleProps {
|
|
7
|
+
$isActive?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const TabsBar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, TabsStylesProps>> & string;
|
|
10
|
+
declare const TabButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, TabsStylesProps>> & string;
|
|
11
|
+
declare const NotificationBubble: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, NotificationBubbleProps>> & string;
|
|
12
|
+
export { TabsBar, TabButton, NotificationBubble };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import React, { HTMLAttributes } from "react";
|
|
2
|
+
import { TabsVariant } from "./types";
|
|
2
3
|
interface TabProps {
|
|
3
4
|
id?: string;
|
|
4
5
|
className?: string;
|
|
5
6
|
onClick?: (tabLabel: string) => void;
|
|
6
|
-
label: string;
|
|
7
7
|
htmlProps?: HTMLAttributes<HTMLButtonElement>;
|
|
8
|
+
active?: boolean;
|
|
9
|
+
variant?: `${TabsVariant}`;
|
|
10
|
+
notifications?: number;
|
|
11
|
+
label: string;
|
|
8
12
|
}
|
|
9
|
-
declare const Tab: ({ id, className, onClick, htmlProps, label }: TabProps) => React.JSX.Element;
|
|
13
|
+
declare const Tab: ({ id, className, onClick, htmlProps, label, variant, active, notifications, }: TabProps) => React.JSX.Element;
|
|
10
14
|
export default Tab;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TabsProps } from "./types";
|
|
3
|
-
declare const Tabs: ({ id, className, tabs,
|
|
3
|
+
declare const Tabs: ({ id, className, tabs, htmlProps, onTabClick, defaultActiveTab, variant, isPill, }: TabsProps) => React.JSX.Element;
|
|
4
4
|
export default Tabs;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { TabsProps } from "./types";
|
|
1
|
+
import { TabsProps, TabsVariant } from "./types";
|
|
2
2
|
declare const _default: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({ id, className, tabs,
|
|
4
|
+
component: ({ id, className, tabs, htmlProps, onTabClick, defaultActiveTab, variant, isPill, }: TabsProps) => import("react").JSX.Element;
|
|
5
5
|
tags: string[];
|
|
6
6
|
parameters: {};
|
|
7
|
-
argTypes: {
|
|
7
|
+
argTypes: {
|
|
8
|
+
variant: {
|
|
9
|
+
options: TabsVariant[];
|
|
10
|
+
control: {
|
|
11
|
+
type: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
8
15
|
args: TabsProps;
|
|
9
16
|
};
|
|
10
17
|
export default _default;
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import { HTMLAttributes } from "react";
|
|
2
|
-
export
|
|
2
|
+
export declare enum TabsVariant {
|
|
3
|
+
LIGHT = "light",
|
|
4
|
+
DARK = "dark"
|
|
5
|
+
}
|
|
6
|
+
interface TabsBaseProps {
|
|
3
7
|
id?: string;
|
|
4
8
|
className?: string;
|
|
5
9
|
activeTab?: string;
|
|
6
10
|
htmlProps?: HTMLAttributes<HTMLElement>;
|
|
7
|
-
|
|
11
|
+
defaultActiveTab?: string;
|
|
12
|
+
isPill?: boolean;
|
|
13
|
+
variant?: `${TabsVariant}`;
|
|
14
|
+
tabs: {
|
|
15
|
+
label: string;
|
|
16
|
+
notifications?: number;
|
|
17
|
+
}[];
|
|
8
18
|
onTabClick: (label?: string) => void;
|
|
9
19
|
}
|
|
20
|
+
interface TabsPropsLight {
|
|
21
|
+
variant?: `${TabsVariant.LIGHT}`;
|
|
22
|
+
isPill?: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface TabsPropsDark {
|
|
25
|
+
variant?: `${TabsVariant.DARK}`;
|
|
26
|
+
isPill?: never;
|
|
27
|
+
}
|
|
28
|
+
export type TabsProps = TabsBaseProps & (TabsPropsLight | TabsPropsDark);
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type DebouncedCallback<T extends (...args: any[]) => any> = (...args: Parameters<T>) => void;
|
|
2
|
+
type DebounceControls<T extends (...args: any[]) => any> = {
|
|
3
|
+
flush: () => void;
|
|
4
|
+
cancel: () => void;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Returns a debounced version of a callback, along with flush and cancel methods.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useDebounceCallback<T extends (...args: any[]) => any>(callback: T, delay: number): [DebouncedCallback<T>, DebounceControls<T>];
|
|
10
|
+
export {};
|
package/dist/esm/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as a$l from 'react';
|
|
2
|
-
import a__default, { createContext, useMemo as useMemo$1, isValidElement, version as version$1, useContext, useRef, useLayoutEffect as useLayoutEffect$1, useEffect, useState, forwardRef, useImperativeHandle } from 'react';
|
|
2
|
+
import a__default, { createContext, useMemo as useMemo$1, isValidElement, version as version$1, useContext, useRef, useLayoutEffect as useLayoutEffect$1, useEffect, useState, forwardRef, useImperativeHandle, useCallback } from 'react';
|
|
3
3
|
import styled, { css, keyframes } from 'styled-components';
|
|
4
4
|
import ReactDOM, { createPortal } from 'react-dom';
|
|
5
5
|
|
|
@@ -38,8 +38,12 @@ const colorTokens = {
|
|
|
38
38
|
50: "var(--grey50)",
|
|
39
39
|
/** #d5dbe5 */
|
|
40
40
|
100: "var(--grey100)",
|
|
41
|
+
/** #BCC2CE */
|
|
42
|
+
200: "var(--grey200)",
|
|
41
43
|
/** #687182 */
|
|
42
44
|
500: "var(--grey500)",
|
|
45
|
+
/** #464F60 */
|
|
46
|
+
700: "var(--grey700)",
|
|
43
47
|
},
|
|
44
48
|
blue: {
|
|
45
49
|
/** #1f4168 */
|
|
@@ -21001,17 +21005,14 @@ const StyledTable = styled.table `
|
|
|
21001
21005
|
border-collapse: collapse;
|
|
21002
21006
|
`;
|
|
21003
21007
|
const CustomIconButton$1 = styled(IconButton) `
|
|
21004
|
-
opacity: ${({ $active }) => ($active ? 1 : 0)};
|
|
21005
|
-
transition: opacity 0.2s ease;
|
|
21006
21008
|
padding: 0px;
|
|
21007
21009
|
& > svg {
|
|
21008
|
-
|
|
21009
|
-
fill: ${({ $active }) => $active ? Styles.color.grey.charcoal : Styles.color.grey.smoke};
|
|
21010
|
+
fill: ${({ $active }) => $active ? Styles.color.grey.charcoal : Styles.color.grey.medium};
|
|
21010
21011
|
}
|
|
21011
21012
|
&:hover:not(:disabled) {
|
|
21012
21013
|
background-color: transparent;
|
|
21013
21014
|
& > svg {
|
|
21014
|
-
fill: ${Styles.color.grey.
|
|
21015
|
+
fill: ${Styles.color.grey.smoke};
|
|
21015
21016
|
}
|
|
21016
21017
|
}
|
|
21017
21018
|
`;
|
|
@@ -21056,9 +21057,20 @@ const Checkbox = styled.input.attrs({ type: "checkbox" }) `
|
|
|
21056
21057
|
cursor: pointer;
|
|
21057
21058
|
`;
|
|
21058
21059
|
const MenuItemGroup = styled.div `
|
|
21059
|
-
max-height:
|
|
21060
|
+
--menu-options-max-height: 136px;
|
|
21061
|
+
max-height: var(--menu-options-max-height);
|
|
21060
21062
|
overflow-y: auto;
|
|
21061
21063
|
overflow-x: hidden;
|
|
21064
|
+
&::after {
|
|
21065
|
+
content: "";
|
|
21066
|
+
position: absolute;
|
|
21067
|
+
top: 0;
|
|
21068
|
+
left: 0;
|
|
21069
|
+
width: 100%;
|
|
21070
|
+
height: calc(var(--menu-options-max-height) + 6px);
|
|
21071
|
+
pointer-events: none;
|
|
21072
|
+
background: linear-gradient(to bottom, transparent 94%, white);
|
|
21073
|
+
}
|
|
21062
21074
|
`;
|
|
21063
21075
|
const BodyCell = styled.td `
|
|
21064
21076
|
box-shadow: ${({ $isPinnedLeft, $columnInfo, $isPinnedRight }) => $isPinnedLeft && $columnInfo.getIsLastColumn("left")
|
|
@@ -21082,7 +21094,7 @@ const BodyCell = styled.td `
|
|
|
21082
21094
|
padding: 0px 12px;
|
|
21083
21095
|
font-size: 12px;
|
|
21084
21096
|
color: ${Styles.color.grey.charcoal};
|
|
21085
|
-
border-bottom:
|
|
21097
|
+
border-bottom: 1px solid ${Styles.color.grey.light};
|
|
21086
21098
|
transition: box-shadow 0.3s ease-out;
|
|
21087
21099
|
`;
|
|
21088
21100
|
const MenuButton = styled.button `
|
|
@@ -21168,7 +21180,7 @@ const MenuItemOption = styled.button `
|
|
|
21168
21180
|
background: #f5f5f5;
|
|
21169
21181
|
}
|
|
21170
21182
|
|
|
21171
|
-
background-color: ${({ $applied }) => $applied ? Styles.color.blue.light : "
|
|
21183
|
+
background-color: ${({ $applied }) => $applied ? Styles.color.blue.light : "transparent"};
|
|
21172
21184
|
`;
|
|
21173
21185
|
const FilterLabelTransparent = styled.div `
|
|
21174
21186
|
font-size: 12px;
|
|
@@ -21230,7 +21242,7 @@ const LoadingShimmer = styled.div `
|
|
|
21230
21242
|
}
|
|
21231
21243
|
`;
|
|
21232
21244
|
const CustomPagination = styled(Pagination) `
|
|
21233
|
-
border-top: 1px solid ${Styles.color.grey.light};
|
|
21245
|
+
border-top: ${({ $hasData }) => $hasData ? "0px" : `1px solid ${Styles.color.grey.light}`};
|
|
21234
21246
|
`;
|
|
21235
21247
|
const KebabAlign = styled.div `
|
|
21236
21248
|
display: flex;
|
|
@@ -21291,6 +21303,38 @@ const IndeterminateCheckbox = ({ isIndeterminate, isChecked, onChange, }) => {
|
|
|
21291
21303
|
return (a__default.createElement(Checkbox, { ref: ref, checked: isChecked, onChange: (e) => onChange?.(e) }));
|
|
21292
21304
|
};
|
|
21293
21305
|
|
|
21306
|
+
/**
|
|
21307
|
+
* Returns a debounced version of a callback, along with flush and cancel methods.
|
|
21308
|
+
*/
|
|
21309
|
+
function useDebounceCallback(callback, delay) {
|
|
21310
|
+
const timeoutRef = useRef(null);
|
|
21311
|
+
const lastArgsRef = useRef(null);
|
|
21312
|
+
const debounced = useCallback((...args) => {
|
|
21313
|
+
lastArgsRef.current = args;
|
|
21314
|
+
if (timeoutRef.current)
|
|
21315
|
+
clearTimeout(timeoutRef.current);
|
|
21316
|
+
timeoutRef.current = setTimeout(() => {
|
|
21317
|
+
if (lastArgsRef.current)
|
|
21318
|
+
callback(...lastArgsRef.current);
|
|
21319
|
+
timeoutRef.current = null;
|
|
21320
|
+
}, delay);
|
|
21321
|
+
}, [callback, delay]);
|
|
21322
|
+
const flush = useCallback(() => {
|
|
21323
|
+
if (timeoutRef.current && lastArgsRef.current) {
|
|
21324
|
+
clearTimeout(timeoutRef.current);
|
|
21325
|
+
callback(...lastArgsRef.current);
|
|
21326
|
+
timeoutRef.current = null;
|
|
21327
|
+
}
|
|
21328
|
+
}, [callback]);
|
|
21329
|
+
const cancel = useCallback(() => {
|
|
21330
|
+
if (timeoutRef.current) {
|
|
21331
|
+
clearTimeout(timeoutRef.current);
|
|
21332
|
+
timeoutRef.current = null;
|
|
21333
|
+
}
|
|
21334
|
+
}, []);
|
|
21335
|
+
return [debounced, { flush, cancel }];
|
|
21336
|
+
}
|
|
21337
|
+
|
|
21294
21338
|
const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition, onFilterMenuInteraction, onFilterApply, }) => {
|
|
21295
21339
|
const column = header.column;
|
|
21296
21340
|
const columnDef = column.columnDef;
|
|
@@ -21300,10 +21344,17 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
|
|
|
21300
21344
|
const buttonRef = useRef(null);
|
|
21301
21345
|
const [showFilter, setShowFilter] = useState(false);
|
|
21302
21346
|
const [coords, setCoords] = useState({ top: 0, left: 0 });
|
|
21347
|
+
const [searchValue, setSearchValue] = useState();
|
|
21303
21348
|
const [tempFilters, setTempFilters] = useState([]);
|
|
21304
21349
|
const [currentAppliedFilters, setCurrentAppliedFilters] = useState([]);
|
|
21305
21350
|
const [filterOptions, setFilterOptions] = useState([]);
|
|
21306
21351
|
const [textAlign, setTextAlign] = useState("left");
|
|
21352
|
+
const [handleSave, { flush }] = useDebounceCallback((value) => {
|
|
21353
|
+
column?.setFilterValue([value]);
|
|
21354
|
+
if (value === "")
|
|
21355
|
+
column?.setFilterValue([]);
|
|
21356
|
+
onFilterApply?.();
|
|
21357
|
+
}, 300);
|
|
21307
21358
|
useEffect(() => {
|
|
21308
21359
|
setFilterOptions(meta?.filterOptions || []);
|
|
21309
21360
|
}, [meta]);
|
|
@@ -21377,7 +21428,13 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
|
|
|
21377
21428
|
position: "absolute",
|
|
21378
21429
|
}, ref: menuRef },
|
|
21379
21430
|
a__default.createElement(MenuItemGroup, null,
|
|
21380
|
-
|
|
21431
|
+
meta?.filterMode === "search" && (a__default.createElement("div", { style: { padding: "4px 10px" } },
|
|
21432
|
+
a__default.createElement(TextInput, { id: `${columnDef.header}-search`, label: `${columnDef.header} search`, placeholder: "Search", hideLabel: true, onChange: (value) => {
|
|
21433
|
+
setSearchValue(value);
|
|
21434
|
+
handleSave(value);
|
|
21435
|
+
}, onBlur: () => flush(), endIcon: "search", value: searchValue }))),
|
|
21436
|
+
(meta?.filterMode === "multiSelect" ||
|
|
21437
|
+
!meta?.filterMode) && (a__default.createElement(MenuItem, { key: "select-all" },
|
|
21381
21438
|
a__default.createElement(Checkbox, { id: "all-checkbox", name: "all-checkbox", checked: meta?.filterOptions?.every((item) => tempFilters?.includes(item)), onChange: () => {
|
|
21382
21439
|
setTempFilters((prev) => {
|
|
21383
21440
|
if (prev?.length === meta?.filterOptions?.length) {
|
|
@@ -21392,7 +21449,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
|
|
|
21392
21449
|
(serverSide
|
|
21393
21450
|
? filterOptions
|
|
21394
21451
|
: Array.from(header.column.getFacetedUniqueValues().keys()))?.map((item) => {
|
|
21395
|
-
if (meta?.singleSelect) {
|
|
21452
|
+
if (meta?.filterMode === "singleSelect") {
|
|
21396
21453
|
return (a__default.createElement(MenuItemOption, { key: item, id: `${item}-button`, onClick: () => {
|
|
21397
21454
|
setCurrentAppliedFilters([item]);
|
|
21398
21455
|
column?.setFilterValue([item]);
|
|
@@ -21400,21 +21457,25 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
|
|
|
21400
21457
|
onFilterApply?.();
|
|
21401
21458
|
}, "$applied": tempFilters?.includes(item) }, item));
|
|
21402
21459
|
}
|
|
21403
|
-
|
|
21404
|
-
|
|
21405
|
-
|
|
21406
|
-
|
|
21407
|
-
|
|
21408
|
-
|
|
21409
|
-
|
|
21410
|
-
|
|
21411
|
-
|
|
21412
|
-
|
|
21413
|
-
|
|
21414
|
-
|
|
21415
|
-
|
|
21460
|
+
if (meta?.filterMode === "multiSelect" ||
|
|
21461
|
+
!meta?.filterMode) {
|
|
21462
|
+
return (a__default.createElement(MenuItem, { key: item },
|
|
21463
|
+
a__default.createElement(Checkbox, { id: `${item}-checkbox`, name: `${item}-checkbox`, checked: tempFilters?.includes(item), onChange: () => {
|
|
21464
|
+
setTempFilters((prev) => {
|
|
21465
|
+
if (prev?.includes(item)) {
|
|
21466
|
+
return prev.filter((i) => i !== item);
|
|
21467
|
+
}
|
|
21468
|
+
else {
|
|
21469
|
+
return [...prev, item];
|
|
21470
|
+
}
|
|
21471
|
+
});
|
|
21472
|
+
} }),
|
|
21473
|
+
a__default.createElement(FilterLabelTransparent, null, item),
|
|
21474
|
+
a__default.createElement(FilterBoxLabel, { htmlFor: `${item}-checkbox` }, item)));
|
|
21475
|
+
}
|
|
21416
21476
|
})),
|
|
21417
|
-
|
|
21477
|
+
(meta?.filterMode === "multiSelect" ||
|
|
21478
|
+
!meta?.filterMode) && (a__default.createElement(MenuButton, { key: "apply", onClick: () => {
|
|
21418
21479
|
setCurrentAppliedFilters(tempFilters);
|
|
21419
21480
|
column?.setFilterValue(tempFilters?.length > 0 ? tempFilters : []);
|
|
21420
21481
|
showFilterMenu(false);
|
|
@@ -21425,6 +21486,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
|
|
|
21425
21486
|
showFilterMenu(false);
|
|
21426
21487
|
setTempFilters([]);
|
|
21427
21488
|
setCurrentAppliedFilters([]);
|
|
21489
|
+
setSearchValue("");
|
|
21428
21490
|
onFilterApply?.();
|
|
21429
21491
|
} }, "Clear Filter"))), document.body))),
|
|
21430
21492
|
header.column.getCanSort() && (a__default.createElement(SortButton, { className: "icon", iconName: "sort", ariaLabel: "Sort Button", variant: "tertiary", "$active": sorting.some((s) => s.id === header.column.id), "$sort": column.getIsSorted(), onClick: (e) => header.column.getToggleSortingHandler()?.(e) })),
|
|
@@ -21486,7 +21548,7 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
|
|
|
21486
21548
|
startingPage: 1,
|
|
21487
21549
|
rowsPerPage: 10,
|
|
21488
21550
|
totalRows: data.length,
|
|
21489
|
-
}, selectionMenuItems, dataAuto, dataTestId, id, className, htmlProps, resetTrigger, emptyTableState, }) {
|
|
21551
|
+
}, selectionMenuItems, dataAuto, dataTestId, id, className, htmlProps, resetTrigger, emptyTableState, defaultFilters, staticFilters, }) {
|
|
21490
21552
|
const [rowSelection, setRowSelection] = useState({});
|
|
21491
21553
|
const [selectedRows] = useState({});
|
|
21492
21554
|
const [pageIndex, setPageIndex] = useState(paginationDetails?.startingPage);
|
|
@@ -21500,7 +21562,26 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
|
|
|
21500
21562
|
const [sorting, setSorting] = useState([]);
|
|
21501
21563
|
const [filters, setFilters] = useState({});
|
|
21502
21564
|
const [rowState, setRowState] = useState({});
|
|
21503
|
-
const [columnFilters, setColumnFilters] = useState(
|
|
21565
|
+
const [columnFilters, setColumnFilters] = useState(() => {
|
|
21566
|
+
const base = defaultFilters ?? [];
|
|
21567
|
+
if (!staticFilters?.length)
|
|
21568
|
+
return base;
|
|
21569
|
+
const merged = [...base];
|
|
21570
|
+
staticFilters.forEach((sf) => {
|
|
21571
|
+
const existing = merged.find((f) => f.id === sf.id);
|
|
21572
|
+
if (existing) {
|
|
21573
|
+
const staticValues = new Set(sf.value);
|
|
21574
|
+
existing.value = [
|
|
21575
|
+
...sf.value,
|
|
21576
|
+
...existing.value.filter((v) => !staticValues.has(v)),
|
|
21577
|
+
];
|
|
21578
|
+
}
|
|
21579
|
+
else {
|
|
21580
|
+
merged.push(sf);
|
|
21581
|
+
}
|
|
21582
|
+
});
|
|
21583
|
+
return merged;
|
|
21584
|
+
});
|
|
21504
21585
|
const [columnPinning, setColumnPinning] = useState({ left: ["select"], right: ["options"] });
|
|
21505
21586
|
const scrollRef = useRef(null);
|
|
21506
21587
|
const [scrollState, setScrollState] = useState({
|
|
@@ -21634,9 +21715,31 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
|
|
|
21634
21715
|
},
|
|
21635
21716
|
onColumnFiltersChange: (updaterOrValue) => {
|
|
21636
21717
|
// TanStack passes either updater function or new filters array
|
|
21637
|
-
|
|
21718
|
+
let next = typeof updaterOrValue === "function"
|
|
21638
21719
|
? updaterOrValue(columnFilters)
|
|
21639
21720
|
: updaterOrValue;
|
|
21721
|
+
// Re-apply static filters so they can never be removed
|
|
21722
|
+
if (staticFilters?.length) {
|
|
21723
|
+
next = next.map((f) => {
|
|
21724
|
+
const staticFilter = staticFilters.find((sf) => sf.id === f.id);
|
|
21725
|
+
if (!staticFilter)
|
|
21726
|
+
return f;
|
|
21727
|
+
const staticValues = new Set(staticFilter.value);
|
|
21728
|
+
const userValues = f.value;
|
|
21729
|
+
// Keep all static values locked in, plus whatever the user freely toggled
|
|
21730
|
+
const merged = [
|
|
21731
|
+
...staticFilter.value,
|
|
21732
|
+
...userValues.filter((v) => !staticValues.has(v)),
|
|
21733
|
+
];
|
|
21734
|
+
return { ...f, value: merged };
|
|
21735
|
+
});
|
|
21736
|
+
// Ensure static filters are always present even if column wasn't touched
|
|
21737
|
+
const nextIds = new Set(next.map((f) => f.id));
|
|
21738
|
+
staticFilters.forEach((sf) => {
|
|
21739
|
+
if (!nextIds.has(sf.id))
|
|
21740
|
+
next = [...next, sf];
|
|
21741
|
+
});
|
|
21742
|
+
}
|
|
21640
21743
|
setColumnFilters(next);
|
|
21641
21744
|
// Also keep your simple `filters` map in sync (optional)
|
|
21642
21745
|
const map = {};
|
|
@@ -21649,7 +21752,7 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
|
|
|
21649
21752
|
number: (row, columnId, filterValue) => {
|
|
21650
21753
|
if (!filterValue?.length)
|
|
21651
21754
|
return true;
|
|
21652
|
-
return filterValue.
|
|
21755
|
+
return filterValue.some((val) => Number(row.getValue(columnId)).toString().includes(val.toString()));
|
|
21653
21756
|
},
|
|
21654
21757
|
},
|
|
21655
21758
|
});
|
|
@@ -21661,11 +21764,16 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
|
|
|
21661
21764
|
onRowSelect?.(selectedData);
|
|
21662
21765
|
}
|
|
21663
21766
|
}, [rowSelection]);
|
|
21767
|
+
const isMounted = useRef(false);
|
|
21664
21768
|
useEffect(() => {
|
|
21769
|
+
if (!isMounted.current) {
|
|
21770
|
+
isMounted.current = true;
|
|
21771
|
+
return;
|
|
21772
|
+
}
|
|
21665
21773
|
resetTable();
|
|
21666
21774
|
}, [resetTrigger]);
|
|
21667
21775
|
const resetTable = () => {
|
|
21668
|
-
setColumnFilters([]);
|
|
21776
|
+
setColumnFilters(staticFilters ?? []);
|
|
21669
21777
|
setFilters({});
|
|
21670
21778
|
setSorting([]);
|
|
21671
21779
|
setPageIndex(1);
|
|
@@ -21755,7 +21863,7 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
|
|
|
21755
21863
|
pagination.pageSize * pagination.pageIndex ===
|
|
21756
21864
|
table.getRowModel().rows.length - 1 }, value));
|
|
21757
21865
|
})))))))),
|
|
21758
|
-
showPagination && paginationDetails?.totalRows > 0 && (a__default.createElement(CustomPagination, { totalRows: serverSide ? totalData : table.getFilteredRowModel().rows.length, isLoading: isLoading, rowsPerPage: paginationDetails?.rowsPerPage, startingPage: pageIndex, onPageChange: (page, pageSize) => {
|
|
21866
|
+
showPagination && paginationDetails?.totalRows > 0 && (a__default.createElement(CustomPagination, { "$hasData": table.getRowModel().rows.length > 0, totalRows: serverSide ? totalData : table.getFilteredRowModel().rows.length, isLoading: isLoading, rowsPerPage: paginationDetails?.rowsPerPage, startingPage: pageIndex, onPageChange: (page, pageSize) => {
|
|
21759
21867
|
table.toggleAllRowsSelected(false);
|
|
21760
21868
|
setPageIndex(page);
|
|
21761
21869
|
setPagination((prev) => ({
|
|
@@ -21925,17 +22033,113 @@ const PaymentStatus = ({ variant, id, className }) => {
|
|
|
21925
22033
|
a__default.createElement(PaymentStatusLabel, null, label)));
|
|
21926
22034
|
};
|
|
21927
22035
|
|
|
21928
|
-
const
|
|
21929
|
-
|
|
22036
|
+
const tabButtonVariantSelector = (variant) => {
|
|
22037
|
+
switch (variant) {
|
|
22038
|
+
case "light":
|
|
22039
|
+
return css `
|
|
22040
|
+
border-image: linear-gradient(
|
|
22041
|
+
to bottom,
|
|
22042
|
+
transparent 20%,
|
|
22043
|
+
${Styles.color.grey[200]} 20% 80%,
|
|
22044
|
+
transparent 80% 100%
|
|
22045
|
+
)
|
|
22046
|
+
1;
|
|
22047
|
+
border-right: 2px solid;
|
|
22048
|
+
&:has(+ .active) {
|
|
22049
|
+
border-image: none;
|
|
22050
|
+
border-right: 2px solid ${Styles.color.grey.light};
|
|
22051
|
+
}
|
|
22052
|
+
&.active {
|
|
22053
|
+
border: none;
|
|
22054
|
+
margin-right: 2px;
|
|
22055
|
+
box-shadow:
|
|
22056
|
+
0 0 0 0.5px rgba(0, 0, 0, 0.08),
|
|
22057
|
+
0 2px 6px 0 rgba(0, 0, 0, 0.25);
|
|
22058
|
+
border-radius: 4px;
|
|
22059
|
+
color: ${Styles.color.core.primary};
|
|
22060
|
+
background-color: ${Styles.color.white};
|
|
22061
|
+
}
|
|
22062
|
+
&:hover:not(.active) {
|
|
22063
|
+
color: ${Styles.color.core.primary};
|
|
22064
|
+
}
|
|
22065
|
+
`;
|
|
22066
|
+
case "dark":
|
|
22067
|
+
return css `
|
|
22068
|
+
&.active {
|
|
22069
|
+
border: none;
|
|
22070
|
+
box-shadow:
|
|
22071
|
+
0 0 0 0.5px rgba(0, 0, 0, 0.08),
|
|
22072
|
+
0 2px 6px 0 rgba(0, 0, 0, 0.25);
|
|
22073
|
+
border-radius: 10px;
|
|
22074
|
+
color: ${Styles.color.white};
|
|
22075
|
+
background-color: ${Styles.color.grey[700]};
|
|
22076
|
+
}
|
|
22077
|
+
&:hover:not(.active) {
|
|
22078
|
+
color: ${Styles.color.grey[700]};
|
|
22079
|
+
}
|
|
22080
|
+
`;
|
|
22081
|
+
default:
|
|
22082
|
+
return css ``;
|
|
22083
|
+
}
|
|
22084
|
+
};
|
|
22085
|
+
const tabsVariantSelector = (variant) => {
|
|
22086
|
+
switch (variant) {
|
|
22087
|
+
case "light":
|
|
22088
|
+
return `${Styles.color.grey.light}`;
|
|
22089
|
+
case "dark":
|
|
22090
|
+
return "transparent";
|
|
22091
|
+
default:
|
|
22092
|
+
return `${Styles.color.grey.light}`;
|
|
22093
|
+
}
|
|
21930
22094
|
};
|
|
21931
|
-
|
|
21932
22095
|
const TabsBar = styled.nav `
|
|
21933
22096
|
display: flex;
|
|
21934
|
-
|
|
22097
|
+
width: fit-content;
|
|
22098
|
+
padding: 2px;
|
|
22099
|
+
background-color: ${({ $variant }) => tabsVariantSelector($variant)};
|
|
22100
|
+
border-radius: ${({ $isPill }) => ($isPill ? "6px" : "6px 6px 0px 0px")};
|
|
22101
|
+
:last-child {
|
|
22102
|
+
border: none;
|
|
22103
|
+
&.active {
|
|
22104
|
+
margin: 0;
|
|
22105
|
+
}
|
|
22106
|
+
}
|
|
22107
|
+
`;
|
|
22108
|
+
const TabButton = styled.button `
|
|
22109
|
+
display: flex;
|
|
22110
|
+
align-items: center;
|
|
22111
|
+
cursor: pointer;
|
|
22112
|
+
background-color: transparent;
|
|
22113
|
+
border: none;
|
|
22114
|
+
color: ${Styles.color.grey.charcoal};
|
|
22115
|
+
padding: 4px 10px;
|
|
22116
|
+
line-height: 20px;
|
|
22117
|
+
font-size: 14px;
|
|
22118
|
+
${({ $variant }) => tabButtonVariantSelector($variant)};
|
|
22119
|
+
`;
|
|
22120
|
+
const NotificationBubble = styled.span `
|
|
22121
|
+
margin-left: 5px;
|
|
22122
|
+
background-color: ${({ $isActive }) => $isActive ? Styles.color.transparent : Styles.color.core.accent};
|
|
22123
|
+
border-radius: 100%;
|
|
22124
|
+
padding: ${({ $isActive }) => ($isActive ? "1px 4px 1px 3px" : "1px 4px")};
|
|
22125
|
+
font-size: ${({ $isActive }) => ($isActive ? "12px" : "10px")};
|
|
22126
|
+
line-height: 12px;
|
|
22127
|
+
color: ${({ $isActive }) => $isActive ? Styles.color.core.primary : Styles.color.white};
|
|
21935
22128
|
`;
|
|
21936
22129
|
|
|
21937
|
-
const
|
|
21938
|
-
return (a__default.createElement(
|
|
22130
|
+
const Tab = ({ id, className, onClick, htmlProps, label, variant = "light", active = false, notifications, }) => {
|
|
22131
|
+
return (a__default.createElement(TabButton, { id: id, "$variant": variant, className: `${className} ${active && "active"}`, onClick: () => onClick?.(label), ...htmlProps },
|
|
22132
|
+
label,
|
|
22133
|
+
notifications && notifications > 0 && (a__default.createElement(NotificationBubble, { "$isActive": active }, notifications))));
|
|
22134
|
+
};
|
|
22135
|
+
|
|
22136
|
+
const Tabs = ({ id, className, tabs, htmlProps, onTabClick, defaultActiveTab, variant = "light", isPill, }) => {
|
|
22137
|
+
const [activeTab, setActiveTab] = useState(defaultActiveTab ?? tabs[0]);
|
|
22138
|
+
const handleClick = (label) => {
|
|
22139
|
+
setActiveTab(label);
|
|
22140
|
+
onTabClick(label);
|
|
22141
|
+
};
|
|
22142
|
+
return (a__default.createElement(TabsBar, { "$variant": variant, "$isPill": isPill, id: id, className: className, ...htmlProps }, tabs.map((tab) => (a__default.createElement(Tab, { key: `${id}-${tab.label}`, id: `${id}-${tab.label}`, label: tab.label, active: tab.label === activeTab, variant: variant, onClick: () => handleClick(tab.label), notifications: tab.notifications })))));
|
|
21939
22143
|
};
|
|
21940
22144
|
|
|
21941
22145
|
export { HelperText, IconButton, Label, Loader, NumberInput, Pagination, PasswordInput, PaymentStatus, StellaButton, StellaButtonVariant, StellaIcon, Styles, Sync, Table, TableUnitsAndTotals, Tabs, TextInput, Tooltip };
|