@kosdev-code/kos-ddk-model-components 0.1.0-dev.5197 → 0.1.0-dev.5202

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.
@@ -1 +1 @@
1
- {"version":3,"file":"super-pump-card.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ddk/kos-ddk-model-components/src/components/pump-cards/super-pump/super-pump-card.tsx"],"names":[],"mappings":";AAQA,OAAO,EACL,KAAK,WAAW,EAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGL,KAAK,kBAAkB,EAExB,MAAM,gCAAgC,CAAC;AA2BxC,UAAU,iBAAiB;IACzB,MAAM,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC;CACzC;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CA6HjE,CAAC;AAEL,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"super-pump-card.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ddk/kos-ddk-model-components/src/components/pump-cards/super-pump/super-pump-card.tsx"],"names":[],"mappings":";AAQA,OAAO,EACL,KAAK,WAAW,EAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGL,KAAK,kBAAkB,EAExB,MAAM,gCAAgC,CAAC;AA4BxC,UAAU,iBAAiB;IACzB,MAAM,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC;CACzC;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CA4IjE,CAAC;AAEL,eAAe,aAAa,CAAC"}
@@ -10,6 +10,118 @@ export type PumpActionResponse = [
10
10
  (actionId: PumpAction) => Promise<void>,
11
11
  ActionLabels
12
12
  ];
13
- export declare const usePumpAction: (intentContainer: IntentAware, actionFactory?: Factory) => PumpActionResponse;
13
+ /**
14
+ * React hook for executing pump maintenance and diagnostic actions.
15
+ *
16
+ * This hook provides a unified interface for triggering various pump operations
17
+ * including calibration, priming, purging, and flow tests. It manages action
18
+ * state, progress tracking via KOS Futures, and internationalized labels.
19
+ *
20
+ * The hook supports optional intent containers, returning safe defaults when
21
+ * no container is provided. This allows components to render UI before models
22
+ * are fully loaded, supporting progressive enhancement patterns.
23
+ *
24
+ * Available pump actions:
25
+ * - `calibrate` - Calibrate pump flow rate
26
+ * - `prime` - Prime the pump line
27
+ * - `purge` - Purge the pump line
28
+ * - `flush` - Flush the system
29
+ * - `low-flow-test` - Run low flow rate test
30
+ * - `high-flow-test` - Run high flow rate test
31
+ * - `fixed-45` - Fixed 45oz pour test
32
+ * - `hold-to-pour` - Hold-to-pour operation
33
+ * - `manual-override` - Manual pump override
34
+ * - `msv-reset` - MSV reset operation
35
+ *
36
+ * @param intentContainer - Optional model implementing {@link IntentAware} interface.
37
+ * When undefined, hook returns null action and safe handlers that
38
+ * won't execute operations. This enables components to render before
39
+ * models are available.
40
+ * @param actionFactory - Optional factory function for custom action types.
41
+ * Defaults to {@link pumpActionFactory} with standard pump actions.
42
+ * Provide custom factory to extend available actions.
43
+ *
44
+ * @returns Tuple containing:
45
+ * - [0] {@link IntentAwareAction} instance or null (null when intentContainer undefined or before first action)
46
+ * - [1] `handleAction` function accepting {@link PumpAction} type strings to trigger operations
47
+ * - [2] {@link ActionLabels} object with internationalized strings (title, summary, success/failure messages, action label)
48
+ *
49
+ * @example
50
+ * Basic pump action controls:
51
+ * ```tsx
52
+ * import { usePumpAction } from '@kosdev-code/kos-ddk-model-components';
53
+ *
54
+ * function PumpControls({ pump }: { pump: PumpModel }) {
55
+ * const [action, handleAction, labels] = usePumpAction(pump);
56
+ *
57
+ * return (
58
+ * <div>
59
+ * <button onPointerDown={() => handleAction("calibrate")}>
60
+ * Calibrate
61
+ * </button>
62
+ * <button onPointerDown={() => handleAction("prime")}>
63
+ * Prime
64
+ * </button>
65
+ * <button onPointerDown={() => handleAction("purge")}>
66
+ * Purge
67
+ * </button>
68
+ * {action && (
69
+ * <FutureProgressBar
70
+ * title={labels.title}
71
+ * future={action.future}
72
+ * />
73
+ * )}
74
+ * </div>
75
+ * );
76
+ * }
77
+ * ```
78
+ *
79
+ * @example
80
+ * Handling optional pump (progressive enhancement):
81
+ * ```tsx
82
+ * function MaintenancePanel({ pump }: { pump?: PumpModel }) {
83
+ * const [action, handleAction, labels] = usePumpAction(pump);
84
+ *
85
+ * // Hook safely handles undefined pump - returns null action and safe handlers
86
+ * return (
87
+ * <div>
88
+ * <button
89
+ * disabled={!pump}
90
+ * onClick={() => handleAction("prime")}
91
+ * >
92
+ * {labels.actionLabel || 'Prime'}
93
+ * </button>
94
+ * {action && <ProgressDisplay action={action} />}
95
+ * </div>
96
+ * );
97
+ * }
98
+ * ```
99
+ *
100
+ * @example
101
+ * Custom action factory:
102
+ * ```tsx
103
+ * const customFactory = (actionId: PumpAction) => {
104
+ * if (actionId === "my-custom-action") return MyCustomAction;
105
+ * return pumpActionFactory(actionId);
106
+ * };
107
+ *
108
+ * function CustomPumpControls({ pump }: { pump: PumpModel }) {
109
+ * const [action, handleAction] = usePumpAction(pump, customFactory);
110
+ *
111
+ * return (
112
+ * <button onClick={() => handleAction("my-custom-action")}>
113
+ * Custom Operation
114
+ * </button>
115
+ * );
116
+ * }
117
+ * ```
118
+ *
119
+ * @category Hooks - Actions
120
+ * @see {@link IntentAware} for required model interface
121
+ * @see {@link PumpAction} for available action types
122
+ * @see {@link IntentAwareAction} for action execution and progress tracking
123
+ * @see {@link ActionLabels} for internationalization label structure
124
+ */
125
+ export declare const usePumpAction: (intentContainer?: IntentAware, actionFactory?: Factory) => PumpActionResponse;
14
126
  export {};
