@topconsultnpm/sdkui-react-beta 6.6.86 → 6.6.88

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.
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ declare enum DeviceType {
3
+ MOBILE = "mobile",
4
+ TABLET = "tablet",
5
+ DESKTOP = "desktop"
6
+ }
7
+ interface DeviceContextProps {
8
+ deviceType?: DeviceType;
9
+ }
10
+ declare const DeviceContext: React.Context<DeviceContextProps | undefined>;
11
+ declare const TMDeviceProvider: React.FC<{
12
+ children: React.ReactNode;
13
+ }>;
14
+ declare const useDeviceType: () => DeviceType | undefined;
15
+ export { DeviceContextProps, DeviceType, useDeviceType, TMDeviceProvider, DeviceContext };
@@ -0,0 +1,41 @@
1
+ import { jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState, createContext, useMemo, useContext } from 'react';
3
+ var DeviceType;
4
+ (function (DeviceType) {
5
+ DeviceType["MOBILE"] = "mobile";
6
+ DeviceType["TABLET"] = "tablet";
7
+ DeviceType["DESKTOP"] = "desktop";
8
+ })(DeviceType || (DeviceType = {}));
9
+ const DESKTOP_BREAKPOINT = 1024;
10
+ const TABLET_BREAKPOINT = 768;
11
+ const DeviceContext = createContext(undefined);
12
+ const TMDeviceProvider = ({ children }) => {
13
+ const [deviceType, setDeviceType] = useState(DeviceType.DESKTOP);
14
+ const updateDeviceType = () => {
15
+ const width = window.innerWidth;
16
+ if (width >= DESKTOP_BREAKPOINT) {
17
+ setDeviceType(DeviceType.DESKTOP);
18
+ }
19
+ else if (width >= TABLET_BREAKPOINT) {
20
+ setDeviceType(DeviceType.TABLET);
21
+ }
22
+ else {
23
+ setDeviceType(DeviceType.MOBILE);
24
+ }
25
+ };
26
+ useEffect(() => {
27
+ updateDeviceType();
28
+ window.addEventListener('resize', updateDeviceType);
29
+ return () => window.removeEventListener('resize', updateDeviceType);
30
+ }, []);
31
+ const contextValue = useMemo(() => ({ deviceType }), [deviceType]);
32
+ return (_jsxs(DeviceContext.Provider, { value: contextValue, children: [" ", children, " "] }));
33
+ };
34
+ const useDeviceType = () => {
35
+ const context = useContext(DeviceContext);
36
+ if (!context) {
37
+ throw new Error('DeviceProvider does not exsist');
38
+ }
39
+ return context.deviceType;
40
+ };
41
+ export { DeviceType, useDeviceType, TMDeviceProvider, DeviceContext };
@@ -102,7 +102,7 @@ const TMDateBox = (props) => {
102
102
  // </DateBox>
103
103
  // <TMVilViewer vil={props.validationItems} />
104
104
  // </>
105
- _jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [props.icon && (_jsx("span", { style: { marginRight: '8px', display: 'flex', alignItems: 'center' }, children: props.icon })), _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '5px' }, children: [_jsx(DateBox, { ref: dateBoxRef, showClearButton: props.showClearButton, dateSerializationFormat: props.useDateSerializationFormat ? 'yyyy-MM-ddTHH:mm:ss' : undefined, disabled: props.disabled, displayFormat: props.displayFormat ?? Globalization.getDateDisplayFormat(props.dateDisplayType), dropDownOptions: dropDownOptions, label: props.label, labelMode: 'static', type: getType(), useMaskBehavior: true, height: '28px', value: props.value, width: props.width, valueChangeEvent: 'keyup input change', onValueChange: (e) => { props.onValueChange?.(e); }, onKeyUp: (e) => {
105
+ _jsxs("div", { style: { display: 'flex', alignItems: 'center', width: '100%' }, children: [props.icon && (_jsx("span", { style: { marginRight: '8px', display: 'flex', alignItems: 'center' }, children: props.icon })), _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '5px', width: '100%' }, children: [_jsx(DateBox, { ref: dateBoxRef, showClearButton: props.showClearButton, dateSerializationFormat: props.useDateSerializationFormat ? 'yyyy-MM-ddTHH:mm:ss' : undefined, disabled: props.disabled, displayFormat: props.displayFormat ?? Globalization.getDateDisplayFormat(props.dateDisplayType), dropDownOptions: dropDownOptions, label: props.label, labelMode: 'static', type: getType(), useMaskBehavior: true, height: '28px', value: props.value, width: props.width, valueChangeEvent: 'keyup input change', onValueChange: (e) => { props.onValueChange?.(e); }, onKeyUp: (e) => {
106
106
  if (e.event?.code == "Space") {
107
107
  const currentDate = new Date();
108
108
  currentDate.setHours(0, 0, 0, 0);
@@ -46,3 +46,4 @@ export { default as SettingsAppearance } from "./settings/SettingsAppearance";
46
46
  export * from "./viewers/TMTidViewer";
47
47
  export * from "./viewers/TMMidViewer";
48
48
  export * from "./viewers/TMDataListItemViewer";
49
+ export * from "./base/TMDeviceProvider";
@@ -61,3 +61,5 @@ export { default as SettingsAppearance } from "./settings/SettingsAppearance";
61
61
  export * from "./viewers/TMTidViewer";
62
62
  export * from "./viewers/TMMidViewer";
63
63
  export * from "./viewers/TMDataListItemViewer";
64
+ //TMDeviceProvider
65
+ export * from "./base/TMDeviceProvider";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.6.86",
3
+ "version": "6.6.88",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",