@equinor/mad-dfw 0.0.3 → 0.0.4

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,14 @@
1
1
  # @equinor/mad-dfw
2
2
 
3
+ ## 0.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 15c1410: Added `WorkOrderCell` component.
8
+ - Updated dependencies [8adb0dc]
9
+ - Updated dependencies [496cd9a]
10
+ - @equinor/mad-components@0.11.3
11
+
3
12
  ## 0.0.3
4
13
 
5
14
  ### Patch Changes
@@ -0,0 +1,168 @@
1
+ import {
2
+ PropertyRow,
3
+ __objRest
4
+ } from "./chunk-KROUGXV5.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
+ workCenterId: "Work Center ID"
28
+ };
29
+ var getStatusIconConfig = (status) => {
30
+ switch (status) {
31
+ case "RDEX":
32
+ return {
33
+ icon: "circle-outline",
34
+ label: "Ready for execution",
35
+ textColor: "textTertiary",
36
+ iconColor: "textPrimary"
37
+ };
38
+ case "STRT":
39
+ return {
40
+ icon: "circle-half-full",
41
+ label: "Started",
42
+ textColor: "textTertiary",
43
+ iconColor: "textPrimary"
44
+ };
45
+ case "RDOP":
46
+ return {
47
+ icon: "circle",
48
+ label: "Ready for operation",
49
+ textColor: "textTertiary",
50
+ iconColor: "textPrimary"
51
+ };
52
+ }
53
+ return void 0;
54
+ };
55
+ var WorkOrderCell = (_a) => {
56
+ var _b = _a, {
57
+ title,
58
+ maintenanceType,
59
+ onStartButtonPress,
60
+ onCompleteButtonPress,
61
+ onPress,
62
+ showSymbols
63
+ } = _b, rest = __objRest(_b, [
64
+ "title",
65
+ "maintenanceType",
66
+ "onStartButtonPress",
67
+ "onCompleteButtonPress",
68
+ "onPress",
69
+ "showSymbols"
70
+ ]);
71
+ var _a2;
72
+ const styles = useStyles(themeStyles);
73
+ const activeStatuses = (_a2 = rest.activeStatusIds) == null ? void 0 : _a2.split(" ");
74
+ const iconsAndLabels = useMemo(() => {
75
+ const currentDate = /* @__PURE__ */ new Date();
76
+ const endDate = rest.basicEndDate ? new Date(rest.basicEndDate) : null;
77
+ const result = [];
78
+ if (endDate && currentDate > endDate) {
79
+ result.push({
80
+ icon: "alarm",
81
+ label: "Required end overdue",
82
+ textColor: "textTertiary",
83
+ iconColor: "danger"
84
+ });
85
+ }
86
+ activeStatuses == null ? void 0 : activeStatuses.forEach((status) => {
87
+ const statusConfig = getStatusIconConfig(status);
88
+ if (statusConfig) {
89
+ result.push(statusConfig);
90
+ }
91
+ });
92
+ return result;
93
+ }, [activeStatuses, rest.basicEndDate]);
94
+ const isStartDisabled = !!(activeStatuses == null ? void 0 : activeStatuses.includes("STRT")) || !!(activeStatuses == null ? void 0 : activeStatuses.includes("RDOP"));
95
+ const isCompleteDisabled = !(activeStatuses == null ? void 0 : activeStatuses.includes("STRT")) || (activeStatuses == null ? void 0 : activeStatuses.includes("RDOP"));
96
+ return /* @__PURE__ */ React.createElement(
97
+ Cell,
98
+ {
99
+ onPress: onPress ? onPress : void 0,
100
+ rightAdornment: onPress ? /* @__PURE__ */ React.createElement(View, { style: { justifyContent: "center" } }, /* @__PURE__ */ React.createElement(Icon, { name: "chevron-right" })) : null
101
+ },
102
+ /* @__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(
103
+ Typography,
104
+ {
105
+ numberOfLines: 1,
106
+ group: "paragraph",
107
+ variant: "caption",
108
+ color: item.textColor
109
+ },
110
+ item.label
111
+ )))), /* @__PURE__ */ React.createElement(Label, { label: maintenanceType, style: { marginBottom: 8 } }), Object.entries(rest).map(([key, value], index) => {
112
+ const label = WorkOrderLabelMap[key];
113
+ let displayValue = value;
114
+ if (key === "basicStartDate" || key === "basicEndDate") {
115
+ displayValue = value ? new Date(value).toLocaleDateString() : "";
116
+ }
117
+ return /* @__PURE__ */ React.createElement(
118
+ PropertyRow,
119
+ {
120
+ key: index,
121
+ label,
122
+ value: displayValue,
123
+ style: { marginBottom: 8 }
124
+ }
125
+ );
126
+ }), (!!onStartButtonPress || !!onCompleteButtonPress) && /* @__PURE__ */ React.createElement(
127
+ View,
128
+ {
129
+ style: {
130
+ gap: 16,
131
+ flexDirection: "row",
132
+ justifyContent: "center",
133
+ marginTop: 22
134
+ }
135
+ },
136
+ onStartButtonPress && /* @__PURE__ */ React.createElement(
137
+ Button,
138
+ {
139
+ title: "Start",
140
+ onPress: onStartButtonPress,
141
+ variant: "outlined",
142
+ disabled: isStartDisabled
143
+ }
144
+ ),
145
+ onCompleteButtonPress && /* @__PURE__ */ React.createElement(
146
+ Button,
147
+ {
148
+ title: "Complete",
149
+ onPress: onCompleteButtonPress,
150
+ variant: "outlined",
151
+ disabled: isCompleteDisabled
152
+ }
153
+ )
154
+ ))
155
+ );
156
+ };
157
+ var themeStyles = EDSStyleSheet.create(() => ({
158
+ iconContainer: {
159
+ flexDirection: "row",
160
+ alignItems: "center",
161
+ gap: 8,
162
+ marginBottom: 8
163
+ }
164
+ }));
165
+
166
+ export {
167
+ WorkOrderCell
168
+ };
@@ -76,5 +76,6 @@ var themeStyles = EDSStyleSheet.create((_, { breakpoint }) => ({
76
76
  }));
