@flanksource/clicky-ui 0.3.84 → 0.3.85

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 (219) hide show
  1. package/dist/components/Combobox.cjs +8 -6
  2. package/dist/components/Combobox.cjs.map +1 -1
  3. package/dist/components/Combobox.d.ts.map +1 -1
  4. package/dist/components/Combobox.js +8 -6
  5. package/dist/components/Combobox.js.map +1 -1
  6. package/dist/components/ComboboxMenu.cjs +7 -4
  7. package/dist/components/ComboboxMenu.cjs.map +1 -1
  8. package/dist/components/ComboboxMenu.d.ts +3 -2
  9. package/dist/components/ComboboxMenu.d.ts.map +1 -1
  10. package/dist/components/ComboboxMenu.js +7 -4
  11. package/dist/components/ComboboxMenu.js.map +1 -1
  12. package/dist/components/FilterBar.cjs +64 -47
  13. package/dist/components/FilterBar.cjs.map +1 -1
  14. package/dist/components/FilterBar.d.ts +20 -2
  15. package/dist/components/FilterBar.d.ts.map +1 -1
  16. package/dist/components/FilterBar.js +63 -46
  17. package/dist/components/FilterBar.js.map +1 -1
  18. package/dist/components/TimeRange.cjs +156 -128
  19. package/dist/components/TimeRange.cjs.map +1 -1
  20. package/dist/components/TimeRange.d.ts +8 -1
  21. package/dist/components/TimeRange.d.ts.map +1 -1
  22. package/dist/components/TimeRange.js +156 -128
  23. package/dist/components/TimeRange.js.map +1 -1
  24. package/dist/components/combobox-types.d.ts +5 -0
  25. package/dist/components/combobox-types.d.ts.map +1 -1
  26. package/dist/components/filter-bar-context.cjs.map +1 -1
  27. package/dist/components/filter-bar-context.d.ts +2 -0
  28. package/dist/components/filter-bar-context.d.ts.map +1 -1
  29. package/dist/components/filter-bar-context.js.map +1 -1
  30. package/dist/components/filter-bar-field-utils.cjs +18 -4
  31. package/dist/components/filter-bar-field-utils.cjs.map +1 -1
  32. package/dist/components/filter-bar-field-utils.d.ts +3 -2
  33. package/dist/components/filter-bar-field-utils.d.ts.map +1 -1
  34. package/dist/components/filter-bar-field-utils.js +19 -5
  35. package/dist/components/filter-bar-field-utils.js.map +1 -1
  36. package/dist/components/filter-bar-menu.cjs +189 -0
  37. package/dist/components/filter-bar-menu.cjs.map +1 -0
  38. package/dist/components/filter-bar-menu.d.ts +25 -0
  39. package/dist/components/filter-bar-menu.d.ts.map +1 -0
  40. package/dist/components/filter-bar-menu.js +189 -0
  41. package/dist/components/filter-bar-menu.js.map +1 -0
  42. package/dist/components/filter-bar-multi.cjs +1 -1
  43. package/dist/components/filter-bar-multi.cjs.map +1 -1
  44. package/dist/components/filter-bar-multi.js +2 -2
  45. package/dist/components/filter-bar-multi.js.map +1 -1
  46. package/dist/components/filter-bar-popup.cjs +37 -0
  47. package/dist/components/filter-bar-popup.cjs.map +1 -0
  48. package/dist/components/filter-bar-popup.d.ts +32 -0
  49. package/dist/components/filter-bar-popup.d.ts.map +1 -0
  50. package/dist/components/filter-bar-popup.js +37 -0
  51. package/dist/components/filter-bar-popup.js.map +1 -0
  52. package/dist/components/filter-bar-tree.cjs +1 -1
  53. package/dist/components/filter-bar-tree.cjs.map +1 -1
  54. package/dist/components/filter-bar-tree.js +2 -2
  55. package/dist/components/filter-bar-tree.js.map +1 -1
  56. package/dist/components/json-schema-form-table-array.cjs +5 -3
  57. package/dist/components/json-schema-form-table-array.cjs.map +1 -1
  58. package/dist/components/json-schema-form-table-array.d.ts.map +1 -1
  59. package/dist/components/json-schema-form-table-array.js +5 -3
  60. package/dist/components/json-schema-form-table-array.js.map +1 -1
  61. package/dist/components.cjs +1 -1
  62. package/dist/components.js +1 -1
  63. package/dist/connections/ConnectionPicker.cjs +6 -2
  64. package/dist/connections/ConnectionPicker.cjs.map +1 -1
  65. package/dist/connections/ConnectionPicker.d.ts.map +1 -1
  66. package/dist/connections/ConnectionPicker.js +6 -2
  67. package/dist/connections/ConnectionPicker.js.map +1 -1
  68. package/dist/connections/CreateConnectionDialog.cjs +8 -21
  69. package/dist/connections/CreateConnectionDialog.cjs.map +1 -1
  70. package/dist/connections/CreateConnectionDialog.d.ts +2 -1
  71. package/dist/connections/CreateConnectionDialog.d.ts.map +1 -1
  72. package/dist/connections/CreateConnectionDialog.js +8 -21
  73. package/dist/connections/CreateConnectionDialog.js.map +1 -1
  74. package/dist/data/ExpandableMarkdown.cjs +59 -0
  75. package/dist/data/ExpandableMarkdown.cjs.map +1 -0
  76. package/dist/data/ExpandableMarkdown.d.ts +17 -0
  77. package/dist/data/ExpandableMarkdown.d.ts.map +1 -0
  78. package/dist/data/ExpandableMarkdown.js +59 -0
  79. package/dist/data/ExpandableMarkdown.js.map +1 -0
  80. package/dist/data/MultiGaugeBar.cjs +49 -21
  81. package/dist/data/MultiGaugeBar.cjs.map +1 -1
  82. package/dist/data/MultiGaugeBar.d.ts +5 -2
  83. package/dist/data/MultiGaugeBar.d.ts.map +1 -1
  84. package/dist/data/MultiGaugeBar.js +49 -21
  85. package/dist/data/MultiGaugeBar.js.map +1 -1
  86. package/dist/data/flow-node/BoxNode.cjs +45 -0
  87. package/dist/data/flow-node/BoxNode.cjs.map +1 -0
  88. package/dist/data/flow-node/BoxNode.d.ts +28 -0
  89. package/dist/data/flow-node/BoxNode.d.ts.map +1 -0
  90. package/dist/data/flow-node/BoxNode.js +45 -0
  91. package/dist/data/flow-node/BoxNode.js.map +1 -0
  92. package/dist/data/flow-node/FlowMetrics.cjs +208 -0
  93. package/dist/data/flow-node/FlowMetrics.cjs.map +1 -0
  94. package/dist/data/flow-node/FlowMetrics.d.ts +60 -0
  95. package/dist/data/flow-node/FlowMetrics.d.ts.map +1 -0
  96. package/dist/data/flow-node/FlowMetrics.js +206 -0
  97. package/dist/data/flow-node/FlowMetrics.js.map +1 -0
  98. package/dist/data/flow-node/WorkloadNode.cjs +63 -0
  99. package/dist/data/flow-node/WorkloadNode.cjs.map +1 -0
  100. package/dist/data/flow-node/WorkloadNode.d.ts +42 -0
  101. package/dist/data/flow-node/WorkloadNode.d.ts.map +1 -0
  102. package/dist/data/flow-node/WorkloadNode.js +63 -0
  103. package/dist/data/flow-node/WorkloadNode.js.map +1 -0
  104. package/dist/data/flow-node/index.d.ts +5 -0
  105. package/dist/data/flow-node/index.d.ts.map +1 -0
  106. package/dist/data/flow-node/latency.cjs +37 -0
  107. package/dist/data/flow-node/latency.cjs.map +1 -0
  108. package/dist/data/flow-node/latency.d.ts +13 -0
  109. package/dist/data/flow-node/latency.d.ts.map +1 -0
  110. package/dist/data/flow-node/latency.js +35 -0
  111. package/dist/data/flow-node/latency.js.map +1 -0
  112. package/dist/data/traces/index.d.ts +1 -0
  113. package/dist/data/traces/index.d.ts.map +1 -1
  114. package/dist/data/traces/otel/OtelTraceDetail.cjs +4 -7
  115. package/dist/data/traces/otel/OtelTraceDetail.cjs.map +1 -1
  116. package/dist/data/traces/otel/OtelTraceDetail.js +4 -7
  117. package/dist/data/traces/otel/OtelTraceDetail.js.map +1 -1
  118. package/dist/data/traces/otel/OtelTraceSearch.cjs +90 -56
  119. package/dist/data/traces/otel/OtelTraceSearch.cjs.map +1 -1
  120. package/dist/data/traces/otel/OtelTraceSearch.d.ts.map +1 -1
  121. package/dist/data/traces/otel/OtelTraceSearch.js +91 -57
  122. package/dist/data/traces/otel/OtelTraceSearch.js.map +1 -1
  123. package/dist/data/traces/otel/QueryBar.cjs +83 -10
  124. package/dist/data/traces/otel/QueryBar.cjs.map +1 -1
  125. package/dist/data/traces/otel/QueryBar.d.ts.map +1 -1
  126. package/dist/data/traces/otel/QueryBar.js +83 -10
  127. package/dist/data/traces/otel/QueryBar.js.map +1 -1
  128. package/dist/data/traces/otel/TraceResults.cjs +81 -13
  129. package/dist/data/traces/otel/TraceResults.cjs.map +1 -1
  130. package/dist/data/traces/otel/TraceResults.d.ts +11 -3
  131. package/dist/data/traces/otel/TraceResults.d.ts.map +1 -1
  132. package/dist/data/traces/otel/TraceResults.js +81 -13
  133. package/dist/data/traces/otel/TraceResults.js.map +1 -1
  134. package/dist/data/traces/otel/api.cjs.map +1 -1
  135. package/dist/data/traces/otel/api.d.ts +14 -0
  136. package/dist/data/traces/otel/api.d.ts.map +1 -1
  137. package/dist/data/traces/otel/api.js.map +1 -1
  138. package/dist/data/traces/otel/query.cjs +2 -2
  139. package/dist/data/traces/otel/query.cjs.map +1 -1
  140. package/dist/data/traces/otel/query.d.ts +1 -1
  141. package/dist/data/traces/otel/query.d.ts.map +1 -1
  142. package/dist/data/traces/otel/query.js +2 -2
  143. package/dist/data/traces/otel/query.js.map +1 -1
  144. package/dist/data/version-info.cjs +3 -3
  145. package/dist/data/version-info.cjs.map +1 -1
  146. package/dist/data/version-info.js +3 -3
  147. package/dist/data/version-info.js.map +1 -1
  148. package/dist/data/workload-panel/MemoryStack.cjs +38 -1
  149. package/dist/data/workload-panel/MemoryStack.cjs.map +1 -1
  150. package/dist/data/workload-panel/MemoryStack.d.ts.map +1 -1
  151. package/dist/data/workload-panel/MemoryStack.js +38 -1
  152. package/dist/data/workload-panel/MemoryStack.js.map +1 -1
  153. package/dist/data.cjs +18 -1
  154. package/dist/data.d.ts +2 -0
  155. package/dist/data.d.ts.map +1 -1
  156. package/dist/data.js +8 -2
  157. package/dist/file-findings/AnnotatedCode.cjs +18 -2
  158. package/dist/file-findings/AnnotatedCode.cjs.map +1 -1
  159. package/dist/file-findings/AnnotatedCode.d.ts +2 -0
  160. package/dist/file-findings/AnnotatedCode.d.ts.map +1 -1
  161. package/dist/file-findings/AnnotatedCode.js +18 -2
  162. package/dist/file-findings/AnnotatedCode.js.map +1 -1
  163. package/dist/file-findings/FileFindingsView.cjs.map +1 -1
  164. package/dist/file-findings/FileFindingsView.d.ts +2 -0
  165. package/dist/file-findings/FileFindingsView.d.ts.map +1 -1
  166. package/dist/file-findings/FileFindingsView.js.map +1 -1
  167. package/dist/file-findings/file-review/FileReview.cjs +2 -1
  168. package/dist/file-findings/file-review/FileReview.cjs.map +1 -1
  169. package/dist/file-findings/file-review/FileReview.d.ts +3 -1
  170. package/dist/file-findings/file-review/FileReview.d.ts.map +1 -1
  171. package/dist/file-findings/file-review/FileReview.js +2 -1
  172. package/dist/file-findings/file-review/FileReview.js.map +1 -1
  173. package/dist/index.cjs +18 -1
  174. package/dist/index.js +8 -2
  175. package/dist/profiles/editor/profileEditor.cjs +29 -30
  176. package/dist/profiles/editor/profileEditor.cjs.map +1 -1
  177. package/dist/profiles/editor/profileEditor.d.ts.map +1 -1
  178. package/dist/profiles/editor/profileEditor.js +29 -30
  179. package/dist/profiles/editor/profileEditor.js.map +1 -1
  180. package/dist/profiles/editor/profileEditorPreview.cjs +44 -43
  181. package/dist/profiles/editor/profileEditorPreview.cjs.map +1 -1
  182. package/dist/profiles/editor/profileEditorPreview.d.ts +10 -5
  183. package/dist/profiles/editor/profileEditorPreview.d.ts.map +1 -1
  184. package/dist/profiles/editor/profileEditorPreview.js +44 -43
  185. package/dist/profiles/editor/profileEditorPreview.js.map +1 -1
  186. package/dist/profiles/editor/profileMappingPreview.cjs +153 -48
  187. package/dist/profiles/editor/profileMappingPreview.cjs.map +1 -1
  188. package/dist/profiles/editor/profileMappingPreview.d.ts +16 -2
  189. package/dist/profiles/editor/profileMappingPreview.d.ts.map +1 -1
  190. package/dist/profiles/editor/profileMappingPreview.js +155 -50
  191. package/dist/profiles/editor/profileMappingPreview.js.map +1 -1
  192. package/dist/profiles/editor/sampleError.cjs +29 -0
  193. package/dist/profiles/editor/sampleError.cjs.map +1 -0
  194. package/dist/profiles/editor/sampleError.d.ts +16 -0
  195. package/dist/profiles/editor/sampleError.d.ts.map +1 -0
  196. package/dist/profiles/editor/sampleError.js +27 -0
  197. package/dist/profiles/editor/sampleError.js.map +1 -0
  198. package/dist/profiles/query/profileSampleResult.cjs.map +1 -1
  199. package/dist/profiles/query/profileSampleResult.d.ts +2 -0
  200. package/dist/profiles/query/profileSampleResult.d.ts.map +1 -1
  201. package/dist/profiles/query/profileSampleResult.js.map +1 -1
  202. package/dist/profiles/wizard/profileWizardQueryStep.cjs +1 -0
  203. package/dist/profiles/wizard/profileWizardQueryStep.cjs.map +1 -1
  204. package/dist/profiles/wizard/profileWizardQueryStep.d.ts +2 -0
  205. package/dist/profiles/wizard/profileWizardQueryStep.d.ts.map +1 -1
  206. package/dist/profiles/wizard/profileWizardQueryStep.js +1 -0
  207. package/dist/profiles/wizard/profileWizardQueryStep.js.map +1 -1
  208. package/dist/react-grab/core/index.js +1 -1
  209. package/dist/react-grab/{core-BERtFDWh.js → core-BK5CU6Lb.js} +2 -2
  210. package/dist/react-grab/index.js +1 -1
  211. package/dist/react-grab/{renderer-KT3FY3K2.js → renderer-DcHrsQ8k.js} +1 -1
  212. package/dist/rpc/apiClient.cjs +12 -15
  213. package/dist/rpc/apiClient.cjs.map +1 -1
  214. package/dist/rpc/apiClient.js +12 -15
  215. package/dist/rpc/apiClient.js.map +1 -1
  216. package/dist/runtime/barrels.json +6481 -6441
  217. package/dist/runtime/importmap.json +2198 -2190
  218. package/dist/styles.css +1 -1
  219. package/package.json +1 -1
@@ -2,7 +2,7 @@ import { FilterPill } from "../data/FilterPill.js";
2
2
  import { Icon } from "../data/Icon.js";
3
3
  import { UiChevronDown } from "../icons/components/UiChevronDown.js";
4
4
  import { cn } from "../lib/utils.js";