15
127
  //# sourceMappingURL=use-pump-action.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-pump-action.d.ts","sourceRoot":"","sources":["../../../../../../packages/ddk/kos-ddk-model-components/src/hooks/actions/use-pump-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EAWL,KAAK,iBAAiB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAEjE,KAAK,UAAU,GACX,WAAW,GACX,UAAU,GACV,OAAO,GACP,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,iBAAiB,GACjB,WAAW,GACX,OAAO,GACP,OAAO,CAAC;AAEZ,KAAK,OAAO,GAAG,CAAC,QAAQ,EAAE,UAAU,KAAK,eAAe,CAAC;AACzD,KAAK,eAAe,GAChB,CAAC,KAAK,eAAe,EAAE,WAAW,KAAK,iBAAiB,CAAC,GACzD,SAAS,CAAC;AAyCd,MAAM,MAAM,kBAAkB,GAAG;IAC/B,iBAAiB,GAAG,IAAI;IACxB,CAAC,QAAQ,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC;IACvC,YAAY;CACb,CAAC;AACF,eAAO,MAAM,aAAa,oBACP,WAAW,kBACb,OAAO,uBAsBvB,CAAC"}
1
+ {"version":3,"file":"use-pump-action.d.ts","sourceRoot":"","sources":["../../../../../../packages/ddk/kos-ddk-model-components/src/hooks/actions/use-pump-action.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EAWL,KAAK,iBAAiB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAEjE,KAAK,UAAU,GACX,WAAW,GACX,UAAU,GACV,OAAO,GACP,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,iBAAiB,GACjB,WAAW,GACX,OAAO,GACP,OAAO,CAAC;AAEZ,KAAK,OAAO,GAAG,CAAC,QAAQ,EAAE,UAAU,KAAK,eAAe,CAAC;AACzD,KAAK,eAAe,GAChB,CAAC,KAAK,eAAe,EAAE,WAAW,KAAK,iBAAiB,CAAC,GACzD,SAAS,CAAC;AAyCd,MAAM,MAAM,kBAAkB,GAAG;IAC/B,iBAAiB,GAAG,IAAI;IACxB,CAAC,QAAQ,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC;IACvC,YAAY;CACb,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+GG;AACH,eAAO,MAAM,aAAa,qBACN,WAAW,kBACd,OAAO,uBA2BvB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './use-pump-calibration';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/ddk/kos-ddk-model-components/src/hooks/calibration/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,93 @@
1
+ import { IntentAware, IntentContainer } from '../../../../../sdk/kos-dispense-sdk/src/index.ts';
2
+
3
+ /**
4
+ * Combined interface representing a model that supports both intent operations
5
+ * and intent volume resolution for calibration purposes.
6
+ *
7
+ * This interface combines {@link IntentAware} for executing intents with
8
+ * {@link IntentContainer} for resolving appropriate volumes, enabling complete
9
+ * calibration workflows that determine the correct volume and execute the operation.
10
+ *
11
+ * @category Hooks - Calibration
12
+ * @see {@link IntentAware} for intent execution capabilities
13
+ * @see {@link IntentContainer} for volume resolution capabilities
14
+ */
15
+ export type IntentAwareContainer = IntentAware & IntentContainer;
16
+ /**
17
+ * React hook for managing pump calibration operations and state.
18
+ *
19
+ * This hook retrieves the calibration volume from the device, tracks whether
20
+ * calibration is possible, and provides an action handler for triggering
21
+ * calibration operations. It combines volume resolution with the pump action
22
+ * pattern for a complete calibration workflow.
23
+ *
24
+ * The hook automatically:
25
+ * - Resolves the appropriate calibration volume from the device based on ingredient type
26
+ * - Updates the volume when the ingredient assignment changes
27
+ * - Tracks calibration readiness state (requires volume > 0 and assigned ingredient)
28
+ * - Provides action handlers integrated with the KOS Future system for progress tracking
29
+ *
30
+ * @param intentContainer - Optional model implementing {@link IntentAware} and {@link IntentContainer}
31
+ * interfaces, typically a holder or pump model. When undefined, the hook
32
+ * returns safe defaults (undefined volume, cannot calibrate).
33
+ *
34
+ * @returns Object containing calibration state and handlers:
35
+ * - `calibrateVolume`: Resolved calibration volume in oz (rounded to integer), or undefined if not yet resolved
36
+ * - `canCalibrate`: Boolean indicating if calibration is ready (volume > 0 and ingredient assigned)
37
+ * - `action`: Current {@link IntentAwareAction} instance or null (for progress tracking)
38
+ * - `handleAction`: Function to trigger pump actions including calibration (accepts {@link PumpAction} type strings)
39
+ *
40
+ * @example
41
+ * Basic calibration button with volume display:
42
+ * ```tsx
43
+ * import { usePumpCalibration } from '@kosdev-code/kos-ddk-model-components';
44
+ *
45
+ * function PumpCard({ holder }: { holder: HolderModel }) {
46
+ * const { calibrateVolume, canCalibrate, action, handleAction } =
47
+ * usePumpCalibration(holder);
48
+ *
49
+ * return (
50
+ * <div>
51
+ * <button
52
+ * disabled={!canCalibrate}
53
+ * onPointerDown={() => handleAction("calibrate")}
54
+ * >
55
+ * Calibrate {canCalibrate && `(${calibrateVolume} oz)`}
56
+ * </button>
57
+ * {action && <FutureProgressBar {...action} />}
58
+ * </div>
59
+ * );
60
+ * }
61
+ * ```
62
+ *
63
+ * @example
64
+ * Handling optional holder (graceful degradation):
65
+ * ```tsx
66
+ * function PumpControls({ holder }: { holder?: HolderModel }) {
67
+ * const { calibrateVolume, canCalibrate, handleAction } =
68
+ * usePumpCalibration(holder);
69
+ *
70
+ * // Hook safely handles undefined holder
71
+ * if (!holder) return <div>No pump selected</div>;
72
+ *
73
+ * return (
74
+ * <button disabled={!canCalibrate} onClick={() => handleAction("calibrate")}>
75
+ * Calibrate ({calibrateVolume ?? '...'} oz)
76
+ * </button>
77
+ * );
78
+ * }
79
+ * ```
80
+ *
81
+ * @category Hooks - Calibration
82
+ * @see {@link usePumpAction} for the underlying action handler
83
+ * @see {@link IntentAware} for intent operation interface
84
+ * @see {@link IntentContainer} for volume resolution interface
85
+ * @see {@link IntentAwareAction} for action execution and progress tracking
86
+ */
87
+ export declare const usePumpCalibration: (intentContainer?: IntentAwareContainer) => {
88
+ calibrateVolume: number | undefined;
89
+ canCalibrate: boolean | 0 | undefined;
90
+ action: import('../..').IntentAwareAction | null;
91
+ handleAction: (actionId: "calibrate" | "fixed-45" | "flush" | "high-flow-test" | "hold-to-pour" | "low-flow-test" | "manual-override" | "msv-reset" | "prime" | "purge") => Promise<void>;
92
+ };
93
+ //# sourceMappingURL=use-pump-calibration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pump-calibration.d.ts","sourceRoot":"","sources":["../../../../../../packages/ddk/kos-ddk-model-components/src/hooks/calibration/use-pump-calibration.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EAChB,MAAM,+BAA+B,CAAC;AAIvC;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,eAAe,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AACH,eAAO,MAAM,kBAAkB,qBAAsB,oBAAoB;;;;;CAgBxE,CAAC"}
package/hooks/index.d.ts CHANGED
@@ -22,6 +22,7 @@ export * from './reboot';
22
22
  export * from './settings';
23
23
  export * from './setup-step';
24
24
  export * from './setup-step-container';
25
+ export * from './calibration';
25
26
  export * from './start';
26
27
  export * from './trouble-action';
27
28
  export * from './troubles';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/ddk/kos-ddk-model-components/src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AAEvC,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/ddk/kos-ddk-model-components/src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AAEvC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC"}