@kopexa/extension-controlref 1.0.0 → 13.0.0

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 (126) hide show
  1. package/dist/chunk-4C72VBLP.mjs +52 -0
  2. package/dist/chunk-A7FWOQDN.mjs +210 -0
  3. package/dist/chunk-AQTNFDGA.mjs +57 -0
  4. package/dist/chunk-D53W4HWR.mjs +245 -0
  5. package/dist/chunk-FTEE5U3H.mjs +37 -0
  6. package/dist/chunk-GYDJVHHG.mjs +250 -0
  7. package/dist/chunk-IMHLTRZJ.mjs +29 -0
  8. package/dist/chunk-JM66CQVD.mjs +10 -0
  9. package/dist/chunk-LMKP3DDN.mjs +189 -0
  10. package/dist/chunk-RTBFRPB3.mjs +186 -0
  11. package/dist/chunk-TEDXYIGO.mjs +38 -0
  12. package/dist/chunk-WIS7ZNTO.mjs +4 -0
  13. package/dist/chunk-X46EFFCE.mjs +148 -0
  14. package/dist/chunk-XHD2KFKQ.mjs +16 -0
  15. package/dist/chunk-ZRKYAFRY.mjs +46 -0
  16. package/dist/chunk-ZUR6XKMG.mjs +21 -0
  17. package/dist/components/control-block-view.d.mts +6 -0
  18. package/dist/components/control-block-view.d.ts +6 -0
  19. package/dist/components/control-block-view.js +789 -0
  20. package/dist/components/control-block-view.mjs +11 -0
  21. package/dist/components/control-implementation-view.d.mts +6 -0
  22. package/dist/components/control-implementation-view.d.ts +6 -0
  23. package/dist/components/control-implementation-view.js +52 -0
  24. package/dist/components/control-implementation-view.mjs +7 -0
  25. package/dist/components/control-picker.d.mts +25 -0
  26. package/dist/components/control-picker.d.ts +25 -0
  27. package/dist/components/control-picker.js +522 -0
  28. package/dist/components/control-picker.mjs +10 -0
  29. package/dist/components/control-view.js +677 -122
  30. package/dist/components/control-view.mjs +5 -5
  31. package/dist/components/use-control.d.mts +20 -0
  32. package/dist/components/use-control.d.ts +20 -0
  33. package/dist/components/use-control.js +127 -0
  34. package/dist/components/use-control.mjs +9 -0
  35. package/dist/control-block.d.mts +35 -0
  36. package/dist/control-block.d.ts +35 -0
  37. package/dist/control-block.js +1012 -0
  38. package/dist/control-block.mjs +17 -0
  39. package/dist/control-implementation.d.mts +7 -0
  40. package/dist/control-implementation.d.ts +7 -0
  41. package/dist/control-implementation.js +92 -0
  42. package/dist/control-implementation.mjs +9 -0
  43. package/dist/control.d.mts +31 -1
  44. package/dist/control.d.ts +31 -1
  45. package/dist/control.js +819 -136
  46. package/dist/control.mjs +7 -6
  47. package/dist/defaults.d.mts +3 -9
  48. package/dist/defaults.d.ts +3 -9
  49. package/dist/defaults.js +3 -20
  50. package/dist/defaults.mjs +3 -6
  51. package/dist/index.d.mts +10 -10
  52. package/dist/index.d.ts +10 -10
  53. package/dist/index.js +1229 -569
  54. package/dist/index.mjs +58 -21
  55. package/dist/messages/index.d.mts +135 -0
  56. package/dist/messages/index.d.ts +135 -0
  57. package/dist/messages/index.js +137 -2
  58. package/dist/messages/index.mjs +1 -2
  59. package/dist/role.d.mts +17 -0
  60. package/dist/role.d.ts +17 -0
  61. package/dist/role.js +5 -0
  62. package/dist/role.mjs +2 -0
  63. package/dist/types.d.mts +23 -16
  64. package/dist/types.d.ts +23 -16
  65. package/dist/utils/create-control-block.d.mts +7 -0
  66. package/dist/utils/create-control-block.d.ts +7 -0
  67. package/dist/utils/create-control-block.js +85 -0
  68. package/dist/utils/create-control-block.mjs +10 -0
  69. package/dist/utils/create-control-implementation.d.mts +8 -0
  70. package/dist/utils/create-control-implementation.d.ts +8 -0
  71. package/dist/utils/create-control-implementation.js +39 -0
  72. package/dist/utils/create-control-implementation.mjs +7 -0
  73. package/dist/utils/getControlNodeTypes.d.mts +5 -0
  74. package/dist/utils/getControlNodeTypes.d.ts +5 -0
  75. package/dist/utils/getControlNodeTypes.js +44 -0
  76. package/dist/utils/getControlNodeTypes.mjs +7 -0
  77. package/dist/utils/index.d.mts +7 -2
  78. package/dist/utils/index.d.ts +7 -2
  79. package/dist/utils/index.js +35 -3
  80. package/dist/utils/index.mjs +7 -4
  81. package/dist/utils/status-indicator.d.mts +18 -0
  82. package/dist/utils/status-indicator.d.ts +18 -0
  83. package/dist/utils/status-indicator.js +80 -0
  84. package/dist/utils/status-indicator.mjs +7 -0
  85. package/package.json +11 -11
  86. package/dist/card-variant.d.mts +0 -12
  87. package/dist/card-variant.d.ts +0 -12
  88. package/dist/card-variant.js +0 -66
  89. package/dist/card-variant.mjs +0 -8
  90. package/dist/chunk-AC4KL3WX.mjs +0 -29
  91. package/dist/chunk-AZ5M5MVC.mjs +0 -36
  92. package/dist/chunk-DTFR234X.mjs +0 -244
  93. package/dist/chunk-EDD7DYLE.mjs +0 -29
  94. package/dist/chunk-GC5EBQ7G.mjs +0 -10
  95. package/dist/chunk-H2ECPGOG.mjs +0 -81
  96. package/dist/chunk-KLX7Q3HL.mjs +0 -109
  97. package/dist/chunk-LKRTUIEV.mjs +0 -46
  98. package/dist/chunk-NAJ6IC4Y.mjs +0 -43
  99. package/dist/chunk-QI3ZPZTR.mjs +0 -26
  100. package/dist/chunk-SNRVOTF5.mjs +0 -8
  101. package/dist/chunk-VP5POY44.mjs +0 -57
  102. package/dist/chunk-WIR5FCIC.mjs +0 -110
  103. package/dist/control-ref-view.d.mts +0 -6
  104. package/dist/control-ref-view.d.ts +0 -6
  105. package/dist/control-ref-view.js +0 -615
  106. package/dist/control-ref-view.mjs +0 -15
  107. package/dist/control-ref.d.mts +0 -28
  108. package/dist/control-ref.d.ts +0 -28
  109. package/dist/control-ref.js +0 -687
  110. package/dist/control-ref.mjs +0 -16
  111. package/dist/i18n.d.mts +0 -4
  112. package/dist/i18n.d.ts +0 -4
  113. package/dist/i18n.js +0 -128
  114. package/dist/i18n.mjs +0 -10
  115. package/dist/lang/de.d.mts +0 -24
  116. package/dist/lang/de.d.ts +0 -24
  117. package/dist/lang/de.js +0 -25
  118. package/dist/lang/de.mjs +0 -8
  119. package/dist/lang/en.d.mts +0 -24
  120. package/dist/lang/en.d.ts +0 -24
  121. package/dist/lang/en.js +0 -25
  122. package/dist/lang/en.mjs +0 -8
  123. package/dist/settings-dialog.d.mts +0 -19
  124. package/dist/settings-dialog.d.ts +0 -19
  125. package/dist/settings-dialog.js +0 -371
  126. package/dist/settings-dialog.mjs +0 -9
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import {
3
+ ControlBlockView
4
+ } from "../chunk-GYDJVHHG.mjs";
5
+ import "../chunk-A7FWOQDN.mjs";
6
+ import "../chunk-4C72VBLP.mjs";
7
+ import "../chunk-AQTNFDGA.mjs";
8
+ import "../chunk-D53W4HWR.mjs";
9
+ export {
10
+ ControlBlockView
11
+ };
@@ -0,0 +1,6 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNodeViewProps } from '@tiptap/react';
3
+
4
+ declare const ControlImplementationView: (props: ReactNodeViewProps) => react_jsx_runtime.JSX.Element;
5
+
6
+ export { ControlImplementationView };
@@ -0,0 +1,6 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNodeViewProps } from '@tiptap/react';
3
+
4
+ declare const ControlImplementationView: (props: ReactNodeViewProps) => react_jsx_runtime.JSX.Element;
5
+
6
+ export { ControlImplementationView };
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/components/control-implementation-view.tsx
22
+ var control_implementation_view_exports = {};
23
+ __export(control_implementation_view_exports, {
24
+ ControlImplementationView: () => ControlImplementationView
25
+ });
26
+ module.exports = __toCommonJS(control_implementation_view_exports);
27
+ var import_react = require("@tiptap/react");
28
+ var import_jsx_runtime = require("react/jsx-runtime");
29
+ var ControlImplementationView = (props) => {
30
+ var _a;
31
+ const { node } = props;
32
+ const a = node.attrs;
33
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
34
+ import_react.NodeViewWrapper,
35
+ {
36
+ as: "div",
37
+ role: "listitem",
38
+ "data-type": "control-implementation",
39
+ "data-id": a.id,
40
+ className: "flex items-start justify-between gap-3 py-3",
41
+ contentEditable: false,
42
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-w-0 flex-1", children: [
43
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm font-medium text-foreground truncate", children: (_a = a.title) != null ? _a : a.id }),
44
+ a.description ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm text-muted-foreground mt-0.5", children: a.description }) : null
45
+ ] })
46
+ }
47
+ );
48
+ };
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ ControlImplementationView
52
+ });
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import {
3
+ ControlImplementationView
4
+ } from "../chunk-IMHLTRZJ.mjs";
5
+ export {
6
+ ControlImplementationView
7
+ };
@@ -0,0 +1,25 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ControlResolver, ControlSummary } from '../types.mjs';
3
+ import '@kopexa/theme';
4
+
5
+ type ControlPickerProps = {
6
+ resolver?: ControlResolver;
7
+ value: ControlSummary | null;
8
+ onChange: (next: ControlSummary | null) => void;
9
+ /** Optional: controls search debounce and timeout */
10
+ debounceMs?: number;
11
+ timeoutMs?: number;
12
+ /** Optional: initial query string */
13
+ initialQuery?: string;
14
+ /** Optional: whether to hide the status chip on items */
15
+ showItemStatus?: boolean;
16
+ };
17
+ /**
18
+ * Reusable async control picker:
19
+ * - debounced search via resolver.getControls
20
+ * - status row (loading / empty / count / hint)
21
+ * - keyboard accessible list
22
+ */
23
+ declare function ControlPicker({ resolver, value, onChange, debounceMs, timeoutMs, initialQuery, showItemStatus, }: ControlPickerProps): react_jsx_runtime.JSX.Element;
24
+
25
+ export { ControlPicker, type ControlPickerProps };
@@ -0,0 +1,25 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ControlResolver, ControlSummary } from '../types.js';
3
+ import '@kopexa/theme';
4
+
5
+ type ControlPickerProps = {
6
+ resolver?: ControlResolver;
7
+ value: ControlSummary | null;
8
+ onChange: (next: ControlSummary | null) => void;
9
+ /** Optional: controls search debounce and timeout */
10
+ debounceMs?: number;
11
+ timeoutMs?: number;
12
+ /** Optional: initial query string */
13
+ initialQuery?: string;
14
+ /** Optional: whether to hide the status chip on items */
15
+ showItemStatus?: boolean;
16
+ };
17
+ /**
18
+ * Reusable async control picker:
19
+ * - debounced search via resolver.getControls
20
+ * - status row (loading / empty / count / hint)
21
+ * - keyboard accessible list
22
+ */
23
+ declare function ControlPicker({ resolver, value, onChange, debounceMs, timeoutMs, initialQuery, showItemStatus, }: ControlPickerProps): react_jsx_runtime.JSX.Element;
24
+
25
+ export { ControlPicker, type ControlPickerProps };
@@ -0,0 +1,522 @@
1
+ "use client";
2
+ "use strict";
3
+ "use client";
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/components/control-picker.tsx
23
+ var control_picker_exports = {};
24
+ __export(control_picker_exports, {
25
+ ControlPicker: () => ControlPicker
26
+ });
27
+ module.exports = __toCommonJS(control_picker_exports);
28
+ var import_sight = require("@kopexa/sight");
29
+ var import_react = require("react");
30
+ var import_react_intl2 = require("react-intl");
31
+
32
+ // src/messages/index.ts
33
+ var import_react_intl = require("react-intl");
34
+ var messages = (0, import_react_intl.defineMessages)({
35
+ control: {
36
+ id: "editor.controlref.control",
37
+ defaultMessage: "Control",
38
+ description: "Label for control"
39
+ },
40
+ settings_dialog_description: {
41
+ id: "editor.controlref.settings_dialog_description",
42
+ defaultMessage: "Customize the appearance and details of the control reference.",
43
+ description: "Description for the settings dialog"
44
+ },
45
+ controls: {
46
+ id: "editor.controlref.controls",
47
+ defaultMessage: "Controls",
48
+ description: "Label for controls"
49
+ },
50
+ change_control: {
51
+ id: "editor.controlref.change_control",
52
+ defaultMessage: "Change Control",
53
+ description: "Label for change control button"
54
+ },
55
+ map_control: {
56
+ id: "editor.controlref.map_control",
57
+ defaultMessage: "Map Control",
58
+ description: "Label for map control button"
59
+ },
60
+ settings: {
61
+ id: "editor.controlref.settings",
62
+ defaultMessage: "Settings",
63
+ description: "Label for settings button"
64
+ },
65
+ appearance: {
66
+ id: "editor.controlref.appearance",
67
+ defaultMessage: "Appearance",
68
+ description: "Label for appearance section"
69
+ },
70
+ search_controls: {
71
+ id: "editor.controlref.search_controls",
72
+ defaultMessage: "Search controls\u2026",
73
+ description: "Placeholder for search controls input"
74
+ },
75
+ variant: {
76
+ id: "editor.controlref.variant",
77
+ defaultMessage: "Variante",
78
+ description: "Label for variant section"
79
+ },
80
+ variant_hint: {
81
+ id: "editor.controlref.variant_hint",
82
+ defaultMessage: "Choose a visual emphasis for this section.",
83
+ description: "Hint for variant section"
84
+ },
85
+ variant_chip: {
86
+ id: "editor.controlref.variant_chip",
87
+ defaultMessage: "Chip",
88
+ description: "Label for variant chip"
89
+ },
90
+ variant_card: {
91
+ id: "editor.controlref.variant_card",
92
+ defaultMessage: "Card",
93
+ description: "Label for variant card"
94
+ },
95
+ show_status: {
96
+ id: "editor.controlref.show_status",
97
+ defaultMessage: "Show Status",
98
+ description: "Label for show status toggle"
99
+ },
100
+ show_description: {
101
+ id: "editor.controlref.show_description",
102
+ defaultMessage: "Show Description",
103
+ description: "Label for show description toggle"
104
+ },
105
+ show_implementations: {
106
+ id: "editor.controlref.show_implementations",
107
+ defaultMessage: "Show Implementations",
108
+ description: "Label for show implementations toggle"
109
+ },
110
+ border: {
111
+ id: "editor.controlref.border",
112
+ defaultMessage: "Border",
113
+ description: "Label for border toggle"
114
+ },
115
+ shadow: {
116
+ id: "editor.controlref.shadow",
117
+ defaultMessage: "Shadow",
118
+ description: "Label for shadow toggle"
119
+ },
120
+ radius: {
121
+ id: "editor.controlref.radius",
122
+ defaultMessage: "Radius",
123
+ description: "Label for radius toggle"
124
+ },
125
+ spacing: {
126
+ id: "editor.controlref.spacing",
127
+ defaultMessage: "Spacing",
128
+ description: "Label for spacing section"
129
+ },
130
+ cancel: {
131
+ id: "editor.controlref.cancel",
132
+ defaultMessage: "Cancel",
133
+ description: "Label for cancel button"
134
+ },
135
+ save_settings: {
136
+ id: "editor.controlref.save_settings",
137
+ defaultMessage: "Save Settings",
138
+ description: "Label for save settings button"
139
+ },
140
+ unmapped_control: {
141
+ id: "editor.controlref.unmapped_control",
142
+ defaultMessage: "Unmapped Control",
143
+ description: "Fallback label when no control is selected"
144
+ },
145
+ control_with_title: {
146
+ id: "editor.controlref.control_with_title",
147
+ defaultMessage: "Control: {title}",
148
+ description: "Dialog title with selected control"
149
+ },
150
+ search_hint: {
151
+ id: "editor.controlref.search_hint",
152
+ defaultMessage: "Start typing to search by ID, title or status.",
153
+ description: "Empty search hint"
154
+ },
155
+ no_results: {
156
+ id: "editor.controlref.no_results",
157
+ defaultMessage: "No controls found for \u201C{query}\u201D. You can keep this chip unmapped.",
158
+ description: "Shown when no controls match search query"
159
+ },
160
+ results_count: {
161
+ id: "editor.controlref.results_count",
162
+ defaultMessage: "{count, plural, one {# result} other {# results}}",
163
+ description: "Number of search results"
164
+ },
165
+ updated_at: {
166
+ id: "editor.controlref.updated_at",
167
+ defaultMessage: "Updated {date}",
168
+ description: "Updated date label"
169
+ },
170
+ selected: {
171
+ id: "editor.controlref.selected",
172
+ defaultMessage: "Selected",
173
+ description: "Label for selected item area"
174
+ },
175
+ no_control_selected: {
176
+ id: "editor.controlref.no_control_selected",
177
+ defaultMessage: "No control selected",
178
+ description: "Empty state in selected area"
179
+ },
180
+ clear: {
181
+ id: "editor.controlref.clear",
182
+ defaultMessage: "Clear",
183
+ description: "Clear selection button"
184
+ },
185
+ unmap: {
186
+ id: "editor.controlref.unmap",
187
+ defaultMessage: "Unmap",
188
+ description: "Unmap selection button"
189
+ },
190
+ live_preview: {
191
+ id: "editor.controlref.live_preview",
192
+ defaultMessage: "Live preview",
193
+ description: "Live preview section title"
194
+ },
195
+ display_options: {
196
+ id: "editor.controlref.display_options",
197
+ defaultMessage: "Display options",
198
+ description: "Display options section title"
199
+ },
200
+ show_status_indicator: {
201
+ id: "editor.controlref.show_status_indicator",
202
+ defaultMessage: "Show status indicator",
203
+ description: "Toggle for showing indicator"
204
+ },
205
+ searching: {
206
+ id: "editor.controlref.searching",
207
+ defaultMessage: "Searching\u2026",
208
+ description: "Loading indicator text"
209
+ },
210
+ map_control_aria: {
211
+ id: "editor.controlref.map_control_aria",
212
+ defaultMessage: "Map control",
213
+ description: "ARIA label for mapping control"
214
+ },
215
+ outdated_badge: {
216
+ id: "editor.controlref.outdated_badge",
217
+ defaultMessage: "A newer revision exists",
218
+ description: "Badge for outdated controls"
219
+ },
220
+ missing_badge: {
221
+ id: "editor.controlref.missing_badge",
222
+ defaultMessage: "Control no longer exists",
223
+ description: "Badge for missing controls"
224
+ },
225
+ error_loading: {
226
+ id: "editor.controlref.error_loading",
227
+ defaultMessage: "Failed to load controls",
228
+ description: "Error message when failing to load controls"
229
+ },
230
+ error_timeout: {
231
+ id: "editor.controlref.error_timeout",
232
+ defaultMessage: "The request timed out. Please try again.",
233
+ description: "Error message when the request times out"
234
+ },
235
+ missing_callout: {
236
+ id: "editor.controlref.missing_callout",
237
+ defaultMessage: "The currently mapped control could not be found. It may have been deleted or you may not have access to it anymore. Please select a different control.",
238
+ description: "Callout message when the selected control is missing"
239
+ },
240
+ outdated_callout: {
241
+ id: "editor.controlref.outdated_callout",
242
+ defaultMessage: "A newer revision of the currently mapped control exists. Consider updating to the latest version by re-selecting it below.",
243
+ description: "Callout message when the selected control is outdated"
244
+ },
245
+ search_placeholder: {
246
+ id: "editor.controlref.search_placeholder",
247
+ defaultMessage: "e.g. CTRL-001, Asset Inventory\u2026",
248
+ description: "Placeholder for search controls input"
249
+ },
250
+ control_implementations: {
251
+ id: "editor.controlref.control_implementations",
252
+ defaultMessage: "Implementations",
253
+ description: "Label for control implementations section"
254
+ },
255
+ header_status: {
256
+ id: "editor.controlblock.header_status",
257
+ defaultMessage: "Show status in header",
258
+ description: "Label for show status in header toggle"
259
+ },
260
+ header_status_aria: {
261
+ id: "editor.controlblock.header_status_aria",
262
+ defaultMessage: "Toggle status chip in card header",
263
+ description: "ARIA label for show status in header toggle"
264
+ },
265
+ header_status_avv_tip: {
266
+ id: "editor.controlblock.header_status_avv_tip",
267
+ defaultMessage: "If this document is intended for use or export as a data processing agreement (AVV), disable this option unless you explicitly want to publish the current control status.",
268
+ description: "Tooltip for show status in header toggle when used in AVV documents"
269
+ }
270
+ });
271
+
272
+ // src/utils/status-indicator.ts
273
+ function norm(status) {
274
+ return (status != null ? status : "").trim().replace(/[\s-]+/g, "_").toUpperCase();
275
+ }
276
+ function colorForStatusKey(key) {
277
+ switch (key == null ? void 0 : key.toUpperCase()) {
278
+ case "FULFILLED_MANUAL":
279
+ case "FULFILLED_AUTO":
280
+ case "IMPLEMENTED":
281
+ case "APPROVED":
282
+ case "PASSED":
283
+ return "success";
284
+ case "IN_PROGRESS":
285
+ case "NEEDS_APPROVAL":
286
+ case "CHANGES_REQUESTED":
287
+ case "PENDING":
288
+ case "PARTIAL":
289
+ return "warning";
290
+ case "FAILED":
291
+ case "REJECTED":
292
+ return "destructive";
293
+ case "OUT_OF_SCOPE":
294
+ case "PREPARING":
295
+ return "secondary";
296
+ default:
297
+ return "default";
298
+ }
299
+ }
300
+ function getIndicatorProps(status, opts) {
301
+ var _a, _b;
302
+ const mapped = (_a = opts == null ? void 0 : opts.mapped) != null ? _a : true;
303
+ const enable = (_b = opts == null ? void 0 : opts.enable) != null ? _b : true;
304
+ if (!enable) {
305
+ return { indicator: false, indicatorColor: "default" };
306
+ }
307
+ if (!mapped) {
308
+ return {
309
+ indicator: true,
310
+ indicatorColor: "destructive",
311
+ indicatorVariant: "pulse"
312
+ };
313
+ }
314
+ const key = norm(status);
315
+ const indicatorColor = colorForStatusKey(key);
316
+ const shouldPulse = key === "IN_PROGRESS" || key === "NEEDS_APPROVAL" || key === "CHANGES_REQUESTED" || key === "PENDING";
317
+ return {
318
+ indicator: true,
319
+ indicatorColor,
320
+ ...shouldPulse ? { indicatorVariant: "pulse" } : {}
321
+ };
322
+ }
323
+
324
+ // src/components/control-picker.tsx
325
+ var import_jsx_runtime = require("react/jsx-runtime");
326
+ function ControlPicker({
327
+ resolver,
328
+ value,
329
+ onChange,
330
+ debounceMs = 300,
331
+ timeoutMs = 5e3,
332
+ initialQuery = "",
333
+ showItemStatus = true
334
+ }) {
335
+ const intl = (0, import_react_intl2.useIntl)();
336
+ const searchId = (0, import_react.useId)();
337
+ const [search, setSearch] = (0, import_react.useState)(initialQuery);
338
+ const [debouncedSearch, setDebouncedSearch] = (0, import_react.useState)(search);
339
+ const [loading, setLoading] = (0, import_react.useState)(false);
340
+ const [error, setError] = (0, import_react.useState)(null);
341
+ const [results, setResults] = (0, import_react.useState)([]);
342
+ (0, import_react.useEffect)(() => {
343
+ const t = setTimeout(() => setDebouncedSearch(search), debounceMs);
344
+ return () => clearTimeout(t);
345
+ }, [search, debounceMs]);
346
+ (0, import_react.useEffect)(() => {
347
+ if (!(resolver == null ? void 0 : resolver.getControls)) return;
348
+ let ignore = false;
349
+ (async () => {
350
+ setLoading(true);
351
+ setError(null);
352
+ try {
353
+ const p = resolver.getControls(debouncedSearch);
354
+ const data = await Promise.race([
355
+ p,
356
+ new Promise(
357
+ (_, rej) => setTimeout(
358
+ () => rej(new Error(intl.formatMessage(messages.error_timeout))),
359
+ timeoutMs
360
+ )
361
+ )
362
+ ]);
363
+ if (!ignore) setResults(data);
364
+ } catch (e) {
365
+ if (!ignore) {
366
+ setError(
367
+ e instanceof Error ? e.message : intl.formatMessage(messages.error_loading)
368
+ );
369
+ setResults([]);
370
+ }
371
+ } finally {
372
+ if (!ignore) setLoading(false);
373
+ }
374
+ })();
375
+ return () => {
376
+ ignore = true;
377
+ };
378
+ }, [debouncedSearch, resolver, timeoutMs, intl]);
379
+ const statusNode = (0, import_react.useMemo)(() => {
380
+ if (loading)
381
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
382
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Spinner, { size: "sm" }),
383
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: intl.formatMessage(messages.searching) })
384
+ ] });
385
+ if (error) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-destructive text-sm", children: error });
386
+ if (results.length === 0 && debouncedSearch)
387
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-muted-foreground text-sm", children: intl.formatMessage(messages.no_results, { query: debouncedSearch }) });
388
+ if (results.length > 0)
389
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-muted-foreground text-sm", children: intl.formatMessage(messages.results_count, {
390
+ count: results.length
391
+ }) });
392
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-muted-foreground text-sm", children: intl.formatMessage(messages.search_hint) });
393
+ }, [loading, error, results.length, debouncedSearch, intl]);
394
+ const itemToStringValue = (item) => {
395
+ var _a, _b;
396
+ return (_b = (_a = item == null ? void 0 : item.title) != null ? _a : item == null ? void 0 : item.id) != null ? _b : "";
397
+ };
398
+ const highlight = (text) => {
399
+ const t = (text != null ? text : "").toString();
400
+ const q = debouncedSearch.trim();
401
+ if (!q) return t;
402
+ const i = t.toLowerCase().indexOf(q.toLowerCase());
403
+ if (i === -1) return t;
404
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
405
+ t.slice(0, i),
406
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("mark", { className: "bg-primary/15 rounded px-0.5", children: t.slice(i, i + q.length) }),
407
+ t.slice(i + q.length)
408
+ ] });
409
+ };
410
+ const indicator = getIndicatorProps(value == null ? void 0 : value.status, {
411
+ mapped: !!(value == null ? void 0 : value.id),
412
+ enable: showItemStatus
413
+ });
414
+ const selInd = value ? indicator : {
415
+ indicator: false,
416
+ indicatorColor: "default"
417
+ };
418
+ const handleClear = () => {
419
+ onChange(null);
420
+ };
421
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-3", children: [
422
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-2", children: [
423
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Label, { htmlFor: searchId, children: intl.formatMessage(messages.controls) }),
424
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
425
+ import_sight.Autocomplete,
426
+ {
427
+ items: results,
428
+ value: search,
429
+ onValueChange: setSearch,
430
+ filter: null,
431
+ itemToStringValue,
432
+ children: [
433
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_sight.Autocomplete.Control, { children: [
434
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
435
+ import_sight.Autocomplete.Input,
436
+ {
437
+ id: searchId,
438
+ placeholder: intl.formatMessage(messages.search_placeholder)
439
+ }
440
+ ),
441
+ search && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Autocomplete.Clear, {})
442
+ ] }),
443
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_sight.Autocomplete.Content, { children: [
444
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "sticky top-0 z-10 bg-background border-b px-2 py-1", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Autocomplete.Status, { children: statusNode }) }),
445
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Autocomplete.List, { children: (c) => {
446
+ var _a, _b, _c;
447
+ const id = (_a = c.id) != null ? _a : crypto.randomUUID();
448
+ const active = (value == null ? void 0 : value.id) && c.id === value.id;
449
+ const ind = getIndicatorProps(c.status, {
450
+ mapped: !!c.id,
451
+ enable: showItemStatus
452
+ });
453
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
454
+ import_sight.Autocomplete.Item,
455
+ {
456
+ value: c,
457
+ className: "rounded-lg data-[active=true]:bg-muted",
458
+ "data-active": active ? "true" : void 0,
459
+ "aria-selected": active ? "true" : "false",
460
+ onClick: () => onChange(c),
461
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2.5 truncate", children: [
462
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex-1 min-w-0", children: [
463
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "font-medium truncate", children: highlight((_b = c.title) != null ? _b : c.id) }),
464
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "text-sm text-muted-foreground truncate", children: [
465
+ highlight((_c = c.id) != null ? _c : ""),
466
+ c.updatedAt ? ` \u2022 ${intl.formatMessage(messages.updated_at, {
467
+ date: intl.formatDate(new Date(c.updatedAt), {
468
+ year: "numeric",
469
+ month: "short",
470
+ day: "2-digit",
471
+ hour: "2-digit",
472
+ minute: "2-digit"
473
+ })
474
+ })}` : ""
475
+ ] })
476
+ ] }),
477
+ showItemStatus && c.status && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
478
+ import_sight.Chip,
479
+ {
480
+ size: "sm",
481
+ variant: "ghost",
482
+ indicator: ind.indicator,
483
+ indicatorColor: ind.indicatorColor,
484
+ indicatorVariant: ind.indicatorVariant,
485
+ status: c.status,
486
+ children: c.status
487
+ }
488
+ )
489
+ ] })
490
+ },
491
+ id
492
+ );
493
+ } })
494
+ ] })
495
+ ]
496
+ }
497
+ )
498
+ ] }),
499
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between gap-2 border rounded-md px-3 py-2", children: [
500
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-3 min-w-0", children: [
501
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Label, { children: intl.formatMessage(messages.selected) }),
502
+ value ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
503
+ import_sight.Chip,
504
+ {
505
+ size: "sm",
506
+ variant: "bordered",
507
+ indicator: selInd.indicator,
508
+ indicatorColor: selInd.indicatorColor,
509
+ indicatorVariant: selInd.indicatorVariant,
510
+ status: showItemStatus ? value == null ? void 0 : value.status : void 0,
511
+ children: value.title
512
+ }
513
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-muted-foreground text-sm", children: intl.formatMessage(messages.no_control_selected) })
514
+ ] }),
515
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Button, { variant: "ghost", onClick: handleClear, disabled: !value, children: intl.formatMessage(messages.clear) }) })
516
+ ] })
517
+ ] });
518
+ }
519
+ // Annotate the CommonJS export names for ESM import in node:
520
+ 0 && (module.exports = {
521
+ ControlPicker
522
+ });
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ "use client";
3
+ import {
4
+ ControlPicker
5
+ } from "../chunk-A7FWOQDN.mjs";
6
+ import "../chunk-AQTNFDGA.mjs";
7
+ import "../chunk-D53W4HWR.mjs";
8
+ export {
9
+ ControlPicker
10
+ };