@equinor/mad-dfw 0.1.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @equinor/mad-dfw
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8503815: Adjusted props related to data display and buttons in the `WorkOrderCell` component.
8
+ Removed the `Id` part from the data props. Removed/adjusted the props: `showActions`,
9
+ `onStartButtonPress`, `onReadyForOperationPress` and `onTecoButtonPress`. New props for this:
10
+ `startJobButton`, `readyForOperationButton` and `tecoButton`. These props have three options
11
+ `visible`, `disabled` and `onpress`. Removed validations for when the buttons are displayed.
12
+
13
+ ## 0.2.0
14
+
15
+ ### Minor Changes
16
+
17
+ - f5133b3: Splitted `WorkOrderCell` into a new component `WorkOrderCell.Navigation`. Removed
18
+ `onPress` from the WorkOrderCell. To get the onPress / navigation functionality, use
19
+ WorkOrderCell.Navigation. `tagId` label is removed/replaced with `functionalLocation`
20
+
21
+ ### Patch Changes
22
+
23
+ - f5133b3: Added technical complete button to the `WorkOrderCell` and a prop, showActions for
24
+ controlling the visibility of buttons
25
+ - f5133b3: Updated the default work order labels and added an overwriteLabel prop to allow
26
+ customization
27
+ - f5133b3: Created a new component `WorkOrderCell.Navigation`
28
+
3
29
  ## 0.1.5
4
30
 
5
31
  ### Patch Changes
