@communitiesuk/svelte-component-library 0.1.17

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 (217) hide show
  1. package/README.md +188 -0
  2. package/dist/assets/css/govuk-frontend.min.css +2 -0
  3. package/dist/assets/css/govuk-frontend.min.css.map +1 -0
  4. package/dist/assets/fonts/bold-affa96571d-v2.woff +0 -0
  5. package/dist/assets/fonts/bold-b542beb274-v2.woff2 +0 -0
  6. package/dist/assets/fonts/light-94a07e06a1-v2.woff2 +0 -0
  7. package/dist/assets/fonts/light-f591b13f7d-v2.woff +0 -0
  8. package/dist/assets/govuk_publishing_components/images/icon-autocomplete-search-suggestion.svg +4 -0
  9. package/dist/assets/govuk_publishing_components/images/icon-close.svg +1 -0
  10. package/dist/assets/images/favicon.ico +0 -0
  11. package/dist/assets/images/favicon.svg +1 -0
  12. package/dist/assets/images/govuk-crest-2x.png +0 -0
  13. package/dist/assets/images/govuk-crest.png +0 -0
  14. package/dist/assets/images/govuk-crest.svg +1 -0
  15. package/dist/assets/images/govuk-icon-180.png +0 -0
  16. package/dist/assets/images/govuk-icon-192.png +0 -0
  17. package/dist/assets/images/govuk-icon-512.png +0 -0
  18. package/dist/assets/images/govuk-icon-mask.svg +1 -0
  19. package/dist/assets/images/govuk-opengraph-image.png +0 -0
  20. package/dist/assets/images/homepage-illustration.svg +1 -0
  21. package/dist/assets/images/homepage.svg +44 -0
  22. package/dist/assets/images/masthead-illustration.svg +123 -0
  23. package/dist/assets/images/oflog_crest_black.png +0 -0
  24. package/dist/assets/images/oflog_crest_white.png +0 -0
  25. package/dist/assets/images/undraw_approved-wireframe_odf4.svg +1 -0
  26. package/dist/assets/images/undraw_collaborators_rgw4.svg +1 -0
  27. package/dist/assets/images/undraw_content-creator_vuqg.svg +1 -0
  28. package/dist/assets/images/undraw_online-media_opxh.svg +1 -0
  29. package/dist/assets/images/undraw_pull-request_zlsu.svg +1 -0
  30. package/dist/assets/images/undraw_reviewed-docs_g0cg.svg +1 -0
  31. package/dist/components/FilterPanel/codeBlocks.d.ts +3 -0
  32. package/dist/components/FilterPanel/codeBlocks.js +418 -0
  33. package/dist/components/content/InsetText.svelte +21 -0
  34. package/dist/components/content/InsetText.svelte.d.ts +7 -0
  35. package/dist/components/content/WarningText.svelte +27 -0
  36. package/dist/components/content/WarningText.svelte.d.ts +8 -0
  37. package/dist/components/data-vis/axis/Axis.svelte +51 -0
  38. package/dist/components/data-vis/axis/Axis.svelte.d.ts +33 -0
  39. package/dist/components/data-vis/axis/Ticks.svelte +113 -0
  40. package/dist/components/data-vis/axis/Ticks.svelte.d.ts +33 -0
  41. package/dist/components/data-vis/line-chart/Line.svelte +150 -0
  42. package/dist/components/data-vis/line-chart/Line.svelte.d.ts +85 -0
  43. package/dist/components/data-vis/line-chart/LineChart.svelte +249 -0
  44. package/dist/components/data-vis/line-chart/LineChart.svelte.d.ts +73 -0
  45. package/dist/components/data-vis/line-chart/Lines.svelte +138 -0
  46. package/dist/components/data-vis/line-chart/Lines.svelte.d.ts +57 -0
  47. package/dist/components/data-vis/line-chart/Marker.svelte +61 -0
  48. package/dist/components/data-vis/line-chart/Marker.svelte.d.ts +37 -0
  49. package/dist/components/data-vis/line-chart/SeriesLabel.svelte +67 -0
  50. package/dist/components/data-vis/line-chart/SeriesLabel.svelte.d.ts +43 -0
  51. package/dist/components/data-vis/line-chart/ValueLabel.svelte +50 -0
  52. package/dist/components/data-vis/line-chart/ValueLabel.svelte.d.ts +25 -0
  53. package/dist/components/data-vis/map/Map.svelte +392 -0
  54. package/dist/components/data-vis/map/Map.svelte.d.ts +47 -0
  55. package/dist/components/data-vis/map/MapLegend.svelte +41 -0
  56. package/dist/components/data-vis/map/MapLegend.svelte.d.ts +15 -0
  57. package/dist/components/data-vis/map/NonStandardControls.svelte +42 -0
  58. package/dist/components/data-vis/map/NonStandardControls.svelte.d.ts +13 -0
  59. package/dist/components/data-vis/map/Tooltip.svelte +41 -0
  60. package/dist/components/data-vis/map/Tooltip.svelte.d.ts +19 -0
  61. package/dist/components/data-vis/map/colorbrewer.d.ts +337 -0
  62. package/dist/components/data-vis/map/colorbrewer.js +1523 -0
  63. package/dist/components/data-vis/map/colors.d.ts +13 -0
  64. package/dist/components/data-vis/map/colors.js +65 -0
  65. package/dist/components/data-vis/map/dataJoin.d.ts +2 -0
  66. package/dist/components/data-vis/map/dataJoin.js +27 -0
  67. package/dist/components/data-vis/map/fullTopo.json +1 -0
  68. package/dist/components/data-vis/map/jenks.d.ts +1 -0
  69. package/dist/components/data-vis/map/jenks.js +51 -0
  70. package/dist/components/data-vis/map/lad2023.json +1 -0
  71. package/dist/components/data-vis/map/mapUtils.d.ts +5 -0
  72. package/dist/components/data-vis/map/mapUtils.js +86 -0
  73. package/dist/components/data-vis/map/topo.json +1 -0
  74. package/dist/components/data-vis/table/Table.svelte +247 -0
  75. package/dist/components/data-vis/table/Table.svelte.d.ts +19 -0
  76. package/dist/components/layout/Breadcrumbs.svelte +191 -0
  77. package/dist/components/layout/Breadcrumbs.svelte.d.ts +24 -0
  78. package/dist/components/layout/Footer.svelte +171 -0
  79. package/dist/components/layout/Footer.svelte.d.ts +30 -0
  80. package/dist/components/layout/Header.svelte +43 -0
  81. package/dist/components/layout/Header.svelte.d.ts +7 -0
  82. package/dist/components/layout/InternalHeader.svelte +628 -0
  83. package/dist/components/layout/InternalHeader.svelte.d.ts +15 -0
  84. package/dist/components/layout/PhaseBanner.svelte +28 -0
  85. package/dist/components/layout/PhaseBanner.svelte.d.ts +9 -0
  86. package/dist/components/layout/ServiceNavigation.svelte +143 -0
  87. package/dist/components/layout/ServiceNavigation.svelte.d.ts +13 -0
  88. package/dist/components/layout/SideNavigation.svelte +345 -0
  89. package/dist/components/layout/SideNavigation.svelte.d.ts +25 -0
  90. package/dist/components/layout/service-navigation-nested-mobile/HeaderNav.svelte +91 -0
  91. package/dist/components/layout/service-navigation-nested-mobile/HeaderNav.svelte.d.ts +15 -0
  92. package/dist/components/layout/service-navigation-nested-mobile/MobileNav.svelte +233 -0
  93. package/dist/components/layout/service-navigation-nested-mobile/MobileNav.svelte.d.ts +27 -0
  94. package/dist/components/layout/service-navigation-nested-mobile/ServiceNavigationNestedMobile.svelte +70 -0
  95. package/dist/components/layout/service-navigation-nested-mobile/ServiceNavigationNestedMobile.svelte.d.ts +11 -0
  96. package/dist/components/layout/service-navigation-nested-mobile/SideNav.svelte +276 -0
  97. package/dist/components/layout/service-navigation-nested-mobile/SideNav.svelte.d.ts +22 -0
  98. package/dist/components/ui/Accordion.svelte +244 -0
  99. package/dist/components/ui/Accordion.svelte.d.ts +23 -0
  100. package/dist/components/ui/Breadcrumbs.svelte +198 -0
  101. package/dist/components/ui/Breadcrumbs.svelte.d.ts +24 -0
  102. package/dist/components/ui/Button.svelte +96 -0
  103. package/dist/components/ui/Button.svelte.d.ts +17 -0
  104. package/dist/components/ui/CheckBox.svelte +198 -0
  105. package/dist/components/ui/CheckBox.svelte.d.ts +27 -0
  106. package/dist/components/ui/ContentsList.svelte +1117 -0
  107. package/dist/components/ui/ContentsList.svelte.d.ts +25 -0
  108. package/dist/components/ui/DateInput.svelte +255 -0
  109. package/dist/components/ui/DateInput.svelte.d.ts +59 -0
  110. package/dist/components/ui/Details.svelte +12 -0
  111. package/dist/components/ui/Details.svelte.d.ts +13 -0
  112. package/dist/components/ui/FilterPanel.svelte +588 -0
  113. package/dist/components/ui/FilterPanel.svelte.d.ts +74 -0
  114. package/dist/components/ui/Footer.svelte +171 -0
  115. package/dist/components/ui/Footer.svelte.d.ts +30 -0
  116. package/dist/components/ui/Header.svelte +43 -0
  117. package/dist/components/ui/Header.svelte.d.ts +7 -0
  118. package/dist/components/ui/Masthead.svelte +267 -0
  119. package/dist/components/ui/Masthead.svelte.d.ts +12 -0
  120. package/dist/components/ui/NavigationExample.svelte +117 -0
  121. package/dist/components/ui/NavigationExample.svelte.d.ts +3 -0
  122. package/dist/components/ui/NotificationBanner.svelte +93 -0
  123. package/dist/components/ui/NotificationBanner.svelte.d.ts +15 -0
  124. package/dist/components/ui/Radios.svelte +176 -0
  125. package/dist/components/ui/Radios.svelte.d.ts +28 -0
  126. package/dist/components/ui/RelatedContent.svelte +596 -0
  127. package/dist/components/ui/RelatedContent.svelte.d.ts +29 -0
  128. package/dist/components/ui/Search.svelte +499 -0
  129. package/dist/components/ui/Search.svelte.d.ts +32 -0
  130. package/dist/components/ui/SearchAutocomplete.svelte +655 -0
  131. package/dist/components/ui/SearchAutocomplete.svelte.d.ts +37 -0
  132. package/dist/components/ui/Select.svelte +116 -0
  133. package/dist/components/ui/Select.svelte.d.ts +22 -0
  134. package/dist/components/ui/ServiceNavigation.svelte +143 -0
  135. package/dist/components/ui/ServiceNavigation.svelte.d.ts +13 -0
  136. package/dist/components/ui/SideNavigation.svelte +346 -0
  137. package/dist/components/ui/SideNavigation.svelte.d.ts +25 -0
  138. package/dist/components/ui/Tabs.svelte +306 -0
  139. package/dist/components/ui/Tabs.svelte.d.ts +18 -0
  140. package/dist/components/ui/WhatsNew.svelte +155 -0
  141. package/dist/components/ui/WhatsNew.svelte.d.ts +29 -0
  142. package/dist/config.d.ts +51 -0
  143. package/dist/config.js +44 -0
  144. package/dist/icons/DoubleChevronButton.svelte +62 -0
  145. package/dist/icons/DoubleChevronButton.svelte.d.ts +13 -0
  146. package/dist/icons/IconSearch.svelte +42 -0
  147. package/dist/icons/IconSearch.svelte.d.ts +6 -0
  148. package/dist/icons/SingleChevronButtonWithLabel.svelte +132 -0
  149. package/dist/icons/SingleChevronButtonWithLabel.svelte.d.ts +19 -0
  150. package/dist/index.d.ts +44 -0
  151. package/dist/index.js +45 -0
  152. package/dist/main.css +1 -0
  153. package/dist/package-wrapping/BaseInformation.svelte +82 -0
  154. package/dist/package-wrapping/BaseInformation.svelte.d.ts +15 -0
  155. package/dist/package-wrapping/BaseNameAndStatus.svelte +108 -0
  156. package/dist/package-wrapping/BaseNameAndStatus.svelte.d.ts +10 -0
  157. package/dist/package-wrapping/CodeBlock.svelte +62 -0
  158. package/dist/package-wrapping/CodeBlock.svelte.d.ts +12 -0
  159. package/dist/package-wrapping/ComponentDemo.svelte +114 -0
  160. package/dist/package-wrapping/ComponentDemo.svelte.d.ts +25 -0
  161. package/dist/package-wrapping/ComponentDemoTEMP.svelte +305 -0
  162. package/dist/package-wrapping/ComponentDemoTEMP.svelte.d.ts +21 -0
  163. package/dist/package-wrapping/ComponentDetails.svelte +123 -0
  164. package/dist/package-wrapping/ComponentDetails.svelte.d.ts +13 -0
  165. package/dist/package-wrapping/DividerLine.svelte +21 -0
  166. package/dist/package-wrapping/DividerLine.svelte.d.ts +17 -0
  167. package/dist/package-wrapping/InputForParameter.svelte +205 -0
  168. package/dist/package-wrapping/InputForParameter.svelte.d.ts +13 -0
  169. package/dist/package-wrapping/InputForParameterUpdated.svelte +222 -0
  170. package/dist/package-wrapping/InputForParameterUpdated.svelte.d.ts +17 -0
  171. package/dist/package-wrapping/InputForParameterUpdatedTEMP.svelte +203 -0
  172. package/dist/package-wrapping/InputForParameterUpdatedTEMP.svelte.d.ts +17 -0
  173. package/dist/package-wrapping/ListOfComponentStatuses.svelte +19 -0
  174. package/dist/package-wrapping/ListOfComponentStatuses.svelte.d.ts +11 -0
  175. package/dist/package-wrapping/OverlayAndComponentContainer.svelte +426 -0
  176. package/dist/package-wrapping/OverlayAndComponentContainer.svelte.d.ts +33 -0
  177. package/dist/package-wrapping/ParametersSection.svelte +235 -0
  178. package/dist/package-wrapping/ParametersSection.svelte.d.ts +19 -0
  179. package/dist/package-wrapping/ParsingErrorToastsContainer.svelte +50 -0
  180. package/dist/package-wrapping/ParsingErrorToastsContainer.svelte.d.ts +15 -0
  181. package/dist/package-wrapping/Pill.svelte +54 -0
  182. package/dist/package-wrapping/Pill.svelte.d.ts +25 -0
  183. package/dist/package-wrapping/PlaygroundDetails.svelte +106 -0
  184. package/dist/package-wrapping/PlaygroundDetails.svelte.d.ts +13 -0
  185. package/dist/package-wrapping/ScreenSizeRadio.svelte +24 -0
  186. package/dist/package-wrapping/ScreenSizeRadio.svelte.d.ts +11 -0
  187. package/dist/package-wrapping/ScreenSizeRadioUpdated.svelte +23 -0
  188. package/dist/package-wrapping/ScreenSizeRadioUpdated.svelte.d.ts +11 -0
  189. package/dist/package-wrapping/SidebarContainer.svelte +103 -0
  190. package/dist/package-wrapping/SidebarContainer.svelte.d.ts +23 -0
  191. package/dist/package-wrapping/WrapperDetailsUpdate.svelte +40 -0
  192. package/dist/package-wrapping/WrapperDetailsUpdate.svelte.d.ts +15 -0
  193. package/dist/package-wrapping/templates/Template.svelte +100 -0
  194. package/dist/package-wrapping/templates/Template.svelte.d.ts +25 -0
  195. package/dist/templates/ComponentPageTemplate.svelte +1 -0
  196. package/dist/templates/ComponentPageTemplate.svelte.d.ts +26 -0
  197. package/dist/utils/data-transformations/convertCSV.d.ts +2 -0
  198. package/dist/utils/data-transformations/convertCSV.js +22 -0
  199. package/dist/utils/data-transformations/getValueFromParametersArray.d.ts +1 -0
  200. package/dist/utils/data-transformations/getValueFromParametersArray.js +9 -0
  201. package/dist/utils/layoutNavHelpers.d.ts +70 -0
  202. package/dist/utils/layoutNavHelpers.js +129 -0
  203. package/dist/utils/package-wrapping-specific/addIndexAndInitialValue.d.ts +1 -0
  204. package/dist/utils/package-wrapping-specific/addIndexAndInitialValue.js +21 -0
  205. package/dist/utils/package-wrapping-specific/createBindableParametersValuesArray.d.ts +1 -0
  206. package/dist/utils/package-wrapping-specific/createBindableParametersValuesArray.js +12 -0
  207. package/dist/utils/package-wrapping-specific/createParametersObject.d.ts +1 -0
  208. package/dist/utils/package-wrapping-specific/createParametersObject.js +29 -0
  209. package/dist/utils/package-wrapping-specific/defineDefaultEventHandler.d.ts +1 -0
  210. package/dist/utils/package-wrapping-specific/defineDefaultEventHandler.js +14 -0
  211. package/dist/utils/package-wrapping-specific/trackVisibleParameters.d.ts +1 -0
  212. package/dist/utils/package-wrapping-specific/trackVisibleParameters.js +29 -0
  213. package/dist/utils/syntax-highlighting/shikiHighlight.d.ts +7 -0
  214. package/dist/utils/syntax-highlighting/shikiHighlight.js +76 -0
  215. package/dist/utils/text-string-conversion/textStringConversion.d.ts +9 -0
  216. package/dist/utils/text-string-conversion/textStringConversion.js +86 -0
  217. package/package.json +113 -0
