@stella-source/stellasource-dsl 0.2.4 → 0.2.8

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/README.md CHANGED
@@ -48,6 +48,6 @@ To get started with the **Stella Source Design System**, visit our [documentatio
48
48
 
49
49
  ---
50
50
 
51
- ## Contributing
51
+ # Contributing to the DSL
52
52
 
53
- Contributing guide coming soon!
53
+ Contributing Guide: https://dev.azure.com/stellasource/Stella%20Source/_wiki/wikis/SecturaSoft.wiki/543/Contributing-To-The-DSL
package/dist/cjs/index.js CHANGED
@@ -3434,7 +3434,7 @@ var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
3434
3434
  * ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
3435
3435
  * exposing only those methods and properties that are defined in the spec.
3436
3436
  */
3437
- var ResizeObserver$1 = /** @class */ (function () {
3437
+ var ResizeObserver$2 = /** @class */ (function () {
3438
3438
  /**
3439
3439
  * Creates a new instance of ResizeObserver.
3440
3440
  *
@@ -3460,7 +3460,7 @@ var ResizeObserver$1 = /** @class */ (function () {
3460
3460
  'unobserve',
3461
3461
  'disconnect'
3462
3462
  ].forEach(function (method) {
3463
- ResizeObserver$1.prototype[method] = function () {
3463
+ ResizeObserver$2.prototype[method] = function () {
3464
3464
  var _a;
3465
3465
  return (_a = observers.get(this))[method].apply(_a, arguments);
3466
3466
  };
@@ -3471,7 +3471,7 @@ var index = (function () {
3471
3471
  if (typeof global$1.ResizeObserver !== 'undefined') {
3472
3472
  return global$1.ResizeObserver;
3473
3473
  }
3474
- return ResizeObserver$1;
3474
+ return ResizeObserver$2;
3475
3475
  })();
3476
3476
 
3477
3477
  // =============================== Const ===============================
@@ -3711,7 +3711,7 @@ if (process.env.NODE_ENV !== 'production') {
3711
3711
  }
3712
3712
 
3713
3713
  var INTERNAL_PREFIX_KEY = 'rc-observer-key';
3714
- function ResizeObserver(props, ref) {
3714
+ function ResizeObserver$1(props, ref) {
3715
3715
  var children = props.children;
3716
3716
  var childNodes = typeof children === 'function' ? [children] : toArray$2(children);
3717
3717
  if (process.env.NODE_ENV !== 'production') {
@@ -3729,7 +3729,7 @@ function ResizeObserver(props, ref) {
3729
3729
  }), child);
3730
3730
  });
3731
3731
  }
3732
- var RefResizeObserver = /*#__PURE__*/a__namespace.forwardRef(ResizeObserver);
3732
+ var RefResizeObserver = /*#__PURE__*/a__namespace.forwardRef(ResizeObserver$1);
3733
3733
  if (process.env.NODE_ENV !== 'production') {
3734
3734
  RefResizeObserver.displayName = 'ResizeObserver';
3735
3735
  }
@@ -20789,6 +20789,7 @@ const TableWrapper = styled.div `
20789
20789
  const TableWrapperScroll = styled.div `
20790
20790
  width: 100%;
20791
20791
  overflow-x: ${({ $stopScroll }) => ($stopScroll ? "hidden" : "auto")};
20792
+ overflow-y: hidden;
20792
20793
  `;
20793
20794
  const StyledTable = styled.table `
20794
20795
  width: 100%;
@@ -21095,7 +21096,11 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
21095
21096
  const [coords, setCoords] = a$j.useState({ top: 0, left: 0 });
21096
21097
  const [tempFilters, setTempFilters] = a$j.useState([]);
21097
21098
  const [currentAppliedFilters, setCurrentAppliedFilters] = a$j.useState([]);
21099
+ const [filterOptions, setFilterOptions] = a$j.useState([]);
21098
21100
  const [textAlign, setTextAlign] = a$j.useState("left");
21101
+ a$j.useEffect(() => {
21102
+ setFilterOptions(meta?.filterOptions || []);
21103
+ }, [meta]);
21099
21104
  const toggleMenu = (e) => {
21100
21105
  e.stopPropagation();
21101
21106
  if (buttonRef.current) {
@@ -21120,7 +21125,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
21120
21125
  const insideButton = !!buttonRef.current?.contains(target);
21121
21126
  const insideMenu = !!menuRef.current?.contains(target);
21122
21127
  if (!insideButton && !insideMenu) {
21123
- setTempFilters(currentAppliedFilters);
21128
+ setTempFilters(filters?.[header.id] || currentAppliedFilters);
21124
21129
  showFilterMenu(false);
21125
21130
  }
21126
21131
  };
@@ -21179,7 +21184,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
21179
21184
  } }),
21180
21185
  a$j.createElement(FilterBoxLabel, { htmlFor: "all-checkbox" }, "Select All"))),
21181
21186
  (serverSide
21182
- ? meta?.filterOptions
21187
+ ? filterOptions
21183
21188
  : Array.from(header.column.getFacetedUniqueValues().keys()))?.map((item) => {
21184
21189
  if (meta?.singleSelect) {
21185
21190
  return (a$j.createElement(MenuItemOption, { key: item, id: `${item}-button`, onClick: () => {
@@ -21281,6 +21286,8 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
21281
21286
  pageIndex: paginationDetails?.startingPage - 1,
21282
21287
  pageSize: paginationDetails?.rowsPerPage || 10,
21283
21288
  });
21289
+ const [localData, setLocalData] = a$j.useState(data);
21290
+ const [localColumns, setLocalColumns] = a$j.useState(columns);
21284
21291
  const [totalData, setTotalData] = a$j.useState(paginationDetails?.totalRows);
21285
21292
  const [sorting, setSorting] = a$j.useState([]);
21286
21293
  const [filters, setFilters] = a$j.useState({});
@@ -21303,20 +21310,47 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
21303
21310
  pageIndex: paginationDetails?.startingPage - 1,
21304
21311
  pageSize: paginationDetails?.rowsPerPage || 10,
21305
21312
  });
21306
- }, [paginationDetails, data]);
21307
- a$j.useEffect(() => {
21308
- const el = scrollRef?.current;
21313
+ setLocalColumns(columns);
21314
+ setLocalData(data);
21315
+ }, [paginationDetails, data, columns]);
21316
+ a$j.useLayoutEffect(() => {
21317
+ const el = scrollRef.current;
21309
21318
  if (!el)
21310
21319
  return;
21311
- const handleScroll = () => {
21312
- const atLeft = el.scrollLeft <= 0;
21313
- const atRight = el.scrollWidth - el.scrollLeft <= el.clientWidth + 1;
21320
+ let raf = 0;
21321
+ const update = () => {
21322
+ const maxScrollLeft = Math.max(0, el.scrollWidth - el.clientWidth);
21323
+ const hasOverflow = maxScrollLeft > 1; // tolerance for rounding
21324
+ let atLeft = el.scrollLeft <= 0;
21325
+ let atRight = el.scrollLeft >= maxScrollLeft - 1;
21326
+ if (!hasOverflow) {
21327
+ atLeft = true;
21328
+ atRight = true;
21329
+ }
21314
21330
  setScrollState({ atLeft, atRight });
21315
21331
  };
21316
- el.addEventListener("scroll", handleScroll);
21317
- handleScroll(); // initial check
21318
- return () => el.removeEventListener("scroll", handleScroll);
21319
- }, [scrollRef]);
21332
+ const schedule = () => {
21333
+ cancelAnimationFrame(raf);
21334
+ raf = requestAnimationFrame(update);
21335
+ };
21336
+ // Listen to scroll
21337
+ el.addEventListener("scroll", schedule);
21338
+ // Recalculate when sizes change
21339
+ const ro = new ResizeObserver(schedule);
21340
+ ro.observe(el);
21341
+ const tableEl = el.querySelector("table");
21342
+ if (tableEl)
21343
+ ro.observe(tableEl);
21344
+ window.addEventListener("resize", schedule);
21345
+ // Initial measurement after layout
21346
+ schedule();
21347
+ return () => {
21348
+ el.removeEventListener("scroll", schedule);
21349
+ window.removeEventListener("resize", schedule);
21350
+ ro.disconnect();
21351
+ cancelAnimationFrame(raf);
21352
+ };
21353
+ }, []);
21320
21354
  const handleInputChange = (rowId, field, value) => {
21321
21355
  setRowState((prev) => ({
21322
21356
  ...prev,
@@ -21337,7 +21371,7 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
21337
21371
  size: 20,
21338
21372
  });
21339
21373
  }
21340
- cols.push(...columns);
21374
+ cols.push(...localColumns);
21341
21375
  if (showRowOptions) {
21342
21376
  cols.push({
21343
21377
  id: "options",
@@ -21349,9 +21383,16 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
21349
21383
  });
21350
21384
  }
21351
21385
  return cols;
21352
- }, [columns, selectedRows, data, onRowSelect, showSelection, showRowOptions]);
21386
+ }, [
21387
+ localColumns,
21388
+ selectedRows,
21389
+ localData,
21390
+ onRowSelect,
21391
+ showSelection,
21392
+ showRowOptions,
21393
+ ]);
21353
21394
  const table = useReactTable({
21354
- data,
21395
+ data: localData,
21355
21396
  columns: enhancedColumns,
21356
21397
  state: {
21357
21398
  pagination,