@cadraos/sdk 0.3.14-p46.3 → 0.3.14-p46.4

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.
@@ -73,86 +73,8 @@ function collectDueRefs(lanes) {
73
73
  }
74
74
  return Array.from(byRef.values());
75
75
  }
76
- var DEFAULT_ORG_COLUMN = "org_id";
77
- function laneStageId(lane) {
78
- return lane.id ?? lane.key;
79
- }
80
- function suggestHostState(lane) {
81
- return lane.label ?? lane.key ?? "";
82
- }
83
- function freshFieldRow(ref, requiresPredicate) {
84
- return {
85
- ref,
86
- kind: requiresPredicate ? "predicate" : "column",
87
- column: "",
88
- path: "",
89
- via: "",
90
- table: "",
91
- name: "",
92
- predicateOnly: requiresPredicate
93
- };
94
- }
95
- function fieldRowFromBinding(b, requiresPredicate) {
96
- const base = freshFieldRow(b.ref, requiresPredicate);
97
- switch (b.kind) {
98
- case "column":
99
- return { ...base, kind: "column", column: b.column };
100
- case "json":
101
- return { ...base, kind: "json", column: b.column, path: b.path };
102
- case "fk":
103
- return { ...base, kind: "fk", via: b.via, table: b.table, column: b.column };
104
- case "predicate":
105
- return { ...base, kind: "predicate", name: b.name };
106
- default:
107
- return base;
108
- }
109
- }
110
- function fieldRowError(row) {
111
- switch (row.kind) {
112
- case "column":
113
- return identifierError(row.column) && `column ${identifierError(row.column)}`;
114
- case "json": {
115
- const colErr = identifierError(row.column);
116
- if (colErr) return `column ${colErr}`;
117
- if (!isValidJsonPath(row.path))
118
- return "path must be dot-separated identifiers";
119
- return null;
120
- }
121
- case "fk": {
122
- const viaErr = identifierError(row.via);
123
- if (viaErr) return `via ${viaErr}`;
124
- const tableErr = identifierError(row.table);
125
- if (tableErr) return `table ${tableErr}`;
126
- const colErr = identifierError(row.column);
127
- if (colErr) return `column ${colErr}`;
128
- return null;
129
- }
130
- case "predicate":
131
- return row.name.length === 0 ? "pick a predicate" : !isValidIdentifier(row.name) ? "predicate name must be a single identifier" : null;
132
- default:
133
- return "unknown kind";
134
- }
135
- }
136
- function rowToBinding(row) {
137
- switch (row.kind) {
138
- case "column":
139
- return { ref: row.ref, kind: "column", column: row.column };
140
- case "json":
141
- return { ref: row.ref, kind: "json", column: row.column, path: row.path };
142
- case "fk":
143
- return {
144
- ref: row.ref,
145
- kind: "fk",
146
- via: row.via,
147
- table: row.table,
148
- column: row.column
149
- };
150
- case "predicate":
151
- return { ref: row.ref, kind: "predicate", name: row.name };
152
- default:
153
- return { ref: row.ref, kind: "column", column: "" };
154
- }
155
- }
76
+
77
+ // src/board-host/widget/styles.ts
156
78
  var S = {
157
79
  card: {
158
80
  background: "#fff",
@@ -234,6 +156,200 @@ var S = {
234
156
  borderRadius: 999
235
157
  }
236
158
  };
159
+ function laneStageId(lane) {
160
+ return lane.id ?? lane.key;
161
+ }
162
+ function withStale(offered, extra) {
163
+ const known = new Set(offered.map((o) => o.value));
164
+ const stale = extra.filter((v) => v && !known.has(v)).map((v) => ({ value: v, label: `${v} (not on the board)` }));
165
+ return [...offered, ...stale];
166
+ }
167
+ function LaneMapStep({
168
+ lanes,
169
+ value,
170
+ onChange,
171
+ hostStates,
172
+ createIfMissing
173
+ }) {
174
+ function setEntry(key, entry) {
175
+ onChange({ ...value, [key]: entry });
176
+ }
177
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: lanes.map((lane) => {
178
+ const entry = value[lane.key];
179
+ const hostState = entry?.hostState ?? "";
180
+ const alsoFrom = entry?.alsoFrom ?? [];
181
+ const mapped = hostState.trim().length > 0;
182
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.lane, children: [
183
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
184
+ lane.label,
185
+ /* @__PURE__ */ jsxRuntime.jsx("small", { style: { display: "block", color: "#98a1ad", fontSize: 11 }, children: laneStageId(lane) })
186
+ ] }),
187
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#98a1ad", textAlign: "center" }, children: "\u2192" }),
188
+ hostStates ? /* @__PURE__ */ jsxRuntime.jsxs(
189
+ "select",
190
+ {
191
+ "aria-label": `Host state for ${lane.label}`,
192
+ value: hostState,
193
+ onChange: (e) => {
194
+ const next = e.target.value;
195
+ setEntry(lane.key, {
196
+ hostState: next,
197
+ alsoFrom: alsoFrom.filter((s) => s !== next)
198
+ });
199
+ },
200
+ style: { ...S.input, minWidth: 0, width: "100%" },
201
+ children: [
202
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "\u2014 host state \u2014" }),
203
+ withStale(hostStates, [hostState]).map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value))
204
+ ]
205
+ }
206
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
207
+ "input",
208
+ {
209
+ "aria-label": `Host state for ${lane.label}`,
210
+ value: hostState,
211
+ placeholder: "\u2014 host state \u2014",
212
+ onChange: (e) => {
213
+ setEntry(lane.key, { ...entry, hostState: e.target.value });
214
+ },
215
+ style: { ...S.input, minWidth: 0, width: "100%" }
216
+ }
217
+ ),
218
+ createIfMissing ? /* @__PURE__ */ jsxRuntime.jsxs(
219
+ "label",
220
+ {
221
+ style: { display: "flex", alignItems: "center", gap: 6, fontSize: 11.5, color: "#6b7480" },
222
+ children: [
223
+ /* @__PURE__ */ jsxRuntime.jsx(
224
+ "input",
225
+ {
226
+ type: "checkbox",
227
+ "aria-label": `Create lane ${lane.label} if missing`,
228
+ checked: createIfMissing.value[lane.key] ?? false,
229
+ onChange: (e) => createIfMissing.onChange(lane.key, e.target.checked)
230
+ }
231
+ ),
232
+ "create"
233
+ ]
234
+ }
235
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", {}),
236
+ hostStates && /* @__PURE__ */ jsxRuntime.jsxs(
237
+ "label",
238
+ {
239
+ style: {
240
+ gridColumn: "1 / -1",
241
+ display: "flex",
242
+ alignItems: "flex-start",
243
+ gap: 8,
244
+ fontSize: 11.5,
245
+ color: "#6b7480"
246
+ },
247
+ children: [
248
+ "Also accepts",
249
+ /* @__PURE__ */ jsxRuntime.jsx(
250
+ "select",
251
+ {
252
+ multiple: true,
253
+ "aria-label": `Also accepts for ${lane.label}`,
254
+ value: alsoFrom,
255
+ onChange: (e) => {
256
+ const picked = Array.from(e.target.options).filter((o) => o.selected).map((o) => o.value);
257
+ setEntry(lane.key, { hostState, alsoFrom: picked });
258
+ },
259
+ style: { ...S.input, minWidth: 0, flex: 1 },
260
+ children: withStale(hostStates, alsoFrom).filter((o) => o.value !== hostState).map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value))
261
+ }
262
+ )
263
+ ]
264
+ }
265
+ ),
266
+ /* @__PURE__ */ jsxRuntime.jsx(
267
+ "span",
268
+ {
269
+ style: { ...S.st, color: mapped ? "#16a34a" : "#c2710c", gridColumn: "1 / -1", marginTop: 2 },
270
+ children: mapped ? "\u2713 mapped" : "\u26A0 gap \u2014 unmapped lane"
271
+ }
272
+ )
273
+ ] }, lane.key);
274
+ }) });
275
+ }
276
+ var DEFAULT_ORG_COLUMN = "org_id";
277
+ function suggestHostState(lane) {
278
+ return lane.label ?? lane.key ?? "";
279
+ }
280
+ function freshFieldRow(ref, requiresPredicate) {
281
+ return {
282
+ ref,
283
+ kind: requiresPredicate ? "predicate" : "column",
284
+ column: "",
285
+ path: "",
286
+ via: "",
287
+ table: "",
288
+ name: "",
289
+ predicateOnly: requiresPredicate
290
+ };
291
+ }
292
+ function fieldRowFromBinding(b, requiresPredicate) {
293
+ const base = freshFieldRow(b.ref, requiresPredicate);
294
+ switch (b.kind) {
295
+ case "column":
296
+ return { ...base, kind: "column", column: b.column };
297
+ case "json":
298
+ return { ...base, kind: "json", column: b.column, path: b.path };
299
+ case "fk":
300
+ return { ...base, kind: "fk", via: b.via, table: b.table, column: b.column };
301
+ case "predicate":
302
+ return { ...base, kind: "predicate", name: b.name };
303
+ default:
304
+ return base;
305
+ }
306
+ }
307
+ function fieldRowError(row) {
308
+ switch (row.kind) {
309
+ case "column":
310
+ return identifierError(row.column) && `column ${identifierError(row.column)}`;
311
+ case "json": {
312
+ const colErr = identifierError(row.column);
313
+ if (colErr) return `column ${colErr}`;
314
+ if (!isValidJsonPath(row.path))
315
+ return "path must be dot-separated identifiers";
316
+ return null;
317
+ }
318
+ case "fk": {
319
+ const viaErr = identifierError(row.via);
320
+ if (viaErr) return `via ${viaErr}`;
321
+ const tableErr = identifierError(row.table);
322
+ if (tableErr) return `table ${tableErr}`;
323
+ const colErr = identifierError(row.column);
324
+ if (colErr) return `column ${colErr}`;
325
+ return null;
326
+ }
327
+ case "predicate":
328
+ return row.name.length === 0 ? "pick a predicate" : !isValidIdentifier(row.name) ? "predicate name must be a single identifier" : null;
329
+ default:
330
+ return "unknown kind";
331
+ }
332
+ }
333
+ function rowToBinding(row) {
334
+ switch (row.kind) {
335
+ case "column":
336
+ return { ref: row.ref, kind: "column", column: row.column };
337
+ case "json":
338
+ return { ref: row.ref, kind: "json", column: row.column, path: row.path };
339
+ case "fk":
340
+ return {
341
+ ref: row.ref,
342
+ kind: "fk",
343
+ via: row.via,
344
+ table: row.table,
345
+ column: row.column
346
+ };
347
+ case "predicate":
348
+ return { ref: row.ref, kind: "predicate", name: row.name };
349
+ default:
350
+ return { ref: row.ref, kind: "column", column: "" };
351
+ }
352
+ }
237
353
  function statusColors(status) {
238
354
  switch (status) {
239
355
  case "valid":
@@ -592,57 +708,28 @@ function BoardHostMapping({
592
708
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: S.ttl, children: "Lane map" }),
593
709
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: { marginLeft: "auto", fontSize: 11, color: "#98a1ad" }, children: "auto-matched by name" })
594
710
  ] }),