@@ -0,0 +1,33 @@
1
+ export default Ticks;
2
+ type Ticks = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const Ticks: import("svelte").Component<{
7
+ ticksArray?: any;
8
+ prefix: any;
9
+ suffix: any;
10
+ chartWidth: any;
11
+ chartHeight: any;
12
+ axisFunction: any;
13
+ values: any;
14
+ numberOfTicks: any;
15
+ floor: any;
16
+ ceiling: any;
17
+ orientation: any;
18
+ yearsInput: any;
19
+ }, {}, "ticksArray">;
20
+ type $$ComponentProps = {
21
+ ticksArray?: any;
22
+ prefix: any;
23
+ suffix: any;
24
+ chartWidth: any;
25
+ chartHeight: any;
26
+ axisFunction: any;
27
+ values: any;
28
+ numberOfTicks: any;
29
+ floor: any;
30
+ ceiling: any;
31
+ orientation: any;
32
+ yearsInput: any;
33
+ };
@@ -0,0 +1,150 @@
1
+ <script>
2
+ import ValueLabel from "./ValueLabel.svelte";
3
+ import Marker from "./Marker.svelte";
4
+ import {
5
+ curveBasis,
6
+ curveCardinal,
7
+ curveLinear,
8
+ curveLinearClosed,
9
+ curveMonotoneX,
10
+ curveStep,
11
+ line,
12
+ area,
13
+ } from "d3-shape";
14
+
15
+ import { scaleLinear } from "d3-scale";
16
+ import LineChart from "../../../../routes/playground/create-a-reactive-line-chart-camilla/local-lib/LineChart.svelte";
17
+
18
+ let {
19
+ dataArray,
20
+ opacity = 1,
21
+ pathStrokeColor = "grey",
22
+ pathStrokeWidth = 3,
23
+ pathFillColor = "none",
24
+ pathStrokeDashArray = "none",
25
+ areaFillColor,
26
+ includeArea = false,
27
+ lineFunction,
28
+ areaFunction,
29
+ xFunction,
30
+ yFunction,
31
+ lineEnding,
32
+ dataId,
33
+ onClickSeries,
34
+ onMouseEnterSeries,
35
+ onMouseLeaveSeries,
36
+ halo,
37
+ chartBackgroundColor,
38
+ invisibleStrokeWidth,
39
+ interactive,
40
+ onClickMarker,
41
+ onMouseEnterMarker,
42
+ onMouseLeaveMarker,
43
+ // includeLabels,
44
+ // labelText,
45
+ // labelColor,
46
+ // labelTextColor,
47
+ clickedSeries,
48
+ hoveredSeries,
49
+ activeMarkerId,
50
+ series,
51
+ y,
52
+ id,
53
+ x,
54
+ markers,
55
+ markerFill,
56
+ markerRadius,
57
+ markerShape,
58
+ markerStroke,
59
+ markerStrokeWidth,
60
+ tier,
61
+ } = $props();
62
+
63
+ let linePath = $derived(lineFunction(dataArray));
64
+ </script>
65
+
66
+ <defs>
67
+ <marker
68
+ id={`arrow-${pathStrokeColor}`}
69
+ markerWidth="4"
70
+ markerHeight="3"
71
+ refX="2.7"
72
+ refY="1.5"
73
+ orient="auto-start-reverse"
74
+ >
75
+ <polygon points="0 0, 4 1.5, 0 3" style="fill: {pathStrokeColor}"></polygon>
76
+ </marker>
77
+
78
+ <marker
79
+ id={`circle-${pathStrokeColor}`}
80
+ markerWidth="14"
81
+ markerHeight="14"
82
+ refX="5"
83
+ refY="5"
84
+ orient="auto"
85
+ >
86
+ <circle cx="5" cy="5" r="1.5" style="fill: {pathStrokeColor}"></circle>
87
+ </marker>
88
+ </defs>
89
+
90
+ <g
91
+ data-id={dataId}
92
+ {id}
93
+ onclick={interactive ? (e) => onClickSeries(dataId, tier) : null}
94
+ onmouseenter={interactive ? (e) => onMouseEnterSeries(dataId, tier) : null}
95
+ onmouseleave={interactive ? (e) => onMouseLeaveSeries(dataId, tier) : null}
96
+ role="button"
97
+ tabindex="0"
98
+ onkeydown={(e) => e.key === "Enter" && onClickSeries(e, dataArray)}
99
+ {opacity}
100
+ pointer-events={interactive ? null : "none"}
101
+ >
102
+ {#if includeArea}
103
+ <path d={areaFunction(dataArray)} fill={areaFillColor}></path>
104
+ {/if}
105
+ <path
106
+ d={linePath}
107
+ fill="none"
108
+ stroke="invisible"
109
+ stroke-width={invisibleStrokeWidth}
110
+ pointer-events={interactive ? "stroke" : "none"}
111
+ ></path>
112
+ {#if halo}
113
+ <path
114
+ d={linePath}
115
+ fill={pathFillColor}
116
+ stroke={chartBackgroundColor}
117
+ stroke-width={pathStrokeWidth * 1.2}
118
+ stroke-dasharray={pathStrokeDashArray}
119
+ pointer-events="none"
120
+ ></path>
121
+ {/if}
122
+ <path
123
+ d={linePath}
124
+ fill={pathFillColor}
125
+ stroke={pathStrokeColor}
126
+ stroke-width={pathStrokeWidth}
127
+ stroke-dasharray={pathStrokeDashArray}
128
+ pointer-events="none"
129
+ marker-start={`url(#${lineEnding}-${pathStrokeColor})`}
130
+ ></path>
131
+ {#if markers}
132
+ <Marker
133
+ {dataArray}
134
+ {markerFill}
135
+ {markerRadius}
136
+ {markerShape}
137
+ {markerStroke}
138
+ {markerStrokeWidth}
139
+ {x}
140
+ {y}
141
+ {series}
142
+ {xFunction}
143
+ {yFunction}
144
+ {onMouseEnterMarker}
145
+ {onMouseLeaveMarker}
146
+ {onClickMarker}
147
+ {activeMarkerId}
148
+ ></Marker>
149
+ {/if}
150
+ </g>
@@ -0,0 +1,85 @@
1
+ export default Line;
2
+ type Line = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const Line: import("svelte").Component<{
7
+ dataArray: any;
8
+ opacity?: number;
9
+ pathStrokeColor?: string;
10
+ pathStrokeWidth?: number;
11
+ pathFillColor?: string;
12
+ pathStrokeDashArray?: string;
13
+ areaFillColor: any;
14
+ includeArea?: boolean;
15
+ lineFunction: any;
16
+ areaFunction: any;
17
+ xFunction: any;
18
+ yFunction: any;
19
+ lineEnding: any;
20
+ dataId: any;
21
+ onClickSeries: any;
22
+ onMouseEnterSeries: any;
23
+ onMouseLeaveSeries: any;
24
+ halo: any;
25
+ chartBackgroundColor: any;
26
+ invisibleStrokeWidth: any;
27
+ interactive: any;
28
+ onClickMarker: any;
29
+ onMouseEnterMarker: any;
30
+ onMouseLeaveMarker: any;
31
+ clickedSeries: any;
32
+ hoveredSeries: any;
33
+ activeMarkerId: any;
34
+ series: any;
35
+ y: any;
36
+ id: any;
37
+ x: any;
38
+ markers: any;
39
+ markerFill: any;
40
+ markerRadius: any;
41
+ markerShape: any;
42
+ markerStroke: any;
43
+ markerStrokeWidth: any;
44
+ tier: any;
45
+ }, {}, "">;
46
+ type $$ComponentProps = {
47
+ dataArray: any;
48
+ opacity?: number;
49
+ pathStrokeColor?: string;
50
+ pathStrokeWidth?: number;
51
+ pathFillColor?: string;
52
+ pathStrokeDashArray?: string;
53
+ areaFillColor: any;
54
+ includeArea?: boolean;
55
+ lineFunction: any;
56
+ areaFunction: any;
57
+ xFunction: any;
58
+ yFunction: any;
59
+ lineEnding: any;
60
+ dataId: any;
61
+ onClickSeries: any;
62
+ onMouseEnterSeries: any;
63
+ onMouseLeaveSeries: any;
64
+ halo: any;
65
+ chartBackgroundColor: any;
66
+ invisibleStrokeWidth: any;
67
+ interactive: any;
68
+ onClickMarker: any;
69
+ onMouseEnterMarker: any;
70
+ onMouseLeaveMarker: any;
71
+ clickedSeries: any;
72
+ hoveredSeries: any;
73
+ activeMarkerId: any;
74
+ series: any;
75
+ y: any;
76
+ id: any;
77
+ x: any;
78
+ markers: any;
79
+ markerFill: any;
80
+ markerRadius: any;
81
+ markerShape: any;
82
+ markerStroke: any;
83
+ markerStrokeWidth: any;
84
+ tier: any;
85
+ };
@@ -0,0 +1,249 @@
1
+ <script>
2
+ // @ts-nocheck
3
+ import SeriesLabel from "./SeriesLabel.svelte";
4
+ import Line from "./Line.svelte";
5
+
6
+ import { scaleLinear } from "d3-scale";
7
+ import { curveLinear, line, area } from "d3-shape";
8
+ import { highlight } from "../../../utils/syntax-highlighting/shikiHighlight";
9
+ import Lines from "./Lines.svelte";
10
+
11
+ let {
12
+ // Required
13
+ series,
14
+ y,
15
+ x,
16
+ lineChartData,
17
+
18
+ // ask
19
+ xFunction = (number) => {
20
+ return scaleLinear()
21
+ .domain([2015, 2022])
22
+ .range([0, svgWidth - paddingLeft - paddingRight])(number);
23
+ },
24
+ yFunction = (number) => {
25
+ return scaleLinear()
26
+ .domain([0, 100])
27
+ .range([svgHeight - paddingTop - paddingBottom, 0])(number);
28
+ },
29
+ lineFunction = line()
30
+ .x((d) => xFunction(d[x]))
31
+ .y((d) => yFunction(d[y]))
32
+ .curve(curveLinear),
33
+ labelText = "labelText",
34
+
35
+ tooltipContent = "tooltipContent",
36
+
37
+ onClickSeries = (series, tier) => {
38
+ if (clickedSeries === dataId) {
39
+ clickedSeries = null;
40
+ } else {
41
+ clickedSeries = series;
42
+ clickedTier = tier;
43
+ }
44
+ },
45
+ onMouseLeaveSeries = (series, tier) => {
46
+ if (hoveredSeries === series) {
47
+ hoveredSeries = null;
48
+ hoveredTier = null;
49
+ }
50
+ },
51
+ onMouseEnterSeries = (series, tier) => {
52
+ if (hoveredSeries !== series) {
53
+ hoveredSeries = series;
54
+ hoveredTier = tier;
55
+ }
56
+ },
57
+ onClickMarker = (event, marker, markerId) => {
58
+ activeMarkerId = marker;
59
+ },
60
+ onMouseEnterMarker = (event, marker, markerId) => {
61
+ activeMarkerId = marker;
62
+ },
63
+ onMouseLeaveMarker = (event, marker, dataId) => {
64
+ activeMarkerId = null;
65
+ },
66
+
67
+ // Optional
68
+ clickedSeries = $bindable(undefined),
69
+ hoveredSeries = undefined,
70
+ overrideLineParams = () => ({}),
71
+ getLine = (key, el) => {
72
+ return true;
73
+ },
74
+ nothingSelected = true,
75
+ svgWidth = $bindable(500),
76
+ svgHeight = 500,
77
+ paddingTop = 50,
78
+ paddingBottom = 50,
79
+ paddingLeft = 50,
80
+ paddingRight = 150,
81
+ activeMarkerId = undefined,
82
+ chartBackgroundColor = "#f5f5f5",
83
+ seriesLabels = $bindable(false),
84
+ globalTierRules = {
85
+ otherTier: {},
86
+ secondary: {
87
+ opacity: nothingSelected ? 1 : 0.5,
88
+ },
89
+ primary: {
90
+ opacity: nothingSelected ? 1 : 0.4,
91
+ },
92
+ hover: { opacity: 1 },
93
+ clicked: { opacity: 1 },
94
+ },
95
+ tieredLineParams = {
96
+ all: {},
97
+ },
98
+
99
+ basicLineParams = {},
100
+ } = $props();
101
+
102
+ let defaultLineParams = $derived({
103
+ xFunction,
104
+ yFunction,
105
+ lineFunction,
106
+ onClickSeries,
107
+ onMouseEnterSeries,
108
+ onMouseLeaveSeries,
109
+ onClickMarker,
110
+ onMouseEnterMarker,
111
+ onMouseLeaveMarker,
112
+ haloColor: chartBackgroundColor,
113
+ invisibleStrokeWidth: 20,
114
+ });
115
+
116
+ let chartWidth = $derived(svgWidth - paddingLeft - paddingRight);
117
+ let chartHeight = $derived(svgHeight - paddingTop - paddingBottom);
118
+ // let areaFunction = $derived(
119
+ // area()
120
+ // .y0((d) => yFunction(0))
121
+ // .x((d) => xFunction(d.x))
122
+ // .y1((d) => yFunction(d.y))
123
+ // .curve(curveLinear),
124
+ // );
125
+
126
+ let selectedLine = $derived([hoveredSeries, clickedSeries]);
127
+
128
+ function handleClickOutside(event) {
129
+ if (
130
+ clickedSeries &&
131
+ !event.target.closest('[id^="line"]') &&
132
+ !event.target.closest('[id^="label"]')
133
+ ) {
134
+ clickedSeries = null;
135
+ }
136
+ }
137
+
138
+ function generateLineAttributes(
139
+ line,
140
+ tier,
141
+ overrideLineParams,
142
+ tieredLineParams,
143
+ basicLineParams,
144
+ defaultLineParams,
145
+ ) {
146
+ const listOfProperties = [
147
+ ...new Set([
148
+ ...Object.keys(defaultLineParams),
149
+ ...Object.keys(basicLineParams ?? {}),
150
+ ...Object.keys(tieredLineParams[tier] ?? {}),
151
+ ...Object.keys(overrideLineParams(tier, line)),
152
+ ]),
153
+ ];
154
+
155
+ const merged = Object.fromEntries(
156
+ listOfProperties.map((key) => [
157
+ key,
158
+ overrideLineParams(tier, line)[key] ??
159
+ tieredLineParams[tier]?.[key] ??
160
+ basicLineParams[key] ??
161
+ defaultLineParams[key],
162
+ ]),
163
+ );
164
+
165
+ return {
166
+ ...merged,
167
+ ...line,
168
+ dataId: line[series],
169
+ dataArray: line.data,
170
+ };
171
+ }
172
+
173
+ let tieredDataObject = $derived(
174
+ Object.keys(tieredLineParams).reduce((acc, tier) => {
175
+ acc[tier] = lineChartData.lines
176
+ .filter((el) => getLine(tier, el))
177
+ .map((line) =>
178
+ generateLineAttributes(
179
+ line,
180
+ tier,
181
+ overrideLineParams,
182
+ tieredLineParams,
183
+ basicLineParams,
184
+ defaultLineParams,
185
+ ),
186
+ );
187
+ return acc;
188
+ }, {}),
189
+ );
190
+
191
+ function hasShowLabel(objOfArrays) {
192
+ return Object.values(objOfArrays).some((array) =>
193
+ array.some((obj) => obj.showLabel === true),
194
+ );
195
+ }
196
+ </script>
197
+
198
+ <div bind:clientWidth={svgWidth}>
199
+ <svg
200
+ onclick={handleClickOutside}
201
+ width={svgWidth}
202
+ height={svgHeight}
203
+ style="background-color: {chartBackgroundColor}"
204
+ >
205
+ {#if svgWidth}
206
+ <g transform="translate({paddingLeft},{paddingTop})">
207
+ <g data-role="lines-group">
208
+ <Lines
209
+ {tieredDataObject}
210
+ dataArray={lineChartData.lines}
211
+ {lineFunction}
212
+ {chartWidth}
213
+ {xFunction}
214
+ {yFunction}
215
+ {hoveredSeries}
216
+ {clickedSeries}
217
+ {chartHeight}
218
+ {globalTierRules}
219
+ {chartBackgroundColor}
220
+ {nothingSelected}
221
+ {onMouseEnterSeries}
222
+ {onClickSeries}
223
+ {onMouseLeaveSeries}
224
+ {onClickMarker}
225
+ {onMouseEnterMarker}
226
+ {onMouseLeaveMarker}
227
+ {activeMarkerId}
228
+ {labelText}
229
+ {series}
230
+ {y}
231
+ {x}
232
+ {tooltipContent}
233
+ ></Lines>
234
+ </g>
235
+ <g data-role="y-axis">
236
+ <path d="M0 0 l0 {chartHeight}" stroke="black" stroke-width="2px"
237
+ ></path>
238
+ </g>
239
+ <g data-role="x-axis">
240
+ <path
241
+ d="M0 {chartHeight} l{chartWidth} 0"
242
+ stroke="black"
243
+ stroke-width="2px"
244
+ ></path>
245
+ </g>
246
+ </g>
247
+ {/if}
248
+ </svg>
249
+ </div>
@@ -0,0 +1,73 @@
1
+ export default LineChart;
2
+ type LineChart = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const LineChart: import("svelte").Component<{
7
+ series: any;
8
+ y: any;
9
+ x: any;
10
+ lineChartData: any;
11
+ xFunction?: Function;
12
+ yFunction?: Function;
13
+ lineFunction?: any;
14
+ labelText?: string;
15
+ tooltipContent?: string;
16
+ onClickSeries?: Function;
17
+ onMouseLeaveSeries?: Function;
18
+ onMouseEnterSeries?: Function;
19
+ onClickMarker?: Function;
20
+ onMouseEnterMarker?: Function;
21
+ onMouseLeaveMarker?: Function;
22
+ clickedSeries?: any;
23
+ hoveredSeries?: any;
24
+ overrideLineParams?: Function;
25
+ getLine?: Function;
26
+ nothingSelected?: boolean;
27
+ svgWidth?: number;
28
+ svgHeight?: number;
29
+ paddingTop?: number;
30
+ paddingBottom?: number;
31
+ paddingLeft?: number;
32
+ paddingRight?: number;
33
+ activeMarkerId?: any;
34
+ chartBackgroundColor?: string;
35
+ seriesLabels?: boolean;
36
+ globalTierRules?: Record<string, any>;
37
+ tieredLineParams?: Record<string, any>;
38
+ basicLineParams?: Record<string, any>;
39
+ }, {}, "clickedSeries" | "svgWidth" | "seriesLabels">;
40
+ type $$ComponentProps = {
41
+ series: any;
42
+ y: any;
43
+ x: any;
44
+ lineChartData: any;
45
+ xFunction?: Function;
46
+ yFunction?: Function;
47
+ lineFunction?: any;
48
+ labelText?: string;
49
+ tooltipContent?: string;
50
+ onClickSeries?: Function;
51
+ onMouseLeaveSeries?: Function;
52
+ onMouseEnterSeries?: Function;
53
+ onClickMarker?: Function;
54
+ onMouseEnterMarker?: Function;
55
+ onMouseLeaveMarker?: Function;
56
+ clickedSeries?: any;
57
+ hoveredSeries?: any;
58
+ overrideLineParams?: Function;
59
+ getLine?: Function;
60
+ nothingSelected?: boolean;
61
+ svgWidth?: number;
62
+ svgHeight?: number;
63
+ paddingTop?: number;
64
+ paddingBottom?: number;
65
+ paddingLeft?: number;
66
+ paddingRight?: number;
67
+ activeMarkerId?: any;
68
+ chartBackgroundColor?: string;
69
+ seriesLabels?: boolean;
70
+ globalTierRules?: Record<string, any>;
71
+ tieredLineParams?: Record<string, any>;
72
+ basicLineParams?: Record<string, any>;
73
+ };