@adcops/autocore-react 3.5.9 → 3.5.13

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 (76) hide show
  1. package/dist/components/index.d.ts +4 -0
  2. package/dist/components/index.d.ts.map +1 -1
  3. package/dist/components/index.js +1 -1
  4. package/dist/components/tis-editor/TisConfigEditor.css +11 -0
  5. package/dist/components/tis-editor/TisConfigEditor.d.ts.map +1 -1
  6. package/dist/components/tis-editor/TisConfigEditor.js +1 -1
  7. package/dist/components/tis-editor/editor/AuthoringContext.d.ts +37 -0
  8. package/dist/components/tis-editor/editor/AuthoringContext.d.ts.map +1 -0
  9. package/dist/components/tis-editor/editor/AuthoringContext.js +1 -0
  10. package/dist/components/tis-editor/editor/ChartViewDialog.d.ts +11 -0
  11. package/dist/components/tis-editor/editor/ChartViewDialog.d.ts.map +1 -1
  12. package/dist/components/tis-editor/editor/ChartViewDialog.js +1 -1
  13. package/dist/components/tis-editor/editor/FieldArrayEditor.d.ts.map +1 -1
  14. package/dist/components/tis-editor/editor/FieldArrayEditor.js +1 -1
  15. package/dist/components/tis-editor/editor/RawDataEditor.d.ts.map +1 -1
  16. package/dist/components/tis-editor/editor/RawDataEditor.js +1 -1
  17. package/dist/components/tis-editor/editor/TestFieldDialog.d.ts +7 -0
  18. package/dist/components/tis-editor/editor/TestFieldDialog.d.ts.map +1 -1
  19. package/dist/components/tis-editor/editor/TestFieldDialog.js +1 -1
  20. package/dist/components/tis-editor/editor/ViewsEditor.d.ts.map +1 -1
  21. package/dist/components/tis-editor/editor/ViewsEditor.js +1 -1
  22. package/dist/components/varpick/VariableInput.d.ts +41 -0
  23. package/dist/components/varpick/VariableInput.d.ts.map +1 -0
  24. package/dist/components/varpick/VariableInput.js +1 -0
  25. package/dist/components/varpick/VariablePicker.d.ts +45 -0
  26. package/dist/components/varpick/VariablePicker.d.ts.map +1 -0
  27. package/dist/components/varpick/VariablePicker.js +1 -0
  28. package/dist/components/varpick/index.d.ts +16 -0
  29. package/dist/components/varpick/index.d.ts.map +1 -0
  30. package/dist/components/varpick/index.js +1 -0
  31. package/dist/components/varpick/tisCatalogs.d.ts +85 -0
  32. package/dist/components/varpick/tisCatalogs.d.ts.map +1 -0
  33. package/dist/components/varpick/tisCatalogs.js +1 -0
  34. package/dist/components/varpick/varpick.css +167 -0
  35. package/dist/core/AutoCoreTagContext.d.ts.map +1 -1
  36. package/dist/core/AutoCoreTagContext.js +1 -1
  37. package/dist/core/AutoCoreTagTypes.d.ts +13 -0
  38. package/dist/core/AutoCoreTagTypes.d.ts.map +1 -1
  39. package/dist/hooks/index.d.ts +4 -0
  40. package/dist/hooks/index.d.ts.map +1 -1
  41. package/dist/hooks/index.js +1 -1
  42. package/dist/hooks/useGmVariables.d.ts +57 -0
  43. package/dist/hooks/useGmVariables.d.ts.map +1 -0
  44. package/dist/hooks/useGmVariables.js +1 -0
  45. package/dist/hooks/useSequenceProducers.d.ts +38 -0
  46. package/dist/hooks/useSequenceProducers.d.ts.map +1 -0
  47. package/dist/hooks/useSequenceProducers.js +1 -0
  48. package/package.json +5 -2
  49. package/src/components/index.ts +17 -0
  50. package/src/components/tis-editor/TisConfigEditor.css +11 -0
  51. package/src/components/tis-editor/TisConfigEditor.tsx +31 -0
  52. package/src/components/tis-editor/editor/AuthoringContext.tsx +43 -0
  53. package/src/components/tis-editor/editor/ChartViewDialog.tsx +24 -7
  54. package/src/components/tis-editor/editor/FieldArrayEditor.tsx +1 -0
  55. package/src/components/tis-editor/editor/RawDataEditor.tsx +7 -2
  56. package/src/components/tis-editor/editor/TestFieldDialog.tsx +66 -12
  57. package/src/components/tis-editor/editor/ViewsEditor.tsx +25 -0
  58. package/src/components/varpick/VariableInput.tsx +126 -0
  59. package/src/components/varpick/VariablePicker.tsx +168 -0
  60. package/src/components/varpick/index.ts +22 -0
  61. package/src/components/varpick/tisCatalogs.ts +235 -0
  62. package/src/components/varpick/varpick.css +167 -0
  63. package/src/core/AutoCoreTagContext.tsx +3 -1
  64. package/src/core/AutoCoreTagTypes.ts +14 -0
  65. package/src/hooks/index.ts +11 -0
  66. package/src/hooks/useGmVariables.ts +142 -0
  67. package/src/hooks/useSequenceProducers.ts +104 -0
  68. package/tools/tests/dist/TestFieldDialog-C4mKVh7q.js +32817 -0
  69. package/tools/tests/dist/autocore-react.css +257 -0
  70. package/tools/tests/dist/tis-editor.entry.js +8431 -40567
  71. package/tools/tests/dist/varpick.entry.js +113 -0
  72. package/tools/tests/live-server.probe.mjs +172 -0
  73. package/tools/tests/varpick.entry.tsx +81 -0
  74. package/tools/tests/varpick.test.mjs +208 -0
  75. package/tools/tests/vite.config.mjs +7 -2
  76. package/tools/tests/dist/tis-editor.entry.css +0 -90
