@powerduck/schema-designer 0.1.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 (102) hide show
  1. package/README.md +217 -0
  2. package/dist/InlineSchemaEditor-BssSx3SI.d.ts +6 -0
  3. package/dist/InlineSchemaEditor-Bua-lDhE.d.cts +6 -0
  4. package/dist/chunk-2XUQB6BQ.js +1896 -0
  5. package/dist/chunk-4H3LXOL4.cjs +1900 -0
  6. package/dist/chunk-7LG4MVMD.cjs +2 -0
  7. package/dist/chunk-BXFABOMJ.js +1475 -0
  8. package/dist/chunk-FTALJIVZ.js +1 -0
  9. package/dist/chunk-GTZH37JS.cjs +1120 -0
  10. package/dist/chunk-GWHDTTQK.js +1437 -0
  11. package/dist/chunk-GXXD6ITE.cjs +1477 -0
  12. package/dist/chunk-HI5FBHCO.js +1057 -0
  13. package/dist/chunk-KX3LFFOV.js +88 -0
  14. package/dist/chunk-MADPN2PJ.js +185 -0
  15. package/dist/chunk-NOUORNCI.cjs +1452 -0
  16. package/dist/chunk-O6PTRJQ5.js +1195 -0
  17. package/dist/chunk-OBHJC3I2.cjs +2 -0
  18. package/dist/chunk-OOSNM45O.cjs +264 -0
  19. package/dist/chunk-P5B3HSPY.js +244 -0
  20. package/dist/chunk-PBE36BVA.js +1 -0
  21. package/dist/chunk-PVEYKCM6.js +1 -0
  22. package/dist/chunk-QZADGAP3.cjs +1218 -0
  23. package/dist/chunk-S7GNTGEE.js +1 -0
  24. package/dist/chunk-SMBDRWV2.cjs +2 -0
  25. package/dist/chunk-THYDOHOP.cjs +2 -0
  26. package/dist/chunk-WRHWOMZQ.cjs +190 -0
  27. package/dist/chunk-YNKP5JJA.cjs +32 -0
  28. package/dist/chunk-YWDKCX6N.cjs +91 -0
  29. package/dist/chunk-ZHNYNFGL.js +28 -0
  30. package/dist/compat/inline.cjs +137 -0
  31. package/dist/compat/inline.css +275 -0
  32. package/dist/compat/inline.d.cts +6 -0
  33. package/dist/compat/inline.d.ts +6 -0
  34. package/dist/compat/inline.js +4 -0
  35. package/dist/compat/parameters.cjs +90 -0
  36. package/dist/compat/parameters.css +997 -0
  37. package/dist/compat/parameters.d.cts +70 -0
  38. package/dist/compat/parameters.d.ts +70 -0
  39. package/dist/compat/parameters.js +9 -0
  40. package/dist/compat/tree.cjs +142 -0
  41. package/dist/compat/tree.css +1069 -0
  42. package/dist/compat/tree.d.cts +4 -0
  43. package/dist/compat/tree.d.ts +4 -0
  44. package/dist/compat/tree.js +5 -0
  45. package/dist/compat/variable-editor.cjs +82 -0
  46. package/dist/compat/variable-editor.d.cts +68 -0
  47. package/dist/compat/variable-editor.d.ts +68 -0
  48. package/dist/compat/variable-editor.js +1 -0
  49. package/dist/core/index.cjs +197 -0
  50. package/dist/core/index.d.cts +21 -0
  51. package/dist/core/index.d.ts +21 -0
  52. package/dist/core/index.js +4 -0
  53. package/dist/index.cjs +35 -0
  54. package/dist/index.css +1791 -0
  55. package/dist/index.d.cts +9 -0
  56. package/dist/index.d.ts +9 -0
  57. package/dist/index.js +10 -0
  58. package/dist/parameterValue-2pL9n-3q.d.ts +8 -0
  59. package/dist/parameterValue-Cky9Lnd3.d.cts +8 -0
  60. package/dist/react/index.cjs +35 -0
  61. package/dist/react/index.css +1791 -0
  62. package/dist/react/index.d.cts +9 -0
  63. package/dist/react/index.d.ts +9 -0
  64. package/dist/react/index.js +10 -0
  65. package/dist/react/inlineSchemaEditor/index.cjs +97 -0
  66. package/dist/react/inlineSchemaEditor/index.css +275 -0
  67. package/dist/react/inlineSchemaEditor/index.d.cts +6 -0
  68. package/dist/react/inlineSchemaEditor/index.d.ts +6 -0
  69. package/dist/react/inlineSchemaEditor/index.js +4 -0
  70. package/dist/react/parametersTable/index.cjs +22 -0
  71. package/dist/react/parametersTable/index.css +997 -0
  72. package/dist/react/parametersTable/index.d.cts +7 -0
  73. package/dist/react/parametersTable/index.d.ts +7 -0
  74. package/dist/react/parametersTable/index.js +9 -0
  75. package/dist/react/parametersTable/libs/generateValue.cjs +558 -0
  76. package/dist/react/parametersTable/libs/generateValue.d.cts +17 -0
  77. package/dist/react/parametersTable/libs/generateValue.d.ts +17 -0
  78. package/dist/react/parametersTable/libs/generateValue.js +551 -0
  79. package/dist/react/schemaTreeEditor/index.cjs +18 -0
  80. package/dist/react/schemaTreeEditor/index.css +1069 -0
  81. package/dist/react/schemaTreeEditor/index.d.cts +7 -0
  82. package/dist/react/schemaTreeEditor/index.d.ts +7 -0
  83. package/dist/react/schemaTreeEditor/index.js +5 -0
  84. package/dist/react/variableTextEditor/index.cjs +11 -0
  85. package/dist/react/variableTextEditor/index.css +306 -0
  86. package/dist/react/variableTextEditor/index.d.cts +6 -0
  87. package/dist/react/variableTextEditor/index.d.ts +6 -0
  88. package/dist/react/variableTextEditor/index.js +2 -0
  89. package/dist/schema-CKAPsYeW.d.cts +41 -0
  90. package/dist/schema-o7OJRaJ8.d.ts +41 -0
  91. package/dist/styles.css +1791 -0
  92. package/dist/tree-D06Xa6_N.d.ts +95 -0
  93. package/dist/tree-Dq1Rk-CF.d.cts +95 -0
  94. package/dist/types-B27Dw9do.d.cts +163 -0
  95. package/dist/types-B27Dw9do.d.ts +163 -0
  96. package/dist/types-Bk9rzr6l.d.cts +48 -0
  97. package/dist/types-D2jEaM9Z.d.cts +145 -0
  98. package/dist/types-D2jEaM9Z.d.ts +145 -0
  99. package/dist/types-xAihO_KW.d.ts +48 -0
  100. package/dist/variableTextEditor.types-ClzvARvK.d.cts +49 -0
  101. package/dist/variableTextEditor.types-ClzvARvK.d.ts +49 -0
  102. package/package.json +130 -0
