@unovis/ts 1.1.1-beta.7 → 1.1.1-beta.8
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.
- package/components/area/config.d.ts +25 -0
- package/components/area/config.js +16 -0
- package/components/area/config.js.map +1 -0
- package/components/area/index.d.ts +19 -0
- package/components/area/index.js +102 -0
- package/components/area/index.js.map +1 -0
- package/components/area/style.d.ts +3 -0
- package/{src/components/area/style.ts → components/area/style.js} +10 -9
- package/components/area/style.js.map +1 -0
- package/components/area/types.d.ts +6 -0
- package/components/axis/config.d.ts +71 -0
- package/components/axis/config.js +32 -0
- package/components/axis/config.js.map +1 -0
- package/components/axis/index.d.ts +44 -0
- package/components/axis/index.js +305 -0
- package/components/axis/index.js.map +1 -0
- package/components/axis/style.d.ts +9 -0
- package/{src/components/axis/style.ts → components/axis/style.js} +22 -27
- package/components/axis/style.js.map +1 -0
- package/components/axis/types.d.ts +4 -0
- package/components/axis/types.js +8 -0
- package/components/axis/types.js.map +1 -0
- package/components/brush/config.d.ts +42 -0
- package/components/brush/config.js +24 -0
- package/components/brush/config.js.map +1 -0
- package/components/brush/index.d.ts +28 -0
- package/components/brush/index.js +199 -0
- package/components/brush/index.js.map +1 -0
- package/components/brush/style.d.ts +5 -0
- package/{src/components/brush/style.ts → components/brush/style.js} +14 -15
- package/components/brush/style.js.map +1 -0
- package/components/brush/types.d.ts +7 -0
- package/components/brush/types.js +8 -0
- package/components/brush/types.js.map +1 -0
- package/components/bullet-legend/config.d.ts +34 -0
- package/components/bullet-legend/config.js +16 -0
- package/components/bullet-legend/config.js.map +1 -0
- package/components/bullet-legend/index.d.ts +19 -0
- package/components/bullet-legend/index.js +79 -0
- package/components/bullet-legend/index.js.map +1 -0
- package/components/bullet-legend/style.d.ts +6 -0
- package/{src/components/bullet-legend/style.ts → components/bullet-legend/style.js} +16 -18
- package/components/bullet-legend/style.js.map +1 -0
- package/components/bullet-legend/types.d.ts +7 -0
- package/components/bullet-legend/types.js +2 -0
- package/components/bullet-legend/types.js.map +1 -0
- package/components/chord-diagram/config.d.ts +44 -0
- package/components/chord-diagram/config.js +25 -0
- package/components/chord-diagram/config.js.map +1 -0
- package/components/chord-diagram/index.d.ts +42 -0
- package/components/chord-diagram/index.js +305 -0
- package/components/chord-diagram/index.js.map +1 -0
- package/components/chord-diagram/modules/label.d.ts +8 -0
- package/components/chord-diagram/modules/label.js +115 -0
- package/components/chord-diagram/modules/label.js.map +1 -0
- package/components/chord-diagram/modules/link.d.ts +21 -0
- package/components/chord-diagram/modules/link.js +63 -0
- package/components/chord-diagram/modules/link.js.map +1 -0
- package/components/chord-diagram/modules/node.d.ts +17 -0
- package/components/chord-diagram/modules/node.js +52 -0
- package/components/chord-diagram/modules/node.js.map +1 -0
- package/components/chord-diagram/style.d.ts +13 -0
- package/{src/components/chord-diagram/style.ts → components/chord-diagram/style.js} +30 -39
- package/components/chord-diagram/style.js.map +1 -0
- package/components/chord-diagram/types.d.ts +58 -0
- package/components/chord-diagram/types.js +8 -0
- package/components/chord-diagram/types.js.map +1 -0
- package/components/crosshair/config.d.ts +43 -0
- package/components/crosshair/config.js +19 -0
- package/components/crosshair/config.js.map +1 -0
- package/components/crosshair/index.d.ts +35 -0
- package/components/crosshair/index.js +183 -0
- package/components/crosshair/index.js.map +1 -0
- package/components/crosshair/style.d.ts +4 -0
- package/{src/components/crosshair/style.ts → components/crosshair/style.js} +12 -12
- package/components/crosshair/style.js.map +1 -0
- package/components/crosshair/types.d.ts +13 -0
- package/components/crosshair/types.js +2 -0
- package/components/crosshair/types.js.map +1 -0
- package/components/donut/config.d.ts +59 -0
- package/components/donut/config.js +28 -0
- package/components/donut/config.js.map +1 -0
- package/components/donut/index.d.ts +21 -0
- package/components/donut/index.js +107 -0
- package/components/donut/index.js.map +1 -0
- package/components/donut/modules/arc.d.ts +10 -0
- package/components/donut/modules/arc.js +59 -0
- package/components/donut/modules/arc.js.map +1 -0
- package/components/donut/style.d.ts +7 -0
- package/{src/components/donut/style.ts → components/donut/style.js} +18 -20
- package/components/donut/style.js.map +1 -0
- package/components/donut/types.d.ts +20 -0
- package/components/flow-legend/config.d.ts +29 -0
- package/components/flow-legend/config.js +18 -0
- package/components/flow-legend/config.js.map +1 -0
- package/components/flow-legend/index.d.ts +16 -0
- package/components/flow-legend/index.js +75 -0
- package/components/flow-legend/index.js.map +1 -0
- package/components/flow-legend/style.d.ts +8 -0
- package/{src/components/flow-legend/style.ts → components/flow-legend/style.js} +21 -25
- package/components/flow-legend/style.js.map +1 -0
- package/components/flow-legend/types.d.ts +9 -0
- package/components/flow-legend/types.js +8 -0
- package/components/flow-legend/types.js.map +1 -0
- package/components/free-brush/config.d.ts +45 -0
- package/components/free-brush/config.js +24 -0
- package/components/free-brush/config.js.map +1 -0
- package/components/free-brush/index.d.ts +20 -0
- package/components/free-brush/index.js +192 -0
- package/components/free-brush/index.js.map +1 -0
- package/components/free-brush/style.d.ts +4 -0
- package/{src/components/free-brush/style.ts → components/free-brush/style.js} +12 -12
- package/components/free-brush/style.js.map +1 -0
- package/components/free-brush/types.d.ts +7 -0
- package/components/free-brush/types.js +9 -0
- package/components/free-brush/types.js.map +1 -0
- package/components/graph/config.d.ts +238 -0
- package/components/graph/config.js +84 -0
- package/components/graph/config.js.map +1 -0
- package/components/graph/index.d.ts +126 -0
- package/components/graph/index.js +656 -0
- package/components/graph/index.js.map +1 -0
- package/components/graph/modules/layout-helpers.d.ts +21 -0
- package/components/graph/modules/layout-helpers.js +69 -0
- package/components/graph/modules/layout-helpers.js.map +1 -0
- package/components/graph/modules/layout.d.ts +10 -0
- package/components/graph/modules/layout.js +399 -0
- package/components/graph/modules/layout.js.map +1 -0
- package/components/graph/modules/link/helper.d.ts +25 -0
- package/components/graph/modules/link/helper.js +74 -0
- package/components/graph/modules/link/helper.js.map +1 -0
- package/components/graph/modules/link/index.d.ts +11 -0
- package/components/graph/modules/link/index.js +212 -0
- package/components/graph/modules/link/index.js.map +1 -0
- package/components/graph/modules/link/style.d.ts +15 -0
- package/{src/components/graph/modules/link/style.ts → components/graph/modules/link/style.js} +34 -45
- package/components/graph/modules/link/style.js.map +1 -0
- package/components/graph/modules/node/helper.d.ts +21 -0
- package/components/graph/modules/node/helper.js +126 -0
- package/components/graph/modules/node/helper.js.map +1 -0
- package/components/graph/modules/node/index.d.ts +11 -0
- package/components/graph/modules/node/index.js +252 -0
- package/components/graph/modules/node/index.js.map +1 -0
- package/components/graph/modules/node/style.d.ts +24 -0
- package/{src/components/graph/modules/node/style.ts → components/graph/modules/node/style.js} +52 -72
- package/components/graph/modules/node/style.js.map +1 -0
- package/components/graph/modules/panel/helper.d.ts +18 -0
- package/components/graph/modules/panel/helper.js +111 -0
- package/components/graph/modules/panel/helper.js.map +1 -0
- package/components/graph/modules/panel/index.d.ts +7 -0
- package/components/graph/modules/panel/index.js +98 -0
- package/components/graph/modules/panel/index.js.map +1 -0
- package/components/graph/modules/panel/style.d.ts +14 -0
- package/{src/components/graph/modules/panel/style.ts → components/graph/modules/panel/style.js} +32 -42
- package/components/graph/modules/panel/style.js.map +1 -0
- package/components/graph/modules/shape.d.ts +6 -0
- package/components/graph/modules/shape.js +80 -0
- package/components/graph/modules/shape.js.map +1 -0
- package/components/graph/modules/zoom-levels.d.ts +6 -0
- package/components/graph/modules/zoom-levels.js +10 -0
- package/components/graph/modules/zoom-levels.js.map +1 -0
- package/components/graph/style.d.ts +6 -0
- package/components/graph/style.js +66 -0
- package/components/graph/style.js.map +1 -0
- package/components/graph/types.d.ts +125 -0
- package/components/graph/types.js +30 -0
- package/components/graph/types.js.map +1 -0
- package/components/grouped-bar/config.d.ts +36 -0
- package/components/grouped-bar/config.js +20 -0
- package/components/grouped-bar/config.js.map +1 -0
- package/components/grouped-bar/index.d.ts +32 -0
- package/components/grouped-bar/index.js +249 -0
- package/components/grouped-bar/index.js.map +1 -0
- package/components/grouped-bar/style.d.ts +5 -0
- package/{src/components/grouped-bar/style.ts → components/grouped-bar/style.js} +14 -15
- package/components/grouped-bar/style.js.map +1 -0
- package/components/leaflet-flow-map/config.d.ts +46 -0
- package/components/leaflet-flow-map/config.js +25 -0
- package/components/leaflet-flow-map/config.js.map +1 -0
- package/components/leaflet-flow-map/index.d.ts +52 -0
- package/components/leaflet-flow-map/index.js +220 -0
- package/components/leaflet-flow-map/index.js.map +1 -0
- package/components/leaflet-flow-map/renderer-utils.d.ts +5 -0
- package/components/leaflet-flow-map/renderer-utils.js +15 -0
- package/components/leaflet-flow-map/renderer-utils.js.map +1 -0
- package/components/leaflet-flow-map/renderer.d.ts +26 -0
- package/components/leaflet-flow-map/renderer.js +117 -0
- package/components/leaflet-flow-map/renderer.js.map +1 -0
- package/components/leaflet-flow-map/shaders.d.ts +2 -0
- package/{src/components/leaflet-flow-map/shaders.ts → components/leaflet-flow-map/shaders.js} +7 -4
- package/components/leaflet-flow-map/shaders.js.map +1 -0
- package/components/leaflet-flow-map/types.d.ts +23 -0
- package/components/leaflet-map/config.d.ts +193 -0
- package/components/leaflet-map/config.js +71 -0
- package/components/leaflet-map/config.js.map +1 -0
- package/components/leaflet-map/index.d.ts +130 -0
- package/components/leaflet-map/index.js +690 -0
- package/components/leaflet-map/index.js.map +1 -0
- package/components/leaflet-map/leaflet.css.js +5 -0
- package/components/leaflet-map/leaflet.css.js.map +1 -0
- package/components/leaflet-map/modules/clusterBackground.d.ts +5 -0
- package/components/leaflet-map/modules/clusterBackground.js +27 -0
- package/components/leaflet-map/modules/clusterBackground.js.map +1 -0
- package/components/leaflet-map/modules/donut.d.ts +3 -0
- package/components/leaflet-map/modules/donut.js +25 -0
- package/components/leaflet-map/modules/donut.js.map +1 -0
- package/components/leaflet-map/modules/map.d.ts +14 -0
- package/components/leaflet-map/modules/map.js +154 -0
- package/components/leaflet-map/modules/map.js.map +1 -0
- package/components/leaflet-map/modules/node.d.ts +9 -0
- package/components/leaflet-map/modules/node.js +162 -0
- package/components/leaflet-map/modules/node.js.map +1 -0
- package/components/leaflet-map/modules/selectionRing.d.ts +7 -0
- package/components/leaflet-map/modules/selectionRing.js +41 -0
- package/components/leaflet-map/modules/selectionRing.js.map +1 -0
- package/components/leaflet-map/modules/utils.d.ts +50 -0
- package/components/leaflet-map/modules/utils.js +210 -0
- package/components/leaflet-map/modules/utils.js.map +1 -0
- package/{src/components → components}/leaflet-map/renderer/leaflet-maplibre-gl.js +78 -76
- package/components/leaflet-map/renderer/leaflet-maplibre-gl.js.map +1 -0
- package/components/leaflet-map/renderer/map-style.d.ts +4 -0
- package/components/leaflet-map/renderer/map-style.js +15 -0
- package/components/leaflet-map/renderer/map-style.js.map +1 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-dark-theme.json.js +40 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-dark-theme.json.js.map +1 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-light-theme.json.js +40 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-light-theme.json.js.map +1 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json.js +4981 -0
- package/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json.js.map +1 -0
- package/components/leaflet-map/renderer/mapboxgl-layer.d.ts +8 -0
- package/components/leaflet-map/renderer/mapboxgl-layer.js +27 -0
- package/components/leaflet-map/renderer/mapboxgl-layer.js.map +1 -0
- package/components/leaflet-map/renderer/mapboxgl-utils.d.ts +4 -0
- package/components/leaflet-map/renderer/mapboxgl-utils.js +39 -0
- package/components/leaflet-map/renderer/mapboxgl-utils.js.map +1 -0
- package/{src/components → components}/leaflet-map/renderer/maplibre-gl.css.js +4 -2
- package/components/leaflet-map/renderer/maplibre-gl.css.js.map +1 -0
- package/components/leaflet-map/style.d.ts +52 -0
- package/components/leaflet-map/style.js +183 -0
- package/components/leaflet-map/style.js.map +1 -0
- package/components/leaflet-map/types.d.ts +75 -0
- package/components/leaflet-map/types.js +15 -0
- package/components/leaflet-map/types.js.map +1 -0
- package/components/line/config.d.ts +30 -0
- package/components/line/config.js +17 -0
- package/components/line/config.js.map +1 -0
- package/components/line/index.d.ts +27 -0
- package/components/line/index.js +152 -0
- package/components/line/index.js.map +1 -0
- package/components/line/style.d.ts +6 -0
- package/{src/components/line/style.ts → components/line/style.js} +16 -18
- package/components/line/style.js.map +1 -0
- package/components/line/types.d.ts +12 -0
- package/components/nested-donut/config.d.ts +59 -0
- package/components/nested-donut/config.js +19 -0
- package/components/nested-donut/config.js.map +1 -0
- package/components/nested-donut/index.d.ts +38 -0
- package/components/nested-donut/index.js +133 -0
- package/components/nested-donut/index.js.map +1 -0
- package/components/nested-donut/modules/arc.d.ts +17 -0
- package/components/nested-donut/modules/arc.js +50 -0
- package/components/nested-donut/modules/arc.js.map +1 -0
- package/components/nested-donut/modules/label.d.ts +7 -0
- package/components/nested-donut/modules/label.js +34 -0
- package/components/nested-donut/modules/label.js.map +1 -0
- package/components/nested-donut/style.d.ts +26 -0
- package/components/nested-donut/style.js +70 -0
- package/components/nested-donut/style.js.map +1 -0
- package/components/nested-donut/types.d.ts +24 -0
- package/components/nested-donut/types.js +11 -0
- package/components/nested-donut/types.js.map +1 -0
- package/components/sankey/config.d.ts +162 -0
- package/components/sankey/config.js +65 -0
- package/components/sankey/config.js.map +1 -0
- package/components/sankey/index.d.ts +59 -0
- package/components/sankey/index.js +306 -0
- package/components/sankey/index.js.map +1 -0
- package/components/sankey/modules/label.d.ts +23 -0
- package/components/sankey/modules/label.js +168 -0
- package/components/sankey/modules/label.js.map +1 -0
- package/components/sankey/modules/link.d.ts +14 -0
- package/components/sankey/modules/link.js +108 -0
- package/components/sankey/modules/link.js.map +1 -0
- package/components/sankey/modules/node.d.ts +10 -0
- package/components/sankey/modules/node.js +156 -0
- package/components/sankey/modules/node.js.map +1 -0
- package/components/sankey/style.d.ts +20 -0
- package/{src/components/sankey/style.ts → components/sankey/style.js} +44 -60
- package/components/sankey/style.js.map +1 -0
- package/components/sankey/types.d.ts +84 -0
- package/components/sankey/types.js +34 -0
- package/components/sankey/types.js.map +1 -0
- package/components/scatter/config.d.ts +44 -0
- package/components/scatter/config.js +23 -0
- package/components/scatter/config.js.map +1 -0
- package/components/scatter/index.d.ts +28 -0
- package/components/scatter/index.js +167 -0
- package/components/scatter/index.js.map +1 -0
- package/components/scatter/modules/point.d.ts +7 -0
- package/components/scatter/modules/point.js +86 -0
- package/components/scatter/modules/point.js.map +1 -0
- package/components/scatter/modules/utils.d.ts +11 -0
- package/components/scatter/modules/utils.js +112 -0
- package/components/scatter/modules/utils.js.map +1 -0
- package/components/scatter/style.d.ts +5 -0
- package/{src/components/scatter/style.ts → components/scatter/style.js} +14 -15
- package/components/scatter/style.js.map +1 -0
- package/components/scatter/types.d.ts +19 -0
- package/components/stacked-bar/config.d.ts +38 -0
- package/components/stacked-bar/config.js +20 -0
- package/components/stacked-bar/config.js.map +1 -0
- package/components/stacked-bar/index.d.ts +28 -0
- package/components/stacked-bar/index.js +208 -0
- package/components/stacked-bar/index.js.map +1 -0
- package/components/stacked-bar/style.d.ts +5 -0
- package/{src/components/stacked-bar/style.ts → components/stacked-bar/style.js} +14 -15
- package/components/stacked-bar/style.js.map +1 -0
- package/components/stacked-bar/types.d.ts +5 -0
- package/components/timeline/config.d.ts +43 -0
- package/components/timeline/config.js +24 -0
- package/components/timeline/config.js.map +1 -0
- package/components/timeline/index.d.ts +41 -0
- package/components/timeline/index.js +244 -0
- package/components/timeline/index.js.map +1 -0
- package/components/timeline/style.d.ts +13 -0
- package/{src/components/timeline/style.ts → components/timeline/style.js} +30 -39
- package/components/timeline/style.js.map +1 -0
- package/components/tooltip/config.d.ts +68 -0
- package/components/tooltip/config.js +20 -0
- package/components/tooltip/config.js.map +1 -0
- package/components/tooltip/index.d.ts +36 -0
- package/components/tooltip/index.js +184 -0
- package/components/tooltip/index.js.map +1 -0
- package/{src/components → components}/tooltip/style.js +14 -11
- package/components/tooltip/style.js.map +1 -0
- package/components/topojson-map/config.d.ts +99 -0
- package/components/topojson-map/config.js +42 -0
- package/components/topojson-map/config.js.map +1 -0
- package/components/topojson-map/index.d.ts +52 -0
- package/components/topojson-map/index.js +355 -0
- package/components/topojson-map/index.js.map +1 -0
- package/components/topojson-map/style.d.ts +11 -0
- package/{src/components/topojson-map/style.ts → components/topojson-map/style.js} +26 -33
- package/components/topojson-map/style.js.map +1 -0
- package/components/topojson-map/types.d.ts +78 -0
- package/components/topojson-map/types.js +80 -0
- package/components/topojson-map/types.js.map +1 -0
- package/components/topojson-map/utils.d.ts +3 -0
- package/components/topojson-map/utils.js +30 -0
- package/components/topojson-map/utils.js.map +1 -0
- package/components/vis-controls/config.d.ts +12 -0
- package/components/vis-controls/config.js +13 -0
- package/components/vis-controls/config.js.map +1 -0
- package/components/vis-controls/index.d.ts +14 -0
- package/components/vis-controls/index.js +52 -0
- package/components/vis-controls/index.js.map +1 -0
- package/components/vis-controls/style.d.ts +11 -0
- package/{src/components/vis-controls/style.ts → components/vis-controls/style.js} +27 -34
- package/components/vis-controls/style.js.map +1 -0
- package/components/vis-controls/types.d.ts +13 -0
- package/components/vis-controls/types.js +8 -0
- package/components/vis-controls/types.js.map +1 -0
- package/components/xy-labels/config.d.ts +48 -0
- package/components/xy-labels/config.js +25 -0
- package/components/xy-labels/config.js.map +1 -0
- package/components/xy-labels/index.d.ts +15 -0
- package/components/xy-labels/index.js +87 -0
- package/components/xy-labels/index.js.map +1 -0
- package/components/xy-labels/modules/label.d.ts +9 -0
- package/components/xy-labels/modules/label.js +107 -0
- package/components/xy-labels/modules/label.js.map +1 -0
- package/components/xy-labels/style.d.ts +5 -0
- package/{src/components/xy-labels/style.ts → components/xy-labels/style.js} +14 -15
- package/components/xy-labels/style.js.map +1 -0
- package/components/xy-labels/types.d.ts +23 -0
- package/components/xy-labels/types.js +9 -0
- package/components/xy-labels/types.js.map +1 -0
- package/components.d.ts +51 -0
- package/components.js +29 -0
- package/components.js.map +1 -0
- package/containers/single-container/config.d.ts +12 -0
- package/containers/single-container/config.js +12 -0
- package/containers/single-container/config.js.map +1 -0
- package/containers/single-container/index.d.ts +19 -0
- package/containers/single-container/index.js +128 -0
- package/containers/single-container/index.js.map +1 -0
- package/containers/xy-container/config.d.ts +99 -0
- package/containers/xy-container/config.js +30 -0
- package/containers/xy-container/config.js.map +1 -0
- package/containers/xy-container/index.d.ts +34 -0
- package/containers/xy-container/index.js +330 -0
- package/containers/xy-container/index.js.map +1 -0
- package/containers.d.ts +6 -0
- package/containers.js +4 -0
- package/containers.js.map +1 -0
- package/core/component/config.d.ts +58 -0
- package/core/component/config.js +14 -0
- package/core/component/config.js.map +1 -0
- package/core/component/index.d.ts +43 -0
- package/core/component/index.js +118 -0
- package/core/component/index.js.map +1 -0
- package/core/component/types.d.ts +2 -0
- package/core/component/types.js +2 -0
- package/core/component/types.js.map +1 -0
- package/core/config/index.d.ts +3 -0
- package/core/config/index.js +16 -0
- package/core/config/index.js.map +1 -0
- package/core/container/config.d.ts +48 -0
- package/core/container/config.js +29 -0
- package/core/container/config.js.map +1 -0
- package/core/container/index.d.ts +26 -0
- package/core/container/index.js +106 -0
- package/core/container/index.js.map +1 -0
- package/core/xy-component/config.d.ts +38 -0
- package/core/xy-component/config.js +20 -0
- package/core/xy-component/config.js.map +1 -0
- package/core/xy-component/index.d.ts +27 -0
- package/core/xy-component/index.js +74 -0
- package/core/xy-component/index.js.map +1 -0
- package/data-models/core.d.ts +6 -0
- package/data-models/core.js +14 -0
- package/data-models/core.js.map +1 -0
- package/data-models/graph.d.ts +24 -0
- package/data-models/graph.js +107 -0
- package/data-models/graph.js.map +1 -0
- package/data-models/map-graph.d.ts +21 -0
- package/data-models/map-graph.js +62 -0
- package/data-models/map-graph.js.map +1 -0
- package/data-models/map.d.ts +5 -0
- package/data-models/map.js +12 -0
- package/data-models/map.js.map +1 -0
- package/data-models/series.d.ts +6 -0
- package/data-models/series.js +19 -0
- package/data-models/series.js.map +1 -0
- package/index.d.ts +7 -0
- package/index.js +55 -0
- package/index.js.map +1 -0
- package/maps/china-provinces.json.js +140373 -0
- package/maps/fr-regions.json.js +14162 -0
- package/maps/germany-regions.json.js +35760 -0
- package/maps/ind-regions.json.js +290584 -0
- package/maps/uk-regions.json.js +96233 -0
- package/maps/us-counties.json.js +206318 -0
- package/maps/us-states.json.js +16345 -0
- package/maps/world-110m-alpha.json.js +251366 -0
- package/maps/world-simple.json.js +89428 -0
- package/maps/world-simplest.json.js +28175 -0
- package/maps.d.ts +60 -0
- package/maps.js +23 -0
- package/package.json +1 -1
- package/styles/colors.d.ts +7 -0
- package/styles/colors.js +24 -0
- package/styles/colors.js.map +1 -0
- package/styles/index.d.ts +7 -0
- package/styles/index.js +38 -0
- package/styles/index.js.map +1 -0
- package/styles/sizes.d.ts +2 -0
- package/{src/styles/sizes.ts → styles/sizes.js} +8 -6
- package/styles/sizes.js.map +1 -0
- package/types/accessor.d.ts +5 -0
- package/types/accessor.js +2 -0
- package/types/accessor.js.map +1 -0
- package/types/component.d.ts +13 -0
- package/types/component.js +14 -0
- package/types/component.js.map +1 -0
- package/types/curve.d.ts +40 -0
- package/types/curve.js +46 -0
- package/types/curve.js.map +1 -0
- package/types/data.d.ts +7 -0
- package/types/data.js +2 -0
- package/types/data.js.map +1 -0
- package/types/direction.d.ts +6 -0
- package/types/direction.js +10 -0
- package/types/direction.js.map +1 -0
- package/types/graph.d.ts +35 -0
- package/types/graph.js +2 -0
- package/types/graph.js.map +1 -0
- package/types/map.d.ts +4 -0
- package/types/map.js +2 -0
- package/types/map.js.map +1 -0
- package/types/misc.d.ts +8 -0
- package/types/position.d.ts +20 -0
- package/types/position.js +27 -0
- package/types/position.js.map +1 -0
- package/types/scale.d.ts +23 -0
- package/types/scale.js +27 -0
- package/types/scale.js.map +1 -0
- package/types/shape.d.ts +7 -0
- package/types/shape.js +11 -0
- package/types/shape.js.map +1 -0
- package/types/spacing.d.ts +6 -0
- package/types/spacing.js +2 -0
- package/types/spacing.js.map +1 -0
- package/types/svg.d.ts +18 -0
- package/types/svg.js +22 -0
- package/types/svg.js.map +1 -0
- package/types/symbol.d.ts +18 -0
- package/types/symbol.js +24 -0
- package/types/symbol.js.map +1 -0
- package/types/text.d.ts +47 -0
- package/types/text.js +26 -0
- package/types/text.js.map +1 -0
- package/types.d.ts +27 -0
- package/types.js +30 -0
- package/types.js.map +1 -0
- package/utils/color.d.ts +10 -0
- package/utils/color.js +32 -0
- package/utils/color.js.map +1 -0
- package/utils/d3.d.ts +3 -0
- package/utils/d3.js +16 -0
- package/utils/d3.js.map +1 -0
- package/utils/data.d.ts +45 -0
- package/utils/data.js +274 -0
- package/utils/data.js.map +1 -0
- package/utils/html.d.ts +1 -0
- package/utils/html.js +16 -0
- package/utils/html.js.map +1 -0
- package/utils/map.d.ts +2 -0
- package/utils/map.js +20 -0
- package/utils/map.js.map +1 -0
- package/utils/misc.d.ts +9 -0
- package/utils/misc.js +47 -0
- package/utils/misc.js.map +1 -0
- package/utils/path.d.ts +23 -0
- package/utils/path.js +144 -0
- package/utils/path.js.map +1 -0
- package/utils/scale.d.ts +1 -0
- package/utils/style.d.ts +6 -0
- package/utils/style.js +24 -0
- package/utils/style.js.map +1 -0
- package/utils/svg.d.ts +3 -0
- package/utils/text.d.ts +139 -0
- package/utils/text.js +443 -0
- package/utils/text.js.map +1 -0
- package/utils/type.d.ts +5 -0
- package/declaration.d.ts +0 -1
- package/index.ts +0 -1
- package/licences.txt +0 -43
- package/maps.ts +0 -1
- package/rollup.config.js +0 -71
- package/rules/ts-getter-setter.js +0 -35
- package/src/components/area/config.ts +0 -29
- package/src/components/area/index.ts +0 -133
- package/src/components/area/types.ts +0 -2
- package/src/components/axis/config.ts +0 -76
- package/src/components/axis/index.ts +0 -363
- package/src/components/axis/types.ts +0 -4
- package/src/components/brush/config.ts +0 -51
- package/src/components/brush/index.ts +0 -233
- package/src/components/brush/types.ts +0 -8
- package/src/components/bullet-legend/config.ts +0 -38
- package/src/components/bullet-legend/index.ts +0 -104
- package/src/components/bullet-legend/types.ts +0 -7
- package/src/components/chord-diagram/config.ts +0 -53
- package/src/components/chord-diagram/index.ts +0 -401
- package/src/components/chord-diagram/modules/label.ts +0 -155
- package/src/components/chord-diagram/modules/link.ts +0 -91
- package/src/components/chord-diagram/modules/node.ts +0 -80
- package/src/components/chord-diagram/types.ts +0 -68
- package/src/components/crosshair/config.ts +0 -48
- package/src/components/crosshair/index.ts +0 -220
- package/src/components/crosshair/types.ts +0 -15
- package/src/components/donut/config.ts +0 -65
- package/src/components/donut/index.ts +0 -148
- package/src/components/donut/modules/arc.ts +0 -86
- package/src/components/donut/types.ts +0 -17
- package/src/components/flow-legend/config.ts +0 -31
- package/src/components/flow-legend/index.ts +0 -103
- package/src/components/flow-legend/types.ts +0 -10
- package/src/components/free-brush/config.ts +0 -54
- package/src/components/free-brush/index.ts +0 -207
- package/src/components/free-brush/types.ts +0 -8
- package/src/components/graph/config.ts +0 -280
- package/src/components/graph/index.ts +0 -809
- package/src/components/graph/modules/layout-helpers.ts +0 -96
- package/src/components/graph/modules/layout.ts +0 -502
- package/src/components/graph/modules/link/helper.ts +0 -105
- package/src/components/graph/modules/link/index.ts +0 -302
- package/src/components/graph/modules/node/helper.ts +0 -162
- package/src/components/graph/modules/node/index.ts +0 -343
- package/src/components/graph/modules/panel/helper.ts +0 -160
- package/src/components/graph/modules/panel/index.ts +0 -137
- package/src/components/graph/modules/shape.ts +0 -108
- package/src/components/graph/modules/zoom-levels.ts +0 -6
- package/src/components/graph/style.ts +0 -72
- package/src/components/graph/types.ts +0 -152
- package/src/components/grouped-bar/config.ts +0 -40
- package/src/components/grouped-bar/index.ts +0 -325
- package/src/components/leaflet-flow-map/config.ts +0 -60
- package/src/components/leaflet-flow-map/index.ts +0 -279
- package/src/components/leaflet-flow-map/renderer-utils.ts +0 -14
- package/src/components/leaflet-flow-map/renderer.ts +0 -146
- package/src/components/leaflet-flow-map/types.ts +0 -18
- package/src/components/leaflet-map/config.ts +0 -234
- package/src/components/leaflet-map/index.ts +0 -808
- package/src/components/leaflet-map/leaflet.css +0 -625
- package/src/components/leaflet-map/modules/clusterBackground.ts +0 -34
- package/src/components/leaflet-map/modules/donut.ts +0 -37
- package/src/components/leaflet-map/modules/map.ts +0 -178
- package/src/components/leaflet-map/modules/node.ts +0 -208
- package/src/components/leaflet-map/modules/selectionRing.ts +0 -63
- package/src/components/leaflet-map/modules/utils.ts +0 -290
- package/src/components/leaflet-map/renderer/map-style.ts +0 -24
- package/src/components/leaflet-map/renderer/mapboxgl/mapboxgl-dark-theme.json +0 -35
- package/src/components/leaflet-map/renderer/mapboxgl/mapboxgl-light-theme.json +0 -35
- package/src/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json +0 -2185
- package/src/components/leaflet-map/renderer/mapboxgl-layer.ts +0 -43
- package/src/components/leaflet-map/renderer/mapboxgl-utils.ts +0 -40
- package/src/components/leaflet-map/style.ts +0 -217
- package/src/components/leaflet-map/types.ts +0 -75
- package/src/components/line/config.ts +0 -34
- package/src/components/line/index.ts +0 -188
- package/src/components/line/types.ts +0 -3
- package/src/components/nested-donut/config.ts +0 -75
- package/src/components/nested-donut/index.ts +0 -176
- package/src/components/nested-donut/modules/arc.ts +0 -78
- package/src/components/nested-donut/modules/label.ts +0 -63
- package/src/components/nested-donut/style.ts +0 -82
- package/src/components/nested-donut/types.ts +0 -29
- package/src/components/sankey/config.ts +0 -195
- package/src/components/sankey/index.ts +0 -387
- package/src/components/sankey/modules/label.ts +0 -228
- package/src/components/sankey/modules/link.ts +0 -141
- package/src/components/sankey/modules/node.ts +0 -221
- package/src/components/sankey/types.ts +0 -95
- package/src/components/scatter/config.ts +0 -49
- package/src/components/scatter/index.ts +0 -220
- package/src/components/scatter/modules/point.ts +0 -123
- package/src/components/scatter/modules/utils.ts +0 -150
- package/src/components/scatter/types.ts +0 -21
- package/src/components/stacked-bar/config.ts +0 -42
- package/src/components/stacked-bar/index.ts +0 -267
- package/src/components/stacked-bar/types.ts +0 -5
- package/src/components/timeline/config.ts +0 -49
- package/src/components/timeline/index.ts +0 -302
- package/src/components/tooltip/config.ts +0 -69
- package/src/components/tooltip/index.ts +0 -220
- package/src/components/topojson-map/config.ts +0 -124
- package/src/components/topojson-map/index.ts +0 -436
- package/src/components/topojson-map/types.ts +0 -123
- package/src/components/topojson-map/utils.ts +0 -29
- package/src/components/vis-controls/config.ts +0 -16
- package/src/components/vis-controls/index.ts +0 -68
- package/src/components/vis-controls/types.ts +0 -14
- package/src/components/xy-labels/config.ts +0 -56
- package/src/components/xy-labels/index.ts +0 -109
- package/src/components/xy-labels/modules/label.ts +0 -140
- package/src/components/xy-labels/types.ts +0 -26
- package/src/components.ts +0 -56
- package/src/containers/single-container/config.ts +0 -15
- package/src/containers/single-container/index.ts +0 -150
- package/src/containers/xy-container/config.ts +0 -112
- package/src/containers/xy-container/index.ts +0 -407
- package/src/containers.ts +0 -6
- package/src/core/component/config.ts +0 -61
- package/src/core/component/index.ts +0 -154
- package/src/core/component/types.ts +0 -9
- package/src/core/config/index.ts +0 -12
- package/src/core/container/config.ts +0 -56
- package/src/core/container/index.ts +0 -136
- package/src/core/xy-component/config.ts +0 -46
- package/src/core/xy-component/index.ts +0 -90
- package/src/data-models/core.ts +0 -15
- package/src/data-models/graph.ts +0 -138
- package/src/data-models/map-graph.ts +0 -72
- package/src/data-models/map.ts +0 -18
- package/src/data-models/series.ts +0 -16
- package/src/index.ts +0 -7
- package/src/maps/china-provinces.json +0 -1
- package/src/maps/fr-regions.json +0 -1
- package/src/maps/germany-regions.json +0 -1
- package/src/maps/ind-regions.json +0 -1
- package/src/maps/uk-regions.json +0 -1
- package/src/maps/us-counties.json +0 -1
- package/src/maps/us-states.json +0 -1
- package/src/maps/world-110m-alpha.json +0 -1
- package/src/maps/world-simple.json +0 -1
- package/src/maps/world-simplest.json +0 -1
- package/src/maps.ts +0 -34
- package/src/styles/colors.ts +0 -28
- package/src/styles/index.ts +0 -38
- package/src/types/accessor.ts +0 -5
- package/src/types/component.ts +0 -15
- package/src/types/curve.ts +0 -62
- package/src/types/data.ts +0 -5
- package/src/types/direction.ts +0 -6
- package/src/types/graph.ts +0 -40
- package/src/types/map.ts +0 -5
- package/src/types/misc.ts +0 -10
- package/src/types/position.ts +0 -23
- package/src/types/scale.ts +0 -47
- package/src/types/shape.ts +0 -7
- package/src/types/spacing.ts +0 -6
- package/src/types/svg.ts +0 -32
- package/src/types/symbol.ts +0 -21
- package/src/types/text.ts +0 -71
- package/src/types.ts +0 -31
- package/src/utils/color.ts +0 -41
- package/src/utils/d3.ts +0 -15
- package/src/utils/data.ts +0 -328
- package/src/utils/html.ts +0 -13
- package/src/utils/map.ts +0 -29
- package/src/utils/misc.ts +0 -54
- package/src/utils/path.ts +0 -196
- package/src/utils/scale.ts +0 -1
- package/src/utils/style.ts +0 -37
- package/src/utils/svg.ts +0 -49
- package/src/utils/text.ts +0 -529
- package/src/utils/type.ts +0 -9
- package/tsconfig.json +0 -29
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { select } from 'd3-selection';
|
|
2
|
+
import { CoreDataModel } from '../../data-models/core.js';
|
|
3
|
+
import { throttle } from '../../utils/data.js';
|
|
4
|
+
import { guid } from '../../utils/misc.js';
|
|
5
|
+
import { ComponentType, Sizing } from '../../types/component.js';
|
|
6
|
+
|
|
7
|
+
class ComponentCore {
|
|
8
|
+
constructor(type = ComponentType.SVG) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
this.type = ComponentType.SVG;
|
|
11
|
+
this.datamodel = new CoreDataModel();
|
|
12
|
+
this.sizing = Sizing.Fit; // Supported by SingleContainer and a subset of components only (Sankey)
|
|
13
|
+
this.events = {};
|
|
14
|
+
/** Component width in pixels. This property is set automatically by the container. */
|
|
15
|
+
this._width = 400;
|
|
16
|
+
/** Component height in pixels. This property is set automatically by the container. */
|
|
17
|
+
this._height = 200;
|
|
18
|
+
/** Container width in pixels. This property is set automatically by the container. */
|
|
19
|
+
this._containerWidth = undefined;
|
|
20
|
+
/** Container height in pixels. This property is set automatically by the container. */
|
|
21
|
+
this._containerHeight = undefined;
|
|
22
|
+
this._setUpComponentEventsThrottled = throttle(this._setUpComponentEvents, 500);
|
|
23
|
+
this._setCustomAttributesThrottled = throttle(this._setCustomAttributes, 500);
|
|
24
|
+
if (type === ComponentType.SVG) {
|
|
25
|
+
this.element = document.createElementNS('http://www.w3.org/2000/svg', 'g');
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.element = document.createElement('div');
|
|
29
|
+
}
|
|
30
|
+
this.uid = guid();
|
|
31
|
+
this.g = select(this.element);
|
|
32
|
+
// Setting the root class if available
|
|
33
|
+
// eslint-disable-next-line dot-notation
|
|
34
|
+
const rootClass = (_b = (_a = this.constructor) === null || _a === void 0 ? void 0 : _a['selectors']) === null || _b === void 0 ? void 0 : _b.root;
|
|
35
|
+
if (rootClass)
|
|
36
|
+
this.g.attr('class', rootClass);
|
|
37
|
+
}
|
|
38
|
+
setConfig(config) {
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
40
|
+
const ConfigModel = this.config.constructor;
|
|
41
|
+
this.prevConfig = this.config; // Store the previous config instance
|
|
42
|
+
this.config = new ConfigModel().init(config);
|
|
43
|
+
}
|
|
44
|
+
setData(data) {
|
|
45
|
+
this.datamodel.data = data;
|
|
46
|
+
}
|
|
47
|
+
setSize(width, height, containerWidth, containerHeight) {
|
|
48
|
+
if (isFinite(width))
|
|
49
|
+
this._width = width;
|
|
50
|
+
if (isFinite(height))
|
|
51
|
+
this._height = height;
|
|
52
|
+
if (isFinite(containerWidth))
|
|
53
|
+
this._containerWidth = containerWidth;
|
|
54
|
+
if (isFinite(containerHeight))
|
|
55
|
+
this._containerHeight = containerHeight;
|
|
56
|
+
}
|
|
57
|
+
render(duration = this.config.duration) {
|
|
58
|
+
this._render(duration);
|
|
59
|
+
// While transition is in progress, we add the 'animating' attribute to the component's SVG group
|
|
60
|
+
const ANIMATING_ATTR = 'animating';
|
|
61
|
+
if (duration) {
|
|
62
|
+
this.g.attr(ANIMATING_ATTR, '');
|
|
63
|
+
const transition = this.g
|
|
64
|
+
.transition(ANIMATING_ATTR)
|
|
65
|
+
.duration(duration);
|
|
66
|
+
transition.on('end interrupt', () => {
|
|
67
|
+
this.g.attr(ANIMATING_ATTR, null);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
this._setUpComponentEventsThrottled();
|
|
71
|
+
this._setCustomAttributesThrottled();
|
|
72
|
+
}
|
|
73
|
+
get bleed() {
|
|
74
|
+
return { top: 0, bottom: 0, left: 0, right: 0 };
|
|
75
|
+
}
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
77
|
+
_render(duration = this.config.duration) {
|
|
78
|
+
}
|
|
79
|
+
_setCustomAttributes() {
|
|
80
|
+
const attributeMap = this.config.attributes;
|
|
81
|
+
Object.keys(attributeMap).forEach(className => {
|
|
82
|
+
Object.keys(attributeMap[className]).forEach(attr => {
|
|
83
|
+
this.g
|
|
84
|
+
.selectAll(`.${className}`)
|
|
85
|
+
.attr(attr, attributeMap[className][attr]);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
_setUpComponentEvents() {
|
|
90
|
+
// Set up default events
|
|
91
|
+
this._bindEvents(this.events);
|
|
92
|
+
// Set up user-defined events
|
|
93
|
+
this._bindEvents(this.config.events, '.user');
|
|
94
|
+
}
|
|
95
|
+
_bindEvents(events = this.events, suffix = '') {
|
|
96
|
+
Object.keys(events).forEach(className => {
|
|
97
|
+
Object.keys(events[className]).forEach(eventType => {
|
|
98
|
+
const selection = this.g.selectAll(`.${className}`);
|
|
99
|
+
selection.on(eventType + suffix, (event, d) => {
|
|
100
|
+
const els = selection.nodes();
|
|
101
|
+
const i = els.indexOf(event.currentTarget);
|
|
102
|
+
return events[className][eventType](d, event, i, els);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
destroy() {
|
|
108
|
+
var _a;
|
|
109
|
+
(_a = this.g) === null || _a === void 0 ? void 0 : _a.remove();
|
|
110
|
+
this.element = undefined;
|
|
111
|
+
}
|
|
112
|
+
isDestroyed() {
|
|
113
|
+
return !this.element;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { ComponentCore };
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/core/component/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\nimport { Transition } from 'd3-transition'\n\n// Core\nimport { CoreDataModel } from 'data-models/core'\n\n// Utils\nimport { throttle } from 'utils/data'\nimport { guid } from 'utils/misc'\n\n// Types\nimport { ComponentType, Sizing } from 'types/component'\nimport { Spacing } from 'types/spacing'\n\n// Local Types\nimport { VisEventCallback, VisEventType } from './types'\n\n// Config\nimport { ComponentConfig, ComponentConfigInterface } from './config'\n\nexport class ComponentCore<\n CoreDatum,\n ConfigClass extends ComponentConfig = ComponentConfig,\n ConfigInterface extends ComponentConfigInterface = ComponentConfigInterface,\n> {\n element: SVGGElement | HTMLElement\n type: ComponentType = ComponentType.SVG\n g: Selection<SVGGElement, unknown, null, undefined> | Selection<HTMLElement, unknown, null, undefined>\n config: ConfigClass\n prevConfig: ConfigClass\n datamodel: CoreDataModel<CoreDatum> = new CoreDataModel()\n sizing: Sizing | string = Sizing.Fit // Supported by SingleContainer and a subset of components only (Sankey)\n uid: string\n\n events: {\n [selector: string]: {\n [eventType in VisEventType]?: VisEventCallback;\n };\n } = {}\n\n /** Component width in pixels. This property is set automatically by the container. */\n protected _width = 400\n /** Component height in pixels. This property is set automatically by the container. */\n protected _height = 200\n /** Container width in pixels. This property is set automatically by the container. */\n protected _containerWidth: number | undefined = undefined\n /** Container height in pixels. This property is set automatically by the container. */\n protected _containerHeight: number | undefined = undefined\n\n _setUpComponentEventsThrottled = throttle(this._setUpComponentEvents, 500)\n _setCustomAttributesThrottled = throttle(this._setCustomAttributes, 500)\n\n constructor (type = ComponentType.SVG) {\n if (type === ComponentType.SVG) {\n this.element = document.createElementNS('http://www.w3.org/2000/svg', 'g')\n } else {\n this.element = document.createElement('div')\n }\n this.uid = guid()\n this.g = select(this.element) as Selection<SVGGElement, unknown, null, undefined> | Selection<HTMLElement, unknown, null, undefined>\n\n // Setting the root class if available\n // eslint-disable-next-line dot-notation\n const rootClass = this.constructor?.['selectors']?.root as string\n if (rootClass) this.g.attr('class', rootClass)\n }\n\n setConfig (config: ConfigInterface): void {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const ConfigModel = (this.config.constructor as typeof ComponentConfig)\n this.prevConfig = this.config // Store the previous config instance\n this.config = new ConfigModel().init(config) as ConfigClass\n }\n\n setData (data: CoreDatum): void {\n this.datamodel.data = data\n }\n\n setSize (width: number, height: number, containerWidth: number, containerHeight: number): void {\n if (isFinite(width)) this._width = width\n if (isFinite(height)) this._height = height\n if (isFinite(containerWidth)) this._containerWidth = containerWidth\n if (isFinite(containerHeight)) this._containerHeight = containerHeight\n }\n\n render (duration = this.config.duration): void {\n this._render(duration)\n\n // While transition is in progress, we add the 'animating' attribute to the component's SVG group\n const ANIMATING_ATTR = 'animating'\n if (duration) {\n this.g.attr(ANIMATING_ATTR, '')\n const transition = this.g\n .transition(ANIMATING_ATTR)\n .duration(duration) as Transition<SVGGElement | HTMLElement, unknown, null, undefined>\n\n transition.on('end interrupt', () => {\n this.g.attr(ANIMATING_ATTR, null)\n })\n }\n this._setUpComponentEventsThrottled()\n this._setCustomAttributesThrottled()\n }\n\n get bleed (): Spacing {\n return { top: 0, bottom: 0, left: 0, right: 0 }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n _render (duration = this.config.duration): void {\n }\n\n private _setCustomAttributes (): void {\n const attributeMap = this.config.attributes\n\n Object.keys(attributeMap).forEach(className => {\n Object.keys(attributeMap[className]).forEach(attr => {\n (this.g as Selection<SVGGElement | HTMLElement, unknown, null, undefined>)\n .selectAll(`.${className}`)\n .attr(attr, attributeMap[className][attr])\n })\n })\n }\n\n private _setUpComponentEvents (): void {\n // Set up default events\n this._bindEvents(this.events)\n\n // Set up user-defined events\n this._bindEvents(this.config.events, '.user')\n }\n\n private _bindEvents (events = this.events, suffix = ''): void {\n Object.keys(events).forEach(className => {\n Object.keys(events[className]).forEach(eventType => {\n const selection = (this.g as Selection<SVGGElement | HTMLElement, unknown, null, undefined>).selectAll(`.${className}`)\n selection.on(eventType + suffix, (event: Event, d) => {\n const els = selection.nodes()\n const i = els.indexOf(event.currentTarget as SVGGElement | HTMLElement)\n return events[className][eventType](d, event, i, els)\n })\n })\n })\n }\n\n public destroy (): void {\n this.g?.remove()\n this.element = undefined\n }\n\n public isDestroyed (): boolean {\n return !this.element\n }\n}\n"],"names":[],"mappings":";;;;;;MAoBa,aAAa,CAAA;AAgCxB,IAAA,WAAA,CAAa,IAAI,GAAG,aAAa,CAAC,GAAG,EAAA;;AA1BrC,QAAA,IAAA,CAAA,IAAI,GAAkB,aAAa,CAAC,GAAG,CAAA;AAIvC,QAAA,IAAA,CAAA,SAAS,GAA6B,IAAI,aAAa,EAAE,CAAA;AACzD,QAAA,IAAA,CAAA,MAAM,GAAoB,MAAM,CAAC,GAAG,CAAA;QAGpC,IAAM,CAAA,MAAA,GAIF,EAAE,CAAA;;QAGI,IAAM,CAAA,MAAA,GAAG,GAAG,CAAA;;QAEZ,IAAO,CAAA,OAAA,GAAG,GAAG,CAAA;;QAEb,IAAe,CAAA,eAAA,GAAuB,SAAS,CAAA;;QAE/C,IAAgB,CAAA,gBAAA,GAAuB,SAAS,CAAA;QAE1D,IAA8B,CAAA,8BAAA,GAAG,QAAQ,CAAC,IAAI,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAA;QAC1E,IAA6B,CAAA,6BAAA,GAAG,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAA;AAGtE,QAAA,IAAI,IAAI,KAAK,aAAa,CAAC,GAAG,EAAE;YAC9B,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,eAAe,CAAC,4BAA4B,EAAE,GAAG,C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AAC,CAAA;AACJ,aAAC,CAAC,CAAA;AACJ,SAAC,CAAC,CAAA;KACH;IAEM,OAAO,GAAA;;AACZ,QAAA,CAAA,EAAA,GAAA,IAAI,CAAC,CAAC,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,MAAM,EAAE,CAAA;AAChB,QAAA,IAAI,CAAC,OAAO,GAAG,SAAS,CAAA;KACzB;IAEM,WAAW,GAAA;AAChB,QAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAA;KACrB;AACF;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare type VisEventType = 'touchstart' | 'touchmove' | 'touchend' | 'mouseover' | 'mousemove' | 'mousedown' | 'mouseup' | 'click' | 'auxclick' | 'contextmenu' | 'dblclick' | 'mouseenter' | 'mouseleave' | 'mouseout' | 'scroll' | 'select' | 'wheel' | 'pointerdown' | 'pointerup' | 'pointerout' | 'pointermove';
|
|
2
|
+
export declare type VisEventCallback<Datum = any> = ((data: Datum, event: MouseEvent, i: number, els: (SVGElement | HTMLElement)[]) => void) | ((data: Datum, event: WheelEvent, i: number, els: (SVGElement | HTMLElement)[]) => void) | ((data: Datum, event: PointerEvent, i: number, els: (SVGElement | HTMLElement)[]) => void) | ((data: Datum, event: TouchEvent, i: number, els: (SVGElement | HTMLElement)[]) => void);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isPlainObject, merge } from '../../utils/data.js';
|
|
2
|
+
|
|
3
|
+
class Config {
|
|
4
|
+
init(config) {
|
|
5
|
+
Object.keys(config).forEach(key => {
|
|
6
|
+
if (isPlainObject(this[key]) && isPlainObject(config[key]))
|
|
7
|
+
this[key] = merge(this[key], config[key]);
|
|
8
|
+
else
|
|
9
|
+
this[key] = config[key];
|
|
10
|
+
});
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { Config };
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/core/config/index.ts"],"sourcesContent":["import { isPlainObject, merge } from 'utils/data'\n\nexport class Config {\n init<T> (config: T): this {\n Object.keys(config).forEach(key => {\n if (isPlainObject(this[key]) && isPlainObject(config[key])) this[key] = merge(this[key], config[key])\n else this[key] = config[key]\n })\n\n return this\n }\n}\n"],"names":[],"mappings":";;MAEa,MAAM,CAAA;AACjB,IAAA,IAAI,CAAK,MAAS,EAAA;QAChB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,IAAG;AAChC,YAAA,IAAI,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAAE,gBAAA,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;;gBAChG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;AAC9B,SAAC,CAAC,CAAA;AAEF,QAAA,OAAO,IAAI,CAAA;KACZ;AACF;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Config } from "../config";
|
|
2
|
+
import { Sizing } from "../../types/component";
|
|
3
|
+
import { Spacing } from "../../types/spacing";
|
|
4
|
+
export interface ContainerConfigInterface {
|
|
5
|
+
/** Animation duration of all the components within the container. Default: `undefined` */
|
|
6
|
+
duration?: number;
|
|
7
|
+
/** Margins. Default: `{ top: 0, bottom: 0, left: 0, right: 0 }` */
|
|
8
|
+
margin?: Spacing;
|
|
9
|
+
/** Padding. Default: `{ top: 0, bottom: 0, left: 0, right: 0 }` */
|
|
10
|
+
padding?: Spacing;
|
|
11
|
+
/** Defines whether components should fit into the container or the container should expand to fit to the component's size. Default: `Sizing.Fit` */
|
|
12
|
+
sizing?: Sizing | string;
|
|
13
|
+
/** Width in pixels or in CSS units.
|
|
14
|
+
* Percentage units `"%"` are not supported here. If you want to set `width` as a percentage, do it via `style`
|
|
15
|
+
* of the corresponding DOM element.
|
|
16
|
+
* By default, Container automatically fits to the size of the parent element.
|
|
17
|
+
* Default: `undefined`
|
|
18
|
+
*/
|
|
19
|
+
width?: number | string;
|
|
20
|
+
/** Height in pixels or in CSS units.
|
|
21
|
+
* Percentage units `"%"` are not supported here. If you want to set `height` as a percentage, do it via `style`
|
|
22
|
+
* of the corresponding DOM element.
|
|
23
|
+
* By default, Container automatically fits to the size of the parent element.
|
|
24
|
+
* Default: `undefined`
|
|
25
|
+
*/
|
|
26
|
+
height?: number | string;
|
|
27
|
+
/** Custom SVG defs available to all the components within the container. Default: `undefined`. */
|
|
28
|
+
svgDefs?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare class ContainerConfig extends Config implements ContainerConfigInterface {
|
|
31
|
+
duration: any;
|
|
32
|
+
margin: {
|
|
33
|
+
top: number;
|
|
34
|
+
bottom: number;
|
|
35
|
+
left: number;
|
|
36
|
+
right: number;
|
|
37
|
+
};
|
|
38
|
+
padding: {
|
|
39
|
+
top: number;
|
|
40
|
+
bottom: number;
|
|
41
|
+
left: number;
|
|
42
|
+
right: number;
|
|
43
|
+
};
|
|
44
|
+
sizing: Sizing;
|
|
45
|
+
width: any;
|
|
46
|
+
height: any;
|
|
47
|
+
svgDefs: any;
|
|
48
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Config } from '../config/index.js';
|
|
2
|
+
import { Sizing } from '../../types/component.js';
|
|
3
|
+
|
|
4
|
+
// Core
|
|
5
|
+
class ContainerConfig extends Config {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.duration = undefined;
|
|
9
|
+
this.margin = {
|
|
10
|
+
top: 0,
|
|
11
|
+
bottom: 0,
|
|
12
|
+
left: 0,
|
|
13
|
+
right: 0,
|
|
14
|
+
};
|
|
15
|
+
this.padding = {
|
|
16
|
+
top: 0,
|
|
17
|
+
bottom: 0,
|
|
18
|
+
left: 0,
|
|
19
|
+
right: 0,
|
|
20
|
+
};
|
|
21
|
+
this.sizing = Sizing.Fit;
|
|
22
|
+
this.width = undefined;
|
|
23
|
+
this.height = undefined;
|
|
24
|
+
this.svgDefs = undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { ContainerConfig };
|
|
29
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/core/container/config.ts"],"sourcesContent":["// Core\nimport { Config } from 'core/config'\n\n// Types\nimport { Sizing } from 'types/component'\nimport { Spacing } from 'types/spacing'\n\nexport interface ContainerConfigInterface {\n /** Animation duration of all the components within the container. Default: `undefined` */\n duration?: number;\n /** Margins. Default: `{ top: 0, bottom: 0, left: 0, right: 0 }` */\n margin?: Spacing;\n /** Padding. Default: `{ top: 0, bottom: 0, left: 0, right: 0 }` */\n padding?: Spacing;\n /** Defines whether components should fit into the container or the container should expand to fit to the component's size. Default: `Sizing.Fit` */\n sizing?: Sizing | string;\n /** Width in pixels or in CSS units.\n * Percentage units `\"%\"` are not supported here. If you want to set `width` as a percentage, do it via `style`\n * of the corresponding DOM element.\n * By default, Container automatically fits to the size of the parent element.\n * Default: `undefined`\n */\n width?: number | string;\n /** Height in pixels or in CSS units.\n * Percentage units `\"%\"` are not supported here. If you want to set `height` as a percentage, do it via `style`\n * of the corresponding DOM element.\n * By default, Container automatically fits to the size of the parent element.\n * Default: `undefined`\n */\n height?: number | string;\n /** Custom SVG defs available to all the components within the container. Default: `undefined`. */\n svgDefs?: string;\n}\n\nexport class ContainerConfig extends Config implements ContainerConfigInterface {\n duration = undefined\n margin = {\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n }\n\n padding = {\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n }\n\n sizing = Sizing.Fit\n width = undefined\n height = undefined\n\n svgDefs = undefined\n}\n"],"names":[],"mappings":";;;AAAA;AAkCM,MAAO,eAAgB,SAAQ,MAAM,CAAA;AAA3C,IAAA,WAAA,GAAA;;QACE,IAAQ,CAAA,QAAA,GAAG,SAAS,CAAA;AACpB,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,GAAG,EAAE,CAAC;AACN,YAAA,MAAM,EAAE,CAAC;AACT,YAAA,IAAI,EAAE,CAAC;AACP,YAAA,KAAK,EAAE,CAAC;SACT,CAAA;AAED,QAAA,IAAA,CAAA,OAAO,GAAG;AACR,YAAA,GAAG,EAAE,CAAC;AACN,YAAA,MAAM,EAAE,CAAC;AACT,YAAA,IAAI,EAAE,CAAC;AACP,YAAA,KAAK,EAAE,CAAC;SACT,CAAA;AAED,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAAC,GAAG,CAAA;QACnB,IAAK,CAAA,KAAA,GAAG,SAAS,CAAA;QACjB,IAAM,CAAA,MAAA,GAAG,SAAS,CAAA;QAElB,IAAO,CAAA,OAAA,GAAG,SAAS,CAAA;KACpB;AAAA;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Selection } from 'd3-selection';
|
|
2
|
+
import { ContainerConfig, ContainerConfigInterface } from './config';
|
|
3
|
+
export declare class ContainerCore {
|
|
4
|
+
svg: Selection<SVGSVGElement, unknown, null, undefined>;
|
|
5
|
+
element: SVGSVGElement;
|
|
6
|
+
prevConfig: ContainerConfig;
|
|
7
|
+
config: ContainerConfig;
|
|
8
|
+
protected _container: HTMLElement;
|
|
9
|
+
protected _requestedAnimationFrame: number;
|
|
10
|
+
protected _isFirstRender: boolean;
|
|
11
|
+
private _containerSize;
|
|
12
|
+
private _resizeObserver;
|
|
13
|
+
static DEFAULT_CONTAINER_HEIGHT: number;
|
|
14
|
+
constructor(element: HTMLElement);
|
|
15
|
+
updateContainer<T extends ContainerConfigInterface>(config: T): void;
|
|
16
|
+
_render(duration?: number): void;
|
|
17
|
+
render(duration?: any): void;
|
|
18
|
+
get containerWidth(): number;
|
|
19
|
+
get containerHeight(): number;
|
|
20
|
+
get width(): number;
|
|
21
|
+
get height(): number;
|
|
22
|
+
removeAllChildren(): void;
|
|
23
|
+
_onResize(): void;
|
|
24
|
+
_setUpResizeObserver(): void;
|
|
25
|
+
destroy(): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { select } from 'd3-selection';
|
|
2
|
+
import { ResizeObserver } from '@juggle/resize-observer';
|
|
3
|
+
import { Sizing } from '../../types/component.js';
|
|
4
|
+
import { clamp, isEqual } from '../../utils/data.js';
|
|
5
|
+
|
|
6
|
+
class ContainerCore {
|
|
7
|
+
constructor(element) {
|
|
8
|
+
this._isFirstRender = true;
|
|
9
|
+
this._requestedAnimationFrame = null;
|
|
10
|
+
this._container = element;
|
|
11
|
+
// Create SVG element for visualizations
|
|
12
|
+
this.svg = select(this._container).append('svg')
|
|
13
|
+
// We set `display` to `block` because inline elements have an invisible
|
|
14
|
+
// inline space that adds 4px to the height of the container
|
|
15
|
+
.style('display', 'block')
|
|
16
|
+
.attr('xmlns', 'http://www.w3.org/2000/svg')
|
|
17
|
+
.attr('height', ContainerCore.DEFAULT_CONTAINER_HEIGHT);
|
|
18
|
+
this.element = this.svg.node();
|
|
19
|
+
}
|
|
20
|
+
updateContainer(config) {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
22
|
+
const ConfigModel = this.config.constructor;
|
|
23
|
+
this.prevConfig = this.config;
|
|
24
|
+
this.config = new ConfigModel().init(config);
|
|
25
|
+
}
|
|
26
|
+
_render(duration) {
|
|
27
|
+
if (this.config.svgDefs) {
|
|
28
|
+
this.svg.select('.svgDefs').remove();
|
|
29
|
+
this.svg.append('defs').attr('class', 'svgDefs').html(this.config.svgDefs);
|
|
30
|
+
}
|
|
31
|
+
this._isFirstRender = false;
|
|
32
|
+
}
|
|
33
|
+
render(duration = this.config.duration) {
|
|
34
|
+
const width = this.config.width || this.containerWidth;
|
|
35
|
+
const height = this.config.height || this.containerHeight;
|
|
36
|
+
// We set SVG size in `render()` instead of `_render()`, because the size values in pixels will become
|
|
37
|
+
// available only in the next animation when being accessed via `element.clientWidth` and `element.clientHeight`,
|
|
38
|
+
// and we rely on those values when setting width and size of the components.
|
|
39
|
+
this.svg
|
|
40
|
+
.attr('width', width)
|
|
41
|
+
.attr('height', height);
|
|
42
|
+
// Set up Resize Observer. We do it in `render()` to capture container size change if it happened
|
|
43
|
+
// in the next animation frame after the initial `render` was called.
|
|
44
|
+
if (!this._resizeObserver)
|
|
45
|
+
this._setUpResizeObserver();
|
|
46
|
+
// Schedule the actual rendering in the next frame
|
|
47
|
+
cancelAnimationFrame(this._requestedAnimationFrame);
|
|
48
|
+
this._requestedAnimationFrame = requestAnimationFrame(() => {
|
|
49
|
+
this._render(duration);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
get containerWidth() {
|
|
53
|
+
return this.config.width
|
|
54
|
+
? this.element.clientWidth
|
|
55
|
+
: clamp(this._container.clientWidth || this._container.getBoundingClientRect().width, 0, Number.POSITIVE_INFINITY);
|
|
56
|
+
}
|
|
57
|
+
get containerHeight() {
|
|
58
|
+
return this.config.height
|
|
59
|
+
? this.element.clientHeight
|
|
60
|
+
: clamp(this._container.clientHeight || this._container.getBoundingClientRect().height, 0, Number.POSITIVE_INFINITY);
|
|
61
|
+
}
|
|
62
|
+
get width() {
|
|
63
|
+
return clamp(this.containerWidth - this.config.margin.left - this.config.margin.right, 0, Number.POSITIVE_INFINITY);
|
|
64
|
+
}
|
|
65
|
+
get height() {
|
|
66
|
+
return clamp(this.containerHeight - this.config.margin.top - this.config.margin.bottom, 0, Number.POSITIVE_INFINITY);
|
|
67
|
+
}
|
|
68
|
+
removeAllChildren() {
|
|
69
|
+
while (this.element.firstChild) {
|
|
70
|
+
this.element.removeChild(this.element.firstChild);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
_onResize() {
|
|
74
|
+
const { config } = this;
|
|
75
|
+
const redrawOnResize = config.sizing === Sizing.Fit || config.sizing === Sizing.FitWidth;
|
|
76
|
+
if (redrawOnResize)
|
|
77
|
+
this.render(0);
|
|
78
|
+
}
|
|
79
|
+
_setUpResizeObserver() {
|
|
80
|
+
const containerRect = this._container.getBoundingClientRect();
|
|
81
|
+
this._containerSize = { width: containerRect.width, height: containerRect.height };
|
|
82
|
+
this._resizeObserver = new ResizeObserver((entries, observer) => {
|
|
83
|
+
const resizedContainerRect = this._container.getBoundingClientRect();
|
|
84
|
+
const resizedContainerSize = { width: resizedContainerRect.width, height: resizedContainerRect.height };
|
|
85
|
+
const hasSizeChanged = !isEqual(this._containerSize, resizedContainerSize);
|
|
86
|
+
// Do resize only if element is attached to the DOM
|
|
87
|
+
// will come in useful when some ancestor of container becomes detached
|
|
88
|
+
if (hasSizeChanged && resizedContainerSize.width && resizedContainerSize.height) {
|
|
89
|
+
this._containerSize = resizedContainerSize;
|
|
90
|
+
this._onResize();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
this._resizeObserver.observe(this._container);
|
|
94
|
+
}
|
|
95
|
+
destroy() {
|
|
96
|
+
var _a;
|
|
97
|
+
cancelAnimationFrame(this._requestedAnimationFrame);
|
|
98
|
+
(_a = this._resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
99
|
+
this.svg.remove();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
103
|
+
ContainerCore.DEFAULT_CONTAINER_HEIGHT = 300;
|
|
104
|
+
|
|
105
|
+
export { ContainerCore };
|
|
106
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/core/container/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\nimport { ResizeObserver } from '@juggle/resize-observer'\n\n// Types\nimport { Sizing } from 'types/component'\n\n// Utils\nimport { isEqual, clamp } from 'utils/data'\n\n// Config\nimport { ContainerConfig, ContainerConfigInterface } from './config'\n\nexport class ContainerCore {\n svg: Selection<SVGSVGElement, unknown, null, undefined>\n element: SVGSVGElement\n prevConfig: ContainerConfig\n config: ContainerConfig\n\n protected _container: HTMLElement\n protected _requestedAnimationFrame: number\n protected _isFirstRender = true\n private _containerSize: { width: number; height: number }\n private _resizeObserver: ResizeObserver | undefined\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n static DEFAULT_CONTAINER_HEIGHT = 300\n\n constructor (element: HTMLElement) {\n this._requestedAnimationFrame = null\n this._container = element\n\n // Create SVG element for visualizations\n this.svg = select(this._container).append('svg')\n // We set `display` to `block` because inline elements have an invisible\n // inline space that adds 4px to the height of the container\n .style('display', 'block')\n .attr('xmlns', 'http://www.w3.org/2000/svg')\n .attr('height', ContainerCore.DEFAULT_CONTAINER_HEIGHT)\n\n this.element = this.svg.node()\n }\n\n updateContainer<T extends ContainerConfigInterface> (config: T): void {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const ConfigModel = (this.config.constructor as typeof ContainerConfig)\n this.prevConfig = this.config\n this.config = new ConfigModel().init(config)\n }\n\n _render (duration?: number): void {\n if (this.config.svgDefs) {\n this.svg.select('.svgDefs').remove()\n this.svg.append('defs').attr('class', 'svgDefs').html(this.config.svgDefs)\n }\n\n this._isFirstRender = false\n }\n\n render (duration = this.config.duration): void {\n const width = this.config.width || this.containerWidth\n const height = this.config.height || this.containerHeight\n\n // We set SVG size in `render()` instead of `_render()`, because the size values in pixels will become\n // available only in the next animation when being accessed via `element.clientWidth` and `element.clientHeight`,\n // and we rely on those values when setting width and size of the components.\n this.svg\n .attr('width', width)\n .attr('height', height)\n\n // Set up Resize Observer. We do it in `render()` to capture container size change if it happened\n // in the next animation frame after the initial `render` was called.\n if (!this._resizeObserver) this._setUpResizeObserver()\n\n // Schedule the actual rendering in the next frame\n cancelAnimationFrame(this._requestedAnimationFrame)\n this._requestedAnimationFrame = requestAnimationFrame(() => {\n this._render(duration)\n })\n }\n\n get containerWidth (): number {\n return this.config.width\n ? this.element.clientWidth\n : clamp(this._container.clientWidth || this._container.getBoundingClientRect().width, 0, Number.POSITIVE_INFINITY)\n }\n\n get containerHeight (): number {\n return this.config.height\n ? this.element.clientHeight\n : clamp(this._container.clientHeight || this._container.getBoundingClientRect().height, 0, Number.POSITIVE_INFINITY)\n }\n\n get width (): number {\n return clamp(this.containerWidth - this.config.margin.left - this.config.margin.right, 0, Number.POSITIVE_INFINITY)\n }\n\n get height (): number {\n return clamp(this.containerHeight - this.config.margin.top - this.config.margin.bottom, 0, Number.POSITIVE_INFINITY)\n }\n\n removeAllChildren (): void {\n while (this.element.firstChild) {\n this.element.removeChild(this.element.firstChild)\n }\n }\n\n _onResize (): void {\n const { config } = this\n const redrawOnResize = config.sizing === Sizing.Fit || config.sizing === Sizing.FitWidth\n if (redrawOnResize) this.render(0)\n }\n\n _setUpResizeObserver (): void {\n const containerRect = this._container.getBoundingClientRect()\n this._containerSize = { width: containerRect.width, height: containerRect.height }\n\n this._resizeObserver = new ResizeObserver((entries, observer) => {\n const resizedContainerRect = this._container.getBoundingClientRect()\n const resizedContainerSize = { width: resizedContainerRect.width, height: resizedContainerRect.height }\n const hasSizeChanged = !isEqual(this._containerSize, resizedContainerSize)\n // Do resize only if element is attached to the DOM\n // will come in useful when some ancestor of container becomes detached\n if (hasSizeChanged && resizedContainerSize.width && resizedContainerSize.height) {\n this._containerSize = resizedContainerSize\n this._onResize()\n }\n })\n this._resizeObserver.observe(this._container)\n }\n\n destroy (): void {\n cancelAnimationFrame(this._requestedAnimationFrame)\n this._resizeObserver?.disconnect()\n this.svg.remove()\n }\n}\n"],"names":[],"mappings":";;;;;MAYa,aAAa,CAAA;AAexB,IAAA,WAAA,CAAa,OAAoB,EAAA;QAPvB,IA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oB,CAAC,KAAK,EAAE,MAAM,EAAE,oBAAoB,CAAC,MAAM,EAAE,CAAA;YACvG,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAA;;;YAG1E,IAAI,cAAc,IAAI,oBAAoB,CAAC,KAAK,IAAI,oBAAoB,CAAC,MAAM,EAAE;AAC/E,gBAAA,IAAI,CAAC,cAAc,GAAG,oBAAoB,CAAA;gBAC1C,IAAI,CAAC,SAAS,EAAE,CAAA;AACjB,aAAA;AACH,SAAC,CAAC,CAAA;QACF,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;KAC9C;IAED,OAAO,GAAA;;AACL,QAAA,oBAAoB,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAA;AACnD,QAAA,CAAA,EAAA,GAAA,IAAI,CAAC,eAAe,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,UAAU,EAAE,CAAA;AAClC,QAAA,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAA;KAClB;;AA9GD;AACO,aAAwB,CAAA,wBAAA,GAAG,GAAG;;;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ContinuousScale } from "../../types/scale";
|
|
2
|
+
import { ColorAccessor, NumericAccessor } from "../../types/accessor";
|
|
3
|
+
import { ComponentConfig, ComponentConfigInterface } from '../component/config';
|
|
4
|
+
export interface XYComponentConfigInterface<Datum> extends ComponentConfigInterface {
|
|
5
|
+
/** Accessor function for getting the values along the X axis. Default: `undefined` */
|
|
6
|
+
x: NumericAccessor<Datum>;
|
|
7
|
+
/** A single of multiple accessor functions for getting the values along the Y axis. Default: `undefined` */
|
|
8
|
+
y: NumericAccessor<Datum> | NumericAccessor<Datum>[];
|
|
9
|
+
/** Accessor function for getting the unique data record id. Used for more persistent data updates. Default: `(d, i) => d.id ?? i` */
|
|
10
|
+
id?: ((d: Datum, i: number, ...any: any[]) => string);
|
|
11
|
+
/** Component color accessor function. Default: `d => d.color` */
|
|
12
|
+
color?: ColorAccessor<Datum> | ColorAccessor<Datum[]>;
|
|
13
|
+
/** Scale for X dimension, e.g. Scale.scaleLinear(). If you set xScale you'll be responsible for setting it's `domain` and `range` as well.
|
|
14
|
+
* Only continuous scales are supported.
|
|
15
|
+
* Default: `undefined`
|
|
16
|
+
*/
|
|
17
|
+
xScale?: ContinuousScale;
|
|
18
|
+
/** Scale for Y dimension, e.g. Scale.scaleLinear(). If you set yScale you'll be responsible for setting it's `domain` and `range` as well.
|
|
19
|
+
* Only continuous scales are supported.
|
|
20
|
+
* Default: `undefined`
|
|
21
|
+
*/
|
|
22
|
+
yScale?: ContinuousScale;
|
|
23
|
+
/** Identifies whether the component should be excluded from overall X and Y domain calculations or not.
|
|
24
|
+
* This property can be useful when you want pass individual data to a component and you don't want it to affect
|
|
25
|
+
* the scales of the chart.
|
|
26
|
+
* Default: `false`
|
|
27
|
+
*/
|
|
28
|
+
excludeFromDomainCalculation?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare class XYComponentConfig<Datum> extends ComponentConfig implements XYComponentConfigInterface<Datum> {
|
|
31
|
+
x: any;
|
|
32
|
+
y: any;
|
|
33
|
+
id: (d: Datum, i: number) => string;
|
|
34
|
+
color: (d: Datum | Datum[]) => string;
|
|
35
|
+
xScale: any;
|
|
36
|
+
yScale: any;
|
|
37
|
+
excludeFromDomainCalculation: boolean;
|
|
38
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ComponentConfig } from '../component/config.js';
|
|
2
|
+
|
|
3
|
+
// Config
|
|
4
|
+
class XYComponentConfig extends ComponentConfig {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.x = undefined;
|
|
8
|
+
this.y = undefined;
|
|
9
|
+
// eslint-disable-next-line dot-notation
|
|
10
|
+
this.id = (d, i) => { var _a; return (_a = d['id']) !== null && _a !== void 0 ? _a : `${i}`; };
|
|
11
|
+
// eslint-disable-next-line dot-notation
|
|
12
|
+
this.color = (d) => d['color'];
|
|
13
|
+
this.xScale = undefined;
|
|
14
|
+
this.yScale = undefined;
|
|
15
|
+
this.excludeFromDomainCalculation = false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { XYComponentConfig };
|
|
20
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/core/xy-component/config.ts"],"sourcesContent":["import { ContinuousScale } from 'types/scale'\n\n// Types\nimport { ColorAccessor, NumericAccessor } from 'types/accessor'\n\n// Config\nimport { ComponentConfig, ComponentConfigInterface } from '../component/config'\n\nexport interface XYComponentConfigInterface<Datum> extends ComponentConfigInterface {\n /** Accessor function for getting the values along the X axis. Default: `undefined` */\n x: NumericAccessor<Datum>;\n /** A single of multiple accessor functions for getting the values along the Y axis. Default: `undefined` */\n y: NumericAccessor<Datum> | NumericAccessor<Datum>[];\n /** Accessor function for getting the unique data record id. Used for more persistent data updates. Default: `(d, i) => d.id ?? i` */\n id?: ((d: Datum, i: number, ...any: any[]) => string);\n /** Component color accessor function. Default: `d => d.color` */\n color?: ColorAccessor<Datum> | ColorAccessor<Datum[]>;\n /** Scale for X dimension, e.g. Scale.scaleLinear(). If you set xScale you'll be responsible for setting it's `domain` and `range` as well.\n * Only continuous scales are supported.\n * Default: `undefined`\n */\n xScale?: ContinuousScale;\n /** Scale for Y dimension, e.g. Scale.scaleLinear(). If you set yScale you'll be responsible for setting it's `domain` and `range` as well.\n * Only continuous scales are supported.\n * Default: `undefined`\n */\n yScale?: ContinuousScale;\n /** Identifies whether the component should be excluded from overall X and Y domain calculations or not.\n * This property can be useful when you want pass individual data to a component and you don't want it to affect\n * the scales of the chart.\n * Default: `false`\n */\n excludeFromDomainCalculation?: boolean;\n}\n\nexport class XYComponentConfig<Datum> extends ComponentConfig implements XYComponentConfigInterface<Datum> {\n x = undefined\n y = undefined\n // eslint-disable-next-line dot-notation\n id = (d: Datum, i: number): string => d['id'] ?? `${i}`\n // eslint-disable-next-line dot-notation\n color = (d: Datum | Datum[]): string => d['color']\n xScale = undefined\n yScale = undefined\n excludeFromDomainCalculation = false\n}\n"],"names":[],"mappings":";;AAKA;AA8BM,MAAO,iBAAyB,SAAQ,eAAe,CAAA;AAA7D,IAAA,WAAA,GAAA;;QACE,IAAC,CAAA,CAAA,GAAG,SAAS,CAAA;QACb,IAAC,CAAA,CAAA,GAAG,SAAS,CAAA;;QAEb,IAAE,CAAA,EAAA,GAAG,CAAC,CAAQ,EAAE,CAAS,eAAa,OAAA,CAAA,EAAA,GAAA,CAAC,CAAC,IAAI,CAAC,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,CAAA,EAAG,CAAC,CAAE,CAAA,CAAA,EAAA,CAAA;;QAEvD,IAAK,CAAA,KAAA,GAAG,CAAC,CAAkB,KAAa,CAAC,CAAC,OAAO,CAAC,CAAA;QAClD,IAAM,CAAA,MAAA,GAAG,SAAS,CAAA;QAClB,IAAM,CAAA,MAAA,GAAG,SAAS,CAAA;QAClB,IAA4B,CAAA,4BAAA,GAAG,KAAK,CAAA;KACrC;AAAA;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Selection } from 'd3-selection';
|
|
2
|
+
import { ComponentCore } from "../component";
|
|
3
|
+
import { SeriesDataModel } from "../../data-models/series";
|
|
4
|
+
import { ContinuousScale, ScaleDimension } from "../../types/scale";
|
|
5
|
+
import { XYComponentConfig, XYComponentConfigInterface } from './config';
|
|
6
|
+
export declare class XYComponentCore<Datum, ConfigClass extends XYComponentConfig<Datum> = XYComponentConfig<Datum>, ConfigInterface extends Partial<XYComponentConfigInterface<Datum>> = Partial<XYComponentConfigInterface<Datum>>> extends ComponentCore<Datum[], ConfigClass, ConfigInterface> {
|
|
7
|
+
element: SVGGraphicsElement;
|
|
8
|
+
g: Selection<SVGGElement, unknown, null, undefined>;
|
|
9
|
+
config: ConfigClass;
|
|
10
|
+
prevConfig: ConfigClass;
|
|
11
|
+
datamodel: SeriesDataModel<Datum>;
|
|
12
|
+
/** Clippable components can be affected by a clipping path (set up in the container) */
|
|
13
|
+
clippable: boolean;
|
|
14
|
+
/** Identifies whether the component displayed stacked data (eg StackedBar, Area) */
|
|
15
|
+
stacked: boolean;
|
|
16
|
+
private _xScale;
|
|
17
|
+
private _yScale;
|
|
18
|
+
get xScale(): ContinuousScale;
|
|
19
|
+
get yScale(): ContinuousScale;
|
|
20
|
+
setConfig(config: ConfigInterface): void;
|
|
21
|
+
setScaleDomain(dimension: ScaleDimension, domain: number[]): void;
|
|
22
|
+
setScaleRange(dimension: ScaleDimension, range: number[]): void;
|
|
23
|
+
setScale(dimension: ScaleDimension, scale: ContinuousScale): void;
|
|
24
|
+
getDataExtent(dimension: ScaleDimension, scaleByVisibleData: boolean): number[];
|
|
25
|
+
getXDataExtent(): number[];
|
|
26
|
+
getYDataExtent(scaleByVisibleData: boolean): number[];
|
|
27
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ComponentCore } from '../component/index.js';
|
|
2
|
+
import { SeriesDataModel } from '../../data-models/series.js';
|
|
3
|
+
import { getExtent, filterDataByRange, isArray } from '../../utils/data.js';
|
|
4
|
+
import { Scale, ScaleDimension } from '../../types/scale.js';
|
|
5
|
+
|
|
6
|
+
// Core
|
|
7
|
+
class XYComponentCore extends ComponentCore {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.datamodel = new SeriesDataModel();
|
|
11
|
+
/** Clippable components can be affected by a clipping path (set up in the container) */
|
|
12
|
+
this.clippable = true;
|
|
13
|
+
/** Identifies whether the component displayed stacked data (eg StackedBar, Area) */
|
|
14
|
+
this.stacked = false;
|
|
15
|
+
this._xScale = Scale.scaleLinear();
|
|
16
|
+
this._yScale = Scale.scaleLinear();
|
|
17
|
+
}
|
|
18
|
+
get xScale() {
|
|
19
|
+
return this.config.xScale || this._xScale;
|
|
20
|
+
}
|
|
21
|
+
get yScale() {
|
|
22
|
+
return this.config.yScale || this._yScale;
|
|
23
|
+
}
|
|
24
|
+
setConfig(config) {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
// We don't allow changing scales after the component has been initialized
|
|
27
|
+
if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.xScale)
|
|
28
|
+
config.xScale = this.config.xScale;
|
|
29
|
+
if ((_b = this.config) === null || _b === void 0 ? void 0 : _b.yScale)
|
|
30
|
+
config.yScale = this.config.yScale;
|
|
31
|
+
super.setConfig(config);
|
|
32
|
+
}
|
|
33
|
+
setScaleDomain(dimension, domain) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
if (dimension === ScaleDimension.X)
|
|
36
|
+
(_a = this._xScale) === null || _a === void 0 ? void 0 : _a.domain(domain);
|
|
37
|
+
if (dimension === ScaleDimension.Y)
|
|
38
|
+
(_b = this._yScale) === null || _b === void 0 ? void 0 : _b.domain(domain);
|
|
39
|
+
}
|
|
40
|
+
setScaleRange(dimension, range) {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
if (dimension === ScaleDimension.X)
|
|
43
|
+
(_a = this._xScale) === null || _a === void 0 ? void 0 : _a.range(range);
|
|
44
|
+
if (dimension === ScaleDimension.Y)
|
|
45
|
+
(_b = this._yScale) === null || _b === void 0 ? void 0 : _b.range(range);
|
|
46
|
+
}
|
|
47
|
+
setScale(dimension, scale) {
|
|
48
|
+
if (scale && (dimension === ScaleDimension.X))
|
|
49
|
+
this._xScale = scale;
|
|
50
|
+
if (scale && (dimension === ScaleDimension.Y))
|
|
51
|
+
this._yScale = scale;
|
|
52
|
+
}
|
|
53
|
+
getDataExtent(dimension, scaleByVisibleData) {
|
|
54
|
+
const { config, datamodel } = this;
|
|
55
|
+
switch (dimension) {
|
|
56
|
+
case ScaleDimension.X: return this.getXDataExtent();
|
|
57
|
+
case ScaleDimension.Y: return this.getYDataExtent(scaleByVisibleData);
|
|
58
|
+
default: return getExtent(datamodel.data, config[dimension]);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
getXDataExtent() {
|
|
62
|
+
const { config, datamodel } = this;
|
|
63
|
+
return getExtent(datamodel.data, config.x);
|
|
64
|
+
}
|
|
65
|
+
getYDataExtent(scaleByVisibleData) {
|
|
66
|
+
const { config, datamodel } = this;
|
|
67
|
+
const data = scaleByVisibleData ? filterDataByRange(datamodel.data, this.xScale.domain(), config.x) : datamodel.data;
|
|
68
|
+
const yAccessors = (isArray(config.y) ? config.y : [config.y]);
|
|
69
|
+
return getExtent(data, ...yAccessors);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { XYComponentCore };
|
|
74
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/core/xy-component/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\n\n// Core\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\n\n// Utils\nimport { filterDataByRange, getExtent, isArray } from 'utils/data'\n\n// Types\nimport { NumericAccessor } from 'types/accessor'\nimport { ContinuousScale, Scale, ScaleDimension } from 'types/scale'\n\n// Config\nimport { XYComponentConfig, XYComponentConfigInterface } from './config'\n\nexport class XYComponentCore<\n Datum,\n ConfigClass extends XYComponentConfig<Datum> = XYComponentConfig<Datum>,\n ConfigInterface extends Partial<XYComponentConfigInterface<Datum>> = Partial<XYComponentConfigInterface<Datum>>,\n> extends ComponentCore<Datum[], ConfigClass, ConfigInterface> {\n element: SVGGraphicsElement\n g: Selection<SVGGElement, unknown, null, undefined>\n config: ConfigClass\n prevConfig: ConfigClass\n datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n\n /** Clippable components can be affected by a clipping path (set up in the container) */\n clippable = true\n\n /** Identifies whether the component displayed stacked data (eg StackedBar, Area) */\n stacked = false\n\n private _xScale: ContinuousScale = Scale.scaleLinear()\n private _yScale: ContinuousScale = Scale.scaleLinear()\n\n get xScale (): ContinuousScale {\n return this.config.xScale || this._xScale\n }\n\n get yScale (): ContinuousScale {\n return this.config.yScale || this._yScale\n }\n\n setConfig (config: ConfigInterface): void {\n // We don't allow changing scales after the component has been initialized\n if (this.config?.xScale) config.xScale = this.config.xScale\n if (this.config?.yScale) config.yScale = this.config.yScale\n\n super.setConfig(config)\n }\n\n setScaleDomain (dimension: ScaleDimension, domain: number[]): void {\n if (dimension === ScaleDimension.X) this._xScale?.domain(domain)\n if (dimension === ScaleDimension.Y) this._yScale?.domain(domain)\n }\n\n setScaleRange (dimension: ScaleDimension, range: number[]): void {\n if (dimension === ScaleDimension.X) this._xScale?.range(range)\n if (dimension === ScaleDimension.Y) this._yScale?.range(range)\n }\n\n setScale (dimension: ScaleDimension, scale: ContinuousScale): void {\n if (scale && (dimension === ScaleDimension.X)) this._xScale = scale\n if (scale && (dimension === ScaleDimension.Y)) this._yScale = scale\n }\n\n getDataExtent (dimension: ScaleDimension, scaleByVisibleData: boolean): number[] {\n const { config, datamodel } = this\n\n switch (dimension) {\n case ScaleDimension.X: return this.getXDataExtent()\n case ScaleDimension.Y: return this.getYDataExtent(scaleByVisibleData)\n default: return getExtent(datamodel.data, config[dimension])\n }\n }\n\n getXDataExtent (): number[] {\n const { config, datamodel } = this\n return getExtent(datamodel.data, config.x)\n }\n\n getYDataExtent (scaleByVisibleData: boolean): number[] {\n const { config, datamodel } = this\n\n const data = scaleByVisibleData ? filterDataByRange(datamodel.data, this.xScale.domain() as [number, number], config.x) : datamodel.data\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n return getExtent(data, ...yAccessors)\n }\n}\n"],"names":[],"mappings":";;;;;AAEA;AAcM,MAAO,eAIX,SAAQ,aAAoD,CAAA;AAJ9D,IAAA,WAAA,GAAA;;AASE,QAAA,IAAA,CAAA,SAAS,GAA2B,IAA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AAE,SAAS,EAAE,GAAG,IAAI,CAAA;QAClC,OAAO,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;KAC3C;AAED,IAAA,cAAc,CAAE,kBAA2B,EAAA;AACzC,QAAA,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;AAElC,QAAA,MAAM,IAAI,GAAG,kBAAkB,GAAG,iBAAiB,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAsB,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,IAAI,CAAA;QACxI,MAAM,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAA6B,CAAA;AAC1F,QAAA,OAAO,SAAS,CAAC,IAAI,EAAE,GAAG,UAAU,CAAC,CAAA;KACtC;AACF;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sources":["../../src/data-models/core.ts"],"sourcesContent":["export class CoreDataModel<T> {\n protected _data: T | undefined\n\n get data (): T {\n return this._data\n }\n\n set data (value: T) {\n this._data = value\n }\n\n constructor (data?: T) {\n this.data = data\n }\n}\n"],"names":[],"mappings":"MAAa,aAAa,CAAA;AAWxB,IAAA,WAAA,CAAa,IAAQ,EAAA;AACnB,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;KACjB;AAVD,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,IAAI,CAAC,KAAK,CAAA;KAClB;IAED,IAAI,IAAI,CAAE,KAAQ,EAAA;AAChB,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;KACnB;AAKF;;;;"}
|