@@ -0,0 +1,96 @@
1
+ import {
2
+ getStatusIconsAndLabels
3
+ } from "./chunk-MCPLMBQO.js";
4
+ import {
5
+ PropertyList
6
+ } from "./chunk-JRXLEWCW.js";
7
+ import {
8
+ StatusIcon
9
+ } from "./chunk-VDHOYF7Z.js";
10
+ import {
11
+ __objRest,
12
+ __spreadProps,
13
+ __spreadValues
14
+ } from "./chunk-G2ADBYYC.js";
15
+
16
+ // src/dfwcomponents/WorkOrderCell/WorkOrderCellNavigation.tsx
17
+ import { Cell, EDSStyleSheet, Icon, Label, Typography, useStyles } from "@equinor/mad-components";
18
+ import moment from "moment";
19
+ import React, { useMemo } from "react";
20
+ import { View } from "react-native";
21
+ var WorkOrderCellNavigation = (_a) => {
22
+ var _b = _a, {
23
+ title,
24
+ maintenanceType,
25
+ valueColor = "textTertiary",
26
+ isHseCritical,
27
+ isProductionCritical,
28
+ showSymbols = true,
29
+ overwriteLabel,
30
+ onPress,
31
+ style
32
+ } = _b, rest = __objRest(_b, [
33
+ "title",
34
+ "maintenanceType",
35
+ "valueColor",
36
+ "isHseCritical",
37
+ "isProductionCritical",
38
+ "showSymbols",
39
+ "overwriteLabel",
40
+ "onPress",
41
+ "style"
42
+ ]);
43
+ const styles = useStyles(themeStyles);
44
+ const currentDate = moment();
45
+ const iconsAndLabels = useMemo(
46
+ () => {
47
+ var _a2;
48
+ return getStatusIconsAndLabels(
49
+ rest.activeStatus,
50
+ (_a2 = rest.requiredEnd) != null ? _a2 : null,
51
+ currentDate,
52
+ isHseCritical,
53
+ isProductionCritical
54
+ );
55
+ },
56
+ [rest.activeStatus, rest.requiredEnd, currentDate, isHseCritical, isProductionCritical]
57
+ );
58
+ return /* @__PURE__ */ React.createElement(Cell, { onPress, style }, /* @__PURE__ */ React.createElement(View, { style: styles.container }, /* @__PURE__ */ React.createElement(View, { style: styles.contentContainer }, /* @__PURE__ */ React.createElement(Typography, { numberOfLines: 1, variant: "h5", bold: true, style: styles.title }, title), maintenanceType && /* @__PURE__ */ React.createElement(Label, { label: maintenanceType, style: styles.label }), /* @__PURE__ */ React.createElement(
59
+ PropertyList,
60
+ {
61
+ workOrder: rest,
62
+ overwriteLabel,
63
+ valueColor,
64
+ currentDate: currentDate.toDate()
65
+ }
66
+ )), showSymbols && /* @__PURE__ */ React.createElement(View, { style: styles.iconListContainer }, iconsAndLabels.map((item, index) => /* @__PURE__ */ React.createElement(StatusIcon, __spreadProps(__spreadValues({ key: index }, item), { label: void 0 })))), /* @__PURE__ */ React.createElement(Icon, { name: "chevron-right" })));
67
+ };
68
+ var themeStyles = EDSStyleSheet.create((theme) => ({
69
+ container: {
70
+ flexDirection: "row",
71
+ justifyContent: "space-between",
72
+ alignItems: "center"
73
+ },
74
+ contentContainer: {
75
+ flex: 1,
76
+ flexDirection: "column"
77
+ },
78
+ title: {
79
+ marginBottom: theme.spacing.container.paddingVertical
80
+ },
81
+ label: {
82
+ marginBottom: theme.spacing.cell.group.titleBottomPadding
83
+ },
84
+ iconListContainer: {
85
+ position: "absolute",
86
+ top: 0,
87
+ right: 0,
88
+ flexDirection: "row",
89
+ alignItems: "center",
90
+ gap: theme.spacing.spacer.small
91
+ }
92
+ }));
93
+
94
+ export {
95
+ WorkOrderCellNavigation
96
+ };
@@ -1,34 +1,8 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
1
+ import {
2
+ __objRest,
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "./chunk-G2ADBYYC.js";
32
6
 
33
7
  // src/dfwcomponents/PropertyRow/PropertyRow.tsx
34
8
  import React from "react";
@@ -88,6 +62,5 @@ var themeStyles = EDSStyleSheet.create((_, { breakpoint }) => ({
88
62
  }));
89
63
 
90
64
  export {
91
- __objRest,
92
65
  PropertyRow
93
66
  };
@@ -0,0 +1,37 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+
33
+ export {
34
+ __spreadValues,
35
+ __spreadProps,
36
+ __objRest
37
+ };
@@ -0,0 +1,150 @@
1
+ import {
2
+ getStatusIconsAndLabels
3
+ } from "./chunk-MCPLMBQO.js";
4
+ import {
5
+ PropertyList
6
+ } from "./chunk-JRXLEWCW.js";
7
+ import {
8
+ StatusIcon
9
+ } from "./chunk-VDHOYF7Z.js";
10
+ import {
11
+ __objRest,
12
+ __spreadValues
13
+ } from "./chunk-G2ADBYYC.js";
14
+
15
+ // src/dfwcomponents/WorkOrderCell/WorkOrderCell.tsx
16
+ import {
17
+ Button,
18
+ Cell,
19
+ EDSStyleSheet,
20
+ Label,
21
+ Typography,
22
+ useBreakpoint,
23
+ useStyles
24
+ } from "@equinor/mad-components";
25
+ import moment from "moment";
26
+ import React, { useMemo } from "react";
27
+ import { View } from "react-native";
28
+ var WorkOrderCell = (_a) => {
29
+ var _b = _a, {
30
+ title,
31
+ maintenanceType,
32
+ showSymbols,
33
+ symbolDirection = "column",
34
+ valueColor = "textTertiary",
35
+ isHseCritical,
36
+ isProductionCritical,
37
+ overwriteLabel,
38
+ style,
39
+ startJobButton,
40
+ readyForOperationButton,
41
+ tecoButton
42
+ } = _b, rest = __objRest(_b, [
43
+ "title",
44
+ "maintenanceType",
45
+ "showSymbols",
46
+ "symbolDirection",
47
+ "valueColor",
48
+ "isHseCritical",
49
+ "isProductionCritical",
50
+ "overwriteLabel",
51
+ "style",
52
+ "startJobButton",
53
+ "readyForOperationButton",
54
+ "tecoButton"
55
+ ]);
56
+ var _a2, _b2;
57
+ const breakpoint = useBreakpoint();
58
+ const styles = useStyles(themeStyles, { symbolDirection });
59
+ const anyButtonVisible = (_b2 = (_a2 = startJobButton == null ? void 0 : startJobButton.visible) != null ? _a2 : readyForOperationButton == null ? void 0 : readyForOperationButton.visible) != null ? _b2 : tecoButton == null ? void 0 : tecoButton.visible;
60
+ const currentDate = moment();
61
+ const iconsAndLabels = useMemo(
62
+ () => {
63
+ var _a3;
64
+ return getStatusIconsAndLabels(
65
+ rest.activeStatus,
66
+ (_a3 = rest.requiredEnd) != null ? _a3 : null,
67
+ currentDate,
68
+ isHseCritical,
69
+ isProductionCritical
70
+ );
71
+ },
72
+ [rest.activeStatus, rest.requiredEnd, currentDate, isHseCritical, isProductionCritical]
73
+ );
74
+ return /* @__PURE__ */ React.createElement(Cell, { style }, /* @__PURE__ */ React.createElement(Typography, { numberOfLines: 1, variant: "h5", bold: true, style: styles.title }, title), showSymbols && /* @__PURE__ */ React.createElement(View, { style: [styles.iconListContainer, { flexDirection: symbolDirection }] }, iconsAndLabels.map((item, index) => /* @__PURE__ */ React.createElement(StatusIcon, __spreadValues({ key: index }, item)))), maintenanceType && /* @__PURE__ */ React.createElement(Label, { label: maintenanceType, style: styles.label }), /* @__PURE__ */ React.createElement(
75
+ PropertyList,
76
+ {
77
+ workOrder: rest,
78
+ overwriteLabel,
79
+ valueColor,
80
+ currentDate: currentDate.toDate()
81
+ }
82
+ ), anyButtonVisible && /* @__PURE__ */ React.createElement(
83
+ View,
84
+ {
85
+ style: [
86
+ styles.actionContainer,
87
+ breakpoint === "xs" && { flexDirection: "column" }
88
+ ]
89
+ },
90
+ (startJobButton == null ? void 0 : startJobButton.visible) && /* @__PURE__ */ React.createElement(
91
+ Button,
92
+ {
93
+ title: "Start job",
94
+ variant: "outlined",
95
+ disabled: startJobButton.disabled,
96
+ onPress: startJobButton.onPress
97
+ }
98
+ ),
99
+ (readyForOperationButton == null ? void 0 : readyForOperationButton.visible) && /* @__PURE__ */ React.createElement(
100
+ Button,
101
+ {
102
+ title: "Ready for operation",
103
+ variant: "outlined",
104
+ disabled: readyForOperationButton.disabled,
105
+ onPress: readyForOperationButton == null ? void 0 : readyForOperationButton.onPress
106
+ }
107
+ ),
108
+ (tecoButton == null ? void 0 : tecoButton.visible) && /* @__PURE__ */ React.createElement(
109
+ Button,
110
+ {
111
+ title: "Technical complete",
112
+ variant: "outlined",
113
+ disabled: tecoButton.disabled,
114
+ onPress: tecoButton.onPress
115
+ }
116
+ )
117
+ ));
118
+ };
119
+ var themeStyles = EDSStyleSheet.create(
120
+ (theme, { symbolDirection }) => ({
121
+ iconContainer: {
122
+ flexDirection: "row",
123
+ alignItems: "center",
124
+ gap: theme.spacing.cell.content.titleDescriptionGap,
125
+ marginBottom: theme.spacing.cell.group.titleBottomPadding
126
+ },
127
+ actionContainer: {
128
+ gap: theme.spacing.spacer.small,
129
+ marginTop: theme.spacing.container.paddingVertical,
130
+ flexDirection: "row",
131
+ justifyContent: "center"
132
+ },
133
+ title: {
134
+ marginBottom: theme.spacing.container.paddingVertical
135
+ },
136
+ label: {
137
+ marginBottom: theme.spacing.cell.group.titleBottomPadding
138
+ },
139
+ iconListContainer: {
140
+ flexWrap: "wrap",
141
+ flexDirection: symbolDirection,
142
+ paddingBottom: theme.spacing.cell.group.titleBottomPadding,
143
+ gap: symbolDirection === "row" ? theme.spacing.spacer.small : theme.spacing.cell.content.titleDescriptionGap
144
+ }
145
+ })
146
+ );
147
+
148
+ export {
149
+ WorkOrderCell
150
+ };
@@ -0,0 +1,14 @@
1
+ import {
2
+ WorkOrderCell
3
+ } from "./chunk-GZZZUFR3.js";
4
+ import {
5
+ WorkOrderCellNavigation
6
+ } from "./chunk-6X2PRIG5.js";
7
+
8
+ // src/dfwcomponents/WorkOrderCell/index.ts
9
+ var WorkOrderCell2 = WorkOrderCell;
10
+ WorkOrderCell2.Navigation = WorkOrderCellNavigation;
11
+
12
+ export {
13
+ WorkOrderCell2 as WorkOrderCell
14
+ };
@@ -0,0 +1,72 @@
1
+ import {
2
+ PropertyRow
3
+ } from "./chunk-DQQOZB3E.js";
4
+
5
+ // src/dfwcomponents/WorkOrderCell/PropertyList.tsx
6
+ import React from "react";
7
+ import moment from "moment";
8
+ import { useToken } from "@equinor/mad-components";
9
+ var defaultWorkOrderLabelMap = {
10
+ title: "Title",
11
+ workOrder: "Work order",
12
+ maintenanceType: "Maintenance type",
13
+ functionalLocation: "Functional Location",
14
+ equipment: "Equipment",
15
+ activeStatus: "Active status",
16
+ basicStartDate: "Basic start",
17
+ basicFinishDate: "Basic finish",
18
+ requiredEnd: "Required end",
19
+ workCenter: "Work center"
20
+ };
21
+ var PropertyList = ({
22
+ workOrder,
23
+ valueColor,
24
+ currentDate,
25
+ overwriteLabel = {}
26
+ }) => {
27
+ const token = useToken();
28
+ const formatDate = (dateString) => moment(dateString).format("DD.MM.YYYY");
29
+ const requiredEnd = workOrder.requiredEnd ? new Date(workOrder.requiredEnd) : null;
30
+ const combinedDates = workOrder.basicStartDate && workOrder.basicFinishDate ? `${formatDate(workOrder.basicStartDate)} - ${formatDate(workOrder.basicFinishDate)}` : null;
31
+ const getLabel = (key) => {
32
+ var _a;
33
+ if (key === "basicStartDate" && combinedDates) {
34
+ return "Basic start / finish";
35
+ }
36
+ return (_a = overwriteLabel == null ? void 0 : overwriteLabel[key]) != null ? _a : defaultWorkOrderLabelMap[key];
37
+ };
38
+ const getDisplayValue = (key, value) => {
39
+ if (key === "basicStartDate" && combinedDates) {
40
+ return combinedDates;
41
+ }
42
+ if (["basicStartDate", "basicFinishDate", "requiredEnd"].includes(key)) {
43
+ return value ? formatDate(value) : "";
44
+ }
45
+ return value;
46
+ };
47
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, Object.entries(workOrder).map(([key, value], index) => {
48
+ const typedKey = key;
49
+ if (combinedDates && typedKey === "basicFinishDate")
50
+ return null;
51
+ if (value || typedKey === "basicStartDate" && combinedDates) {
52
+ const label = getLabel(typedKey);
53
+ const displayValue = getDisplayValue(typedKey, value);
54
+ const textColor = typedKey === "requiredEnd" && requiredEnd && currentDate > requiredEnd ? "danger" : valueColor;
55
+ return /* @__PURE__ */ React.createElement(
56
+ PropertyRow,
57
+ {
58
+ key: index,
59
+ label,
60
+ value: displayValue != null ? displayValue : "",
61
+ style: { marginBottom: token.spacing.cell.group.titleBottomPadding },
62
+ textColor
63
+ }
64
+ );
65
+ }
66
+ return null;
67
+ }));
68
+ };
69
+
70
+ export {
71
+ PropertyList
72
+ };
@@ -0,0 +1,69 @@
1
+ // src/dfwcomponents/WorkOrderCell/utils.ts
2
+ import moment from "moment";
3
+ var getStatusIconConfig = (status) => {
4
+ switch (status) {
5
+ case "RDEX":
6
+ return {
7
+ icon: "circle-outline",
8
+ label: "Ready for execution",
9
+ textColor: "textTertiary",
10
+ iconColor: "textPrimary"
11
+ };
12
+ case "STRT":
13
+ return {
14
+ icon: "circle-half-full",
15
+ label: "Started",
16
+ textColor: "textTertiary",
17
+ iconColor: "textPrimary"
18
+ };
19
+ case "RDOP":
20
+ return {
21
+ icon: "circle",
22
+ label: "Ready for operation",
23
+ textColor: "textTertiary",
24
+ iconColor: "textPrimary"
25
+ };
26
+ }
27
+ return void 0;
28
+ };
29
+ var getStatusIconsAndLabels = (activeStatusIds, requiredEndDate, currentDate, hseCritical, productionCritical) => {
30
+ const requiredEnd = requiredEndDate ? moment(requiredEndDate) : null;
31
+ const activeStatuses = activeStatusIds == null ? void 0 : activeStatusIds.split(" ");
32
+ const iconsAndLabels = [];
33
+ if (requiredEnd && currentDate > requiredEnd) {
34
+ iconsAndLabels.push({
35
+ icon: "alarm",
36
+ label: "Required end overdue",
37
+ textColor: "textTertiary",
38
+ iconColor: "danger"
39
+ });
40
+ }
41
+ if (hseCritical) {
42
+ iconsAndLabels.push({
43
+ icon: "alert-outline",
44
+ label: "HSE critical",
45
+ textColor: "textTertiary",
46
+ iconColor: "danger"
47
+ });
48
+ }
49
+ if (productionCritical) {
50
+ iconsAndLabels.push({
51
+ icon: "water-outline",
52
+ label: "Production critical",
53
+ textColor: "textTertiary",
54
+ iconColor: "danger"
55
+ });
56
+ }
57
+ activeStatuses == null ? void 0 : activeStatuses.forEach((status) => {
58
+ const statusConfig = getStatusIconConfig(status);
59
+ if (statusConfig) {
60
+ iconsAndLabels.push(statusConfig);
61
+ }
62
+ });
63
+ return iconsAndLabels;
64
+ };
65
+
66
+ export {
67
+ getStatusIconConfig,
68
+ getStatusIconsAndLabels
69
+ };
@@ -0,0 +1,19 @@
1
+ // src/dfwcomponents/WorkOrderCell/StatusIcon.tsx
2
+ import { EDSStyleSheet, Icon, Typography, useStyles } from "@equinor/mad-components";
3
+ import React from "react";
4
+ import { View } from "react-native";
5
+ var StatusIcon = ({ icon, label, textColor, iconColor }) => {
6
+ const styles = useStyles(themeStyles);
7
+ return /* @__PURE__ */ React.createElement(View, { style: styles.iconContainer }, /* @__PURE__ */ React.createElement(Icon, { name: icon, size: 24, color: iconColor }), label && /* @__PURE__ */ React.createElement(Typography, { numberOfLines: 1, group: "paragraph", variant: "caption", color: textColor }, label));
8
+ };
9
+ var themeStyles = EDSStyleSheet.create((theme) => ({
10
+ iconContainer: {
11
+ flexDirection: "row",
12
+ alignItems: "center",
13
+ gap: theme.spacing.cell.content.titleDescriptionGap
14
+ }
15
+ }));
16
+
17
+ export {
18
+ StatusIcon
19
+ };
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  PropertyRow
3
- } from "../../chunk-TGZYJ3XS.js";
3
+ } from "../../chunk-DQQOZB3E.js";
4
+ import "../../chunk-G2ADBYYC.js";
4
5
  export {
5
6
  PropertyRow
6
7
  };