@@ -0,0 +1,1452 @@
1
+ 'use strict';
2
+
3
+ var chunk4H3LXOL4_cjs = require('./chunk-4H3LXOL4.cjs');
4
+ var chunkGXXD6ITE_cjs = require('./chunk-GXXD6ITE.cjs');
5
+ var chunkYNKP5JJA_cjs = require('./chunk-YNKP5JJA.cjs');
6
+ var chunkWRHWOMZQ_cjs = require('./chunk-WRHWOMZQ.cjs');
7
+ var chunkGTZH37JS_cjs = require('./chunk-GTZH37JS.cjs');
8
+ var nanoid = require('nanoid');
9
+ var vsc = require('react-icons/vsc');
10
+ var react$1 = require('@chakra-ui/react');
11
+ var jsxRuntime = require('react/jsx-runtime');
12
+ var react = require('react');
13
+ var dnd = require('@hello-pangea/dnd');
14
+ var lu = require('react-icons/lu');
15
+ var ai = require('react-icons/ai');
16
+
17
+ // src/react/parametersTable/libs/columns.ts
18
+ var DEFAULT_COLUMNS = [
19
+ { id: "name", label: "Name", defaultWidth: 180, minWidth: 160 },
20
+ { id: "value", label: "Value", defaultWidth: 220, minWidth: 120 },
21
+ { id: "type", label: "Type", defaultWidth: 140, minWidth: 120 },
22
+ {
23
+ id: "required",
24
+ label: "Required",
25
+ defaultWidth: 100,
26
+ minWidth: 100,
27
+ maxWidth: 140
28
+ },
29
+ { id: "description", label: "Description", defaultWidth: 360, minWidth: 180 }
30
+ ];
31
+ function getVisibleColumns(args) {
32
+ const { showRequired, showType, showDescription } = args;
33
+ return DEFAULT_COLUMNS.filter((c) => {
34
+ if (c.id === "required" && !showRequired) return false;
35
+ if (c.id === "type" && !showType) return false;
36
+ if (c.id === "description" && !showDescription) return false;
37
+ return true;
38
+ });
39
+ }
40
+ function getRightNeighborId(visibleColumns, columnId) {
41
+ const idx = visibleColumns.findIndex((c) => c.id === columnId);
42
+ if (idx < 0) return null;
43
+ return visibleColumns[idx + 1]?.id ?? null;
44
+ }
45
+ function clamp(value, min, max) {
46
+ return Math.max(min, Math.min(max, value));
47
+ }
48
+ function buildColumnDefsById(columns) {
49
+ return columns.reduce(
50
+ (acc, c) => {
51
+ acc[c.id] = c;
52
+ return acc;
53
+ },
54
+ {}
55
+ );
56
+ }
57
+ function fitColumnWidths(previous, columns, available) {
58
+ if (!columns.length || !Number.isFinite(available) || available <= 0)
59
+ return previous;
60
+ const minimum = columns.reduce((sum, column) => sum + column.minWidth, 0);
61
+ const maximum = columns.reduce(
62
+ (sum, column) => sum + (column.maxWidth ?? Infinity),
63
+ 0
64
+ );
65
+ const target = Math.max(minimum, Math.min(maximum, available));
66
+ const currentTotal = columns.reduce(
67
+ (sum, column) => sum + previous[column.id],
68
+ 0
69
+ );
70
+ const valid = columns.every(
71
+ (column) => Number.isFinite(previous[column.id]) && previous[column.id] >= column.minWidth && previous[column.id] <= (column.maxWidth ?? Infinity)
72
+ );
73
+ if (valid && Math.abs(currentTotal - target) < 0.01) return previous;
74
+ const weights = columns.map(
75
+ (column) => Math.max(
76
+ 1,
77
+ Number.isFinite(previous[column.id]) ? previous[column.id] : column.defaultWidth
78
+ )
79
+ );
80
+ const widthAt = (index, scale) => Math.max(
81
+ columns[index].minWidth,
82
+ Math.min(columns[index].maxWidth ?? Infinity, weights[index] * scale)
83
+ );
84
+ let low = 0;
85
+ let high = Math.max(1, target / Math.min(...weights));
86
+ for (let iteration = 0; iteration < 40; iteration += 1) {
87
+ const middle = (low + high) / 2;
88
+ const total = columns.reduce(
89
+ (sum, _, index) => sum + widthAt(index, middle),
90
+ 0
91
+ );
92
+ if (total < target) low = middle;
93
+ else high = middle;
94
+ }
95
+ const next = { ...previous };
96
+ columns.forEach((column, index) => {
97
+ next[column.id] = widthAt(index, (low + high) / 2);
98
+ });
99
+ return columns.every(
100
+ (column) => Math.abs(previous[column.id] - next[column.id]) < 0.01
101
+ ) ? previous : next;
102
+ }
103
+
104
+ // src/react/parametersTable/libs/splitterResize.ts
105
+ var EPSILON = 1e-3;
106
+ function finiteOr(value, fallback) {
107
+ return Number.isFinite(value) ? value : fallback;
108
+ }
109
+ function normalizeBounds(min, max) {
110
+ const safeMin = Math.max(0, finiteOr(min, 0));
111
+ const safeMax = Number.isFinite(max) ? Math.max(safeMin, max) : Number.POSITIVE_INFINITY;
112
+ return [safeMin, safeMax];
113
+ }
114
+ function clamp2(value, min, max) {
115
+ if (!Number.isFinite(value)) {
116
+ return min;
117
+ }
118
+ if (value < min) {
119
+ return min;
120
+ }
121
+ if (value > max) {
122
+ return max;
123
+ }
124
+ return value;
125
+ }
126
+ function applyAdjacentSplitterResize({
127
+ session,
128
+ clientX,
129
+ widths
130
+ }) {
131
+ if (!Number.isFinite(clientX)) {
132
+ return widths;
133
+ }
134
+ const { leftId, rightId, startClientX } = session;
135
+ if (!Number.isFinite(startClientX)) {
136
+ return widths;
137
+ }
138
+ const startLeftWidth = Math.max(
139
+ 0,
140
+ finiteOr(session.startLeftWidth, widths[leftId] ?? 0)
141
+ );
142
+ const startRightWidth = Math.max(
143
+ 0,
144
+ finiteOr(session.startRightWidth, widths[rightId] ?? 0)
145
+ );
146
+ const totalWidth = startLeftWidth + startRightWidth;
147
+ if (!Number.isFinite(totalWidth) || totalWidth <= 0) {
148
+ return widths;
149
+ }
150
+ const [leftMin, leftMax] = normalizeBounds(
151
+ session.leftMinWidth,
152
+ session.leftMaxWidth
153
+ );
154
+ const [rightMin, rightMax] = normalizeBounds(
155
+ session.rightMinWidth,
156
+ session.rightMaxWidth
157
+ );
158
+ const feasibleLeftMin = Math.max(
159
+ leftMin,
160
+ Number.isFinite(rightMax) ? totalWidth - rightMax : 0
161
+ );
162
+ const feasibleLeftMax = Math.min(leftMax, totalWidth - rightMin);
163
+ if (feasibleLeftMin > feasibleLeftMax + EPSILON) {
164
+ return widths;
165
+ }
166
+ const delta = clientX - startClientX;
167
+ const requestedLeft = startLeftWidth + delta;
168
+ const nextLeft = clamp2(requestedLeft, feasibleLeftMin, feasibleLeftMax);
169
+ const nextRight = totalWidth - nextLeft;
170
+ if (nextLeft < leftMin - EPSILON || nextLeft > leftMax + EPSILON || nextRight < rightMin - EPSILON || nextRight > rightMax + EPSILON) {
171
+ return widths;
172
+ }
173
+ const currentLeft = widths[leftId];
174
+ const currentRight = widths[rightId];
175
+ if (Number.isFinite(currentLeft) && Number.isFinite(currentRight) && Math.abs(currentLeft - nextLeft) < EPSILON && Math.abs(currentRight - nextRight) < EPSILON) {
176
+ return widths;
177
+ }
178
+ return {
179
+ ...widths,
180
+ [leftId]: nextLeft,
181
+ [rightId]: nextRight
182
+ };
183
+ }
184
+
185
+ // src/react/parametersTable/libs/reorder.ts
186
+ function reorder(list, startIndex, endIndex) {
187
+ if (!Number.isInteger(startIndex) || !Number.isInteger(endIndex) || startIndex < 0 || endIndex < 0 || startIndex >= list.length || endIndex >= list.length || startIndex === endIndex)
188
+ return list;
189
+ const result = [...list];
190
+ const [removed] = result.splice(startIndex, 1);
191
+ result.splice(endIndex, 0, removed);
192
+ return result;
193
+ }
194
+ function createRows(parameters) {
195
+ return parameters.map((parameter) => ({
196
+ id: nanoid.nanoid(),
197
+ parameter
198
+ }));
199
+ }
200
+ function getDisplayValue(row, document) {
201
+ const resolved = chunkWRHWOMZQ_cjs.resolveParameterValue(row.parameter, document);
202
+ if (Object.prototype.hasOwnProperty.call(row, "generatedValue")) {
203
+ return { value: row.generatedValue, source: "generated" };
204
+ }
205
+ return resolved;
206
+ }
207
+ function areParametersEqual(a, b) {
208
+ if (Object.is(a, b)) {
209
+ return true;
210
+ }
211
+ try {
212
+ return JSON.stringify(a) === JSON.stringify(b);
213
+ } catch {
214
+ return false;
215
+ }
216
+ }
217
+ function areParameterArraysEqual(a, b) {
218
+ if (a === b) {
219
+ return true;
220
+ }
221
+ if (a.length !== b.length) {
222
+ return false;
223
+ }
224
+ for (let i = 0; i < a.length; i += 1) {
225
+ if (!areParametersEqual(a[i], b[i])) {
226
+ return false;
227
+ }
228
+ }
229
+ return true;
230
+ }
231
+ function reconcileRows(previous, parameters) {
232
+ if (parameters.length === previous.length && parameters.every(
233
+ (parameter, index) => parameter === previous[index].parameter
234
+ ))
235
+ return previous;
236
+ if (parameters.length === 0) {
237
+ return [];
238
+ }
239
+ const previousByKey = /* @__PURE__ */ new Map();
240
+ for (const row of previous) {
241
+ const name = String(row.parameter.name ?? "");
242
+ const location = String(
243
+ row.parameter.in ?? ""
244
+ );
245
+ const key = `${location}\0${name}`;
246
+ const bucket = previousByKey.get(key);
247
+ if (bucket) {
248
+ bucket.push(row);
249
+ } else {
250
+ previousByKey.set(key, [row]);
251
+ }
252
+ }
253
+ const used = /* @__PURE__ */ new Set();
254
+ return parameters.map((parameter) => {
255
+ const name = String(parameter.name ?? "");
256
+ const location = String(
257
+ parameter.in ?? ""
258
+ );
259
+ const key = `${location}\0${name}`;
260
+ const bucket = previousByKey.get(key);
261
+ if (bucket) {
262
+ while (bucket.length > 0) {
263
+ const candidate = bucket.shift();
264
+ if (candidate && !used.has(candidate.id)) {
265
+ used.add(candidate.id);
266
+ return candidate.parameter === parameter ? candidate : { ...candidate, parameter };
267
+ }
268
+ }
269
+ }
270
+ return {
271
+ id: nanoid.nanoid(),
272
+ parameter
273
+ };
274
+ });
275
+ }
276
+ function ParameterSettings({
277
+ parameter,
278
+ document,
279
+ disabled,
280
+ onChange
281
+ }) {
282
+ const patch = (value) => {
283
+ if (!disabled) onChange({ ...parameter, ...value });
284
+ };
285
+ return /* @__PURE__ */ jsxRuntime.jsxs(
286
+ react$1.Popover.Root,
287
+ {
288
+ lazyMount: true,
289
+ unmountOnExit: true,
290
+ positioning: {
291
+ placement: "bottom-start",
292
+ strategy: "fixed",
293
+ overflowPadding: 12
294
+ },
295
+ children: [
296
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
297
+ react$1.Button,
298
+ {
299
+ width: "24px",
300
+ minWidth: "24px",
301
+ height: "24px",
302
+ padding: "0",
303
+ size: "xs",
304
+ variant: "ghost",
305
+ "aria-label": `Configure ${parameter.name}`,
306
+ title: `Configure ${parameter.name}`,
307
+ children: /* @__PURE__ */ jsxRuntime.jsx(vsc.VscSettingsCompact, { size: 16 })
308
+ }
309
+ ) }),
310
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Popover.Positioner, { children: /* @__PURE__ */ jsxRuntime.jsx(chunk4H3LXOL4_cjs.SettingsPanel, { title: parameter.name || "Parameter", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunk4H3LXOL4_cjs.InlineSchemaEditor_default.root, children: /* @__PURE__ */ jsxRuntime.jsxs(
311
+ react$1.Tabs.Root,
312
+ {
313
+ variant: "plain",
314
+ defaultValue: "schema",
315
+ lazyMount: true,
316
+ unmountOnExit: true,
317
+ children: [
318
+ /* @__PURE__ */ jsxRuntime.jsxs(react$1.Tabs.List, { children: [
319
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Tabs.Trigger, { value: "schema", children: "Schema" }),
320
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Tabs.Trigger, { value: "parameter", children: "Parameter" })
321
+ ] }),
322
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Tabs.Content, { value: "parameter", pt: "2", children: /* @__PURE__ */ jsxRuntime.jsxs(react$1.Stack, { gap: "2", children: [
323
+ /* @__PURE__ */ jsxRuntime.jsxs(react$1.Field.Root, { children: [
324
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Field.Label, { children: "Location" }),
325
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.NativeSelect.Root, { disabled, children: /* @__PURE__ */ jsxRuntime.jsx(
326
+ react$1.NativeSelect.Field,
327
+ {
328
+ value: parameter.in,
329
+ onChange: (event) => {
330
+ const location = event.target.value;
331
+ patch({
332
+ in: location,
333
+ required: location === "path" ? true : parameter.required
334
+ });
335
+ },
336
+ children: [
337
+ "query",
338
+ "header",
339
+ "path",
340
+ "cookie",
341
+ "querystring"
342
+ ].map((value) => /* @__PURE__ */ jsxRuntime.jsx("option", { children: value }, value))
343
+ }
344
+ ) })
345
+ ] }),
346
+ /* @__PURE__ */ jsxRuntime.jsxs(
347
+ react$1.Switch.Root,
348
+ {
349
+ checked: parameter.in === "path" || !!parameter.required,
350
+ disabled: disabled || parameter.in === "path",
351
+ onCheckedChange: (event) => patch({ required: event.checked }),
352
+ children: [
353
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Switch.HiddenInput, {}),
354
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Switch.Control, {}),
355
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Switch.Label, { children: "Required" })
356
+ ]
357
+ }
358
+ ),
359
+ /* @__PURE__ */ jsxRuntime.jsxs(react$1.Field.Root, { children: [
360
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Field.Label, { children: "Description" }),
361
+ /* @__PURE__ */ jsxRuntime.jsx(
362
+ react$1.Input,
363
+ {
364
+ value: parameter.description ?? "",
365
+ disabled,
366
+ onChange: (event) => patch({ description: event.target.value })
367
+ }
368
+ )
369
+ ] }),
370
+ /* @__PURE__ */ jsxRuntime.jsxs("details", { className: chunk4H3LXOL4_cjs.InlineSchemaEditor_default.reference, children: [
371
+ /* @__PURE__ */ jsxRuntime.jsx("summary", { children: "Serialization" }),
372
+ /* @__PURE__ */ jsxRuntime.jsxs(react$1.Stack, { gap: "2", pt: "2", children: [
373
+ /* @__PURE__ */ jsxRuntime.jsxs(react$1.Field.Root, { children: [
374
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Field.Label, { children: "Serialization style" }),
375
+ /* @__PURE__ */ jsxRuntime.jsx(
376
+ react$1.Input,
377
+ {
378
+ value: parameter.style ?? "",
379
+ disabled,
380
+ placeholder: "Default for location",
381
+ onChange: (event) => patch({ style: event.target.value || void 0 })
382
+ }
383
+ )
384
+ ] }),
385
+ /* @__PURE__ */ jsxRuntime.jsxs(
386
+ react$1.Switch.Root,
387
+ {
388
+ checked: !!parameter.explode,
389
+ disabled,
390
+ onCheckedChange: (event) => patch({ explode: event.checked }),
391
+ children: [
392
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Switch.HiddenInput, {}),
393
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Switch.Control, {}),
394
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Switch.Label, { children: "Explode" })
395
+ ]
396
+ }
397
+ ),
398
+ /* @__PURE__ */ jsxRuntime.jsxs(
399
+ react$1.Switch.Root,
400
+ {
401
+ checked: !!parameter.allowReserved,
402
+ disabled,
403
+ onCheckedChange: (event) => patch({ allowReserved: event.checked }),
404
+ children: [
405
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Switch.HiddenInput, {}),
406
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Switch.Control, {}),
407
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Switch.Label, { children: "Allow reserved characters" })
408
+ ]
409
+ }
410
+ )
411
+ ] })
412
+ ] })
413
+ ] }) }),
414
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Tabs.Content, { value: "schema", pt: "2", children: parameter.content ? /* @__PURE__ */ jsxRuntime.jsx("p", { children: "This parameter uses content. Its media type schema is preserved." }) : /* @__PURE__ */ jsxRuntime.jsx(
415
+ chunk4H3LXOL4_cjs.InlineSchemaEditor,
416
+ {
417
+ schema: parameter.schema ?? {},
418
+ fullSchema: document,
419
+ nested: true,
420
+ disabled,
421
+ onChange: (value) => patch({ schema: value })
422
+ }
423
+ ) })
424
+ ]
425
+ }
426
+ ) }) }) }) })
427
+ ]
428
+ }
429
+ );
430
+ }
431
+
432
+ // src/react/parametersTable/ParametersTable.module.css
433
+ var ParametersTable_default = {
434
+ root: "ParametersTable_root",
435
+ tableViewport: "ParametersTable_tableViewport",
436
+ tableContainer: "ParametersTable_tableContainer",
437
+ table: "ParametersTable_table",
438
+ colCheckbox: "ParametersTable_colCheckbox",
439
+ colData: "ParametersTable_colData",
440
+ headerCell: "ParametersTable_headerCell",
441
+ checkboxCell: "ParametersTable_checkboxCell",
442
+ headerContent: "ParametersTable_headerContent",
443
+ headerLabel: "ParametersTable_headerLabel",
444
+ resizeHandle: "ParametersTable_resizeHandle",
445
+ variableTextEditor: "ParametersTable_variableTextEditor",
446
+ row: "ParametersTable_row",
447
+ cell: "ParametersTable_cell",
448
+ nameCell: "ParametersTable_nameCell",
449
+ checkboxCellGroup: "ParametersTable_checkboxCellGroup",
450
+ checkboxRoot: "ParametersTable_checkboxRoot",
451
+ dragHandleWrap: "ParametersTable_dragHandleWrap",
452
+ dragHandle: "ParametersTable_dragHandle",
453
+ description: "ParametersTable_description",
454
+ required: "ParametersTable_required",
455
+ optional: "ParametersTable_optional",
456
+ empty: "ParametersTable_empty",
457
+ actionBarContent: "ParametersTable_actionBarContent",
458
+ actionBarLeft: "ParametersTable_actionBarLeft",
459
+ actionBarTrigger: "ParametersTable_actionBarTrigger",
460
+ actionBarDivider: "ParametersTable_actionBarDivider",
461
+ actionButton: "ParametersTable_actionButton",
462
+ actionButtonAccent: "ParametersTable_actionButtonAccent",
463
+ actionIcon: "ParametersTable_actionIcon"
464
+ };
465
+ var EMPTY_VARIABLES = Object.freeze([]);
466
+ var CHECKBOX_COLUMN_WIDTH = 48;
467
+ var RowDragHandle = react.memo(function RowDragHandle2() {
468
+ return /* @__PURE__ */ jsxRuntime.jsx(
469
+ react$1.Box,
470
+ {
471
+ className: ParametersTable_default.dragHandle,
472
+ "aria-label": "Drag to reorder",
473
+ role: "button",
474
+ children: /* @__PURE__ */ jsxRuntime.jsx(lu.LuGripVertical, { size: 14 })
475
+ }
476
+ );
477
+ });
478
+ var ParameterTable = react.memo(function ParameterTable2(props) {
479
+ const {
480
+ parameters,
481
+ onChange,
482
+ onSelectionChange,
483
+ onRowReorder,
484
+ generateValue,
485
+ faker,
486
+ emptyState,
487
+ showRequired = false,
488
+ showType = false,
489
+ showDescription = false,
490
+ stickyHeader = true,
491
+ height = "100%",
492
+ className
493
+ } = props;
494
+ const readOnly = props.readOnly === true;
495
+ const requestMode = props.mode === "request";
496
+ const [generationError, setGenerationError] = react.useState(null);
497
+ const generationRef = react.useRef(null);
498
+ const rowsRef = react.useRef([]);
499
+ react.useEffect(() => () => generationRef.current?.abort(), []);
500
+ const [rows, setRows] = react.useState(
501
+ () => createRows(parameters)
502
+ );
503
+ rowsRef.current = rows;
504
+ const hasRows = rows.length > 0;
505
+ react.useEffect(() => {
506
+ generationRef.current?.abort();
507
+ }, [readOnly, requestMode, props.document]);
508
+ const [selectedIds, setSelectedIds] = react.useState(() => /* @__PURE__ */ new Set());
509
+ const lastEmittedParametersRef = react.useRef(
510
+ null
511
+ );
512
+ const visibleColumns = react.useMemo(
513
+ () => getVisibleColumns({
514
+ showRequired,
515
+ showType,
516
+ showDescription
517
+ }),
518
+ [showRequired, showType, showDescription]
519
+ );
520
+ const columnDefsById = react.useMemo(
521
+ () => buildColumnDefsById(DEFAULT_COLUMNS),
522
+ []
523
+ );
524
+ const [columnWidths, setColumnWidths] = react.useState(
525
+ () => {
526
+ const initial = {};
527
+ for (const column of DEFAULT_COLUMNS) {
528
+ initial[column.id] = column.defaultWidth;
529
+ }
530
+ return initial;
531
+ }
532
+ );
533
+ const widthsByLayoutRef = react.useRef(/* @__PURE__ */ new Map());
534
+ const activeLayoutRef = react.useRef(null);
535
+ const currentWidthsRef = react.useRef(columnWidths);
536
+ currentWidthsRef.current = columnWidths;
537
+ const viewportRef = react.useRef(null);
538
+ const tableRef = react.useRef(null);
539
+ const resizeHandleRefs = react.useRef(/* @__PURE__ */ new Map());
540
+ react.useEffect(() => {
541
+ const lastEmitted = lastEmittedParametersRef.current;
542
+ if (lastEmitted && areParameterArraysEqual(parameters, lastEmitted)) {
543
+ lastEmittedParametersRef.current = null;
544
+ return;
545
+ }
546
+ setRows((previous) => reconcileRows(previous, parameters));
547
+ setSelectedIds(/* @__PURE__ */ new Set());
548
+ }, [parameters]);
549
+ react.useEffect(() => {
550
+ onSelectionChange?.([...selectedIds]);
551
+ }, [onSelectionChange, selectedIds]);
552
+ react.useLayoutEffect(() => {
553
+ const viewport = viewportRef.current;
554
+ if (!viewport) return;
555
+ const layoutKey = visibleColumns.map((column) => column.id).join(",");
556
+ if (activeLayoutRef.current !== null) {
557
+ widthsByLayoutRef.current.set(
558
+ activeLayoutRef.current,
559
+ currentWidthsRef.current
560
+ );
561
+ }
562
+ activeLayoutRef.current = layoutKey;
563
+ const restored = widthsByLayoutRef.current.get(layoutKey) ?? Object.fromEntries(
564
+ DEFAULT_COLUMNS.map((column) => [column.id, column.defaultWidth])
565
+ );
566
+ let firstMeasurement = true;
567
+ let lastWidth = -1;
568
+ let disposed = false;
569
+ const synchronize = () => {
570
+ if (disposed) return;
571
+ const width = viewport.clientWidth;
572
+ if (!Number.isFinite(width) || width <= 0 || width === lastWidth) return;
573
+ lastWidth = width;
574
+ const baseline = firstMeasurement ? restored : void 0;
575
+ firstMeasurement = false;
576
+ setColumnWidths(
577
+ (previous) => fitColumnWidths(
578
+ baseline ?? previous,
579
+ visibleColumns,
580
+ width - CHECKBOX_COLUMN_WIDTH
581
+ )
582
+ );
583
+ };
584
+ synchronize();
585
+ if (typeof ResizeObserver === "undefined") {
586
+ window.addEventListener("resize", synchronize);
587
+ return () => {
588
+ disposed = true;
589
+ window.removeEventListener("resize", synchronize);
590
+ };
591
+ }
592
+ const observer = new ResizeObserver(synchronize);
593
+ observer.observe(viewport);
594
+ return () => {
595
+ disposed = true;
596
+ observer.disconnect();
597
+ };
598
+ }, [visibleColumns, hasRows]);
599
+ const [localValues, setLocalValues] = react.useState({});
600
+ const effectiveValues = props.values ?? localValues;
601
+ const controlledValuesRef = react.useRef(props.values !== void 0);
602
+ controlledValuesRef.current = props.values !== void 0;
603
+ const valuesRef = react.useRef(effectiveValues);
604
+ valuesRef.current = effectiveValues;
605
+ const onValuesChangeRef = react.useRef(props.onValuesChange);
606
+ onValuesChangeRef.current = props.onValuesChange;
607
+ const writeValues = (nextRows, changedIds) => {
608
+ const next = { ...valuesRef.current };
609
+ for (const row of nextRows) {
610
+ if (!changedIds.has(row.id)) continue;
611
+ if (Object.prototype.hasOwnProperty.call(row, "generatedValue")) {
612
+ const key = chunkYNKP5JJA_cjs.parameterKey(row.parameter);
613
+ next[key] = {
614
+ enabled: next[key]?.enabled ?? true,
615
+ value: row.generatedValue
616
+ };
617
+ }
618
+ }
619
+ if (!controlledValuesRef.current) valuesRef.current = next;
620
+ setLocalValues(next);
621
+ onValuesChangeRef.current?.(next);
622
+ };
623
+ const editValue = (rowId, value) => {
624
+ if (readOnly) return;
625
+ const next = rowsRef.current.map(
626
+ (row) => row.id === rowId ? { ...row, generatedValue: value } : row
627
+ );
628
+ rowsRef.current = next;
629
+ setRows(next);
630
+ writeValues(next, /* @__PURE__ */ new Set([rowId]));
631
+ };
632
+ const allSelected = rows.length > 0 && rows.every((row) => selectedIds.has(row.id));
633
+ const someSelected = rows.some((row) => selectedIds.has(row.id)) && !allSelected;
634
+ const handleSelectAll = react.useCallback(
635
+ (checked) => {
636
+ if (!checked) {
637
+ setSelectedIds(/* @__PURE__ */ new Set());
638
+ return;
639
+ }
640
+ setSelectedIds(new Set(rows.map((row) => row.id)));
641
+ },
642
+ [rows]
643
+ );
644
+ const handleSelectRow = react.useCallback((rowId, checked) => {
645
+ setSelectedIds((previous) => {
646
+ const next = new Set(previous);
647
+ if (checked) {
648
+ next.add(rowId);
649
+ } else {
650
+ next.delete(rowId);
651
+ }
652
+ return next;
653
+ });
654
+ }, []);
655
+ const commitRows = react.useCallback(
656
+ (nextRows) => {
657
+ if (readOnly || requestMode) return;
658
+ rowsRef.current = nextRows;
659
+ setRows(nextRows);
660
+ const nextParameters = nextRows.map((row) => row.parameter);
661
+ lastEmittedParametersRef.current = nextParameters;
662
+ onChange?.(nextParameters);
663
+ },
664
+ [onChange, readOnly, requestMode]
665
+ );
666
+ const commitReorder = react.useCallback(
667
+ (nextRows) => {
668
+ if (readOnly || requestMode) return;
669
+ rowsRef.current = nextRows;
670
+ setRows(nextRows);
671
+ const nextParameters = nextRows.map((row) => row.parameter);
672
+ lastEmittedParametersRef.current = nextParameters;
673
+ onChange?.(nextParameters);
674
+ onRowReorder?.(nextParameters);
675
+ },
676
+ [onChange, onRowReorder, readOnly, requestMode]
677
+ );
678
+ const typeOptions = react.useMemo(
679
+ () => react$1.createListCollection({
680
+ items: [
681
+ {
682
+ label: "string",
683
+ value: "string"
684
+ },
685
+ {
686
+ label: "integer",
687
+ value: "integer"
688
+ },
689
+ ...["number", "boolean", "array", "object", "null"].map((value) => ({
690
+ label: value,
691
+ value
692
+ }))
693
+ ]
694
+ }),
695
+ []
696
+ );
697
+ const handleGenerate = react.useCallback(async () => {
698
+ if (readOnly) return;
699
+ setGenerationError(null);
700
+ generationRef.current?.abort();
701
+ const controller = new AbortController();
702
+ generationRef.current = controller;
703
+ const snapshot = rowsRef.current;
704
+ const valuesSnapshot = valuesRef.current;
705
+ const generated = /* @__PURE__ */ new Map();
706
+ await Promise.all(
707
+ snapshot.map(async (row, rowIndex) => {
708
+ if (!selectedIds.has(row.id) || !controlledValuesRef.current && Object.prototype.hasOwnProperty.call(row, "generatedValue"))
709
+ return;
710
+ const key = chunkYNKP5JJA_cjs.parameterKey(row.parameter);
711
+ if (valuesSnapshot?.[key] || chunkWRHWOMZQ_cjs.resolveParameterValue(row.parameter, props.document).source !== "missing")
712
+ return;
713
+ try {
714
+ const context = {
715
+ parameter: row.parameter,
716
+ rowIndex,
717
+ signal: controller.signal,
718
+ document: props.document
719
+ };
720
+ const value = generateValue ? await generateValue(context) : faker ? await faker.generate(context) : await import('./react/parametersTable/libs/generateValue.cjs').then(
721
+ (module) => module.generateParameterValue(context)
722
+ );
723
+ generated.set(row.id, { ...row, generatedValue: value });
724
+ } catch (error) {
725
+ if (!controller.signal.aborted) {
726
+ setGenerationError(
727
+ error instanceof Error ? error.message : "Value generation failed."
728
+ );
729
+ try {
730
+ props.onError?.(error);
731
+ } catch {
732
+ }
733
+ }
734
+ }
735
+ })
736
+ );
737
+ if (controller.signal.aborted) return;
738
+ const originals = new Map(snapshot.map((row) => [row.id, row]));
739
+ const next = rowsRef.current.map((row) => {
740
+ const key = chunkYNKP5JJA_cjs.parameterKey(row.parameter);
741
+ return row === originals.get(row.id) && valuesRef.current?.[key] === valuesSnapshot?.[key] ? generated.get(row.id) ?? row : row;
742
+ });
743
+ const changedIds = new Set(
744
+ next.filter((row, index) => row !== rowsRef.current[index]).map((row) => row.id)
745
+ );
746
+ if (!changedIds.size) return;
747
+ rowsRef.current = next;
748
+ setRows(next);
749
+ writeValues(next, changedIds);
750
+ }, [
751
+ faker,
752
+ generateValue,
753
+ selectedIds,
754
+ readOnly,
755
+ props.onError,
756
+ props.document
757
+ ]);
758
+ const onDragEnd = react.useCallback(
759
+ (result) => {
760
+ const { destination, source } = result;
761
+ if (!destination) {
762
+ return;
763
+ }
764
+ if (destination.droppableId !== source.droppableId) {
765
+ return;
766
+ }
767
+ if (destination.index === source.index) {
768
+ return;
769
+ }
770
+ const next = reorder(rows, source.index, destination.index);
771
+ commitReorder(next);
772
+ },
773
+ [commitReorder, rows]
774
+ );
775
+ const resizeSessionRef = react.useRef(null);
776
+ const resizeRafRef = react.useRef(null);
777
+ const pendingResizeSnapshotRef = react.useRef(null);
778
+ const resizingColumnRef = react.useRef(null);
779
+ const getActualColumnWidth = react.useCallback(
780
+ (columnId) => {
781
+ const header = tableRef.current?.querySelector(
782
+ `th[data-column="${columnId}"]`
783
+ );
784
+ if (!header) {
785
+ return null;
786
+ }
787
+ const width = header.getBoundingClientRect().width;
788
+ if (!Number.isFinite(width) || width <= 0) {
789
+ return null;
790
+ }
791
+ return width;
792
+ },
793
+ []
794
+ );
795
+ const cleanupResize = react.useCallback(() => {
796
+ resizingColumnRef.current = null;
797
+ pendingResizeSnapshotRef.current = null;
798
+ resizeSessionRef.current = null;
799
+ if (resizeRafRef.current !== null) {
800
+ window.cancelAnimationFrame(resizeRafRef.current);
801
+ resizeRafRef.current = null;
802
+ }
803
+ const handles = resizeHandleRefs.current;
804
+ for (const handle of handles.values()) {
805
+ handle.removeAttribute("data-resizing");
806
+ }
807
+ }, []);
808
+ const onResizeMoveWindow = react.useCallback((event) => {
809
+ const session = resizeSessionRef.current;
810
+ if (!session) {
811
+ return;
812
+ }
813
+ if (session.pointerId !== event.pointerId) {
814
+ return;
815
+ }
816
+ pendingResizeSnapshotRef.current = {
817
+ clientX: event.clientX,
818
+ pointerId: event.pointerId
819
+ };
820
+ if (resizeRafRef.current !== null) {
821
+ return;
822
+ }
823
+ resizeRafRef.current = window.requestAnimationFrame(() => {
824
+ resizeRafRef.current = null;
825
+ const activeSession = resizeSessionRef.current;
826
+ const snapshot = pendingResizeSnapshotRef.current;
827
+ if (!activeSession || !snapshot) {
828
+ return;
829
+ }
830
+ if (snapshot.pointerId !== activeSession.pointerId) {
831
+ return;
832
+ }
833
+ const clientX = snapshot.clientX;
834
+ setColumnWidths(
835
+ (previous) => applyAdjacentSplitterResize({
836
+ session: activeSession,
837
+ clientX,
838
+ widths: previous
839
+ })
840
+ );
841
+ });
842
+ }, []);
843
+ const onResizeEndWindow = react.useCallback(
844
+ (event) => {
845
+ const session = resizeSessionRef.current;
846
+ if (!session) {
847
+ return;
848
+ }
849
+ if (session.pointerId !== event.pointerId) {
850
+ return;
851
+ }
852
+ if (event.type === "pointerup")
853
+ setColumnWidths(
854
+ (widths) => applyAdjacentSplitterResize({
855
+ session,
856
+ clientX: event.clientX,
857
+ widths
858
+ })
859
+ );
860
+ cleanupResize();
861
+ window.removeEventListener("pointermove", onResizeMoveWindow);
862
+ window.removeEventListener("pointerup", onResizeEndWindow);
863
+ window.removeEventListener("pointercancel", onResizeEndWindow);
864
+ },
865
+ [cleanupResize, onResizeMoveWindow]
866
+ );
867
+ react.useEffect(() => {
868
+ return () => {
869
+ cleanupResize();
870
+ window.removeEventListener("pointermove", onResizeMoveWindow);
871
+ window.removeEventListener("pointerup", onResizeEndWindow);
872
+ window.removeEventListener("pointercancel", onResizeEndWindow);
873
+ };
874
+ }, [cleanupResize, onResizeEndWindow, onResizeMoveWindow]);
875
+ const onResizeStart = react.useCallback(
876
+ (event, leftColumn) => {
877
+ if (event.pointerType === "mouse" && event.button !== 0) {
878
+ return;
879
+ }
880
+ event.preventDefault();
881
+ event.stopPropagation();
882
+ const rightId = getRightNeighborId(visibleColumns, leftColumn.id);
883
+ if (!rightId) {
884
+ return;
885
+ }
886
+ const leftDefinition = columnDefsById[leftColumn.id];
887
+ const rightDefinition = columnDefsById[rightId];
888
+ if (!leftDefinition || !rightDefinition) {
889
+ return;
890
+ }
891
+ const actualLeftWidth = getActualColumnWidth(leftColumn.id);
892
+ const actualRightWidth = getActualColumnWidth(rightId);
893
+ if (actualLeftWidth === null || actualRightWidth === null) {
894
+ return;
895
+ }
896
+ if (actualLeftWidth < leftDefinition.minWidth || actualRightWidth < rightDefinition.minWidth) {
897
+ return;
898
+ }
899
+ const session = {
900
+ leftId: leftColumn.id,
901
+ rightId,
902
+ pointerId: event.pointerId,
903
+ startClientX: event.clientX,
904
+ startLeftWidth: actualLeftWidth,
905
+ startRightWidth: actualRightWidth,
906
+ leftMinWidth: leftDefinition.minWidth,
907
+ leftMaxWidth: leftDefinition.maxWidth ?? Number.POSITIVE_INFINITY,
908
+ rightMinWidth: rightDefinition.minWidth,
909
+ rightMaxWidth: rightDefinition.maxWidth ?? Number.POSITIVE_INFINITY
910
+ };
911
+ resizeSessionRef.current = session;
912
+ pendingResizeSnapshotRef.current = {
913
+ clientX: event.clientX,
914
+ pointerId: event.pointerId
915
+ };
916
+ resizingColumnRef.current = leftColumn.id;
917
+ const leftHandle = resizeHandleRefs.current.get(leftColumn.id);
918
+ leftHandle?.setAttribute("data-resizing", "true");
919
+ window.addEventListener("pointermove", onResizeMoveWindow, {
920
+ passive: true
921
+ });
922
+ window.addEventListener("pointerup", onResizeEndWindow, {
923
+ passive: true
924
+ });
925
+ window.addEventListener("pointercancel", onResizeEndWindow, {
926
+ passive: true
927
+ });
928
+ },
929
+ [
930
+ columnDefsById,
931
+ getActualColumnWidth,
932
+ onResizeEndWindow,
933
+ onResizeMoveWindow,
934
+ visibleColumns
935
+ ]
936
+ );
937
+ const handleInputChange = react.useCallback(
938
+ (rowId, updater) => {
939
+ const currentRows = rowsRef.current;
940
+ const nextRows = currentRows.map(
941
+ (row) => row.id === rowId ? {
942
+ ...row,
943
+ parameter: updater(row.parameter)
944
+ } : row
945
+ );
946
+ commitRows(nextRows);
947
+ },
948
+ [commitRows, rows]
949
+ );
950
+ const handleDeleteSelected = react.useCallback(() => {
951
+ if (selectedIds.size === 0) {
952
+ return;
953
+ }
954
+ const nextRows = rows.filter((row) => !selectedIds.has(row.id));
955
+ setSelectedIds(/* @__PURE__ */ new Set());
956
+ commitRows(nextRows);
957
+ }, [commitRows, rows, selectedIds]);
958
+ const setResizeHandleRef = react.useCallback(
959
+ (columnId, node) => {
960
+ if (node) {
961
+ resizeHandleRefs.current.set(columnId, node);
962
+ } else {
963
+ resizeHandleRefs.current.delete(columnId);
964
+ }
965
+ },
966
+ []
967
+ );
968
+ if (rows.length === 0) {
969
+ return /* @__PURE__ */ jsxRuntime.jsxs(
970
+ react$1.Box,
971
+ {
972
+ className: `${ParametersTable_default.root} ${className ?? ""}`,
973
+ "data-sticky-header": stickyHeader,
974
+ style: { height },
975
+ children: [
976
+ generationError && /* @__PURE__ */ jsxRuntime.jsx(react$1.Text, { role: "alert", fontSize: "sm", p: "2", color: "var(--color-danger)", children: generationError }),
977
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Box, { className: ParametersTable_default.toolbar, children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Box, { className: ParametersTable_default.toolbarLeft, children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Text, { className: ParametersTable_default.toolbarTitle, children: "Parameters" }) }) }),
978
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Box, { className: ParametersTable_default.empty, children: emptyState ?? /* @__PURE__ */ jsxRuntime.jsx(react$1.Text, { children: "No parameters defined." }) })
979
+ ]
980
+ }
981
+ );
982
+ }
983
+ return /* @__PURE__ */ jsxRuntime.jsxs(
984
+ react$1.Box,
985
+ {
986
+ className: `${ParametersTable_default.root} ${className ?? ""}`,
987
+ "data-sticky-header": stickyHeader,
988
+ style: { height },
989
+ children: [
990
+ generationError && /* @__PURE__ */ jsxRuntime.jsx(react$1.Text, { role: "alert", fontSize: "sm", p: "2", color: "var(--color-danger)", children: generationError }),
991
+ /* @__PURE__ */ jsxRuntime.jsxs(react$1.Box, { ref: viewportRef, className: ParametersTable_default.tableViewport, children: [
992
+ /* @__PURE__ */ jsxRuntime.jsx(dnd.DragDropContext, { onDragEnd, children: /* @__PURE__ */ jsxRuntime.jsx(dnd.Droppable, { droppableId: "parameters", direction: "vertical", children: (provided) => /* @__PURE__ */ jsxRuntime.jsx(
993
+ react$1.Box,
994
+ {
995
+ ref: provided.innerRef,
996
+ ...provided.droppableProps,
997
+ className: ParametersTable_default.tableContainer,
998
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
999
+ react$1.Table.Root,
1000
+ {
1001
+ ref: tableRef,
1002
+ className: ParametersTable_default.table,
1003
+ stickyHeader: stickyHeader ? true : void 0,
1004
+ interactive: true,
1005
+ size: "sm",
1006
+ children: [
1007
+ /* @__PURE__ */ jsxRuntime.jsxs("colgroup", { children: [
1008
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: ParametersTable_default.colCheckbox }),
1009
+ visibleColumns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
1010
+ "col",
1011
+ {
1012
+ className: ParametersTable_default.colData,
1013
+ style: {
1014
+ width: columnWidths[column.id]
1015
+ }
1016
+ },
1017
+ column.id
1018
+ ))
1019
+ ] }),
1020
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Table.Header, { children: /* @__PURE__ */ jsxRuntime.jsxs(react$1.Table.Row, { children: [
1021
+ /* @__PURE__ */ jsxRuntime.jsx(
1022
+ react$1.Table.ColumnHeader,
1023
+ {
1024
+ className: `${ParametersTable_default.headerCell} ${ParametersTable_default.checkboxCell}`,
1025
+ children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Flex, { className: ParametersTable_default.checkboxCellGroup, children: /* @__PURE__ */ jsxRuntime.jsxs(
1026
+ react$1.Checkbox.Root,
1027
+ {
1028
+ checked: allSelected ? true : someSelected ? "indeterminate" : false,
1029
+ onCheckedChange: (details) => handleSelectAll(details.checked === true),
1030
+ size: "sm",
1031
+ "aria-label": "Select all parameters",
1032
+ className: ParametersTable_default.checkboxRoot,
1033
+ children: [
1034
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Checkbox.HiddenInput, {}),
1035
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Checkbox.Control, {})
1036
+ ]
1037
+ }
1038
+ ) })
1039
+ }
1040
+ ),
1041
+ visibleColumns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
1042
+ react$1.Table.ColumnHeader,
1043
+ {
1044
+ "data-column": column.id,
1045
+ "data-sticky": column.id === "name" ? "end" : void 0,
1046
+ className: ParametersTable_default.headerCell,
1047
+ children: /* @__PURE__ */ jsxRuntime.jsxs(react$1.Box, { className: ParametersTable_default.headerContent, children: [
1048
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Span, { className: ParametersTable_default.headerLabel, children: column.label }),
1049
+ getRightNeighborId(visibleColumns, column.id) && /* @__PURE__ */ jsxRuntime.jsx(
1050
+ react$1.Span,
1051
+ {
1052
+ tabIndex: 0,
1053
+ "aria-valuenow": Math.round(
1054
+ columnWidths[column.id]
1055
+ ),
1056
+ "aria-valuemin": column.minWidth,
1057
+ onKeyDown: (event) => {
1058
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight")
1059
+ return;
1060
+ event.preventDefault();
1061
+ const rightId = getRightNeighborId(
1062
+ visibleColumns,
1063
+ column.id
1064
+ );
1065
+ if (!rightId) return;
1066
+ const right = columnDefsById[rightId];
1067
+ setColumnWidths(
1068
+ (widths) => applyAdjacentSplitterResize({
1069
+ widths,
1070
+ clientX: (event.key === "ArrowRight" ? 1 : -1) * (event.shiftKey ? 32 : 8),
1071
+ session: {
1072
+ leftId: column.id,
1073
+ rightId,
1074
+ startClientX: 0,
1075
+ startLeftWidth: widths[column.id],
1076
+ startRightWidth: widths[rightId],
1077
+ leftMinWidth: column.minWidth,
1078
+ leftMaxWidth: column.maxWidth ?? Infinity,
1079
+ rightMinWidth: right.minWidth,
1080
+ rightMaxWidth: right.maxWidth ?? Infinity
1081
+ }
1082
+ })
1083
+ );
1084
+ },
1085
+ ref: (node) => setResizeHandleRef(column.id, node),
1086
+ className: ParametersTable_default.resizeHandle,
1087
+ role: "separator",
1088
+ "aria-orientation": "vertical",
1089
+ "aria-label": `Resize ${column.label} column`,
1090
+ onPointerDown: (event) => onResizeStart(event, column)
1091
+ }
1092
+ )
1093
+ ] })
1094
+ },
1095
+ column.id
1096
+ ))
1097
+ ] }) }),
1098
+ /* @__PURE__ */ jsxRuntime.jsxs(react$1.Table.Body, { children: [
1099
+ rows.map((row, index) => {
1100
+ const parameter = row.parameter;
1101
+ const displayValue = props.values !== void 0 ? chunkWRHWOMZQ_cjs.resolveParameterValue(parameter, props.document) : getDisplayValue(row, props.document);
1102
+ const type = chunkWRHWOMZQ_cjs.resolveParameterType(
1103
+ parameter,
1104
+ props.document
1105
+ );
1106
+ const selected = selectedIds.has(row.id);
1107
+ return /* @__PURE__ */ jsxRuntime.jsx(
1108
+ dnd.Draggable,
1109
+ {
1110
+ draggableId: row.id,
1111
+ index,
1112
+ isDragDisabled: readOnly || requestMode,
1113
+ children: (dragProvided, snapshot) => /* @__PURE__ */ jsxRuntime.jsxs(
1114
+ react$1.Table.Row,
1115
+ {
1116
+ ref: dragProvided.innerRef,
1117
+ className: ParametersTable_default.row,
1118
+ "data-selected": selected,
1119
+ "data-dragging": snapshot.isDragging ? "true" : "false",
1120
+ ...dragProvided.draggableProps,
1121
+ children: [
1122
+ /* @__PURE__ */ jsxRuntime.jsx(
1123
+ react$1.Table.Cell,
1124
+ {
1125
+ className: `${ParametersTable_default.cell} ${ParametersTable_default.checkboxCell}`,
1126
+ children: /* @__PURE__ */ jsxRuntime.jsxs(react$1.Flex, { className: ParametersTable_default.checkboxCellGroup, children: [
1127
+ /* @__PURE__ */ jsxRuntime.jsx(
1128
+ react$1.Box,
1129
+ {
1130
+ ...dragProvided.dragHandleProps,
1131
+ className: ParametersTable_default.dragHandleWrap,
1132
+ display: readOnly || requestMode ? "none" : void 0,
1133
+ "aria-label": `Drag ${parameter.name ?? ""}`,
1134
+ children: /* @__PURE__ */ jsxRuntime.jsx(RowDragHandle, {})
1135
+ }
1136
+ ),
1137
+ /* @__PURE__ */ jsxRuntime.jsxs(
1138
+ react$1.Checkbox.Root,
1139
+ {
1140
+ size: "sm",
1141
+ checked: selected,
1142
+ onCheckedChange: (details) => handleSelectRow(
1143
+ row.id,
1144
+ details.checked === true
1145
+ ),
1146
+ "aria-label": `Select ${parameter.name ?? "parameter"}`,
1147
+ className: ParametersTable_default.checkboxRoot,
1148
+ children: [
1149
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Checkbox.HiddenInput, {}),
1150
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Checkbox.Control, {})
1151
+ ]
1152
+ }
1153
+ )
1154
+ ] })
1155
+ }
1156
+ ),
1157
+ visibleColumns.map((column) => {
1158
+ switch (column.id) {
1159
+ case "name":
1160
+ return /* @__PURE__ */ jsxRuntime.jsx(
1161
+ react$1.Table.Cell,
1162
+ {
1163
+ className: `${ParametersTable_default.cell} ${ParametersTable_default.nameCell}`,
1164
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1165
+ react$1.Box,
1166
+ {
1167
+ className: ParametersTable_default.variableTextEditor,
1168
+ children: [
1169
+ /* @__PURE__ */ jsxRuntime.jsx(
1170
+ chunkGXXD6ITE_cjs.VariableTextEditor,
1171
+ {
1172
+ autoFocus: false,
1173
+ ariaLabel: `Name for ${parameter.name}`,
1174
+ readOnly: readOnly || requestMode,
1175
+ value: String(parameter.name ?? ""),
1176
+ onSubmit: () => {
1177
+ },
1178
+ placeholder: "Name",
1179
+ variables: EMPTY_VARIABLES,
1180
+ allowLineBreaks: false,
1181
+ submitOnEnter: true,
1182
+ expansionMode: "overlay",
1183
+ minHeight: 28,
1184
+ safePadding: 4,
1185
+ maxFocusedHeight: 360,
1186
+ onChange: (name) => {
1187
+ handleInputChange(
1188
+ row.id,
1189
+ (p) => ({
1190
+ ...p,
1191
+ name
1192
+ })
1193
+ );
1194
+ }
1195
+ }
1196
+ ),
1197
+ /* @__PURE__ */ jsxRuntime.jsx(
1198
+ ParameterSettings,
1199
+ {
1200
+ parameter,
1201
+ document: props.document,
1202
+ disabled: readOnly || requestMode,
1203
+ onChange: (next) => handleInputChange(
1204
+ row.id,
1205
+ () => next
1206
+ )
1207
+ }
1208
+ )
1209
+ ]
1210
+ }
1211
+ )
1212
+ },
1213
+ column.id
1214
+ );
1215
+ case "value":
1216
+ return /* @__PURE__ */ jsxRuntime.jsx(
1217
+ react$1.Table.Cell,
1218
+ {
1219
+ className: ParametersTable_default.cell,
1220
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1221
+ react$1.Box,
1222
+ {
1223
+ className: ParametersTable_default.variableTextEditor,
1224
+ children: [
1225
+ requestMode && /* @__PURE__ */ jsxRuntime.jsxs(
1226
+ react$1.Checkbox.Root,
1227
+ {
1228
+ className: ParametersTable_default.checkboxRoot,
1229
+ size: "sm",
1230
+ disabled: readOnly || parameter.in === "path",
1231
+ checked: parameter.in === "path" || (effectiveValues[chunkYNKP5JJA_cjs.parameterKey(parameter)]?.enabled ?? true),
1232
+ "aria-label": `Include ${parameter.name}`,
1233
+ onCheckedChange: (event) => {
1234
+ const key = chunkYNKP5JJA_cjs.parameterKey(parameter);
1235
+ const next = {
1236
+ ...valuesRef.current,
1237
+ [key]: {
1238
+ value: valuesRef.current?.[key] ? valuesRef.current[key].value : displayValue.value,
1239
+ enabled: event.checked === true
1240
+ }
1241
+ };
1242
+ setLocalValues(next);
1243
+ onValuesChangeRef.current?.(
1244
+ next
1245
+ );
1246
+ },
1247
+ children: [
1248
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Checkbox.HiddenInput, {}),
1249
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Checkbox.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Checkbox.Indicator, {}) })
1250
+ ]
1251
+ }
1252
+ ),
1253
+ /* @__PURE__ */ jsxRuntime.jsx(
1254
+ chunkGXXD6ITE_cjs.VariableTextEditor,
1255
+ {
1256
+ autoFocus: false,
1257
+ ariaLabel: `Value for ${parameter.name}`,
1258
+ readOnly,
1259
+ value: chunkYNKP5JJA_cjs.parameterValueText(
1260
+ Object.hasOwn(
1261
+ effectiveValues,
1262
+ chunkYNKP5JJA_cjs.parameterKey(parameter)
1263
+ ) ? effectiveValues[chunkYNKP5JJA_cjs.parameterKey(parameter)].value : displayValue.value
1264
+ ),
1265
+ onSubmit: () => {
1266
+ },
1267
+ placeholder: "Value",
1268
+ variables: EMPTY_VARIABLES,
1269
+ allowLineBreaks: true,
1270
+ expansionMode: "overlay",
1271
+ minHeight: 28,
1272
+ safePadding: 4,
1273
+ maxFocusedHeight: 360,
1274
+ onChange: (value) => {
1275
+ editValue(row.id, value);
1276
+ }
1277
+ }
1278
+ )
1279
+ ]
1280
+ }
1281
+ )
1282
+ },
1283
+ column.id
1284
+ );
1285
+ case "type":
1286
+ return /* @__PURE__ */ jsxRuntime.jsx(
1287
+ react$1.Table.Cell,
1288
+ {
1289
+ className: ParametersTable_default.cell,
1290
+ children: requestMode || readOnly || parameter.content ? /* @__PURE__ */ jsxRuntime.jsx(react$1.Span, { className: ParametersTable_default.description, children: type }) : /* @__PURE__ */ jsxRuntime.jsxs(
1291
+ react$1.Select.Root,
1292
+ {
1293
+ disabled: readOnly || requestMode,
1294
+ collection: typeOptions,
1295
+ size: "xs",
1296
+ value: [type.split(" (")[0]],
1297
+ onValueChange: (event) => {
1298
+ const newType = event.value[0];
1299
+ if (!newType) {
1300
+ return;
1301
+ }
1302
+ handleInputChange(
1303
+ row.id,
1304
+ (p) => ({
1305
+ ...p,
1306
+ schema: chunkGTZH37JS_cjs.createSchemaForType(
1307
+ newType,
1308
+ typeof p.schema === "object" ? p.schema : void 0
1309
+ )
1310
+ })
1311
+ );
1312
+ },
1313
+ children: [
1314
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Select.HiddenSelect, {}),
1315
+ /* @__PURE__ */ jsxRuntime.jsxs(react$1.Select.Control, { children: [
1316
+ /* @__PURE__ */ jsxRuntime.jsx(
1317
+ react$1.Select.Trigger,
1318
+ {
1319
+ "aria-label": `Type for ${parameter.name}`,
1320
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1321
+ react$1.Select.ValueText,
1322
+ {
1323
+ placeholder: type === "unknown" ? "Select type" : type
1324
+ }
1325
+ )
1326
+ }
1327
+ ),
1328
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Select.IndicatorGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Select.Indicator, {}) })
1329
+ ] }),
1330
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Select.Positioner, { children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Select.Content, { className: "pdDesignerSelectMenu", children: typeOptions.items.map(
1331
+ (item) => /* @__PURE__ */ jsxRuntime.jsxs(
1332
+ react$1.Select.Item,
1333
+ {
1334
+ item,
1335
+ children: [
1336
+ item.label,
1337
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Select.ItemIndicator, {})
1338
+ ]
1339
+ },
1340
+ item.value
1341
+ )
1342
+ ) }) }) })
1343
+ ]
1344
+ }
1345
+ )
1346
+ },
1347
+ column.id
1348
+ );
1349
+ case "required":
1350
+ return /* @__PURE__ */ jsxRuntime.jsx(
1351
+ react$1.Table.Cell,
1352
+ {
1353
+ className: ParametersTable_default.cell,
1354
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1355
+ react$1.Span,
1356
+ {
1357
+ className: parameter.in === "path" || parameter.required ? ParametersTable_default.required : ParametersTable_default.optional,
1358
+ children: parameter.in === "path" || parameter.required ? "Required" : "Optional"
1359
+ }
1360
+ )
1361
+ },
1362
+ column.id
1363
+ );
1364
+ case "description":
1365
+ return /* @__PURE__ */ jsxRuntime.jsx(
1366
+ react$1.Table.Cell,
1367
+ {
1368
+ className: ParametersTable_default.cell,
1369
+ children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Span, { className: ParametersTable_default.description, children: parameter.description ?? "\u2014" })
1370
+ },
1371
+ column.id
1372
+ );
1373
+ default:
1374
+ return null;
1375
+ }
1376
+ })
1377
+ ]
1378
+ }
1379
+ )
1380
+ },
1381
+ row.id
1382
+ );
1383
+ }),
1384
+ provided.placeholder
1385
+ ] })
1386
+ ]
1387
+ }
1388
+ )
1389
+ }
1390
+ ) }) }),
1391
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.ActionBar.Root, { open: selectedIds.size > 0, children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(react$1.ActionBar.Positioner, { children: /* @__PURE__ */ jsxRuntime.jsxs(react$1.ActionBar.Content, { className: ParametersTable_default.actionBarContent, children: [
1392
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Box, { className: ParametersTable_default.actionBarLeft, children: /* @__PURE__ */ jsxRuntime.jsxs(
1393
+ react$1.ActionBar.SelectionTrigger,
1394
+ {
1395
+ className: ParametersTable_default.actionBarTrigger,
1396
+ children: [
1397
+ selectedIds.size,
1398
+ " selected"
1399
+ ]
1400
+ }
1401
+ ) }),
1402
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Span, { className: ParametersTable_default.actionBarDivider }),
1403
+ /* @__PURE__ */ jsxRuntime.jsxs(
1404
+ react$1.Button,
1405
+ {
1406
+ variant: "ghost",
1407
+ size: "xs",
1408
+ className: ParametersTable_default.actionButton,
1409
+ disabled: readOnly || requestMode,
1410
+ onClick: handleDeleteSelected,
1411
+ children: [
1412
+ /* @__PURE__ */ jsxRuntime.jsx(ai.AiOutlineDelete, { className: ParametersTable_default.actionIcon }),
1413
+ "Delete"
1414
+ ]
1415
+ }
1416
+ ),
1417
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Span, { className: ParametersTable_default.actionBarDivider }),
1418
+ /* @__PURE__ */ jsxRuntime.jsxs(
1419
+ react$1.Button,
1420
+ {
1421
+ variant: "ghost",
1422
+ size: "xs",
1423
+ className: `${ParametersTable_default.actionButton} ${ParametersTable_default.actionButtonAccent}`,
1424
+ disabled: readOnly,
1425
+ onClick: handleGenerate,
1426
+ children: [
1427
+ /* @__PURE__ */ jsxRuntime.jsx(lu.LuRefreshCw, { className: ParametersTable_default.actionIcon }),
1428
+ "Generate values"
1429
+ ]
1430
+ }
1431
+ )
1432
+ ] }) }) }) })
1433
+ ] })
1434
+ ]
1435
+ }
1436
+ );
1437
+ });
1438
+
1439
+ exports.DEFAULT_COLUMNS = DEFAULT_COLUMNS;
1440
+ exports.ParameterTable = ParameterTable;
1441
+ exports.applyAdjacentSplitterResize = applyAdjacentSplitterResize;
1442
+ exports.areParameterArraysEqual = areParameterArraysEqual;
1443
+ exports.areParametersEqual = areParametersEqual;
1444
+ exports.buildColumnDefsById = buildColumnDefsById;
1445
+ exports.clamp = clamp;
1446
+ exports.createRows = createRows;
1447
+ exports.fitColumnWidths = fitColumnWidths;
1448
+ exports.getDisplayValue = getDisplayValue;
1449
+ exports.getRightNeighborId = getRightNeighborId;
1450
+ exports.getVisibleColumns = getVisibleColumns;
1451
+ exports.reconcileRows = reconcileRows;
1452
+ exports.reorder = reorder;