595
- lanes.map((lane) => {
596
- const mapped = (laneStates[lane.key] ?? "").trim().length > 0;
597
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.lane, children: [
598
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
599
- lane.label,
600
- /* @__PURE__ */ jsxRuntime.jsx("small", { style: { display: "block", color: "#98a1ad", fontSize: 11 }, children: laneStageId(lane) })
601
- ] }),
602
- /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#98a1ad", textAlign: "center" }, children: "\u2192" }),
603
- /* @__PURE__ */ jsxRuntime.jsx(
604
- "input",
605
- {
606
- "aria-label": `Host state for ${lane.label}`,
607
- value: laneStates[lane.key] ?? "",
608
- placeholder: "\u2014 host state \u2014",
609
- onChange: (e) => {
610
- setLaneStates((s) => ({ ...s, [lane.key]: e.target.value }));
611
- setValidation(null);
612
- },
613
- style: { ...S.input, minWidth: 0, width: "100%" }
614
- }
615
- ),
616
- /* @__PURE__ */ jsxRuntime.jsxs(
617
- "label",
618
- {
619
- style: { display: "flex", alignItems: "center", gap: 6, fontSize: 11.5, color: "#6b7480" },
620
- children: [
621
- /* @__PURE__ */ jsxRuntime.jsx(
622
- "input",
623
- {
624
- type: "checkbox",
625
- "aria-label": `Create lane ${lane.label} if missing`,
626
- checked: laneCreate[lane.key] ?? false,
627
- onChange: (e) => {
628
- setLaneCreate((c) => ({ ...c, [lane.key]: e.target.checked }));
629
- setValidation(null);
630
- }
631
- }
632
- ),
633
- "create"
634
- ]
635
- }
711
+ /* @__PURE__ */ jsxRuntime.jsx(
712
+ LaneMapStep,
713
+ {
714
+ lanes,
715
+ value: Object.fromEntries(
716
+ Object.entries(laneStates).map(([k, hostState]) => [k, { hostState }])
636
717
  ),
637
- /* @__PURE__ */ jsxRuntime.jsx(
638
- "span",
639
- {
640
- style: { ...S.st, color: mapped ? "#16a34a" : "#c2710c", gridColumn: "1 / -1", marginTop: 2 },
641
- children: mapped ? "\u2713 mapped" : "\u26A0 gap \u2014 unmapped lane"
718
+ onChange: (next) => {
719
+ setLaneStates(
720
+ Object.fromEntries(Object.entries(next).map(([k, e]) => [k, e.hostState]))
721
+ );
722
+ setValidation(null);
723
+ },
724
+ createIfMissing: {
725
+ value: laneCreate,
726
+ onChange: (key, checked) => {
727
+ setLaneCreate((c) => ({ ...c, [key]: checked }));
728
+ setValidation(null);
642
729
  }
643
- )
644
- ] }, lane.key);
645
- })
730
+ }
731
+ }
732
+ )
646
733
  ] }),
647
734
  /* @__PURE__ */ jsxRuntime.jsxs("section", { style: S.sec, "aria-label": "Field map", children: [
648
735
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.lbl, children: [
@@ -819,6 +906,7 @@ function BoardHostMapping({
819
906
 
820
907
  exports.BoardHostMapping = BoardHostMapping;
821
908
  exports.BoardHostMappingProvider = BoardHostMappingProvider;
909
+ exports.LaneMapStep = LaneMapStep;
822
910
  exports.WIDGET_IDENTIFIER_PATTERN = WIDGET_IDENTIFIER_PATTERN;
823
911
  exports.collectDueRefs = collectDueRefs;
824
912
  exports.identifierError = identifierError;