@equinor/mad-dfw 0.0.2 → 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,20 @@
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
+
12
+ ## 0.0.3
13
+
14
+ ### Patch Changes
15
+
16
+ - 61a8d3e: Added propertyrow component
17
+
3
18
  ## 0.0.2
4
19
 
5
20
  ### 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
+ };
@@ -0,0 +1,81 @@
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
+ // src/dfwcomponents/PropertyRow/PropertyRow.tsx
34
+ import React from "react";
35
+ import {
36
+ EDSStyleSheet,
37
+ useStyles,
38
+ useBreakpoint,
39
+ Icon,
40
+ Typography
41
+ } from "@equinor/mad-components";
42
+ import { View } from "react-native";
43
+ var PropertyRow = (_a) => {
44
+ var _b = _a, { label, value, iconName } = _b, rest = __objRest(_b, ["label", "value", "iconName"]);
45
+ const breakpoint = useBreakpoint();
46
+ const styles = useStyles(themeStyles, { breakpoint });
47
+ const renderIcon = () => iconName && /* @__PURE__ */ React.createElement(Icon, { name: iconName, size: 20, style: styles.iconStyle, color: "textTertiary" });
48
+ const labelProps = breakpoint === "xs" ? { group: "paragraph", variant: "overline" } : { group: "paragraph", variant: "body_short" };
49
+ return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, rest), { style: [styles.propertyLabel, rest.style] }), breakpoint === "xs" && renderIcon(), /* @__PURE__ */ React.createElement(View, { style: styles.textContainer }, /* @__PURE__ */ React.createElement(View, { style: styles.labelStyle }, breakpoint !== "xs" && renderIcon(), /* @__PURE__ */ React.createElement(Typography, __spreadProps(__spreadValues({}, labelProps), { color: "textTertiary" }), label)), /* @__PURE__ */ React.createElement(
50
+ Typography,
51
+ {
52
+ group: "paragraph",
53
+ variant: "body_short",
54
+ color: "textTertiary",
55
+ style: { flex: 1 },
56
+ numberOfLines: 1
57
+ },
58
+ value
59
+ )));
60
+ };
61
+ var themeStyles = EDSStyleSheet.create((_, { breakpoint }) => ({
62
+ propertyLabel: {
63
+ flexDirection: "row",
64
+ alignItems: "center"
65
+ },
66
+ iconStyle: {
67
+ paddingRight: 10
68
+ },
69
+ labelStyle: {
70
+ flexDirection: "row",
71
+ minWidth: breakpoint !== "xs" ? 232 : 0
72
+ },
73
+ textContainer: {
74
+ flexDirection: breakpoint === "xs" ? "column" : "row"
75
+ }
76
+ }));
77
+
78
+ export {
79
+ __objRest,
80
+ PropertyRow
81
+ };
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { IconName } from "@equinor/mad-components";
3
+ import { ViewProps } from "react-native";
4
+ export type PropertyRowProps = {
5
+ label: string;
6
+ value: string;
7
+ iconName?: IconName;
8
+ } & ViewProps;
9
+ export declare const PropertyRow: ({ label, value, iconName, ...rest }: PropertyRowProps) => React.JSX.Element;
@@ -0,0 +1,6 @@
1
+ import {
2
+ PropertyRow
3
+ } from "../../chunk-KROUGXV5.js";
4
+ export {
5
+ PropertyRow
6
+ };
@@ -0,0 +1 @@
1
+ export * from "./PropertyRow";
@@ -0,0 +1,7 @@
1
+ import "../../chunk-2JQRYR7Z.js";
2
+ import {
3
+ PropertyRow
4
+ } from "../../chunk-KROUGXV5.js";
5
+ export {
6
+ PropertyRow
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
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./dfwcomponents/PropertyRow";
2
+ export * from "./dfwcomponents/WorkOrderCell";
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import "./chunk-RW7P2LMK.js";
2
+ import {
3
+ WorkOrderCell
4
+ } from "./chunk-ED7C2IER.js";
5
+ import "./chunk-2JQRYR7Z.js";
6
+ import {
7
+ PropertyRow
8
+ } from "./chunk-KROUGXV5.js";
9
+ export {
10
+ PropertyRow,
11
+ WorkOrderCell
12
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/mad-dfw",
3
- "version": "0.0.2",
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"
File without changes