@wavelengthusaf/components 2.7.3 → 2.8.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.
@@ -6114,6 +6114,7 @@ function DefaultPagination({ totalPages, currentPageNumber, siblingCount = 1, bo
6114
6114
  );
6115
6115
  }
6116
6116
  }
6117
+ var WavelengthPagination_default = DefaultPagination;
6117
6118
 
6118
6119
  // src/components/TextField/WavelengthTextField.tsx
6119
6120
 
@@ -6247,6 +6248,368 @@ function WavelengthTextField(props) {
6247
6248
  return null;
6248
6249
  }
6249
6250
 
6251
+ // src/components/DataTable/WavelengthDataTable.tsx
6252
+
6253
+
6254
+
6255
+ var ModalInputDiv = _styledcomponents2.default.div`
6256
+ display: flex;
6257
+ flex-direction: column; /* Corrected this line */
6258
+ gap: 3px;
6259
+ margin: 3px;
6260
+
6261
+ label {
6262
+ align-self: flex-start;
6263
+ color: #c6c7cc;
6264
+ }
6265
+
6266
+ input,
6267
+ select {
6268
+ width: 100%;
6269
+ padding: 12px 20px;
6270
+ margin: 8px 0;
6271
+ box-sizing: border-box;
6272
+ border: none;
6273
+ outline: none;
6274
+ border-bottom: 2px solid #c6c7cc;
6275
+
6276
+ &:hover {
6277
+ border-bottom: 2px solid black;
6278
+ }
6279
+
6280
+ &:focus {
6281
+ border-bottom: 2px solid #8fd8ff;
6282
+ }
6283
+ }
6284
+ `;
6285
+ var ModalOverlay = _styledcomponents2.default.div`
6286
+ position: fixed;
6287
+ bottom: 19%;
6288
+ right: 15%;
6289
+ width: 100%;
6290
+ height: 100%;
6291
+ background-color: rgba(0, 0, 0, 0);
6292
+ display: flex;
6293
+ justify-content: center;
6294
+ align-items: center;
6295
+ z-index: 1;
6296
+ `;
6297
+ var ModalWrapper = _styledcomponents2.default.div`
6298
+ background-color: white;
6299
+ border-radius: 8px;
6300
+ padding: 20px;
6301
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
6302
+ position: relative;
6303
+ min-width: 300px;
6304
+ z-index: 1;
6305
+ display: flex;
6306
+ align-items: center;
6307
+ `;
6308
+ var ModalClose = _styledcomponents2.default.button`
6309
+ position: absolute;
6310
+ top: 10px;
6311
+ right: 10px;
6312
+ font-size: 20px;
6313
+ cursor: pointer;
6314
+ border: none;
6315
+ background: none;
6316
+ z-index: 2;
6317
+ `;
6318
+ var TableHeadStyle = _styledcomponents2.default.th`
6319
+ position: relative;
6320
+ `;
6321
+ var KebabMenu = _styledcomponents2.default.div`
6322
+ display: inline-block;
6323
+ position: absolute;
6324
+ right: 0;
6325
+ top: 2px;
6326
+ `;
6327
+ var KebabIcon = _styledcomponents2.default.div`
6328
+ cursor: pointer;
6329
+ font-size: 20px;
6330
+ padding: 5px;
6331
+
6332
+ &:hover,
6333
+ &:focus {
6334
+ color: #45beff;
6335
+ }
6336
+ &:active {
6337
+ color: #8fd8ff;
6338
+ }
6339
+ `;
6340
+ var MenuOptions = _styledcomponents2.default.ul`
6341
+ position: absolute;
6342
+ right: 0;
6343
+ top: 100%;
6344
+ background-color: #f9f9f9;
6345
+ min-width: 160px;
6346
+ box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
6347
+ z-index: 1;
6348
+ list-style: none;
6349
+ padding: 0;
6350
+ margin: 0;
6351
+
6352
+ li {
6353
+ padding: 10px;
6354
+ text-decoration: none;
6355
+ display: block;
6356
+ cursor: pointer;
6357
+
6358
+ &:hover {
6359
+ background-color: #ddd;
6360
+ }
6361
+ }
6362
+ `;
6363
+ var StyledBoxDiv = _styledcomponents2.default.div`
6364
+ background-color: white;
6365
+ width: 700px;
6366
+ height: 480px;
6367
+ position: relative;
6368
+ border-top-left-radius: 10px;
6369
+ border-top-right-radius: 10px;
6370
+ `;
6371
+ var StyledNavBoxDiv = _styledcomponents2.default.div`
6372
+ background-color: white;
6373
+ width: 700px;
6374
+ display: flex; /* Make parent a flex-container */
6375
+ justify-content: center;
6376
+ border-bottom-left-radius: 10px;
6377
+ border-bottom-right-radius: 10px;
6378
+
6379
+ box-shadow: 0.5px 3px 5px black;
6380
+ `;
6381
+ var StyledTd = _styledcomponents2.default.td`
6382
+ border-top: 1px solid #c6c7cc;
6383
+ border-bottom: 1px solid #c6c7cc;
6384
+ padding: 10px 15px;
6385
+ vertical-align: middle;
6386
+ `;
6387
+ var StyledTableTwo = _styledcomponents2.default.table`
6388
+ width: 95%;
6389
+ height: 95%;
6390
+ border-collapse: collapse;
6391
+ background-color: white;
6392
+ color: black;
6393
+
6394
+ margin-left: auto;
6395
+ margin-right: auto;
6396
+
6397
+ th {
6398
+ position: relative; /* Enable absolute positioning of pseudo-elements */
6399
+ padding: 10px 15px;
6400
+
6401
+ /* Create the partial right border */
6402
+ &:not(:last-child):after {
6403
+ content: ""; /* Ensure the pseudo-element is visible */
6404
+ position: absolute;
6405
+ right: 0; /* Position it on the right side of the th */
6406
+ top: 50%; /* Position it in the vertical center */
6407
+ height: 50%; /* Set the height of the border to be half the height of th */
6408
+ border-right: 1px solid #c6c7cc;
6409
+ transform: translateY(-50%); /* Center it vertically */
6410
+ }
6411
+ }
6412
+ `;
6413
+ var StyledInput = _styledcomponents2.default.input`
6414
+ height: 100%;
6415
+ width: 100%;
6416
+ outline: none;
6417
+ border: none;
6418
+ color: #8fd8ff;
6419
+ `;
6420
+ var WavelengthDataTable = ({ data, columns, itemsPerPage, totalPages }) => {
6421
+ const [localData, setLocalData] = _react.useState.call(void 0, data || []);
6422
+ const copiedArray = [...data || []];
6423
+ const [editingId, setEditingId] = _react.useState.call(void 0, null);
6424
+ const [editedColumnKey, setEditedColumnKey] = _react.useState.call(void 0, null);
6425
+ const [editedValue, setEditedValue] = _react.useState.call(void 0, "");
6426
+ const [noRowsOpen, setNoRowsOpen] = _react.useState.call(void 0, false);
6427
+ const [isModalOpen, setIsModalOpen] = _react.useState.call(void 0, false);
6428
+ const [searchItem, setSearchItem] = _react.useState.call(void 0, "");
6429
+ const [selectedValue, setSelectedValue] = _react.useState.call(void 0, _optionalChain([columns, 'access', _37 => _37[0], 'optionalAccess', _38 => _38.key]) || "");
6430
+ const [currentPage, setCurrentPage] = _react.useState.call(void 0, 1);
6431
+ const [isOpen, setIsOpen] = _react.useState.call(void 0, false);
6432
+ const [editingMenuKey, setEditingMenuKey] = _react.useState.call(void 0, null);
6433
+ const menuRef = _react.useRef.call(void 0, null);
6434
+ const modalRef = _react.useRef.call(void 0, null);
6435
+ function isNumeric(value) {
6436
+ return /^\d+$/.test(value);
6437
+ }
6438
+ const handleChange = (event) => {
6439
+ setSelectedValue(event.target.value);
6440
+ setLocalData(copiedArray);
6441
+ };
6442
+ _react.useEffect.call(void 0, () => {
6443
+ if (!selectedValue || searchItem === "") {
6444
+ setLocalData(copiedArray);
6445
+ setNoRowsOpen(false);
6446
+ return;
6447
+ }
6448
+ if (isNumeric(searchItem)) {
6449
+ const filteredItems = localData.filter((item) => item[selectedValue].toString().includes(searchItem));
6450
+ setLocalData(filteredItems);
6451
+ if (filteredItems.length === 0) {
6452
+ setNoRowsOpen(true);
6453
+ } else {
6454
+ setNoRowsOpen(false);
6455
+ }
6456
+ } else {
6457
+ const filteredItems = localData.filter((item) => item[selectedValue].toString().toLowerCase().includes(searchItem.toLowerCase()));
6458
+ if (filteredItems.length === 0) {
6459
+ setNoRowsOpen(true);
6460
+ } else {
6461
+ setLocalData(filteredItems);
6462
+ setNoRowsOpen(false);
6463
+ }
6464
+ }
6465
+ }, [selectedValue, searchItem]);
6466
+ const openModal = () => {
6467
+ setIsModalOpen(true);
6468
+ };
6469
+ const closeModal = () => {
6470
+ setIsModalOpen(false);
6471
+ };
6472
+ _react.useEffect.call(void 0, () => {
6473
+ const handleClickOutside = (event) => {
6474
+ if (isModalOpen && modalRef.current && !modalRef.current.contains(event.target)) {
6475
+ closeModal();
6476
+ }
6477
+ };
6478
+ if (isOpen) {
6479
+ document.addEventListener("mousedown", handleClickOutside);
6480
+ }
6481
+ return () => {
6482
+ document.removeEventListener("mousedown", handleClickOutside);
6483
+ };
6484
+ }, [isModalOpen]);
6485
+ const toggleMenu = (key) => {
6486
+ setIsOpen(!isOpen);
6487
+ setEditingMenuKey(key);
6488
+ };
6489
+ const indexOfLastItem = currentPage * itemsPerPage;
6490
+ const indexOfFirstItem = indexOfLastItem - itemsPerPage;
6491
+ const currentPageData = localData.filter((_, index) => index >= indexOfFirstItem && index < indexOfLastItem);
6492
+ const [sortOrder, setSortOrder] = _react.useState.call(void 0, "asc");
6493
+ const handleSort = (column, sortType) => {
6494
+ const sortedItems = [...localData].sort((a, b) => {
6495
+ const valueA = a[column];
6496
+ const valueB = b[column];
6497
+ if (typeof valueA === "string" && typeof valueB === "string") {
6498
+ if (sortType === "asc") {
6499
+ return valueA.localeCompare(valueB);
6500
+ } else {
6501
+ return valueB.localeCompare(valueA);
6502
+ }
6503
+ } else if (typeof valueA === "number" && typeof valueB === "number") {
6504
+ if (sortType === "asc") {
6505
+ return valueA - valueB;
6506
+ } else {
6507
+ return valueB - valueA;
6508
+ }
6509
+ } else {
6510
+ return 0;
6511
+ }
6512
+ });
6513
+ setLocalData(sortedItems);
6514
+ setSortOrder(sortOrder === "asc" ? "desc" : "asc");
6515
+ };
6516
+ const handleEdit = (id, value, columnKey) => {
6517
+ setEditingId(id);
6518
+ setEditedValue(value);
6519
+ setEditedColumnKey(columnKey);
6520
+ };
6521
+ const saveEdit = (id, editedValue2, columnKey) => {
6522
+ setLocalData(localData.map((item) => id === item.id ? { ...item, [columnKey]: editedValue2 } : item));
6523
+ setEditingId(null);
6524
+ };
6525
+ const handleCancel = () => {
6526
+ setEditingId(null);
6527
+ };
6528
+ const headers = columns.map((column, index) => {
6529
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, TableHeadStyle, { children: [
6530
+ column.title,
6531
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, KebabMenu, { ref: menuRef, children: [
6532
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
6533
+ KebabIcon,
6534
+ {
6535
+ title: `KebabIcon-${index}`,
6536
+ onClick: () => {
6537
+ toggleMenu(column.key);
6538
+ },
6539
+ children: "\u22EE"
6540
+ }
6541
+ ),
6542
+ isOpen && editingMenuKey === column.key && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, MenuOptions, { children: [
6543
+ sortOrder === "asc" ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { title: `MenuListASC-${index}`, onClick: () => handleSort(column.key, "asc"), children: [
6544
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "\u2B06" }),
6545
+ " Sort ASC"
6546
+ ] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { title: `MenuListDES-${index}`, onClick: () => handleSort(column.key, "desc"), children: [
6547
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "\u2B07" }),
6548
+ " Sort DESC"
6549
+ ] }),
6550
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { title: `MenuListFilterButton-${index}`, onClick: openModal, children: [
6551
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "\u23F7" }),
6552
+ " Filter"
6553
+ ] }),
6554
+ isModalOpen && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ModalOverlay, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ModalWrapper, { ref: modalRef, children: [
6555
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ModalClose, { title: `ModalClose-${index}`, onClick: closeModal, children: "\xD7" }),
6556
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ModalInputDiv, { children: [
6557
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { htmlFor: "filterSelectId", children: "Columns: " }),
6558
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "select", { title: `filterSelect-${index}`, id: "filterSelectId", value: selectedValue, onChange: handleChange, children: columns.map((item) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { children: item.key }, item.key)) })
6559
+ ] }),
6560
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ModalInputDiv, { children: [
6561
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { htmlFor: "filterInputId", children: "Values: " }),
6562
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
6563
+ "input",
6564
+ {
6565
+ title: `Inputfiltertest-${index}`,
6566
+ id: "filterInputId",
6567
+ type: isNumeric(searchItem) ? "number" : "text",
6568
+ value: searchItem,
6569
+ onKeyDown: (e) => {
6570
+ if (e.key === "Backspace") {
6571
+ setLocalData(copiedArray);
6572
+ }
6573
+ },
6574
+ onChange: (e) => setSearchItem(e.target.value)
6575
+ }
6576
+ )
6577
+ ] })
6578
+ ] }) })
6579
+ ] })
6580
+ ] }, index)
6581
+ ] }, `headCell-${index}`);
6582
+ });
6583
+ const rows = !_optionalChain([currentPageData, 'optionalAccess', _39 => _39.length]) || noRowsOpen ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "tr", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "td", { title: "NoDataRows", colSpan: columns.length, children: "No data" }) }) : _optionalChain([currentPageData, 'optionalAccess', _40 => _40.map, 'call', _41 => _41((item) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "tr", { children: columns.map((column, index2) => {
6584
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, StyledTd, { children: editingId === item.id && editedColumnKey === column.key ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
6585
+ StyledInput,
6586
+ {
6587
+ title: `styledRow-${item.id}-${column.key}-${index2}`,
6588
+ type: "text",
6589
+ value: editedValue,
6590
+ onChange: (e) => setEditedValue(e.target.value),
6591
+ onBlur: () => saveEdit(item.id, editedValue, column.key),
6592
+ onKeyDown: (e) => {
6593
+ if (e.key === "Enter") {
6594
+ saveEdit(item.id, editedValue, column.key);
6595
+ } else if (e.key === "Escape") {
6596
+ handleCancel();
6597
+ }
6598
+ },
6599
+ autoFocus: true
6600
+ }
6601
+ ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { title: `spanRow-${item.id}-${column.key}-${index2}`, onDoubleClick: () => handleEdit(item.id, item[column.key], column.key), children: item[column.key] }) }, index2);
6602
+ }) }, item.id))]);
6603
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
6604
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, StyledBoxDiv, { title: "StyledBoxDiv", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, StyledTableTwo, { title: "StyledTable", children: [
6605
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "thead", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "tr", { children: headers }) }),
6606
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "tbody", { children: rows })
6607
+ ] }) }),
6608
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, StyledNavBoxDiv, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WavelengthPagination_default, { totalPages, currentPageNumber: currentPage, onPageChange: setCurrentPage, style: "circular" }) })
6609
+ ] });
6610
+ };
6611
+
6612
+
6250
6613
 
