@cwellt_software/cwellt-reactjs-lib 1.1.5 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +248 -2
- package/dist/index.css +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.es.js +248 -3
- package/dist/playground/main.d.ts.map +1 -1
- package/dist/src/dev/palette.d.ts +1 -1
- package/dist/src/dev/palette.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -9,6 +9,7 @@ var Draggable = require('react-draggable');
|
|
|
9
9
|
var moment = require('moment');
|
|
10
10
|
var lodash = require('lodash');
|
|
11
11
|
var reactWindow = require('react-window');
|
|
12
|
+
var ideToolbox = require('@react-buddy/ide-toolbox');
|
|
12
13
|
|
|
13
14
|
function _interopNamespaceDefault(e) {
|
|
14
15
|
var n = Object.create(null);
|
|
@@ -708,7 +709,7 @@ function CwLoadingSmall(CwelltLoadingAppointements) {
|
|
|
708
709
|
jsxRuntime.jsx("div", {})) }));
|
|
709
710
|
}
|
|
710
711
|
|
|
711
|
-
var styles$j = {"cw-generic-tooltip-content":"cw-generic-tooltip-module_cw-generic-tooltip-content__la-Si"
|
|
712
|
+
var styles$j = {"cw-generic-tooltip-content":"cw-generic-tooltip-module_cw-generic-tooltip-content__la-Si"};
|
|
712
713
|
|
|
713
714
|
// Constants moved outside to prevent recreation
|
|
714
715
|
const margin = 16;
|
|
@@ -2093,7 +2094,7 @@ function CwFileUpload(fileUploadProps) {
|
|
|
2093
2094
|
return (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("div", { className: "row", children: [jsxRuntime.jsx("input", { className: "cw-button", type: "file", accept: fileUploadProps.accept, readOnly: true, placeholder: "No file selected...", onChange: handleFileChange }), previewURL && (jsxRuntime.jsx("div", { className: "row", children: jsxRuntime.jsx("img", { src: previewURL, alt: "Preview", style: { maxWidth: "200px", maxHeight: "200px" } }) }))] }), error && jsxRuntime.jsx("div", { className: "row error", children: error }), jsxRuntime.jsx("div", { className: "row", children: jsxRuntime.jsxs("label", { children: ["Please note: File/image has to be in ", fileUploadProps.acceptString, " format", fileUploadProps.sizeString && `, ${fileUploadProps.sizeString}`] }) })] }));
|
|
2094
2095
|
}
|
|
2095
2096
|
|
|
2096
|
-
var styles$b = {"fileUploadContainer":"cw-file-upload-multiple-module_fileUploadContainer__liEc1","hiddenInput":"cw-file-upload-multiple-module_hiddenInput__TZBBI","uploadArea":"cw-file-upload-multiple-module_uploadArea__DdOhs","uploadAreaDisabled":"cw-file-upload-multiple-module_uploadAreaDisabled__VWeFX","uploadTitle":"cw-file-upload-multiple-module_uploadTitle__gjRk8","
|
|
2097
|
+
var styles$b = {"fileUploadContainer":"cw-file-upload-multiple-module_fileUploadContainer__liEc1","hiddenInput":"cw-file-upload-multiple-module_hiddenInput__TZBBI","uploadArea":"cw-file-upload-multiple-module_uploadArea__DdOhs","uploadAreaDisabled":"cw-file-upload-multiple-module_uploadAreaDisabled__VWeFX","uploadTitle":"cw-file-upload-multiple-module_uploadTitle__gjRk8","uploadSubtitle":"cw-file-upload-multiple-module_uploadSubtitle__Z0S5t","filesContainer":"cw-file-upload-multiple-module_filesContainer__g44PY","fileItem":"cw-file-upload-multiple-module_fileItem__w27Dg","fileIcon":"cw-file-upload-multiple-module_fileIcon__iJJUX","fileExtension":"cw-file-upload-multiple-module_fileExtension__vOuHv","fileInfo":"cw-file-upload-multiple-module_fileInfo__R5ZTv","fileName":"cw-file-upload-multiple-module_fileName__DjepK","fileSize":"cw-file-upload-multiple-module_fileSize__b8GSm","smallButton":"cw-file-upload-multiple-module_smallButton__siUAh"};
|
|
2097
2098
|
|
|
2098
2099
|
function CwFileUploadMultiple(fileUploadProps) {
|
|
2099
2100
|
const fileInputRef = React.useRef(null);
|
|
@@ -7087,6 +7088,10 @@ class OnClickRowHeader {
|
|
|
7087
7088
|
this.id = id;
|
|
7088
7089
|
}
|
|
7089
7090
|
}
|
|
7091
|
+
class UpdateApi {
|
|
7092
|
+
constructor() {
|
|
7093
|
+
}
|
|
7094
|
+
}
|
|
7090
7095
|
class OnClickUtc {
|
|
7091
7096
|
constructor() {
|
|
7092
7097
|
}
|
|
@@ -7743,6 +7748,205 @@ const getWeekendsDaysInDateRange = (initialDate, visibleDays) => {
|
|
|
7743
7748
|
|
|
7744
7749
|
class UiEvent {
|
|
7745
7750
|
}
|
|
7751
|
+
function when(event) {
|
|
7752
|
+
let found = false;
|
|
7753
|
+
const actions = {
|
|
7754
|
+
case(eventType, action) {
|
|
7755
|
+
if (!found && event instanceof eventType) {
|
|
7756
|
+
action(event);
|
|
7757
|
+
found = true;
|
|
7758
|
+
}
|
|
7759
|
+
return actions;
|
|
7760
|
+
},
|
|
7761
|
+
else(action) {
|
|
7762
|
+
if (!found) {
|
|
7763
|
+
action(event);
|
|
7764
|
+
}
|
|
7765
|
+
}
|
|
7766
|
+
};
|
|
7767
|
+
return actions;
|
|
7768
|
+
}
|
|
7769
|
+
|
|
7770
|
+
const getListOfNumbers = (len) => Array(len)
|
|
7771
|
+
.fill(0)
|
|
7772
|
+
.map((_, idx) => idx);
|
|
7773
|
+
const getRandomColor = () => {
|
|
7774
|
+
return "#" + (0x1000000 + Math.random() * 0xffffff).toString(16).substr(1, 6);
|
|
7775
|
+
};
|
|
7776
|
+
const getRandomEvents = (date, visibleDays, resourceId) => {
|
|
7777
|
+
return getListOfNumbers(visibleDays).map((e) => {
|
|
7778
|
+
const len1 = Math.floor(Math.random() * 24) + 1;
|
|
7779
|
+
const moment1 = moment(date).add(e, "days").add(e, "minutes");
|
|
7780
|
+
const len2 = Math.floor(Math.random() * 25) + 1;
|
|
7781
|
+
return {
|
|
7782
|
+
id: crypto.randomUUID(),
|
|
7783
|
+
rowId: resourceId.toString(),
|
|
7784
|
+
name: "API Design",
|
|
7785
|
+
color: getRandomColor(),
|
|
7786
|
+
startDate: moment1.add(-len1, "hour").toDate(),
|
|
7787
|
+
endDate: moment1.add(len2, "hour").toDate(),
|
|
7788
|
+
};
|
|
7789
|
+
});
|
|
7790
|
+
};
|
|
7791
|
+
|
|
7792
|
+
const eventToUiState = (it, selectedDate, visibleDays, tooltip) => {
|
|
7793
|
+
const { left, width } = getEventSizes(selectedDate, visibleDays, it.startDate, it.endDate);
|
|
7794
|
+
const eventState = {
|
|
7795
|
+
...it,
|
|
7796
|
+
left,
|
|
7797
|
+
width,
|
|
7798
|
+
tooltip: tooltip,
|
|
7799
|
+
selected: false,
|
|
7800
|
+
isResizable: false,
|
|
7801
|
+
isDraggable: false,
|
|
7802
|
+
};
|
|
7803
|
+
return eventState;
|
|
7804
|
+
};
|
|
7805
|
+
const SchedulerPresenter = () => {
|
|
7806
|
+
const [events, setEvents] = React.useState([]);
|
|
7807
|
+
const [backgroundEvents, setBackgroundEvents] = React.useState([]);
|
|
7808
|
+
const [uiState, setUiState] = React.useState(() => {
|
|
7809
|
+
const visibleDays = 1;
|
|
7810
|
+
const selectedDate = new Date("2024-12-03");
|
|
7811
|
+
const isHeaderVisible = true;
|
|
7812
|
+
return {
|
|
7813
|
+
isUtc: false,
|
|
7814
|
+
selectedDate: selectedDate,
|
|
7815
|
+
isHeaderVisible: isHeaderVisible,
|
|
7816
|
+
visibleDays: visibleDays,
|
|
7817
|
+
rowsHeight: 2,
|
|
7818
|
+
visibleRows: 8,
|
|
7819
|
+
};
|
|
7820
|
+
});
|
|
7821
|
+
const [resources, setResources] = React.useState([]);
|
|
7822
|
+
const selectedEventRef = React.useRef("");
|
|
7823
|
+
React.useEffect(() => {
|
|
7824
|
+
updateDataFromApi();
|
|
7825
|
+
}, []);
|
|
7826
|
+
const updateDataFromApi = () => {
|
|
7827
|
+
const rows = 1;
|
|
7828
|
+
// api call here to events
|
|
7829
|
+
const apiEvents = getListOfNumbers(rows).flatMap((e) => {
|
|
7830
|
+
return getRandomEvents(uiState.selectedDate, uiState.visibleDays * 3, e);
|
|
7831
|
+
});
|
|
7832
|
+
const eventsWithSizes = apiEvents.map((it) => {
|
|
7833
|
+
return eventToUiState(it, uiState.selectedDate, uiState.visibleDays, jsxRuntime.jsxs("div", { children: [it.startDate.getHours() + ":" + it.startDate.getMinutes(), " -", it.endDate.getHours() + ":" + it.endDate.getMinutes()] }));
|
|
7834
|
+
});
|
|
7835
|
+
const visibleEvents = eventsWithSizes.filter((event) => {
|
|
7836
|
+
return eventIsVisible(event.startDate, event.endDate, uiState.selectedDate, uiState.visibleDays);
|
|
7837
|
+
});
|
|
7838
|
+
setEvents(visibleEvents);
|
|
7839
|
+
const apiBackgroundEvents = getListOfNumbers(1).map((e) => {
|
|
7840
|
+
const backgroundEvent = {
|
|
7841
|
+
id: e.toString(),
|
|
7842
|
+
rowId: e.toString(),
|
|
7843
|
+
color: "orange",
|
|
7844
|
+
isResizable: false,
|
|
7845
|
+
isDraggable: false,
|
|
7846
|
+
width: 100 / uiState.visibleDays,
|
|
7847
|
+
name: "Birthday",
|
|
7848
|
+
icons: jsxRuntime.jsx(CwIcon, { iconId: "house", style: { padding: "0.5rem" } }, "cosa"),
|
|
7849
|
+
startDate: new Date(),
|
|
7850
|
+
left: 0,
|
|
7851
|
+
endDate: new Date(),
|
|
7852
|
+
isVisible: true,
|
|
7853
|
+
selected: false,
|
|
7854
|
+
};
|
|
7855
|
+
return backgroundEvent;
|
|
7856
|
+
});
|
|
7857
|
+
setBackgroundEvents(apiBackgroundEvents);
|
|
7858
|
+
// api call here to rows
|
|
7859
|
+
const apiRows = getListOfNumbers(rows).map((e) => {
|
|
7860
|
+
return {
|
|
7861
|
+
resourceId: e.toString(),
|
|
7862
|
+
title: "JAC" + e,
|
|
7863
|
+
};
|
|
7864
|
+
});
|
|
7865
|
+
const headerProps = apiRows.map((row) => {
|
|
7866
|
+
return {
|
|
7867
|
+
rowId: row.resourceId,
|
|
7868
|
+
title: row.title,
|
|
7869
|
+
};
|
|
7870
|
+
});
|
|
7871
|
+
setResources(headerProps);
|
|
7872
|
+
};
|
|
7873
|
+
const onEvent = (event) => {
|
|
7874
|
+
when(event)
|
|
7875
|
+
.case(OnClickEvent, (event) => {
|
|
7876
|
+
console.log("onClick event: " + event.id);
|
|
7877
|
+
})
|
|
7878
|
+
.case(OnDoubleClickEvent, (event) => {
|
|
7879
|
+
const eventData = resources
|
|
7880
|
+
.map((resource) => {
|
|
7881
|
+
const element = events
|
|
7882
|
+
.filter((it) => {
|
|
7883
|
+
return it.rowId === resource.rowId;
|
|
7884
|
+
})
|
|
7885
|
+
.find((it) => it.id == event.id);
|
|
7886
|
+
return element;
|
|
7887
|
+
})
|
|
7888
|
+
.filter((it) => it !== undefined)[0];
|
|
7889
|
+
console.log("found", eventData?.startDate, eventData?.endDate);
|
|
7890
|
+
})
|
|
7891
|
+
.case(OnDragEvent, (event) => {
|
|
7892
|
+
console.log("onDrag event: " + event.id);
|
|
7893
|
+
selectedEventRef.current = event.id;
|
|
7894
|
+
console.log("selectedEvent set to: " + selectedEventRef.current);
|
|
7895
|
+
})
|
|
7896
|
+
.case(OnDropEvent, (event) => {
|
|
7897
|
+
console.log("onDrop event: " + selectedEventRef.current + " to row: " + event.id);
|
|
7898
|
+
setEvents((prevEvents) => {
|
|
7899
|
+
// Find the index of the event to be updated
|
|
7900
|
+
const eventIndex = prevEvents.findIndex((e) => e.id === selectedEventRef.current);
|
|
7901
|
+
// If event is found, create a new array with the updated event
|
|
7902
|
+
const updatedEvents = [...prevEvents];
|
|
7903
|
+
updatedEvents[eventIndex] = {
|
|
7904
|
+
...updatedEvents[eventIndex],
|
|
7905
|
+
rowId: event.id,
|
|
7906
|
+
};
|
|
7907
|
+
return updatedEvents;
|
|
7908
|
+
});
|
|
7909
|
+
console.log("drop on");
|
|
7910
|
+
selectedEventRef.current = ""; // Reset the selected event ref
|
|
7911
|
+
})
|
|
7912
|
+
.case(OnDropCtrlEvent, (event) => {
|
|
7913
|
+
alert(`Clicked row is ${event.id}`);
|
|
7914
|
+
})
|
|
7915
|
+
.case(OnClickRowEvent, (event) => {
|
|
7916
|
+
alert(`Clicked row is ${event.id}`);
|
|
7917
|
+
})
|
|
7918
|
+
.case(OnRightClickEvent, (event) => {
|
|
7919
|
+
alert(`RightClick event ${event.id}`);
|
|
7920
|
+
})
|
|
7921
|
+
.case(OnRightClickRow, (event) => {
|
|
7922
|
+
alert(`RightClick row ${event.id}`);
|
|
7923
|
+
})
|
|
7924
|
+
.case(OnLeftDragStart, (event) => {
|
|
7925
|
+
alert(`Start left Drag ${event.id}`);
|
|
7926
|
+
})
|
|
7927
|
+
.case(OnRightDragStart, (event) => {
|
|
7928
|
+
alert(`Start Right Drag ${event.id}`);
|
|
7929
|
+
})
|
|
7930
|
+
.case(UpdateApi, () => {
|
|
7931
|
+
updateDataFromApi();
|
|
7932
|
+
})
|
|
7933
|
+
.case(OnClickRowHeader, (event) => {
|
|
7934
|
+
console.log(`Clicked row ${event.id}`);
|
|
7935
|
+
})
|
|
7936
|
+
.case(OnClickUtc, () => {
|
|
7937
|
+
setUiState((old) => {
|
|
7938
|
+
return { ...old, isUtc: !old.isUtc };
|
|
7939
|
+
});
|
|
7940
|
+
});
|
|
7941
|
+
};
|
|
7942
|
+
return {
|
|
7943
|
+
state: uiState,
|
|
7944
|
+
resources: resources,
|
|
7945
|
+
events,
|
|
7946
|
+
backgroundEvents,
|
|
7947
|
+
onEvent: onEvent,
|
|
7948
|
+
};
|
|
7949
|
+
};
|
|
7746
7950
|
|
|
7747
7951
|
const getNow = (isUtc) => {
|
|
7748
7952
|
let now = new Date();
|
|
@@ -7843,6 +8047,10 @@ const height = (events, rows, rowsNumber) => {
|
|
|
7843
8047
|
});
|
|
7844
8048
|
return flatMapped.length;
|
|
7845
8049
|
};
|
|
8050
|
+
const SchedulerPreview = () => {
|
|
8051
|
+
const { state, resources, events, backgroundEvents, onEvent } = SchedulerPresenter();
|
|
8052
|
+
return (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("button", { onClick: (_) => onEvent(new UpdateApi()), children: "update" }), jsxRuntime.jsx("button", { onClick: (_) => onEvent(new OnClickUtc()), children: state.isUtc ? "set Local" : "set UTC" }), jsxRuntime.jsx(Scheduler, { id: "test", state: state, header: { title: "Flights", classification: "ACFT" }, rows: resources, onEvent: onEvent, EventComp: SchedulerEvent, RowTitleComp: DefaultRowHeader, events: events, backgroundEvents: backgroundEvents, contextMenuItems: [] })] }));
|
|
8053
|
+
};
|
|
7846
8054
|
|
|
7847
8055
|
let topsCounter = 0;
|
|
7848
8056
|
class CwSuperScheduler extends React__namespace.Component {
|
|
@@ -8457,6 +8665,43 @@ const CwFindAirport = ({ handleChange, searchType = "OnlyDatabase", placeHolder
|
|
|
8457
8665
|
return (jsxRuntime.jsxs("div", { className: `cw-find-airport ${className}`, style: width ? { width } : undefined, children: [jsxRuntime.jsxs("div", { className: "cw-find-airport-input-wrapper", children: [jsxRuntime.jsx("input", { ref: inputRef, type: "text", value: inputValue, onChange: handleInputChange, onKeyDown: handleKeyDown, onFocus: handleInputFocus, placeholder: isInitialLoading ? "Loading…" : placeHolder, disabled: disabled, required: required, autoComplete: "off", "aria-expanded": showDropdown, "aria-haspopup": "listbox", role: "combobox", title: tooltipText }), (isLoading || isInitialLoading) && (jsxRuntime.jsx("div", { className: "cw-find-airport-loading", children: jsxRuntime.jsx(CwIcon, { iconId: "spinner" }) })), inputValue && !disabled && !isInitialLoading && (jsxRuntime.jsx(CwButton, { type: "button", onClick: handleClear, "aria-label": "Clear selected airport", variant: "icon", icon: "close", color: "neutral" }))] }), showDropdown && options.length > 0 && (jsxRuntime.jsx("div", { ref: dropdownRef, className: "cw-find-airport-dropdown", role: "listbox", children: options.map((option, index) => (jsxRuntime.jsx("div", { className: `cw-find-airport-option ${index === highlightedIndex ? "highlighted" : ""}`, onClick: () => handleOptionSelect(option.value), role: "option", "aria-selected": index === highlightedIndex, children: option.text }, option.value))) }))] }));
|
|
8458
8666
|
};
|
|
8459
8667
|
|
|
8668
|
+
const CwPaletteTree = () => (jsxRuntime.jsxs(ideToolbox.Palette, { children: [jsxRuntime.jsx(ideToolbox.Category, { name: "buttons", children: jsxRuntime.jsxs(ideToolbox.Component, { name: "CwButton", children: [jsxRuntime.jsx(ideToolbox.Variant, { name: "solid", children: jsxRuntime.jsx(CwButton, { variant: "solid", text: "Button" }) }), jsxRuntime.jsx(ideToolbox.Variant, { name: "outline", children: jsxRuntime.jsx(CwButton, { variant: "outline", text: "Button" }) }), jsxRuntime.jsx(ideToolbox.Variant, { name: "Icon", children: jsxRuntime.jsx(CwButton, { variant: "icon", icon: "save" }) }), jsxRuntime.jsx(ideToolbox.Variant, { name: "Example", children: jsxRuntime.jsxs(CwButton, { variant: "solid", color: "danger", children: [jsxRuntime.jsx("span", { children: "Example" }), jsxRuntime.jsx("span", { children: "texmple 2" })] }) })] }) }), jsxRuntime.jsx(ideToolbox.Category, { name: "search", children: jsxRuntime.jsx(ideToolbox.Component, { name: "CwSearchInput", children: jsxRuntime.jsx(ideToolbox.Variant, { children: jsxRuntime.jsx(CwSearchInput, { placeholder: "Search", selectList: [
|
|
8669
|
+
new CwSelectList("Search", "1", "Search something", "red")
|
|
8670
|
+
] }) }) }) }), jsxRuntime.jsxs(ideToolbox.Category, { name: "Scheduler-headers", children: [jsxRuntime.jsx(ideToolbox.Component, { name: "DefaultRowHeader", children: jsxRuntime.jsx(ideToolbox.Variant, { children: jsxRuntime.jsx(DefaultRowHeader, { value: {
|
|
8671
|
+
rowId: "1",
|
|
8672
|
+
title: "JAC",
|
|
8673
|
+
title2: "CMD",
|
|
8674
|
+
subtitle: "ICAO",
|
|
8675
|
+
subtitle2: "IATA"
|
|
8676
|
+
},
|
|
8677
|
+
// color={"red"}
|
|
8678
|
+
width: 180, onEvent: () => {
|
|
8679
|
+
} }) }) }), jsxRuntime.jsxs(ideToolbox.Component, { name: "PinRowHeader", children: [jsxRuntime.jsx(ideToolbox.Variant, { children: jsxRuntime.jsx(PinRowHeader, { value: {
|
|
8680
|
+
rowId: "1",
|
|
8681
|
+
title: "JAC",
|
|
8682
|
+
title2: "CMD",
|
|
8683
|
+
subtitle: "ICAO",
|
|
8684
|
+
subtitle2: "IATA",
|
|
8685
|
+
isPinned: true,
|
|
8686
|
+
contextMenuItems: [],
|
|
8687
|
+
isLoading: false,
|
|
8688
|
+
},
|
|
8689
|
+
// color={"red"}
|
|
8690
|
+
width: 180, onEvent: () => {
|
|
8691
|
+
} }) }), jsxRuntime.jsx(ideToolbox.Variant, { name: "pinned", children: jsxRuntime.jsx(PinRowHeader, { value: {
|
|
8692
|
+
rowId: "1",
|
|
8693
|
+
title: "JAC",
|
|
8694
|
+
title2: "CMD",
|
|
8695
|
+
subtitle: "ICAO",
|
|
8696
|
+
subtitle2: "IATA",
|
|
8697
|
+
isPinned: true,
|
|
8698
|
+
contextMenuItems: [],
|
|
8699
|
+
isLoading: false,
|
|
8700
|
+
},
|
|
8701
|
+
// color={"red"}
|
|
8702
|
+
width: 180, onEvent: () => {
|
|
8703
|
+
} }) })] })] }), jsxRuntime.jsx(ideToolbox.Category, { name: "Scheduler", children: jsxRuntime.jsx(ideToolbox.Component, { name: "Scheduler", children: jsxRuntime.jsx(ideToolbox.Variant, { children: jsxRuntime.jsx(SchedulerPreview, {}) }) }) })] }));
|
|
8704
|
+
|
|
8460
8705
|
exports.CblDragAndDrop = CblDragAndDrop;
|
|
8461
8706
|
exports.CwAccordionContainer = CwAccordionContainer;
|
|
8462
8707
|
exports.CwAlign = CwAlign;
|
|
@@ -8557,6 +8802,7 @@ exports.CwMultiselect = CwMultiselect;
|
|
|
8557
8802
|
exports.CwNote = CwNote;
|
|
8558
8803
|
exports.CwOption = CwOption;
|
|
8559
8804
|
exports.CwOptionList = CwOptionList;
|
|
8805
|
+
exports.CwPaletteTree = CwPaletteTree;
|
|
8560
8806
|
exports.CwReportModal = CwReportModal;
|
|
8561
8807
|
exports.CwScheduler = CwScheduler;
|
|
8562
8808
|
exports.CwScheduler2 = CwScheduler2;
|