@stella-source/stellasource-dsl 3.1.6 → 3.2.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 +42 -29
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/Table/types.d.ts +4 -1
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/esm/index.esm.js +42 -29
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/types/components/Table/types.d.ts +4 -1
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/index.d.ts +12 -1
- package/package.json +1 -1
|
@@ -59,7 +59,10 @@ export interface CustomColumnMeta {
|
|
|
59
59
|
cellAlign?: "left" | "right";
|
|
60
60
|
dataType?: "string" | "number";
|
|
61
61
|
pin?: "left" | "right";
|
|
62
|
-
filterOptions?: string[] | number[]
|
|
62
|
+
filterOptions?: string[] | number[] | {
|
|
63
|
+
key?: string;
|
|
64
|
+
value?: string;
|
|
65
|
+
}[];
|
|
63
66
|
filterMode?: "singleSelect" | "multiSelect" | "search";
|
|
64
67
|
}
|
|
65
68
|
export type RowStatus = "action-pending" | "completed";
|
|
@@ -24,4 +24,5 @@ import "./shared/tokens/tokens.css";
|
|
|
24
24
|
import OrderStatus from "./components/OrderStatus/OrderStatus";
|
|
25
25
|
/**Exports */
|
|
26
26
|
export type { StellaIconDefinition } from "./components/StellaIcon/types";
|
|
27
|
+
export type { CustomColumnMeta } from "./components/Table/types";
|
|
27
28
|
export { Tabs, Label, StellaButton, IconButton, Loader, HelperText, Tooltip, StellaIcon, TextInput, PasswordInput, NumberInput, Table, Pagination, Sync, TableUnitsAndTotals, StellaButtonVariant, PaymentStatus, OrderStatus, Styles, };
|
package/dist/esm/index.esm.js
CHANGED
|
@@ -21392,7 +21392,7 @@ const KebabAlign = styled.div `
|
|
|
21392
21392
|
`;
|
|
21393
21393
|
// EmptyTableState
|
|
21394
21394
|
const EmptyTableCell = styled.td `
|
|
21395
|
-
padding:
|
|
21395
|
+
padding: 5rem;
|
|
21396
21396
|
background-color: white;
|
|
21397
21397
|
`;
|
|
21398
21398
|
const EmptyTableSection = styled.section `
|
|
@@ -21477,6 +21477,18 @@ function useDebounceCallback(callback, delay) {
|
|
|
21477
21477
|
return [debounced, { flush, cancel }];
|
|
21478
21478
|
}
|
|
21479
21479
|
|
|
21480
|
+
const normalizeOptions = (raw) => {
|
|
21481
|
+
return raw
|
|
21482
|
+
.map((item) => {
|
|
21483
|
+
if (typeof item === "string" || typeof item === "number") {
|
|
21484
|
+
return { key: item.toString(), value: item.toString() };
|
|
21485
|
+
}
|
|
21486
|
+
const key = item.key ?? item.value ?? "";
|
|
21487
|
+
const value = item.value ?? item.key ?? "";
|
|
21488
|
+
return { key, value };
|
|
21489
|
+
})
|
|
21490
|
+
.filter((o) => o.key && o.value);
|
|
21491
|
+
};
|
|
21480
21492
|
const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition, onFilterMenuInteraction, onFilterApply, }) => {
|
|
21481
21493
|
const column = header.column;
|
|
21482
21494
|
const columnDef = column.columnDef;
|
|
@@ -21489,6 +21501,9 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
|
|
|
21489
21501
|
const [tempFilters, setTempFilters] = useState([]);
|
|
21490
21502
|
const [currentAppliedFilters, setCurrentAppliedFilters] = useState([]);
|
|
21491
21503
|
const [filterOptions, setFilterOptions] = useState([]);
|
|
21504
|
+
const displayOptions = serverSide
|
|
21505
|
+
? filterOptions
|
|
21506
|
+
: normalizeOptions(Array.from(header.column.getFacetedUniqueValues().keys()));
|
|
21492
21507
|
const [textAlign, setTextAlign] = useState("left");
|
|
21493
21508
|
const [handleSave, { flush }] = useDebounceCallback((value) => {
|
|
21494
21509
|
column?.setFilterValue([value]);
|
|
@@ -21497,7 +21512,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
|
|
|
21497
21512
|
onFilterApply?.();
|
|
21498
21513
|
}, 300);
|
|
21499
21514
|
useEffect(() => {
|
|
21500
|
-
setFilterOptions(meta?.filterOptions || []);
|
|
21515
|
+
setFilterOptions(normalizeOptions(meta?.filterOptions || []));
|
|
21501
21516
|
}, [meta]);
|
|
21502
21517
|
const toggleMenu = (e) => {
|
|
21503
21518
|
e.stopPropagation();
|
|
@@ -21578,43 +21593,39 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
|
|
|
21578
21593
|
}, onBlur: () => !serverSide && flush(), endIcon: "search", value: tempFilters?.[0] }))),
|
|
21579
21594
|
(meta?.filterMode === "multiSelect" ||
|
|
21580
21595
|
!meta?.filterMode) && (a__default.createElement(MenuItem, { key: "select-all" },
|
|
21581
|
-
a__default.createElement(Checkbox, { id: "all-checkbox", name: "all-checkbox", checked:
|
|
21596
|
+
a__default.createElement(Checkbox, { id: "all-checkbox", name: "all-checkbox", checked: displayOptions?.every((opt) => tempFilters?.includes(opt.key)), onChange: () => {
|
|
21582
21597
|
setTempFilters((prev) => {
|
|
21583
|
-
if (prev?.length ===
|
|
21598
|
+
if (prev?.length === displayOptions?.length) {
|
|
21584
21599
|
return [];
|
|
21585
21600
|
}
|
|
21586
21601
|
else {
|
|
21587
|
-
return
|
|
21602
|
+
return displayOptions.map((opt) => opt.key);
|
|
21588
21603
|
}
|
|
21589
21604
|
});
|
|
21590
21605
|
} }),
|
|
21591
21606
|
a__default.createElement(FilterBoxLabel, { htmlFor: "all-checkbox" }, "Select All"))),
|
|
21592
|
-
(
|
|
21593
|
-
? filterOptions
|
|
21594
|
-
: Array.from(header.column.getFacetedUniqueValues().keys()))?.map((item) => {
|
|
21607
|
+
displayOptions?.map(({ key, value }, index) => {
|
|
21595
21608
|
if (meta?.filterMode === "singleSelect") {
|
|
21596
|
-
return (a__default.createElement(MenuItemOption, { key:
|
|
21597
|
-
setCurrentAppliedFilters([
|
|
21598
|
-
column?.setFilterValue([
|
|
21609
|
+
return (a__default.createElement(MenuItemOption, { key: `${key}-${index}`, id: `${key}-button`, onClick: () => {
|
|
21610
|
+
setCurrentAppliedFilters([key]);
|
|
21611
|
+
column?.setFilterValue([key]);
|
|
21599
21612
|
showFilterMenu(false);
|
|
21600
21613
|
onFilterApply?.();
|
|
21601
|
-
}, "$applied": tempFilters?.includes(
|
|
21614
|
+
}, "$applied": tempFilters?.includes(key) }, value));
|
|
21602
21615
|
}
|
|
21603
21616
|
if (meta?.filterMode === "multiSelect" ||
|
|
21604
21617
|
!meta?.filterMode) {
|
|
21605
|
-
return (a__default.createElement(MenuItem, { key:
|
|
21606
|
-
a__default.createElement(Checkbox, { id: `${
|
|
21618
|
+
return (a__default.createElement(MenuItem, { key: key },
|
|
21619
|
+
a__default.createElement(Checkbox, { id: `${key}-checkbox`, name: `${key}-checkbox`, checked: tempFilters?.includes(key), onChange: () => {
|
|
21607
21620
|
setTempFilters((prev) => {
|
|
21608
|
-
if (prev?.includes(
|
|
21609
|
-
return prev.filter((i) => i !==
|
|
21610
|
-
|
|
21611
|
-
|
|
21612
|
-
return [...prev, item];
|
|
21613
|
-
}
|
|
21621
|
+
if (prev?.includes(key))
|
|
21622
|
+
return prev.filter((i) => i !== key);
|
|
21623
|
+
else
|
|
21624
|
+
return [...prev, key];
|
|
21614
21625
|
});
|
|
21615
21626
|
} }),
|
|
21616
|
-
a__default.createElement(FilterLabelTransparent, null,
|
|
21617
|
-
a__default.createElement(FilterBoxLabel, { htmlFor: `${
|
|
21627
|
+
a__default.createElement(FilterLabelTransparent, null, value),
|
|
21628
|
+
a__default.createElement(FilterBoxLabel, { htmlFor: `${key}-checkbox` }, value)));
|
|
21618
21629
|
}
|
|
21619
21630
|
})),
|
|
21620
21631
|
(meta?.filterMode === "multiSelect" ||
|
|
@@ -21884,11 +21895,9 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
|
|
|
21884
21895
|
});
|
|
21885
21896
|
}
|
|
21886
21897
|
setColumnFilters(next);
|
|
21887
|
-
// Also keep your simple `filters` map in sync (optional)
|
|
21888
21898
|
const map = {};
|
|
21889
21899
|
next.forEach((f) => (map[f.id] = f.value));
|
|
21890
21900
|
setFilters(map);
|
|
21891
|
-
// Inform parent (useful for server-side)
|
|
21892
21901
|
onFilterChange?.(next);
|
|
21893
21902
|
},
|
|
21894
21903
|
filterFns: {
|
|
@@ -22137,6 +22146,9 @@ const PaymentStatusIcon = styled(StellaIcon) `
|
|
|
22137
22146
|
`;
|
|
22138
22147
|
const PaymentStatusLabel = styled.span `
|
|
22139
22148
|
line-height: 20px;
|
|
22149
|
+
text-overflow: ellipsis;
|
|
22150
|
+
white-space: nowrap;
|
|
22151
|
+
overflow: hidden;
|
|
22140
22152
|
`;
|
|
22141
22153
|
|
|
22142
22154
|
var PaymentStatusVariant;
|
|
@@ -22273,7 +22285,7 @@ const NotificationBubble = styled.span `
|
|
|
22273
22285
|
const Tab = ({ id, className, onClick, htmlProps, label, variant = "light", active = false, notifications, }) => {
|
|
22274
22286
|
return (a__default.createElement(TabButton, { id: id, "$variant": variant, className: `${className} ${active && "active"}`, onClick: () => onClick?.(label), ...htmlProps },
|
|
22275
22287
|
label,
|
|
22276
|
-
notifications && notifications > 0 && (a__default.createElement(NotificationBubble, { "$isActive": active }, notifications))));
|
|
22288
|
+
!!(notifications && notifications > 0) && (a__default.createElement(NotificationBubble, { "$isActive": active }, notifications))));
|
|
22277
22289
|
};
|
|
22278
22290
|
|
|
22279
22291
|
const Tabs = ({ id, className, tabs, htmlProps, onTabClick, defaultActiveTab, variant = "light", isPill, }) => {
|
|
@@ -22299,6 +22311,9 @@ const OrderStatusIcon = styled(StellaIcon) `
|
|
|
22299
22311
|
`;
|
|
22300
22312
|
const OrderStatusLabel = styled.span `
|
|
22301
22313
|
line-height: 20px;
|
|
22314
|
+
text-overflow: ellipsis;
|
|
22315
|
+
white-space: nowrap;
|
|
22316
|
+
overflow: hidden;
|
|
22302
22317
|
`;
|
|
22303
22318
|
|
|
22304
22319
|
var OrderStatusVariant;
|
|
@@ -22324,9 +22339,7 @@ const getOrderStatusLabel = (variant, isPurchaser) => {
|
|
|
22324
22339
|
case OrderStatusVariant.VIEW_PRICING:
|
|
22325
22340
|
return isPurchaser ? "View Quote" : "Quoted";
|
|
22326
22341
|
case OrderStatusVariant.ACTION_REQUIRED:
|
|
22327
|
-
return
|
|
22328
|
-
case OrderStatusVariant.ORDER_PLACED:
|
|
22329
|
-
return "Awaiting Acknowledgement";
|
|
22342
|
+
return "Action Required";
|
|
22330
22343
|
case OrderStatusVariant.DECLINED:
|
|
22331
22344
|
return "Declined to Purchase";
|
|
22332
22345
|
case OrderStatusVariant.EXPIRED:
|
|
@@ -22342,7 +22355,7 @@ const OrderStatus = ({ variant, id, className, isPurchaser, }) => {
|
|
|
22342
22355
|
const STATUS_ICON_MAP = {
|
|
22343
22356
|
InfoNeeded: "warning",
|
|
22344
22357
|
ViewPricing: "eye",
|
|
22345
|
-
ActionRequired:
|
|
22358
|
+
ActionRequired: "warning",
|
|
22346
22359
|
OrderPlaced: "list-checks",
|
|
22347
22360
|
OrderAcknowledged: "check-square",
|
|
22348
22361
|
OrderCanceled: "x-circle",
|