5
- import { comboboxLabelProps, lookupFieldWidthClass, nextFilterMode, updateMultiFilterValue, useDebouncedMultiDraft } from "./filter-bar-field-utils.js";
5
+ import { lookupFieldWidthClass, nextFilterMode, updateMultiFilterValue, useComboboxLabelProps, useDebouncedMultiDraft } from "./filter-bar-field-utils.js";
6
6
  import { hasSelectedDescendant, treeSelectionSummary } from "./filter-bar-tree-model.js";
7
7
  import { inputSizeClass } from "./json-schema-form-size.js";
8
8
  import { TreePickerField } from "./TreePickerField.js";
@@ -13,7 +13,7 @@ var isFolder = (node) => (node.children?.length ?? 0) > 0;
13
13
  function TreeFilterField({ filter, grow }) {
14
14
  const [draft, setDraft] = useDebouncedMultiDraft(filter.value, filter.onChange);
15
15
  const summary = useMemo(() => treeSelectionSummary(filter.nodes, draft), [filter.nodes, draft]);
16
- const { label, ariaLabel } = comboboxLabelProps(filter);
16
+ const { label, ariaLabel } = useComboboxLabelProps(filter);
17
17
  const setMode = (key, mode) => setDraft(updateMultiFilterValue(draft, key, mode));
18
18
  return /* @__PURE__ */ jsx(TreePickerField, {
19
19
  roots: filter.nodes,
@@ -1 +1 @@
1
- {"version":3,"file":"filter-bar-tree.js","names":[],"sources":["../../src/components/filter-bar-tree.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { FilterPill, type FilterMode } from \"../data/FilterPill\";\nimport { Icon } from \"../data/Icon\";\nimport { UiChevronDown } from \"../icons\";\nimport { cn } from \"../lib/utils\";\nimport {\n comboboxLabelProps,\n lookupFieldWidthClass,\n nextFilterMode,\n updateMultiFilterValue,\n useDebouncedMultiDraft,\n} from \"./filter-bar-field-utils\";\nimport {\n hasSelectedDescendant,\n treeSelectionSummary,\n type FilterBarTreeFilter,\n type FilterTreeNode,\n} from \"./filter-bar-tree-model\";\nimport { inputSizeClass } from \"./json-schema-form-size\";\nimport { TreePickerField } from \"./TreePickerField\";\n\nexport type { FilterBarTreeFilter, FilterTreeNode };\n\nconst isFolder = (node: FilterTreeNode) => (node.children?.length ?? 0) > 0;\n\n// TreeFilterField renders a \"tree\" filter as the same inline-labelled field the\n// lookup comboboxes use, opening a TreePickerField whose every row (folder or\n// leaf) carries the include/exclude/neutral switch of the \"multi\" kind. The\n// panel stays open across selections, and opens already expanded down to\n// whatever is selected. Clicking a folder row only expands it; clicking a leaf\n// row cycles neutral, include, exclude.\nexport function TreeFilterField({\n filter,\n grow,\n}: {\n filter: FilterBarTreeFilter;\n grow: boolean;\n}) {\n const [draft, setDraft] = useDebouncedMultiDraft(filter.value, filter.onChange);\n const summary = useMemo(\n () => treeSelectionSummary(filter.nodes, draft),\n [filter.nodes, draft],\n );\n const { label, ariaLabel } = comboboxLabelProps(filter);\n const setMode = (key: string, mode: FilterMode) =>\n setDraft(updateMultiFilterValue(draft, key, mode));\n\n return (\n <TreePickerField<FilterTreeNode>\n roots={filter.nodes}\n getKey={(node) => node.key}\n getChildren={(node) => node.children}\n getSearchText={(node) => [node.label, node.key, node.description].filter(Boolean).join(\" \")}\n defaultOpen={(node) => hasSelectedDescendant(node, draft)}\n isSelectable={(node) => !isFolder(node)}\n onSelect={(node) => setMode(node.key, nextFilterMode(draft[node.key] ?? \"neutral\"))}\n closeOnSelect={false}\n ariaLabel={filter.label}\n size=\"sm\"\n {...(filter.disabled !== undefined ? { disabled: filter.disabled } : {})}\n className={cn(lookupFieldWidthClass(grow), filter.className)}\n renderTrigger={({ open, disabled, triggerRef, toggle }) => (\n <button\n ref={triggerRef}\n type=\"button\"\n disabled={disabled}\n aria-label={ariaLabel ?? filter.label}\n aria-haspopup=\"tree\"\n aria-expanded={open}\n title={summary || filter.description}\n onClick={toggle}\n className={cn(\n \"relative flex w-full items-center gap-1.5 rounded-md border border-input bg-background pr-8 text-left text-foreground\",\n inputSizeClass.sm,\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1\",\n \"disabled:cursor-not-allowed disabled:opacity-50\",\n )}\n >\n <span className=\"shrink-0 whitespace-nowrap text-[10px] font-medium uppercase tracking-wide text-muted-foreground\">\n {label}\n </span>\n <span className={cn(\"min-w-0 flex-1 truncate\", !summary && \"text-placeholder\")}>\n {summary || filter.placeholder}\n </span>\n <span className=\"pointer-events-none absolute right-0 flex h-full items-center px-2 text-muted-foreground\">\n <Icon icon={UiChevronDown} className=\"text-xs\" />\n </span>\n </button>\n )}\n renderRow={({ node }) => (\n <FilterPill\n className=\"min-w-0 flex-1 justify-between\"\n togglePosition=\"right\"\n mode={draft[node.key] ?? \"neutral\"}\n title={node.label}\n label={\n <span className=\"block min-w-0 text-left\">\n <span className=\"block truncate\">{node.label}</span>\n {node.description && (\n <span className=\"mt-0.5 block truncate text-xs font-normal text-muted-foreground\">\n {node.description}\n </span>\n )}\n </span>\n }\n onModeChange={(next) => setMode(node.key, next)}\n />\n )}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;AAuBA,IAAM,YAAY,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;IACN,oBAAC,QAAD;KAAM,WAAU;KACd,UAAA,oBAAC,MAAD;MAAM,MAAM;MAAe,WAAU;KAAW,CAAA;IAC5C,CAAA;GACA;;EAEV,YAAY,EAAE,WACZ,oBAAC,YAAD;GACE,WAAU;GACV,gBAAe;GACf,MAAM,MAAM,KAAK,QAAQ;GACzB,OAAO,KAAK;GACZ,OACE,qBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CACE,oBAAC,QAAD;KAAM,WAAU;KAAkB,UAAA,KAAK;IAAY,CAAA,GAClD,KAAK,eACJ,oBAAC,QAAD;KAAM,WAAU;KACb,UAAA,KAAK;IACF,CAAA,CAEJ;;GAER,eAAe,SAAS,QAAQ,KAAK,KAAK,IAAI;EAC/C,CAAA;CAEJ,CAAA;AAEL"}
1
+ {"version":3,"file":"filter-bar-tree.js","names":[],"sources":["../../src/components/filter-bar-tree.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { FilterPill, type FilterMode } from \"../data/FilterPill\";\nimport { Icon } from \"../data/Icon\";\nimport { UiChevronDown } from \"../icons\";\nimport { cn } from \"../lib/utils\";\nimport {\n lookupFieldWidthClass,\n nextFilterMode,\n updateMultiFilterValue,\n useComboboxLabelProps,\n useDebouncedMultiDraft,\n} from \"./filter-bar-field-utils\";\nimport {\n hasSelectedDescendant,\n treeSelectionSummary,\n type FilterBarTreeFilter,\n type FilterTreeNode,\n} from \"./filter-bar-tree-model\";\nimport { inputSizeClass } from \"./json-schema-form-size\";\nimport { TreePickerField } from \"./TreePickerField\";\n\nexport type { FilterBarTreeFilter, FilterTreeNode };\n\nconst isFolder = (node: FilterTreeNode) => (node.children?.length ?? 0) > 0;\n\n// TreeFilterField renders a \"tree\" filter as the same inline-labelled field the\n// lookup comboboxes use, opening a TreePickerField whose every row (folder or\n// leaf) carries the include/exclude/neutral switch of the \"multi\" kind. The\n// panel stays open across selections, and opens already expanded down to\n// whatever is selected. Clicking a folder row only expands it; clicking a leaf\n// row cycles neutral, include, exclude.\nexport function TreeFilterField({\n filter,\n grow,\n}: {\n filter: FilterBarTreeFilter;\n grow: boolean;\n}) {\n const [draft, setDraft] = useDebouncedMultiDraft(filter.value, filter.onChange);\n const summary = useMemo(\n () => treeSelectionSummary(filter.nodes, draft),\n [filter.nodes, draft],\n );\n const { label, ariaLabel } = useComboboxLabelProps(filter);\n const setMode = (key: string, mode: FilterMode) =>\n setDraft(updateMultiFilterValue(draft, key, mode));\n\n return (\n <TreePickerField<FilterTreeNode>\n roots={filter.nodes}\n getKey={(node) => node.key}\n getChildren={(node) => node.children}\n getSearchText={(node) => [node.label, node.key, node.description].filter(Boolean).join(\" \")}\n defaultOpen={(node) => hasSelectedDescendant(node, draft)}\n isSelectable={(node) => !isFolder(node)}\n onSelect={(node) => setMode(node.key, nextFilterMode(draft[node.key] ?? \"neutral\"))}\n closeOnSelect={false}\n ariaLabel={filter.label}\n size=\"sm\"\n {...(filter.disabled !== undefined ? { disabled: filter.disabled } : {})}\n className={cn(lookupFieldWidthClass(grow), filter.className)}\n renderTrigger={({ open, disabled, triggerRef, toggle }) => (\n <button\n ref={triggerRef}\n type=\"button\"\n disabled={disabled}\n aria-label={ariaLabel ?? filter.label}\n aria-haspopup=\"tree\"\n aria-expanded={open}\n title={summary || filter.description}\n onClick={toggle}\n className={cn(\n \"relative flex w-full items-center gap-1.5 rounded-md border border-input bg-background pr-8 text-left text-foreground\",\n inputSizeClass.sm,\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1\",\n \"disabled:cursor-not-allowed disabled:opacity-50\",\n )}\n >\n <span className=\"shrink-0 whitespace-nowrap text-[10px] font-medium uppercase tracking-wide text-muted-foreground\">\n {label}\n </span>\n <span className={cn(\"min-w-0 flex-1 truncate\", !summary && \"text-placeholder\")}>\n {summary || filter.placeholder}\n </span>\n <span className=\"pointer-events-none absolute right-0 flex h-full items-center px-2 text-muted-foreground\">\n <Icon icon={UiChevronDown} className=\"text-xs\" />\n </span>\n </button>\n )}\n renderRow={({ node }) => (\n <FilterPill\n className=\"min-w-0 flex-1 justify-between\"\n togglePosition=\"right\"\n mode={draft[node.key] ?? \"neutral\"}\n title={node.label}\n label={\n <span className=\"block min-w-0 text-left\">\n <span className=\"block truncate\">{node.label}</span>\n {node.description && (\n <span className=\"mt-0.5 block truncate text-xs font-normal text-muted-foreground\">\n {node.description}\n </span>\n )}\n </span>\n }\n onModeChange={(next) => setMode(node.key, next)}\n />\n )}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;AAuBA,IAAM,YAAY,UAA0B,KAAK,UAAU,UAAU,KAAK;AAQ1E,SAAgB,gBAAgB,EAC9B,QACA,QAIC;CACD,MAAM,CAAC,OAAO,YAAY,uBAAuB,OAAO,OAAO,OAAO,QAAQ;CAC9E,MAAM,UAAU,cACR,qBAAqB,OAAO,OAAO,KAAK,GAC9C,CAAC,OAAO,OAAO,KAAK,CACtB;CACA,MAAM,EAAE,OAAO,cAAc,sBAAsB,MAAM;CACzD,MAAM,WAAW,KAAa,SAC5B,SAAS,uBAAuB,OAAO,KAAK,IAAI,CAAC;CAEnD,OACE,oBAAC,iBAAD;EACE,OAAO,OAAO;EACd,SAAS,SAAS,KAAK;EACvB,cAAc,SAAS,KAAK;EAC5B,gBAAgB,SAAS;GAAC,KAAK;GAAO,KAAK;GAAK,KAAK;EAAW,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EAC1F,cAAc,SAAS,sBAAsB,MAAM,KAAK;EACxD,eAAe,SAAS,CAAC,SAAS,IAAI;EACtC,WAAW,SAAS,QAAQ,KAAK,KAAK,eAAe,MAAM,KAAK,QAAQ,SAAS,CAAC;EAClF,eAAe;EACf,WAAW,OAAO;EAClB,MAAK;EACL,GAAK,OAAO,aAAa,KAAA,IAAY,EAAE,UAAU,OAAO,SAAS,IAAI,CAAC;EACtE,WAAW,GAAG,sBAAsB,IAAI,GAAG,OAAO,SAAS;EAC3D,gBAAgB,EAAE,MAAM,UAAU,YAAY,aAC5C,qBAAC,UAAD;GACE,KAAK;GACL,MAAK;GACK;GACV,cAAY,aAAa,OAAO;GAChC,iBAAc;GACd,iBAAe;GACf,OAAO,WAAW,OAAO;GACzB,SAAS;GACT,WAAW,GACT,yHACA,eAAe,IACf,uGACA,iDACF;GAdF,UAAA;IAgBE,oBAAC,QAAD;KAAM,WAAU;KACb,UAAA;IACG,CAAA;IACN,oBAAC,QAAD;KAAM,WAAW,GAAG,2BAA2B,CAAC,WAAW,kBAAkB;KAC1E,UAAA,WAAW,OAAO;IACf,CAAA;IACN,oBAAC,QAAD;KAAM,WAAU;KACd,UAAA,oBAAC,MAAD;MAAM,MAAM;MAAe,WAAU;KAAW,CAAA;IAC5C,CAAA;GACA;;EAEV,YAAY,EAAE,WACZ,oBAAC,YAAD;GACE,WAAU;GACV,gBAAe;GACf,MAAM,MAAM,KAAK,QAAQ;GACzB,OAAO,KAAK;GACZ,OACE,qBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CACE,oBAAC,QAAD;KAAM,WAAU;KAAkB,UAAA,KAAK;IAAY,CAAA,GAClD,KAAK,eACJ,oBAAC,QAAD;KAAM,WAAU;KACb,UAAA,KAAK;IACF,CAAA,CAEJ;;GAER,eAAe,SAAS,QAAQ,KAAK,KAAK,IAAI;EAC/C,CAAA;CAEJ,CAAA;AAEL"}
@@ -64,8 +64,10 @@ function TableArray({ field, ctx, readOnly, toolbar }) {
64
64
  "aria-hidden": "true",
65
65
  className: require_utils.cn("block", require_json_schema_form_size.controlMinHeightClass[ctx.size])
66
66
  });
67
- return ctx.presentation ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
68
- className: require_utils.cn("flex min-w-0 items-center [overflow-wrap:anywhere] [&_span[data-jsf-readonly]]:h-auto [&_span[data-jsf-readonly]]:min-w-0", require_json_schema_form_size.controlMinHeightClass[ctx.size]),
67
+ const valueCell = valueCells || prop?.readOnly === true;
68
+ return ctx.presentation || valueCell ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
69
+ "data-jsf-value-cell": "",
70
+ className: require_utils.cn("flex min-w-0 items-center [overflow-wrap:anywhere] [&_span[data-jsf-readonly]]:h-auto [&_span[data-jsf-readonly]]:min-w-0", valueCell && "max-w-[32rem] [&_span[data-jsf-readonly]]:line-clamp-3", require_json_schema_form_size.controlMinHeightClass[ctx.size]),
69
71
  children: nodes.value
70
72
  }) : nodes.value;
71
73
  }
@@ -112,7 +114,7 @@ function TableArray({ field, ctx, readOnly, toolbar }) {
112
114
  }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: itemRows.map((row, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", {
113
115
  className: require_utils.cn("border-b last:border-b-0 align-top", ctx.presentation ? "border-border" : "border-input"),
114
116
  children: [columns.map(([col]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
115
- className: require_utils.cn("px-2 py-1", !ctx.presentation && !readOnly && "min-w-40"),
117
+ className: require_utils.cn("px-2 py-1", !ctx.presentation && !readOnly && "min-w-40", valueCells && "min-w-20"),
116
118
  children: cell(row, i, col)
117
119
  }, col)), removable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
118
120
  className: "px-2 py-1",
@@ -1 +1 @@
1
- {"version":3,"file":"json-schema-form-table-array.cjs","names":["useArrayRows","tableColumnOptions","tableLayout","canRemoveItem","isPlainObject","setIndex","applyChangeEffects","appendInstancePath","cn","controlMinHeightClass","resolveControl","applyPostExtensions","controlHeightClass","removeIndex","Icon","UiTrash","canAddItem","Button","inputSizeClass","seedFromSchema","UiAdd","emptyListLine","resolveItemSpec","labelSizeClass","schemaHelper","HoverCard"],"sources":["../../src/components/json-schema-form-table-array.tsx"],"sourcesContent":["import { type ReactNode } from \"react\";\nimport { isPlainObject, removeIndex, setIndex } from \"../lib/collections\";\nimport { cn } from \"../lib/utils\";\nimport { Icon } from \"../data/Icon\";\nimport { UiAdd, UiTrash } from \"../icons\";\nimport { HoverCard } from \"../overlay/HoverCard\";\nimport { Button } from \"./button\";\nimport {\n controlHeightClass,\n controlMinHeightClass,\n inputSizeClass,\n} from \"./json-schema-form-size\";\nimport { resolveControl, schemaHelper } from \"./json-schema-form-resolve\";\nimport { applyPostExtensions } from \"./json-schema-form-extensions\";\nimport { appendInstancePath } from \"./json-schema-form-errors\";\nimport { applyChangeEffects } from \"./json-schema-form-listeners\";\nimport { tableColumnOptions, tableLayout } from \"./json-schema-form-array-view\";\nimport { useArrayRows } from \"./json-schema-form-array-rows\";\nimport { emptyListLine, resolveItemSpec } from \"./json-schema-form-item-summary\";\nimport { labelSizeClass } from \"./json-schema-form-size\";\nimport {\n canAddItem,\n canRemoveItem,\n seedFromSchema,\n} from \"./json-schema-form-utils\";\nimport type {\n FieldControl,\n JsonSchemaObject,\n JsonSchemaProperty,\n RenderContext,\n} from \"./json-schema-form-types\";\n\n// TableArray renders an object-item array as a table: a header row of the item's\n// property names and one row per item with value-only controls, plus per-row\n// remove and an add button. The grid view of an object array; see ObjectArrayView.\nexport function TableArray({\n field,\n ctx,\n readOnly,\n toolbar,\n}: {\n field: FieldControl;\n ctx: RenderContext;\n readOnly: boolean;\n /** List-level actions, right-aligned on a slim line above the table. */\n toolbar?: ReactNode;\n}) {\n const items = Array.isArray(field.value) ? field.value : [];\n const { rows: itemRows, rememberRows } = useArrayRows(field.value);\n const itemSchema = field.itemSchema ?? { type: \"object\" };\n // A table read-only as a whole — a view (the form's `readOnly` prop or a\n // readOnly ancestor; see RenderContext.viewOnly) or the array's own\n // `readOnly` — renders every cell as its value, exactly as a column the\n // schema (or a listener patch) marks readOnly does: a readOnly field is value\n // text wherever it sits, and in a table the grid itself is the structure a\n // disabled control would otherwise keep visible. `x-disabled`, which only\n // reaches ctx.readOnly, keeps real controls, disabled.\n const options = tableColumnOptions(field, ctx);\n const valueCells = options.valueCells;\n // Columns are the union across rows of each row's effective item properties\n // under its own listener state — `allOf` members included, so a listener\n // path that patches one cell (appended as an allOf member) reaches it —\n // minus the cells no row would render: `x-hidden`, a readOnly cell under\n // hideReadOnlyFields, and a writeOnly cell in a read-only view. A cell its\n // own row hides renders as an empty placeholder in a column another row\n // shows. The item schema's explicit `x-order` is the authority for the keys\n // it names: per-property `x-clicky-order` sorts first, then `x-order` pulls\n // its listed columns to the front in its own sequence.\n const { columns, rows } = tableLayout(itemSchema, items, options);\n // hideReadOnlyFields already dropped the declared-readOnly columns; the\n // cells a read-only table marks readOnly itself must still render.\n const childCtx: RenderContext = {\n ...ctx,\n readOnly,\n depth: ctx.depth + 1,\n ...(valueCells ? { hideReadOnlyFields: false } : {}),\n };\n // The trash column disappears with the buttons that would have filled it, so\n // an array of a fixed length reads as a table rather than one with a blank\n // gutter down the side.\n const removable = !readOnly && canRemoveItem(field, items.length);\n\n function changeRows(next: typeof itemRows) {\n rememberRows(next);\n field.onChange(next.map((row) => row.item));\n }\n\n // A cell renders its OWN row's property, so a listener's readOnly, enable or\n // patch reaches that row alone, and commits through the row's value\n // listeners exactly as an item of the list views does.\n function cell(row: (typeof itemRows)[number], rowIndex: number, col: string): ReactNode {\n const { item } = row;\n const obj = isPlainObject(item) ? item : {};\n const prop = rows[rowIndex]?.[col];\n const nodes = prop\n ? ctx.render.renderFieldNodes(\n {\n key: `${field.key}[${rowIndex}].${col}`,\n prop: valueCells ? { ...prop, readOnly: true } : prop,\n required: false,\n value: obj[col],\n onChange: (next) =>\n changeRows(\n setIndex(\n itemRows,\n rowIndex,\n {\n ...row,\n item: applyChangeEffects(itemSchema as JsonSchemaObject, {\n root: options.rootValue ?? obj,\n ...(options.evaluate ? { evaluate: options.evaluate } : {}),\n value: obj,\n key: col,\n next,\n }),\n },\n ),\n ),\n instancePath: appendInstancePath(\n appendInstancePath(ctx.instancePath, rowIndex),\n col,\n ),\n },\n childCtx,\n )\n : null;\n if (!nodes) return <span data-jsf-cell-placeholder aria-hidden=\"true\" className={cn(\"block\", controlMinHeightClass[ctx.size])} />;\n return ctx.presentation ? (\n <div\n className={cn(\n \"flex min-w-0 items-center [overflow-wrap:anywhere] [&_span[data-jsf-readonly]]:h-auto [&_span[data-jsf-readonly]]:min-w-0\",\n controlMinHeightClass[ctx.size],\n )}\n >\n {nodes.value}\n </div>\n ) : (\n nodes.value\n );\n }\n\n // A column header is its column's label, so post extensions decorate it as\n // they decorate every field label, on the column's field (keyed by the\n // property name, after the pre-extensions). Only the returned label is used:\n // a header holds no value, and value adornments belong in the cells. A\n // column names no single value, so the context carries no instancePath.\n function columnHeader(col: string, prop: JsonSchemaProperty, header: ReactNode): ReactNode {\n const roots = {\n ...(ctx.rootValue ? { rootValue: ctx.rootValue } : {}),\n ...(ctx.onRootChange ? { onRootChange: ctx.onRootChange } : {}),\n };\n let column: FieldControl | null = resolveControl({ key: col, prop, required: false, value: undefined, onChange: () => {} });\n for (const ext of ctx.pre) {\n if (!column) break;\n column = ext(column, { key: col, prop, value: undefined, ...roots });\n }\n if (!column) return header;\n return applyPostExtensions(column, { label: header, value: null }, ctx.post, roots).label;\n }\n\n const table = (\n <div\n className={cn(\n \"overflow-x-auto\",\n !ctx.presentation && \"rounded-md border border-input\",\n )}\n >\n <table className=\"w-full text-sm\">\n <thead>\n <tr\n className={cn(\n \"border-b bg-muted/40 text-left\",\n ctx.presentation ? \"border-border\" : \"border-input\",\n )}\n >\n {columns.map(([col, prop]) => (\n <th\n key={col}\n className=\"px-2 py-1 text-xs font-medium text-muted-foreground [overflow-wrap:anywhere]\"\n >\n {columnHeader(\n col,\n prop,\n ctx.presentation ? prop.title || col : <TableColumnHeader name={col} schema={prop} />,\n )}\n </th>\n ))}\n {removable && <th className=\"w-10 px-2 py-1\" />}\n </tr>\n </thead>\n <tbody>\n {itemRows.map((row, i) => (\n <tr\n key={row.key}\n className={cn(\n \"border-b last:border-b-0 align-top\",\n ctx.presentation ? \"border-border\" : \"border-input\",\n )}\n >\n {columns.map(([col]) => (\n <td key={col} className={cn(\"px-2 py-1\", !ctx.presentation && !readOnly && \"min-w-40\")}>\n {cell(row, i, col)}\n </td>\n ))}\n {removable && (\n <td className=\"px-2 py-1\">\n <button\n type=\"button\"\n aria-label={`Remove item ${i + 1}`}\n className={cn(\n \"inline-flex aspect-square items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground\",\n controlHeightClass[ctx.size],\n )}\n onClick={() => changeRows(removeIndex(itemRows, i))}\n >\n <Icon icon={UiTrash} className=\"text-sm\" />\n </button>\n </td>\n )}\n </tr>\n ))}\n </tbody>\n </table>\n {!readOnly && canAddItem(field, items.length) && (\n <div className=\"p-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n className={cn(\"gap-1.5\", inputSizeClass[ctx.size])}\n onClick={() =>\n field.onChange([...items, seedFromSchema(itemSchema)])\n }\n >\n <Icon icon={UiAdd} className=\"text-sm\" />\n Add item\n </Button>\n </div>\n )}\n </div>\n );\n const emptyLine = emptyListLine(field.itemSpec ?? resolveItemSpec(field.schema, itemSchema), items.length);\n if (emptyLine === undefined && toolbar == null) return table;\n return (\n <div className=\"flex flex-col gap-2\">\n <div data-jsf-array-summary className=\"flex items-center justify-between gap-2\">\n <p className={cn(\"text-muted-foreground\", labelSizeClass[ctx.size])}>{emptyLine}</p>\n {toolbar != null && <div className=\"flex shrink-0 items-center\">{toolbar}</div>}\n </div>\n {table}\n </div>\n );\n}\n\nfunction TableColumnHeader({\n name,\n schema,\n}: {\n name: string;\n schema: JsonSchemaProperty;\n}) {\n const label =\n typeof schema.title === \"string\" && schema.title ? schema.title : name;\n const helper = schemaHelper(schema);\n if (!helper) return label;\n\n return (\n <HoverCard\n placement=\"bottom\"\n trigger={\n <button\n type=\"button\"\n aria-label={`${label} help`}\n className=\"cursor-help border-b border-dotted border-current text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {label}\n </button>\n }\n cardClassName=\"max-w-xs whitespace-normal text-left font-normal text-foreground\"\n >\n {helper}\n </HoverCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,WAAW,EACzB,OACA,KAC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,MAAM;CAClC,IAAI,CAAC,QAAQ,OAAO;CAEpB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,kBAAAA,WAAD;EACE,WAAU;EACV,SACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;GACE,MAAK;GACL,cAAY,GAAG,MAAM;GACrB,WAAU;GAET,UAAA;EACK,CAAA;EAEV,eAAc;EAEb,UAAA;CACQ,CAAA;AAEf"}
1
+ {"version":3,"file":"json-schema-form-table-array.cjs","names":["useArrayRows","tableColumnOptions","tableLayout","canRemoveItem","isPlainObject","setIndex","applyChangeEffects","appendInstancePath","cn","controlMinHeightClass","resolveControl","applyPostExtensions","controlHeightClass","removeIndex","Icon","UiTrash","canAddItem","Button","inputSizeClass","seedFromSchema","UiAdd","emptyListLine","resolveItemSpec","labelSizeClass","schemaHelper","HoverCard"],"sources":["../../src/components/json-schema-form-table-array.tsx"],"sourcesContent":["import { type ReactNode } from \"react\";\nimport { isPlainObject, removeIndex, setIndex } from \"../lib/collections\";\nimport { cn } from \"../lib/utils\";\nimport { Icon } from \"../data/Icon\";\nimport { UiAdd, UiTrash } from \"../icons\";\nimport { HoverCard } from \"../overlay/HoverCard\";\nimport { Button } from \"./button\";\nimport {\n controlHeightClass,\n controlMinHeightClass,\n inputSizeClass,\n} from \"./json-schema-form-size\";\nimport { resolveControl, schemaHelper } from \"./json-schema-form-resolve\";\nimport { applyPostExtensions } from \"./json-schema-form-extensions\";\nimport { appendInstancePath } from \"./json-schema-form-errors\";\nimport { applyChangeEffects } from \"./json-schema-form-listeners\";\nimport { tableColumnOptions, tableLayout } from \"./json-schema-form-array-view\";\nimport { useArrayRows } from \"./json-schema-form-array-rows\";\nimport { emptyListLine, resolveItemSpec } from \"./json-schema-form-item-summary\";\nimport { labelSizeClass } from \"./json-schema-form-size\";\nimport {\n canAddItem,\n canRemoveItem,\n seedFromSchema,\n} from \"./json-schema-form-utils\";\nimport type {\n FieldControl,\n JsonSchemaObject,\n JsonSchemaProperty,\n RenderContext,\n} from \"./json-schema-form-types\";\n\n// TableArray renders an object-item array as a table: a header row of the item's\n// property names and one row per item with value-only controls, plus per-row\n// remove and an add button. The grid view of an object array; see ObjectArrayView.\nexport function TableArray({\n field,\n ctx,\n readOnly,\n toolbar,\n}: {\n field: FieldControl;\n ctx: RenderContext;\n readOnly: boolean;\n /** List-level actions, right-aligned on a slim line above the table. */\n toolbar?: ReactNode;\n}) {\n const items = Array.isArray(field.value) ? field.value : [];\n const { rows: itemRows, rememberRows } = useArrayRows(field.value);\n const itemSchema = field.itemSchema ?? { type: \"object\" };\n // A table read-only as a whole — a view (the form's `readOnly` prop or a\n // readOnly ancestor; see RenderContext.viewOnly) or the array's own\n // `readOnly` — renders every cell as its value, exactly as a column the\n // schema (or a listener patch) marks readOnly does: a readOnly field is value\n // text wherever it sits, and in a table the grid itself is the structure a\n // disabled control would otherwise keep visible. `x-disabled`, which only\n // reaches ctx.readOnly, keeps real controls, disabled.\n const options = tableColumnOptions(field, ctx);\n const valueCells = options.valueCells;\n // Columns are the union across rows of each row's effective item properties\n // under its own listener state — `allOf` members included, so a listener\n // path that patches one cell (appended as an allOf member) reaches it —\n // minus the cells no row would render: `x-hidden`, a readOnly cell under\n // hideReadOnlyFields, and a writeOnly cell in a read-only view. A cell its\n // own row hides renders as an empty placeholder in a column another row\n // shows. The item schema's explicit `x-order` is the authority for the keys\n // it names: per-property `x-clicky-order` sorts first, then `x-order` pulls\n // its listed columns to the front in its own sequence.\n const { columns, rows } = tableLayout(itemSchema, items, options);\n // hideReadOnlyFields already dropped the declared-readOnly columns; the\n // cells a read-only table marks readOnly itself must still render.\n const childCtx: RenderContext = {\n ...ctx,\n readOnly,\n depth: ctx.depth + 1,\n ...(valueCells ? { hideReadOnlyFields: false } : {}),\n };\n // The trash column disappears with the buttons that would have filled it, so\n // an array of a fixed length reads as a table rather than one with a blank\n // gutter down the side.\n const removable = !readOnly && canRemoveItem(field, items.length);\n\n function changeRows(next: typeof itemRows) {\n rememberRows(next);\n field.onChange(next.map((row) => row.item));\n }\n\n // A cell renders its OWN row's property, so a listener's readOnly, enable or\n // patch reaches that row alone, and commits through the row's value\n // listeners exactly as an item of the list views does.\n function cell(row: (typeof itemRows)[number], rowIndex: number, col: string): ReactNode {\n const { item } = row;\n const obj = isPlainObject(item) ? item : {};\n const prop = rows[rowIndex]?.[col];\n const nodes = prop\n ? ctx.render.renderFieldNodes(\n {\n key: `${field.key}[${rowIndex}].${col}`,\n prop: valueCells ? { ...prop, readOnly: true } : prop,\n required: false,\n value: obj[col],\n onChange: (next) =>\n changeRows(\n setIndex(\n itemRows,\n rowIndex,\n {\n ...row,\n item: applyChangeEffects(itemSchema as JsonSchemaObject, {\n root: options.rootValue ?? obj,\n ...(options.evaluate ? { evaluate: options.evaluate } : {}),\n value: obj,\n key: col,\n next,\n }),\n },\n ),\n ),\n instancePath: appendInstancePath(\n appendInstancePath(ctx.instancePath, rowIndex),\n col,\n ),\n },\n childCtx,\n )\n : null;\n if (!nodes) return <span data-jsf-cell-placeholder aria-hidden=\"true\" className={cn(\"block\", controlMinHeightClass[ctx.size])} />;\n // A value cell wraps instead of holding a control's fixed height, so a long\n // message, id or timestamp neither spills out of its row nor stretches the\n // table past its container; in a read-only table a long value is capped in\n // width and clamped to three lines, its full text on hover (the value's title).\n const valueCell = valueCells || prop?.readOnly === true;\n return ctx.presentation || valueCell ? (\n <div\n data-jsf-value-cell=\"\"\n className={cn(\n \"flex min-w-0 items-center [overflow-wrap:anywhere] [&_span[data-jsf-readonly]]:h-auto [&_span[data-jsf-readonly]]:min-w-0\",\n valueCell && \"max-w-[32rem] [&_span[data-jsf-readonly]]:line-clamp-3\",\n controlMinHeightClass[ctx.size],\n )}\n >\n {nodes.value}\n </div>\n ) : (\n nodes.value\n );\n }\n\n // A column header is its column's label, so post extensions decorate it as\n // they decorate every field label, on the column's field (keyed by the\n // property name, after the pre-extensions). Only the returned label is used:\n // a header holds no value, and value adornments belong in the cells. A\n // column names no single value, so the context carries no instancePath.\n function columnHeader(col: string, prop: JsonSchemaProperty, header: ReactNode): ReactNode {\n const roots = {\n ...(ctx.rootValue ? { rootValue: ctx.rootValue } : {}),\n ...(ctx.onRootChange ? { onRootChange: ctx.onRootChange } : {}),\n };\n let column: FieldControl | null = resolveControl({ key: col, prop, required: false, value: undefined, onChange: () => {} });\n for (const ext of ctx.pre) {\n if (!column) break;\n column = ext(column, { key: col, prop, value: undefined, ...roots });\n }\n if (!column) return header;\n return applyPostExtensions(column, { label: header, value: null }, ctx.post, roots).label;\n }\n\n const table = (\n <div\n className={cn(\n \"overflow-x-auto\",\n !ctx.presentation && \"rounded-md border border-input\",\n )}\n >\n <table className=\"w-full text-sm\">\n <thead>\n <tr\n className={cn(\n \"border-b bg-muted/40 text-left\",\n ctx.presentation ? \"border-border\" : \"border-input\",\n )}\n >\n {columns.map(([col, prop]) => (\n <th\n key={col}\n className=\"px-2 py-1 text-xs font-medium text-muted-foreground [overflow-wrap:anywhere]\"\n >\n {columnHeader(\n col,\n prop,\n ctx.presentation ? prop.title || col : <TableColumnHeader name={col} schema={prop} />,\n )}\n </th>\n ))}\n {removable && <th className=\"w-10 px-2 py-1\" />}\n </tr>\n </thead>\n <tbody>\n {itemRows.map((row, i) => (\n <tr\n key={row.key}\n className={cn(\n \"border-b last:border-b-0 align-top\",\n ctx.presentation ? \"border-border\" : \"border-input\",\n )}\n >\n {columns.map(([col]) => (\n <td key={col} className={cn(\"px-2 py-1\", !ctx.presentation && !readOnly && \"min-w-40\", valueCells && \"min-w-20\")}>\n {cell(row, i, col)}\n </td>\n ))}\n {removable && (\n <td className=\"px-2 py-1\">\n <button\n type=\"button\"\n aria-label={`Remove item ${i + 1}`}\n className={cn(\n \"inline-flex aspect-square items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground\",\n controlHeightClass[ctx.size],\n )}\n onClick={() => changeRows(removeIndex(itemRows, i))}\n >\n <Icon icon={UiTrash} className=\"text-sm\" />\n </button>\n </td>\n )}\n </tr>\n ))}\n </tbody>\n </table>\n {!readOnly && canAddItem(field, items.length) && (\n <div className=\"p-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n className={cn(\"gap-1.5\", inputSizeClass[ctx.size])}\n onClick={() =>\n field.onChange([...items, seedFromSchema(itemSchema)])\n }\n >\n <Icon icon={UiAdd} className=\"text-sm\" />\n Add item\n </Button>\n </div>\n )}\n </div>\n );\n const emptyLine = emptyListLine(field.itemSpec ?? resolveItemSpec(field.schema, itemSchema), items.length);\n if (emptyLine === undefined && toolbar == null) return table;\n return (\n <div className=\"flex flex-col gap-2\">\n <div data-jsf-array-summary className=\"flex items-center justify-between gap-2\">\n <p className={cn(\"text-muted-foreground\", labelSizeClass[ctx.size])}>{emptyLine}</p>\n {toolbar != null && <div className=\"flex shrink-0 items-center\">{toolbar}</div>}\n </div>\n {table}\n </div>\n );\n}\n\nfunction TableColumnHeader({\n name,\n schema,\n}: {\n name: string;\n schema: JsonSchemaProperty;\n}) {\n const label =\n typeof schema.title === \"string\" && schema.title ? schema.title : name;\n const helper = schemaHelper(schema);\n if (!helper) return label;\n\n return (\n <HoverCard\n placement=\"bottom\"\n trigger={\n <button\n type=\"button\"\n aria-label={`${label} help`}\n className=\"cursor-help border-b border-dotted border-current text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {label}\n </button>\n }\n cardClassName=\"max-w-xs whitespace-normal text-left font-normal text-foreground\"\n >\n {helper}\n </HoverCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,WAAW,EACzB,OACA,KACA,UACA,WAOC;CACD,MAAM,QAAQ,MAAM,QAAQ,MAAM,KAAK,IAAI,MAAM,QAAQ,CAAC;CAC1D,MAAM,EAAE,MAAM,UAAU,iBAAiBA,oCAAAA,aAAa,MAAM,KAAK;CACjE,MAAM,aAAa,MAAM,cAAc,EAAE,MAAM,SAAS;CAQxD,MAAM,UAAUC,oCAAAA,mBAAmB,OAAO,GAAG;CAC7C,MAAM,aAA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,GAAG,MAAM;GACrB,WAAU;GAET,UAAA;EACK,CAAA;EAEV,eAAc;EAEb,UAAA;CACQ,CAAA;AAEf"}
@@ -1 +1 @@
1
- {"version":3,"file":"json-schema-form-table-array.d.ts","sourceRoot":"","sources":["../../src/components/json-schema-form-table-array.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAyBvC,OAAO,KAAK,EACV,YAAY,EAGZ,aAAa,EACd,MAAM,0BAA0B,CAAC;AAKlC,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,GAAG,EACH,QAAQ,EACR,OAAO,GACR,EAAE;IACD,KAAK,EAAE,YAAY,CAAC;IACpB,GAAG,EAAE,aAAa,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,wEAAwE;IACxE,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB,+BA6MA"}
1
+ {"version":3,"file":"json-schema-form-table-array.d.ts","sourceRoot":"","sources":["../../src/components/json-schema-form-table-array.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAyBvC,OAAO,KAAK,EACV,YAAY,EAGZ,aAAa,EACd,MAAM,0BAA0B,CAAC;AAKlC,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,GAAG,EACH,QAAQ,EACR,OAAO,GACR,EAAE;IACD,KAAK,EAAE,YAAY,CAAC;IACpB,GAAG,EAAE,aAAa,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,wEAAwE;IACxE,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB,+BAoNA"}
@@ -64,8 +64,10 @@ function TableArray({ field, ctx, readOnly, toolbar }) {
64
64
  "aria-hidden": "true",
65
65
  className: cn("block", controlMinHeightClass[ctx.size])
66
66
  });
67
- return ctx.presentation ? /* @__PURE__ */ jsx("div", {
68
- className: cn("flex min-w-0 items-center [overflow-wrap:anywhere] [&_span[data-jsf-readonly]]:h-auto [&_span[data-jsf-readonly]]:min-w-0", controlMinHeightClass[ctx.size]),
67
+ const valueCell = valueCells || prop?.readOnly === true;
68
+ return ctx.presentation || valueCell ? /* @__PURE__ */ jsx("div", {
69
+ "data-jsf-value-cell": "",
70
+ className: cn("flex min-w-0 items-center [overflow-wrap:anywhere] [&_span[data-jsf-readonly]]:h-auto [&_span[data-jsf-readonly]]:min-w-0", valueCell && "max-w-[32rem] [&_span[data-jsf-readonly]]:line-clamp-3", controlMinHeightClass[ctx.size]),
69
71
  children: nodes.value
70
72
  }) : nodes.value;
71
73
  }
@@ -112,7 +114,7 @@ function TableArray({ field, ctx, readOnly, toolbar }) {
112
114
  }) }), /* @__PURE__ */ jsx("tbody", { children: itemRows.map((row, i) => /* @__PURE__ */ jsxs("tr", {
113
115
  className: cn("border-b last:border-b-0 align-top", ctx.presentation ? "border-border" : "border-input"),
114
116
  children: [columns.map(([col]) => /* @__PURE__ */ jsx("td", {
115
- className: cn("px-2 py-1", !ctx.presentation && !readOnly && "min-w-40"),
117
+ className: cn("px-2 py-1", !ctx.presentation && !readOnly && "min-w-40", valueCells && "min-w-20"),
116
118
  children: cell(row, i, col)
117
119
  }, col)), removable && /* @__PURE__ */ jsx("td", {
118
120
  className: "px-2 py-1",
@@ -1 +1 @@
1
- {"version":3,"file":"json-schema-form-table-array.js","names":[],"sources":["../../src/components/json-schema-form-table-array.tsx"],"sourcesContent":["import { type ReactNode } from \"react\";\nimport { isPlainObject, removeIndex, setIndex } from \"../lib/collections\";\nimport { cn } from \"../lib/utils\";\nimport { Icon } from \"../data/Icon\";\nimport { UiAdd, UiTrash } from \"../icons\";\nimport { HoverCard } from \"../overlay/HoverCard\";\nimport { Button } from \"./button\";\nimport {\n controlHeightClass,\n controlMinHeightClass,\n inputSizeClass,\n} from \"./json-schema-form-size\";\nimport { resolveControl, schemaHelper } from \"./json-schema-form-resolve\";\nimport { applyPostExtensions } from \"./json-schema-form-extensions\";\nimport { appendInstancePath } from \"./json-schema-form-errors\";\nimport { applyChangeEffects } from \"./json-schema-form-listeners\";\nimport { tableColumnOptions, tableLayout } from \"./json-schema-form-array-view\";\nimport { useArrayRows } from \"./json-schema-form-array-rows\";\nimport { emptyListLine, resolveItemSpec } from \"./json-schema-form-item-summary\";\nimport { labelSizeClass } from \"./json-schema-form-size\";\nimport {\n canAddItem,\n canRemoveItem,\n seedFromSchema,\n} from \"./json-schema-form-utils\";\nimport type {\n FieldControl,\n JsonSchemaObject,\n JsonSchemaProperty,\n RenderContext,\n} from \"./json-schema-form-types\";\n\n// TableArray renders an object-item array as a table: a header row of the item's\n// property names and one row per item with value-only controls, plus per-row\n// remove and an add button. The grid view of an object array; see ObjectArrayView.\nexport function TableArray({\n field,\n ctx,\n readOnly,\n toolbar,\n}: {\n field: FieldControl;\n ctx: RenderContext;\n readOnly: boolean;\n /** List-level actions, right-aligned on a slim line above the table. */\n toolbar?: ReactNode;\n}) {\n const items = Array.isArray(field.value) ? field.value : [];\n const { rows: itemRows, rememberRows } = useArrayRows(field.value);\n const itemSchema = field.itemSchema ?? { type: \"object\" };\n // A table read-only as a whole — a view (the form's `readOnly` prop or a\n // readOnly ancestor; see RenderContext.viewOnly) or the array's own\n // `readOnly` — renders every cell as its value, exactly as a column the\n // schema (or a listener patch) marks readOnly does: a readOnly field is value\n // text wherever it sits, and in a table the grid itself is the structure a\n // disabled control would otherwise keep visible. `x-disabled`, which only\n // reaches ctx.readOnly, keeps real controls, disabled.\n const options = tableColumnOptions(field, ctx);\n const valueCells = options.valueCells;\n // Columns are the union across rows of each row's effective item properties\n // under its own listener state — `allOf` members included, so a listener\n // path that patches one cell (appended as an allOf member) reaches it —\n // minus the cells no row would render: `x-hidden`, a readOnly cell under\n // hideReadOnlyFields, and a writeOnly cell in a read-only view. A cell its\n // own row hides renders as an empty placeholder in a column another row\n // shows. The item schema's explicit `x-order` is the authority for the keys\n // it names: per-property `x-clicky-order` sorts first, then `x-order` pulls\n // its listed columns to the front in its own sequence.\n const { columns, rows } = tableLayout(itemSchema, items, options);\n // hideReadOnlyFields already dropped the declared-readOnly columns; the\n // cells a read-only table marks readOnly itself must still render.\n const childCtx: RenderContext = {\n ...ctx,\n readOnly,\n depth: ctx.depth + 1,\n ...(valueCells ? { hideReadOnlyFields: false } : {}),\n };\n // The trash column disappears with the buttons that would have filled it, so\n // an array of a fixed length reads as a table rather than one with a blank\n // gutter down the side.\n const removable = !readOnly && canRemoveItem(field, items.length);\n\n function changeRows(next: typeof itemRows) {\n rememberRows(next);\n field.onChange(next.map((row) => row.item));\n }\n\n // A cell renders its OWN row's property, so a listener's readOnly, enable or\n // patch reaches that row alone, and commits through the row's value\n // listeners exactly as an item of the list views does.\n function cell(row: (typeof itemRows)[number], rowIndex: number, col: string): ReactNode {\n const { item } = row;\n const obj = isPlainObject(item) ? item : {};\n const prop = rows[rowIndex]?.[col];\n const nodes = prop\n ? ctx.render.renderFieldNodes(\n {\n key: `${field.key}[${rowIndex}].${col}`,\n prop: valueCells ? { ...prop, readOnly: true } : prop,\n required: false,\n value: obj[col],\n onChange: (next) =>\n changeRows(\n setIndex(\n itemRows,\n rowIndex,\n {\n ...row,\n item: applyChangeEffects(itemSchema as JsonSchemaObject, {\n root: options.rootValue ?? obj,\n ...(options.evaluate ? { evaluate: options.evaluate } : {}),\n value: obj,\n key: col,\n next,\n }),\n },\n ),\n ),\n instancePath: appendInstancePath(\n appendInstancePath(ctx.instancePath, rowIndex),\n col,\n ),\n },\n childCtx,\n )\n : null;\n if (!nodes) return <span data-jsf-cell-placeholder aria-hidden=\"true\" className={cn(\"block\", controlMinHeightClass[ctx.size])} />;\n return ctx.presentation ? (\n <div\n className={cn(\n \"flex min-w-0 items-center [overflow-wrap:anywhere] [&_span[data-jsf-readonly]]:h-auto [&_span[data-jsf-readonly]]:min-w-0\",\n controlMinHeightClass[ctx.size],\n )}\n >\n {nodes.value}\n </div>\n ) : (\n nodes.value\n );\n }\n\n // A column header is its column's label, so post extensions decorate it as\n // they decorate every field label, on the column's field (keyed by the\n // property name, after the pre-extensions). Only the returned label is used:\n // a header holds no value, and value adornments belong in the cells. A\n // column names no single value, so the context carries no instancePath.\n function columnHeader(col: string, prop: JsonSchemaProperty, header: ReactNode): ReactNode {\n const roots = {\n ...(ctx.rootValue ? { rootValue: ctx.rootValue } : {}),\n ...(ctx.onRootChange ? { onRootChange: ctx.onRootChange } : {}),\n };\n let column: FieldControl | null = resolveControl({ key: col, prop, required: false, value: undefined, onChange: () => {} });\n for (const ext of ctx.pre) {\n if (!column) break;\n column = ext(column, { key: col, prop, value: undefined, ...roots });\n }\n if (!column) return header;\n return applyPostExtensions(column, { label: header, value: null }, ctx.post, roots).label;\n }\n\n const table = (\n <div\n className={cn(\n \"overflow-x-auto\",\n !ctx.presentation && \"rounded-md border border-input\",\n )}\n >\n <table className=\"w-full text-sm\">\n <thead>\n <tr\n className={cn(\n \"border-b bg-muted/40 text-left\",\n ctx.presentation ? \"border-border\" : \"border-input\",\n )}\n >\n {columns.map(([col, prop]) => (\n <th\n key={col}\n className=\"px-2 py-1 text-xs font-medium text-muted-foreground [overflow-wrap:anywhere]\"\n >\n {columnHeader(\n col,\n prop,\n ctx.presentation ? prop.title || col : <TableColumnHeader name={col} schema={prop} />,\n )}\n </th>\n ))}\n {removable && <th className=\"w-10 px-2 py-1\" />}\n </tr>\n </thead>\n <tbody>\n {itemRows.map((row, i) => (\n <tr\n key={row.key}\n className={cn(\n \"border-b last:border-b-0 align-top\",\n ctx.presentation ? \"border-border\" : \"border-input\",\n )}\n >\n {columns.map(([col]) => (\n <td key={col} className={cn(\"px-2 py-1\", !ctx.presentation && !readOnly && \"min-w-40\")}>\n {cell(row, i, col)}\n </td>\n ))}\n {removable && (\n <td className=\"px-2 py-1\">\n <button\n type=\"button\"\n aria-label={`Remove item ${i + 1}`}\n className={cn(\n \"inline-flex aspect-square items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground\",\n controlHeightClass[ctx.size],\n )}\n onClick={() => changeRows(removeIndex(itemRows, i))}\n >\n <Icon icon={UiTrash} className=\"text-sm\" />\n </button>\n </td>\n )}\n </tr>\n ))}\n </tbody>\n </table>\n {!readOnly && canAddItem(field, items.length) && (\n <div className=\"p-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n className={cn(\"gap-1.5\", inputSizeClass[ctx.size])}\n onClick={() =>\n field.onChange([...items, seedFromSchema(itemSchema)])\n }\n >\n <Icon icon={UiAdd} className=\"text-sm\" />\n Add item\n </Button>\n </div>\n )}\n </div>\n );\n const emptyLine = emptyListLine(field.itemSpec ?? resolveItemSpec(field.schema, itemSchema), items.length);\n if (emptyLine === undefined && toolbar == null) return table;\n return (\n <div className=\"flex flex-col gap-2\">\n <div data-jsf-array-summary className=\"flex items-center justify-between gap-2\">\n <p className={cn(\"text-muted-foreground\", labelSizeClass[ctx.size])}>{emptyLine}</p>\n {toolbar != null && <div className=\"flex shrink-0 items-center\">{toolbar}</div>}\n </div>\n {table}\n </div>\n );\n}\n\nfunction TableColumnHeader({\n name,\n schema,\n}: {\n name: string;\n schema: JsonSchemaProperty;\n}) {\n const label =\n typeof schema.title === \"string\" && schema.title ? schema.title : name;\n const helper = schemaHelper(schema);\n if (!helper) return label;\n\n return (\n <HoverCard\n placement=\"bottom\"\n trigger={\n <button\n type=\"button\"\n aria-label={`${label} help`}\n className=\"cursor-help border-b border-dotted border-current text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {label}\n </button>\n }\n cardClassName=\"max-w-xs whitespace-normal text-left font-normal text-foreground\"\n >\n {helper}\n </HoverCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,WAAW,EACzB,OACA,KACA,UACA,WAOC;CACD,MAAM,QAAQ,MAAM,QAAQ,MAAM,KAAK,IAAI,MAAM,QAAQ,CAAC;CAC1D,MAAM,EAAE,MAAM,UAAU,iBAAiB,aAAa,MAAM,KAAK;CACjE,MAAM,aAAa,MAAM,cAAc,EAAE,MAAM,SAAS;CAQxD,MA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EACJ,CAAA,GAAA,KACE;;AAET;AAEA,SAAS,kBAAkB,EACzB,MACA,UAIC;CACD,MAAM,QACJ,OAAO,OAAO,UAAU,YAAY,OAAO,QAAQ,OAAO,QAAQ;CACpE,MAAM,SAAS,aAAa,MAAM;CAClC,IAAI,CAAC,QAAQ,OAAO;CAEpB,OACE,oBAAC,WAAD;EACE,WAAU;EACV,SACE,oBAAC,UAAD;GACE,MAAK;GACL,cAAY,GAAG,MAAM;GACrB,WAAU;GAET,UAAA;EACK,CAAA;EAEV,eAAc;EAEb,UAAA;CACQ,CAAA;AAEf"}
1
+ {"version":3,"file":"json-schema-form-table-array.js","names":[],"sources":["../../src/components/json-schema-form-table-array.tsx"],"sourcesContent":["import { type ReactNode } from \"react\";\nimport { isPlainObject, removeIndex, setIndex } from \"../lib/collections\";\nimport { cn } from \"../lib/utils\";\nimport { Icon } from \"../data/Icon\";\nimport { UiAdd, UiTrash } from \"../icons\";\nimport { HoverCard } from \"../overlay/HoverCard\";\nimport { Button } from \"./button\";\nimport {\n controlHeightClass,\n controlMinHeightClass,\n inputSizeClass,\n} from \"./json-schema-form-size\";\nimport { resolveControl, schemaHelper } from \"./json-schema-form-resolve\";\nimport { applyPostExtensions } from \"./json-schema-form-extensions\";\nimport { appendInstancePath } from \"./json-schema-form-errors\";\nimport { applyChangeEffects } from \"./json-schema-form-listeners\";\nimport { tableColumnOptions, tableLayout } from \"./json-schema-form-array-view\";\nimport { useArrayRows } from \"./json-schema-form-array-rows\";\nimport { emptyListLine, resolveItemSpec } from \"./json-schema-form-item-summary\";\nimport { labelSizeClass } from \"./json-schema-form-size\";\nimport {\n canAddItem,\n canRemoveItem,\n seedFromSchema,\n} from \"./json-schema-form-utils\";\nimport type {\n FieldControl,\n JsonSchemaObject,\n JsonSchemaProperty,\n RenderContext,\n} from \"./json-schema-form-types\";\n\n// TableArray renders an object-item array as a table: a header row of the item's\n// property names and one row per item with value-only controls, plus per-row\n// remove and an add button. The grid view of an object array; see ObjectArrayView.\nexport function TableArray({\n field,\n ctx,\n readOnly,\n toolbar,\n}: {\n field: FieldControl;\n ctx: RenderContext;\n readOnly: boolean;\n /** List-level actions, right-aligned on a slim line above the table. */\n toolbar?: ReactNode;\n}) {\n const items = Array.isArray(field.value) ? field.value : [];\n const { rows: itemRows, rememberRows } = useArrayRows(field.value);\n const itemSchema = field.itemSchema ?? { type: \"object\" };\n // A table read-only as a whole — a view (the form's `readOnly` prop or a\n // readOnly ancestor; see RenderContext.viewOnly) or the array's own\n // `readOnly` — renders every cell as its value, exactly as a column the\n // schema (or a listener patch) marks readOnly does: a readOnly field is value\n // text wherever it sits, and in a table the grid itself is the structure a\n // disabled control would otherwise keep visible. `x-disabled`, which only\n // reaches ctx.readOnly, keeps real controls, disabled.\n const options = tableColumnOptions(field, ctx);\n const valueCells = options.valueCells;\n // Columns are the union across rows of each row's effective item properties\n // under its own listener state — `allOf` members included, so a listener\n // path that patches one cell (appended as an allOf member) reaches it —\n // minus the cells no row would render: `x-hidden`, a readOnly cell under\n // hideReadOnlyFields, and a writeOnly cell in a read-only view. A cell its\n // own row hides renders as an empty placeholder in a column another row\n // shows. The item schema's explicit `x-order` is the authority for the keys\n // it names: per-property `x-clicky-order` sorts first, then `x-order` pulls\n // its listed columns to the front in its own sequence.\n const { columns, rows } = tableLayout(itemSchema, items, options);\n // hideReadOnlyFields already dropped the declared-readOnly columns; the\n // cells a read-only table marks readOnly itself must still render.\n const childCtx: RenderContext = {\n ...ctx,\n readOnly,\n depth: ctx.depth + 1,\n ...(valueCells ? { hideReadOnlyFields: false } : {}),\n };\n // The trash column disappears with the buttons that would have filled it, so\n // an array of a fixed length reads as a table rather than one with a blank\n // gutter down the side.\n const removable = !readOnly && canRemoveItem(field, items.length);\n\n function changeRows(next: typeof itemRows) {\n rememberRows(next);\n field.onChange(next.map((row) => row.item));\n }\n\n // A cell renders its OWN row's property, so a listener's readOnly, enable or\n // patch reaches that row alone, and commits through the row's value\n // listeners exactly as an item of the list views does.\n function cell(row: (typeof itemRows)[number], rowIndex: number, col: string): ReactNode {\n const { item } = row;\n const obj = isPlainObject(item) ? item : {};\n const prop = rows[rowIndex]?.[col];\n const nodes = prop\n ? ctx.render.renderFieldNodes(\n {\n key: `${field.key}[${rowIndex}].${col}`,\n prop: valueCells ? { ...prop, readOnly: true } : prop,\n required: false,\n value: obj[col],\n onChange: (next) =>\n changeRows(\n setIndex(\n itemRows,\n rowIndex,\n {\n ...row,\n item: applyChangeEffects(itemSchema as JsonSchemaObject, {\n root: options.rootValue ?? obj,\n ...(options.evaluate ? { evaluate: options.evaluate } : {}),\n value: obj,\n key: col,\n next,\n }),\n },\n ),\n ),\n instancePath: appendInstancePath(\n appendInstancePath(ctx.instancePath, rowIndex),\n col,\n ),\n },\n childCtx,\n )\n : null;\n if (!nodes) return <span data-jsf-cell-placeholder aria-hidden=\"true\" className={cn(\"block\", controlMinHeightClass[ctx.size])} />;\n // A value cell wraps instead of holding a control's fixed height, so a long\n // message, id or timestamp neither spills out of its row nor stretches the\n // table past its container; in a read-only table a long value is capped in\n // width and clamped to three lines, its full text on hover (the value's title).\n const valueCell = valueCells || prop?.readOnly === true;\n return ctx.presentation || valueCell ? (\n <div\n data-jsf-value-cell=\"\"\n className={cn(\n \"flex min-w-0 items-center [overflow-wrap:anywhere] [&_span[data-jsf-readonly]]:h-auto [&_span[data-jsf-readonly]]:min-w-0\",\n valueCell && \"max-w-[32rem] [&_span[data-jsf-readonly]]:line-clamp-3\",\n controlMinHeightClass[ctx.size],\n )}\n >\n {nodes.value}\n </div>\n ) : (\n nodes.value\n );\n }\n\n // A column header is its column's label, so post extensions decorate it as\n // they decorate every field label, on the column's field (keyed by the\n // property name, after the pre-extensions). Only the returned label is used:\n // a header holds no value, and value adornments belong in the cells. A\n // column names no single value, so the context carries no instancePath.\n function columnHeader(col: string, prop: JsonSchemaProperty, header: ReactNode): ReactNode {\n const roots = {\n ...(ctx.rootValue ? { rootValue: ctx.rootValue } : {}),\n ...(ctx.onRootChange ? { onRootChange: ctx.onRootChange } : {}),\n };\n let column: FieldControl | null = resolveControl({ key: col, prop, required: false, value: undefined, onChange: () => {} });\n for (const ext of ctx.pre) {\n if (!column) break;\n column = ext(column, { key: col, prop, value: undefined, ...roots });\n }\n if (!column) return header;\n return applyPostExtensions(column, { label: header, value: null }, ctx.post, roots).label;\n }\n\n const table = (\n <div\n className={cn(\n \"overflow-x-auto\",\n !ctx.presentation && \"rounded-md border border-input\",\n )}\n >\n <table className=\"w-full text-sm\">\n <thead>\n <tr\n className={cn(\n \"border-b bg-muted/40 text-left\",\n ctx.presentation ? \"border-border\" : \"border-input\",\n )}\n >\n {columns.map(([col, prop]) => (\n <th\n key={col}\n className=\"px-2 py-1 text-xs font-medium text-muted-foreground [overflow-wrap:anywhere]\"\n >\n {columnHeader(\n col,\n prop,\n ctx.presentation ? prop.title || col : <TableColumnHeader name={col} schema={prop} />,\n )}\n </th>\n ))}\n {removable && <th className=\"w-10 px-2 py-1\" />}\n </tr>\n </thead>\n <tbody>\n {itemRows.map((row, i) => (\n <tr\n key={row.key}\n className={cn(\n \"border-b last:border-b-0 align-top\",\n ctx.presentation ? \"border-border\" : \"border-input\",\n )}\n >\n {columns.map(([col]) => (\n <td key={col} className={cn(\"px-2 py-1\", !ctx.presentation && !readOnly && \"min-w-40\", valueCells && \"min-w-20\")}>\n {cell(row, i, col)}\n </td>\n ))}\n {removable && (\n <td className=\"px-2 py-1\">\n <button\n type=\"button\"\n aria-label={`Remove item ${i + 1}`}\n className={cn(\n \"inline-flex aspect-square items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground\",\n controlHeightClass[ctx.size],\n )}\n onClick={() => changeRows(removeIndex(itemRows, i))}\n >\n <Icon icon={UiTrash} className=\"text-sm\" />\n </button>\n </td>\n )}\n </tr>\n ))}\n </tbody>\n </table>\n {!readOnly && canAddItem(field, items.length) && (\n <div className=\"p-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n className={cn(\"gap-1.5\", inputSizeClass[ctx.size])}\n onClick={() =>\n field.onChange([...items, seedFromSchema(itemSchema)])\n }\n >\n <Icon icon={UiAdd} className=\"text-sm\" />\n Add item\n </Button>\n </div>\n )}\n </div>\n );\n const emptyLine = emptyListLine(field.itemSpec ?? resolveItemSpec(field.schema, itemSchema), items.length);\n if (emptyLine === undefined && toolbar == null) return table;\n return (\n <div className=\"flex flex-col gap-2\">\n <div data-jsf-array-summary className=\"flex items-center justify-between gap-2\">\n <p className={cn(\"text-muted-foreground\", labelSizeClass[ctx.size])}>{emptyLine}</p>\n {toolbar != null && <div className=\"flex shrink-0 items-center\">{toolbar}</div>}\n </div>\n {table}\n </div>\n );\n}\n\nfunction TableColumnHeader({\n name,\n schema,\n}: {\n name: string;\n schema: JsonSchemaProperty;\n}) {\n const label =\n typeof schema.title === \"string\" && schema.title ? schema.title : name;\n const helper = schemaHelper(schema);\n if (!helper) return label;\n\n return (\n <HoverCard\n placement=\"bottom\"\n trigger={\n <button\n type=\"button\"\n aria-label={`${label} help`}\n className=\"cursor-help border-b border-dotted border-current text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {label}\n </button>\n }\n cardClassName=\"max-w-xs whitespace-normal text-left font-normal text-foreground\"\n >\n {helper}\n </HoverCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,WAAW,EACzB,OACA,KACA,UACA,WAOC;CACD,MAAM,QAAQ,MAAM,QAAQ,MAAM,KAAK,IAAI,MAAM,QAAQ,CAAC;CAC1D,MAAM,EAAE,MAAM,UAAU,iBAAiB,aAAa,MAAM,KAAK;CACjE,MAAM,aAAa,MAAM,cAAc,EAAE,MAAM,SAAS;CAQxD,MAAM,UAAU,mBAAmB,OAAO,GAAG;CAC7C,MAAM,aAAa,QAAQ;CAU3B,MAAM,EAAE,SAAS,SAAS,YAAY,YAAY,OAAO,OAAO;CAGhE,MAAM,WAA0B;EAC9B,GAAG;EACH;EACA,OAAO,IAAI,QAAQ;EACnB,GAAI,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,YAAY,OAAO,QAAQ,OAAO,QAAQ;CACpE,MAAM,SAAS,aAAa,MAAM;CAClC,IAAI,CAAC,QAAQ,OAAO;CAEpB,OACE,oBAAC,WAAD;EACE,WAAU;EACV,SACE,oBAAC,UAAD;GACE,MAAK;GACL,cAAY,GAAG,MAAM;GACrB,WAAU;GAET,UAAA;EACK,CAAA;EAEV,eAAc;EAEb,UAAA;CACQ,CAAA;AAEf"}
@@ -41,8 +41,8 @@ const require_ConnectionLoggingPolicy_model = require("./components/ConnectionLo
41
41
  const require_Combobox = require("./components/Combobox.cjs");
42
42
  const require_CountryFlag = require("./components/CountryFlag.cjs");
43
43
  const require_CountryPicker = require("./components/CountryPicker.cjs");
44
- const require_filter_bar_multi = require("./components/filter-bar-multi.cjs");
45
44
  const require_country_options = require("./components/country-options.cjs");
45
+ const require_filter_bar_multi = require("./components/filter-bar-multi.cjs");
46
46
  const require_Field = require("./components/Field.cjs");
47
47
  const require_use_form = require("./components/use-form.cjs");
48
48
  const require_TreePickerField = require("./components/TreePickerField.cjs");
@@ -40,8 +40,8 @@ import { CONNECTION_LOG_LEVELS, isConnectionLoggingCapability, visibleConnection
40
40
  import { Combobox } from "./components/Combobox.js";
41
41
  import { CountryFlag } from "./components/CountryFlag.js";
42
42
  import { CountryPicker } from "./components/CountryPicker.js";
43
- import { TriStateMultiSelect } from "./components/filter-bar-multi.js";
44
43
  import { COUNTRY_OPTIONS, getCountryOption, isCountryCode } from "./components/country-options.js";
44
+ import { TriStateMultiSelect } from "./components/filter-bar-multi.js";
45
45
  import { Field } from "./components/Field.js";
46
46
  import { useForm } from "./components/use-form.js";
47
47
  import { TreePickerField } from "./components/TreePickerField.js";
@@ -23,10 +23,14 @@ function ConnectionPicker({ options, value, onChange, types, typeIcons, typeLabe
23
23
  });
24
24
  return [...new Set(grouped.map((entry) => entry.group))].flatMap((group) => grouped.filter((entry) => entry.group === group)).map(({ option, group }) => {
25
25
  const { group: _listed, ...row } = require_lookup_option_view.fieldOptionToComboboxOption(option);
26
- return group ? {
26
+ const stacked = row.description ? {
27
27
  ...row,
28
- group
28
+ descriptionLayout: "stacked"
29
29
  } : row;
30
+ return group ? {
31
+ ...stacked,
32
+ group
33
+ } : stacked;
30
34
  });
31
35
  }, [
32
36
  options,
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectionPicker.cjs","names":["useMemo","connectionTypeOfIcon","connectionTypeLabel","fieldOptionToComboboxOption","UiAdd","Combobox","Icon"],"sources":["../../src/connections/ConnectionPicker.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { Combobox } from \"../components/Combobox\";\nimport type { ComboboxSingleProps } from \"../components/combobox-types\";\nimport type { FieldOption } from \"../components/json-schema-form-types\";\nimport { fieldOptionToComboboxOption } from \"../components/lookup-option-view\";\nimport { Icon } from \"../data/Icon\";\nimport { UiAdd } from \"../icons\";\nimport { connectionTypeLabel, connectionTypeOfIcon } from \"./connectionTypes\";\n\n/** The connection a picker's footer asks to create; `type` is absent for an any-type picker. */\nexport type ConnectionCreateRequest = { type?: string };\n\nexport type ConnectionPickerProps = Pick<\n ComboboxSingleProps,\n | \"id\"\n | \"size\"\n | \"disabled\"\n | \"loading\"\n | \"onSearch\"\n | \"invalid\"\n | \"ariaRequired\"\n | \"describedBy\"\n | \"clearable\"\n | \"clearLabel\"\n | \"onClear\"\n | \"className\"\n> & {\n /**\n * The connections to offer, as the lookup returned them: `icon` is the type's\n * mark, `description` the endpoint, `badges` how it is reached. The picker\n * holds no connection model of its own.\n */\n options: FieldOption[];\n /** The selected connection's `connection://[namespace/]name` ref. */\n value: string;\n onChange: (ref: string) => void;\n /**\n * The connection types the field accepts (`x-connection-types`). Exactly one\n * makes a typed picker: its icon is pinned in the control, no group headers\n * and the footer creates that type. Otherwise rows group under a type header.\n */\n types?: string[];\n /** Runtime icon name per type (the connection schema's `x-enum-icons`). A type without one uses its own name. */\n typeIcons?: Record<string, string>;\n /** Display label per type (the schema's `x-enum-labels`); an absent type is title-cased. */\n typeLabels?: Record<string, string>;\n /** Shows the \"New {type} connection…\" footer and is called when it is clicked. Omit where connections cannot be created. */\n onCreate?: (request: ConnectionCreateRequest) => void;\n};\n\n/**\n * Picks one connection from the options a lookup returned. The value is the\n * `connection://` ref, free text is refused, and — only when `onCreate` is\n * given — the menu ends with a \"New {type} connection…\" footer.\n */\nexport function ConnectionPicker({\n options,\n value,\n onChange,\n types,\n typeIcons,\n typeLabels,\n onCreate,\n ...combobox\n}: ConnectionPickerProps) {\n const type = types?.length === 1 ? types[0] : undefined;\n const comboboxOptions = useMemo(() => {\n const grouped = options.map((option) => {\n const optionType = connectionTypeOfIcon(option.icon, typeIcons);\n return {\n option,\n group: type ? undefined : (option.group ?? (optionType ? connectionTypeLabel(optionType, typeLabels) : undefined)),\n };\n });\n // Groups are contiguous runs, so gather each group's rows under its first appearance.\n const order = [...new Set(grouped.map((entry) => entry.group))];\n return order\n .flatMap((group) => grouped.filter((entry) => entry.group === group))\n .map(({ option, group }) => {\n const { group: _listed, ...row } = fieldOptionToComboboxOption(option);\n return group ? { ...row, group } : row;\n });\n }, [options, type, typeIcons, typeLabels]);\n const unlisted = value !== \"\" && !options.some((option) => option.value === value);\n const rows = unlisted ? [{ value, label: value, selectedLabel: value }, ...comboboxOptions] : comboboxOptions;\n\n const noun = type ? `${connectionTypeLabel(type, typeLabels)} connection` : \"connection\";\n const footer = onCreate ? (\n <button\n type=\"button\"\n className=\"flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-primary hover:bg-muted/60\"\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => onCreate(type ? { type } : {})}\n >\n <UiAdd className=\"size-4\" />\n {`New ${noun}…`}\n </button>\n ) : undefined;\n\n return (\n <Combobox\n {...combobox}\n options={rows}\n value={value}\n onChange={onChange}\n allowCustomValue={false}\n placeholder={`Select a ${noun}`}\n ariaLabel={type ? `${connectionTypeLabel(type, typeLabels)} connection` : \"Connection\"}\n menuWidth={540}\n {...(type ? { prefix: <Icon name={typeIcons?.[type] ?? type} className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,CAME,iBAAA,GAAA,kBAAA,IAAA,CAACE,cAAAA,OAAD,EAAO,WAAU,SAAU,CAAA,GAC1B,OAAO,KAAK,EACP;CACN,CAAA,IAAA,KAAA;CAEJ,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,iBAAAA,UAAD;EACE,GAAI;EACJ,SAAS;EACF;EACG;EACV,kBAAkB;EAClB,aAAa,YAAY;EACzB,WAAW,OAAO,GAAGH,wBAAAA,oBAAoB,MAAM,UAAU,EAAE,eAAe;EAC1E,WAAW;EACX,GAAK,OAAO,EAAE,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAACI,aAAAA,MAAD;GAAM,MAAM,YAAY,SAAS;GAAM,WAAU;EAAa,CAAA,EAAE,IAAI,CAAC;EAC3F,GAAK,SAAS,EAAE,OAAO,IAAI,CAAC;CAC7B,CAAA;AAEL"}
1
+ {"version":3,"file":"ConnectionPicker.cjs","names":["useMemo","connectionTypeOfIcon","connectionTypeLabel","fieldOptionToComboboxOption","UiAdd","Combobox","Icon"],"sources":["../../src/connections/ConnectionPicker.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { Combobox } from \"../components/Combobox\";\nimport type { ComboboxSingleProps } from \"../components/combobox-types\";\nimport type { FieldOption } from \"../components/json-schema-form-types\";\nimport { fieldOptionToComboboxOption } from \"../components/lookup-option-view\";\nimport { Icon } from \"../data/Icon\";\nimport { UiAdd } from \"../icons\";\nimport { connectionTypeLabel, connectionTypeOfIcon } from \"./connectionTypes\";\n\n/** The connection a picker's footer asks to create; `type` is absent for an any-type picker. */\nexport type ConnectionCreateRequest = { type?: string };\n\nexport type ConnectionPickerProps = Pick<\n ComboboxSingleProps,\n | \"id\"\n | \"size\"\n | \"disabled\"\n | \"loading\"\n | \"onSearch\"\n | \"invalid\"\n | \"ariaRequired\"\n | \"describedBy\"\n | \"clearable\"\n | \"clearLabel\"\n | \"onClear\"\n | \"className\"\n> & {\n /**\n * The connections to offer, as the lookup returned them: `icon` is the type's\n * mark, `description` the endpoint, `badges` how it is reached. The picker\n * holds no connection model of its own.\n */\n options: FieldOption[];\n /** The selected connection's `connection://[namespace/]name` ref. */\n value: string;\n onChange: (ref: string) => void;\n /**\n * The connection types the field accepts (`x-connection-types`). Exactly one\n * makes a typed picker: its icon is pinned in the control, no group headers\n * and the footer creates that type. Otherwise rows group under a type header.\n */\n types?: string[];\n /** Runtime icon name per type (the connection schema's `x-enum-icons`). A type without one uses its own name. */\n typeIcons?: Record<string, string>;\n /** Display label per type (the schema's `x-enum-labels`); an absent type is title-cased. */\n typeLabels?: Record<string, string>;\n /** Shows the \"New {type} connection…\" footer and is called when it is clicked. Omit where connections cannot be created. */\n onCreate?: (request: ConnectionCreateRequest) => void;\n};\n\n/**\n * Picks one connection from the options a lookup returned. The value is the\n * `connection://` ref, free text is refused, and — only when `onCreate` is\n * given — the menu ends with a \"New {type} connection…\" footer.\n */\nexport function ConnectionPicker({\n options,\n value,\n onChange,\n types,\n typeIcons,\n typeLabels,\n onCreate,\n ...combobox\n}: ConnectionPickerProps) {\n const type = types?.length === 1 ? types[0] : undefined;\n const comboboxOptions = useMemo(() => {\n const grouped = options.map((option) => {\n const optionType = connectionTypeOfIcon(option.icon, typeIcons);\n return {\n option,\n group: type ? undefined : (option.group ?? (optionType ? connectionTypeLabel(optionType, typeLabels) : undefined)),\n };\n });\n // Groups are contiguous runs, so gather each group's rows under its first appearance.\n const order = [...new Set(grouped.map((entry) => entry.group))];\n return order\n .flatMap((group) => grouped.filter((entry) => entry.group === group))\n .map(({ option, group }) => {\n const { group: _listed, ...row } = fieldOptionToComboboxOption(option);\n // The endpoint is the long part of a row; it gets its own line under the name.\n const stacked = row.description ? { ...row, descriptionLayout: \"stacked\" as const } : row;\n return group ? { ...stacked, group } : stacked;\n });\n }, [options, type, typeIcons, typeLabels]);\n const unlisted = value !== \"\" && !options.some((option) => option.value === value);\n const rows = unlisted ? [{ value, label: value, selectedLabel: value }, ...comboboxOptions] : comboboxOptions;\n\n const noun = type ? `${connectionTypeLabel(type, typeLabels)} connection` : \"connection\";\n const footer = onCreate ? (\n <button\n type=\"button\"\n className=\"flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-primary hover:bg-muted/60\"\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => onCreate(type ? { type } : {})}\n >\n <UiAdd className=\"size-4\" />\n {`New ${noun}…`}\n </button>\n ) : undefined;\n\n return (\n <Combobox\n {...combobox}\n options={rows}\n value={value}\n onChange={onChange}\n allowCustomValue={false}\n placeholder={`Select a ${noun}`}\n ariaLabel={type ? `${connectionTypeLabel(type, typeLabels)} connection` : \"Connection\"}\n menuWidth={540}\n {...(type ? { prefix: <Icon name={typeIcons?.[type] ?? type} className=\"text-base\" /> } : {})}\n {...(footer ? { footer } : {})}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAuDA,SAAgB,iBAAiB,EAC/B,SACA,OACA,UACA,OACA,WACA,YACA,UACA,GAAG,YACqB;CACxB,MAAM,OAAO,OAAO,WAAW,IAAI,MAAM,KAAK,KAAA;CAC9C,MAAM,mBAAA,GAAkBA,MAAAA,QAAAA,OAAc;EACpC,MAAM,UAAU,QAAQ,KAAK,WAAW;GACtC,MAAM,aAAaC,wBAAAA,qBAAqB,OAAO,MAAM,SAAS;GAC9D,OAAO;IACL;IACA,OAAO,OAAO,KAAA,IAAa,OAAO,UAAU,aAAaC,wBAAAA,oBAAoB,YAAY,UAAU,IAAI,KAAA;GACzG;EACF,CAAC;EAGD,OAAO,CADQ,GAAG,IAAI,IAAI,QAAQ,KAAK,UAAU,MAAM,KAAK,CAAC,CACtD,CAAA,CACJ,SAAS,UAAU,QAAQ,QAAQ,UAAU,MAAM,UAAU,KAAK,CAAC,CAAC,CACpE,KAAK,EAAE,QAAQ,YAAY;GAC1B,MAAM,EAAE,OAAO,SAAS,GAAG,QAAQC,2BAAAA,4BAA4B,MAAM;GAErE,MAAM,UAAU,IAAI,cAAc;IAAE,GAAG;IAAK,mBAAmB;GAAmB,IAAI;GACt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AE,MAAM,CAAA;CAAE,CAAC;AAExD,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,mBAAmB,EACjB,IAAI,GACJ,MAAM,GACN,UAAU,GACV,SAAS,GACT,UAAU,GACV,SAAS,GACT,cAAc,GACd,aAAa,GACb,WAAW,GACX,YAAY,GACZ,SAAS,GACT,WAAW,CACd,GAAG;IACF;;;;OAIG;IACH,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,iHAAiH;IACjH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,4FAA4F;IAC5F,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,4HAA4H;IAC5H,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAAC;CACvD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,KAAK,EACL,QAAQ,EACR,KAAK,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,GAAG,QAAQ,EACZ,EAAE,qBAAqB,+BAmDvB"}
@@ -23,10 +23,14 @@ function ConnectionPicker({ options, value, onChange, types, typeIcons, typeLabe
23
23
  });
24
24
  return [...new Set(grouped.map((entry) => entry.group))].flatMap((group) => grouped.filter((entry) => entry.group === group)).map(({ option, group }) => {
25
25
  const { group: _listed, ...row } = fieldOptionToComboboxOption(option);
26
- return group ? {
26
+ const stacked = row.description ? {
27
27
  ...row,
28
- group
28
+ descriptionLayout: "stacked"
29
29
  } : row;
30
+ return group ? {
31
+ ...stacked,
32
+ group
33
+ } : stacked;
30
34
  });
31
35
  }, [
32
36
  options,
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectionPicker.js","names":[],"sources":["../../src/connections/ConnectionPicker.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { Combobox } from \"../components/Combobox\";\nimport type { ComboboxSingleProps } from \"../components/combobox-types\";\nimport type { FieldOption } from \"../components/json-schema-form-types\";\nimport { fieldOptionToComboboxOption } from \"../components/lookup-option-view\";\nimport { Icon } from \"../data/Icon\";\nimport { UiAdd } from \"../icons\";\nimport { connectionTypeLabel, connectionTypeOfIcon } from \"./connectionTypes\";\n\n/** The connection a picker's footer asks to create; `type` is absent for an any-type picker. */\nexport type ConnectionCreateRequest = { type?: string };\n\nexport type ConnectionPickerProps = Pick<\n ComboboxSingleProps,\n | \"id\"\n | \"size\"\n | \"disabled\"\n | \"loading\"\n | \"onSearch\"\n | \"invalid\"\n | \"ariaRequired\"\n | \"describedBy\"\n | \"clearable\"\n | \"clearLabel\"\n | \"onClear\"\n | \"className\"\n> & {\n /**\n * The connections to offer, as the lookup returned them: `icon` is the type's\n * mark, `description` the endpoint, `badges` how it is reached. The picker\n * holds no connection model of its own.\n */\n options: FieldOption[];\n /** The selected connection's `connection://[namespace/]name` ref. */\n value: string;\n onChange: (ref: string) => void;\n /**\n * The connection types the field accepts (`x-connection-types`). Exactly one\n * makes a typed picker: its icon is pinned in the control, no group headers\n * and the footer creates that type. Otherwise rows group under a type header.\n */\n types?: string[];\n /** Runtime icon name per type (the connection schema's `x-enum-icons`). A type without one uses its own name. */\n typeIcons?: Record<string, string>;\n /** Display label per type (the schema's `x-enum-labels`); an absent type is title-cased. */\n typeLabels?: Record<string, string>;\n /** Shows the \"New {type} connection…\" footer and is called when it is clicked. Omit where connections cannot be created. */\n onCreate?: (request: ConnectionCreateRequest) => void;\n};\n\n/**\n * Picks one connection from the options a lookup returned. The value is the\n * `connection://` ref, free text is refused, and — only when `onCreate` is\n * given — the menu ends with a \"New {type} connection…\" footer.\n */\nexport function ConnectionPicker({\n options,\n value,\n onChange,\n types,\n typeIcons,\n typeLabels,\n onCreate,\n ...combobox\n}: ConnectionPickerProps) {\n const type = types?.length === 1 ? types[0] : undefined;\n const comboboxOptions = useMemo(() => {\n const grouped = options.map((option) => {\n const optionType = connectionTypeOfIcon(option.icon, typeIcons);\n return {\n option,\n group: type ? undefined : (option.group ?? (optionType ? connectionTypeLabel(optionType, typeLabels) : undefined)),\n };\n });\n // Groups are contiguous runs, so gather each group's rows under its first appearance.\n const order = [...new Set(grouped.map((entry) => entry.group))];\n return order\n .flatMap((group) => grouped.filter((entry) => entry.group === group))\n .map(({ option, group }) => {\n const { group: _listed, ...row } = fieldOptionToComboboxOption(option);\n return group ? { ...row, group } : row;\n });\n }, [options, type, typeIcons, typeLabels]);\n const unlisted = value !== \"\" && !options.some((option) => option.value === value);\n const rows = unlisted ? [{ value, label: value, selectedLabel: value }, ...comboboxOptions] : comboboxOptions;\n\n const noun = type ? `${connectionTypeLabel(type, typeLabels)} connection` : \"connection\";\n const footer = onCreate ? (\n <button\n type=\"button\"\n className=\"flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-primary hover:bg-muted/60\"\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => onCreate(type ? { type } : {})}\n >\n <UiAdd className=\"size-4\" />\n {`New ${noun}…`}\n </button>\n ) : undefined;\n\n return (\n <Combobox\n {...combobox}\n options={rows}\n value={value}\n onChange={onChange}\n allowCustomValue={false}\n placeholder={`Select a ${noun}`}\n ariaLabel={type ? `${connectionTypeLabel(type, typeLabels)} connection` : \"Connection\"}\n menuWidth={540}\n {...(type ? { prefix: <Icon name={typeIcons?.[type] ?? type} className=\"text-base\" /> } : {})}\n {...(footer ? { footer } : {})}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAuDA,SAAgB,iBAAiB,EAC/B,SACA,OACA,UACA,OACA,WACA,YACA,UACA,GAAG,YACqB;CACxB,MAAM,OAAO,OAAO,WAAW,IAAI,MAAM,KAAK,KAAA;CAC9C,MAAM,kBAAkB,cAAc;EACpC,MAAM,UAAU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CAAA,EAAE,IAAI,CAAC;EAC3F,GAAK,SAAS,EAAE,OAAO,IAAI,CAAC;CAC7B,CAAA;AAEL"}
1
+ {"version":3,"file":"ConnectionPicker.js","names":[],"sources":["../../src/connections/ConnectionPicker.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { Combobox } from \"../components/Combobox\";\nimport type { ComboboxSingleProps } from \"../components/combobox-types\";\nimport type { FieldOption } from \"../components/json-schema-form-types\";\nimport { fieldOptionToComboboxOption } from \"../components/lookup-option-view\";\nimport { Icon } from \"../data/Icon\";\nimport { UiAdd } from \"../icons\";\nimport { connectionTypeLabel, connectionTypeOfIcon } from \"./connectionTypes\";\n\n/** The connection a picker's footer asks to create; `type` is absent for an any-type picker. */\nexport type ConnectionCreateRequest = { type?: string };\n\nexport type ConnectionPickerProps = Pick<\n ComboboxSingleProps,\n | \"id\"\n | \"size\"\n | \"disabled\"\n | \"loading\"\n | \"onSearch\"\n | \"invalid\"\n | \"ariaRequired\"\n | \"describedBy\"\n | \"clearable\"\n | \"clearLabel\"\n | \"onClear\"\n | \"className\"\n> & {\n /**\n * The connections to offer, as the lookup returned them: `icon` is the type's\n * mark, `description` the endpoint, `badges` how it is reached. The picker\n * holds no connection model of its own.\n */\n options: FieldOption[];\n /** The selected connection's `connection://[namespace/]name` ref. */\n value: string;\n onChange: (ref: string) => void;\n /**\n * The connection types the field accepts (`x-connection-types`). Exactly one\n * makes a typed picker: its icon is pinned in the control, no group headers\n * and the footer creates that type. Otherwise rows group under a type header.\n */\n types?: string[];\n /** Runtime icon name per type (the connection schema's `x-enum-icons`). A type without one uses its own name. */\n typeIcons?: Record<string, string>;\n /** Display label per type (the schema's `x-enum-labels`); an absent type is title-cased. */\n typeLabels?: Record<string, string>;\n /** Shows the \"New {type} connection…\" footer and is called when it is clicked. Omit where connections cannot be created. */\n onCreate?: (request: ConnectionCreateRequest) => void;\n};\n\n/**\n * Picks one connection from the options a lookup returned. The value is the\n * `connection://` ref, free text is refused, and — only when `onCreate` is\n * given — the menu ends with a \"New {type} connection…\" footer.\n */\nexport function ConnectionPicker({\n options,\n value,\n onChange,\n types,\n typeIcons,\n typeLabels,\n onCreate,\n ...combobox\n}: ConnectionPickerProps) {\n const type = types?.length === 1 ? types[0] : undefined;\n const comboboxOptions = useMemo(() => {\n const grouped = options.map((option) => {\n const optionType = connectionTypeOfIcon(option.icon, typeIcons);\n return {\n option,\n group: type ? undefined : (option.group ?? (optionType ? connectionTypeLabel(optionType, typeLabels) : undefined)),\n };\n });\n // Groups are contiguous runs, so gather each group's rows under its first appearance.\n const order = [...new Set(grouped.map((entry) => entry.group))];\n return order\n .flatMap((group) => grouped.filter((entry) => entry.group === group))\n .map(({ option, group }) => {\n const { group: _listed, ...row } = fieldOptionToComboboxOption(option);\n // The endpoint is the long part of a row; it gets its own line under the name.\n const stacked = row.description ? { ...row, descriptionLayout: \"stacked\" as const } : row;\n return group ? { ...stacked, group } : stacked;\n });\n }, [options, type, typeIcons, typeLabels]);\n const unlisted = value !== \"\" && !options.some((option) => option.value === value);\n const rows = unlisted ? [{ value, label: value, selectedLabel: value }, ...comboboxOptions] : comboboxOptions;\n\n const noun = type ? `${connectionTypeLabel(type, typeLabels)} connection` : \"connection\";\n const footer = onCreate ? (\n <button\n type=\"button\"\n className=\"flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-primary hover:bg-muted/60\"\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => onCreate(type ? { type } : {})}\n >\n <UiAdd className=\"size-4\" />\n {`New ${noun}…`}\n </button>\n ) : undefined;\n\n return (\n <Combobox\n {...combobox}\n options={rows}\n value={value}\n onChange={onChange}\n allowCustomValue={false}\n placeholder={`Select a ${noun}`}\n ariaLabel={type ? `${connectionTypeLabel(type, typeLabels)} connection` : \"Connection\"}\n menuWidth={540}\n {...(type ? { prefix: <Icon name={typeIcons?.[type] ?? type} className=\"text-base\" /> } : {})}\n {...(footer ? { footer } : {})}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;A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AEJ,OACE,oBAAC,UAAD;EACE,GAAI;EACJ,SAAS;EACF;EACG;EACV,kBAAkB;EAClB,aAAa,YAAY;EACzB,WAAW,OAAO,GAAG,oBAAoB,MAAM,UAAU,EAAE,eAAe;EAC1E,WAAW;EACX,GAAK,OAAO,EAAE,QAAQ,oBAAC,MAAD;GAAM,MAAM,YAAY,SAAS;GAAM,WAAU;EAAa,CAAA,EAAE,IAAI,CAAC;EAC3F,GAAK,SAAS,EAAE,OAAO,IAAI,CAAC;CAC7B,CAAA;AAEL"}
@@ -3,7 +3,6 @@ const require_collections = require("../lib/collections.cjs");
3
3
  const require_Modal = require("../overlay/Modal.cjs");
4
4
  const require_apiClient = require("../rpc/apiClient.cjs");
5
5
  const require_ConnectionFormDialog = require("./ConnectionFormDialog.cjs");
6
- const require_ConnectionKubernetesContext = require("./ConnectionKubernetesContext.cjs");
7
6
  const require_connectionFormSupport = require("./connectionFormSupport.cjs");
8
7
  const require_connectionsPageModel = require("./connectionsPageModel.cjs");
9
8
  const require_connectionSchemaFormExtensions = require("./connectionSchemaFormExtensions.cjs");
@@ -16,7 +15,8 @@ let react_jsx_runtime = require("react/jsx-runtime");
16
15
  * Creates a connection without leaving the form that needs one: the schema form
17
16
  * the service serves on `GET {apiBase}/connection`, POSTed to `{apiBase}/connection`.
18
17
  * With `type` the form opens on that type's branch with the type fixed; the
19
- * Kubernetes context sits in the header. Needs a react-query QueryClientProvider.
18
+ * kubeconfig and kubecontext are a row of the form, as in ConnectionsPage. Needs
19
+ * a react-query QueryClientProvider.
20
20
  */
21
21
  function CreateConnectionDialog({ apiBase, type, initialValue, existing, fetcher = require_connectionSchemaFormExtensions.fetchConnectionJson, onClose, onCreated }) {
22
22
  const client = (0, react.useMemo)(() => require_apiClient.createOperationsApiClient({ baseUrl: apiBase }), [apiBase]);
@@ -24,8 +24,7 @@ function CreateConnectionDialog({ apiBase, type, initialValue, existing, fetcher
24
24
  const { extensions, error: extensionsError } = require_connectionFormSupport.useConnectionFormExtensions({
25
25
  apiBase,
26
26
  schema: schema.data,
27
- fetcher,
28
- kubernetes: "external"
27
+ fetcher
29
28
  });
30
29
  const meta = (0, react.useMemo)(() => schema.data ? require_connectionTypes.connectionTypeMeta(schema.data) : void 0, [schema.data]);
31
30
  const start = (0, react.useMemo)(() => ({
@@ -74,26 +73,14 @@ function CreateConnectionDialog({ apiBase, type, initialValue, existing, fetcher
74
73
  value,
75
74
  canSubmit
76
75
  }),
77
- title: ({ value, onValueChange }) => {
76
+ title: ({ value }) => {
78
77
  const chosen = typeof value?.type === "string" && value.type ? value.type : void 0;
79
78
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
80
79
  className: "flex items-center gap-2",
81
- children: [
82
- chosen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Icon.Icon, {
83
- name: meta?.icons[chosen] ?? chosen,
84
- className: "text-base"
85
- }),
86
- chosen ? `New ${require_connectionTypes.connectionTypeLabel(chosen, meta?.labels)} connection` : "New connection",
87
- chosen && value && onValueChange && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
88
- className: "ml-auto text-sm font-normal",
89
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ConnectionKubernetesContext.ConnectionKubernetesContext, {
90
- rootValue: value,
91
- onRootChange: onValueChange,
92
- apiBase,
93
- fetcher
94
- })
95
- })
96
- ]
80
+ children: [chosen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Icon.Icon, {
81
+ name: meta?.icons[chosen] ?? chosen,
82
+ className: "text-base"
83
+ }), chosen ? `New ${require_connectionTypes.connectionTypeLabel(chosen, meta?.labels)} connection` : "New connection"]
97
84
  });
98
85
  },
99
86
  onClose,
@@ -1 +1 @@
1
- {"version":3,"file":"CreateConnectionDialog.cjs","names":["fetchConnectionJson","useMemo","createOperationsApiClient","useConnectionSchema","useConnectionFormExtensions","connectionTypeMeta","useCallback","connectionRef","isPlainObject","Modal","CONNECTION_ERROR_BOX","ConnectionFormDialog","createConnectionAction","ConnectionTestButton","Icon","connectionTypeLabel","ConnectionKubernetesContext"],"sources":["../../src/connections/CreateConnectionDialog.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport { Icon } from \"../data/Icon\";\nimport { isPlainObject } from \"../lib/collections\";\nimport { Modal } from \"../overlay/Modal\";\nimport { createOperationsApiClient } from \"../rpc/apiClient\";\nimport type { ExecutionResponse } from \"../rpc/types\";\nimport { ConnectionFormDialog } from \"./ConnectionFormDialog\";\nimport { ConnectionKubernetesContext } from \"./ConnectionKubernetesContext\";\nimport { CONNECTION_ERROR_BOX, useConnectionFormExtensions, useConnectionSchema } from \"./connectionFormSupport\";\nimport { createConnectionAction } from \"./connectionsPageModel\";\nimport { fetchConnectionJson, type ConnectionJsonFetcher } from \"./connectionSchemaFormExtensions\";\nimport { ConnectionTestButton } from \"./connectionTestButton\";\nimport { connectionRef, connectionTypeLabel, connectionTypeMeta } from \"./connectionTypes\";\n\nexport type CreateConnectionDialogProps = {\n /** Where the commons-db connections service is mounted, e.g. `/api/v1`. */\n apiBase: string;\n /** Fixes the connection type and hides the form's type picker. Omit to let the form's own picker choose. */\n type?: string;\n /** Pre-fills the form, e.g. a suggested name. */\n initialValue?: Record<string, unknown>;\n /** The `connection://` refs already on offer: creating a name+namespace among them is refused. */\n existing?: string[];\n /** Overrides how the form's secret / cluster lookups are fetched. Defaults to `fetch`. */\n fetcher?: ConnectionJsonFetcher;\n onClose: () => void;\n /** Called with the created connection's `connection://[namespace/]name` ref, ready to be selected. */\n onCreated: (ref: string) => void;\n};\n\n/**\n * Creates a connection without leaving the form that needs one: the schema form\n * the service serves on `GET {apiBase}/connection`, POSTed to `{apiBase}/connection`.\n * With `type` the form opens on that type's branch with the type fixed; the\n * Kubernetes context sits in the header. Needs a react-query QueryClientProvider.\n */\nexport function CreateConnectionDialog({\n apiBase,\n type,\n initialValue,\n existing,\n fetcher = fetchConnectionJson,\n onClose,\n onCreated,\n}: CreateConnectionDialogProps) {\n const client = useMemo(() => createOperationsApiClient({ baseUrl: apiBase }), [apiBase]);\n const schema = useConnectionSchema(client);\n const { extensions, error: extensionsError } = useConnectionFormExtensions({\n apiBase,\n schema: schema.data,\n fetcher,\n kubernetes: \"external\",\n });\n const meta = useMemo(() => (schema.data ? connectionTypeMeta(schema.data) : undefined), [schema.data]);\n const start = useMemo(() => ({ ...(type ? { type } : {}), ...initialValue }), [type, initialValue]);\n const taken = useMemo(() => new Set(existing), [existing]);\n\n const submitBlocker = useCallback(\n (value: Record<string, unknown>) => {\n const name = typeof value.name === \"string\" ? value.name.trim() : \"\";\n const namespace = typeof value.namespace === \"string\" ? value.namespace : \"\";\n if (!name || !taken.has(connectionRef({ name, namespace }))) return undefined;\n return `A connection named “${name}” already exists in ${namespace || \"the default namespace\"}.`;\n },\n [taken],\n );\n\n const saved = useCallback(\n (response: ExecutionResponse) => {\n const created = response.parsed;\n if (!isPlainObject(created) || typeof created.name !== \"string\" || created.name === \"\") {\n throw new Error(`POST ${apiBase}/connection did not return the created connection (expected an object with a name)`);\n }\n onCreated(\n connectionRef({\n name: created.name,\n ...(typeof created.namespace === \"string\" ? { namespace: created.namespace } : {}),\n }),\n );\n },\n [apiBase, onCreated],\n );\n\n if (extensionsError) {\n return (\n <Modal open onClose={onClose} title=\"New connection\" size=\"2xl\">\n <div className={CONNECTION_ERROR_BOX}>{extensionsError}</div>\n </Modal>\n );\n }\n\n return (\n <ConnectionFormDialog\n apiBase={apiBase}\n client={client}\n action={createConnectionAction}\n initialValue={start}\n submitLabel=\"Create and select\"\n extensions={extensions}\n {...(type ? { hiddenKeys: [\"type\"] } : {})}\n submitBlocker={submitBlocker}\n footerActions={({ value, canSubmit }) => <ConnectionTestButton apiBase={apiBase} value={value} canSubmit={canSubmit} />}\n title={({ value, onValueChange }) => {\n const chosen = typeof value?.type === \"string\" && value.type ? value.type : undefined;\n return (\n <span className=\"flex items-center gap-2\">\n {chosen && <Icon name={meta?.icons[chosen] ?? chosen} className=\"text-base\" />}\n {chosen ? `New ${connectionTypeLabel(chosen, meta?.labels)} connection` : \"New connection\"}\n {chosen && value && onValueChange && (\n <span className=\"ml-auto text-sm font-normal\">\n <ConnectionKubernetesContext rootValue={value} onRootChange={onValueChange} apiBase={apiBase} fetcher={fetcher} />\n </span>\n )}\n </span>\n );\n }}\n onClose={onClose}\n onSaved={saved}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,uBAAuB,EACrC,SACA,MACA,cACA,UACA,UAAUA,uCAAAA,qBACV,SACA,aAC8B;CAC9B,MAAM,UAAA,GAASC,MAAAA,QAAAA,OAAcC,kBAAAA,0BAA0B,EAAE,SAAS,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC;CACvF,MAAM,SAASC,8BAAAA,oBAAoB,MAAM;CACzC,MAAM,EAAE,YAAY,OAAO,oBAAoBC,8BAAAA,4BAA4B;EACzE;EACA,QAAQ,OAAO;EACf;EACA,YAAY;CACd,CAAC;CACD,MAAM,QAAA,GAAOH,MAAAA,QAAAA,OAAe,OAAO,OAAOI,wBAAAA,mBAAmB,OAAO,IAAI,IAAI,KAAA,GAAY,CAAC,OAAO,IAAI,CAAC;CACrG,MAAM,SAAA,GAAQJ,MAAAA,QAAAA,QAAe;EAAE,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;EAAI,GAAG;CAAa,IAAI,CAAC,MAAM,YAAY,CAAC;CAClG,MAAM,SAAA,GAAQA,MAAAA,QAAAA,OAAc,IAAI,IAAI,QAAQ,GAAG,CAAC,QAAQ,CAAC;CAEzD,MAAM,iBAAA,GAAgBK,MAAAA,YAAAA,EACnB,UAAmC;EAClC,MAAM,OAAO,OAAO,MAAM,SAAS,WAAW,MAAM,KAAK,KAAK,IAAI;EAClE,MAAM,YAAY,OAAO,MAAM,cAAc,WAAW,MAAM,YAAY;EAC1E,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAIC,wBAAAA,cAAc;GAAE;GAAM;EAAU,CAAC,CAAC,GAAG,OA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MAAM,MAAM,WAAW;MAAQ,WAAU;KAAa,CAAA;KAC5E,SAAS,OAAOC,wBAAAA,oBAAoB,QAAQ,MAAM,MAAM,EAAE,eAAe;KACzE,UAAU,SAAS,iBAClB,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;MAAM,WAAU;MACd,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,oCAAAA,6BAAD;OAA6B,WAAW;OAAO,cAAc;OAAwB;OAAkB;MAAU,CAAA;KAC7G,CAAA;IAEJ;;EAEV;EACS;EACT,SAAS;CACV,CAAA;AAEL"}
1
+ {"version":3,"file":"CreateConnectionDialog.cjs","names":["fetchConnectionJson","useMemo","createOperationsApiClient","useConnectionSchema","useConnectionFormExtensions","connectionTypeMeta","useCallback","connectionRef","isPlainObject","Modal","CONNECTION_ERROR_BOX","ConnectionFormDialog","createConnectionAction","ConnectionTestButton","Icon","connectionTypeLabel"],"sources":["../../src/connections/CreateConnectionDialog.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport { Icon } from \"../data/Icon\";\nimport { isPlainObject } from \"../lib/collections\";\nimport { Modal } from \"../overlay/Modal\";\nimport { createOperationsApiClient } from \"../rpc/apiClient\";\nimport type { ExecutionResponse } from \"../rpc/types\";\nimport { ConnectionFormDialog } from \"./ConnectionFormDialog\";\nimport { CONNECTION_ERROR_BOX, useConnectionFormExtensions, useConnectionSchema } from \"./connectionFormSupport\";\nimport { createConnectionAction } from \"./connectionsPageModel\";\nimport { fetchConnectionJson, type ConnectionJsonFetcher } from \"./connectionSchemaFormExtensions\";\nimport { ConnectionTestButton } from \"./connectionTestButton\";\nimport { connectionRef, connectionTypeLabel, connectionTypeMeta } from \"./connectionTypes\";\n\nexport type CreateConnectionDialogProps = {\n /** Where the commons-db connections service is mounted, e.g. `/api/v1`. */\n apiBase: string;\n /** Fixes the connection type and hides the form's type picker. Omit to let the form's own picker choose. */\n type?: string;\n /** Pre-fills the form, e.g. a suggested name. */\n initialValue?: Record<string, unknown>;\n /** The `connection://` refs already on offer: creating a name+namespace among them is refused. */\n existing?: string[];\n /** Overrides how the form's secret / cluster lookups are fetched. Defaults to `fetch`. */\n fetcher?: ConnectionJsonFetcher;\n onClose: () => void;\n /** Called with the created connection's `connection://[namespace/]name` ref, ready to be selected. */\n onCreated: (ref: string) => void;\n};\n\n/**\n * Creates a connection without leaving the form that needs one: the schema form\n * the service serves on `GET {apiBase}/connection`, POSTed to `{apiBase}/connection`.\n * With `type` the form opens on that type's branch with the type fixed; the\n * kubeconfig and kubecontext are a row of the form, as in ConnectionsPage. Needs\n * a react-query QueryClientProvider.\n */\nexport function CreateConnectionDialog({\n apiBase,\n type,\n initialValue,\n existing,\n fetcher = fetchConnectionJson,\n onClose,\n onCreated,\n}: CreateConnectionDialogProps) {\n const client = useMemo(() => createOperationsApiClient({ baseUrl: apiBase }), [apiBase]);\n const schema = useConnectionSchema(client);\n // Kubeconfig and kubecontext render as a form row, as ConnectionsPage's add form does.\n const { extensions, error: extensionsError } = useConnectionFormExtensions({\n apiBase,\n schema: schema.data,\n fetcher,\n });\n const meta = useMemo(() => (schema.data ? connectionTypeMeta(schema.data) : undefined), [schema.data]);\n const start = useMemo(() => ({ ...(type ? { type } : {}), ...initialValue }), [type, initialValue]);\n const taken = useMemo(() => new Set(existing), [existing]);\n\n const submitBlocker = useCallback(\n (value: Record<string, unknown>) => {\n const name = typeof value.name === \"string\" ? value.name.trim() : \"\";\n const namespace = typeof value.namespace === \"string\" ? value.namespace : \"\";\n if (!name || !taken.has(connectionRef({ name, namespace }))) return undefined;\n return `A connection named “${name}” already exists in ${namespace || \"the default namespace\"}.`;\n },\n [taken],\n );\n\n const saved = useCallback(\n (response: ExecutionResponse) => {\n const created = response.parsed;\n if (!isPlainObject(created) || typeof created.name !== \"string\" || created.name === \"\") {\n throw new Error(`POST ${apiBase}/connection did not return the created connection (expected an object with a name)`);\n }\n onCreated(\n connectionRef({\n name: created.name,\n ...(typeof created.namespace === \"string\" ? { namespace: created.namespace } : {}),\n }),\n );\n },\n [apiBase, onCreated],\n );\n\n if (extensionsError) {\n return (\n <Modal open onClose={onClose} title=\"New connection\" size=\"2xl\">\n <div className={CONNECTION_ERROR_BOX}>{extensionsError}</div>\n </Modal>\n );\n }\n\n return (\n <ConnectionFormDialog\n apiBase={apiBase}\n client={client}\n action={createConnectionAction}\n initialValue={start}\n submitLabel=\"Create and select\"\n extensions={extensions}\n {...(type ? { hiddenKeys: [\"type\"] } : {})}\n submitBlocker={submitBlocker}\n footerActions={({ value, canSubmit }) => <ConnectionTestButton apiBase={apiBase} value={value} canSubmit={canSubmit} />}\n title={({ value }) => {\n const chosen = typeof value?.type === \"string\" && value.type ? value.type : undefined;\n return (\n <span className=\"flex items-center gap-2\">\n {chosen && <Icon name={meta?.icons[chosen] ?? chosen} className=\"text-base\" />}\n {chosen ? `New ${connectionTypeLabel(chosen, meta?.labels)} connection` : \"New connection\"}\n </span>\n );\n }}\n onClose={onClose}\n onSaved={saved}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,uBAAuB,EACrC,SACA,MACA,cACA,UACA,UAAUA,uCAAAA,qBACV,SACA,aAC8B;CAC9B,MAAM,UAAA,GAASC,MAAAA,QAAAA,OAAcC,kBAAAA,0BAA0B,EAAE,SAAS,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC;CACvF,MAAM,SAASC,8BAAAA,oBAAoB,MAAM;CAEzC,MAAM,EAAE,YAAY,OAAO,oBAAoBC,8BAAAA,4BAA4B;EACzE;EACA,QAAQ,OAAO;EACf;CACF,CAAC;CACD,MAAM,QAAA,GAAOH,MAAAA,QAAAA,OAAe,OAAO,OAAOI,wBAAAA,mBAAmB,OAAO,IAAI,IAAI,KAAA,GAAY,CAAC,OAAO,IAAI,CAAC;CACrG,MAAM,SAAA,GAAQJ,MAAAA,QAAAA,QAAe;EAAE,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;EAAI,GAAG;CAAa,IAAI,CAAC,MA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AI,CAAC;EACzB;EACf,gBAAgB,EAAE,OAAO,gBAAgB,iBAAA,GAAA,kBAAA,IAAA,CAACC,6BAAAA,sBAAD;GAA+B;GAAgB;GAAkB;EAAY,CAAA;EACtH,QAAQ,EAAE,YAAY;GACpB,MAAM,SAAS,OAAO,OAAO,SAAS,YAAY,MAAM,OAAO,MAAM,OAAO,KAAA;GAC5E,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CACG,UAAU,iBAAA,GAAA,kBAAA,IAAA,CAACC,aAAAA,MAAD;KAAM,MAAM,MAAM,MAAM,WAAW;KAAQ,WAAU;IAAa,CAAA,GAC5E,SAAS,OAAOC,wBAAAA,oBAAoB,QAAQ,MAAM,MAAM,EAAE,eAAe,gBACtE;;EAEV;EACS;EACT,SAAS;CACV,CAAA;AAEL"}
@@ -18,7 +18,8 @@ export type CreateConnectionDialogProps = {
18
18
  * Creates a connection without leaving the form that needs one: the schema form
19
19
  * the service serves on `GET {apiBase}/connection`, POSTed to `{apiBase}/connection`.
20
20
  * With `type` the form opens on that type's branch with the type fixed; the
21
- * Kubernetes context sits in the header. Needs a react-query QueryClientProvider.
21
+ * kubeconfig and kubecontext are a row of the form, as in ConnectionsPage. Needs
22
+ * a react-query QueryClientProvider.
22
23
  */
23
24
  export declare function CreateConnectionDialog({ apiBase, type, initialValue, existing, fetcher, onClose, onCreated, }: CreateConnectionDialogProps): import("react").JSX.Element;
24
25
  //# sourceMappingURL=CreateConnectionDialog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CreateConnectionDialog.d.ts","sourceRoot":"","sources":["../../src/connections/CreateConnectionDialog.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAuB,KAAK,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAInG,MAAM,MAAM,2BAA2B,GAAG;IACxC,2EAA2E;IAC3E,OAAO,EAAE,MAAM,CAAC;IAChB,4GAA4G;IAC5G,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,kGAAkG;IAClG,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,sGAAsG;IACtG,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,OAA6B,EAC7B,OAAO,EACP,SAAS,GACV,EAAE,2BAA2B,+BA4E7B"}
1
+ {"version":3,"file":"CreateConnectionDialog.d.ts","sourceRoot":"","sources":["../../src/connections/CreateConnectionDialog.tsx"],"names":[],"mappings":"AASA,OAAO,EAAuB,KAAK,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAInG,MAAM,MAAM,2BAA2B,GAAG;IACxC,2EAA2E;IAC3E,OAAO,EAAE,MAAM,CAAC;IAChB,4GAA4G;IAC5G,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,kGAAkG;IAClG,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,sGAAsG;IACtG,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,OAA6B,EAC7B,OAAO,EACP,SAAS,GACV,EAAE,2BAA2B,+BAuE7B"}
@@ -3,7 +3,6 @@ import { isPlainObject } from "../lib/collections.js";
3
3
  import { Modal } from "../overlay/Modal.js";
4
4
  import { createOperationsApiClient } from "../rpc/apiClient.js";
5
5
  import { ConnectionFormDialog } from "./ConnectionFormDialog.js";
6
- import { ConnectionKubernetesContext } from "./ConnectionKubernetesContext.js";
7
6
  import { CONNECTION_ERROR_BOX, useConnectionFormExtensions, useConnectionSchema } from "./connectionFormSupport.js";
8
7
  import { createConnectionAction } from "./connectionsPageModel.js";
9
8
  import { fetchConnectionJson } from "./connectionSchemaFormExtensions.js";
@@ -16,7 +15,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
16
15
  * Creates a connection without leaving the form that needs one: the schema form
17
16
  * the service serves on `GET {apiBase}/connection`, POSTed to `{apiBase}/connection`.
18
17
  * With `type` the form opens on that type's branch with the type fixed; the
19
- * Kubernetes context sits in the header. Needs a react-query QueryClientProvider.
18
+ * kubeconfig and kubecontext are a row of the form, as in ConnectionsPage. Needs
19
+ * a react-query QueryClientProvider.
20
20
  */
21
21
  function CreateConnectionDialog({ apiBase, type, initialValue, existing, fetcher = fetchConnectionJson, onClose, onCreated }) {
22
22
  const client = useMemo(() => createOperationsApiClient({ baseUrl: apiBase }), [apiBase]);
@@ -24,8 +24,7 @@ function CreateConnectionDialog({ apiBase, type, initialValue, existing, fetcher
24
24
  const { extensions, error: extensionsError } = useConnectionFormExtensions({
25
25
  apiBase,
26
26
  schema: schema.data,
27
- fetcher,
28
- kubernetes: "external"
27
+ fetcher
29
28
  });
30
29
  const meta = useMemo(() => schema.data ? connectionTypeMeta(schema.data) : void 0, [schema.data]);
31
30
  const start = useMemo(() => ({
@@ -74,26 +73,14 @@ function CreateConnectionDialog({ apiBase, type, initialValue, existing, fetcher
74
73
  value,
75
74
  canSubmit
76
75
  }),
77
- title: ({ value, onValueChange }) => {
76
+ title: ({ value }) => {
78
77
  const chosen = typeof value?.type === "string" && value.type ? value.type : void 0;
79
78
  return /* @__PURE__ */ jsxs("span", {
80
79
  className: "flex items-center gap-2",
81
- children: [
82
- chosen && /* @__PURE__ */ jsx(Icon, {
83
- name: meta?.icons[chosen] ?? chosen,
84
- className: "text-base"
85
- }),
86
- chosen ? `New ${connectionTypeLabel(chosen, meta?.labels)} connection` : "New connection",
87
- chosen && value && onValueChange && /* @__PURE__ */ jsx("span", {
88
- className: "ml-auto text-sm font-normal",
89
- children: /* @__PURE__ */ jsx(ConnectionKubernetesContext, {
90
- rootValue: value,
91
- onRootChange: onValueChange,
92
- apiBase,
93
- fetcher
94
- })
95
- })
96
- ]
80
+ children: [chosen && /* @__PURE__ */ jsx(Icon, {
81
+ name: meta?.icons[chosen] ?? chosen,
82
+ className: "text-base"
83
+ }), chosen ? `New ${connectionTypeLabel(chosen, meta?.labels)} connection` : "New connection"]
97
84
  });
98
85
  },
99
86
  onClose,