@@ -1,7 +1,8 @@
1
1
  import "../../chunk-2JQRYR7Z.js";
2
2
  import {
3
3
  PropertyRow
4
- } from "../../chunk-TGZYJ3XS.js";
4
+ } from "../../chunk-DQQOZB3E.js";
5
+ import "../../chunk-G2ADBYYC.js";
5
6
  export {
6
7
  PropertyRow
7
8
  };
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { WorkOrder } from "./types";
3
+ import { Color } from "@equinor/mad-components";
4
+ type PropertyListProps = {
5
+ workOrder: Partial<WorkOrder>;
6
+ valueColor: Color;
7
+ currentDate: Date;
8
+ overwriteLabel?: Partial<Record<keyof WorkOrder, string>>;
9
+ };
10
+ export declare const PropertyList: ({ workOrder, valueColor, currentDate, overwriteLabel, }: PropertyListProps) => React.JSX.Element;
11
+ export {};
@@ -0,0 +1,9 @@
1
+ import {
2
+ PropertyList
3
+ } from "../../chunk-JRXLEWCW.js";
4
+ import "../../chunk-2JQRYR7Z.js";
5
+ import "../../chunk-DQQOZB3E.js";
6
+ import "../../chunk-G2ADBYYC.js";
7
+ export {
8
+ PropertyList
9
+ };
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import { StatusConfig } from "./types";
3
+ export declare const StatusIcon: ({ icon, label, textColor, iconColor }: StatusConfig) => React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import {
2
+ StatusIcon
3
+ } from "../../chunk-VDHOYF7Z.js";
4
+ import "../../chunk-G2ADBYYC.js";
5
+ export {
6
+ StatusIcon
7
+ };
@@ -1,22 +1,3 @@
1
1
  import React from "react";
2
- import { Color } from "@equinor/mad-components";
3
- export type WorkOrder = {
4
- title: string;
5
- workOrderId: string;
6
- maintenanceType?: string;
7
- tagId?: string;
8
- equipmentId?: string;
9
- activeStatusIds?: string;
10
- basicStartDate?: string;
11
- basicEndDate?: string;
12
- requiredEnd?: string;
13
- workCenterId?: string;
14
- };
15
- export type WorkOrderCellProps = {
16
- onStartButtonPress?: () => void;
17
- onCompleteButtonPress?: () => void;
18
- onPress?: () => void;
19
- showSymbols?: boolean;
20
- valueColor?: Color;
21
- } & WorkOrder;
22
- export declare const WorkOrderCell: ({ title, maintenanceType, onStartButtonPress, onCompleteButtonPress, onPress, showSymbols, valueColor, ...rest }: WorkOrderCellProps) => React.JSX.Element;
2
+ import { WorkOrderCellProps } from "./types";
3
+ export declare const WorkOrderCell: ({ title, maintenanceType, showSymbols, symbolDirection, valueColor, isHseCritical, isProductionCritical, overwriteLabel, style, startJobButton, readyForOperationButton, tecoButton, ...rest }: WorkOrderCellProps) => React.JSX.Element;
@@ -1,8 +1,12 @@
1
1
  import {
2
2
  WorkOrderCell
3
- } from "../../chunk-CERI4DFI.js";
3
+ } from "../../chunk-GZZZUFR3.js";
4
+ import "../../chunk-MCPLMBQO.js";
5
+ import "../../chunk-JRXLEWCW.js";
4
6
  import "../../chunk-2JQRYR7Z.js";
5
- import "../../chunk-TGZYJ3XS.js";
7
+ import "../../chunk-DQQOZB3E.js";
8
+ import "../../chunk-VDHOYF7Z.js";
9
+ import "../../chunk-G2ADBYYC.js";
6
10
  export {
7
11
  WorkOrderCell
8
12
  };
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { WorkOrderCellProps } from "./types";
3
+ type WorkOrderCellNavigationProps = WorkOrderCellProps & {
4
+ onPress: () => void;
5
+ };
6
+ export declare const WorkOrderCellNavigation: ({ title, maintenanceType, valueColor, isHseCritical, isProductionCritical, showSymbols, overwriteLabel, onPress, style, ...rest }: WorkOrderCellNavigationProps) => React.JSX.Element;
7
+ export {};
@@ -0,0 +1,12 @@
1
+ import {
2
+ WorkOrderCellNavigation
3
+ } from "../../chunk-6X2PRIG5.js";
4
+ import "../../chunk-MCPLMBQO.js";
5
+ import "../../chunk-JRXLEWCW.js";
6
+ import "../../chunk-2JQRYR7Z.js";
7
+ import "../../chunk-DQQOZB3E.js";
8
+ import "../../chunk-VDHOYF7Z.js";
9
+ import "../../chunk-G2ADBYYC.js";
10
+ export {
11
+ WorkOrderCellNavigation
12
+ };
@@ -1 +1,9 @@
1
- export * from "./WorkOrderCell";
1
+ import { WorkOrderCell as _WorkOrderCell } from "./WorkOrderCell";
2
+ import { WorkOrderCellNavigation } from "./WorkOrderCellNavigation";
3
+ import { WorkOrder, WorkOrderCellProps, StatusConfig } from "./types";
4
+ type WorkOrderCellFamily = typeof _WorkOrderCell & {
5
+ Navigation: typeof WorkOrderCellNavigation;
6
+ };
7
+ declare const WorkOrderCell: WorkOrderCellFamily;
8
+ export { WorkOrderCell };
9
+ export type { WorkOrder, WorkOrderCellProps, StatusConfig };
@@ -1,9 +1,14 @@
1
- import "../../chunk-RW7P2LMK.js";
2
1
  import {
3
2
  WorkOrderCell
4
- } from "../../chunk-CERI4DFI.js";
3
+ } from "../../chunk-H7FKL5KN.js";
4
+ import "../../chunk-GZZZUFR3.js";
5
+ import "../../chunk-6X2PRIG5.js";
6
+ import "../../chunk-MCPLMBQO.js";
7
+ import "../../chunk-JRXLEWCW.js";
5
8
  import "../../chunk-2JQRYR7Z.js";
