@d3plus/core 4.6.0 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README.md +728 -1454
  2. package/es/index.js.map +1 -1
  3. package/es/internal.js +5 -0
  4. package/es/internal.js.map +1 -1
  5. package/es/src/charts/Chord/index.js +2 -0
  6. package/es/src/charts/Chord/index.js.map +1 -1
  7. package/es/src/charts/Geomap/applyLayout.js +3 -1
  8. package/es/src/charts/Geomap/applyLayout.js.map +1 -1
  9. package/es/src/charts/Geomap/index.js +3 -1
  10. package/es/src/charts/Geomap/index.js.map +1 -1
  11. package/es/src/charts/Matrix/emit.js +5 -4
  12. package/es/src/charts/Matrix/emit.js.map +1 -1
  13. package/es/src/charts/Network/index.js +4 -0
  14. package/es/src/charts/Network/index.js.map +1 -1
  15. package/es/src/charts/Pack/emit.js +6 -6
  16. package/es/src/charts/Pack/emit.js.map +1 -1
  17. package/es/src/charts/Pack/index.js +2 -0
  18. package/es/src/charts/Pack/index.js.map +1 -1
  19. package/es/src/charts/Pie/emit.js +5 -6
  20. package/es/src/charts/Pie/emit.js.map +1 -1
  21. package/es/src/charts/Pie/index.js +2 -0
  22. package/es/src/charts/Pie/index.js.map +1 -1
  23. package/es/src/charts/Plot/index.js +15 -1
  24. package/es/src/charts/Plot/index.js.map +1 -1
  25. package/es/src/charts/Plot/insetRegion.js +21 -0
  26. package/es/src/charts/Plot/insetRegion.js.map +1 -0
  27. package/es/src/charts/Plot/sharedHover.js +117 -16
  28. package/es/src/charts/Plot/sharedHover.js.map +1 -1
  29. package/es/src/charts/Plot/sharedTooltip.js +35 -15
  30. package/es/src/charts/Plot/sharedTooltip.js.map +1 -1
  31. package/es/src/charts/Plot/trendLines.js +140 -38
  32. package/es/src/charts/Plot/trendLines.js.map +1 -1
  33. package/es/src/charts/Plot/trendProjection.js +120 -0
  34. package/es/src/charts/Plot/trendProjection.js.map +1 -0
  35. package/es/src/charts/Plot/trendScene.js +33 -19
  36. package/es/src/charts/Plot/trendScene.js.map +1 -1
  37. package/es/src/charts/Plot/trendTooltip.js +79 -17
  38. package/es/src/charts/Plot/trendTooltip.js.map +1 -1
  39. package/es/src/charts/Priestley/emit.js +3 -4
  40. package/es/src/charts/Priestley/emit.js.map +1 -1
  41. package/es/src/charts/RadialMatrix/emit.js +4 -4
  42. package/es/src/charts/RadialMatrix/emit.js.map +1 -1
  43. package/es/src/charts/Rings/index.js +5 -1
  44. package/es/src/charts/Rings/index.js.map +1 -1
  45. package/es/src/charts/Sankey/index.js +2 -0
  46. package/es/src/charts/Sankey/index.js.map +1 -1
  47. package/es/src/charts/Tree/index.js +2 -0
  48. package/es/src/charts/Tree/index.js.map +1 -1
  49. package/es/src/charts/Treemap/emit.js +3 -4
  50. package/es/src/charts/Treemap/emit.js.map +1 -1
  51. package/es/src/charts/definition/ChartDefinition.js.map +1 -1
  52. package/es/src/charts/definition/makeChart.js +8 -2
  53. package/es/src/charts/definition/makeChart.js.map +1 -1
  54. package/es/src/charts/drawSteps/bottomRightControls.js +3 -0
  55. package/es/src/charts/drawSteps/bottomRightControls.js.map +1 -1
  56. package/es/src/charts/drawSteps/bottomRightControlsMarkup.js +135 -4
  57. package/es/src/charts/drawSteps/bottomRightControlsMarkup.js.map +1 -1
  58. package/es/src/charts/drawSteps/searchControlsMarkup.js +15 -38
  59. package/es/src/charts/drawSteps/searchControlsMarkup.js.map +1 -1
  60. package/es/src/charts/events/click.legend.js +10 -5
  61. package/es/src/charts/events/click.legend.js.map +1 -1
  62. package/es/src/charts/events/mousemove.shape.js +8 -1
  63. package/es/src/charts/events/mousemove.shape.js.map +1 -1
  64. package/es/src/charts/features/emitHelpers.js +19 -5
  65. package/es/src/charts/features/emitHelpers.js.map +1 -1
  66. package/es/src/charts/features/features.js +3 -108
  67. package/es/src/charts/features/features.js.map +1 -1
  68. package/es/src/charts/features/featuresColorScale.js +161 -0
  69. package/es/src/charts/features/featuresColorScale.js.map +1 -0
  70. package/es/src/charts/features/featuresLegend.js +145 -32
  71. package/es/src/charts/features/featuresLegend.js.map +1 -1
  72. package/es/src/charts/features/insetState.js +174 -0
  73. package/es/src/charts/features/insetState.js.map +1 -0
  74. package/es/src/charts/features/sceneBounds.js +271 -0
  75. package/es/src/charts/features/sceneBounds.js.map +1 -0
  76. package/es/src/charts/features/tooltipSwatch.js +73 -0
  77. package/es/src/charts/features/tooltipSwatch.js.map +1 -0
  78. package/es/src/charts/pipeline/insetPlacement.js +406 -0
  79. package/es/src/charts/pipeline/insetPlacement.js.map +1 -0
  80. package/es/src/charts/pipeline/runVizPipeline.js +6 -2
  81. package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
  82. package/es/src/charts/viz/Viz.js +18 -3
  83. package/es/src/charts/viz/Viz.js.map +1 -1
  84. package/es/src/charts/viz/VizBaseConfig.js +20 -24
  85. package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
  86. package/es/src/charts/viz/interactionOpacity.js +21 -13
  87. package/es/src/charts/viz/interactionOpacity.js.map +1 -1
  88. package/es/src/charts/viz/linkGroup.js +386 -0
  89. package/es/src/charts/viz/linkGroup.js.map +1 -0
  90. package/es/src/charts/viz/sceneRows.js +33 -0
  91. package/es/src/charts/viz/sceneRows.js.map +1 -0
  92. package/es/src/charts/viz/vizDefaults.js +13 -8
  93. package/es/src/charts/viz/vizDefaults.js.map +1 -1
  94. package/es/src/charts/viz/vizTypes.js.map +1 -1
  95. package/es/src/components/Axis/AxisBottom.js +1 -1
  96. package/es/src/components/Axis/AxisBottom.js.map +1 -1
  97. package/es/src/components/Axis/AxisLeft.js +1 -1
  98. package/es/src/components/Axis/AxisLeft.js.map +1 -1
  99. package/es/src/components/Axis/AxisRight.js +1 -1
  100. package/es/src/components/Axis/AxisRight.js.map +1 -1
  101. package/es/src/components/Axis/AxisTop.js +1 -1
  102. package/es/src/components/Axis/AxisTop.js.map +1 -1
  103. package/es/src/components/Axis/axisLayoutLabels.js +13 -1
  104. package/es/src/components/Axis/axisLayoutLabels.js.map +1 -1
  105. package/es/src/components/ColorScale/ColorScale.js.map +1 -1
  106. package/es/src/components/Legend/legendConfig.js +2 -1
  107. package/es/src/components/Legend/legendConfig.js.map +1 -1
  108. package/es/src/components/Legend/legendRender.js +42 -5
  109. package/es/src/components/Legend/legendRender.js.map +1 -1
  110. package/es/src/components/TextBox.js +1 -1
  111. package/es/src/components/TextBox.js.map +1 -1
  112. package/es/src/shapes/Bar.js +1 -1
  113. package/es/src/shapes/Bar.js.map +1 -1
  114. package/es/src/shapes/Box.js +1 -1
  115. package/es/src/shapes/Box.js.map +1 -1
  116. package/es/src/shapes/Rect.js +1 -1
  117. package/es/src/shapes/Rect.js.map +1 -1
  118. package/es/src/shapes/Shape.js +9 -36
  119. package/es/src/shapes/Shape.js.map +1 -1
  120. package/es/src/shapes/Whisker.js +1 -1
  121. package/es/src/shapes/Whisker.js.map +1 -1
  122. package/es/src/shapes/textureKey.js +104 -0
  123. package/es/src/shapes/textureKey.js.map +1 -0
  124. package/es/src/utils/D3plusConfig.js.map +1 -1
  125. package/package.json +10 -9
  126. package/types/index.d.ts +1 -0
  127. package/types/internal.d.ts +7 -0
  128. package/types/src/charts/Plot/index.d.ts +8 -0
  129. package/types/src/charts/Plot/insetRegion.d.ts +4 -0
  130. package/types/src/charts/Plot/sharedHover.d.ts +5 -0
  131. package/types/src/charts/Plot/sharedTooltip.d.ts +10 -0
  132. package/types/src/charts/Plot/trendLines.d.ts +23 -3
  133. package/types/src/charts/Plot/trendProjection.d.ts +28 -0
  134. package/types/src/charts/Plot/trendScene.d.ts +2 -1
  135. package/types/src/charts/Plot/trendTooltip.d.ts +16 -5
  136. package/types/src/charts/definition/ChartDefinition.d.ts +9 -0
  137. package/types/src/charts/definition/makeChart.d.ts +2 -2
  138. package/types/src/charts/drawSteps/bottomRightControlsMarkup.d.ts +2 -0
  139. package/types/src/charts/drawSteps/searchControlsMarkup.d.ts +7 -5
  140. package/types/src/charts/features/emitHelpers.d.ts +10 -4
  141. package/types/src/charts/features/features.d.ts +1 -8
  142. package/types/src/charts/features/featuresColorScale.d.ts +24 -0
  143. package/types/src/charts/features/featuresLegend.d.ts +15 -0
  144. package/types/src/charts/features/insetState.d.ts +95 -0
  145. package/types/src/charts/features/sceneBounds.d.ts +18 -0
  146. package/types/src/charts/features/tooltipSwatch.d.ts +31 -0
  147. package/types/src/charts/pipeline/insetPlacement.d.ts +45 -0
  148. package/types/src/charts/pipeline/runVizPipeline.d.ts +2 -1
  149. package/types/src/charts/viz/Viz.d.ts +9 -1
  150. package/types/src/charts/viz/VizBaseConfig.d.ts +8 -12
  151. package/types/src/charts/viz/linkGroup.d.ts +96 -0
  152. package/types/src/charts/viz/sceneRows.d.ts +13 -0
  153. package/types/src/charts/viz/vizTypes.d.ts +17 -0
  154. package/types/src/components/Axis/AxisBottom.d.ts +1 -1
  155. package/types/src/components/Axis/AxisLeft.d.ts +1 -1
  156. package/types/src/components/Axis/AxisRight.d.ts +1 -1
  157. package/types/src/components/Axis/AxisTop.d.ts +1 -1
  158. package/types/src/components/ColorScale/ColorScale.d.ts +4 -4
  159. package/types/src/components/Legend/legendRender.d.ts +1 -1
  160. package/types/src/components/TextBox.d.ts +1 -1
  161. package/types/src/shapes/Bar.d.ts +1 -1
  162. package/types/src/shapes/Box.d.ts +1 -1
  163. package/types/src/shapes/Rect.d.ts +1 -1
  164. package/types/src/shapes/Whisker.d.ts +1 -1
  165. package/types/src/shapes/textureKey.d.ts +9 -0
  166. package/types/src/utils/D3plusConfig.d.ts +42 -1
  167. package/umd/d3plus-core.full.js +2393 -594
  168. package/umd/d3plus-core.full.js.map +1 -1
  169. package/umd/d3plus-core.full.min.js +1945 -1601
  170. package/umd/d3plus-core.js +1744 -404
  171. package/umd/d3plus-core.js.map +1 -1
  172. package/umd/d3plus-core.min.js +1401 -1087
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/charts/drawSteps/bottomRightControls.ts"],"sourcesContent":["/**\n @name bottomRightControlsFeature\n The bottom-right corner panel: chart chrome anchored in the corner below\n the chart body, currently the size legend. Like the top-left panel it's\n fed by independent contributor functions — a new corner item appends\n its own to `BOTTOM_RIGHT_CONTRIBUTORS`.\n\n Two steps, split around the chart's layout:\n 1. `reserveBottomRight` (called from `vizDrawPure`, before the legend\n and colorScale lay out) measures every contribution from a\n pre-layout estimate and stores the box on `viz._bottomRightBox`, so\n bottom-band content insets around it and the chart body stays\n clear of it.\n 2. `bottomRightControlsFeature` (post-draw, see `runVizPipeline`)\n paints each contribution from its final, laid-out state into the\n reserved box.\n\n @module\n*/\nimport {colorContrast} from \"@d3plus/color\";\nimport {backgroundColor} from \"@d3plus/dom\";\n\nimport type {FeatureModule} from \"../features/features.js\";\nimport {resolveSpec} from \"../pipeline/resolveSpec.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\nimport {zoomSizeLegendScale} from \"../../components/SizeLegend/sizeLegendLayout.js\";\nimport type {SizeLegendScale} from \"../../components/SizeLegend/sizeLegendLayout.js\";\nimport {buildBottomRightPanel, bottomRightControlsBox, measureBottomRight} from \"./bottomRightControlsMarkup.js\";\nimport type {BottomRightContribution} from \"./bottomRightControlsMarkup.js\";\n\n/** The chart area a contribution may size itself against, before layout. */\nexport interface BottomRightAvailable {\n width: number;\n height: number;\n}\n\n/** The text/stroke color that reads against the chart's background. */\nfunction inkColor(viz: VizInstance): string {\n const node = viz._select && typeof viz._select.node === \"function\" ? viz._select.node() : null;\n const bg = node ? backgroundColor(node) : \"rgb(255, 255, 255)\";\n return colorContrast(bg, viz.schema.colorDefaults);\n}\n\n/** Configures the size legend for a scale and lays it out, returning its size. */\nfunction layoutSizeLegend(viz: VizInstance, scale: SizeLegendScale): {width: number; height: number} {\n const ink = inkColor(viz);\n const legend = viz._sizeLegendClass!;\n legend\n .renderMode(\"compute\")\n .locale(viz.schema.locale)\n .title(viz._sizeKey)\n .labelConfig({fontColor: ink, fontFamily: viz.schema.fontFamily})\n .titleConfig({fontColor: ink, fontFamily: viz.schema.fontFamily})\n .lineConfig({stroke: ink})\n .shapeConfig({fill: ink, stroke: ink})\n .config(viz.schema.sizeLegendConfig)\n .scale(scale);\n const {width, height} = legend.layout();\n return {width, height};\n}\n\n/**\n The size legend's contribution: sized from the chart's pre-layout scale\n estimate, painted from the scale the chart's layout actually drew with.\n*/\nexport function sizeLegendContribution(\n viz: VizInstance,\n available: BottomRightAvailable,\n): BottomRightContribution | null {\n if (!viz._sizeLegendClass || typeof viz._sizeLegendScale !== \"function\") return null;\n const scale = viz._sizeLegendScale(available);\n if (!scale) return null;\n viz._sizeLegendClass._maxRadius = undefined;\n const {width, height} = layoutSizeLegend(viz, scale);\n if (!width || !height) return null;\n const size = {width, height, availableWidth: available.width, availableHeight: available.height};\n if (!viz.schema.sizeLegend.bind(viz)(resolveSpec(viz), scale, size)) return null;\n return {\n key: \"sizeLegend\",\n width,\n height,\n paint: zoom => {\n const final = viz._sizeLegendFinal;\n if (!final) return null;\n viz._sizeLegendClass!._maxRadius = zoom === 1 ? undefined : final(final.domain()[1]);\n const size = layoutSizeLegend(viz, zoomSizeLegendScale(final, zoom));\n if (!size.width || !size.height) return null;\n return {node: viz._sizeLegendClass!.toScene(), ...size};\n },\n };\n}\n\n/**\n Ordered contributors to the bottom-right panel, right to left.\n*/\nexport const BOTTOM_RIGHT_CONTRIBUTORS: Array<\n (viz: VizInstance, available: BottomRightAvailable) => BottomRightContribution | null\n> = [sizeLegendContribution];\n\n/**\n Measures the panel for this draw and stores it on `viz._bottomRightBox`\n (null when nothing contributes). `bottom` is how far above the chart's\n bottom edge the panel sits (below it: the timeline); `available` is the\n chart area left after the claims made so far. `sizeLegendPosition`\n picks the margin it claims (see `BottomRightBox.side`).\n*/\nexport function reserveBottomRight(\n viz: VizInstance,\n bottom: number,\n available: BottomRightAvailable,\n): void {\n const items: BottomRightContribution[] = [];\n for (const fn of BOTTOM_RIGHT_CONTRIBUTORS) {\n const c = fn(viz, available);\n if (c) items.push(c);\n }\n const side = viz.schema.sizeLegendPosition === \"bottom\" ? \"bottom\" : \"right\";\n viz._bottomRightBox = items.length ? {...measureBottomRight(items), bottom, side, items} : null;\n}\n\nexport const bottomRightControlsFeature: FeatureModule = {\n name: \"bottomRightControls\",\n configFields: [\"sizeLegend\", \"sizeLegendConfig\", \"sizeLegendPosition\"],\n layout: ({viz}) => {\n const box = bottomRightControlsBox(viz);\n return {panel: box ? buildBottomRightPanel(viz, box) : null, margin: {}};\n },\n};\n"],"names":["colorContrast","backgroundColor","resolveSpec","zoomSizeLegendScale","buildBottomRightPanel","bottomRightControlsBox","measureBottomRight","inkColor","viz","node","_select","bg","schema","colorDefaults","layoutSizeLegend","scale","ink","legend","_sizeLegendClass","renderMode","locale","title","_sizeKey","labelConfig","fontColor","fontFamily","titleConfig","lineConfig","stroke","shapeConfig","fill","config","sizeLegendConfig","layout","width","height","sizeLegendContribution","available","_sizeLegendScale","_maxRadius","undefined","size","availableWidth","availableHeight","sizeLegend","bind","key","paint","zoom","final","_sizeLegendFinal","domain","toScene","BOTTOM_RIGHT_CONTRIBUTORS","reserveBottomRight","bottom","items","fn","c","push","side","sizeLegendPosition","_bottomRightBox","length","bottomRightControlsFeature","name","configFields","box","panel","margin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;AAkBA,GACA,SAAQA,aAAa,QAAO,gBAAgB;AAC5C,SAAQC,eAAe,QAAO,cAAc;AAG5C,SAAQC,WAAW,QAAO,6BAA6B;AAEvD,SAAQC,mBAAmB,QAAO,kDAAkD;AAEpF,SAAQC,qBAAqB,EAAEC,sBAAsB,EAAEC,kBAAkB,QAAO,iCAAiC;AASjH,qEAAqE,GACrE,SAASC,SAASC,GAAgB;IAChC,IAAMC,OAAOD,IAAIE,OAAO,IAAI,OAAOF,IAAIE,OAAO,CAACD,IAAI,KAAK,aAAaD,IAAIE,OAAO,CAACD,IAAI,KAAK;IAC1F,IAAME,KAAKF,OAAOR,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AAMQ,6BAA4C;IACvDC,MAAM;IACNC,cAAc;QAAC;QAAc;QAAoB;KAAqB;IACtEjC,QAAQ,SAARA;YAAUzB,YAAAA;QACR,IAAM2D,MAAM9D,uBAAuBG;QACnC,OAAO;YAAC4D,OAAOD,MAAM/D,sBAAsBI,KAAK2D,OAAO;YAAME,QAAQ,CAAC;QAAC;IACzE;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../../src/charts/drawSteps/bottomRightControls.ts"],"sourcesContent":["/**\n @name bottomRightControlsFeature\n The bottom-right corner panel: chart chrome anchored in the corner below\n the chart body, currently the size legend. Like the top-left panel it's\n fed by independent contributor functions — a new corner item appends\n its own to `BOTTOM_RIGHT_CONTRIBUTORS`.\n\n Two steps, split around the chart's layout:\n 1. `reserveBottomRight` (called from `vizDrawPure`, before the legend\n and colorScale lay out) measures every contribution from a\n pre-layout estimate and stores the box on `viz._bottomRightBox`, so\n bottom-band content insets around it and the chart body stays\n clear of it.\n 2. `bottomRightControlsFeature` (post-draw, see `runVizPipeline`)\n paints each contribution from its final, laid-out state into the\n reserved box.\n\n @module\n*/\nimport {colorContrast} from \"@d3plus/color\";\nimport {backgroundColor} from \"@d3plus/dom\";\n\nimport type {FeatureModule} from \"../features/features.js\";\nimport {isInsetPending} from \"../features/insetState.js\";\nimport {resolveSpec} from \"../pipeline/resolveSpec.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\nimport {zoomSizeLegendScale} from \"../../components/SizeLegend/sizeLegendLayout.js\";\nimport type {SizeLegendScale} from \"../../components/SizeLegend/sizeLegendLayout.js\";\nimport {buildBottomRightPanel, bottomRightControlsBox, measureBottomRight} from \"./bottomRightControlsMarkup.js\";\nimport type {BottomRightContribution} from \"./bottomRightControlsMarkup.js\";\n\n/** The chart area a contribution may size itself against, before layout. */\nexport interface BottomRightAvailable {\n width: number;\n height: number;\n}\n\n/** The text/stroke color that reads against the chart's background. */\nfunction inkColor(viz: VizInstance): string {\n const node = viz._select && typeof viz._select.node === \"function\" ? viz._select.node() : null;\n const bg = node ? backgroundColor(node) : \"rgb(255, 255, 255)\";\n return colorContrast(bg, viz.schema.colorDefaults);\n}\n\n/** Configures the size legend for a scale and lays it out, returning its size. */\nfunction layoutSizeLegend(viz: VizInstance, scale: SizeLegendScale): {width: number; height: number} {\n const ink = inkColor(viz);\n const legend = viz._sizeLegendClass!;\n legend\n .renderMode(\"compute\")\n .locale(viz.schema.locale)\n .title(viz._sizeKey)\n .labelConfig({fontColor: ink, fontFamily: viz.schema.fontFamily})\n .titleConfig({fontColor: ink, fontFamily: viz.schema.fontFamily})\n .lineConfig({stroke: ink})\n .shapeConfig({fill: ink, stroke: ink})\n .config(viz.schema.sizeLegendConfig)\n .scale(scale);\n const {width, height} = legend.layout();\n return {width, height};\n}\n\n/**\n The size legend's contribution: sized from the chart's pre-layout scale\n estimate, painted from the scale the chart's layout actually drew with.\n*/\nexport function sizeLegendContribution(\n viz: VizInstance,\n available: BottomRightAvailable,\n): BottomRightContribution | null {\n if (!viz._sizeLegendClass || typeof viz._sizeLegendScale !== \"function\") return null;\n const scale = viz._sizeLegendScale(available);\n if (!scale) return null;\n viz._sizeLegendClass._maxRadius = undefined;\n const {width, height} = layoutSizeLegend(viz, scale);\n if (!width || !height) return null;\n const size = {width, height, availableWidth: available.width, availableHeight: available.height};\n if (!viz.schema.sizeLegend.bind(viz)(resolveSpec(viz), scale, size)) return null;\n return {\n key: \"sizeLegend\",\n width,\n height,\n paint: zoom => {\n const final = viz._sizeLegendFinal;\n if (!final) return null;\n viz._sizeLegendClass!._maxRadius = zoom === 1 ? undefined : final(final.domain()[1]);\n const size = layoutSizeLegend(viz, zoomSizeLegendScale(final, zoom));\n if (!size.width || !size.height) return null;\n return {node: viz._sizeLegendClass!.toScene(), ...size};\n },\n };\n}\n\n/**\n Ordered contributors to the bottom-right panel, right to left.\n*/\nexport const BOTTOM_RIGHT_CONTRIBUTORS: Array<\n (viz: VizInstance, available: BottomRightAvailable) => BottomRightContribution | null\n> = [sizeLegendContribution];\n\n/**\n Measures the panel for this draw and stores it on `viz._bottomRightBox`\n (null when nothing contributes). `bottom` is how far above the chart's\n bottom edge the panel sits (below it: the timeline); `available` is the\n chart area left after the claims made so far. `sizeLegendPosition`\n picks the margin it claims (see `BottomRightBox.side`).\n*/\nexport function reserveBottomRight(\n viz: VizInstance,\n bottom: number,\n available: BottomRightAvailable,\n): void {\n const items: BottomRightContribution[] = [];\n for (const fn of BOTTOM_RIGHT_CONTRIBUTORS) {\n const c = fn(viz, available);\n if (c) items.push(c);\n }\n const side = viz.schema.sizeLegendPosition === \"bottom\" ? \"bottom\" : \"right\";\n const inset = isInsetPending(viz, \"sizeLegend\");\n viz._bottomRightBox = items.length ? {...measureBottomRight(items), bottom, side, inset, items} : null;\n}\n\nexport const bottomRightControlsFeature: FeatureModule = {\n name: \"bottomRightControls\",\n configFields: [\"sizeLegend\", \"sizeLegendConfig\", \"sizeLegendPosition\"],\n layout: ({viz}) => {\n const box = bottomRightControlsBox(viz);\n return {panel: box ? buildBottomRightPanel(viz, box) : null, margin: {}};\n },\n};\n"],"names":["colorContrast","backgroundColor","isInsetPending","resolveSpec","zoomSizeLegendScale","buildBottomRightPanel","bottomRightControlsBox","measureBottomRight","inkColor","viz","node","_select","bg","schema","colorDefaults","layoutSizeLegend","scale","ink","legend","_sizeLegendClass","renderMode","locale","title","_sizeKey","labelConfig","fontColor","fontFamily","titleConfig","lineConfig","stroke","shapeConfig","fill","config","sizeLegendConfig","layout","width","height","sizeLegendContribution","available","_sizeLegendScale","_maxRadius","undefined","size","availableWidth","availableHeight","sizeLegend","bind","key","paint","zoom","final","_sizeLegendFinal","domain","toScene","BOTTOM_RIGHT_CONTRIBUTORS","reserveBottomRight","bottom","items","fn","c","push","side","sizeLegendPosition","inset","_bottomRightBox","length","bottomRightControlsFeature","name","configFields","box","panel","margin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;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AA;;QAAL,QAAK,YAAYH,8CAAZ,SAAA,6BAAA,QAAA,yBAAA,iCAAuC;YAAvC,IAAMI,KAAN;YACH,IAAMC,IAAID,GAAGjD,KAAK6B;YAClB,IAAIqB,GAAGF,MAAMG,IAAI,CAACD;QACpB;;QAHK;QAAA;;;iBAAA,6BAAA;gBAAA;;;gBAAA;sBAAA;;;;IAIL,IAAME,OAAOpD,IAAII,MAAM,CAACiD,kBAAkB,KAAK,WAAW,WAAW;IACrE,IAAMC,QAAQ7D,eAAeO,KAAK;IAClCA,IAAIuD,eAAe,GAAGP,MAAMQ,MAAM,GAAG,wCAAI1D,mBAAmBkD;QAAQD,QAAAA;QAAQK,MAAAA;QAAME,OAAAA;QAAON,OAAAA;SAAS;AACpG;AAEA,OAAO,IAAMS,6BAA4C;IACvDC,MAAM;IACNC,cAAc;QAAC;QAAc;QAAoB;KAAqB;IACtElC,QAAQ,SAARA;YAAUzB,YAAAA;QACR,IAAM4D,MAAM/D,uBAAuBG;QACnC,OAAO;YAAC6D,OAAOD,MAAMhE,sBAAsBI,KAAK4D,OAAO;YAAME,QAAQ,CAAC;QAAC;IACzE;AACF,EAAE"}
@@ -24,12 +24,64 @@
24
24
  function _array_without_holes(arr) {
25
25
  if (Array.isArray(arr)) return _array_like_to_array(arr);
26
26
  }
