@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.
Files changed (77) hide show
  1. package/dist/components/UnitSystemSelector.d.ts +17 -0
  2. package/dist/components/UnitSystemSelector.d.ts.map +1 -0
  3. package/dist/components/UnitSystemSelector.js +1 -0
  4. package/dist/components/UnitsEditor.d.ts +11 -0
  5. package/dist/components/UnitsEditor.d.ts.map +1 -0
  6. package/dist/components/UnitsEditor.js +1 -0
  7. package/dist/components/ams/AmsProvider.d.ts +14 -0
  8. package/dist/components/ams/AmsProvider.d.ts.map +1 -1
  9. package/dist/components/ams/AmsProvider.js +1 -1
  10. package/dist/components/ams/AssetDetailView.d.ts.map +1 -1
  11. package/dist/components/ams/AssetDetailView.js +1 -1
  12. package/dist/components/ams/AssetNameplateGrid.d.ts +13 -0
  13. package/dist/components/ams/AssetNameplateGrid.d.ts.map +1 -0
  14. package/dist/components/ams/AssetNameplateGrid.js +1 -0
  15. package/dist/components/ams/InstalledAssetPicker.d.ts +35 -0
  16. package/dist/components/ams/InstalledAssetPicker.d.ts.map +1 -0
  17. package/dist/components/ams/InstalledAssetPicker.js +1 -0
  18. package/dist/components/ams/index.d.ts +5 -0
  19. package/dist/components/ams/index.d.ts.map +1 -1
  20. package/dist/components/ams/index.js +1 -1
  21. package/dist/components/ams/useInstalledAsset.d.ts +26 -0
  22. package/dist/components/ams/useInstalledAsset.d.ts.map +1 -0
  23. package/dist/components/ams/useInstalledAsset.js +1 -0
  24. package/dist/components/index.d.ts +4 -0
  25. package/dist/components/index.d.ts.map +1 -1
  26. package/dist/components/index.js +1 -1
  27. package/dist/components/tis/ResultHistoryTable.d.ts.map +1 -1
  28. package/dist/components/tis/ResultHistoryTable.js +1 -1
  29. package/dist/components/tis/ScienceTable.d.ts.map +1 -1
  30. package/dist/components/tis/ScienceTable.js +1 -1
  31. package/dist/components/tis/TestDataView.d.ts +16 -4
  32. package/dist/components/tis/TestDataView.d.ts.map +1 -1
  33. package/dist/components/tis/TestDataView.js +1 -1
  34. package/dist/components/tis/TestFieldRow.d.ts +88 -7
  35. package/dist/components/tis/TestFieldRow.d.ts.map +1 -1
  36. package/dist/components/tis/TestFieldRow.js +1 -1
  37. package/dist/components/tis/TestSetupForm.d.ts.map +1 -1
  38. package/dist/components/tis/TestSetupForm.js +1 -1
  39. package/dist/components/tis/TisProvider.d.ts.map +1 -1
  40. package/dist/components/tis/TisProvider.js +1 -1
  41. package/dist/components/tis-editor/editor/TestFieldDialog.d.ts.map +1 -1
  42. package/dist/components/tis-editor/editor/TestFieldDialog.js +1 -1
  43. package/dist/components/tis-editor/types.d.ts +6 -2
  44. package/dist/components/tis-editor/types.d.ts.map +1 -1
  45. package/dist/core/AutoCoreTagContext.d.ts.map +1 -1
  46. package/dist/core/AutoCoreTagContext.js +1 -1
  47. package/dist/core/AutoCoreTagTypes.d.ts +82 -7
  48. package/dist/core/AutoCoreTagTypes.d.ts.map +1 -1
  49. package/dist/core/formatScaled.d.ts +16 -0
  50. package/dist/core/formatScaled.d.ts.map +1 -0
  51. package/dist/core/formatScaled.js +1 -0
  52. package/dist/hooks/useAutoCoreTag.d.ts +11 -3
  53. package/dist/hooks/useAutoCoreTag.d.ts.map +1 -1
  54. package/dist/hooks/useAutoCoreTag.js +1 -1
  55. package/package.json +1 -1
  56. package/src/components/UnitSystemSelector.tsx +88 -0
  57. package/src/components/UnitsEditor.tsx +317 -0
  58. package/src/components/ams/AmsProvider.tsx +36 -1
  59. package/src/components/ams/AssetDetailView.tsx +2 -20
  60. package/src/components/ams/AssetNameplateGrid.tsx +62 -0
  61. package/src/components/ams/InstalledAssetPicker.tsx +209 -0
  62. package/src/components/ams/index.ts +7 -0
  63. package/src/components/ams/useInstalledAsset.ts +108 -0
  64. package/src/components/index.ts +4 -0
  65. package/src/components/tis/ResultHistoryTable.tsx +89 -6
  66. package/src/components/tis/ScienceTable.tsx +13 -0
  67. package/src/components/tis/TestDataView.tsx +153 -35
  68. package/src/components/tis/TestFieldRow.tsx +157 -19
  69. package/src/components/tis/TestSetupForm.tsx +35 -7
  70. package/src/components/tis/TisProvider.tsx +46 -3
  71. package/src/components/tis-editor/editor/TestFieldDialog.tsx +29 -18
  72. package/src/components/tis-editor/types.ts +6 -2
  73. package/src/core/AutoCoreTagContext.tsx +165 -16
  74. package/src/core/AutoCoreTagTypes.ts +91 -7
  75. package/src/core/formatScaled.ts +72 -0
  76. package/src/hooks/useAutoCoreTag.ts +51 -3
  77. 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((scaleName: string) => scales[scaleName], [scales]);
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
- return { useAutoCoreTag, useAutoCoreTags, useAutoCoreSelect, useScales } as const;
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.