@cwellt_software/cwellt-reactjs-lib 1.0.3 → 1.0.5

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.
Files changed (56) hide show
  1. package/dist/content/icons/new-cw-icons/NewCwIcons.html +390 -6
  2. package/dist/content/icons/new-cw-icons/NewCwIcons.json +1 -1
  3. package/dist/content/icons/new-cw-icons/css/new-cw-icons.css +20 -6
  4. package/dist/content/icons/new-cw-icons/fonts/NewCwIcons.woff +0 -0
  5. package/dist/index.cjs.js +653 -356
  6. package/dist/index.css +2 -2
  7. package/dist/index.d.ts +284 -134
  8. package/dist/index.es.js +658 -351
  9. package/dist/src/common/functions/colorManipulation.d.ts.map +1 -1
  10. package/dist/src/components/control/action/button/CwButton.d.ts +3 -2
  11. package/dist/src/components/control/action/button/CwButton.d.ts.map +1 -1
  12. package/dist/src/components/control/action/buttons/CwButtons.d.ts +0 -11
  13. package/dist/src/components/control/action/buttons/CwButtons.d.ts.map +1 -1
  14. package/dist/src/components/control/action/contextmenu/CwContextMenu.d.ts +4 -0
  15. package/dist/src/components/control/action/contextmenu/CwContextMenu.d.ts.map +1 -1
  16. package/dist/src/components/control/action/search/CwSearch.d.ts +1 -1
  17. package/dist/src/components/control/action/search/CwSearch.d.ts.map +1 -1
  18. package/dist/src/components/control/choice/dropdown/CwDropdown.d.ts +2 -2
  19. package/dist/src/components/control/choice/dropdown/CwDropdown.d.ts.map +1 -1
  20. package/dist/src/components/control/choice/multi-filter/CwMultiFilter.d.ts +122 -33
  21. package/dist/src/components/control/choice/multi-filter/CwMultiFilter.d.ts.map +1 -1
  22. package/dist/src/components/control/choice/toggle/CwToggle.d.ts +0 -4
  23. package/dist/src/components/control/choice/toggle/CwToggle.d.ts.map +1 -1
  24. package/dist/src/components/control/input/any/CwInput.d.ts.map +1 -1
  25. package/dist/src/components/control/input/number/CwInputNumber.d.ts.map +1 -1
  26. package/dist/src/components/custom/scheduler/CwSchedulerComp.d.ts.map +1 -1
  27. package/dist/src/components/custom/scheduler-new/presentation/NewScheduler.d.ts.map +1 -1
  28. package/dist/src/components/custom/scheduler-new/presentation/components/row/BackgroundEvent.d.ts +0 -1
  29. package/dist/src/components/custom/scheduler-new/presentation/components/row/BackgroundEvent.d.ts.map +1 -1
  30. package/dist/src/components/custom/scheduler-new/presentation/components/row/DefaultRowHeader.d.ts.map +1 -1
  31. package/dist/src/components/custom/scheduler-new/presentation/components/row/Event.d.ts +1 -0
  32. package/dist/src/components/custom/scheduler-new/presentation/components/row/Event.d.ts.map +1 -1
  33. package/dist/src/components/custom/super-scheduler/PinRowHeader.d.ts.map +1 -1
  34. package/dist/src/components/display/data/accordion/CwAccordionContainer.d.ts.map +1 -1
  35. package/dist/src/components/display/data/generic_tooltip/CwGenericTooltip.d.ts +1 -0
  36. package/dist/src/components/display/data/generic_tooltip/CwGenericTooltip.d.ts.map +1 -1
  37. package/dist/src/components/display/data/table/CwTable.d.ts +48 -63
  38. package/dist/src/components/display/data/table/CwTable.d.ts.map +1 -1
  39. package/dist/src/components/display/graphics/loading/CwLoading.d.ts +39 -9
  40. package/dist/src/components/display/graphics/loading/CwLoading.d.ts.map +1 -1
  41. package/dist/src/components/display/graphics/loading-small/CwLoadingSmall.d.ts +13 -1
  42. package/dist/src/components/display/graphics/loading-small/CwLoadingSmall.d.ts.map +1 -1
  43. package/dist/src/components/display/text/tag/CwTag.d.ts +2 -2
  44. package/dist/src/components/display/text/tag/CwTag.d.ts.map +1 -1
  45. package/dist/src/components/layout/dialog/CwDialog.d.ts +15 -4
  46. package/dist/src/components/layout/dialog/CwDialog.d.ts.map +1 -1
  47. package/dist/src/components/layout/list/key-value/CwKeyValueList.d.ts +33 -0
  48. package/dist/src/components/layout/list/key-value/CwKeyValueList.d.ts.map +1 -0
  49. package/dist/src/components/layout/modal/CwModalReportFunctional.d.ts +2 -2
  50. package/dist/src/components/layout/modal/CwModalReportFunctional.d.ts.map +1 -1
  51. package/dist/src/components/layout/modal/legacy/cw_modal_report.d.ts.map +1 -1
  52. package/dist/src/components/layout/tabs/CwTabs.d.ts +2 -1
  53. package/dist/src/components/layout/tabs/CwTabs.d.ts.map +1 -1
  54. package/dist/src/index.d.ts +3 -2
  55. package/dist/src/index.d.ts.map +1 -1
  56. package/package.json +1 -1
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
- import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
- import React__default, { useEffect, useState, useRef, useMemo, useCallback, forwardRef, useImperativeHandle, createElement, memo, Fragment, Component } from 'react';
3
+ import React__default, { useEffect, useState, useRef, useMemo, useCallback, forwardRef, useImperativeHandle, createElement, memo, Fragment as Fragment$1, Component } from 'react';
4
4
  import { createRoot } from 'react-dom/client';
5
5
  import { createPortal } from 'react-dom';
6
6
  import { Tooltip, Modal, InputNumber, Select, Tag, Dropdown, Menu } from 'antd';