6251
6614
 
6252
6615
 
@@ -6293,7 +6656,7 @@ function WavelengthTextField(props) {
6293
6656
 
6294
6657
 
6295
6658
 
6296
- exports.AppLogo = AppLogo; exports.ButtonIcon = ButtonIcon; exports.ButtonMenu = ButtonMenu; exports.DefaultCarousel = DefaultCarousel; exports.DefaultIcon = DefaultIcon; exports.DefaultPagination = DefaultPagination; exports.ManyPlanesComponent = ManyPlanesComponent; exports.NotAvailablePage = NotAvailablePage; exports.SearchTextField = SearchTextField; exports.SliderCardCarousel = SliderCardCarousel; exports.TestSnackbar = TestSnackbar; exports.WavelengthAppTheme = WavelengthAppTheme; exports.WavelengthAutocomplete = WavelengthAutocomplete; exports.WavelengthBanner = WavelengthBanner2; exports.WavelengthBox = WavelengthBox; exports.WavelengthButton = WavelengthButton; exports.WavelengthCommentDisplay = WavelengthCommentDisplay; exports.WavelengthConfirmationModal = WavelengthConfirmationModal; exports.WavelengthContentModal = WavelengthContentModal; exports.WavelengthContentPlaceholder = WavelengthContentPlaceholder; exports.WavelengthDragAndDrop = WavelengthDragAndDrop; exports.WavelengthDropdown = WavelengthDropdown; exports.WavelengthDropdownButton = WavelengthDropdownButton; exports.WavelengthExampleComponent = WavelengthExampleComponent; exports.WavelengthFileDownloader = WavelengthFileDownloader; exports.WavelengthFooter = WavelengthFooter; exports.WavelengthPlaneTrail = WavelengthPlaneTrail; exports.WavelengthPopUpMenu = WavelengthPopUpMenu; exports.WavelengthProgressBar = WavelengthProgressBar; exports.WavelengthSearch = WavelengthSearch; exports.WavelengthSideBar = WavelengthSideBar; exports.WavelengthSlider = WavelengthSlider; exports.WavelengthSnackbar = WavelengthSnackbar; exports.WavelengthSpinningLogo = WavelengthSpinningLogo; exports.WavelengthSpinningOuterCircle = WavelengthSpinningOuterCircle; exports.WavelengthStandardSnackbar = WavelengthStandardSnackbar; exports.WavelengthStyledButton = WavelengthStyledButton; exports.WavelengthTextField = WavelengthTextField; exports.WavelengthTitleBar = WavelengthTitleBar2; exports.add = add; exports.ascendingRange = ascendingRange; exports.concat = concat; exports.findBestStringMatch = findBestStringMatch; exports.range = range; exports.useOutsideClick = useOutsideClick; exports.useThemeContext = useThemeContext;
6659
+ exports.AppLogo = AppLogo; exports.ButtonIcon = ButtonIcon; exports.ButtonMenu = ButtonMenu; exports.DefaultCarousel = DefaultCarousel; exports.DefaultIcon = DefaultIcon; exports.DefaultPagination = DefaultPagination; exports.ManyPlanesComponent = ManyPlanesComponent; exports.NotAvailablePage = NotAvailablePage; exports.SearchTextField = SearchTextField; exports.SliderCardCarousel = SliderCardCarousel; exports.TestSnackbar = TestSnackbar; exports.WavelengthAppTheme = WavelengthAppTheme; exports.WavelengthAutocomplete = WavelengthAutocomplete; exports.WavelengthBanner = WavelengthBanner2; exports.WavelengthBox = WavelengthBox; exports.WavelengthButton = WavelengthButton; exports.WavelengthCommentDisplay = WavelengthCommentDisplay; exports.WavelengthConfirmationModal = WavelengthConfirmationModal; exports.WavelengthContentModal = WavelengthContentModal; exports.WavelengthContentPlaceholder = WavelengthContentPlaceholder; exports.WavelengthDataTable = WavelengthDataTable; exports.WavelengthDragAndDrop = WavelengthDragAndDrop; exports.WavelengthDropdown = WavelengthDropdown; exports.WavelengthDropdownButton = WavelengthDropdownButton; exports.WavelengthExampleComponent = WavelengthExampleComponent; exports.WavelengthFileDownloader = WavelengthFileDownloader; exports.WavelengthFooter = WavelengthFooter; exports.WavelengthPlaneTrail = WavelengthPlaneTrail; exports.WavelengthPopUpMenu = WavelengthPopUpMenu; exports.WavelengthProgressBar = WavelengthProgressBar; exports.WavelengthSearch = WavelengthSearch; exports.WavelengthSideBar = WavelengthSideBar; exports.WavelengthSlider = WavelengthSlider; exports.WavelengthSnackbar = WavelengthSnackbar; exports.WavelengthSpinningLogo = WavelengthSpinningLogo; exports.WavelengthSpinningOuterCircle = WavelengthSpinningOuterCircle; exports.WavelengthStandardSnackbar = WavelengthStandardSnackbar; exports.WavelengthStyledButton = WavelengthStyledButton; exports.WavelengthTextField = WavelengthTextField; exports.WavelengthTitleBar = WavelengthTitleBar2; exports.add = add; exports.ascendingRange = ascendingRange; exports.concat = concat; exports.findBestStringMatch = findBestStringMatch; exports.range = range; exports.useOutsideClick = useOutsideClick; exports.useThemeContext = useThemeContext;
6297
6660
  /*! Bundled license information:
6298
6661
 
6299
6662
  react-is/cjs/react-is.production.min.js: