@equinor/mad-dfw 0.1.5 → 0.2.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,21 @@
1
1
  # @equinor/mad-dfw
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f5133b3: Splitted `WorkOrderCell` into a new component `WorkOrderCell.Navigation`. Removed
8
+ `onPress` from the WorkOrderCell. To get the onPress / navigation functionality, use
9
+ WorkOrderCell.Navigation. `tagId` label is removed/replaced with `functionalLocation`
10
+
11
+ ### Patch Changes
12
+
13
+ - f5133b3: Added technical complete button to the `WorkOrderCell` and a prop, showActions for
14
+ controlling the visibility of buttons
15
+ - f5133b3: Updated the default work order labels and added an overwriteLabel prop to allow
16
+ customization
17
+ - f5133b3: Created a new component `WorkOrderCell.Navigation`
18
+
3
19
  ## 0.1.5
4
20
 
5
21
  ### Patch Changes
@@ -0,0 +1,14 @@
1
+ import {
2
+ WorkOrderCell
3
+ } from "./chunk-EOMGHONK.js";
4
+ import {
5
+ WorkOrderCellNavigation
6
+ } from "./chunk-EYU4DV4X.js";
7
+
8
+ // src/dfwcomponents/WorkOrderCell/index.ts
9
+ var WorkOrderCell2 = WorkOrderCell;
10
+ WorkOrderCell2.Navigation = WorkOrderCellNavigation;
11
+
12
+ export {
13
+ WorkOrderCell2 as WorkOrderCell
14
+ };
@@ -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,133 @@
1
+ import {
2
+ getStatusIconsAndLabels
3
+ } from "./chunk-MCPLMBQO.js";
4
+ import {
5
+ PropertyList
6
+ } from "./chunk-TQDX6N52.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 { Button, Cell, EDSStyleSheet, Label, Typography, useStyles } from "@equinor/mad-components";
17
+ import moment from "moment";
18
+ import React, { useMemo } from "react";
19
+ import { View } from "react-native";
20
+ var WorkOrderCell = (_a) => {
21
+ var _b = _a, {
22
+ title,
23
+ maintenanceType,
24
+ showSymbols,
25
+ symbolDirection = "column",
26
+ valueColor = "textTertiary",
27
+ isHseCritical,
28
+ isProductionCritical,
29
+ showActions,
30
+ overwriteLabel,
31
+ style,
32
+ onStartButtonPress,
33
+ onCompleteButtonPress,
34
+ onTecoButtonPress
35
+ } = _b, rest = __objRest(_b, [
36
+ "title",
37
+ "maintenanceType",
38
+ "showSymbols",
39
+ "symbolDirection",
40
+ "valueColor",
41
+ "isHseCritical",
42
+ "isProductionCritical",
43
+ "showActions",
44
+ "overwriteLabel",
45
+ "style",
46
+ "onStartButtonPress",
47
+ "onCompleteButtonPress",
48
+ "onTecoButtonPress"
49
+ ]);
50
+ var _a2, _b2;
51
+ const styles = useStyles(themeStyles, { symbolDirection });
52
+ const currentDate = moment();
53
+ const activeStatuses = (_a2 = rest.activeStatusIds) == null ? void 0 : _a2.split(" ");
54
+ const isStartDisabled = (_b2 = activeStatuses == null ? void 0 : activeStatuses.includes("STRT")) != null ? _b2 : activeStatuses == null ? void 0 : activeStatuses.includes("RDOP");
55
+ const isCompleteDisabled = !(activeStatuses == null ? void 0 : activeStatuses.includes("STRT"));
56
+ const iconsAndLabels = useMemo(
57
+ () => {
58
+ var _a3;
59
+ return getStatusIconsAndLabels(
60
+ rest.activeStatusIds,
61
+ (_a3 = rest.requiredEnd) != null ? _a3 : null,
62
+ currentDate,
63
+ isHseCritical,
64
+ isProductionCritical
65
+ );
66
+ },
67
+ [rest.activeStatusIds, rest.requiredEnd, currentDate, isHseCritical, isProductionCritical]
68
+ );
69
+ 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(
70
+ PropertyList,
71
+ {
72
+ workOrder: rest,
73
+ overwriteLabel,
74
+ valueColor,
75
+ currentDate: currentDate.toDate()
76
+ }
77
+ ), showActions && /* @__PURE__ */ React.createElement(View, { style: styles.actionContainer }, showActions.startButton && /* @__PURE__ */ React.createElement(
78
+ Button,
79
+ {
80
+ title: "Start job",
81
+ variant: "outlined",
82
+ disabled: isStartDisabled,
83
+ onPress: onStartButtonPress
84
+ }
85
+ ), showActions.completeButton && /* @__PURE__ */ React.createElement(
86
+ Button,
87
+ {
88
+ title: "Ready for operation",
89
+ variant: "outlined",
90
+ disabled: isCompleteDisabled,
91
+ onPress: onCompleteButtonPress
92
+ }
93
+ ), showActions.tecoButton && /* @__PURE__ */ React.createElement(
94
+ Button,
95
+ {
96
+ title: "Technical complete",
97
+ variant: "outlined",
98
+ onPress: onTecoButtonPress
99
+ }
100
+ )));
101
+ };
102
+ var themeStyles = EDSStyleSheet.create(
103
+ (theme, { symbolDirection }) => ({
104
+ iconContainer: {
105
+ flexDirection: "row",
106
+ alignItems: "center",
107
+ gap: theme.spacing.cell.content.titleDescriptionGap,
108
+ marginBottom: theme.spacing.cell.group.titleBottomPadding
109
+ },
110
+ actionContainer: {
111
+ gap: theme.spacing.container.paddingVertical,
112
+ marginTop: theme.spacing.spacer.medium,
113
+ flexDirection: "row",
114
+ justifyContent: "center"
115
+ },
116
+ title: {
117
+ marginBottom: theme.spacing.container.paddingVertical
118
+ },
119
+ label: {
120
+ marginBottom: theme.spacing.cell.group.titleBottomPadding
121
+ },
122
+ iconListContainer: {
123
+ flexWrap: "wrap",
124
+ flexDirection: symbolDirection,
125
+ paddingBottom: theme.spacing.cell.group.titleBottomPadding,
126
+ gap: symbolDirection === "row" ? theme.spacing.spacer.medium : theme.spacing.cell.content.titleDescriptionGap
127
+ }
128
+ })
129
+ );
130
+
131
+ export {
132
+ WorkOrderCell
133
+ };
@@ -0,0 +1,96 @@
1
+ import {
2
+ getStatusIconsAndLabels
3
+ } from "./chunk-MCPLMBQO.js";
4
+ import {
5
+ PropertyList
6
+ } from "./chunk-TQDX6N52.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.activeStatusIds,
50
+ (_a2 = rest.requiredEnd) != null ? _a2 : null,
51
+ currentDate,
52
+ isHseCritical,
53
+ isProductionCritical
54
+ );
55
+ },
56
+ [rest.activeStatusIds, 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
+ };
@@ -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,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,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
+ workOrderId: "Work order ID",
12
+ maintenanceType: "Maintenance type",
13
+ functionalLocation: "Functional Location",
14
+ equipmentId: "Equipment",
15
+ activeStatusIds: "Active status",
16
+ basicStartDate: "Basic start",
17
+ basicFinishDate: "Basic finish",
18
+ requiredEnd: "Required end",
19
+ workCenterId: "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,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-TQDX6N52.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, showActions, overwriteLabel, style, onStartButtonPress, onCompleteButtonPress, onTecoButtonPress, ...rest }: WorkOrderCellProps) => React.JSX.Element;
@@ -1,8 +1,12 @@
1
1
  import {
2
2
  WorkOrderCell
3
- } from "../../chunk-CERI4DFI.js";
3
+ } from "../../chunk-EOMGHONK.js";
4
+ import "../../chunk-MCPLMBQO.js";
5
+ import "../../chunk-TQDX6N52.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-EYU4DV4X.js";
4
+ import "../../chunk-MCPLMBQO.js";
5
+ import "../../chunk-TQDX6N52.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-6POU5MQB.js";
4
+ import "../../chunk-EOMGHONK.js";
5
+ import "../../chunk-EYU4DV4X.js";
6
+ import "../../chunk-MCPLMBQO.js";
7
+ import "../../chunk-TQDX6N52.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
+ workOrderId: string;
6
+ maintenanceType?: string;
7
+ equipmentId?: string;
8
+ activeStatusIds?: string;
9
+ basicStartDate?: string;
10
+ basicFinishDate?: string;
11
+ requiredEnd?: string;
12
+ workCenterId?: string;
13
+ functionalLocation?: string;
14
+ };
15
+ export type WorkOrderCellActions = {
16
+ startButton?: boolean;
17
+ completeButton?: boolean;
18
+ tecoButton?: boolean;
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
+ showActions?: WorkOrderCellActions;
29
+ onStartButtonPress?: () => void;
30
+ onCompleteButtonPress?: () => void;
31
+ onTecoButtonPress?: () => void;
32
+ } & WorkOrder;
33
+ export type StatusConfig = {
34
+ icon: IconName;
35
+ label?: string;
36
+ textColor: Color;
37
+ iconColor: Color;
38
+ };
@@ -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-6POU5MQB.js";
4
+ import "./chunk-EOMGHONK.js";
5
+ import "./chunk-EYU4DV4X.js";
6
+ import "./chunk-MCPLMBQO.js";
7
+ import "./chunk-TQDX6N52.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.2.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
- };