27
+ function _define_property(obj, key, value) {
28
+ if (key in obj) {
29
+ Object.defineProperty(obj, key, {
30
+ value: value,
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true
34
+ });
35
+ } else {
36
+ obj[key] = value;
37
+ }
38
+ return obj;
39
+ }
27
40
  function _iterable_to_array(iter) {
28
41
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
29
42
  }
30
43
  function _non_iterable_spread() {
31
44
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
32
45
  }
46
+ function _object_spread(target) {
47
+ for(var i = 1; i < arguments.length; i++){
48
+ var source = arguments[i] != null ? arguments[i] : {};
49
+ var ownKeys = Object.keys(source);
50
+ if (typeof Object.getOwnPropertySymbols === "function") {
51
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
52
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
53
+ }));
54
+ }
55
+ ownKeys.forEach(function(key) {
56
+ _define_property(target, key, source[key]);
57
+ });
58
+ }
59
+ return target;
60
+ }
61
+ function ownKeys(object, enumerableOnly) {
62
+ var keys = Object.keys(object);
63
+ if (Object.getOwnPropertySymbols) {
64
+ var symbols = Object.getOwnPropertySymbols(object);
65
+ if (enumerableOnly) {
66
+ symbols = symbols.filter(function(sym) {
67
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
68
+ });
69
+ }
70
+ keys.push.apply(keys, symbols);
71
+ }
72
+ return keys;
73
+ }
74
+ function _object_spread_props(target, source) {
75
+ source = source != null ? source : {};
76
+ if (Object.getOwnPropertyDescriptors) {
77
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
78
+ } else {
79
+ ownKeys(Object(source)).forEach(function(key) {
80
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
81
+ });
82
+ }
83
+ return target;
84
+ }
33
85
  function _to_consumable_array(arr) {
34
86
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
35
87
  }