6
- import "../../chunk-TGZYJ3XS.js";
9
+ import "../../chunk-DQQOZB3E.js";
10
+ import "../../chunk-VDHOYF7Z.js";
11
+ import "../../chunk-G2ADBYYC.js";
7
12
  export {
8
13
  WorkOrderCell
9
14
  };
@@ -0,0 +1,38 @@
1
+ import { Color, IconName } from "@equinor/mad-components";
2
+ import { ViewProps } from "react-native";
3
+ export type WorkOrder = {
4
+ title: string;
5
+ workOrder: string;
6
+ maintenanceType?: string;
7
+ equipment?: string;
8
+ activeStatus?: string;
9
+ basicStartDate?: string;
10
+ basicFinishDate?: string;
11
+ requiredEnd?: string;
12
+ workCenter?: string;
13
+ functionalLocation?: string;
14
+ };
15
+ type ButtonOptions = {
16
+ disabled?: boolean;
17
+ visible: boolean;
18
+ onPress: () => void;
19
+ };
20
+ export type WorkOrderCellProps = {
21
+ showSymbols?: boolean;
22
+ symbolDirection?: "column" | "row";
23
+ valueColor?: Color;
24
+ isHseCritical?: boolean;
25
+ isProductionCritical?: boolean;
26
+ style?: ViewProps["style"];
27
+ overwriteLabel?: Partial<Record<keyof WorkOrder, string>>;
28
+ startJobButton?: ButtonOptions;
29
+ readyForOperationButton?: ButtonOptions;
30
+ tecoButton?: ButtonOptions;
31
+ } & WorkOrder;
32
+ export type StatusConfig = {
33
+ icon: IconName;
34
+ label?: string;
35
+ textColor: Color;
36
+ iconColor: Color;
37
+ };
38
+ export {};
@@ -0,0 +1,4 @@
1
+ import moment from "moment";
2
+ import { StatusConfig } from "./types";
3
+ export declare const getStatusIconConfig: (status: string) => StatusConfig | undefined;
4
+ export declare const getStatusIconsAndLabels: (activeStatusIds: string | undefined, requiredEndDate: string | null, currentDate: moment.Moment, hseCritical?: boolean, productionCritical?: boolean) => StatusConfig[];
@@ -0,0 +1,9 @@
1
+ import {
2
+ getStatusIconConfig,
3
+ getStatusIconsAndLabels
4
+ } from "../../chunk-MCPLMBQO.js";
5
+ import "../../chunk-G2ADBYYC.js";
6
+ export {
7
+ getStatusIconConfig,
8
+ getStatusIconsAndLabels
9
+ };
package/dist/index.js CHANGED
@@ -1,11 +1,16 @@
1
- import "./chunk-RW7P2LMK.js";
2
1
  import {
3
2
  WorkOrderCell
4
- } from "./chunk-CERI4DFI.js";
3
+ } from "./chunk-H7FKL5KN.js";
4
+ import "./chunk-GZZZUFR3.js";
5
+ import "./chunk-6X2PRIG5.js";
6
+ import "./chunk-MCPLMBQO.js";
7
+ import "./chunk-JRXLEWCW.js";
5
8
  import "./chunk-2JQRYR7Z.js";
6
9
  import {
7
10
  PropertyRow
8
- } from "./chunk-TGZYJ3XS.js";
11
+ } from "./chunk-DQQOZB3E.js";
12
+ import "./chunk-VDHOYF7Z.js";
13
+ import "./chunk-G2ADBYYC.js";
9
14
  export {
10
15
  PropertyRow,
11
16
  WorkOrderCell
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/mad-dfw",
3
- "version": "0.1.5",
3
+ "version": "0.3.0",
4
4
  "description": "A React Native component library for the Digital Field Worker applications.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,179 +0,0 @@
1
- import {
2
- PropertyRow,
3
- __objRest
4
- } from "./chunk-TGZYJ3XS.js";
5
-
6
- // src/dfwcomponents/WorkOrderCell/WorkOrderCell.tsx
7
- import React, { useMemo } from "react";
8
- import { View } from "react-native";
9
- import {
10
- Button,
11
- Cell,
12
- Icon,
13
- Label,
14
- Typography,
15
- useStyles,
16
- EDSStyleSheet
17
- } from "@equinor/mad-components";
18
- var WorkOrderLabelMap = {
19
- title: "Title",
20
- workOrderId: "Work Order ID",
21
- maintenanceType: "Maintenance Type",
22
- tagId: "Tag ID",
23
- equipmentId: "Equipment ID",
24
- activeStatusIds: "Active Status IDs",
25
- basicStartDate: "Basic Start Date",
26
- basicEndDate: "Basic End Date",
27
- requiredEnd: "Required End",
28
- workCenterId: "Work Center ID"
29
- };
30
- var getStatusIconConfig = (status) => {
31
- switch (status) {
32
- case "RDEX":
33
- return {
34
- icon: "circle-outline",
35
- label: "Ready for execution",
36
- textColor: "textTertiary",
37
- iconColor: "textPrimary"
38
- };
39
- case "STRT":
40
- return {
41
- icon: "circle-half-full",
42
- label: "Started",
43
- textColor: "textTertiary",
44
- iconColor: "textPrimary"
45
- };
46
- case "RDOP":
47
- return {
48
- icon: "circle",
49
- label: "Ready for operation",
50
- textColor: "textTertiary",
51
- iconColor: "textPrimary"
52
- };
53
- }
54
- return void 0;
55
- };
56
- var WorkOrderCell = (_a) => {
57
- var _b = _a, {
58
- title,
59
- maintenanceType,
60
- onStartButtonPress,
61
- onCompleteButtonPress,
62
- onPress,
63
- showSymbols,
64
- valueColor = "textTertiary"
65
- } = _b, rest = __objRest(_b, [
66
- "title",
67
- "maintenanceType",
68
- "onStartButtonPress",
69
- "onCompleteButtonPress",
70
- "onPress",
71
- "showSymbols",
72
- "valueColor"
73
- ]);
74
- var _a2;
75
- const styles = useStyles(themeStyles);
76
- const activeStatuses = (_a2 = rest.activeStatusIds) == null ? void 0 : _a2.split(" ");
77
- const currentDate = /* @__PURE__ */ new Date();
78
- const requiredEnd = rest.requiredEnd ? new Date(rest.requiredEnd) : null;
79
- const iconsAndLabels = useMemo(() => {
80
- const result = [];
81
- if (requiredEnd && currentDate > requiredEnd) {
82
- result.push({
83
- icon: "alarm",
84
- label: "Required end overdue",
85
- textColor: "textTertiary",
86
- iconColor: "danger"
87
- });
88
- }
89
- activeStatuses == null ? void 0 : activeStatuses.forEach((status) => {
90
- const statusConfig = getStatusIconConfig(status);
91
- if (statusConfig) {
92
- result.push(statusConfig);
93
- }
94
- });
95
- return result;
96
- }, [activeStatuses, rest.requiredEnd]);
97
- const isStartDisabled = !!(activeStatuses == null ? void 0 : activeStatuses.includes("STRT")) || !!(activeStatuses == null ? void 0 : activeStatuses.includes("RDOP"));
98
- const isCompleteDisabled = !(activeStatuses == null ? void 0 : activeStatuses.includes("STRT")) || (activeStatuses == null ? void 0 : activeStatuses.includes("RDOP"));
99
- return /* @__PURE__ */ React.createElement(
100
- Cell,
101
- {
102
- onPress: onPress ? onPress : void 0,
103
- rightAdornment: onPress ? /* @__PURE__ */ React.createElement(View, { style: { justifyContent: "center" } }, /* @__PURE__ */ React.createElement(Icon, { name: "chevron-right" })) : null
104
- },
105
- /* @__PURE__ */ React.createElement(View, { style: { flex: 1 } }, /* @__PURE__ */ React.createElement(Typography, { numberOfLines: 1, variant: "h5", bold: true, style: { marginBottom: 16 } }, title), showSymbols && (iconsAndLabels == null ? void 0 : iconsAndLabels.map((item, index) => /* @__PURE__ */ React.createElement(View, { key: index, style: styles.iconContainer }, /* @__PURE__ */ React.createElement(Icon, { name: item.icon, size: 24, color: item.iconColor }), /* @__PURE__ */ React.createElement(
106
- Typography,
107
- {
108
- numberOfLines: 1,
109
- group: "paragraph",
110
- variant: "caption",
111
- color: item.textColor
112
- },
113
- item.label
114
- )))), /* @__PURE__ */ React.createElement(Label, { label: maintenanceType, style: { marginBottom: 8 } }), Object.entries(rest).map(([key, value], index) => {
115
- if (value) {
116
- const label = WorkOrderLabelMap[key];
117
- let displayValue = value;
118
- let requiredEndColor = valueColor;
119
- if (key === "basicStartDate" || key === "basicEndDate" || key === "requiredEnd") {
120
- displayValue = value ? new Date(value).toLocaleDateString() : "";
121
- }
122
- if (key === "requiredEnd" && requiredEnd && currentDate > requiredEnd) {
123
- requiredEndColor = "danger";
124
- }
125
- return /* @__PURE__ */ React.createElement(
126
- PropertyRow,
127
- {
128
- key: index,
129
- label,
130
- value: displayValue,
131
- style: { marginBottom: 8 },
132
- textColor: requiredEndColor
133
- }
134
- );
135
- }
136
- return null;
137
- }), (!!onStartButtonPress || !!onCompleteButtonPress) && /* @__PURE__ */ React.createElement(
138
- View,
139
- {
140
- style: {
141
- gap: 16,
142
- flexDirection: "row",
143
- justifyContent: "center",
144
- marginTop: 22
145
- }
146
- },
147
- onStartButtonPress && /* @__PURE__ */ React.createElement(
148
- Button,
149
- {
150
- title: "Start",
151
- onPress: onStartButtonPress,
152
- variant: "outlined",
153
- disabled: isStartDisabled
154
- }
155
- ),
156
- onCompleteButtonPress && /* @__PURE__ */ React.createElement(
157
- Button,
158
- {
159
- title: "Complete",
160
- onPress: onCompleteButtonPress,
161
- variant: "outlined",
162
- disabled: isCompleteDisabled
163
- }
164
- )
165
- ))
166
- );
167
- };
168
- var themeStyles = EDSStyleSheet.create(() => ({
169
- iconContainer: {
170
- flexDirection: "row",
171
- alignItems: "center",
172
- gap: 8,
173
- marginBottom: 8
174
- }
175
- }));
176
-
177
- export {
178
- WorkOrderCell
179
- };