77
77
 
78
78
  export {
79
+ __objRest,
79
80
  PropertyRow
80
81
  };
File without changes
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PropertyRow
3
- } from "../../chunk-JLN4BW2C.js";
3
+ } from "../../chunk-KROUGXV5.js";
4
4
  export {
5
5
  PropertyRow
6
6
  };
@@ -1,7 +1,7 @@
1
1
  import "../../chunk-2JQRYR7Z.js";
2
2
  import {
3
3
  PropertyRow
4
- } from "../../chunk-JLN4BW2C.js";
4
+ } from "../../chunk-KROUGXV5.js";
5
5
  export {
6
6
  PropertyRow
7
7
  };
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ export type WorkOrder = {
3
+ title: string;
4
+ workOrderId: string;
5
+ maintenanceType?: string;
6
+ tagId?: string;
7
+ equipmentId?: string;
8
+ activeStatusIds?: string;
9
+ basicStartDate?: string;
10
+ basicEndDate?: string;
11
+ workCenterId?: string;
12
+ };
13
+ export type WorkOrderCellProps = {
14
+ onStartButtonPress?: () => void;
15
+ onCompleteButtonPress?: () => void;
16
+ onPress?: () => void;
17
+ showSymbols?: boolean;
18
+ } & WorkOrder;
19
+ export declare const WorkOrderCell: ({ title, maintenanceType, onStartButtonPress, onCompleteButtonPress, onPress, showSymbols, ...rest }: WorkOrderCellProps) => React.JSX.Element;
@@ -0,0 +1,8 @@
1
+ import {
2
+ WorkOrderCell
3
+ } from "../../chunk-ED7C2IER.js";
4
+ import "../../chunk-2JQRYR7Z.js";
5
+ import "../../chunk-KROUGXV5.js";
6
+ export {
7
+ WorkOrderCell
8
+ };
@@ -0,0 +1 @@
1
+ export * from "./WorkOrderCell";
@@ -0,0 +1,9 @@
1
+ import "../../chunk-RW7P2LMK.js";
2
+ import {
3
+ WorkOrderCell
4
+ } from "../../chunk-ED7C2IER.js";
5
+ import "../../chunk-2JQRYR7Z.js";
6
+ import "../../chunk-KROUGXV5.js";
7
+ export {
8
+ WorkOrderCell
9
+ };
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from "./dfwcomponents/PropertyRow";
2
+ export * from "./dfwcomponents/WorkOrderCell";
package/dist/index.js CHANGED
@@ -1,7 +1,12 @@
1
+ import "./chunk-RW7P2LMK.js";
2
+ import {
3
+ WorkOrderCell
4
+ } from "./chunk-ED7C2IER.js";
1
5
  import "./chunk-2JQRYR7Z.js";
2
6
  import {
3
7
  PropertyRow
4
- } from "./chunk-JLN4BW2C.js";
8
+ } from "./chunk-KROUGXV5.js";
5
9
  export {
6
- PropertyRow
10
+ PropertyRow,
11
+ WorkOrderCell
7
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/mad-dfw",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "A React Native component library for the Digital Field Worker applications.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -27,7 +27,7 @@
27
27
  "react-native": ">=0.70"
28
28
  },
29
29
  "dependencies": {
30
- "@equinor/mad-components": "0.11.2"
30
+ "@equinor/mad-components": "0.11.3"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@equinor/eslint-config-mad": "0.3.1"