@adcops/autocore-react 3.3.124 → 3.5.5
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/dist/components/UnitSystemSelector.d.ts +17 -0
- package/dist/components/UnitSystemSelector.d.ts.map +1 -0
- package/dist/components/UnitSystemSelector.js +1 -0
- package/dist/components/UnitsEditor.d.ts +11 -0
- package/dist/components/UnitsEditor.d.ts.map +1 -0
- package/dist/components/UnitsEditor.js +1 -0
- package/dist/components/ams/AmsProvider.d.ts +14 -0
- package/dist/components/ams/AmsProvider.d.ts.map +1 -1
- package/dist/components/ams/AmsProvider.js +1 -1
- package/dist/components/ams/AssetDetailView.d.ts.map +1 -1
- package/dist/components/ams/AssetDetailView.js +1 -1
- package/dist/components/ams/AssetNameplateGrid.d.ts +13 -0
- package/dist/components/ams/AssetNameplateGrid.d.ts.map +1 -0
- package/dist/components/ams/AssetNameplateGrid.js +1 -0
- package/dist/components/ams/InstalledAssetPicker.d.ts +35 -0
- package/dist/components/ams/InstalledAssetPicker.d.ts.map +1 -0
- package/dist/components/ams/InstalledAssetPicker.js +1 -0
- package/dist/components/ams/index.d.ts +5 -0
- package/dist/components/ams/index.d.ts.map +1 -1
- package/dist/components/ams/index.js +1 -1
- package/dist/components/ams/useInstalledAsset.d.ts +26 -0
- package/dist/components/ams/useInstalledAsset.d.ts.map +1 -0
- package/dist/components/ams/useInstalledAsset.js +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/tis/ResultHistoryTable.d.ts.map +1 -1
- package/dist/components/tis/ResultHistoryTable.js +1 -1
- package/dist/components/tis/ScienceTable.d.ts.map +1 -1
- package/dist/components/tis/ScienceTable.js +1 -1
- package/dist/components/tis/TestDataView.d.ts +16 -4
- package/dist/components/tis/TestDataView.d.ts.map +1 -1
- package/dist/components/tis/TestDataView.js +1 -1
- package/dist/components/tis/TestFieldRow.d.ts +88 -7
- package/dist/components/tis/TestFieldRow.d.ts.map +1 -1
- package/dist/components/tis/TestFieldRow.js +1 -1
- package/dist/components/tis/TestSetupForm.d.ts.map +1 -1
- package/dist/components/tis/TestSetupForm.js +1 -1
- package/dist/components/tis/TisProvider.d.ts.map +1 -1
- package/dist/components/tis/TisProvider.js +1 -1
- package/dist/components/tis-editor/editor/TestFieldDialog.d.ts.map +1 -1
- package/dist/components/tis-editor/editor/TestFieldDialog.js +1 -1
- package/dist/components/tis-editor/types.d.ts +6 -2
- package/dist/components/tis-editor/types.d.ts.map +1 -1
- package/dist/core/AutoCoreTagContext.d.ts.map +1 -1
- package/dist/core/AutoCoreTagContext.js +1 -1
- package/dist/core/AutoCoreTagTypes.d.ts +82 -7
- package/dist/core/AutoCoreTagTypes.d.ts.map +1 -1
- package/dist/core/formatScaled.d.ts +16 -0
- package/dist/core/formatScaled.d.ts.map +1 -0
- package/dist/core/formatScaled.js +1 -0
- package/dist/hooks/useAutoCoreTag.d.ts +11 -3
- package/dist/hooks/useAutoCoreTag.d.ts.map +1 -1
- package/dist/hooks/useAutoCoreTag.js +1 -1
- package/package.json +1 -1
- package/src/components/UnitSystemSelector.tsx +88 -0
- package/src/components/UnitsEditor.tsx +317 -0
- package/src/components/ams/AmsProvider.tsx +36 -1
- package/src/components/ams/AssetDetailView.tsx +2 -20
- package/src/components/ams/AssetNameplateGrid.tsx +62 -0
- package/src/components/ams/InstalledAssetPicker.tsx +209 -0
- package/src/components/ams/index.ts +7 -0
- package/src/components/ams/useInstalledAsset.ts +108 -0
- package/src/components/index.ts +4 -0
- package/src/components/tis/ResultHistoryTable.tsx +89 -6
- package/src/components/tis/ScienceTable.tsx +13 -0
- package/src/components/tis/TestDataView.tsx +153 -35
- package/src/components/tis/TestFieldRow.tsx +157 -19
- package/src/components/tis/TestSetupForm.tsx +35 -7
- package/src/components/tis/TisProvider.tsx +46 -3
- package/src/components/tis-editor/editor/TestFieldDialog.tsx +29 -18
- package/src/components/tis-editor/types.ts +6 -2
- package/src/core/AutoCoreTagContext.tsx +165 -16
- package/src/core/AutoCoreTagTypes.ts +91 -7
- package/src/core/formatScaled.ts +72 -0
- package/src/hooks/useAutoCoreTag.ts +51 -3
- package/todo.md +6 -0
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { useCallback, useContext, useMemo } from "react";
|
|
17
|
-
import type { BaseContextValue, TagConfig, TagValueMap } from "../core/AutoCoreTagTypes";
|
|
17
|
+
import type { BaseContextValue, ScaleConfig, TagConfig, TagValueMap } from "../core/AutoCoreTagTypes";
|
|
18
18
|
|
|
19
19
|
export function makeAutoCoreTagHooks<Spec extends readonly TagConfig[]>(
|
|
20
20
|
Context: React.Context<BaseContextValue<TagValueMap<Spec>>>,
|
|
@@ -96,12 +96,60 @@ export function makeAutoCoreTagHooks<Spec extends readonly TagConfig[]>(
|
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
98
|
* Access scale configurations and update functions.
|
|
99
|
+
*
|
|
100
|
+
* `getScale` NEVER returns undefined. Callers destructure it directly
|
|
101
|
+
* (`const { label } = getScale("load")`), so handing back undefined for an
|
|
102
|
+
* unknown group throws inside render and white-screens the whole HMI — on a
|
|
103
|
+
* machine, that is the operator losing the screen over a missing unit label.
|
|
104
|
+
* An unknown group yields an identity scale instead: no conversion, empty
|
|
105
|
+
* label, which is the same thing the provider did before units.json existed.
|
|
99
106
|
*/
|
|
100
107
|
const useScales = () => {
|
|
101
108
|
const { scales, updateScale } = useContext(Context);
|
|
102
|
-
const getScale = useCallback(
|
|
109
|
+
const getScale = useCallback(
|
|
110
|
+
(scaleName: string): ScaleConfig =>
|
|
111
|
+
scales[scaleName] ?? { name: scaleName, scale: 1, label: "" },
|
|
112
|
+
[scales],
|
|
113
|
+
);
|
|
103
114
|
return { scales, updateScale, getScale } as const;
|
|
104
115
|
};
|
|
105
116
|
|
|
106
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Access the machine's units table, the active display system, the live
|
|
119
|
+
* switch, and the shared formatter.
|
|
120
|
+
*
|
|
121
|
+
* `format(quantity, backendValue)` is the one place display precision is
|
|
122
|
+
* applied — use it rather than `toFixed` so a readout, a table cell and a
|
|
123
|
+
* chart tick can never disagree. It takes a BACKEND value; conversion to the
|
|
124
|
+
* active system happens inside.
|
|
125
|
+
*/
|
|
126
|
+
const useUnits = () => {
|
|
127
|
+
const { units, activeSystem, setUnitSystem, formatQuantity, scales } =
|
|
128
|
+
useContext(Context);
|
|
129
|
+
const label = useCallback(
|
|
130
|
+
(quantity: string) => scales[quantity]?.label ?? "",
|
|
131
|
+
[scales],
|
|
132
|
+
);
|
|
133
|
+
const format = useCallback(
|
|
134
|
+
(quantity: string, backendValue: number) =>
|
|
135
|
+
formatQuantity ? formatQuantity(quantity, backendValue) : String(backendValue),
|
|
136
|
+
[formatQuantity],
|
|
137
|
+
);
|
|
138
|
+
return {
|
|
139
|
+
units: units ?? null,
|
|
140
|
+
activeSystem: activeSystem ?? null,
|
|
141
|
+
systems: units?.systems ?? [],
|
|
142
|
+
setUnitSystem,
|
|
143
|
+
label,
|
|
144
|
+
format,
|
|
145
|
+
} as const;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
useAutoCoreTag,
|
|
150
|
+
useAutoCoreTags,
|
|
151
|
+
useAutoCoreSelect,
|
|
152
|
+
useScales,
|
|
153
|
+
useUnits,
|
|
154
|
+
} as const;
|
|
107
155
|
}
|
package/todo.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# TODO
|
|
2
2
|
|
|
3
|
+
## 3.5.0 — Units & scales
|
|
4
|
+
<!-- NOT 4.0: that is a separate in-progress branch. -->
|
|
5
|
+
- [ ] Replace `ScaleConfig` / `acScales` with quantity-based derivation from the
|
|
6
|
+
project `units` block + GNV `active_unit_system`. Design plan:
|
|
7
|
+
**`autocore-server/UNITS_PLAN.md`** (§5.3 is the autocore-react section).
|
|
8
|
+
|
|
3
9
|
## Integration
|
|
4
10
|
- [x] Hub class to route to and from the back end
|
|
5
11
|
- -[x] The Hub should also be the dispatcher. I can't think of a reason they should be separate.
|