@@ -0,0 +1,104 @@
1
+ /**
2
+ * useSequenceProducers — the names a method's sequence actually records.
3
+ *
4
+ * A TIS cycle field has two possible producers and the method editor could only
5
+ * ever see one of them:
6
+ *
7
+ * 1. `source: "gm.<var>"` — the generated `add_cycle()` reads the tag.
8
+ * 2. `source: null` — the value arrives with the row, matched by NAME. On
9
+ * gen4_ac that is the sequencer: `store_value` steps fill a row buffer and
10
+ * `tis.add_cycle` writes `cycle_data` verbatim, without checking it against
11
+ * `cycle_fields`.
12
+ *
13
+ * Because nothing checks the second one, both of its failure modes are silent:
14
+ * a declared column nothing stores is blank on every row forever, and a stored
15
+ * name with no column is recorded where nothing displays it. This hook reads
16
+ * the `.seq.json` so the editor can say so.
17
+ *
18
+ * The method id IS the sequence filename and the TIS method id — one name, set
19
+ * by the sequence workbench's New / Save As / Open. A product with no sequencer
20
+ * simply has no such file, which is why "could not read it" resolves to
21
+ * `undefined` and never to `[]`: an empty list would claim every cycle field
22
+ * has no producer.
23
+ */
24
+
25
+ import { useCallback, useContext, useEffect, useRef, useState } from 'react';
26
+ import { EventEmitterContext } from '../core/EventEmitterContext';
27
+ import { MessageType } from '../hub/CommandMessage';
28
+
29
+ /** Where the sequence library lives in the datastore. */
30
+ const METHOD_DIR = 'methods';
31
+ const METHOD_EXT = '.seq.json';
32
+
33
+ export interface UseSequenceProducersOptions {
34
+ /** Override the IPC layer (tests, playground). */
35
+ invoker?: (topic: string, messageType: number, payload: object) => Promise<any>;
36
+ }
37
+
38
+ export interface UseSequenceProducersResult {
39
+ /** `store_value` names, or `undefined` when there is no sequence to read. */
40
+ producedNames: string[] | undefined;
41
+ loading: boolean;
42
+ refresh: () => Promise<void>;
43
+ }
44
+
45
+ /** Every `store_value` name in a method, `cycle` bodies included. */
46
+ export function collectStoredNames(method: any): string[] {
47
+ const out: string[] = [];
48
+ const walk = (steps: any[]) => {
49
+ if (!Array.isArray(steps)) return;
50
+ for (const s of steps) {
51
+ if (!s || typeof s !== 'object') continue;
52
+ if (s.type === 'cycle') walk(s.body);
53
+ // A repeated measurement lives inside a `cycle` body, so a walk that
54
+ // stopped at the top level would miss exactly the methods that
55
+ // record the most.
56
+ if (s.type === 'store_value' && typeof s.name === 'string' && s.name.trim() !== '') {
57
+ if (!out.includes(s.name)) out.push(s.name);
58
+ }
59
+ }
60
+ };
61
+ walk(method?.steps);
62
+ return out;
63
+ }
64
+
65
+ export function useSequenceProducers(
66
+ methodId: string | null,
67
+ options?: UseSequenceProducersOptions,
68
+ ): UseSequenceProducersResult {
69
+ const ctx = useContext(EventEmitterContext);
70
+ const invoke = options?.invoker
71
+ ?? ((topic: string, messageType: number, payload: object) =>
72
+ ctx.invoke(topic as any, messageType as any, payload as any));
73
+
74
+ const invokeRef = useRef(invoke);
75
+ invokeRef.current = invoke;
76
+
77
+ const [producedNames, setProducedNames] = useState<string[] | undefined>(undefined);
78
+ const [loading, setLoading] = useState<boolean>(false);
79
+
80
+ const refresh = useCallback(async () => {
81
+ if (!methodId) { setProducedNames(undefined); return; }
82
+ setLoading(true);
83
+ try {
84
+ const topic = `datastore.${METHOD_DIR}/${methodId}${METHOD_EXT}`;
85
+ const resp: any = await invokeRef.current(topic, MessageType.Read, {});
86
+ if (resp?.success === false) { setProducedNames(undefined); return; }
87
+ const method = resp?.data ?? resp;
88
+ // Only a method-shaped object counts. A read that returns something
89
+ // else is "no sequence", not "a sequence storing nothing".
90
+ if (!method || !Array.isArray(method.steps)) { setProducedNames(undefined); return; }
91
+ setProducedNames(collectStoredNames(method));
92
+ } catch {
93
+ setProducedNames(undefined);
94
+ } finally {
95
+ setLoading(false);
96
+ }
97
+ }, [methodId]);
98
+
99
+ useEffect(() => { void refresh(); }, [refresh]);
100
+
101
+ return { producedNames, loading, refresh };
102
+ }
103
+
104
+ export default useSequenceProducers;