@@ -41,6 +93,7 @@ function _unsupported_iterable_to_array(o, minLen) {
41
93
  if (n === "Map" || n === "Set") return Array.from(n);
42
94
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
43
95
  }
96
+ import { insetBackground, insetPlacementFor, insetStyle } from "../features/insetState.js";
44
97
  /** Horizontal gap between items, and between the panel and content inset around it. */ export var BOTTOM_RIGHT_GAP = 6;
45
98
  /** Lays contributions out in a row, right to left: the panel's total width and height. */ export function measureBottomRight(items) {
46
99
  var _Math;
@@ -61,6 +114,10 @@ function _unsupported_iterable_to_array(o, minLen) {
61
114
  var box = viz._bottomRightBox;
62
115
  return box && box.width && box.height ? box : null;
63
116
  }
117
+ /** The panel when it occupies the chart's corner, so margins and neighbors make room for it; null when it doesn't. */ function cornerBox(viz) {
118
+ var box = bottomRightControlsBox(viz);
119
+ return box && !box.inset ? box : null;
120
+ }
64
121
  /**
65
122
  How far content in the bottom band must pull in its right edge to clear
66
123
  the panel: content whose bottom edge sits `bottom` px above the chart's
@@ -68,7 +125,7 @@ function _unsupported_iterable_to_array(o, minLen) {
68
125
  right edge. Zero when nothing is showing or the content starts above the
69
126
  panel.
70
127
  */ export function bottomRightControlsInset(viz, bottom, right) {
71
- var box = bottomRightControlsBox(viz);
128
+ var box = cornerBox(viz);
72
129
  // A right-side panel already widened the right margin bottom content lays out against.
73
130
  if (!box || box.side === "right" || bottom >= box.bottom + box.height) return 0;
74
131
  var inset = box.width - right;
@@ -79,7 +136,7 @@ function _unsupported_iterable_to_array(o, minLen) {
79
136
  above the chart's bottom edge, must shorten to end above the panel. Zero
80
137
  when nothing is showing.
81
138
  */ export function bottomRightControlsDrop(viz, bottom) {
82
- var box = bottomRightControlsBox(viz);
139
+ var box = cornerBox(viz);
83
140
  if (!box) return 0;
84
141
  return Math.max(0, box.bottom + box.height - bottom);
85
142
  }
@@ -98,7 +155,7 @@ function _unsupported_iterable_to_array(o, minLen) {
98
155
  `bottom` px above the chart's bottom edge, stays clear of a bottom-side
99
156
  panel. Zero for a right-side panel.
100
157
  */ export function bottomRightControlsShortfall(viz, bottom) {
101
- var box = bottomRightControlsBox(viz);
158
+ var box = cornerBox(viz);
102
159
  return box && box.side === "bottom" ? Math.max(0, box.bottom + box.height - bottom) : 0;
103
160
  }
104
161
  /**
@@ -106,9 +163,82 @@ function _unsupported_iterable_to_array(o, minLen) {
106
163
  `right` px in from the chart's right edge, stays clear of a right-side
107
164
  panel. Zero for a bottom-side panel.
108
165
  */ export function bottomRightControlsRightShortfall(viz, right) {
109
- var box = bottomRightControlsBox(viz);
166
+ var box = cornerBox(viz);
110
167
  return box && box.side === "right" ? Math.max(0, box.width + BOTTOM_RIGHT_GAP - right) : 0;
111
168
  }
169
+ /**
170
+ The panel's scene when it's drawn inside the chart: the items painted
171
+ from their final state, in a row on a background box that hugs them,
172
+ aligned within the placed box the way the placement anchored it.
173
+ */ function buildInsetPanel(viz, box, zoom) {
174
+ var _Math;
175
+ var placed = insetPlacementFor(viz, "sizeLegend");
176
+ if (!placed) return null;
177
+ var margin = insetStyle(viz).margin;
178
+ var painted = box.items.map(function(item) {
179
+ return {
180
+ item: item,
181
+ paint: item.paint(zoom)
182
+ };
183
+ }).filter(function(p) {
184
+ return Boolean(p.paint);
185
+ });
186
+ if (!painted.length) return null;
187
+ var width = painted.reduce(function(w, p, i) {
188
+ return w + p.paint.width + (i ? BOTTOM_RIGHT_GAP : 0);
189
+ }, 0) + margin * 2;
190
+ var height = (_Math = Math).max.apply(_Math, _to_consumable_array(painted.map(function(p) {
191
+ return p.paint.height;
192
+ }))) + margin * 2;
193
+ var x = placed.alignX === "left" ? placed.x : placed.alignX === "center" ? placed.x + (placed.width - width) / 2 : placed.x + placed.width - width;
194
+ var y = placed.alignY === "top" ? placed.y : placed.alignY === "middle" ? placed.y + (placed.height - height) / 2 : placed.y + placed.height - height;
195
+ var children = [
196
+ insetBackground(viz, _object_spread_props(_object_spread({}, placed), {
197
+ x: x,
198
+ y: y,
199
+ width: width,
200
+ height: height
201
+ }))
202
+ ];
203
+ var right = x + width - margin;
204
+ var baseline = y + height - margin;
205
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
206
+ try {
207
+ for(var _iterator = painted[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
208
+ var _step_value = _step.value, item = _step_value.item, paint = _step_value.paint;
209
+ children.push({
210
+ type: "group",
211
+ key: item.key,
212
+ transform: {
213
+ x: right - paint.width,
214
+ y: baseline - paint.height
215
+ },
216
+ children: [
217
+ paint.node
218
+ ]
219
+ });
220
+ right -= paint.width + BOTTOM_RIGHT_GAP;
221
+ }
222
+ } catch (err) {
223
+ _didIteratorError = true;
224
+ _iteratorError = err;
225
+ } finally{
226
+ try {
227
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
228
+ _iterator.return();
229
+ }
230
+ } finally{
231
+ if (_didIteratorError) {
232
+ throw _iteratorError;
233
+ }
234
+ }
235
+ }
236
+ return {
237
+ type: "group",
238
+ key: "viz-bottomRight",
239
+ children: children
240
+ };
241
+ }
112
242
  /**
113
243
  The panel's scene: each item painted from its final state, bottom-right
114
244
  aligned in the slot it reserved. Null when nothing paints.
@@ -116,6 +246,7 @@ function _unsupported_iterable_to_array(o, minLen) {
116
246
  var _ref;
117
247
  var _viz__zoomTransform;
118
248
  var zoom = (_ref = (_viz__zoomTransform = viz._zoomTransform) === null || _viz__zoomTransform === void 0 ? void 0 : _viz__zoomTransform.scale) !== null && _ref !== void 0 ? _ref : 1;
249
+ if (box.inset) return buildInsetPanel(viz, box, zoom);
119
250
  var children = [];
120
251
  var right = viz.schema.width;
121
252
  var baseline = viz.schema.height - box.bottom;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/charts/drawSteps/bottomRightControlsMarkup.ts"],"sourcesContent":["/**\n Layout for the bottom-right corner panel — the bottom-corner counterpart\n of the top-right zoom-control panel. Its items (the size legend, today)\n are scene nodes rather than HTML, so the panel exports with the chart.\n\n The panel is measured before the chart lays out (`reserveBottomRight`,\n called from `vizDrawPure`), and the result is stored on\n `viz._bottomRightBox` so content sharing the bottom band (a bottom\n legend or colorScale) can inset around it via `bottomRightControlsInset`,\n and content in the right column can stop short of it via\n `bottomRightControlsDrop`. It paints after the chart lays out\n (`bottomRightControlsFeature`), from each item's final state.\n\n Kept separate from `bottomRightControls.ts` (the `FeatureModule` + the\n contributor list) so the legend/colorScale features can import the inset\n helpers without depending on the contributors.\n\n @module\n*/\n\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport type {VizInstance} from \"../viz/vizTypes.js\";\n\n/**\n One item's contribution to the bottom-right panel: its size as reserved\n before layout, and a `paint` that builds its scene after layout (its\n top-left at the origin) along with the size it actually drew at, which\n must not exceed the reservation. `zoom` is the scale the chart's picture\n is currently zoomed by (1 unzoomed; charts that zoom by rescaling axes,\n like Plot, always paint at 1).\n*/\nexport interface BottomRightContribution {\n key: string;\n width: number;\n height: number;\n paint: (zoom: number) => {node: SceneNode; width: number; height: number} | null;\n}\n\n/** The measured panel, as stored on `viz._bottomRightBox`. */\nexport interface BottomRightBox {\n width: number;\n height: number;\n /** Offset of the panel's bottom edge from the chart's bottom edge (the timeline sits below it). */\n bottom: number;\n /**\n The margin the panel claims: `\"right\"` widens the right margin so the\n chart body ends left of it (it shares the right column, below any\n right legend/colorScale); `\"bottom\"` deepens the bottom margin so the\n body ends above it (bottom legends/colorScales sit beside it).\n */\n side: \"right\" | \"bottom\";\n items: BottomRightContribution[];\n}\n\n/** Horizontal gap between items, and between the panel and content inset around it. */\nexport const BOTTOM_RIGHT_GAP = 6;\n\n/** Lays contributions out in a row, right to left: the panel's total width and height. */\nexport function measureBottomRight(items: BottomRightContribution[]): {width: number; height: number} {\n const width = items.reduce((w, item, i) => w + item.width + (i ? BOTTOM_RIGHT_GAP : 0), 0);\n const height = Math.max(0, ...items.map(item => item.height));\n return {width, height};\n}\n\n/** The panel reserved for this draw, or null when nothing is showing there. */\nexport function bottomRightControlsBox(viz: VizInstance): BottomRightBox | null {\n const box = viz._bottomRightBox;\n return box && box.width && box.height ? box : null;\n}\n\n/**\n How far content in the bottom band must pull in its right edge to clear\n the panel: content whose bottom edge sits `bottom` px above the chart's\n bottom edge and whose right edge sits `right` px in from the chart's\n right edge. Zero when nothing is showing or the content starts above the\n panel.\n*/\nexport function bottomRightControlsInset(viz: VizInstance, bottom: number, right: number): number {\n const box = bottomRightControlsBox(viz);\n // A right-side panel already widened the right margin bottom content lays out against.\n if (!box || box.side === \"right\" || bottom >= box.bottom + box.height) return 0;\n const inset = box.width - right;\n return inset > 0 ? inset + BOTTOM_RIGHT_GAP : 0;\n}\n\n/**\n How much content in the right column, whose bottom edge sits `bottom` px\n above the chart's bottom edge, must shorten to end above the panel. Zero\n when nothing is showing.\n*/\nexport function bottomRightControlsDrop(viz: VizInstance, bottom: number): number {\n const box = bottomRightControlsBox(viz);\n if (!box) return 0;\n return Math.max(0, box.bottom + box.height - bottom);\n}\n\n/**\n How a legend or colorScale at `position` clears the panel: a bottom one\n pulls its right edge in by `inset`, a left/right one shortens by `drop`.\n `bottom`/`right` are its edges' distances from the chart's bottom/right.\n*/\nexport function bottomRightClearance(\n viz: VizInstance,\n position: string | false,\n bottom: number,\n right: number,\n): {inset: number; drop: number} {\n return {\n inset: position === \"bottom\" ? bottomRightControlsInset(viz, bottom, right) : 0,\n drop: position === \"left\" || position === \"right\" ? bottomRightControlsDrop(viz, bottom) : 0,\n };\n}\n\n/**\n How much taller the bottom margin must grow so the chart body, ending\n `bottom` px above the chart's bottom edge, stays clear of a bottom-side\n panel. Zero for a right-side panel.\n*/\nexport function bottomRightControlsShortfall(viz: VizInstance, bottom: number): number {\n const box = bottomRightControlsBox(viz);\n return box && box.side === \"bottom\" ? Math.max(0, box.bottom + box.height - bottom) : 0;\n}\n\n/**\n How much wider the right margin must grow so the chart body, ending\n `right` px in from the chart's right edge, stays clear of a right-side\n panel. Zero for a bottom-side panel.\n*/\nexport function bottomRightControlsRightShortfall(viz: VizInstance, right: number): number {\n const box = bottomRightControlsBox(viz);\n return box && box.side === \"right\" ? Math.max(0, box.width + BOTTOM_RIGHT_GAP - right) : 0;\n}\n\n/**\n The panel's scene: each item painted from its final state, bottom-right\n aligned in the slot it reserved. Null when nothing paints.\n*/\nexport function buildBottomRightPanel(viz: VizInstance, box: BottomRightBox): SceneNode | null {\n const zoom = viz._zoomTransform?.scale ?? 1;\n const children: SceneNode[] = [];\n let right = viz.schema.width;\n const baseline = viz.schema.height - box.bottom;\n box.items.forEach(item => {\n const painted = item.paint(zoom);\n if (painted) {\n children.push({\n type: \"group\",\n key: item.key,\n transform: {x: right - painted.width, y: baseline - painted.height},\n children: [painted.node],\n });\n }\n right -= item.width + BOTTOM_RIGHT_GAP;\n });\n if (!children.length) return null;\n return {type: \"group\", key: \"viz-bottomRight\", children};\n}\n\n/**\n Repaints the panel in place for the current zoom — called on every zoom\n event, which repaints the scene without re-running the pipeline.\n*/\nexport function refreshBottomRightPanel(viz: VizInstance): void {\n const box = bottomRightControlsBox(viz);\n if (!box || !viz._featurePanels) return;\n const panels = viz._featurePanels.filter(p => p.key !== \"viz-bottomRight\");\n const panel = buildBottomRightPanel(viz, box);\n viz._featurePanels = panel ? [...panels, panel] : panels;\n}\n"],"names":["BOTTOM_RIGHT_GAP","measureBottomRight","items","Math","width","reduce","w","item","i","height","max","map","bottomRightControlsBox","viz","box","_bottomRightBox","bottomRightControlsInset","bottom","right","side","inset","bottomRightControlsDrop","bottomRightClearance","position","drop","bottomRightControlsShortfall","bottomRightControlsRightShortfall","buildBottomRightPanel","zoom","_zoomTransform","scale","children","schema","baseline","forEach","painted","paint","push","type","key","transform","x","y","node","length","refreshBottomRightPanel","_featurePanels","panels","filter","p","panel"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,qFAAqF,GACrF,OAAO,IAAMA,mBAAmB,EAAE;AAElC,wFAAwF,GACxF,OAAO,SAASC,mBAAmBC,KAAgC;QAElDC;IADf,IAAMC,QAAQF,MAAMG,MAAM,CAAC,SAACC,GAAGC,MAAMC;eAAMF,IAAIC,KAAKH,KAAK,GAAII,CAAAA,IAAIR,mBAAmB,CAAA;OAAI;IACxF,IAAMS,SAASN,CAAAA,QAAAA,MAAKO,GAAG,OAARP,OAAAA;QAAS;KAAqC,CAA9CA,OAAY,qBAAGD,MAAMS,GAAG,CAACJ,SAAAA;eAAQA,KAAKE,MAAM;;IAC3D,OAAO;QAAC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AAIiC,cAAc,GAAGI,QAAQ,AAAC,qBAAGH,eAAJ;QAAYG;KAAM,IAAGH;AACpD"}
1
+ {"version":3,"sources":["../../../../src/charts/drawSteps/bottomRightControlsMarkup.ts"],"sourcesContent":["/**\n Layout for the bottom-right corner panel — the bottom-corner counterpart\n of the top-right zoom-control panel. Its items (the size legend, today)\n are scene nodes rather than HTML, so the panel exports with the chart.\n\n The panel is measured before the chart lays out (`reserveBottomRight`,\n called from `vizDrawPure`), and the result is stored on\n `viz._bottomRightBox` so content sharing the bottom band (a bottom\n legend or colorScale) can inset around it via `bottomRightControlsInset`,\n and content in the right column can stop short of it via\n `bottomRightControlsDrop`. It paints after the chart lays out\n (`bottomRightControlsFeature`), from each item's final state.\n\n Kept separate from `bottomRightControls.ts` (the `FeatureModule` + the\n contributor list) so the legend/colorScale features can import the inset\n helpers without depending on the contributors.\n\n @module\n*/\n\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport type {VizInstance} from \"../viz/vizTypes.js\";\nimport {insetBackground, insetPlacementFor, insetStyle} from \"../features/insetState.js\";\n\n/**\n One item's contribution to the bottom-right panel: its size as reserved\n before layout, and a `paint` that builds its scene after layout (its\n top-left at the origin) along with the size it actually drew at, which\n must not exceed the reservation. `zoom` is the scale the chart's picture\n is currently zoomed by (1 unzoomed; charts that zoom by rescaling axes,\n like Plot, always paint at 1).\n*/\nexport interface BottomRightContribution {\n key: string;\n width: number;\n height: number;\n paint: (zoom: number) => {node: SceneNode; width: number; height: number} | null;\n}\n\n/** The measured panel, as stored on `viz._bottomRightBox`. */\nexport interface BottomRightBox {\n width: number;\n height: number;\n /** Offset of the panel's bottom edge from the chart's bottom edge (the timeline sits below it). */\n bottom: number;\n /**\n The margin the panel claims: `\"right\"` widens the right margin so the\n chart body ends left of it (it shares the right column, below any\n right legend/colorScale); `\"bottom\"` deepens the bottom margin so the\n body ends above it (bottom legends/colorScales sit beside it).\n */\n side: \"right\" | \"bottom\";\n /** Drawn inside the chart's negative space instead (see `pipeline/insetPlacement.ts`): claims no margin and nothing insets around it. */\n inset?: boolean;\n items: BottomRightContribution[];\n}\n\n/** Horizontal gap between items, and between the panel and content inset around it. */\nexport const BOTTOM_RIGHT_GAP = 6;\n\n/** Lays contributions out in a row, right to left: the panel's total width and height. */\nexport function measureBottomRight(items: BottomRightContribution[]): {width: number; height: number} {\n const width = items.reduce((w, item, i) => w + item.width + (i ? BOTTOM_RIGHT_GAP : 0), 0);\n const height = Math.max(0, ...items.map(item => item.height));\n return {width, height};\n}\n\n/** The panel reserved for this draw, or null when nothing is showing there. */\nexport function bottomRightControlsBox(viz: VizInstance): BottomRightBox | null {\n const box = viz._bottomRightBox;\n return box && box.width && box.height ? box : null;\n}\n\n/** The panel when it occupies the chart's corner, so margins and neighbors make room for it; null when it doesn't. */\nfunction cornerBox(viz: VizInstance): BottomRightBox | null {\n const box = bottomRightControlsBox(viz);\n return box && !box.inset ? box : null;\n}\n\n/**\n How far content in the bottom band must pull in its right edge to clear\n the panel: content whose bottom edge sits `bottom` px above the chart's\n bottom edge and whose right edge sits `right` px in from the chart's\n right edge. Zero when nothing is showing or the content starts above the\n panel.\n*/\nexport function bottomRightControlsInset(viz: VizInstance, bottom: number, right: number): number {\n const box = cornerBox(viz);\n // A right-side panel already widened the right margin bottom content lays out against.\n if (!box || box.side === \"right\" || bottom >= box.bottom + box.height) return 0;\n const inset = box.width - right;\n return inset > 0 ? inset + BOTTOM_RIGHT_GAP : 0;\n}\n\n/**\n How much content in the right column, whose bottom edge sits `bottom` px\n above the chart's bottom edge, must shorten to end above the panel. Zero\n when nothing is showing.\n*/\nexport function bottomRightControlsDrop(viz: VizInstance, bottom: number): number {\n const box = cornerBox(viz);\n if (!box) return 0;\n return Math.max(0, box.bottom + box.height - bottom);\n}\n\n/**\n How a legend or colorScale at `position` clears the panel: a bottom one\n pulls its right edge in by `inset`, a left/right one shortens by `drop`.\n `bottom`/`right` are its edges' distances from the chart's bottom/right.\n*/\nexport function bottomRightClearance(\n viz: VizInstance,\n position: string | false,\n bottom: number,\n right: number,\n): {inset: number; drop: number} {\n return {\n inset: position === \"bottom\" ? bottomRightControlsInset(viz, bottom, right) : 0,\n drop: position === \"left\" || position === \"right\" ? bottomRightControlsDrop(viz, bottom) : 0,\n };\n}\n\n/**\n How much taller the bottom margin must grow so the chart body, ending\n `bottom` px above the chart's bottom edge, stays clear of a bottom-side\n panel. Zero for a right-side panel.\n*/\nexport function bottomRightControlsShortfall(viz: VizInstance, bottom: number): number {\n const box = cornerBox(viz);\n return box && box.side === \"bottom\" ? Math.max(0, box.bottom + box.height - bottom) : 0;\n}\n\n/**\n How much wider the right margin must grow so the chart body, ending\n `right` px in from the chart's right edge, stays clear of a right-side\n panel. Zero for a bottom-side panel.\n*/\nexport function bottomRightControlsRightShortfall(viz: VizInstance, right: number): number {\n const box = cornerBox(viz);\n return box && box.side === \"right\" ? Math.max(0, box.width + BOTTOM_RIGHT_GAP - right) : 0;\n}\n\n/**\n The panel's scene when it's drawn inside the chart: the items painted\n from their final state, in a row on a background box that hugs them,\n aligned within the placed box the way the placement anchored it.\n*/\nfunction buildInsetPanel(viz: VizInstance, box: BottomRightBox, zoom: number): SceneNode | null {\n const placed = insetPlacementFor(viz, \"sizeLegend\");\n if (!placed) return null;\n const {margin} = insetStyle(viz);\n const painted = box.items\n .map(item => ({item, paint: item.paint(zoom)}))\n .filter((p): p is {item: BottomRightContribution; paint: NonNullable<ReturnType<BottomRightContribution[\"paint\"]>>} => Boolean(p.paint));\n if (!painted.length) return null;\n const width = painted.reduce((w, p, i) => w + p.paint.width + (i ? BOTTOM_RIGHT_GAP : 0), 0) + margin * 2;\n const height = Math.max(...painted.map(p => p.paint.height)) + margin * 2;\n const x = placed.alignX === \"left\"\n ? placed.x\n : placed.alignX === \"center\" ? placed.x + (placed.width - width) / 2 : placed.x + placed.width - width;\n const y = placed.alignY === \"top\"\n ? placed.y\n : placed.alignY === \"middle\" ? placed.y + (placed.height - height) / 2 : placed.y + placed.height - height;\n const children: SceneNode[] = [insetBackground(viz, {...placed, x, y, width, height})];\n let right = x + width - margin;\n const baseline = y + height - margin;\n for (const {item, paint} of painted) {\n children.push({\n type: \"group\",\n key: item.key,\n transform: {x: right - paint.width, y: baseline - paint.height},\n children: [paint.node],\n });\n right -= paint.width + BOTTOM_RIGHT_GAP;\n }\n return {type: \"group\", key: \"viz-bottomRight\", children};\n}\n\n/**\n The panel's scene: each item painted from its final state, bottom-right\n aligned in the slot it reserved. Null when nothing paints.\n*/\nexport function buildBottomRightPanel(viz: VizInstance, box: BottomRightBox): SceneNode | null {\n const zoom = viz._zoomTransform?.scale ?? 1;\n if (box.inset) return buildInsetPanel(viz, box, zoom);\n const children: SceneNode[] = [];\n let right = viz.schema.width;\n const baseline = viz.schema.height - box.bottom;\n box.items.forEach(item => {\n const painted = item.paint(zoom);\n if (painted) {\n children.push({\n type: \"group\",\n key: item.key,\n transform: {x: right - painted.width, y: baseline - painted.height},\n children: [painted.node],\n });\n }\n right -= item.width + BOTTOM_RIGHT_GAP;\n });\n if (!children.length) return null;\n return {type: \"group\", key: \"viz-bottomRight\", children};\n}\n\n/**\n Repaints the panel in place for the current zoom — called on every zoom\n event, which repaints the scene without re-running the pipeline.\n*/\nexport function refreshBottomRightPanel(viz: VizInstance): void {\n const box = bottomRightControlsBox(viz);\n if (!box || !viz._featurePanels) return;\n const panels = viz._featurePanels.filter(p => p.key !== \"viz-bottomRight\");\n const panel = buildBottomRightPanel(viz, box);\n viz._featurePanels = panel ? [...panels, panel] : panels;\n}\n"],"names":["insetBackground","insetPlacementFor","insetStyle","BOTTOM_RIGHT_GAP","measureBottomRight","items","Math","width","reduce","w","item","i","height","max","map","bottomRightControlsBox","viz","box","_bottomRightBox","cornerBox","inset","bottomRightControlsInset","bottom","right","side","bottomRightControlsDrop","bottomRightClearance","position","drop","bottomRightControlsShortfall","bottomRightControlsRightShortfall","buildInsetPanel","zoom","placed","margin","painted","paint","filter","p","Boolean","length","x","alignX","y","alignY","children","baseline","push","type","key","transform","node","buildBottomRightPanel","_zoomTransform","scale","schema","forEach","refreshBottomRightPanel","_featurePanels","panels","panel"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAAQA,eAAe,EAAEC,iBAAiB,EAAEC,UAAU,QAAO,4BAA4B;AAmCzF,qFAAqF,GACrF,OAAO,IAAMC,mBAAmB,EAAE;AAElC,wFAAwF,GACxF,OAAO,SAASC,mBAAmBC,KAAgC;QAElDC;IADf,IAAMC,QAAQF,MAAMG,MAAM,CAAC,SAACC,GAAGC,MAAMC;eAAMF,IAAIC,KAAKH,KAAK,GAAII,CAAAA,IAAIR,mBAAmB,CAAA;OAAI;IACxF,IAAMS,SAASN,CAAAA,QAAAA,MAAKO,GAAG,OAARP,OAAAA;QAAS;KAAqC,CAA9CA,OAAY,qBAAGD,MAAMS,GAAG,CAACJ,SAAAA;eAAQA,KAAKE,MAAM;;IAC3D,OAAO;QAACL,OAAAA;QAAOK,QAAAA;IAAM;AACvB;AAEA,6EAA6E,GAC7E,OAAO,SAASG,uBAAuBC,GAAgB;IACrD,IAAMC,MAAMD,IAAIE,eAAe;IAC/B,OAAOD,OAAOA,IAAIV,KAAK,IAAIU,IAAIL,MAAM,GAAGK,MAAM;AAChD;AAEA,oHAAoH,GACpH,SAASE,UAAUH,GAAgB;IACjC,IAAMC,MAAMF,uBAAuBC;IACnC,OAAOC,OAAO,CAACA,IAAIG,KAAK,GAAGH,MAAM;AACnC;AAEA;;;;;;AAMA,GACA,OAAO,SAASI,yBAAyBL,GAAgB,EAAEM,MAAc,EAAEC,KAAa;IACtF,IAAMN,MAAME,UAAUH;IACtB,uFAAuF;IACvF,IAAI,CAACC,OAAOA,IAAIO,IAAI,KAAK,WAAWF,UAAUL,IAAIK,MAAM,GAAGL,IAAIL,MAAM,EAAE,OAAO;IAC9E,IAAMQ,QAAQH,I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ACA,OAAO,SAASY,wBAAwBzC,GAAgB;IACtD,IAAMC,MAAMF,uBAAuBC;IACnC,IAAI,CAACC,OAAO,CAACD,IAAI0C,cAAc,EAAE;IACjC,IAAMC,SAAS3C,IAAI0C,cAAc,CAACrB,MAAM,CAACC,SAAAA;eAAKA,EAAEW,GAAG,KAAK;;IACxD,IAAMW,QAAQR,sBAAsBpC,KAAKC;IACzCD,IAAI0C,cAAc,GAAGE,QAAQ,AAAC,qBAAGD,eAAJ;QAAYC;KAAM,IAAGD;AACpD"}
@@ -109,6 +109,7 @@ function _unsupported_iterable_to_array(o, minLen) {
109
109
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
110
110
  }
111
111
  import { fontFamily, fontFamilyStringify } from "@d3plus/text";
112
+ import { forEachSceneRow } from "../viz/sceneRows.js";
112
113
  import { ICON_ATTRS, kebab } from "./zoomControlsMarkup.js";
113
114
  import { paintControlButton, resolveControlStyle } from "./controlButtonStyle.js";
114
115
  import { searchControlStyleActiveDefault, searchControlStyleDefault, searchControlStyleHoverDefault } from "../viz/vizDefaults.js";
@@ -356,51 +357,27 @@ function styleAttr(style) {
356
357
  return matchesSearchNeedle(viz, d, i, needle);
357
358
  };
358
359
  }
359
- /** Scene mark types a match is searched against — mirrors `interactionOpacity.ts`'s own `MARK_TYPES`. */ var MARK_TYPES = new Set([
360
- "rect",
361
- "circle",
362
- "line",
363
- "area",
364
- "path"
365
- ]);
366
360
  /**
367
361
  Every currently-rendered mark matching the given term, in scene order.
368
362
  Walks `viz._chartScene` (the actual painted scene, post-layout) rather
369
- than the raw data array, unwrapping each node's datum the same way
370
- `applyInteractionOpacity` does, so a grouped/aggregated chart matches by
371
- rendered mark, not by raw input row — and de-dupes by datum reference so
372
- a mark's separate label node doesn't double-count it. An empty term
373
- matches nothing (there's no "everything" state to jump through).
363
+ than the raw data array, via `forEachSceneRow` — the same row/index
364
+ resolution `applyInteractionOpacity` uses — so a grouped/aggregated chart
365
+ matches by rendered mark, not by raw input row, and the index a custom
366
+ searchAccessor sees always matches the one the highlight predicate was
367
+ evaluated with (Enter/Shift+Enter never jumps to a different mark than the
368
+ one that's actually highlighted). An empty term matches nothing (there's
369
+ no "everything" state to jump through).
374
370
  */ export function searchMatches(viz, term) {
375
371
  var needle = term.trim().toLowerCase();
376
372
  if (!needle) return [];
377
- var nodes = viz._chartScene || [];
378
- var seen = new Set();
379
373
  var results = [];
380
- var walk = function walk1(node) {
381
- if (MARK_TYPES.has(node.type) && node.datum !== undefined) {
382
- var raw = node.datum;
383
- var row = raw && raw.data ? raw.data : raw;
384
- if (row !== undefined && !seen.has(row)) {
385
- seen.add(row);
386
- // Mirrors applyInteractionOpacity's own fallback order exactly
387
- // (interactionOpacity.ts) — node.index, then the row's own `.i`,
388
- // then 0 — so the index a custom searchAccessor sees here always
389
- // matches the index the highlight predicate was evaluated with,
390
- // and Enter/Shift+Enter never jumps to a different mark than the
391
- // one that's actually highlighted.
392
- var i = typeof node.index === "number" ? node.index : typeof row.i === "number" ? row.i : 0;
393
- if (matchesSearchNeedle(viz, row, i, needle)) results.push({
394
- node: node,
395
- row: row,
396
- index: i
397
- });
398
- }
399
- }
400
- var kids = node.children;
401
- if (kids) kids.forEach(walk);
402
- };
403
- nodes.forEach(walk);
374
+ forEachSceneRow(viz._chartScene || [], function(row, i, node) {
375
+ if (matchesSearchNeedle(viz, row, i, needle)) results.push({
376
+ node: node,
377
+ row: row,
378
+ index: i
379
+ });
380
+ });
404
381
  return results;
405
382
  }
406
383
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/charts/drawSteps/searchControlsMarkup.ts"],"sourcesContent":["/**\n Markup, styling, and event handlers for the search control (a toggle\n button + an expanding text input) — the top-left counterpart to the\n zoom-controls panel's buttons, contributed into the shared top-left\n controls panel (`topLeftControls.ts`) alongside the back button. Kept as\n its own module rather than folded into `zoomControlsMarkup.ts`/\n `topLeftControlsMarkup.ts`: search is independent chrome a chart can mix\n and match with zoom/back, so its styling knobs stay uncoupled from\n theirs (matching the convention `zoomControlsMarkup.ts` itself notes for\n why zoom and table-view don't share styling code).\n\n @module\n*/\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {SceneNode} from \"@d3plus/render\";\nimport {fontFamily, fontFamilyStringify} from \"@d3plus/text\";\n\nimport type Viz from \"../viz/Viz.js\";\nimport {ICON_ATTRS, kebab} from \"./zoomControlsMarkup.js\";\nimport {paintControlButton, resolveControlStyle, type StyleObject} from \"./controlButtonStyle.js\";\nimport {\n searchControlStyleActiveDefault,\n searchControlStyleDefault,\n searchControlStyleHoverDefault,\n} from \"../viz/vizDefaults.js\";\n\n/** Search-open state is per-chart, read/written via `viz._searchOpen`. */\nexport function isSearchOpen(viz: Viz): boolean {\n return Boolean(viz._searchOpen);\n}\n\n/** The resolved base / active / hover button styles for a chart — also the cheap, non-DOM basis for `searchContribution`'s `styleSignature` (see `Contribution.styleSignature`). */\nexport function searchButtonStyles(viz: Viz): {base: StyleObject; active: StyleObject; hover: StyleObject} {\n const className = Boolean(viz.schema.searchControlClassName);\n return {\n base: resolveControlStyle(viz.schema.searchControlStyle, searchControlStyleDefault, className),\n active: resolveControlStyle(viz.schema.searchControlStyleActive, searchControlStyleActiveDefault, className),\n hover: resolveControlStyle(viz.schema.searchControlStyleHover, searchControlStyleHoverDefault, className),\n };\n}\n\n/** Paints the search toggle button's inline style for its current state. Mirrors `paintZoomButton`. */\nexport function paintSearchButton(viz: Viz, btn: HTMLElement, hovered = false): void {\n paintControlButton(btn, searchButtonStyles(viz), hovered, btn.classList.contains(\"active\"));\n}\n\n// A magnifying glass: a circle + a short diagonal handle. Nudged 1 unit\n// above the viewBox's true mathematical center (cy 10 → 9, the handle\n// shifted to match) — the ring's hollow center reads as lighter than the\n// handle's solid diagonal stroke, so a perfectly math-centered glass looks\n// optically low next to a symmetric icon like the back arrow's, even\n// though both render in pixel-identical boxes.\nconst SEARCH_ICON = `<svg ${ICON_ATTRS}><circle cx=\"10\" cy=\"9\" r=\"7\"/><line x1=\"21\" y1=\"20\" x2=\"15\" y2=\"14\"/></svg>`;\n// An X: two crossed diagonals, for the clear button.\nconst CLEAR_ICON = `<svg ${ICON_ATTRS}><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"/><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"/></svg>`;\n\n/**\n The input's inline style at rest (closed) vs. open — set directly by the\n toggle click handler, never regenerated mid-typing. Open's right padding\n reserves room for the clear button, which sits absolutely-positioned\n INSIDE the input's own box (see `SEARCH_CLEAR_STYLE_SHOWN`) rather than\n beside it, so typed text wraps short of it instead of running underneath.\n*/\nexport const SEARCH_INPUT_STYLE_CLOSED: Record<string, string> = {\n width: \"0\",\n padding: \"0\",\n border: \"none\",\n opacity: \"0\",\n \"pointer-events\": \"none\",\n};\nexport const SEARCH_INPUT_STYLE_OPEN: Record<string, string> = {\n width: \"120px\",\n padding: \"0 22px 0 6px\",\n border: \"1px solid #ccc\",\n \"border-radius\": \"3px\",\n opacity: \"1\",\n \"pointer-events\": \"auto\",\n};\n\nconst SEARCH_INPUT_BASE_STYLE: Record<string, string> = {\n height: \"20px\",\n \"box-sizing\": \"border-box\",\n // `inherit` picked up whatever font-size the host page's body/chart\n // container happened to set — often much larger than this 20px-tall\n // control was designed for. An explicit size matches the rest of the\n // panel (back/zoom's own buttons) regardless of the host page's CSS.\n font: `12px/1 ${fontFamilyStringify(fontFamily)}`,\n transition: \"width 0.15s ease, opacity 0.15s ease\",\n};\n\n/**\n The wrapper `.search-input-wrap` is the positioning context for both the\n clear button (absolute, inside the input's own box) and the match-count\n feedback (absolute, below it) — an `inline-block` with no explicit width\n of its own, so it always shrink-wraps to the input's CURRENT width\n (0 closed, 120px open) and the count box (`width: 100%`) automatically\n matches it.\n*/\nexport const SEARCH_INPUT_WRAP_STYLE: Record<string, string> = {\n position: \"relative\",\n display: \"inline-block\",\n};\n\n/**\n The root wrapper tying the toggle button and `.search-input-wrap` span\n together. Without it, the two sit as bare inline siblings and align by\n CSS's default inline baseline rule — which, since a `<button>` and an\n `<input>` differ in their UA-default box model (borders/padding under\n `content-box` vs. this module's explicit `border-box` on the input),\n doesn't actually land their content on the same visual center. `flex` +\n `align-items: center` centers both on their shared cross-axis instead,\n regardless of that box-model mismatch.\n*/\nconst SEARCH_ROOT_STYLE: Record<string, string> = {\n display: \"inline-flex\",\n \"align-items\": \"center\",\n};\n\n// The clear button and match-count feedback only ever show once there's a\n// term — both are toggled by the same `hasTerm` condition, at generation\n// time (`searchControlsHtml`) and imperatively while typing (`searchControls.ts`).\n// The hidden state uses `visibility: hidden`, not `display: none`, for the\n// clear button: it keeps its layout space reserved (matching the input's\n// permanent right padding) even while empty. The count box doesn't need\n// that — it's absolutely positioned below the input, so it never affects\n// the panel's own width/height either way.\nconst SEARCH_CLEAR_STYLE_SHOWN: Record<string, string> = {\n position: \"absolute\",\n top: \"50%\",\n right: \"2px\",\n transform: \"translateY(-50%)\",\n display: \"inline-flex\",\n \"align-items\": \"center\",\n \"justify-content\": \"center\",\n visibility: \"visible\",\n width: \"16px\",\n height: \"16px\",\n padding: \"0\",\n border: \"none\",\n background: \"none\",\n cursor: \"pointer\",\n};\nconst SEARCH_CLEAR_STYLE_HIDDEN: Record<string, string> = {...SEARCH_CLEAR_STYLE_SHOWN, visibility: \"hidden\", cursor: \"default\"};\n\n/**\n The match-count feedback sits directly below the input, at its same\n width, styled like the attribution box (`vizDefaults.ts`'s\n `attributionStyle` default) — a translucent white pill overlaying\n whatever chart content is beneath it. `pointer-events: none` so it never\n intercepts a click meant for the chart.\n*/\nconst SEARCH_COUNT_STYLE_SHOWN: Record<string, string> = {\n position: \"absolute\",\n top: \"100%\",\n left: \"0\",\n \"margin-top\": \"4px\",\n width: \"100%\",\n \"box-sizing\": \"border-box\",\n display: \"block\",\n visibility: \"visible\",\n background: \"rgba(255, 255, 255, 0.75)\",\n border: \"1px solid rgba(0, 0, 0, 0.25)\",\n color: \"rgba(0, 0, 0, 0.75)\",\n \"font-size\": \"11px\",\n \"text-align\": \"center\",\n padding: \"2px 4px\",\n \"white-space\": \"nowrap\",\n overflow: \"hidden\",\n \"text-overflow\": \"ellipsis\",\n \"pointer-events\": \"none\",\n};\nconst SEARCH_COUNT_STYLE_HIDDEN: Record<string, string> = {...SEARCH_COUNT_STYLE_SHOWN, visibility: \"hidden\"};\n\nfunction styleAttr(style: Record<string, string>): string {\n return Object.entries(style)\n .map(([k, v]) => `${kebab(k)}:${v}`)\n .join(\";\");\n}\n\n/** Applies the open/closed inline style directly to the input DOM node — no panel rebuild, so focus/cursor survive. */\nexport function applySearchInputOpenState(input: HTMLInputElement, open: boolean): void {\n const style = open ? SEARCH_INPUT_STYLE_OPEN : SEARCH_INPUT_STYLE_CLOSED;\n for (const key in style) input.style.setProperty(kebab(key), style[key]);\n}\n\n/** Shows/hides the clear button, directly on the DOM node — same no-rebuild pattern as the input's open state. */\nexport function applySearchClearVisible(btn: HTMLElement, visible: boolean): void {\n const style = visible ? SEARCH_CLEAR_STYLE_SHOWN : SEARCH_CLEAR_STYLE_HIDDEN;\n for (const key in style) btn.style.setProperty(kebab(key), style[key]);\n btn.tabIndex = visible ? 0 : -1;\n}\n\n/** Writes the match-count feedback's text/visibility directly onto the DOM node — visible whenever there's a term, regardless of whether it matched anything (\"No Matches\" is itself useful feedback). */\nexport function applySearchCount(viz: Viz, el: HTMLElement, hasTerm: boolean, index: number | undefined, total: number): void {\n const style = hasTerm ? SEARCH_COUNT_STYLE_SHOWN : SEARCH_COUNT_STYLE_HIDDEN;\n for (const key in style) el.style.setProperty(kebab(key), style[key]);\n const {text, label} = formatMatchCount(viz, index, total);\n el.textContent = hasTerm ? text : \"\";\n el.setAttribute(\"aria-label\", label);\n}\n\n/** Escapes a value for safe interpolation into `innerHTML`. */\nfunction escapeHtml(value: unknown): string {\n return String(value ?? \"\").replace(/[&<>\"']/g, c => (\n {\"&\": \"&amp;\", \"<\": \"&lt;\", \">\": \"&gt;\", '\"': \"&quot;\", \"'\": \"&#39;\"}[c] as string\n ));\n}\n\n/**\n The search control's markup: a toggle `<button>`, an `<input>`, a clear\n (×) button, and a match-count span — all real elements so host-page\n button/input styling applies through the cascade the same way zoom's\n buttons do. Term/open state is baked in from `viz._searchTerm`/\n `_searchOpen` so a full re-render (e.g. a resize or data change)\n preserves whatever the user was doing — typing itself never regenerates\n this markup (see `searchControls.ts`).\n\n The count span is left EMPTY here on purpose — its text is written by\n `searchContribution`'s `onUpdate` instead (see there), not baked into\n this string. `onUpdate` runs on every draw regardless of whether this\n html string changed, while the match count itself depends on the\n CHART's data/scene, not on the search box's own state — baking its text\n in here would make this contribution's own html change (and its DOM,\n including the live `<input>`, get torn down and rebuilt) every time the\n chart's data changes for a reason that has nothing to do with search,\n e.g. drilling down while the box is open and focused.\n*/\nexport function searchControlsHtml(viz: Viz): string {\n const extraClass = viz.schema.searchControlClassName ? ` ${viz.schema.searchControlClassName}` : \"\";\n const label = viz.schema.translate(\"Search\");\n const open = isSearchOpen(viz);\n const term = viz._searchTerm || \"\";\n const hasTerm = term.trim().length > 0;\n const inputStyle = styleAttr({...SEARCH_INPUT_BASE_STYLE, ...(open ? SEARCH_INPUT_STYLE_OPEN : SEARCH_INPUT_STYLE_CLOSED)});\n const clearStyle = styleAttr(hasTerm ? SEARCH_CLEAR_STYLE_SHOWN : SEARCH_CLEAR_STYLE_HIDDEN);\n const wrapStyle = styleAttr(SEARCH_INPUT_WRAP_STYLE);\n const rootStyle = styleAttr(SEARCH_ROOT_STYLE);\n return (\n `<span class=\"search-root\" style=\"${rootStyle}\">` +\n `<button type=\"button\" class=\"search-control search-toggle${open ? \" active\" : \"\"}${extraClass}\" aria-label=\"${label}\" aria-pressed=\"${open}\">${SEARCH_ICON}</button>` +\n `<span class=\"search-input-wrap\" style=\"${wrapStyle}\">` +\n `<input type=\"text\" class=\"search-control search-input\" placeholder=\"${label}\" aria-label=\"${label}\" value=\"${escapeHtml(term)}\" style=\"${inputStyle}\"${open ? \"\" : \" tabindex=\\\"-1\\\"\"}/>` +\n `<button type=\"button\" class=\"search-control search-clear\" aria-label=\"${viz.schema.translate(\"Clear\")}\" style=\"${clearStyle}\"${hasTerm ? \"\" : \" tabindex=\\\"-1\\\"\"}>${CLEAR_ICON}</button>` +\n `<span class=\"search-count\" aria-live=\"polite\"></span>` +\n `</span>` +\n `</span>`\n );\n}\n\n/**\n Whether `d` (row at index `i`) matches the (already-lowercased,\n already-trimmed) search `needle` — checked against\n `viz.schema.searchAccessor`'s resolved string, OR any level of `d`'s\n groupBy hierarchy (`viz._ids(d, i)`, one id string per groupBy field).\n\n The hierarchy check is what makes a match reach across drawn depth: a\n grouped chart's aggregate row (a Treemap's un-drilled parent cell, or a\n legend entry) is built by merging every leaf row it summarizes\n (`merge`/`objectMerge` in `@d3plus/data`), and a merged field that\n varies across those leaves survives as an ARRAY of every value seen —\n so an aggregate \"Group 2\" row's OWN `_ids()` output still contains\n \"Fig\" (search \"Fig\", match \"Group 2\"'s cell/legend entry) even though\n its rendered label is just \"Group 2\". The reverse direction needs no\n special-casing: a LEAF row's `_ids()` includes its ancestor's own\n (unmerged) id directly, so searching \"Group 2\" matches every one of its\n leaves too. Non-hierarchical charts (a single-field `groupBy`) degrade\n to exactly today's behavior — `_ids()` is a 1-element array equal to\n the accessor's own value.\n\n A custom `.searchAccessor()` isn't guaranteed to return a string for\n every row shape this runs against (the legend's own merged-aggregate\n rows differ in shape from a chart mark's row) — guard rather than let a\n non-string (commonly `undefined`) throw on `.toLowerCase()`.\n*/\nfunction matchesSearchNeedle(viz: Viz, d: DataPoint, i: number, needle: string): boolean {\n const value = viz.schema.searchAccessor(d, i);\n if (typeof value === \"string\" && value.toLowerCase().includes(needle)) return true;\n const ids = viz._ids(d, i) as string[];\n return ids.some(id => typeof id === \"string\" && id.toLowerCase().includes(needle));\n}\n\n/**\n Builds the predicate `.highlight()` drives from the current search term\n — see `matchesSearchNeedle` for the match rule. Empty term restores\n whatever `.highlight()` predicate (if any) was active before the search\n box opened.\n*/\nexport function searchHighlightPredicate(\n viz: Viz,\n term: string,\n): ((d: DataPoint, i: number) => boolean) | false {\n const needle = term.trim().toLowerCase();\n if (!needle) return viz._searchPrevHighlight ?? false;\n return (d: DataPoint, i: number) => matchesSearchNeedle(viz, d, i, needle);\n}\n\n/** Scene mark types a match is searched against — mirrors `interactionOpacity.ts`'s own `MARK_TYPES`. */\nconst MARK_TYPES = new Set([\"rect\", \"circle\", \"line\", \"area\", \"path\"]);\n\n/** One matching mark: its scene node (for `.key`/geometry), the unwrapped source row, and its index. */\nexport interface SearchMatch {\n node: SceneNode;\n row: DataPoint;\n index: number;\n}\n\n/**\n Every currently-rendered mark matching the given term, in scene order.\n Walks `viz._chartScene` (the actual painted scene, post-layout) rather\n than the raw data array, unwrapping each node's datum the same way\n `applyInteractionOpacity` does, so a grouped/aggregated chart matches by\n rendered mark, not by raw input row — and de-dupes by datum reference so\n a mark's separate label node doesn't double-count it. An empty term\n matches nothing (there's no \"everything\" state to jump through).\n*/\nexport function searchMatches(viz: Viz, term: string): SearchMatch[] {\n const needle = term.trim().toLowerCase();\n if (!needle) return [];\n const nodes = viz._chartScene || [];\n const seen = new Set<unknown>();\n const results: SearchMatch[] = [];\n const walk = (node: SceneNode): void => {\n if (MARK_TYPES.has(node.type) && node.datum !== undefined) {\n const raw = node.datum as (DataPoint & {data?: DataPoint}) | undefined;\n const row = (raw && raw.data ? raw.data : raw) as DataPoint;\n if (row !== undefined && !seen.has(row)) {\n seen.add(row);\n // Mirrors applyInteractionOpacity's own fallback order exactly\n // (interactionOpacity.ts) — node.index, then the row's own `.i`,\n // then 0 — so the index a custom searchAccessor sees here always\n // matches the index the highlight predicate was evaluated with,\n // and Enter/Shift+Enter never jumps to a different mark than the\n // one that's actually highlighted.\n const i =\n typeof node.index === \"number\"\n ? node.index\n : typeof (row as {i?: number}).i === \"number\"\n ? (row as {i: number}).i\n : 0;\n if (matchesSearchNeedle(viz, row, i, needle)) results.push({node, row, index: i});\n }\n }\n const kids = (node as {children?: SceneNode[]}).children;\n if (kids) kids.forEach(walk);\n };\n nodes.forEach(walk);\n return results;\n}\n\n/**\n Formats the match-count feedback as a readable, localized phrase:\n \"No Matches\" with nothing found, \"6 Matches\"/\"1 Match\" once there's a\n count but the user hasn't stepped to one yet (Enter/Shift+Enter), and\n \"Match 2/6\" once they have — the translated noun for context, plus a\n compact numeric position rather than a translated \"of\" connector, since\n a fixed English word order (\"Match 2 of 6\") wouldn't read naturally in\n every locale, while a number pair after a noun does. `index` is 0-based\n (`viz._searchMatchIndex`); `total` is `searchMatches(...).length`. Text\n and label are the same string — both visible and accessible.\n*/\nexport function formatMatchCount(viz: Viz, index: number | undefined, total: number): {text: string; label: string} {\n let text: string;\n if (total === 0) text = viz.schema.translate(\"No Matches\");\n else if (typeof index !== \"number\") text = `${total} ${viz.schema.translate(total === 1 ? \"Match\" : \"Matches\")}`;\n else text = `${viz.schema.translate(\"Match\")} ${index + 1}/${total}`;\n return {text, label: text};\n}\n\n/** Whether a chart shows the search control. */\nexport function showsSearchControls(viz: Viz): boolean {\n return Boolean(viz.schema.search) && !viz._ssr;\n}\n"],"names":["fontFamily","fontFamilyStringify","ICON_ATTRS","kebab","paintControlButton","resolveControlStyle","searchControlStyleActiveDefault","searchControlStyleDefault","searchControlStyleHoverDefault","isSearchOpen","viz","Boolean","_searchOpen","searchButtonStyles","className","schema","searchControlClassName","base","searchControlStyle","active","searchControlStyleActive","hover","searchControlStyleHover","paintSearchButton","btn","hovered","classList","contains","SEARCH_ICON","CLEAR_ICON","SEARCH_INPUT_STYLE_CLOSED","width","padding","border","opacity","SEARCH_INPUT_STYLE_OPEN","SEARCH_INPUT_BASE_STYLE","height","font","transition","SEARCH_INPUT_WRAP_STYLE","position","display","SEARCH_ROOT_STYLE","SEARCH_CLEAR_STYLE_SHOWN","top","right","transform","visibility","background","cursor","SEARCH_CLEAR_STYLE_HIDDEN","SEARCH_COUNT_STYLE_SHOWN","left","color","overflow","SEARCH_COUNT_STYLE_HIDDEN","styleAttr","style","Object","entries","map","k","v","join","applySearchInputOpenState","input","open","key","setProperty","applySearchClearVisible","visible","tabIndex","applySearchCount","el","hasTerm","index","total","formatMatchCount","text","label","textContent","setAttribute","escapeHtml","value","String","replace","c","searchControlsHtml","extraClass","translate","term","_searchTerm","trim","length","inputStyle","clearStyle","wrapStyle","rootStyle","matchesSearchNeedle","d","i","needle","searchAccessor","toLowerCase","includes","ids","_ids","some","id","searchHighlightPredicate","_searchPrevHighlight","MARK_TYPES","Set","searchMatches","nodes","_chartScene","seen","results","walk","node","has","type","datum","undefined","raw","row","data","add","push","kids","children","forEach","showsSearchControls","search","_ssr"],"mappings":"AAAA;;;;;;;;;;;;AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAQA,UAAU,EAAEC,mBAAmB,QAAO,eAAe;AAG7D,SAAQC,UAAU,EAAEC,KAAK,QAAO,0BAA0B;AAC1D,SAAQC,kBAAkB,EAAEC,mBAAmB,QAAyB,0BAA0B;AAClG,SACEC,+BAA+B,EAC/BC,yBAAyB,EACzBC,8BAA8B,QACzB,wBAAwB;AAE/B,wEAAwE,GACxE,OAAO,SAASC,aAAaC,GAAQ;IACnC,OAAOC,QAAQD,IAAIE,WAAW;AAChC;AAEA,kLAAkL,GAClL,OAAO,SAASC,mBAAmBH,GAAQ;IACzC,IAAMI,YAAYH,QAAQD,IAAIK,MAAM,CAACC,sBAAsB;IAC3D,OAAO;QACLC,MAAMZ,oBAAoBK,IAAIK,MAAM,CAACG,kBAAkB,EAAEX,2BAA2BO;QACpFK,QAAQd,oBAAoBK,IAAIK,MAAM,CAACK,wBAAwB,EAAEd,iCAAiCQ;QAClGO,OAAOhB,oBAAoBK,IAAIK,MAAM,CAACO,uBAAuB,EAAEd,gCAAgCM;IACjG;AACF;AAEA,qGAAqG,GACrG,OAAO,S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OAAO,AAAC,GAAmCH,OAAjClE,IAAIK,MAAM,CAAC2E,SAAS,CAAC,UAAS,KAAgBb,OAAbD,QAAQ,GAAE,KAAS,OAANC;IAC7D,OAAO;QAACE,MAAAA;QAAMC,OAAOD;IAAI;AAC3B;AAEA,8CAA8C,GAC9C,OAAO,SAASsD,oBAAoB3H,GAAQ;IAC1C,OAAOC,QAAQD,IAAIK,MAAM,CAACuH,MAAM,KAAK,CAAC5H,IAAI6H,IAAI;AAChD"}
1
+ {"version":3,"sources":["../../../../src/charts/drawSteps/searchControlsMarkup.ts"],"sourcesContent":["/**\n Markup, styling, and event handlers for the search control (a toggle\n button + an expanding text input) — the top-left counterpart to the\n zoom-controls panel's buttons, contributed into the shared top-left\n controls panel (`topLeftControls.ts`) alongside the back button. Kept as\n its own module rather than folded into `zoomControlsMarkup.ts`/\n `topLeftControlsMarkup.ts`: search is independent chrome a chart can mix\n and match with zoom/back, so its styling knobs stay uncoupled from\n theirs (matching the convention `zoomControlsMarkup.ts` itself notes for\n why zoom and table-view don't share styling code).\n\n @module\n*/\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {SceneNode} from \"@d3plus/render\";\nimport {fontFamily, fontFamilyStringify} from \"@d3plus/text\";\n\nimport {forEachSceneRow} from \"../viz/sceneRows.js\";\nimport type Viz from \"../viz/Viz.js\";\nimport {ICON_ATTRS, kebab} from \"./zoomControlsMarkup.js\";\nimport {paintControlButton, resolveControlStyle, type StyleObject} from \"./controlButtonStyle.js\";\nimport {\n searchControlStyleActiveDefault,\n searchControlStyleDefault,\n searchControlStyleHoverDefault,\n} from \"../viz/vizDefaults.js\";\n\n/** Search-open state is per-chart, read/written via `viz._searchOpen`. */\nexport function isSearchOpen(viz: Viz): boolean {\n return Boolean(viz._searchOpen);\n}\n\n/** The resolved base / active / hover button styles for a chart — also the cheap, non-DOM basis for `searchContribution`'s `styleSignature` (see `Contribution.styleSignature`). */\nexport function searchButtonStyles(viz: Viz): {base: StyleObject; active: StyleObject; hover: StyleObject} {\n const className = Boolean(viz.schema.searchControlClassName);\n return {\n base: resolveControlStyle(viz.schema.searchControlStyle, searchControlStyleDefault, className),\n active: resolveControlStyle(viz.schema.searchControlStyleActive, searchControlStyleActiveDefault, className),\n hover: resolveControlStyle(viz.schema.searchControlStyleHover, searchControlStyleHoverDefault, className),\n };\n}\n\n/** Paints the search toggle button's inline style for its current state. Mirrors `paintZoomButton`. */\nexport function paintSearchButton(viz: Viz, btn: HTMLElement, hovered = false): void {\n paintControlButton(btn, searchButtonStyles(viz), hovered, btn.classList.contains(\"active\"));\n}\n\n// A magnifying glass: a circle + a short diagonal handle. Nudged 1 unit\n// above the viewBox's true mathematical center (cy 10 → 9, the handle\n// shifted to match) — the ring's hollow center reads as lighter than the\n// handle's solid diagonal stroke, so a perfectly math-centered glass looks\n// optically low next to a symmetric icon like the back arrow's, even\n// though both render in pixel-identical boxes.\nconst SEARCH_ICON = `<svg ${ICON_ATTRS}><circle cx=\"10\" cy=\"9\" r=\"7\"/><line x1=\"21\" y1=\"20\" x2=\"15\" y2=\"14\"/></svg>`;\n// An X: two crossed diagonals, for the clear button.\nconst CLEAR_ICON = `<svg ${ICON_ATTRS}><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"/><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"/></svg>`;\n\n/**\n The input's inline style at rest (closed) vs. open — set directly by the\n toggle click handler, never regenerated mid-typing. Open's right padding\n reserves room for the clear button, which sits absolutely-positioned\n INSIDE the input's own box (see `SEARCH_CLEAR_STYLE_SHOWN`) rather than\n beside it, so typed text wraps short of it instead of running underneath.\n*/\nexport const SEARCH_INPUT_STYLE_CLOSED: Record<string, string> = {\n width: \"0\",\n padding: \"0\",\n border: \"none\",\n opacity: \"0\",\n \"pointer-events\": \"none\",\n};\nexport const SEARCH_INPUT_STYLE_OPEN: Record<string, string> = {\n width: \"120px\",\n padding: \"0 22px 0 6px\",\n border: \"1px solid #ccc\",\n \"border-radius\": \"3px\",\n opacity: \"1\",\n \"pointer-events\": \"auto\",\n};\n\nconst SEARCH_INPUT_BASE_STYLE: Record<string, string> = {\n height: \"20px\",\n \"box-sizing\": \"border-box\",\n // `inherit` picked up whatever font-size the host page's body/chart\n // container happened to set — often much larger than this 20px-tall\n // control was designed for. An explicit size matches the rest of the\n // panel (back/zoom's own buttons) regardless of the host page's CSS.\n font: `12px/1 ${fontFamilyStringify(fontFamily)}`,\n transition: \"width 0.15s ease, opacity 0.15s ease\",\n};\n\n/**\n The wrapper `.search-input-wrap` is the positioning context for both the\n clear button (absolute, inside the input's own box) and the match-count\n feedback (absolute, below it) — an `inline-block` with no explicit width\n of its own, so it always shrink-wraps to the input's CURRENT width\n (0 closed, 120px open) and the count box (`width: 100%`) automatically\n matches it.\n*/\nexport const SEARCH_INPUT_WRAP_STYLE: Record<string, string> = {\n position: \"relative\",\n display: \"inline-block\",\n};\n\n/**\n The root wrapper tying the toggle button and `.search-input-wrap` span\n together. Without it, the two sit as bare inline siblings and align by\n CSS's default inline baseline rule — which, since a `<button>` and an\n `<input>` differ in their UA-default box model (borders/padding under\n `content-box` vs. this module's explicit `border-box` on the input),\n doesn't actually land their content on the same visual center. `flex` +\n `align-items: center` centers both on their shared cross-axis instead,\n regardless of that box-model mismatch.\n*/\nconst SEARCH_ROOT_STYLE: Record<string, string> = {\n display: \"inline-flex\",\n \"align-items\": \"center\",\n};\n\n// The clear button and match-count feedback only ever show once there's a\n// term — both are toggled by the same `hasTerm` condition, at generation\n// time (`searchControlsHtml`) and imperatively while typing (`searchControls.ts`).\n// The hidden state uses `visibility: hidden`, not `display: none`, for the\n// clear button: it keeps its layout space reserved (matching the input's\n// permanent right padding) even while empty. The count box doesn't need\n// that — it's absolutely positioned below the input, so it never affects\n// the panel's own width/height either way.\nconst SEARCH_CLEAR_STYLE_SHOWN: Record<string, string> = {\n position: \"absolute\",\n top: \"50%\",\n right: \"2px\",\n transform: \"translateY(-50%)\",\n display: \"inline-flex\",\n \"align-items\": \"center\",\n \"justify-content\": \"center\",\n visibility: \"visible\",\n width: \"16px\",\n height: \"16px\",\n padding: \"0\",\n border: \"none\",\n background: \"none\",\n cursor: \"pointer\",\n};\nconst SEARCH_CLEAR_STYLE_HIDDEN: Record<string, string> = {...SEARCH_CLEAR_STYLE_SHOWN, visibility: \"hidden\", cursor: \"default\"};\n\n/**\n The match-count feedback sits directly below the input, at its same\n width, styled like the attribution box (`vizDefaults.ts`'s\n `attributionStyle` default) — a translucent white pill overlaying\n whatever chart content is beneath it. `pointer-events: none` so it never\n intercepts a click meant for the chart.\n*/\nconst SEARCH_COUNT_STYLE_SHOWN: Record<string, string> = {\n position: \"absolute\",\n top: \"100%\",\n left: \"0\",\n \"margin-top\": \"4px\",\n width: \"100%\",\n \"box-sizing\": \"border-box\",\n display: \"block\",\n visibility: \"visible\",\n background: \"rgba(255, 255, 255, 0.75)\",\n border: \"1px solid rgba(0, 0, 0, 0.25)\",\n color: \"rgba(0, 0, 0, 0.75)\",\n \"font-size\": \"11px\",\n \"text-align\": \"center\",\n padding: \"2px 4px\",\n \"white-space\": \"nowrap\",\n overflow: \"hidden\",\n \"text-overflow\": \"ellipsis\",\n \"pointer-events\": \"none\",\n};\nconst SEARCH_COUNT_STYLE_HIDDEN: Record<string, string> = {...SEARCH_COUNT_STYLE_SHOWN, visibility: \"hidden\"};\n\nfunction styleAttr(style: Record<string, string>): string {\n return Object.entries(style)\n .map(([k, v]) => `${kebab(k)}:${v}`)\n .join(\";\");\n}\n\n/** Applies the open/closed inline style directly to the input DOM node — no panel rebuild, so focus/cursor survive. */\nexport function applySearchInputOpenState(input: HTMLInputElement, open: boolean): void {\n const style = open ? SEARCH_INPUT_STYLE_OPEN : SEARCH_INPUT_STYLE_CLOSED;\n for (const key in style) input.style.setProperty(kebab(key), style[key]);\n}\n\n/** Shows/hides the clear button, directly on the DOM node — same no-rebuild pattern as the input's open state. */\nexport function applySearchClearVisible(btn: HTMLElement, visible: boolean): void {\n const style = visible ? SEARCH_CLEAR_STYLE_SHOWN : SEARCH_CLEAR_STYLE_HIDDEN;\n for (const key in style) btn.style.setProperty(kebab(key), style[key]);\n btn.tabIndex = visible ? 0 : -1;\n}\n\n/** Writes the match-count feedback's text/visibility directly onto the DOM node — visible whenever there's a term, regardless of whether it matched anything (\"No Matches\" is itself useful feedback). */\nexport function applySearchCount(viz: Viz, el: HTMLElement, hasTerm: boolean, index: number | undefined, total: number): void {\n const style = hasTerm ? SEARCH_COUNT_STYLE_SHOWN : SEARCH_COUNT_STYLE_HIDDEN;\n for (const key in style) el.style.setProperty(kebab(key), style[key]);\n const {text, label} = formatMatchCount(viz, index, total);\n el.textContent = hasTerm ? text : \"\";\n el.setAttribute(\"aria-label\", label);\n}\n\n/** Escapes a value for safe interpolation into `innerHTML`. */\nfunction escapeHtml(value: unknown): string {\n return String(value ?? \"\").replace(/[&<>\"']/g, c => (\n {\"&\": \"&amp;\", \"<\": \"&lt;\", \">\": \"&gt;\", '\"': \"&quot;\", \"'\": \"&#39;\"}[c] as string\n ));\n}\n\n/**\n The search control's markup: a toggle `<button>`, an `<input>`, a clear\n (×) button, and a match-count span — all real elements so host-page\n button/input styling applies through the cascade the same way zoom's\n buttons do. Term/open state is baked in from `viz._searchTerm`/\n `_searchOpen` so a full re-render (e.g. a resize or data change)\n preserves whatever the user was doing — typing itself never regenerates\n this markup (see `searchControls.ts`).\n\n The count span is left EMPTY here on purpose — its text is written by\n `searchContribution`'s `onUpdate` instead (see there), not baked into\n this string. `onUpdate` runs on every draw regardless of whether this\n html string changed, while the match count itself depends on the\n CHART's data/scene, not on the search box's own state — baking its text\n in here would make this contribution's own html change (and its DOM,\n including the live `<input>`, get torn down and rebuilt) every time the\n chart's data changes for a reason that has nothing to do with search,\n e.g. drilling down while the box is open and focused.\n*/\nexport function searchControlsHtml(viz: Viz): string {\n const extraClass = viz.schema.searchControlClassName ? ` ${viz.schema.searchControlClassName}` : \"\";\n const label = viz.schema.translate(\"Search\");\n const open = isSearchOpen(viz);\n const term = viz._searchTerm || \"\";\n const hasTerm = term.trim().length > 0;\n const inputStyle = styleAttr({...SEARCH_INPUT_BASE_STYLE, ...(open ? SEARCH_INPUT_STYLE_OPEN : SEARCH_INPUT_STYLE_CLOSED)});\n const clearStyle = styleAttr(hasTerm ? SEARCH_CLEAR_STYLE_SHOWN : SEARCH_CLEAR_STYLE_HIDDEN);\n const wrapStyle = styleAttr(SEARCH_INPUT_WRAP_STYLE);\n const rootStyle = styleAttr(SEARCH_ROOT_STYLE);\n return (\n `<span class=\"search-root\" style=\"${rootStyle}\">` +\n `<button type=\"button\" class=\"search-control search-toggle${open ? \" active\" : \"\"}${extraClass}\" aria-label=\"${label}\" aria-pressed=\"${open}\">${SEARCH_ICON}</button>` +\n `<span class=\"search-input-wrap\" style=\"${wrapStyle}\">` +\n `<input type=\"text\" class=\"search-control search-input\" placeholder=\"${label}\" aria-label=\"${label}\" value=\"${escapeHtml(term)}\" style=\"${inputStyle}\"${open ? \"\" : \" tabindex=\\\"-1\\\"\"}/>` +\n `<button type=\"button\" class=\"search-control search-clear\" aria-label=\"${viz.schema.translate(\"Clear\")}\" style=\"${clearStyle}\"${hasTerm ? \"\" : \" tabindex=\\\"-1\\\"\"}>${CLEAR_ICON}</button>` +\n `<span class=\"search-count\" aria-live=\"polite\"></span>` +\n `</span>` +\n `</span>`\n );\n}\n\n/**\n Whether `d` (row at index `i`) matches the (already-lowercased,\n already-trimmed) search `needle` — checked against\n `viz.schema.searchAccessor`'s resolved string, OR any level of `d`'s\n groupBy hierarchy (`viz._ids(d, i)`, one id string per groupBy field).\n\n The hierarchy check is what makes a match reach across drawn depth: a\n grouped chart's aggregate row (a Treemap's un-drilled parent cell, or a\n legend entry) is built by merging every leaf row it summarizes\n (`merge`/`objectMerge` in `@d3plus/data`), and a merged field that\n varies across those leaves survives as an ARRAY of every value seen —\n so an aggregate \"Group 2\" row's OWN `_ids()` output still contains\n \"Fig\" (search \"Fig\", match \"Group 2\"'s cell/legend entry) even though\n its rendered label is just \"Group 2\". The reverse direction needs no\n special-casing: a LEAF row's `_ids()` includes its ancestor's own\n (unmerged) id directly, so searching \"Group 2\" matches every one of its\n leaves too. Non-hierarchical charts (a single-field `groupBy`) degrade\n to exactly today's behavior — `_ids()` is a 1-element array equal to\n the accessor's own value.\n\n A custom `.searchAccessor()` isn't guaranteed to return a string for\n every row shape this runs against (the legend's own merged-aggregate\n rows differ in shape from a chart mark's row) — guard rather than let a\n non-string (commonly `undefined`) throw on `.toLowerCase()`.\n*/\nfunction matchesSearchNeedle(viz: Viz, d: DataPoint, i: number, needle: string): boolean {\n const value = viz.schema.searchAccessor(d, i);\n if (typeof value === \"string\" && value.toLowerCase().includes(needle)) return true;\n const ids = viz._ids(d, i) as string[];\n return ids.some(id => typeof id === \"string\" && id.toLowerCase().includes(needle));\n}\n\n/**\n Builds the predicate `.highlight()` drives from the current search term\n — see `matchesSearchNeedle` for the match rule. Empty term restores\n whatever `.highlight()` predicate (if any) was active before the search\n box opened.\n*/\nexport function searchHighlightPredicate(\n viz: Viz,\n term: string,\n): ((d: DataPoint, i: number) => boolean) | false {\n const needle = term.trim().toLowerCase();\n if (!needle) return viz._searchPrevHighlight ?? false;\n return (d: DataPoint, i: number) => matchesSearchNeedle(viz, d, i, needle);\n}\n\n/** One matching mark: its scene node (for `.key`/geometry), the unwrapped source row, and its index. */\nexport interface SearchMatch {\n node: SceneNode;\n row: DataPoint;\n index: number;\n}\n\n/**\n Every currently-rendered mark matching the given term, in scene order.\n Walks `viz._chartScene` (the actual painted scene, post-layout) rather\n than the raw data array, via `forEachSceneRow` — the same row/index\n resolution `applyInteractionOpacity` uses — so a grouped/aggregated chart\n matches by rendered mark, not by raw input row, and the index a custom\n searchAccessor sees always matches the one the highlight predicate was\n evaluated with (Enter/Shift+Enter never jumps to a different mark than the\n one that's actually highlighted). An empty term matches nothing (there's\n no \"everything\" state to jump through).\n*/\nexport function searchMatches(viz: Viz, term: string): SearchMatch[] {\n const needle = term.trim().toLowerCase();\n if (!needle) return [];\n const results: SearchMatch[] = [];\n forEachSceneRow(viz._chartScene || [], (row, i, node) => {\n if (matchesSearchNeedle(viz, row, i, needle)) results.push({node, row, index: i});\n });\n return results;\n}\n\n/**\n Formats the match-count feedback as a readable, localized phrase:\n \"No Matches\" with nothing found, \"6 Matches\"/\"1 Match\" once there's a\n count but the user hasn't stepped to one yet (Enter/Shift+Enter), and\n \"Match 2/6\" once they have — the translated noun for context, plus a\n compact numeric position rather than a translated \"of\" connector, since\n a fixed English word order (\"Match 2 of 6\") wouldn't read naturally in\n every locale, while a number pair after a noun does. `index` is 0-based\n (`viz._searchMatchIndex`); `total` is `searchMatches(...).length`. Text\n and label are the same string — both visible and accessible.\n*/\nexport function formatMatchCount(viz: Viz, index: number | undefined, total: number): {text: string; label: string} {\n let text: string;\n if (total === 0) text = viz.schema.translate(\"No Matches\");\n else if (typeof index !== \"number\") text = `${total} ${viz.schema.translate(total === 1 ? \"Match\" : \"Matches\")}`;\n else text = `${viz.schema.translate(\"Match\")} ${index + 1}/${total}`;\n return {text, label: text};\n}\n\n/** Whether a chart shows the search control. */\nexport function showsSearchControls(viz: Viz): boolean {\n return Boolean(viz.schema.search) && !viz._ssr;\n}\n"],"names":["fontFamily","fontFamilyStringify","forEachSceneRow","ICON_ATTRS","kebab","paintControlButton","resolveControlStyle","searchControlStyleActiveDefault","searchControlStyleDefault","searchControlStyleHoverDefault","isSearchOpen","viz","Boolean","_searchOpen","searchButtonStyles","className","schema","searchControlClassName","base","searchControlStyle","active","searchControlStyleActive","hover","searchControlStyleHover","paintSearchButton","btn","hovered","classList","contains","SEARCH_ICON","CLEAR_ICON","SEARCH_INPUT_STYLE_CLOSED","width","padding","border","opacity","SEARCH_INPUT_STYLE_OPEN","SEARCH_INPUT_BASE_STYLE","height","font","transition","SEARCH_INPUT_WRAP_STYLE","position","display","SEARCH_ROOT_STYLE","SEARCH_CLEAR_STYLE_SHOWN","top","right","transform","visibility","background","cursor","SEARCH_CLEAR_STYLE_HIDDEN","SEARCH_COUNT_STYLE_SHOWN","left","color","overflow","SEARCH_COUNT_STYLE_HIDDEN","styleAttr","style","Object","entries","map","k","v","join","applySearchInputOpenState","input","open","key","setProperty","applySearchClearVisible","visible","tabIndex","applySearchCount","el","hasTerm","index","total","formatMatchCount","text","label","textContent","setAttribute","escapeHtml","value","String","replace","c","searchControlsHtml","extraClass","translate","term","_searchTerm","trim","length","inputStyle","clearStyle","wrapStyle","rootStyle","matchesSearchNeedle","d","i","needle","searchAccessor","toLowerCase","includes","ids","_ids","some","id","searchHighlightPredicate","_searchPrevHighlight","searchMatches","results","_chartScene","row","node","push","showsSearchControls","search","_ssr"],"mappings":"AAAA;;;;;;;;;;;;AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAQA,UAAU,EAAEC,mBAAmB,QAAO,eAAe;AAE7D,SAAQC,eAAe,QAAO,sBAAsB;AAEpD,SAAQC,UAAU,EAAEC,KAAK,QAAO,0BAA0B;AAC1D,SAAQC,kBAAkB,EAAEC,mBAAmB,QAAyB,0BAA0B;AAClG,SACEC,+BAA+B,EAC/BC,yBAAyB,EACzBC,8BAA8B,QACzB,wBAAwB;AAE/B,wEAAwE,GACxE,OAAO,SAASC,aAAaC,GAAQ;IACnC,OAAOC,QAAQD,IAAIE,WAAW;AAChC;AAEA,kLAAkL,GAClL,OAAO,SAASC,mBAAmBH,GAAQ;IACzC,IAAMI,YAAYH,QAAQD,IAAIK,MAAM,CAACC,sBAAsB;IAC3D,OAAO;QACLC,MAAMZ,oBAAoBK,IAAIK,MAAM,CAACG,kBAAkB,EAAEX,2BAA2BO;QACpFK,QAAQd,oBAAoBK,IAAIK,MAAM,CAACK,wBAAwB,EAAEd,iCAAiCQ;QAClGO,OAAOhB,oBAAoBK,IAAIK,MAAM,CAACO,uBAAuB,EAAEd,gCAAgCM;IACjG;AACF;AAEA,qGAAqG,GAC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AAE,EAAE,SAACC,KAAKd,GAAGe;QAC9C,IAAIjB,oBAAoBzF,KAAKyG,KAAKd,GAAGC,SAASW,QAAQI,IAAI,CAAC;YAACD,MAAAA;YAAMD,KAAAA;YAAKvC,OAAOyB;QAAC;IACjF;IACA,OAAOY;AACT;AAEA;;;;;;;;;;AAUA,GACA,OAAO,SAASnC,iBAAiBpE,GAAQ,EAAEkE,KAAyB,EAAEC,KAAa;IACjF,IAAIE;IACJ,IAAIF,UAAU,GAAGE,OAAOrE,IAAIK,MAAM,CAAC2E,SAAS,CAAC;SACxC,IAAI,OAAOd,UAAU,UAAUG,OAAO,AAAC,GAAWrE,OAATmE,OAAM,KAA2D,OAAxDnE,IAAIK,MAAM,CAAC2E,SAAS,CAACb,UAAU,IAAI,UAAU;SAC/FE,OAAO,AAAC,GAAmCH,OAAjClE,IAAIK,MAAM,CAAC2E,SAAS,CAAC,UAAS,KAAgBb,OAAbD,QAAQ,GAAE,KAAS,OAANC;IAC7D,OAAO;QAACE,MAAAA;QAAMC,OAAOD;IAAI;AAC3B;AAEA,8CAA8C,GAC9C,OAAO,SAASuC,oBAAoB5G,GAAQ;IAC1C,OAAOC,QAAQD,IAAIK,MAAM,CAACwG,MAAM,KAAK,CAAC7G,IAAI8G,IAAI;AAChD"}
@@ -7,6 +7,7 @@ function _instanceof(left, right) {
7
7
  }
8
8
  }
9
9
  import { merge } from "d3-array";
10
+ import { broadcastLegend } from "../viz/linkGroup.js";
10
11
  /**
11
12
  @module clickLegend
12
13
  On click event for all legend shapes in a Viz.
@@ -29,17 +30,21 @@ import { merge } from "d3-array";
29
30
  return id;
30
31
  })).length;
31
32
  var inverted = this.schema.legendFilterInvert.bind(this)(this);
33
+ var rerender = function rerender() {
34
+ broadcastLegend(_this);
35
+ _this.render();
36
+ };
32
37
  if (inverted) {
33
38
  if (event.shiftKey) {
34
39
  if (hiddenIndex < 0 && !this._solo.length) {
35
40
  this._hidden = this._hidden.concat(id);
36
41
  if (soloIndex >= 0) this._solo = [];
37
42
  if (this._hidden.length === dataLength) this._hidden = [];
38
- this.render();
43
+ rerender();
39
44
  } else if (soloIndex >= 0) {
40
45
  this._solo = [];
41
46
  this._hidden = [];
42
- this.render();
47
+ rerender();
43
48
  }
44
49
  } else {
45
50
  if (soloIndex < 0 && this._hidden.length < dataLength - 1) {
@@ -49,13 +54,13 @@ import { merge } from "d3-array";
49
54
  this._solo = [];
50
55
  this._hidden = [];
51
56
  }
52
- this.render();
57
+ rerender();
53
58
  }
54
59
  } else {
55
60
  if (event.shiftKey && soloIndex < 0) {
56
61
  this._solo = id;
57
62
  this._hidden = [];
58
- this.render();
63
+ rerender();
59
64
  } else if (!event.shiftKey) {
60
65
  if (hiddenIndex >= 0) {
61
66
  this._hidden.splice(hiddenIndex, id.length);
@@ -69,7 +74,7 @@ import { merge } from "d3-array";
69
74
  this._hidden = this._hidden.concat(id);
70
75
  if (this._hidden.length === dataLength) this._hidden = [];
71
76
  }
72
- this.render();
77
+ rerender();
73
78
  }
74
79
  }
75
80
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/charts/events/click.legend.ts"],"sourcesContent":["import {merge} from \"d3-array\";\nimport type {DataPoint} from \"@d3plus/data\";\nimport type Viz from \"../viz/Viz.js\";\n\n/**\n @module clickLegend\n On click event for all legend shapes in a Viz.\n @private\n*/\nexport default function (\n this: Viz,\n d: DataPoint,\n i: number,\n x: DataPoint,\n event: MouseEvent,\n): void {\n this._select.style(\"cursor\", \"auto\");\n if (this.schema.tooltip(d, i)) this._tooltipClass.data([]).render();\n\n let id = this._id(d, i);\n if (!(id instanceof Array)) id = [id];\n const hiddenIndex = this._hidden.indexOf(id[0]);\n const soloIndex = this._solo.indexOf(id[0]);\n const dataLength = merge(\n this._legendClass.data().map((d: DataPoint, i: number) => {\n let id = this._id(d, i);\n if (!(id instanceof Array)) id = [id];\n return id;\n }),\n ).length;\n\n const inverted = this.schema.legendFilterInvert.bind(this)(this);\n\n if (inverted) {\n if (event.shiftKey) {\n if (hiddenIndex < 0 && !this._solo.length) {\n this._hidden = this._hidden.concat(id);\n if (soloIndex >= 0) this._solo = [];\n if (this._hidden.length === dataLength) this._hidden = [];\n this.render();\n } else if (soloIndex >= 0) {\n this._solo = [];\n this._hidden = [];\n this.render();\n }\n } else {\n if (soloIndex < 0 && this._hidden.length < dataLength - 1) {\n this._solo = id;\n this._hidden = [];\n } else {\n this._solo = [];\n this._hidden = [];\n }\n this.render();\n }\n } else {\n if (event.shiftKey && soloIndex < 0) {\n this._solo = id;\n this._hidden = [];\n this.render();\n } else if (!event.shiftKey) {\n if (hiddenIndex >= 0) {\n this._hidden.splice(hiddenIndex, id.length);\n } else if (soloIndex >= 0) {\n this._solo = [];\n this._hidden = [];\n } else if (this._solo.length && soloIndex < 0) {\n this._solo = this._solo.concat(id);\n if (this._solo.length === dataLength) this._solo = [];\n } else {\n this._hidden = this._hidden.concat(id);\n if (this._hidden.length === dataLength) this._hidden = [];\n }\n this.render();\n }\n }\n}\n"],"names":["merge","d","i","x","event","_select","style","schema","tooltip","_tooltipClass","data","render","id","_id","Array","hiddenIndex","_hidden","indexOf","soloIndex","_solo","dataLength","_legendClass","map","length","inverted","legendFilterInvert","bind","shiftKey","concat","splice"],"mappings":";;;;;;;;AAAA,SAAQA,KAAK,QAAO,WAAW;AAI/B;;;;AAIA,GACA,eAAe,SAEbC,CAAY,EACZC,CAAS,EACTC,CAAY,EACZC,KAAiB;;IAEjB,IAAI,CAACC,OAAO,CAACC,KAAK,CAAC,UAAU;IAC7B,IAAI,IAAI,CAACC,MAAM,CAACC,OAAO,CAACP,GAAGC,IAAI,IAAI,CAACO,aAAa,CAACC,IAAI,CAAC,EAAE,EAAEC,MAAM;IAEjE,IAAIC,KAAK,IAAI,CAACC,GAAG,CAACZ,GAAGC;IACrB,IAAI,CAAEU,AAAE,YAAFA,IAAcE,QAAQF,KAAK;QAACA;KAAG;IACrC,IAAMG,cAAc,IAAI,CAACC,OAAO,CAACC,OAAO,CAACL,EAAE,CAA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G;YACnC,IAAI,CAACC,KAAK,GAAGP;YACb,IAAI,CAACI,OAAO,GAAG,EAAE;YACjB,IAAI,CAACL,MAAM;QACb,OAAO,IAAI,CAACP,MAAMuB,QAAQ,EAAE;YAC1B,IAAIZ,eAAe,GAAG;gBACpB,IAAI,CAACC,OAAO,CAACa,MAAM,CAACd,aAAaH,GAAGW,MAAM;YAC5C,OAAO,IAAIL,aAAa,GAAG;gBACzB,IAAI,CAACC,KAAK,GAAG,EAAE;gBACf,IAAI,CAACH,OAAO,GAAG,EAAE;YACnB,OAAO,IAAI,IAAI,CAACG,KAAK,CAACI,MAAM,IAAIL,YAAY,GAAG;gBAC7C,IAAI,CAACC,KAAK,GAAG,IAAI,CAACA,KAAK,CAACS,MAAM,CAAChB;gBAC/B,IAAI,IAAI,CAACO,KAAK,CAACI,MAAM,KAAKH,YAAY,IAAI,CAACD,KAAK,GAAG,EAAE;YACvD,OAAO;gBACL,IAAI,CAACH,OAAO,GAAG,IAAI,CAACA,OAAO,CAACY,MAAM,CAAChB;gBACnC,IAAI,IAAI,CAACI,OAAO,CAACO,MAAM,KAAKH,YAAY,IAAI,CAACJ,OAAO,GAAG,EAAE;YAC3D;YACA,IAAI,CAACL,MAAM;QACb;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../src/charts/events/click.legend.ts"],"sourcesContent":["import {merge} from \"d3-array\";\nimport type {DataPoint} from \"@d3plus/data\";\nimport {broadcastLegend} from \"../viz/linkGroup.js\";\nimport type Viz from \"../viz/Viz.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\n\n/**\n @module clickLegend\n On click event for all legend shapes in a Viz.\n @private\n*/\nexport default function (\n this: Viz,\n d: DataPoint,\n i: number,\n x: DataPoint,\n event: MouseEvent,\n): void {\n this._select.style(\"cursor\", \"auto\");\n if (this.schema.tooltip(d, i)) this._tooltipClass.data([]).render();\n\n let id = this._id(d, i);\n if (!(id instanceof Array)) id = [id];\n const hiddenIndex = this._hidden.indexOf(id[0]);\n const soloIndex = this._solo.indexOf(id[0]);\n const dataLength = merge(\n this._legendClass.data().map((d: DataPoint, i: number) => {\n let id = this._id(d, i);\n if (!(id instanceof Array)) id = [id];\n return id;\n }),\n ).length;\n\n const inverted = this.schema.legendFilterInvert.bind(this)(this);\n\n const rerender = (): void => {\n broadcastLegend(this as unknown as VizInstance);\n this.render();\n };\n\n if (inverted) {\n if (event.shiftKey) {\n if (hiddenIndex < 0 && !this._solo.length) {\n this._hidden = this._hidden.concat(id);\n if (soloIndex >= 0) this._solo = [];\n if (this._hidden.length === dataLength) this._hidden = [];\n rerender();\n } else if (soloIndex >= 0) {\n this._solo = [];\n this._hidden = [];\n rerender();\n }\n } else {\n if (soloIndex < 0 && this._hidden.length < dataLength - 1) {\n this._solo = id;\n this._hidden = [];\n } else {\n this._solo = [];\n this._hidden = [];\n }\n rerender();\n }\n } else {\n if (event.shiftKey && soloIndex < 0) {\n this._solo = id;\n this._hidden = [];\n rerender();\n } else if (!event.shiftKey) {\n if (hiddenIndex >= 0) {\n this._hidden.splice(hiddenIndex, id.length);\n } else if (soloIndex >= 0) {\n this._solo = [];\n this._hidden = [];\n } else if (this._solo.length && soloIndex < 0) {\n this._solo = this._solo.concat(id);\n if (this._solo.length === dataLength) this._solo = [];\n } else {\n this._hidden = this._hidden.concat(id);\n if (this._hidden.length === dataLength) this._hidden = [];\n }\n rerender();\n }\n }\n}\n"],"names":["merge","broadcastLegend","d","i","x","event","_select","style","schema","tooltip","_tooltipClass","data","render","id","_id","Array","hiddenIndex","_hidden","indexOf","soloIndex","_solo","dataLength","_legendClass","map","length","inverted","legendFilterInvert","bind","rerender","shiftKey","concat","splice"],"mappings":";;;;;;;;AAAA,SAAQA,KAAK,QAAO,WAAW;AAE/B,SAAQC,eAAe,QAAO,sBAAsB;AAIpD;;;;AAIA,GACA,eAAe,SAEbC,CAAY,EACZC,CAAS,EACTC,CAAY,EACZC,KAAiB;;IAEjB,IAAI,CAACC,OAAO,CAACC,KAAK,CAAC,UAAU;IA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