@@ -120,17 +120,17 @@ function CwTooltip(CwelltTooltipProps) {
120
120
  function CwTag(tagProps) {
121
121
  const hideTag = (event_clickTag) => {
122
122
  const tag = event_clickTag.currentTarget.parentElement;
123
- tag.classList.add("cwellt_display_none");
123
+ tag?.classList.add("cwellt_display_none");
124
124
  };
125
125
  const onClickClosableCustomTag = (event_clickClosableT) => {
126
126
  hideTag(event_clickClosableT);
127
- if (typeof tagProps.onClickClosableTag === "function") {
127
+ if (tagProps.onClickClosableTag != undefined) {
128
128
  tagProps.onClickClosableTag(event_clickClosableT);
129
129
  }
130
130
  };
131
131
  const onClickCustomTag = (event_clickTag) => {
132
132
  // click option interface
133
- if (typeof tagProps.onClickTag === "function") {
133
+ if (tagProps.onClickTag !== undefined) {
134
134
  tagProps.onClickTag(event_clickTag);
135
135
  }
136
136
  };
@@ -222,30 +222,53 @@ function CwDisplayMessage(message, type, duration) {
222
222
  CwMessageManager.getInstance().showMessage(message, type, duration);
223
223
  }
224
224
 
225
- function CwLoading(props) {
226
- return (jsx("div", { children: jsxs("div", { "aria-busy": props.cwelltBooleanLoading, className: props.cwelltBooleanLoading === true
227
- ? "cwellt_flex cwellt_flex_column cwelltContentLoading " +
228
- (props.cwelltClassNameContentLoading === undefined ? "" : props.cwelltClassNameContentLoading)
229
- : "", children: [props.cwelltBooleanLoading === true ? (
230
- // Container loading [ Icon and text of loading here is the property: cwelltClassNameLoading to custom orientation Vertical or Horizontal ]
231
- jsxs("div", { className: props.cwelltClassNameLoading === undefined
232
- ? "cwelltContainerLoading cwellt_flex cwellt_justify_center cwellt_align_items_center cwellt_flex_wrap "
233
- : props.cwelltClassNameLoading +
234
- " cwelltContainerLoading cwellt_flex cwellt_justify_center cwellt_align_items_center cwellt_flex_wrap", children: [jsx("div", { className: props.cwelltSizeLoading === undefined
235
- ? "cwelltDefaultLoadingSize cwellt_loading cwellt_flex cwellt_align_items_center "
236
- : props.cwelltSizeLoading +
237
- " cwelltDefaultLoadingSize cwellt_loading cwellt_flex cwellt_align_items_center ", children: jsx("span", { className: "cwelltIconLoading cwellt_flex cwellt_justify_center cwellt_align_items_center" }) }), jsx("div", { className: "cwelltTextLoading", children: jsx("h1", { children: props.cwelltTextLoading }) })] })) : (jsx("div", {})), jsx("div", { className: props.cwelltBooleanLoading === true ? "cwelltContentLoadingDisabled" : "", children: props.children })] }) }));
225
+ /**
226
+ * CwLoading
227
+ *
228
+ * A versatile loading component that shows a spinner with optional text
229
+ * and disables the wrapped content while in loading state.
230
+ *
231
+ * @example
232
+ * // Basic usage
233
+ * <CwLoading isLoading={isSubmitting}>
234
+ * <form>...</form>
235
+ * </CwLoading>
236
+ *
237
+ * // With custom text and size
238
+ * <CwLoading
239
+ * isLoading={isLoading}
240
+ * text="Please wait..."
241
+ * size="large"
242
+ * >
243
+ * <UserProfile />
244
+ * </CwLoading>
245
+ */
246
+ function CwLoading({ isLoading = false, text = '', size = 'regular', iconPosition = 'outside', iconName = 'cwi-plane-solid', animation = 'spin', children }) {
247
+ const iconClasses = `cwi-icons ${iconName || ''}`;
248
+ return (jsxs("div", { "aria-busy": isLoading, className: isLoading ? 'cw-loading-container' : '', children: [isLoading && (jsxs("div", { className: "cw-loading-content", "data-size": size, "data-animation": animation, children: [jsx("div", { className: "cw-loading", "data-icon-position": iconPosition, children: jsx("span", { className: iconClasses }) }), text && (jsx("p", { children: text }))] })), jsx("div", { className: isLoading ? 'cw-loading-disabled-content' : '', children: children })] }));
238
249
  }
239
250
 
251
+ /**
252
+ * @deprecated since may 2025. Use <CwLoading size="small"> instead.
253
+ *
254
+ * This component will be removed in a future release.
255
+ *
256
+ * @example
257
+ * // Instead of:
258
+ * <CwLoadingSmall />
259
+ *
260
+ * // Use:
261
+ * <CwLoading size="small" />
262
+ */
240
263
  function CwLoadingSmall(CwelltLoadingAppointements) {
241
- return (jsx("div", { children: CwelltLoadingAppointements.cwelltBooleanLoadingAppointment === true ? (
264
+ return (jsx("div", { children: CwelltLoadingAppointements.isLoading === true ? (
242
265
  // * Show loading appointment
243
- jsx("div", { className: "cwellt_loadingAppointmentContainer cwellt_loading cwellt_flex cwellt_align_items_center cwellt_loading cwellt_flex cwellt_align_items_center ", children: jsx("span", { className: "cwelltIconLoading cwellt_flex cwellt_justify_center cwellt_align_items_center" }) })) : (
266
+ jsx("div", { className: "cw-loading-container", children: jsx("div", { className: "cw-loading" }) })) : (
244
267
  // Show empty div
245
- jsx("div", { className: "cwellt_d_none" })) }));
268
+ jsx("div", {})) }));
246
269
  }
247
270
 
248
- var styles$a = {"cw-generic-tooltip":"cw-generic-tooltip-module_cw-generic-tooltip__Ij76M","cw-generic-tooltip-content":"cw-generic-tooltip-module_cw-generic-tooltip-content__la-Si"};
271
+ var styles$b = {"cw-generic-tooltip-content":"cw-generic-tooltip-module_cw-generic-tooltip-content__la-Si"};
249
272
 
250
273
  // Constants moved outside to prevent recreation
251
274
  const margin = 16;
@@ -350,23 +373,25 @@ const useTooltipPosition = (isVisible, containerRef, preferredPosition, tooltipC
350
373
  return tooltipState;
351
374
  };
352
375
  // Main component with optimizations
353
- const CwGenericTooltip = ({ children, content = null, position = defaultPosition, dissapearsWhenHover = false, overlayStyle = {}, showDelay = 0, }) => {
376
+ const CwGenericTooltip = ({ children, content = null, position = defaultPosition, dissapearsWhenHover = false, hide = false, overlayStyle = {}, showDelay = 0, }) => {
354
377
  const [isVisible, setIsVisible] = useState(false);
355
378
  const containerRef = useRef(null);
356
- const { setTooltipTimeout, clearTooltipTimeout } = useTooltipDelay(() => setIsVisible(true), showDelay);
357
- const { position: tooltipPosition, actualPosition } = useTooltipPosition(isVisible, containerRef, position, styles$a["cw-generic-tooltip-content"]);
379
+ const { setTooltipTimeout, clearTooltipTimeout } = useTooltipDelay(() => {
380
+ setIsVisible(true);
381
+ }, showDelay);
382
+ const { position: tooltipPosition, actualPosition } = useTooltipPosition(isVisible, containerRef, position, styles$b["cw-generic-tooltip-content"]);
358
383
  // Memoize tooltip content creation
359
384
  const tooltipContent = useMemo(() => {
360
- if (!isVisible || !content)
385
+ if (hide || !isVisible || !content)
361
386
  return null;
362
- return createPortal(jsx("div", { className: styles$a["cw-generic-tooltip-content"], "data-position": actualPosition, "data-visible": isVisible, style: {
387
+ return createPortal(jsx("div", { className: styles$b["cw-generic-tooltip-content"], "data-position": actualPosition, "data-visible": isVisible, style: {
363
388
  position: 'fixed',
364
389
  top: `${tooltipPosition.top}px`,
365
390
  left: `${tooltipPosition.left}px`,
366
391
  visibility: tooltipPosition.top === 0 && tooltipPosition.left === 0 ? 'hidden' : 'visible',
367
392
  ...overlayStyle
368
393
  }, onMouseEnter: () => dissapearsWhenHover && setIsVisible(false), children: content }), document.body);
369
- }, [isVisible, content, actualPosition, tooltipPosition, dissapearsWhenHover, overlayStyle]);
394
+ }, [isVisible, content, actualPosition, tooltipPosition, dissapearsWhenHover, overlayStyle, hide]);
370
395
  const handleMouseEnter = useCallback(() => {
371
396
  setTooltipTimeout();
372
397
  }, [setTooltipTimeout]);
@@ -374,7 +399,7 @@ const CwGenericTooltip = ({ children, content = null, position = defaultPosition
374
399
  clearTooltipTimeout();
375
400
  setIsVisible(false);
376
401
  }, [clearTooltipTimeout]);
377
- return (jsxs("div", { ref: containerRef, className: styles$a["cw-generic-tooltip"], onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: overlayStyle, children: [tooltipContent, children] }));
402
+ return (jsxs("div", { ref: containerRef, className: styles$b["cw-generic-tooltip"], onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: overlayStyle, children: [tooltipContent, children] }));
378
403
  };
379
404
 
380
405
  // Reference for draggable modal
@@ -493,19 +518,107 @@ class CwModalIframe extends React.Component {
493
518
  }
494
519
  }
495
520
 
496
- var styles$9 = {"cw-dialog-main":"cw-dialog-module_cw-dialog-main__cHxHt","cw-dialog-button-close":"cw-dialog-module_cw-dialog-button-close__9GRd8","cw-dialog-button-save":"cw-dialog-module_cw-dialog-button-save__eZ9SI"};
521
+ var styles$a = {"cw-dialog-main":"cw-dialog-module_cw-dialog-main__cHxHt","cw-dialog-button-close":"cw-dialog-module_cw-dialog-button-close__9GRd8"};
497
522
 
523
+ // Helper function to parse size values
524
+ const parseSize = (size) => {
525
+ if (typeof size === 'number')
526
+ return { value: size, unit: 'px' };
527
+ // Match numeric value and unit
528
+ const match = String(size).match(/^([\d.]+)(\D+)$/);
529
+ if (match) {
530
+ const unit = match[2];
531
+ // Only allow px, rem, vw, vh
532
+ if (['px', 'rem', 'vw', 'vh'].includes(unit)) {
533
+ return { value: parseFloat(match[1]), unit };
534
+ }
535
+ }
536
+ // Default to pixels if no unit specified or unit not supported
537
+ return { value: parseFloat(String(size)), unit: 'px' };
538
+ };
539
+ // Helper to convert size to px for calculations
540
+ const convertToPx = (size) => {
541
+ switch (size.unit) {
542
+ case 'px': return size.value;
543
+ case 'rem': return size.value * 16; // Assuming 1rem = 16px
544
+ case 'vh': return (window.innerHeight * size.value) / 100;
545
+ case 'vw': return (window.innerWidth * size.value) / 100;
546
+ default: return size.value; // Default fallback
547
+ }
548
+ };
549
+ // Function to convert from px back to original unit
550
+ const convertFromPx = (px, unit) => {
551
+ switch (unit) {
552
+ case 'px': return px;
553
+ case 'rem': return px / 16;
554
+ case 'vh': return (px * 100) / window.innerHeight;
555
+ case 'vw': return (px * 100) / window.innerWidth;
556
+ default: return px;
557
+ }
558
+ };
498
559
  const CwDialog = props => {
560
+ const { customFooter, customHeader, headline, width, height, dialogSize, scrim, onSave, onClose, hideFooter, children, open, ...domProps } = props;
499
561
  const dialogRef = useRef(null);
500
- const initialDialogSize = { width: props.dialogSize?.width ?? 800, height: props.dialogSize?.height ?? 600 };
562
+ const initialSetup = useMemo(() => {
563
+ // Default width and height with units
564
+ const defaultWidth = 800;
565
+ // Priority: direct props > dialogSize > default values
566
+ const initialWidth = width !== undefined
567
+ ? width
568
+ : dialogSize?.width !== undefined
569
+ ? dialogSize.width
570
+ : defaultWidth;
571
+ const initialHeight = height !== undefined
572
+ ? height
573
+ : dialogSize?.height !== undefined
574
+ ? dialogSize.height
575
+ : undefined; // Undefined for autoHeight
576
+ // Determine if height is automatic when height is not provided
577
+ const isAutoHeight = initialHeight === undefined;
578
+ // Parse the sizes to separate value and unit
579
+ const parsedWidth = parseSize(initialWidth);
580
+ const parsedHeight = isAutoHeight
581
+ ? { value: 0, unit: 'auto' }
582
+ : parseSize(initialHeight);
583
+ // Convert to px for internal calculations
584
+ const initialWidthPx = convertToPx(parsedWidth);
585
+ const initialHeightPx = isAutoHeight ? 0 : convertToPx(parsedHeight);
586
+ // Use estimated height for initial positioning when autoHeight is true
587
+ const initialEstimatedHeight = isAutoHeight ? 300 : initialHeightPx;
588
+ const initialDialogSize = {
589
+ width: initialWidthPx,
590
+ height: initialHeightPx,
591
+ widthUnit: parsedWidth.unit,
592
+ heightUnit: parsedHeight.unit,
593
+ autoHeight: isAutoHeight
594
+ };
595
+ const initialPosition = {
596
+ x: window.document.body.clientWidth / 2 - initialWidthPx / 2,
597
+ y: window.document.body.clientHeight / 2 - initialEstimatedHeight / 2
598
+ };
599
+ return { initialDialogSize, initialPosition };
600
+ }, [width, height, dialogSize]); // Only recalculate when these props change
501
601
  const [isDragging, setIsDragging] = useState(false);
502
602
  const [resizeDirection, setResizeDirection] = useState(null);
503
- const [position, setPosition] = useState({
504
- x: window.document.body.clientWidth / 2 - initialDialogSize.width / 2,
505
- y: window.document.body.clientHeight / 2 - initialDialogSize.height / 2
506
- });
507
- const [size, setSize] = useState(initialDialogSize);
603
+ const [position, setPosition] = useState(initialSetup.initialPosition);
604
+ const [size, setSize] = useState(initialSetup.initialDialogSize);
508
605
  const [dragStart, setDragStart] = useState({ x: 0, y: 0 });
606
+ // scrim is true by default
607
+ const hasScrim = scrim !== false;
608
+ // Adjust position after the dialog is rendered when using autoHeight
609
+ useEffect(() => {
610
+ if (size.autoHeight && dialogRef.current && open) {
611
+ // Get the actual height after rendering
612
+ const actualHeight = dialogRef.current.offsetHeight;
613
+ // Only update position if height is available
614
+ if (actualHeight > 0) {
615
+ setPosition(prevPos => ({
616
+ ...prevPos,
617
+ y: window.document.body.clientHeight / 2 - actualHeight / 2
618
+ }));
619
+ }
620
+ }
621
+ }, [size.autoHeight, open]);
509
622
  useEffect(() => {
510
623
  const handleMouseMove = (e) => {
511
624
  if (isDragging) {
@@ -535,26 +648,40 @@ const CwDialog = props => {
535
648
  let newY = position.y;
536
649
  const minVisiblePx = 64;
537
650
  const minSize = 100;
538
- if (resizeDirection.includes("w")) {
539
- const dx = e.clientX - position.x;
540
- newWidth = Math.max(size.width - dx, minSize);
541
- newX = Math.min(Math.max(position.x + dx, minVisiblePx - newWidth), position.x + size.width - minSize);
542
- }
543
- if (resizeDirection.includes("e")) {
544
- newWidth = Math.min(Math.max(e.clientX - position.x, minSize), parentRect.width - position.x + dialogRect.width - minVisiblePx);
651
+ // Only allow horizontal resizing if autoHeight is true
652
+ if (!size.autoHeight || (!resizeDirection.includes("n") && !resizeDirection.includes("s"))) {
653
+ // Logic for horizontal resizing
654
+ if (resizeDirection.includes("w")) {
655
+ const dx = e.clientX - position.x;
656
+ newWidth = Math.max(size.width - dx, minSize);
657
+ newX = Math.min(Math.max(position.x + dx, minVisiblePx - newWidth), position.x + size.width - minSize);
658
+ }
659
+ if (resizeDirection.includes("e")) {
660
+ newWidth = Math.min(Math.max(e.clientX - position.x, minSize), parentRect.width - position.x + dialogRect.width - minVisiblePx);
661
+ }
545
662
  }
546
- if (resizeDirection.includes("n")) {
547
- const dy = e.clientY - position.y;
548
- newHeight = Math.max(size.height - dy, minSize);
549
- newY = Math.min(Math.max(position.y + dy, minVisiblePx - newHeight), position.y + size.height - minSize);
550
- }
551
- if (resizeDirection.includes("s")) {
552
- newHeight = Math.min(Math.max(e.clientY - position.y, minSize), parentRect.height - position.y + dialogRect.height - minVisiblePx);
663
+ // Only apply vertical resizing if autoHeight is false
664
+ if (!size.autoHeight) {
665
+ if (resizeDirection.includes("n")) {
666
+ const dy = e.clientY - position.y;
667
+ newHeight = Math.max(size.height - dy, minSize);
668
+ newY = Math.min(Math.max(position.y + dy, minVisiblePx - newHeight), position.y + size.height - minSize);
669
+ }
670
+ if (resizeDirection.includes("s")) {
671
+ newHeight = Math.min(Math.max(e.clientY - position.y, minSize), parentRect.height - position.y + dialogRect.height - minVisiblePx);
672
+ }
553
673
  }
554
674
  // Ensure the modal stays within bounds after resizing
555
675
  newX = Math.min(Math.max(newX, minVisiblePx - newWidth), parentRect.width - minVisiblePx);
556
676
  newY = Math.min(Math.max(newY, minVisiblePx - newHeight), parentRect.height - minVisiblePx);
557
- setSize({ width: newWidth, height: newHeight });
677
+ // Update state maintaining original units
678
+ setSize({
679
+ width: newWidth,
680
+ height: newHeight,
681
+ widthUnit: size.widthUnit,
682
+ heightUnit: size.heightUnit,
683
+ autoHeight: size.autoHeight
684
+ });
558
685
  setPosition({ x: newX, y: newY });
559
686
  }
560
687
  }
@@ -571,38 +698,54 @@ const CwDialog = props => {
571
698
  document.removeEventListener("mouseup", handleMouseUp);
572
699
  };
573
700
  }, [isDragging, resizeDirection, dragStart, position, size]);
574
- const handleMouseDown = (e) => {
701
+ const handleMouseDown = useCallback((e) => {
575
702
  setIsDragging(true);
576
703
  setDragStart({ x: e.clientX - position.x, y: e.clientY - position.y });
577
- };
578
- const handleResizeMouseDown = (direction) => (e) => {
704
+ }, [position]);
705
+ const handleResizeMouseDown = useCallback((direction) => (e) => {
579
706
  e.stopPropagation();
580
707
  setResizeDirection(direction);
581
- };
582
- const header = (jsxs("header", { onMouseDown: handleMouseDown, children: [jsx("span", { children: props.headline }), props.customHeader || (jsx("button", { className: styles$9["cw-dialog-button-close"], onClick: props.onClose, children: "\u2A2F" }))] }));
583
- const content = (jsx("section", { style: { flex: 1, overflowX: "auto", overflowY: "auto", width: "100%" }, children: props.children }));
584
- const footer = (jsx("footer", { style: { width: "100%" }, children: props.customFooter || (jsx("button", { className: styles$9["cw-dialog-button-save"], onClick: props.onSave, children: "\uD83D\uDDAB" })) }));
585
- const resizeHandles = [
586
- jsx("div", { "data-handle-n": true, onMouseDown: handleResizeMouseDown("n") }, "handle-n"),
587
- jsx("div", { "data-handle-s": true, onMouseDown: handleResizeMouseDown("s") }, "handle-s"),
588
- jsx("div", { "data-handle-e": true, onMouseDown: handleResizeMouseDown("e") }, "handle-e"),
589
- jsx("div", { "data-handle-w": true, onMouseDown: handleResizeMouseDown("w") }, "handle-w"),
590
- jsx("div", { "data-handle-ne": true, onMouseDown: handleResizeMouseDown("ne") }, "handle-ne"),
591
- jsx("div", { "data-handle-nw": true, onMouseDown: handleResizeMouseDown("nw") }, "handle-nw"),
592
- jsx("div", { "data-handle-se": true, onMouseDown: handleResizeMouseDown("se") }, "handle-se"),
593
- jsx("div", { "data-handle-sw": true, onMouseDown: handleResizeMouseDown("sw") }, "handle-sw")
594
- ];
595
- return (props.open && (jsx("div", { "data-has-scrim": props.scrim, className: styles$9["cw-dialog-main"], children: jsxs("dialog", { ...props, ref: dialogRef, style: {
708
+ }, []);
709
+ const handleScrimClick = useCallback((e) => {
710
+ if (e.target === e.currentTarget && onClose) {
711
+ onClose();
712
+ }
713
+ }, [onClose]);
714
+ const header = useMemo(() => (jsxs("header", { onMouseDown: handleMouseDown, children: [jsx("span", { children: headline }), customHeader || (jsx("button", { className: styles$a["cw-dialog-button-close"], onClick: onClose }))] })), [handleMouseDown, headline, customHeader, onClose]);
715
+ const content = useMemo(() => (jsx("section", { children: children })), [children]);
716
+ const footer = useMemo(() => (jsx("footer", { children: customFooter || (jsx("button", { className: "cw-button-icon cwi-save", onClick: onSave })) })), [customFooter, onSave]);
717
+ const resizeHandles = useMemo(() => size.autoHeight
718
+ ? [
719
+ // Only horizontal handles if autoHeight is true
720
+ jsx("div", { "data-handle-e": true, onMouseDown: handleResizeMouseDown("e") }, "handle-e"),
721
+ jsx("div", { "data-handle-w": true, onMouseDown: handleResizeMouseDown("w") }, "handle-w")
722
+ ]
723
+ : [
724
+ // All handles if autoHeight is false
725
+ jsx("div", { "data-handle-n": true, onMouseDown: handleResizeMouseDown("n") }, "handle-n"),
726
+ jsx("div", { "data-handle-s": true, onMouseDown: handleResizeMouseDown("s") }, "handle-s"),
727
+ jsx("div", { "data-handle-e": true, onMouseDown: handleResizeMouseDown("e") }, "handle-e"),
728
+ jsx("div", { "data-handle-w": true, onMouseDown: handleResizeMouseDown("w") }, "handle-w"),
729
+ jsx("div", { "data-handle-ne": true, onMouseDown: handleResizeMouseDown("ne") }, "handle-ne"),
730
+ jsx("div", { "data-handle-nw": true, onMouseDown: handleResizeMouseDown("nw") }, "handle-nw"),
731
+ jsx("div", { "data-handle-se": true, onMouseDown: handleResizeMouseDown("se") }, "handle-se"),
732
+ jsx("div", { "data-handle-sw": true, onMouseDown: handleResizeMouseDown("sw") }, "handle-sw")
733
+ ], [size.autoHeight, handleResizeMouseDown]);
734
+ const displayDimensions = useMemo(() => {
735
+ // Prepare width and height with original units for display
736
+ const displayWidth = `${convertFromPx(size.width, size.widthUnit)}${size.widthUnit}`;
737
+ // If autoHeight, don't specify height and let it adapt to content
738
+ const displayHeight = size.autoHeight
739
+ ? 'auto'
740
+ : `${convertFromPx(size.height, size.heightUnit)}${size.heightUnit}`;
741
+ return { displayWidth, displayHeight };
742
+ }, [size.width, size.height, size.widthUnit, size.heightUnit, size.autoHeight]);
743
+ return (open && (jsx("div", { "data-has-scrim": hasScrim, className: styles$a["cw-dialog-main"], onClick: handleScrimClick, children: jsxs("dialog", { ...domProps, ref: dialogRef, style: {
596
744
  left: `${position.x}px`,
597
745
  top: `${position.y}px`,
598
- width: `${size.width}px`,
599
- height: `${size.height}px`,
600
- zIndex: props.zIndex,
601
- minWidth: "200px", // Set an appropriate minimum size
602
- minHeight: "200px", // Set an appropriate minimum size
603
- display: "flex",
604
- flexDirection: "column"
605
- }, children: [header, content, props.isReport !== true && footer, resizeHandles] }) })));
746
+ width: displayDimensions.displayWidth,
747
+ height: displayDimensions.displayHeight
748
+ }, children: [header, content, hideFooter !== true && footer, resizeHandles] }) })));
606
749
  };
607
750
 
608
751
  const CwModalReportFunctional = (props) => {
@@ -623,7 +766,9 @@ const CwModalReportFunctional = (props) => {
623
766
  return (jsxs("div", { children: ["Please add a(n) ", props.reportName, " report in ", props.moduleSettings, " Settings"] }));
624
767
  }
625
768
  };
626
- return (jsx("div", { id: "cwelltModalReportContent", children: isModal ? (jsx(CwDialog, { open: props.visible, dialogSize: { width: props.width, height: props.height }, headline: props.title, customFooter: [jsx("div", {}, "footer")], onClose: props.onCloseModal, isReport: true, children: renderContentModal() })) : (jsx("div", { children: renderContentNotModal() })) }));
769
+ return (jsx("div", { id: "cwelltModalReportContent", children: isModal ? (jsx(CwDialog, { open: props.visible, width: props.width, headline: props.title,
770
+ //customFooter={[<div key="footer"></div>]}
771
+ onClose: props.onCloseModal, hideFooter: true, children: renderContentModal() })) : (jsx("div", { children: renderContentNotModal() })) }));
627
772
  };
628
773
 
629
774
  class CwReportModal extends React.Component {
@@ -643,10 +788,10 @@ class CwReportModal extends React.Component {
643
788
  };
644
789
  }
645
790
  render() {
646
- return (jsx("div", { id: "cwelltModalReportContent", children: this.state.isModal === true ? (jsxs(CwDialog, { open: this.props.visible, dialogSize: { width: this.props.width, height: this.props.height }, headline: this.props.title, customFooter: new Array(jsx("div", {})), onClose: () => {
791
+ return (jsx("div", { id: "cwelltModalReportContent", children: this.state.isModal === true ? (jsxs(CwDialog, { open: this.props.visible, width: this.props.width, headline: this.props.title, customFooter: new Array(jsx("div", {})), onClose: () => {
647
792
  this.formRef?.current?.resetFields();
648
793
  this.props.SET_MODAL_REPORT_VISIBLE(false);
649
- }, isReport: true, children: [this.props.name !== "Empty.pdf" && (jsx("div", { style: { width: "100%", height: "100%", overflowX: "auto", overflowY: "auto" }, children: jsx("embed", { src: "data:application/pdf;base64," + this.props.content, type: "application/pdf", style: { width: "100%", height: "100%", display: "block" } }) })), this.props.name === "Empty.pdf" && (jsx("div", { children: jsxs("h1", { style: { marginLeft: "2em" }, children: [" ", "Please add a(n) ", this.props.reportName, " report in ", this.props.moduleSettings, " Settings"] }) }))] })) : (jsxs("div", { children: [this.props.name !== "Empty.pdf" && (jsx("embed", { src: "data:application/pdf;base64," + this.props.content, type: "application/pdf", width: "100%", height: "600px" })), this.props.name === "Empty.pdf" && (jsxs("div", { children: ["Please add a(n) ", this.props.reportName, " report in ", this.props.moduleSettings, " Settings"] }))] })) }));
794
+ }, hideFooter: true, children: [this.props.name !== "Empty.pdf" && (jsx("div", { style: { width: "100%", height: "100%", overflowX: "auto", overflowY: "auto" }, children: jsx("embed", { src: "data:application/pdf;base64," + this.props.content, type: "application/pdf", style: { width: "100%", height: "100%", display: "block" } }) })), this.props.name === "Empty.pdf" && (jsx("div", { children: jsxs("h1", { style: { marginLeft: "2em" }, children: [" ", "Please add a(n) ", this.props.reportName, " report in ", this.props.moduleSettings, " Settings"] }) }))] })) : (jsxs("div", { children: [this.props.name !== "Empty.pdf" && (jsx("embed", { src: "data:application/pdf;base64," + this.props.content, type: "application/pdf", width: "100%", height: "600px" })), this.props.name === "Empty.pdf" && (jsxs("div", { children: ["Please add a(n) ", this.props.reportName, " report in ", this.props.moduleSettings, " Settings"] }))] })) }));
650
795
  }
651
796
  }
652
797
 
@@ -747,6 +892,8 @@ class CwDialogManager {
747
892
  }
748
893
  }
749
894
 
895
+ var styles$9 = {"cw-accordion":"cw-accordion-module_cw-accordion__ErvlW","cw-accordion-body":"cw-accordion-module_cw-accordion-body__xlI8b"};
896
+
750
897
  /**
751
898
  *
752
899
  * @param CwelltAccordionContainerProps
@@ -762,169 +909,211 @@ function CwAccordionContainer(CwelltAccordionContainerProps) {
762
909
  setVisible_accordionBody(!isVisible_accordionBody);
763
910
  };
764
911
  // #endregion
765
- return (jsxs("div", { className: "cwellt_accordionContainer cwellt_flex cwellt_flex_column cwellt_justify_center cwellt_align_items_center", style: CwelltAccordionContainerProps.style, children: [jsxs("div", { className: "cwellt_flex cwelt_accordionHeader cwellt_align_items_center", onClick: () => showAccordionBody(), children: [jsx("div", { className: "cwellt_descAccordion cwellt_flex cwellt_align_items_center cwellt_justify_flex_start cwellt_flex_11", children: jsx("div", { className: "cwellt_desc_tex", children: CwelltAccordionContainerProps.desc_text }) }), jsx("div", { className: "cwellt_btnContent_expandCollapse cwellt_flex cwellt_align_items_center cwellt_justify_center cwellt_flex_1", children: jsx("button", { className: isVisible_accordionBody
766
- ? "cwellt_expandCollapse_active cwellt_flex cwellt_align_items_center cwellt_justify_center"
767
- : "cwellt_expandCollapse cwellt_flex cwellt_align_items_center cwellt_justify_center" }) })] }), jsx("div", { className: isVisible_accordionBody
768
- ? "cwellt_accordionBody cwellt_flex cwellt_flex_column cwellt_justify_flex_start"
769
- : "cwellt_accordionBody cwellt_display_none cwellt_flex_column cwellt_justify_flex_start", children: CwelltAccordionContainerProps.children })] }));
912
+ return (jsxs("div", { className: styles$9["cw-accordion"], style: CwelltAccordionContainerProps.style, "data-open": isVisible_accordionBody, children: [jsxs("header", { onClick: () => showAccordionBody(), children: [jsx("div", { children: CwelltAccordionContainerProps.desc_text }), jsx("button", { className: "cw-button-icon" })] }), jsx("div", { className: styles$9["cw-accordion-body"], children: CwelltAccordionContainerProps.children })] }));
770
913
  }
771
914
 
772
915
  /**
773
- * A Table view
774
- * @param props
916
+ * A reusable and customizable table component.
917
+ *
918
+ * @param props - Component props to configure columns, data, styles, pagination, expanded rows, and more.
919
+ *
775
920
  * @example
776
921
  * const columns = [
777
922
  * {
778
923
  * title: 'Name',
779
924
  * dataIndex: 'name',
780
925
  * key: 'name',
926
+ * sortable: true, // Column is sortable
927
+ * width: 100 // You can define the width of the column
781
928
  * },
782
929
  * {
783
930
  * title: 'Age',
784
931
  * dataIndex: 'age',
785
932
  * key: 'age',
786
- * render: (age) => <span>{age} years</span>, // Example of custom rendering
933
+ * sortable: true,
934
+ * render: (item) => <span>{item.age} years</span> // Custom rendering
787
935
  * },
788
936
  * {
789
937
  * title: 'Address',
790
938
  * dataIndex: 'address',
791
939
  * key: 'address',
792
- * render: (address) => (
793
- * <a href={`https://maps.google.com/?q=${encodeURIComponent(address)}`} target="_blank">
794
- * {address}
940
+ * render: (item) => (
941
+ * <a href={`https://maps.google.com/?q=${encodeURIComponent(item.address)}`} target="_blank" rel="noreferrer">
942
+ * {item.address}
795
943
  * </a>
796
- * ), // Example of custom link rendering
797
- * },
944
+ * ) // Link rendering
945
+ * }
798
946
  * ];
799
947
  *
800
948
  * const data = [
801
- * {
802
- * key: '1',
803
- * name: 'Mike',
804
- * age: 32,
805
- * address: '10 Downing Street',
806
- * },
807
- * {
808
- * key: '2',
809
- * name: 'John',
810
- * age: 42,
811
- * address: '10 Downing Street',
812
- * },
813
- * {
814
- * key: '3',
815
- * name: 'Andres',
816
- * age: 33,
817
- * address: '10 Downing Street',
818
- * },
819
- * {
820
- * key: '4',
821
- * name: 'Gabriel',
822
- * age: 22,
823
- * address: '10 Downing Street',
824
- * },
825
- * {
826
- * key: '5',
827
- * name: 'Sergio',
828
- * age: 47,
829
- * address: '10 Downing Street',
830
- * },
831
- * {
832
- * key: '6',
833
- * name: 'Zacarias',
834
- * age: 61,
835
- * address: '10 Downing Street',
836
- * },
949
+ * { key: '1', name: 'Mike', age: 32, address: '10 Downing Street' },
950
+ * { key: '2', name: 'John', age: 42, address: '11 Downing Street' },
951
+ * { key: '3', name: 'Andres', age: 33, address: '12 Downing Street' },
952
+ * { key: '4', name: 'Gabriel', age: 22, address: '13 Downing Street' },
953
+ * { key: '5', name: 'Sergio', age: 47, address: '14 Downing Street' },
954
+ * { key: '6', name: 'Zacarias', age: 61, address: '15 Downing Street' }
837
955
  * ];
838
956
  *
839
- * const generateExpandedContent = (record) => {
840
- * var testValue = record;
841
- * return (
842
- * <div>
843
- * Contenido expandido personalizado para {record.name}
844
- * </div>
845
- * );
846
- * };
847
- *
848
- * ------------------------- render ---------------------------
957
+ * const generateExpandedContent = (record) => (
958
+ * <div>
959
+ * Custom expanded content for {record.name}
960
+ * </div>
961
+ * );
849
962
  *
850
963
  * <CwTable
851
964
  * columns={columns}
852
- * data={data} // WTF whatever array of objects you add here, make sure each has a key otherwise everything will expand
853
- * itemsPerPage={3}
965
+ * data={data}
854
966
  * pagination={true}
967
+ * pageSizeOptions={[3, 5, 10]} // Optional, defaults to [5, 10, 20, 50]
855
968
  * expandedRowRender={generateExpandedContent}
856
- * onExpand={(e)=> test(e)}
969
+ * onExpand={(item) => console.log('Expanded:', item)}
970
+ * rowKey="key" // Optional, defaults to 'key'
971
+ * textNoData="No data available" // Optional message when no data
972
+ * loading={false} // Optional, shows loading indicator
973
+ * scrollHeight={300} // Optional scroll height, defaults to 300
974
+ * stickyHeader={true} // Optional, makes header sticky on scroll
975
+ * classNameContainer="my-table-wrapper" // Optional wrapper class
976
+ * className="my-table" // Optional table class
977
+ * classNameRow="my-table-row" // Optional class for each row
978
+ * id="custom-table-id" // Optional ID for the container
979
+ * style={{ border: '1px solid #ccc' }} // Optional inline styles
857
980
  * />
981
+ *
858
982
  * @returns React component
859
983
  */
860
- function CwTable({ columns, data, pagination, itemsPerPage, expandedRowRender, onExpand, className, classNameHeader, classNameTr_row, style, classNameContainer, id, textNoData }) {
984
+ function CwTable({ columns, data, pagination = false, pageSizeOptions = [5, 10, 20, 50], expandedRowRender, onExpand, className, classNameRow, style, classNameContainer, id, textNoData = "No data available at the moment", rowKey = "key", loading = false, scrollHeight, stickyHeader = false, }) {
861
985
  const [currentPage, setCurrentPage] = useState(1);
862
986
  const [expandedRowKey, setExpandedRowKey] = useState(null);
863
987
  const [sortConfig, setSortConfig] = useState({
864
988
  key: null,
865
989
  direction: "asc"
866
990
  });
867
- // Function to handle expanding/collapsing rows
868
- const handleRowExpand = (rowKey) => {
869
- if (expandedRowKey === rowKey.key) {
870
- setExpandedRowKey(null);
871
- }
872
- else {
873
- setExpandedRowKey(rowKey.key);
874
- }
875
- if (typeof onExpand === "function") {
876
- onExpand(rowKey);
877
- }
878
- };
879
- // Function to handle sorting by column
880
- const handleSort = (columnKey) => {
881
- let direction = "asc";
882
- if (sortConfig.key === columnKey && sortConfig.direction === "asc") {
883
- direction = "desc";
884
- }
885
- setSortConfig({ key: columnKey, direction });
886
- };
887
- // Use useMemo to calculate sortedData
991
+ const [localItemsPerPage, setLocalItemsPerPage] = useState(pageSizeOptions[0]);
992
+ const [columnWidths, setColumnWidths] = useState(() => columns.reduce((acc, col) => {
993
+ if (col.width)
994
+ acc[col.key] = col.width;
995
+ return acc;
996
+ }, {}));
997
+ const handleItemsPerPageChange = useCallback((e) => {
998
+ setLocalItemsPerPage(parseInt(e.target.value, 10));
999
+ setCurrentPage(1);
1000
+ }, []);
1001
+ const handleRowExpand = useCallback((item) => {
1002
+ const itemKey = item[rowKey];
1003
+ setExpandedRowKey(prev => (prev === itemKey ? null : itemKey));
1004
+ onExpand?.(item);
1005
+ }, [rowKey, onExpand]);
1006
+ const handleSort = useCallback((columnKey) => {
1007
+ setSortConfig(prev => {
1008
+ if (prev.key !== columnKey)
1009
+ return { key: columnKey, direction: "asc" };
1010
+ if (prev.direction === "asc")
1011
+ return { key: columnKey, direction: "desc" };
1012
+ return { key: null, direction: "asc" };
1013
+ });
1014
+ }, []);
888
1015
  const sortedData = useMemo(() => {
889
1016
  if (!data || data.length === 0)
890
- return null;
1017
+ return [];
891
1018
  const dataCopy = [...data];
892
- if (sortConfig.key !== null) {
1019
+ if (sortConfig.key) {
893
1020
  dataCopy.sort((a, b) => {
894
- const aValue = a[sortConfig.key];
895
- const bValue = b[sortConfig.key];
896
- if (aValue < bValue) {
897
- return sortConfig.direction === "asc" ? -1 : 1;
898
- }
899
- if (aValue > bValue) {
900
- return sortConfig.direction === "asc" ? 1 : -1;
901
- }
902
- return 0;
1021
+ const aVal = a[sortConfig.key];
1022
+ const bVal = b[sortConfig.key];
1023
+ return (aVal < bVal ? -1 : aVal > bVal ? 1 : 0) * (sortConfig.direction === "asc" ? 1 : -1);
903
1024
  });
904
1025
  }
905
1026
  return dataCopy;
906
1027
  }, [data, sortConfig]);
907
- // Calculate paged data only if sortedData is not null
908
1028
  const paginatedData = useMemo(() => {
909
1029
  if (!sortedData)
910
- return null;
911
- const startIndex = itemsPerPage !== undefined ? (currentPage - 1) * itemsPerPage : 0;
912
- const endIndex = itemsPerPage !== undefined ? startIndex + itemsPerPage : sortedData.length;
913
- return sortedData.slice(startIndex, endIndex);
914
- }, [sortedData, currentPage, itemsPerPage]);
915
- // Calculate the total number of pages for pagination
1030
+ return [];
1031
+ if (!pagination)
1032
+ return sortedData;
1033
+ const start = (currentPage - 1) * localItemsPerPage;
1034
+ return sortedData.slice(start, start + localItemsPerPage);
1035
+ }, [sortedData, currentPage, localItemsPerPage, pagination]);
916
1036
  const totalPages = useMemo(() => {
917
- if (!sortedData)
918
- return 0;
919
- return itemsPerPage !== undefined ? Math.ceil(sortedData.length / itemsPerPage) : 1;
920
- }, [sortedData, itemsPerPage]);
921
- // Function to handle page change
922
- const handlePageChange = (newPage) => {
923
- if (newPage >= 1 && newPage <= totalPages) {
924
- setCurrentPage(newPage);
1037
+ return pagination ? Math.ceil(sortedData.length / localItemsPerPage) : 1;
1038
+ }, [sortedData, localItemsPerPage, pagination]);
1039
+ const handlePageChange = (page) => {
1040
+ if (page >= 1 && page <= totalPages)
1041
+ setCurrentPage(page);
1042
+ };
1043
+ const startResize = (e, key) => {
1044
+ e.preventDefault();
1045
+ const startX = e.clientX;
1046
+ const startWidth = e.target.parentElement?.offsetWidth || 0;
1047
+ const onMouseMove = (moveEvent) => {
1048
+ const newWidth = Math.max(startWidth + moveEvent.clientX - startX, 50); // mínimo 50px
1049
+ setColumnWidths(prev => ({ ...prev, [key]: newWidth }));
1050
+ };
1051
+ const onMouseUp = () => {
1052
+ window.removeEventListener("mousemove", onMouseMove);
1053
+ window.removeEventListener("mouseup", onMouseUp);
1054
+ };
1055
+ window.addEventListener("mousemove", onMouseMove);
1056
+ window.addEventListener("mouseup", onMouseUp);
1057
+ };
1058
+ const scrollContainerStyle = useMemo(() => {
1059
+ if (stickyHeader || scrollHeight) {
1060
+ return {
1061
+ maxHeight: scrollHeight ?? 300,
1062
+ overflowY: "auto"
1063
+ };
925
1064
  }
1065
+ return {}; // sin altura ni scroll
1066
+ }, [stickyHeader, scrollHeight]);
1067
+ const getColSpan = () => columns.length + (expandedRowRender ? 1 : 0);
1068
+ const renderTableBody = () => {
1069
+ if (loading) {
1070
+ return (jsx("tr", { children: jsx("td", { colSpan: getColSpan(), children: jsx("div", { className: "text-center py-4 text-muted-foreground", children: "Loading data..." }) }) }));
1071
+ }
1072
+ if (!paginatedData || paginatedData.length === 0) {
1073
+ return (jsx("tr", { children: jsx("td", { colSpan: getColSpan(), className: "cw-table-cell-empty", style: { textAlign: "center" }, children: textNoData }) }));
1074
+ }
1075
+ return paginatedData.map(item => {
1076
+ const itemKey = item[rowKey];
1077
+ if (!itemKey)
1078
+ console.warn("Missing row key for item", item);
1079
+ return (jsxs(React__default.Fragment, { children: [jsxs("tr", { className: classNameRow ?? "", children: [expandedRowRender && (jsx("td", { className: "cw-table-col-action cw-table-col-expand", children: jsx("button", { onClick: () => handleRowExpand(item), className: `cw-button-icon ${expandedRowKey === itemKey ? "cwi-chevron-down" : "cwi-chevron-right"}` }) })), columns.map(col => (jsx("td", { className: col.className ?? "", children: col.render ? col.render(item) : item[col.dataIndex] }, `${itemKey}_${col.key}`)))] }), expandedRowRender && expandedRowKey === itemKey && (jsx("tr", { className: "cw-table-row-expanded", children: jsx("td", { colSpan: getColSpan(), children: expandedRowRender(item) }) }))] }, itemKey));
1080
+ });
926
1081
  };
927
- return (jsxs("div", { id: id, className: classNameContainer + " " + "cwTableComp", children: [jsxs("table", { className: className + " " + "cw_table", style: style, children: [jsx("thead", { className: `${classNameHeader} cw_thead`, children: jsxs("tr", { className: "cw_thead_tr", children: [expandedRowRender && jsx("th", { className: "cw_thead_th cw_thead_th_expand" }), columns.map(column => (jsx("th", { onClick: () => handleSort(column.dataIndex), className: `cw_thead_th ${column.className} ${sortConfig.key === column.dataIndex ? sortConfig.direction : ""}`, children: column.title }, column.key)))] }) }), jsx("tbody", { className: "cw_tbody", children: !paginatedData || paginatedData.length === 0 ? (jsx("tr", { children: jsx("td", { colSpan: columns.length + (expandedRowRender ? 1 : 0), style: { textAlign: "center" }, children: textNoData !== undefined && textNoData !== "" ? textNoData : "No data" }) })) : (paginatedData.map(item => (jsxs(React__default.Fragment, { children: [jsxs("tr", { className: `${classNameTr_row} cw_tbody_tr`, children: [expandedRowRender && (jsx("td", { className: "cw_tbody_td", children: jsx("button", { onClick: () => handleRowExpand(item), className: `cwellt_flex cwellt_justify_center cwellt_align_items_center cw_button_expanded_collapse ${expandedRowKey === item.key ? "cw_button_expanded" : "cw_button_collapse"}` }) })), columns.map(column => (jsx("td", { className: "cw_tbody_td", children: column.render ? column.render(item) : item[column.dataIndex] }, `${item.key}_${column.key}`)))] }), expandedRowKey === item.key && expandedRowRender && (jsx("tr", { children: jsx("td", { colSpan: columns.length + 1, children: expandedRowRender(item) }) }))] }, item.key)))) })] }), pagination && totalPages > 1 && (jsxs("div", { className: "cw_table_pagination cwellt_flex cwellt_align-items-start cwellt_align_items_center", children: [jsx("button", { onClick: () => handlePageChange(currentPage - 1), disabled: currentPage === 1, className: "cw_tb_button_pag cw_tb_button_prev cwellt_flex cwellt_justify_center cwellt_align_items_center" }), jsxs("span", { className: "cw_table_pag_desc", children: ["Page ", currentPage, " of ", totalPages] }), jsx("button", { onClick: () => handlePageChange(currentPage + 1), disabled: currentPage === totalPages, className: "cw_tb_button_pag cw_tb_button_next cwellt_flex cwellt_justify_center cwellt_align_items_center" })] }))] }));
1082
+ return (jsxs("div", { id: id, className: `cw-table-container ${classNameContainer ?? ""}`, style: style, children: [jsx("div", { style: scrollContainerStyle, children: jsxs("table", { className: `cw-table ${className ?? ""}`, style: { width: "100%" }, children: [jsx("thead", { style: stickyHeader
1083
+ ? { position: "sticky", top: 0, background: "white", zIndex: 2 }
1084
+ : undefined, children: jsxs("tr", { children: [expandedRowRender && jsx("th", {}), columns.map(col => (jsxs("th", { onClick: () => col.sortable && handleSort(col.dataIndex), className: `${col.className ?? ""} ${sortConfig.key === col.dataIndex ? sortConfig.direction : ""}`.trim(), style: {
1085
+ cursor: col.sortable ? "pointer" : "default",
1086
+ userSelect: "none",
1087
+ width: columnWidths[col.key] ?? col.width,
1088
+ position: "relative",
1089
+ ...((col.width || columnWidths[col.key]) && {
1090
+ minWidth: 50,
1091
+ maxWidth: columnWidths[col.key] ?? col.width
1092
+ }),
1093
+ }, children: [jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [jsx("span", { children: col.title }), col.sortable && (jsx("span", { style: { fontSize: "12px", marginLeft: "6px" }, children: sortConfig.key !== col.dataIndex ? "↕" : sortConfig.direction === "asc" ? "↑" : "↓" }))] }), jsx("div", { onMouseDown: (e) => startResize(e, col.key), style: {
1094
+ position: "absolute",
1095
+ right: 0,
1096
+ top: 7,
1097
+ bottom: 0,
1098
+ width: "2px",
1099
+ cursor: "col-resize",
1100
+ zIndex: 1,
1101
+ backgroundColor: "white",
1102
+ height: 20,
1103
+ } })] }, col.key)))] }) }), jsx("tbody", { children: renderTableBody() })] }) }), pagination && (jsxs("footer", { className: "cw-table-pagination", children: [jsx("button", { onClick: () => handlePageChange(1), disabled: currentPage === 1 || totalPages === 1, className: "cw-button-icon cwi-chevron-left-double", title: "First" }), jsx("button", { onClick: () => handlePageChange(currentPage - 1), disabled: currentPage === 1 || totalPages === 1, className: "cw-button-icon cwi-chevron-left", title: "Previous" }), totalPages > 1 && (jsxs("span", { children: [jsx("input", { type: "number", value: currentPage, onChange: (e) => {
1104
+ const value = parseInt(e.target.value, 10);
1105
+ if (!isNaN(value))
1106
+ handlePageChange(value);
1107
+ }, onBlur: (e) => {
1108
+ const value = parseInt(e.target.value, 10);
1109
+ if (isNaN(value) || value < 1 || value > totalPages) {
1110
+ handlePageChange(1);
1111
+ }
1112
+ }, min: 1, max: totalPages, style: {
1113
+ width: "4rem",
1114
+ textAlign: "center",
1115
+ marginRight: "0.5rem"
1116
+ } }), "of ", totalPages] })), jsx("button", { onClick: () => handlePageChange(currentPage + 1), disabled: currentPage === totalPages || totalPages === 1, className: "cw-button-icon cwi-chevron-right", title: "Next" }), jsx("button", { onClick: () => handlePageChange(totalPages), disabled: currentPage === totalPages || totalPages === 1, className: "cw-button-icon cwi-chevron-right-double", title: "Last" }), jsx("select", { value: localItemsPerPage, onChange: handleItemsPerPageChange, style: { marginLeft: "1rem" }, children: pageSizeOptions.map(size => (jsxs("option", { value: size, children: [size, " / page"] }, size))) })] }))] }));
928
1117
  }
929
1118
 
930
1119
  var styles$8 = {"cw-tabs":"cw-tabs-module_cw-tabs__1pmji","cw-tabs-content":"cw-tabs-module_cw-tabs-content__HTp8d"};
@@ -967,7 +1156,10 @@ function CwTabs(CwTabsProps) {
967
1156
  }
968
1157
  };
969
1158
  const position = CwTabsProps.tabsPosition || 'top';
970
- return (jsxs("div", { id: CwTabsProps.id, className: styles$8['cw-tabs'], "data-tabs-position": position, children: [jsx("ul", { children: CwTabsProps.tabs.map(tab => (jsxs("li", { className: `${tab.key === activeTab ? "cw-tab-active" : ""}`, onClick: () => handleTabClick(tab), "data-active": tab.key === activeTab, children: [jsx(TabIcon, { icon: tab.icon }), tab.title] }, tab.key))) }), jsx("div", { className: styles$8['cw-tabs-content'], children: activeTab !== null && CwTabsProps.tabs.find(tab => tab.key === activeTab)?.content })] }));
1159
+ const tabsListStyle = position === 'left' && CwTabsProps.tabsListWidth
1160
+ ? { minWidth: CwTabsProps.tabsListWidth }
1161
+ : undefined;
1162
+ return (jsxs("div", { id: CwTabsProps.id, className: styles$8['cw-tabs'], style: CwTabsProps.style, "data-tabs-position": position, children: [jsx("ul", { style: tabsListStyle, children: CwTabsProps.tabs.map(tab => (jsxs("li", { className: `${tab.key === activeTab ? "cw-tab-active" : ""}`, onClick: () => handleTabClick(tab), "data-active": tab.key === activeTab, children: [jsx(TabIcon, { icon: tab.icon }), tab.title] }, tab.key))) }), jsx("div", { className: styles$8['cw-tabs-content'], children: activeTab !== null && CwTabsProps.tabs.find(tab => tab.key === activeTab)?.content })] }));
971
1163
  }
972
1164
 
973
1165
  /**
@@ -994,6 +1186,25 @@ const CwExpandable = ({ briefing, onToggle, onOpen, onClose, children, ...detail
994
1186
  return (jsx("div", { className: "cw-expandable", children: jsxs("details", { ref: myRef, ...detailsProps, children: [jsx("summary", { children: briefing }), children && jsx("section", { children: children })] }) }));
995
1187
  };
996
1188
 
1189
+ /**
1190
+ * A component for displaying key-value pairs in a definition list format
1191
+ * Used for read-only display of structured data
1192
+ *
1193
+ * @example
1194
+ * <CwKeyValueList
1195
+ * items={[
1196
+ * { key: "length", label: "Length", value: "10", suffix: "m" },
1197
+ * { key: "width", label: "Width", value: null, suffix: "m" }
1198
+ * ]}
1199
+ * emptyValue="N/A"
1200
+ * />
1201
+ */
1202
+ const CwKeyValueList = ({ items, className = "", emptyValue = "-", direction = "row" }) => {
1203
+ return (jsx("dl", { className: `cw-keyvalue-list ${className}`, children: items.map(item => (jsxs("div", { className: `cw-keyvalue-list-item cw-flex-${direction}`, children: [jsx("dt", { children: item.label }), jsx("dd", { children: item.value !== undefined && item.value !== null && item.value !== ""
1204
+ ? `${item.value}${item.suffix ? ` ${item.suffix}` : ''}`
1205
+ : emptyValue })] }, item.key))) }));
1206
+ };
1207
+
997
1208
  /**
998
1209
  * A table with expandable row groups.
999
1210
  * @param props The data to display
@@ -1117,20 +1328,24 @@ function CwInput(CwInputProps) {
1117
1328
  const handleClearClick = () => {
1118
1329
  CwInputProps.onChange("");
1119
1330
  };
1120
- return (jsxs("div", { className: CwInputProps.labelPosition === "inline"
1121
- ? "cwellt_flex cwellt_flex_row cwellt_align_items_center cw_inputContent"
1122
- : CwInputProps.labelPosition === "column"
1123
- ? "cwellt_flex cwellt_flex_column cwellt_align-items_baseline cw_inputContent"
1124
- : "cwellt_flex cwellt_flex_row cwellt_align_items_center cw_inputContent", children: [jsx("label", { className: CwInputProps.disabled === true
1331
+ return (jsxs("div", { className: CwInputProps.labelPosition === "column"
1332
+ ? "cw-flex-column"
1333
+ : "cw-flex-row ", children: [jsx("label", { className: CwInputProps.disabled === true
1125
1334
  ? CwInputProps.labelClassName + " " + "cw_label_text cw_label_text_disabled"
1126
1335
  : CwInputProps.labelClassName + " " + "cw_label_text", children: CwInputProps.labelName }), jsx("input", { id: CwInputProps.id, type: "text", value: CwInputProps.value, onChange: e => handleChange(e), className: CwInputProps.className + " " + "cw_input", placeholder: CwInputProps.placeholder === undefined ? "Write a text please" : CwInputProps.placeholder, style: CwInputProps.style, disabled: CwInputProps.disabled, required: CwInputProps.required }), CwInputProps.value && (
1127
1336
  // if the component is disabled do not show clear button
1128
1337
  jsx("button", { className: "cw_button_clear cwellt_flex cwellt_justify_center cwellt_align_items_center", onClick: handleClearClick }))] }));
1129
1338
  }
1130
1339
 
1131
- function CwButton(props) {
1132
- const { text, ...buttonProps } = props;
1133
- return (jsx("button", { type: "button", className: "cw-button", ...buttonProps, children: buttonProps.children ?? text }));
1340
+ function CwButton({ text, variant = 'solid', className = '', children, ...buttonProps }) {
1341
+ let buttonClass = "cw-button";
1342
+ if (variant === 'outline') {
1343
+ buttonClass += " cw-button-outline";
1344
+ }
1345
+ if (className) {
1346
+ buttonClass += ` ${className}`;
1347
+ }
1348
+ return (jsx("button", { type: "button", className: buttonClass, ...buttonProps, children: children ?? text }));
1134
1349
  }
1135
1350
 
1136
1351
  /**
@@ -1205,11 +1420,9 @@ function CwInputNumber(CwInputNumberProps) {
1205
1420
  const handleChange = (e) => {
1206
1421
  CwInputNumberProps.onChange(e.target.value);
1207
1422
  };
1208
- return (jsxs("div", { className: CwInputNumberProps.labelPosition == "inline"
1209
- ? "cw-label-input"
1210
- : CwInputNumberProps.labelPosition == "column"
1211
- ? "cwellt_flex cwellt_flex_column cwellt_align-items_baseline cw-label-input"
1212
- : "cw-label-input", children: [jsx("label", { className: CwInputNumberProps.disabled === true
1423
+ return (jsxs("div", { className: CwInputNumberProps.labelPosition == "column"
1424
+ ? "cw-flex-column"
1425
+ : "cw-flex-row", children: [jsx("label", { className: CwInputNumberProps.disabled === true
1213
1426
  ? CwInputNumberProps.labelClassName + " " + "cw_label_text cw_label_text_disabled"
1214
1427
  : CwInputNumberProps.labelClassName + " " + "cw_label_text", children: CwInputNumberProps.labelName }), jsx("input", { id: CwInputNumberProps.id, type: "number", value: CwInputNumberProps.value, onChange: e => handleChange(e), className: CwInputNumberProps.className + " " + " cw-input-number", placeholder: CwInputNumberProps.placeholder == undefined ? "Write a number please" : CwInputNumberProps.placeholder, style: CwInputNumberProps.style, disabled: CwInputNumberProps.disabled, required: CwInputNumberProps.required, step: CwInputNumberProps.step, min: CwInputNumberProps.min, max: CwInputNumberProps.max })] }));
1215
1428
  }
@@ -1678,7 +1891,7 @@ class Weekdays {
1678
1891
  static WEEKDAYS_TO_USA_SHORT_FORMAT = new Map([
1679
1892
  ["M", "Mon"],
1680
1893
  ["T", "Tue"],
1681
- ["W", "Wen"],
1894
+ ["W", "Wed"],
1682
1895
  ["R", "Thu"],
1683
1896
  ["F", "Fri"],
1684
1897
  ["S", "Sat"],
@@ -1812,8 +2025,8 @@ function CwCheckbox(CwCheckboxProps) {
1812
2025
  * <CwToggle checked/>
1813
2026
  */
1814
2027
  function CwToggle(props) {
1815
- const { alignProps, labelProps, buttonProps, iconProps, ...inputProps } = props;
1816
- return (jsx("div", { className: "cw-toggle", children: jsxs(CwAlign, { ...alignProps, children: [labelProps && (jsxs(CwLabel, { ...labelProps, children: [iconProps && jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsx("input", { className: "cw-toggle", type: "checkbox", ...inputProps }), buttonProps && jsx(CwButton, { ...buttonProps })] }) }));
2028
+ const { labelProps, buttonProps, iconProps, ...inputProps } = props;
2029
+ return (jsxs("div", { className: "cw-toggle", children: [labelProps && (jsxs(CwLabel, { ...labelProps, children: [iconProps && jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsx("input", { className: "cw-toggle", type: "checkbox", ...inputProps }), buttonProps && jsx(CwButton, { ...buttonProps })] }));
1817
2030
  }
1818
2031
 
1819
2032
  /**
@@ -1882,9 +2095,9 @@ function CwDropdown(optionsProps) {
1882
2095
  ? "cwellt_flex cwellt_flex_row cwellt_align_items_center cwDropDownComp" + " " + optionsProps.className
1883
2096
  : optionsProps.labelPosition === "column"
1884
2097
  ? "cwellt_flex cwellt_flex_column cwellt_align-items_baseline cwDropDownComp" + " " + optionsProps.className
1885
- : "cwellt_flex cwellt_flex_row cwellt_align_items_center cwDropDownComp" + " " + optionsProps.className, style: optionsProps.style, children: [jsx("label", { className: optionsProps.disabled === true
2098
+ : "cwellt_flex cwellt_flex_row cwellt_align_items_center cwDropDownComp" + " " + optionsProps.className, style: optionsProps.style, id: optionsProps.id, children: [jsx("label", { className: optionsProps.disabled === true
1886
2099
  ? "cw_label_text cw_label_text_disabled" + " " + optionsProps.labelClassName
1887
- : "cw_label_text" + " " + optionsProps.labelClassName, children: optionsProps.labelName }), jsxs("select", { value: selectedOption, onChange: handleOptionSelect, className: "cw_select", style: optionsProps.styleSelect, disabled: optionsProps.disabled, children: [jsx("option", { value: "", className: "cw_option", children: optionsProps.placeholder }), optionsProps.selectList.map(option => (jsx("option", { value: option.id, className: "cw_option", style: optionsProps.styleOption, children: option.description }, option.id)))] })] }));
2100
+ : "cw_label_text" + " " + optionsProps.labelClassName, children: optionsProps.labelName }), jsx("select", { value: selectedOption, onChange: handleOptionSelect, className: "cw_select", style: optionsProps.styleSelect, disabled: optionsProps.disabled || optionsProps.selectList.length === 0, children: optionsProps.selectList.length === 0 ? (jsx("option", { value: "", className: "cw_option", disabled: true, children: "No data" })) : (jsxs(Fragment, { children: [jsx("option", { value: "", className: "cw_option", children: optionsProps.placeholder }), optionsProps.selectList.map(option => (jsx("option", { value: option.id, className: "cw_option", style: optionsProps.styleOption, children: option.description }, option.id)))] })) })] }));
1888
2101
  }
1889
2102
 
1890
2103
  function CwDropdownContainer(dropDownContainerProps) {
@@ -2717,7 +2930,7 @@ function CwMultiselect(CwelltCustomFilterTabProps) {
2717
2930
  const luminance = 0.299 * redBgColor_custom_tag_selected_list +
2718
2931
  0.587 * greenBgColor_custom_tag_selected_list +
2719
2932
  0.114 * blueBgColor_custom_tag_selected_list;
2720
- return s.type !== undefined && s.type !== undefined ? (jsx("div", { id: "cwContent_tag", "data-id": s.type + "_" + s.id, className: "cwellt_flex cwellt_align_items_center", children: jsx(CwTag, { styleTag: {
2933
+ return s.type !== undefined ? (jsx("div", { id: "cwContent_tag", "data-id": s.type + "_" + s.id, className: "cwellt_flex cwellt_align_items_center", children: jsx(CwTag, { styleTag: {
2721
2934
  background: s.color
2722
2935
  }, styleTag_description: {
2723
2936
  background: s.color,
@@ -2774,8 +2987,20 @@ const CwMultiFilterTag = props => {
2774
2987
  var styles$5 = {"cw-multi-filter-catalog-container":"cw-multi-filter-module_cw-multi-filter-catalog-container__S3nsq","cw-multi-filter":"cw-multi-filter-module_cw-multi-filter__zipBK","cw-multi-filter-search":"cw-multi-filter-module_cw-multi-filter-search__eyHr0"};
2775
2988
 
2776
2989
  /**
2777
- * A multiple filter selector, a MULTI-SELECT even.
2990
+ * A multiple filter selector, a MULTI-SELECT even. Allows users to select and filter items based on tags.
2778
2991
  * @remark
2992
+ * The CwMultiFilter component provides a user interface for selecting multiple filter options
2993
+ * organized by categories. Each filter option is represented as a clickable tag with customizable
2994
+ * colors. The component manages the selection state internally but reports changes via a callback.
2995
+ *
2996
+ * Filter tags should include the following properties:
2997
+ * - `Name`: Display name of the filter
2998
+ * - `Value`: Actual value used for filtering logic
2999
+ * - `Category`: Group the filter belongs to
3000
+ * - `ID`: Unique identifier for the filter
3001
+ * - `PrimaryColor`: Background color of the tag
3002
+ * - `OnPrimaryColor`: Text color of the tag
3003
+ *
2779
3004
  * ```
2780
3005
  * ╭───────────────────────────────────────────────────────────────╮
2781
3006
  * │ ╭──────────╮ ╭──────────╮ ╭──────────╮ │
@@ -2790,39 +3015,116 @@ var styles$5 = {"cw-multi-filter-catalog-container":"cw-multi-filter-module_cw-m
2790
3015
  * ╰─────────────────────────────────────────────────────────────╯
2791
3016
  * ```
2792
3017
  * @example
2793
- * ```
2794
- * /// Use setSelectedTags to set the initial selected tags or to add/remove them after an action.
2795
- * const [selectedTags, setSelectedTags] = useState(new Set<CwMultiFilterTagProps>());
2796
- * const [selectedCategory, setSelectedCategory] = useState("");
3018
+ * ```tsx
3019
+ * import { CwMultiFilter, type CwMultiFilterTagProps, type ICwMultiFilterTag } from "cwellt-reactjs-lib";
3020
+ * import { useCallback, useState } from "react";
3021
+ * import { hexToRGB } from "../common/functions/color";
3022
+ *
3023
+ * function FilterExample() {
3024
+ * // State to track selected filter tags
3025
+ * const [selectedTags, setSelectedTags] = useState(new Set<CwMultiFilterTagProps>());
3026
+ *
3027
+ * // Sample data to filter
3028
+ * const [users, setUsers] = useState([
3029
+ * { id: 1, name: "John", role: "admin", department: "IT" },
3030
+ * { id: 2, name: "Sarah", role: "user", department: "HR" },
3031
+ * // More users...
3032
+ * ]);
3033
+ *
3034
+ * // Filtered users based on selected tags
3035
+ * const [filteredUsers, setFilteredUsers] = useState(users);
3036
+ *
3037
+ * // Define filter options
3038
+ * const filterOptions = new Set([
3039
+ * {
3040
+ * Name: "Admin",
3041
+ * Value: "admin",
3042
+ * Category: "Roles",
3043
+ * ID: "Roles_admin",
3044
+ * OnPrimaryColor: hexToRGB("#2050a8"),
3045
+ * PrimaryColor: hexToRGB("#cedcff")
3046
+ * },
3047
+ * {
3048
+ * Name: "User",
3049
+ * Value: "user",
3050
+ * Category: "Roles",
3051
+ * ID: "Roles_user",
3052
+ * OnPrimaryColor: hexToRGB("#2050a8"),
3053
+ * PrimaryColor: hexToRGB("#cedcff")
3054
+ * },
3055
+ * {
3056
+ * Name: "IT",
3057
+ * Value: "IT",
3058
+ * Category: "Departments",
3059
+ * ID: "Departments_IT",
3060
+ * OnPrimaryColor: hexToRGB("#a82037"),
3061
+ * PrimaryColor: hexToRGB("#ffceda")
3062
+ * },
3063
+ * {
3064
+ * Name: "HR",
3065
+ * Value: "HR",
3066
+ * Category: "Departments",
3067
+ * ID: "Departments_HR",
3068
+ * OnPrimaryColor: hexToRGB("#a82037"),
3069
+ * PrimaryColor: hexToRGB("#ffceda")
3070
+ * }
3071
+ * ]);
3072
+ *
3073
+ * // Handle filter changes
3074
+ * const onChangeFilters = useCallback((tags: Set<ICwMultiFilterTag>) => {
3075
+ * setSelectedTags(tags);
3076
+ * const tagsArray = Array.from(tags);
2797
3077
  *
2798
- * <CwMultiFilter
2799
- * id="multifilter"
2800
- * onChange={tags => { // Collection of currently active tags
2801
- * console.log("This will get called every time the selected filters change");
2802
- * }}
2803
- * selectedTags={selectedTags} // Selected filters, in case you want to modify them manually
2804
- * selectedCategory={selectedCategory}
2805
- * onChangeCategory={setSelectedCategory}
2806
- * allTags={
2807
- * new Set([
2808
- * {
2809
- * Name: "DEF", // The text displayed on the tag/filter/chip
2810
- * Value: "DEF", // Working value, used for whatever you need, it might be the CrewmemberID or the same as Name
2811
- * Category: "Crewmembers", // Category it belongs to (you don't need to define categories elsewhere)
2812
- * ID: "Crewmembers_DEF", // make sure each ID is unique
2813
- * OnPrimaryColor: hexToRGB("#2050a8"), // color for text and outline of the tag/filter/chip
2814
- * PrimaryColor: hexToRGB("#cedcff"), // background color for the tag/filter/chip
2815
- * },
2816
- * {
2817
- * Name: "ABC",
2818
- * Value: "ABC",
2819
- * Category: "Crewmembers",
2820
- * ID: "Crewmembers_ABC",
2821
- * OnPrimaryColor: hexToRGB("#2050a8"), // you can also do { r: 255, g: 128, b: 64 }
2822
- * PrimaryColor: hexToRGB("#cedcff")
2823
- * }
2824
- * ])
2825
- * }
3078
+ * // Get values for each category
3079
+ * const roleValues = tagsArray
3080
+ * .filter(tag => tag.Category === "Roles")
3081
+ * .map(tag => tag.Value);
3082
+ *
3083
+ * const departmentValues = tagsArray
3084
+ * .filter(tag => tag.Category === "Departments")
3085
+ * .map(tag => tag.Value);
3086
+ *
3087
+ * // Apply filters
3088
+ * if (tagsArray.length === 0) {
3089
+ * // No filters applied
3090
+ * setFilteredUsers(users);
3091
+ * } else {
3092
+ * let filtered = users;
3093
+ *
3094
+ * if (roleValues.length > 0) {
3095
+ * filtered = filtered.filter(user => roleValues.includes(user.role));
3096
+ * }
3097
+ *
3098
+ * if (departmentValues.length > 0) {
3099
+ * filtered = filtered.filter(user => departmentValues.includes(user.department));
3100
+ * }
3101
+ *
3102
+ * setFilteredUsers(filtered);
3103
+ * }
3104
+ * }, [users]);
3105
+ *
3106
+ * return (
3107
+ * <div>
3108
+ * <h2>Filter Users</h2>
3109
+ * <div style={{ width: "50%" }}>
3110
+ * <CwMultiFilter
3111
+ * id="user-filter"
3112
+ * allTags={filterOptions}
3113
+ * onChangeSelectedTags={onChangeFilters}
3114
+ * selectedTags={selectedTags}
3115
+ * />
3116
+ * </div>
3117
+ * <div style={{ marginTop: "20px" }}>
3118
+ * <h3>Filtered Results ({filteredUsers.length})</h3>
3119
+ * <ul>
3120
+ * {filteredUsers.map(user => (
3121
+ * <li key={user.id}>{user.name} - {user.role} ({user.department})</li>
3122
+ * ))}
3123
+ * </ul>
3124
+ * </div>
3125
+ * </div>
3126
+ * );
3127
+ * }
2826
3128
  * ```
2827
3129
  * @param {CwMultiFilterProps} props
2828
3130
  * @returns Set the `onChange` callback to a function to check for changes in the selected filters
@@ -2930,7 +3232,7 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, style
2930
3232
  };
2931
3233
  return (jsxs("form", { ref: componentRef, id: id, className: styles$5["cw-multi-filter"], style: style, onSubmit: (e) => {
2932
3234
  e.preventDefault();
2933
- }, children: [jsxs("div", { onClick: handleDivClick, className: styles$5["cw-multi-filter-search"], style: isPanelOpen ? { outline: "1px solid var(--cw-color-primary)", outlineOffset: "-2px" } : {}, children: [jsxs("ul", { id: id + "_selected_filters", children: [Array.from(selectedTags).map(tag => (createElement(CwMultiFilterTag, { ...tag, key: tag.ID, Selectable: false, Removable: true, OnRemove: () => removeTag(tag.ID) }))), jsx("input", { type: "text", id: id + "_input", ref: inputRef, value: inputTextValue, spellCheck: false, onFocus: () => setIsPanelOpen(true), onChange: e => handleInputText(e.target.value), autoComplete: "off", onKeyDown: e => {
3235
+ }, children: [jsxs("div", { onClick: handleDivClick, className: styles$5["cw-multi-filter-search"], style: isPanelOpen ? { outline: "1px solid var(--cw-color-primary)", outlineOffset: "-2px" } : {}, children: [jsxs("ul", { id: id + "_selected_filters", children: [Array.from(selectedTags).map(tag => (createElement(CwMultiFilterTag, { ...tag, key: tag.ID, Selectable: false, Removable: true, OnRemove: () => removeTag(tag.ID) }))), jsx("input", { type: "text", id: id + "_input", ref: inputRef, value: inputTextValue, spellCheck: false, onFocus: () => setIsPanelOpen(true), onChange: e => handleInputText(e.target.value), autoComplete: "off", placeholder: "Write to filter", onKeyDown: e => {
2934
3236
  switch (e.key) {
2935
3237
  case "Enter":
2936
3238
  case "Tab":
@@ -2981,20 +3283,49 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, style
2981
3283
  function CwSearchInput(optionsProps) {
2982
3284
  const [searchText, setSearchText] = useState("");
2983
3285
  const [filteredOptions, setFilteredOptions] = useState([]);
3286
+ const [_selectedOption, setSelectedOption] = useState(null);
3287
+ // Make default value selection when loading the component
3288
+ useEffect(() => {
3289
+ if (optionsProps.defaultValue && optionsProps.selectList && optionsProps.selectList.length > 0) {
3290
+ const defaultOption = optionsProps.selectList.find(option => option.id === optionsProps.defaultValue?.toString());
3291
+ if (defaultOption) {
3292
+ setSearchText(defaultOption.description);
3293
+ setSelectedOption(defaultOption);
3294
+ // Notify the parent component if there is a handleChange
3295
+ if (optionsProps.handleChange) {
3296
+ optionsProps.handleChange(defaultOption.id);
3297
+ }
3298
+ }
3299
+ }
3300
+ }, [optionsProps.defaultValue, optionsProps.selectList]);
2984
3301
  const handleInputChange = (event) => {
2985
3302
  const text = event.target.value;
2986
3303
  setSearchText(text);
2987
3304
  if (text === "") {
2988
3305
  setFilteredOptions([]);
3306
+ setSelectedOption(null);
3307
+ // Notify that there is no selection
3308
+ if (optionsProps.handleChange) {
3309
+ optionsProps.handleChange("");
3310
+ }
2989
3311
  }
2990
3312
  else {
2991
- // Filter options based on search text
2992
- const filtered = optionsProps.selectList.filter((option) => option.description.toLowerCase().includes(text.toLowerCase()));
3313
+ // Filter options based on search text in any text property
3314
+ const filtered = optionsProps.selectList.filter((option) => {
3315
+ // Search all properties of the object
3316
+ return Object.keys(option).some(key => {
3317
+ const value = option[key];
3318
+ // Verify that the value is a string or number and contains the search text
3319
+ return (typeof value === 'string' || typeof value === 'number') &&
3320
+ String(value).toLowerCase().includes(text.toLowerCase());
3321
+ });
3322
+ });
2993
3323
  setFilteredOptions(filtered);
2994
3324
  }
2995
3325
  };
2996
3326
  const handleOptionSelect = (option) => {
2997
3327
  setSearchText(option.description);
3328
+ setSelectedOption(option);
2998
3329
  if (optionsProps.handleChange) {
2999
3330
  optionsProps.handleChange(option.id);
3000
3331
  }
@@ -3004,14 +3335,15 @@ function CwSearchInput(optionsProps) {
3004
3335
  const handleClearClick = () => {
3005
3336
  setSearchText("");
3006
3337
  setFilteredOptions([]);
3338
+ setSelectedOption(null);
3007
3339
  };
3008
- return (jsxs("div", { className: "cwellt_flex cwellt_flex_row cwellt_flex_wrap cwellt_p_rel cwSearchInputComp", style: optionsProps.style, id: optionsProps.id, children: [jsxs("div", { className: optionsProps.labelPosition === "inline"
3009
- ? "cwellt_flex cwellt_flex_row "
3340
+ return (jsxs("div", { className: "cwSearchInputComp", style: optionsProps.style, id: optionsProps.id, children: [jsxs("div", { className: optionsProps.labelPosition === "inline"
3341
+ ? "cw-flex-row "
3010
3342
  : optionsProps.labelPosition === "column"
3011
- ? "cwellt_flex cwellt_flex_column"
3012
- : "cwellt_flex cwellt_flex_row ", children: [jsx("label", { className: optionsProps.disabled === true
3343
+ ? "cw-flex-column"
3344
+ : "cw-flex-row ", children: [optionsProps.labelName && (jsx("label", { className: optionsProps.disabled === true
3013
3345
  ? "cw_label_text cw_label_text_disabled" + " " + optionsProps.labelClassName
3014
- : "cw_label_text" + " " + optionsProps.labelClassName, children: optionsProps.labelName }), jsx("input", { type: "text", value: searchText, onChange: handleInputChange, placeholder: "Search...", className: "cw_input_search", disabled: optionsProps.disabled }), searchText && (jsx("button", { className: "cw_button_search_clear cwelt_flex cwellt_justify_center cwellt_align_items_center cwellt_p_abs", onClick: handleClearClick }))] }), filteredOptions.length > 0 && (jsx("div", { className: "cw_searchInput_dropDown cwellt_p_abs", children: jsx("ul", { className: "cw_searchInput_listContainer", children: filteredOptions.map((option) => (jsx("li", { onClick: () => handleOptionSelect(option), className: "cw_searchInput_list cwellt_flex cwellt_align_items_center", children: option.description }, option.id))) }) }))] }));
3346
+ : "cw_label_text" + " " + optionsProps.labelClassName, children: optionsProps.labelName })), jsx("input", { type: "text", value: searchText, onChange: handleInputChange, placeholder: "Search...", className: "cw_input_search", disabled: optionsProps.disabled }), searchText && (jsx("button", { className: "cw-button-icon cwi-close cw-input-search-clear", onClick: handleClearClick }))] }), filteredOptions.length > 0 && (jsx("div", { className: "cw-input-search-dropdown", children: jsx("ul", { children: filteredOptions.map((option) => (jsx("li", { onClick: () => handleOptionSelect(option), children: option.description }, option.id))) }) }))] }));
3015
3347
  }
3016
3348
 
3017
3349
  var styles$4 = {"context-menu":"cw-context-menu-module_context-menu__dbxnO","context-menu-item":"cw-context-menu-module_context-menu-item__B2W-Q"};
@@ -3027,7 +3359,7 @@ var styles$4 = {"context-menu":"cw-context-menu-module_context-menu__dbxnO","con
3027
3359
  * <div>Right-click me!</div>
3028
3360
  * </ContextMenu>
3029
3361
  */
3030
- const CwContextMenu = ({ children, options, onSelect }) => {
3362
+ const CwContextMenu = ({ children, options, offset, onSelect }) => {
3031
3363
  const [isOpen, setIsOpen] = useState(false);
3032
3364
  const [position, setPosition] = useState({ x: 0, y: 0 });
3033
3365
  const menuRef = useRef(null);
@@ -3052,8 +3384,8 @@ const CwContextMenu = ({ children, options, onSelect }) => {
3052
3384
  };
3053
3385
  }, []);
3054
3386
  return (jsxs("div", { onContextMenu: handleContextMenu, children: [children, isOpen && (jsx("div", { ref: menuRef, className: styles$4["context-menu"], style: {
3055
- top: position.y,
3056
- left: position.x
3387
+ top: position.y + (offset?.y || 0),
3388
+ left: position.x + (offset?.x || 0),
3057
3389
  }, children: options.map(option => (jsx("div", { onClick: () => handleOptionClick(option), className: styles$4["context-menu-item"], children: option }, option))) }))] }));
3058
3390
  };
3059
3391
 
@@ -3133,47 +3465,11 @@ function CwFloatingButton() {
3133
3465
  };
3134
3466
  return jsx("button", { className: "cw_btnFloatingButton", onClick: cwShowElement, id: "cw_btnFloatingButton" });
3135
3467
  }
3136
- // Button for expand and collapase
3137
- function CwButtonExpandAndCollapse() {
3138
- const cwExpandCollapseButton = () => {
3139
- // cwellt_btnExpandCollapse
3140
- const cw_btnExpandCollapse = document.getElementById("cw_btnExpandCollapse");
3141
- cw_btnExpandCollapse?.classList.toggle("cw_btnExpandCollapseActive");
3142
- // text of tooltip
3143
- // Switches
3144
- const cwSwitches = document.getElementsByClassName("CwSwitches")[0];
3145
- cwSwitches.classList.toggle("cwSwitchesActive");
3146
- // ContentButton
3147
- };
3148
- return jsx("button", { className: "cw_btnExpandCollapse", onClick: cwExpandCollapseButton, id: "cw_btnExpandCollapse" });
3149
- }
3150
3468
  // Primary button => CwButtonDef
3151
3469
  // CwButtonDef
3152
3470
  function CwButtonDef({ cw_btn_desc, cw_btnOnclick, cw_btn_disabled }) {
3153
3471
  return (jsx("button", { className: "cw-button cw_btn_primary", onClick: cw_btnOnclick, disabled: cw_btn_disabled, children: cw_btn_desc }));
3154
3472
  }
3155
- // CwButtonDefOutline
3156
- function CwButtonDefOutline({ cw_btn_desc, cw_btnOnclick, cw_btn_disabled }) {
3157
- return (jsx("button", { className: "cw-button cw_btn_primaryOutline", onClick: cw_btnOnclick, disabled: cw_btn_disabled, children: cw_btn_desc }));
3158
- }
3159
- // Primary button => CwButtonSecondary
3160
- // CweButtonSec
3161
- function CwButtonSec({ cw_btn_desc, cw_btnOnclick, cw_btn_disabled }) {
3162
- return (jsx("button", { className: "cw-button cw_btn_secondary", onClick: cw_btnOnclick, disabled: cw_btn_disabled, children: cw_btn_desc }));
3163
- }
3164
- // CwButtonSecOutline
3165
- function CwButtonSecOutline({ cw_btn_desc, cw_btnOnclick, cw_btn_disabled }) {
3166
- return (jsx("button", { className: "cw-button cw_btn_secondaryOutline", onClick: cw_btnOnclick, disabled: cw_btn_disabled, children: cw_btn_desc }));
3167
- }
3168
- // Primary button => cwelltButton_danger
3169
- // CwButton_danger
3170
- function CwButtonDanger({ cw_btn_desc, cw_btnOnclick, cw_btn_disabled }) {
3171
- return (jsx("button", { className: "cw-button cw_btn_danger", onClick: cw_btnOnclick, disabled: cw_btn_disabled, children: cw_btn_desc }));
3172
- }
3173
- // CwButtonDangerOutline
3174
- function CwButtonDangerOutline({ cw_btn_desc, cw_btnOnclick, cw_btn_disabled }) {
3175
- return (jsx("button", { className: "cw-button cw_btn_dangerOutline", onClick: cw_btnOnclick, disabled: cw_btn_disabled, children: cw_btn_desc }));
3176
- }
3177
3473
  // Cw add button
3178
3474
  function CwBtnAdd({ cw_btnOnclick, cw_btn_disabled }) {
3179
3475
  return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btn_add", disabled: cw_btn_disabled });
@@ -3242,10 +3538,6 @@ function CwBtnFiles({ cw_btnOnclick, cw_btn_disabled }) {
3242
3538
  function CwBtnAirport({ cw_btnOnclick, cw_btn_disabled }) {
3243
3539
  return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btn_airport", disabled: cw_btn_disabled });
3244
3540
  }
3245
- // userFolder
3246
- function CwBtnUserFolder({ cw_btnOnclick, cw_btn_disabled }) {
3247
- return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-folder-user", disabled: cw_btn_disabled });
3248
- }
3249
3541
  // DownLoadAllInfo
3250
3542
  function CwBtnDownLoadAllInfo({ cw_btnOnclick, cw_btn_disabled }) {
3251
3543
  return (jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-folder-download", disabled: cw_btn_disabled }));
@@ -3262,10 +3554,6 @@ function CwBtnAddFolder({ cw_btnOnclick, cw_btn_disabled }) {
3262
3554
  function CwBtnEditFolder({ cw_btnOnclick, cw_btn_disabled }) {
3263
3555
  return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-folder-edit", disabled: cw_btn_disabled });
3264
3556
  }
3265
- // PropertyFolder
3266
- function CwBtnSelectedFolder({ cw_btnOnclick, cw_btn_disabled }) {
3267
- return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-folder-selected", disabled: cw_btn_disabled });
3268
- }
3269
3557
  // UploadFiles
3270
3558
  function CwBtnUploadFiles({ cw_btnOnclick, cw_btn_disabled }) {
3271
3559
  return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btn_uploadFiles", disabled: cw_btn_disabled });
@@ -3278,14 +3566,6 @@ function CwBtnGoBackFolder({ cw_btnOnclick, cw_btn_disabled }) {
3278
3566
  function CwBtnBookMark({ cw_btnOnclick, cw_btn_disabled }) {
3279
3567
  return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-star", disabled: cw_btn_disabled });
3280
3568
  }
3281
- // Archive
3282
- function CwBtnArchive({ cw_btnOnclick, cw_btn_disabled }) {
3283
- return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-archive", disabled: cw_btn_disabled });
3284
- }
3285
- // Archive
3286
- function CwBtnArchiveRestore({ cw_btnOnclick, cw_btn_disabled }) {
3287
- return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-archive-restore", disabled: cw_btn_disabled });
3288
- }
3289
3569
  // Publish
3290
3570
  function CwBtnPublish({ cw_btnOnclick, cw_btn_disabled }) {
3291
3571
  return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btnPublish", disabled: cw_btn_disabled });
@@ -3294,10 +3574,6 @@ function CwBtnPublish({ cw_btnOnclick, cw_btn_disabled }) {
3294
3574
  function CwBtnApprove({ cw_btnOnclick, cw_btn_disabled }) {
3295
3575
  return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btnApprove", disabled: cw_btn_disabled });
3296
3576
  }
3297
- // BookMarkLinkPag
3298
- function CwBtnBookMarkLinkPage({ cw_btnOnclick, cw_btn_disabled }) {
3299
- return (jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-favorite-files", disabled: cw_btn_disabled }));
3300
- }
3301
3577
  // Bulk duty
3302
3578
  function CwBtnBulkDuty({ cw_btnOnclick, cw_btn_disabled }) {
3303
3579
  return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btnBulkDuty", disabled: cw_btn_disabled });
@@ -3651,7 +3927,7 @@ const ResourceRender$1 = memo(({ res, schedulerProps, contentArea, state }) => {
3651
3927
  }, arePropsEqual$1);
3652
3928
 
3653
3929
  const ResourceListRender$1 = ({ resources, schedulerProps, state, contentArea, onClickContextMenu, crewAssignmentSchedulerContextMenu, }) => {
3654
- return (jsx(Fragment, { children: resources.map((r, _i) => (jsx(Dropdown, { placement: "topLeft", dropdownRender: () => {
3930
+ return (jsx(Fragment$1, { children: resources.map((r, _i) => (jsx(Dropdown, { placement: "topLeft", dropdownRender: () => {
3655
3931
  return (jsx(Menu, { style: { pointerEvents: "auto" }, onClick: (e) => {
3656
3932
  onClickContextMenu(e, r);
3657
3933
  }, children: crewAssignmentSchedulerContextMenu?.map((m) => (jsxs(Menu.Item, { children: [jsx("span", { className: m.icon, style: { color: m.color } }), jsx("span", { className: "cwellt_contextMenu", children: m.text })] }, m.key))) }));
@@ -4801,7 +5077,7 @@ const ResourceRender = memo(({ res, schedulerProps, contentArea, state }) => {
4801
5077
  }, arePropsEqual);
4802
5078
 
4803
5079
  const ResourceListRender = ({ resources, schedulerProps, state, contentArea, onClickContextMenu, crewAssignmentSchedulerContextMenu, }) => {
4804
- return (jsx(Fragment, { children: resources.map((r, _i) => (jsx(Dropdown, { placement: "topLeft", dropdownRender: () => {
5080
+ return (jsx(Fragment$1, { children: resources.map((r, _i) => (jsx(Dropdown, { placement: "topLeft", dropdownRender: () => {
4805
5081
  return (jsx(Menu, { style: { pointerEvents: "auto" }, onClick: (e) => {
4806
5082
  onClickContextMenu(e, r);
4807
5083
  }, children: crewAssignmentSchedulerContextMenu?.map((m) => (jsxs(Menu.Item, { children: [jsx("span", { className: m.icon, style: { color: m.color } }), jsx("span", { className: "cwellt_contextMenu", children: m.text })] }, m.key))) }));
@@ -5353,8 +5629,9 @@ const getTimeHeaders = (startDate, endDate) => {
5353
5629
  class CwScheduler extends Component {
5354
5630
  contentArea;
5355
5631
  calculateMaxPx = () => {
5356
- const mainRect = document.body.getBoundingClientRect();
5357
- return Math.floor(mainRect.width - 200);
5632
+ const mainElement = document.body;
5633
+ const mainRect = mainElement.getBoundingClientRect();
5634
+ return Math.floor(mainRect.width - 190);
5358
5635
  };
5359
5636
  constructor(props) {
5360
5637
  super(props);
@@ -5526,9 +5803,7 @@ class CwScheduler extends Component {
5526
5803
  const isPinnedTable = this.props.id.toLowerCase().includes("pinned");
5527
5804
  const schedulerHeight = heightScheduler(this.state.resources, this.props.height, this.props.id === "crewAssignmentsScheduler");
5528
5805
  return (jsx("div", { id: this.props.id, style: {
5529
- overflowY: "scroll",
5530
5806
  maxHeight: isPinnedTable ? "auto" : schedulerHeight,
5531
- minHeight: (this.state.resources.length === 1 || this.state.resources.length === 2) ? schedulerHeight + 10 : 0
5532
5807
  }, className: this.state.resources.length > 0 ? "cwellt_tb_con" : "cwellt_tb_con cw_tb_con_emptyValues", children: jsxs("table", { id: "cwelltTableScheduler", children: [this.props.id !== "crewAssignmentsScheduler" && (jsx(SchedulerHeader$1, { timelineProps: {
5533
5808
  maxPx: this.state.maxPx,
5534
5809
  hoursList: this.state.timeHeaders,
@@ -5537,8 +5812,8 @@ class CwScheduler extends Component {
5537
5812
  endDate: this.props.endDate,
5538
5813
  headerName: this.props.resourceName,
5539
5814
  }, descriptionColumn: this.props.descriptionColumn })), jsx("tbody", { style: {
5540
- overflow: "visible",
5541
- width: this.state.maxPx + 150
5815
+ width: this.state.maxPx + 150,
5816
+ maxHeight: isPinnedTable ? "auto" : schedulerHeight,
5542
5817
  }, className: isPinnedTable ? "fc-body cw-fc-body-pinned" : "fc-body", children: jsxs("tr", { className: "fc_body_row", children: [jsx(ResourcesTitleList, { resources: this.state.resources, canBePinned: this.props.canBePinned ?? false, includesPinned: this.props.id.toLowerCase().includes("pinned"), onCrewPinning: this.handleCrewPinning, onClickResourceContextMenu: (_e, resource) => {
5543
5818
  if (this.props.scheduler_handleOnClickResourceContextMenu) {
5544
5819
  this.props.scheduler_handleOnClickResourceContextMenu(_e, resource);
@@ -5803,13 +6078,40 @@ function getHSLColor(color, alpha = 1) {
5803
6078
  return `hsla(${hsl.h}, ${hsl.s}%, ${hsl.l}%, ${alpha})`;
5804
6079
  }
5805
6080
  function getContrastColor(color) {
6081
+ if (color === null) {
6082
+ return '#000000';
6083
+ }
5806
6084
  const hsl = colorToHSL(color);
5807
- const contrastL = hsl.l > 50 ? 20 : 90;
5808
- return `hsl(${hsl.h}, ${hsl.s}%, ${contrastL}%)`;
6085
+ // Saturated greenyellow and cyan tones need lower luminance threshold (40-35)
6086
+ // Saturated mediumblue and blueviolet tones need higher luminance threshold (55-60)
6087
+ // Saturated orangered tones need lower luminance threshold (45)
6088
+ const isYellowGreen = (hsl.h >= 45 && hsl.h <= 180);
6089
+ const isBlueViolet = (hsl.h >= 210 && hsl.h <= 300);
6090
+ const isRedOrange = (hsl.h >= 0 && hsl.h <= 30) || (hsl.h >= 330 && hsl.h <= 360);
6091
+ let threshold = 50;
6092
+ if (isYellowGreen) {
6093
+ threshold = 40;
6094
+ if (hsl.s >= 70) {
6095
+ threshold = 35;
6096
+ }
6097
+ }
6098
+ else if (isBlueViolet) {
6099
+ threshold = 55;
6100
+ if (hsl.s >= 70) {
6101
+ threshold = 60;
6102
+ }
6103
+ }
6104
+ else if (isRedOrange && hsl.s >= 80) {
6105
+ threshold = 45;
6106
+ }
6107
+ const contrastL = hsl.l >= threshold ? 20 : 90;
6108
+ const contrastS = Math.min(hsl.s, 90);
6109
+ return `hsl(${hsl.h}, ${contrastS}%, ${contrastL}%)`;
5809
6110
  }
5810
6111
 
6112
+ var styles$2 = {"hide-scrollbar":"new-scheduler-module_hide-scrollbar__33GG9","scheduler-event":"new-scheduler-module_scheduler-event__gphwn","scheduler-event-container":"new-scheduler-module_scheduler-event-container__-h1xm","time-marker":"new-scheduler-module_time-marker__2BejU","scheduler-event-text":"new-scheduler-module_scheduler-event-text__zjvd7"};
6113
+
5811
6114
  const BackgroundEvent = ({ value, heightRem }) => {
5812
- const isVerticalText = value.isVerticalText ?? false;
5813
6115
  const backColor = getHSLColor(value.color, value.alpha ?? 0.5);
5814
6116
  const textColor = getContrastColor(value.color);
5815
6117
  return value.isVisible ? (jsx("div", { style: {
@@ -5817,6 +6119,7 @@ const BackgroundEvent = ({ value, heightRem }) => {
5817
6119
  width: `${value.width}%`,
5818
6120
  position: "absolute",
5819
6121
  height: `${heightRem}rem`,
6122
+ pointerEvents: "auto",
5820
6123
  }, children: jsx(CwGenericTooltip, { content: value.tooltip, position: "bottom", dissapearsWhenHover: true, showDelay: 200, children: jsx("div", { style: {
5821
6124
  overflow: "hidden",
5822
6125
  backgroundColor: backColor,
@@ -5828,28 +6131,21 @@ const BackgroundEvent = ({ value, heightRem }) => {
5828
6131
  contentVisibility: "auto",
5829
6132
  height: `${heightRem}rem`,
5830
6133
  }, children: jsxs("div", { style: {
5831
- flex: 1,
5832
- display: "flex",
5833
- flexDirection: "row",
5834
- alignItems: "center",
5835
- whiteSpace: "nowrap",
5836
- overflow: "hidden",
5837
6134
  width: value.width + "%",
5838
- fontSize: "var(--cw-font-size-smallest)"
5839
- }, children: [value.icons ? jsx("div", { style: {
6135
+ fontSize: "var(--cw-font-size-smallest)",
6136
+ padding: "0.25rem",
6137
+ color: textColor,
6138
+ alignItems: "flex-end"
6139
+ }, className: styles$2["scheduler-event-container"], children: [value.icons ? jsx("div", { style: {
5840
6140
  display: "flex",
5841
6141
  flexDirection: "row",
5842
6142
  alignItems: "center",
5843
6143
  whiteSpace: "nowrap",
5844
6144
  color: textColor,
5845
- }, children: value.icons }) : null, jsx("span", { style: {
5846
- color: textColor,
5847
- writingMode: isVerticalText ? "vertical-lr" : "initial",
5848
- textOrientation: isVerticalText ? "upright" : "initial"
5849
- }, children: value.name })] }) }) }) }) })) : null;
6145
+ }, children: value.icons }) : null, jsx("span", { className: styles$2["scheduler-event-text"], children: value.name })] }) }) }) }) })) : null;
5850
6146
  };
5851
6147
 
5852
- var styles$2 = {"scheduler-row-header":"scheduler-row-module_scheduler-row-header__S-iv4"};
6148
+ var styles$1 = {"scheduler-row-header":"scheduler-row-module_scheduler-row-header__S-iv4"};
5853
6149
 
5854
6150
  const DefaultRowHeader = ({ value, width, onEvent }) => {
5855
6151
  return (jsxs("div", { style: {
@@ -5857,7 +6153,7 @@ const DefaultRowHeader = ({ value, width, onEvent }) => {
5857
6153
  // background: color,
5858
6154
  }, onClick: (_) => {
5859
6155
  onEvent(new OnClickRowHeader(value.rowId));
5860
- }, className: styles$2["scheduler-row-header"], children: [jsxs("div", { children: [jsx("strong", { children: value.title }), value.title2 && jsxs("span", { children: ["-", value.title2] }), value.title3 && jsxs("span", { className: styles$2["scheduler-crewmember-functions"], children: ["(", value.title3, ")"] })] }), value.subtitle && jsxs("div", { style: { opacity: 0.5 }, children: [jsx("strong", { children: value.subtitle }), value.subtitle2 && jsxs("span", { children: ["-", value.subtitle2] })] })] }));
6156
+ }, className: styles$1["scheduler-row-header"], children: [jsxs("div", { children: [jsx("strong", { children: value.title }), value.title2 && jsxs("span", { children: ["-", value.title2] }), " ", jsx("strong", { children: value.subtitle })] }), value.subtitle && jsxs("div", { style: { opacity: 0.5 }, children: [value.title3 && jsxs("span", { className: styles$1["scheduler-crewmember-functions"], children: ["(", value.title3, ")"] }), value.subtitle2 && jsxs("span", { children: ["-", value.subtitle2] })] })] }));
5861
6157
  };
5862
6158
 
5863
6159
  function useSingleAndDoubleClicks(onClick, onDoubleClick) {
@@ -5887,8 +6183,6 @@ function useSingleAndDoubleClicks(onClick, onDoubleClick) {
5887
6183
  return { handleClick, handleDoubleClick };
5888
6184
  }
5889
6185
 
5890
- var styles$1 = {"hide-scrollbar":"new-scheduler-module_hide-scrollbar__33GG9","scheduler-event":"new-scheduler-module_scheduler-event__gphwn","scheduler-event-container":"new-scheduler-module_scheduler-event-container__-h1xm","time-marker":"new-scheduler-module_time-marker__2BejU"};
5891
-
5892
6186
  const EventSideDrag = ({ left = false, heightRem, onStartEvent }) => {
5893
6187
  return (jsx("span", { draggable: true, onDragStart: (e) => {
5894
6188
  e.stopPropagation();
@@ -5966,12 +6260,12 @@ const SchedulerEvent = ({ value, heightRem, onEvent }) => {
5966
6260
  e.stopPropagation();
5967
6261
  e.preventDefault();
5968
6262
  onEvent(new OnRightClickEvent(value.id));
5969
- }, children: jsx(CwGenericTooltip, { content: value.tooltip, position: "bottom", dissapearsWhenHover: true, showDelay: 200, children: jsxs("div", { style: {
6263
+ }, children: jsx(CwGenericTooltip, { content: value.tooltip, position: "bottom", hide: isOnDrag, dissapearsWhenHover: true, showDelay: 200, children: jsxs("div", { style: {
5970
6264
  border: value.selected ? "2px solid black" : "none",
5971
6265
  backgroundColor: backColor,
5972
6266
  height: `calc(${heightRem}rem - 4px)`,
5973
6267
  opacity: eventTransparent ? 0.5 : 1,
5974
- }, className: styles$1["scheduler-event"], children: [jsxs("div", { style: {
6268
+ }, className: styles$2["scheduler-event"], children: [jsxs("div", { style: {
5975
6269
  display: "flex",
5976
6270
  flexDirection: "row",
5977
6271
  alignItems: "stretch",
@@ -5980,7 +6274,7 @@ const SchedulerEvent = ({ value, heightRem, onEvent }) => {
5980
6274
  height: `calc(${heightRem}rem - 10px)`,
5981
6275
  }, children: [value.isResizable && (jsx(EventSideDrag, { left: true, heightRem: heightRem * 0.7, onStartEvent: () => {
5982
6276
  onEvent(new OnLeftDragStart(value.id));
5983
- } })), jsxs("div", { className: styles$1["scheduler-event-container"], children: [jsx("div", { style: {
6277
+ } })), jsxs("div", { className: styles$2["scheduler-event-container"], children: [jsx("div", { style: {
5984
6278
  display: "flex",
5985
6279
  flexDirection: "row",
5986
6280
  alignItems: "center",
@@ -5989,11 +6283,24 @@ const SchedulerEvent = ({ value, heightRem, onEvent }) => {
5989
6283
  }, children: value.icons }), jsx("span", { style: {
5990
6284
  padding: "0.1rem",
5991
6285
  color: textColor,
5992
- }, children: value.name })] }), value.isResizable && (jsx(EventSideDrag, { heightRem: heightRem * 0.7, onStartEvent: () => {
6286
+ display: "flex",
6287
+ flex: 1,
6288
+ alignItems: "center",
6289
+ width: "100%",
6290
+ }, children: value.rectangleColors && value.rectangleColors.length > 0 ? (jsx("div", { style: {
6291
+ display: "flex",
6292
+ width: "100%",
6293
+ }, children: value.rectangleColors.map((item, i) => (jsx("div", { className: "cwellt_rectangle_indicator", style: {
6294
+ backgroundColor: item,
6295
+ flex: 1,
6296
+ height: "8px",
6297
+ margin: 0,
6298
+ padding: 0,
6299
+ } }, value.id + "_" + i))) })) : (value.name) })] }), value.isResizable && (jsx(EventSideDrag, { heightRem: heightRem * 0.7, onStartEvent: () => {
5993
6300
  onEvent(new OnRightDragStart(value.id));
5994
- } }))] }), value.primaryTimeMarkerColor && (jsx("div", { className: styles$1["time-marker"], style: {
6301
+ } }))] }), value.primaryTimeMarkerColor && (jsx("div", { className: styles$2["time-marker"], style: {
5995
6302
  backgroundColor: value.primaryTimeMarkerColor,
5996
- } })), value.secondaryTimeMarkerColor && (jsx("div", { className: styles$1["time-marker"], style: {
6303
+ } })), value.secondaryTimeMarkerColor && (jsx("div", { className: styles$2["time-marker"], style: {
5997
6304
  backgroundColor: value.secondaryTimeMarkerColor,
5998
6305
  } }))] }) }) }, value.id) }, value.id));
5999
6306
  };
@@ -6372,6 +6679,7 @@ const getNow = (isUtc) => {
6372
6679
  }
6373
6680
  return now;
6374
6681
  };
6682
+ const rowsHeight = 1.75; // rem
6375
6683
  const Scheduler = (props) => {
6376
6684
  const { header: headerContent, id, events: eventsState, backgroundEvents, contextMenuItems, EventComp, RowTitleComp, orderCategories = ["title"], useOrderCategory, onEvent, groupRowColors, rowHeaderWidth = 180, } = props;
6377
6685
  const BackgroundEventComp = props.BackgroundEventComp ?? BackgroundEvent;
@@ -6405,7 +6713,6 @@ const Scheduler = (props) => {
6405
6713
  };
6406
6714
  const evenColor = "var(--cw-color-surface-container-low)";
6407
6715
  const oddColor = "var(--cw-color-surface-container)";
6408
- const rowsHeight = 1.75; // rem
6409
6716
  const schedulerContentHeight = rowsHeight * visibleRows;
6410
6717
  const weekendsLines = getWeekendLinesByDatesVisible(selectedDate, visibleDays);
6411
6718
  const divisionLines = getLinesByDivisions(header.divisions);
@@ -6442,7 +6749,7 @@ const Scheduler = (props) => {
6442
6749
  const rowsNumber = innerRows.length > 0 ? innerRows.length : 1;
6443
6750
  const pixelsInRem = 16;
6444
6751
  return rowsNumber * rowsHeight * pixelsInRem;
6445
- }, [rows, events, selectedDate, visibleDays, rowsHeight]);
6752
+ }, [rows, events]);
6446
6753
  // Render
6447
6754
  return (jsxs("div", { id: id, style: {
6448
6755
  position: "relative",
@@ -6453,7 +6760,7 @@ const Scheduler = (props) => {
6453
6760
  position: "sticky",
6454
6761
  top: 0,
6455
6762
  zIndex: 1,
6456
- }, children: jsx(SchedulerHeader, { ...header }) })), jsx(VariableSizeList, { height: schedulerContentHeight * 16, itemCount: rows.length, itemSize: getItemSize, width: "100%", style: { overflowX: "hidden" }, ref: instanceRef, className: styles$1["hide-scrollbar"], children: Row })] }));
6763
+ }, children: jsx(SchedulerHeader, { ...header }) })), jsx(VariableSizeList, { height: schedulerContentHeight * 16, itemCount: rows.length, itemSize: getItemSize, width: "100%", style: { overflowX: "hidden" }, ref: instanceRef, className: styles$2["hide-scrollbar"], children: Row })] }));
6457
6764
  };
6458
6765
  const height = (events, rows, rowsNumber) => {
6459
6766
  const selectedRows = rows.slice(0, rowsNumber);
@@ -6832,14 +7139,14 @@ const PinRowHeader = ({ value, width, onEvent }) => {
6832
7139
  flexDirection: "column",
6833
7140
  justifyContent: "center",
6834
7141
  alignItems: "flex-start",
6835
- }, children: [jsxs("div", { children: [jsx("strong", { children: value.title }), value.title2 && jsxs("span", { children: ["-", value.title2] }), value.title3 && jsxs("span", { className: styles["scheduler-crewmember-functions"], children: [" (", value.title3, ")"] })] }), value.subtitle && jsxs("div", { style: { opacity: 0.5 }, children: [jsx("strong", { children: value.subtitle }), value.subtitle2 && jsxs("span", { children: ["-", value.subtitle2] })] })] }) }, value.rowId) }, value.rowId), isLoading ? jsx(CwIcon, { iconId: "spinner fa-spin" }) : undefined] }));
7142
+ }, children: [jsxs("div", { children: [jsx("strong", { children: value.title }), value.title2 && jsxs("span", { children: ["-", value.title2] }), " ", jsx("strong", { children: value.subtitle })] }), value.subtitle && jsxs("div", { style: { opacity: 0.5 }, children: [value.title3 && jsxs("span", { className: styles["scheduler-crewmember-functions"], children: ["(", value.title3, ")"] }), value.subtitle2 && jsxs("span", { children: ["-", value.subtitle2] })] })] }) }, value.rowId) }, value.rowId), isLoading ? jsx("span", { className: "cwi-icons cwi-spinner" }) : undefined] }));
6836
7143
  };
6837
7144
 
6838
7145
  const SuperScheduler = ({ id, state, header, rows, events, pinnedOrderCategory, unPinnedOrderCategory, backgroundEvents, contextMenuItems, onEvent }) => {
6839
7146
  const pinnedRows = rows.filter((it) => it.isPinned);
6840
7147
  const notPinnedRows = rows.filter((it) => !it.isPinned);
6841
7148
  const isFirstVisible = pinnedRows.length > 0;
6842
- return (jsxs(Fragment$1, { children: [isFirstVisible && (jsxs(Fragment$1, { children: [jsx(Scheduler, { id: `${id}-pinned`, state: state, header: header, rows: pinnedRows, events: events, backgroundEvents: backgroundEvents, contextMenuItems: contextMenuItems, orderCategories: pinnedOrderCategory, onEvent: onEvent, EventComp: SchedulerEvent, RowTitleComp: PinRowHeader }), jsx("div", { children: jsx(CwButton, { onClick: () => {
7149
+ return (jsxs(Fragment, { children: [isFirstVisible && (jsxs(Fragment, { children: [jsx(Scheduler, { id: `${id}-pinned`, state: state, header: header, rows: pinnedRows, events: events, backgroundEvents: backgroundEvents, contextMenuItems: contextMenuItems, orderCategories: pinnedOrderCategory, onEvent: onEvent, EventComp: SchedulerEvent, RowTitleComp: PinRowHeader }), jsx("div", { children: jsx(CwButton, { onClick: () => {
6843
7150
  onEvent(new OnClearPinned());
6844
7151
  }, children: "Clear pinned" }) })] })), jsx(Scheduler, { id: `${id}-notPinned`, state: { ...state, isHeaderVisible: !isFirstVisible }, header: header, rows: notPinnedRows, events: events, backgroundEvents: backgroundEvents, contextMenuItems: contextMenuItems, orderCategories: unPinnedOrderCategory, onEvent: onEvent, EventComp: SchedulerEvent, RowTitleComp: PinRowHeader })] }));
6845
7152
  };
@@ -7000,4 +7307,4 @@ class CwFindAirport extends React.Component {
7000
7307
  }
7001
7308
  }
7002
7309
 
7003
- export { CblDragAndDrop, CwAccordionContainer, CwAlign, CwBtnAdd, CwBtnAddFolder, CwBtnAirport, CwBtnAlert, CwBtnApprove, CwBtnArchive, CwBtnArchiveRestore, CwBtnBookMark, CwBtnBookMarkLinkPage, CwBtnBulkDuty, CwBtnCancel, CwBtnCrewPlanning, CwBtnDelay, CwBtnDelete, CwBtnDownLoadAllInfo, CwBtnDownload, CwBtnDropDownMenu, CwBtnEdit, CwBtnEditFolder, CwBtnFiles, CwBtnGeneratePairing, CwBtnGoBackFolder, CwBtnHide, CwBtnImportRequests, CwBtnInfo, CwBtnMVT, CwBtnNavFirstItemView, CwBtnNavLastItemView, CwBtnNavNextDay, CwBtnNavPreviewItem, CwBtnPairing, CwBtnPrint, CwBtnPropertyFolder, CwBtnPublish, CwBtnRefresh, CwBtnReleasePeriod, CwBtnSave, CwBtnSearch, CwBtnSelect, CwBtnSelectedFolder, CwBtnShare, CwBtnStatistic, CwBtnUploadFiles, CwBtnUserFolder, CwBtnVacations, CwBtnView, CwBtnWarning, CwButton, CwButtonDanger, CwButtonDangerOutline, CwButtonDef, CwButtonDefOutline, CwButtonExpandAndCollapse, CwButtonSec, CwButtonSecOutline, CwCheckbox, CwContextMenu, CwContextualMenu, CwDialog, CwDialogManager, CwDigit, CwDisplayMessage, CwDropdown, CwDropdownContainer, CwDropdownFilter, CwDropdownNavigation, CwExpandable, CwFileUpload, CwFindAirport, CwFloatingButton, CwGenericTooltip, CwHeadFilter, CwHeadingMain, CwHeadingSecond, CwIcon, CwImageArea, CwInput, CwInputDate, CwInputDatePicker, CwInputDateText, CwInputDatetime, CwInputImage, CwInputNumber, CwInputPhone, CwInputText, CwLabel, CwLoading, CwLoadingSmall, CwMessage, CwMessageManager, CwMessageType, CwModal, CwModalConfirm, CwModalHover, CwModalIframe, CwModalReportFunctional, CwMultiFilter, CwMultiFilterTag, CwMultiselect, CwOption, CwOptionList, CwReportModal, CwScheduler, CwScheduler2, CwSearchInput, CwSelect, CwSelectList, CwSelectListItems, CwSuperScheduler, CwTable, CwTableGrouped, CwTabs, CwTag, CwTextArea, CwTime, CwToggle, CwTooltip, CwWeekdaySelector, DefaultRowHeader, MultiSelect, OnClearPinned, OnClickContextMenu, OnClickEvent, OnClickRowEvent, OnClickRowHeader, OnClickUtc, OnDoubleClickEvent, OnDoubleClickRowEvent, OnDragEvent, OnDropCtrlEvent, OnDropEvent, OnEndClickHeaderEvent, OnLeftDragStart, OnMultiClickEvent, OnPinRow, OnRangeClickEvent, OnRightClickEvent, OnRightClickRow, OnRightDragStart, OnStartClickHeaderEvent, OnUnpinRow, PinRowHeader, Resource, Scheduler, SchedulerEvent, SuperScheduler, UiEvent, Weekdays, cblEvent, eventIsVisible, getDefaultDivisions, getEventSizes, itemsToMultiFilterTags, useCwMessage };
7310
+ export { CblDragAndDrop, CwAccordionContainer, CwAlign, CwBtnAdd, CwBtnAddFolder, CwBtnAirport, CwBtnAlert, CwBtnApprove, CwBtnBookMark, CwBtnBulkDuty, CwBtnCancel, CwBtnCrewPlanning, CwBtnDelay, CwBtnDelete, CwBtnDownLoadAllInfo, CwBtnDownload, CwBtnDropDownMenu, CwBtnEdit, CwBtnEditFolder, CwBtnFiles, CwBtnGeneratePairing, CwBtnGoBackFolder, CwBtnHide, CwBtnImportRequests, CwBtnInfo, CwBtnMVT, CwBtnNavFirstItemView, CwBtnNavLastItemView, CwBtnNavNextDay, CwBtnNavPreviewItem, CwBtnPairing, CwBtnPrint, CwBtnPropertyFolder, CwBtnPublish, CwBtnRefresh, CwBtnReleasePeriod, CwBtnSave, CwBtnSearch, CwBtnSelect, CwBtnShare, CwBtnStatistic, CwBtnUploadFiles, CwBtnVacations, CwBtnView, CwBtnWarning, CwButton, CwButtonDef, CwCheckbox, CwContextMenu, CwContextualMenu, CwDialog, CwDialogManager, CwDigit, CwDisplayMessage, CwDropdown, CwDropdownContainer, CwDropdownFilter, CwDropdownNavigation, CwExpandable, CwFileUpload, CwFindAirport, CwFloatingButton, CwGenericTooltip, CwHeadFilter, CwHeadingMain, CwHeadingSecond, CwIcon, CwImageArea, CwInput, CwInputDate, CwInputDatePicker, CwInputDateText, CwInputDatetime, CwInputImage, CwInputNumber, CwInputPhone, CwInputText, CwKeyValueList, CwLabel, CwLoading, CwLoadingSmall, CwMessage, CwMessageManager, CwMessageType, CwModal, CwModalConfirm, CwModalHover, CwModalIframe, CwModalReportFunctional, CwMultiFilter, CwMultiFilterTag, CwMultiselect, CwOption, CwOptionList, CwReportModal, CwScheduler, CwScheduler2, CwSearchInput, CwSelect, CwSelectList, CwSelectListItems, CwSuperScheduler, CwTable, CwTableGrouped, CwTabs, CwTag, CwTextArea, CwTime, CwToggle, CwTooltip, CwWeekdaySelector, DefaultRowHeader, MultiSelect, OnClearPinned, OnClickContextMenu, OnClickEvent, OnClickRowEvent, OnClickRowHeader, OnClickUtc, OnDoubleClickEvent, OnDoubleClickRowEvent, OnDragEvent, OnDropCtrlEvent, OnDropEvent, OnEndClickHeaderEvent, OnLeftDragStart, OnMultiClickEvent, OnPinRow, OnRangeClickEvent, OnRightClickEvent, OnRightClickRow, OnRightDragStart, OnStartClickHeaderEvent, OnUnpinRow, PinRowHeader, Resource, Scheduler, SchedulerEvent, SuperScheduler, UiEvent, Weekdays, cblEvent, eventIsVisible, getDefaultDivisions, getEventSizes, itemsToMultiFilterTags, useCwMessage };