buckaroo-js-core 0.8.4 → 0.11.7

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 (242) hide show
  1. package/LICENSE +24 -12
  2. package/README.md +55 -51
  3. package/dist/index.cjs.js +114 -0
  4. package/dist/index.cjs.js.map +1 -0
  5. package/dist/index.es.js +60790 -0
  6. package/dist/index.es.js.map +1 -0
  7. package/dist/index.esm.js +60790 -0
  8. package/dist/index.esm.js.map +1 -0
  9. package/dist/jest.setup.d.ts +0 -0
  10. package/dist/src/SampleComponent.d.ts +10 -0
  11. package/{buckaroo_js → dist/src}/baked_data/colorMap.d.ts +0 -1
  12. package/dist/src/baked_data/olympic-winners.d.ts +12 -0
  13. package/dist/src/components/BuckarooInfiniteWidget.flash.test.d.ts +1 -0
  14. package/dist/src/components/BuckarooStaticTable.d.ts +26 -0
  15. package/dist/src/components/BuckarooWidgetInfinite.d.ts +38 -0
  16. package/{buckaroo_js → dist/src}/components/ColumnsEditor.d.ts +5 -8
  17. package/{buckaroo_js → dist/src}/components/CommandUtils.d.ts +8 -5
  18. package/dist/src/components/DCFCell.d.ts +19 -0
  19. package/dist/src/components/DFViewerParts/ChartCell.d.ts +43 -0
  20. package/dist/src/components/DFViewerParts/DFViewerConfigs.d.ts +5 -0
  21. package/dist/src/components/DFViewerParts/DFViewerDataHelper.d.ts +20 -0
  22. package/dist/src/components/DFViewerParts/DFViewerInfinite.d.ts +43 -0
  23. package/dist/src/components/DFViewerParts/DFViewerInfinite.flash.test.d.ts +1 -0
  24. package/dist/src/components/DFViewerParts/DFViewerInfinite.test.d.ts +1 -0
  25. package/dist/src/components/DFViewerParts/DFWhole.d.ts +173 -0
  26. package/{buckaroo_js → dist/src}/components/DFViewerParts/Displayer.d.ts +20 -6
  27. package/dist/src/components/DFViewerParts/HistogramCell.d.ts +29 -0
  28. package/dist/src/components/DFViewerParts/HistogramCell.hooks.test.d.ts +1 -0
  29. package/dist/src/components/DFViewerParts/OtherRenderers.d.ts +5 -0
  30. package/dist/src/components/DFViewerParts/RowCache.d.ts +61 -0
  31. package/dist/src/components/DFViewerParts/RowCache.test.d.ts +1 -0
  32. package/dist/src/components/DFViewerParts/RowStore.d.ts +22 -0
  33. package/dist/src/components/DFViewerParts/RowStore.test.d.ts +1 -0
  34. package/dist/src/components/DFViewerParts/RowStoreGc.d.ts +22 -0
  35. package/dist/src/components/DFViewerParts/RowStoreGc.test.d.ts +1 -0
  36. package/dist/src/components/DFViewerParts/SeriesSummaryTooltip.d.ts +13 -0
  37. package/dist/src/components/DFViewerParts/SmartRowCache.d.ts +83 -0
  38. package/dist/src/components/DFViewerParts/SmartRowCache.test.d.ts +23 -0
  39. package/dist/src/components/DFViewerParts/Styler.d.ts +33 -0
  40. package/dist/src/components/DFViewerParts/TableInfinite.d.ts +10 -0
  41. package/dist/src/components/DFViewerParts/ViewRegistry.d.ts +21 -0
  42. package/dist/src/components/DFViewerParts/ViewRegistry.test.d.ts +1 -0
  43. package/dist/src/components/DFViewerParts/Views.d.ts +53 -0
  44. package/dist/src/components/DFViewerParts/Views.test.d.ts +1 -0
  45. package/dist/src/components/DFViewerParts/autocleaning.toggle.integration.test.d.ts +27 -0
  46. package/dist/src/components/DFViewerParts/gridUtils.d.ts +81 -0
  47. package/dist/src/components/DFViewerParts/gridUtils.test.d.ts +1 -0
  48. package/dist/src/components/DFViewerParts/resolveDFData.d.ts +29 -0
  49. package/dist/src/components/DFViewerParts/resolveDFData.test.d.ts +1 -0
  50. package/dist/src/components/DFViewerParts/xorqWindow.dom.test.d.ts +1 -0
  51. package/dist/src/components/DFViewerParts/xorqWindow.test.d.ts +1 -0
  52. package/{buckaroo_js → dist/src}/components/DependentTabs.d.ts +8 -13
  53. package/dist/src/components/MessageBox.d.ts +8 -0
  54. package/{buckaroo_js → dist/src}/components/OperationDetail.d.ts +4 -6
  55. package/dist/src/components/OperationExamples.d.ts +8 -0
  56. package/{buckaroo_js → dist/src}/components/OperationUtils.d.ts +1 -1
  57. package/dist/src/components/Operations.d.ts +14 -0
  58. package/dist/src/components/Operations.test.d.ts +4 -0
  59. package/dist/src/components/OperationsList.d.ts +9 -0
  60. package/dist/src/components/OperationsList.test.d.ts +0 -0
  61. package/dist/src/components/StatusBar.d.ts +15 -0
  62. package/{buckaroo_js → dist/src}/components/WidgetTypes.d.ts +3 -4
  63. package/dist/src/components/useColorScheme.d.ts +7 -0
  64. package/dist/src/components/utils.d.ts +299 -0
  65. package/dist/src/index.d.ts +59 -0
  66. package/dist/src/stories/BuckarooWidgetTest.stories.d.ts +12 -0
  67. package/dist/src/stories/ChartCell.stories.d.ts +20 -0
  68. package/dist/src/stories/ColumnsEditor.stories.d.ts +17 -0
  69. package/dist/src/stories/DFViewer.stories.d.ts +26 -0
  70. package/dist/src/stories/DFViewerInfiniteRaw.stories.d.ts +24 -0
  71. package/dist/src/stories/DFViewerInfiniteShadow.stories.d.ts +31 -0
  72. package/dist/src/stories/HistogramCell.stories.d.ts +18 -0
  73. package/dist/src/stories/InheritEdgeCases.stories.d.ts +12 -0
  74. package/dist/src/stories/InheritPinnedRows.stories.d.ts +13 -0
  75. package/dist/src/stories/MessageBox.stories.d.ts +26 -0
  76. package/dist/src/stories/OperationViewer.stories.d.ts +24 -0
  77. package/dist/src/stories/OperationsList.stories.d.ts +19 -0
  78. package/dist/src/stories/OutsideParamsInconsistency.stories.d.ts +16 -0
  79. package/dist/src/stories/PinnedRowsDynamic.stories.d.ts +12 -0
  80. package/dist/src/stories/PinnedRowsRace.stories.d.ts +12 -0
  81. package/dist/src/stories/PinnedRowsTranscriptReplayer.stories.d.ts +13 -0
  82. package/dist/src/stories/RawAGGrid.stories.d.ts +17 -0
  83. package/dist/src/stories/SmallDFScroll.stories.d.ts +11 -0
  84. package/dist/src/stories/StatusBar.stories.d.ts +19 -0
  85. package/dist/src/stories/StoryUtils.d.ts +13 -0
  86. package/dist/src/stories/Styling.stories.d.ts +15 -0
  87. package/dist/src/stories/StylingIssues.stories.d.ts +54 -0
  88. package/dist/src/stories/ThemeCustomization.stories.d.ts +22 -0
  89. package/dist/src/stories/UseMemoExamples.stories.d.ts +12 -0
  90. package/dist/src/stories/WeirdTypes.stories.d.ts +17 -0
  91. package/dist/src/test-utils/agGridSpy.d.ts +50 -0
  92. package/dist/src/widgetUtils.d.ts +1 -0
  93. package/dist/style.css +1 -0
  94. package/package.json +109 -101
  95. package/.prettierrc +0 -16
  96. package/CHANGELOG.md +0 -23
  97. package/buckaroo_js/baked_data/colorMap.d.ts.map +0 -1
  98. package/buckaroo_js/baked_data/colorMap.js +0 -520
  99. package/buckaroo_js/baked_data/colorMap.js.map +0 -1
  100. package/buckaroo_js/baked_data/staticData.d.ts +0 -124
  101. package/buckaroo_js/baked_data/staticData.d.ts.map +0 -1
  102. package/buckaroo_js/baked_data/staticData.js +0 -459
  103. package/buckaroo_js/baked_data/staticData.js.map +0 -1
  104. package/buckaroo_js/components/ColumnsEditor.d.ts.map +0 -1
  105. package/buckaroo_js/components/ColumnsEditor.js +0 -68
  106. package/buckaroo_js/components/ColumnsEditor.js.map +0 -1
  107. package/buckaroo_js/components/CommandUtils.d.ts.map +0 -1
  108. package/buckaroo_js/components/CommandUtils.js +0 -17
  109. package/buckaroo_js/components/CommandUtils.js.map +0 -1
  110. package/buckaroo_js/components/DCFCell.d.ts +0 -28
  111. package/buckaroo_js/components/DCFCell.d.ts.map +0 -1
  112. package/buckaroo_js/components/DCFCell.js +0 -120
  113. package/buckaroo_js/components/DCFCell.js.map +0 -1
  114. package/buckaroo_js/components/DFViewerParts/DFViewer.d.ts +0 -29
  115. package/buckaroo_js/components/DFViewerParts/DFViewer.d.ts.map +0 -1
  116. package/buckaroo_js/components/DFViewerParts/DFViewer.js +0 -163
  117. package/buckaroo_js/components/DFViewerParts/DFViewer.js.map +0 -1
  118. package/buckaroo_js/components/DFViewerParts/DFWhole.d.ts +0 -111
  119. package/buckaroo_js/components/DFViewerParts/DFWhole.d.ts.map +0 -1
  120. package/buckaroo_js/components/DFViewerParts/DFWhole.js +0 -17
  121. package/buckaroo_js/components/DFViewerParts/DFWhole.js.map +0 -1
  122. package/buckaroo_js/components/DFViewerParts/Displayer.d.ts.map +0 -1
  123. package/buckaroo_js/components/DFViewerParts/Displayer.js +0 -221
  124. package/buckaroo_js/components/DFViewerParts/Displayer.js.map +0 -1
  125. package/buckaroo_js/components/DFViewerParts/HistogramCell.d.ts +0 -20
  126. package/buckaroo_js/components/DFViewerParts/HistogramCell.d.ts.map +0 -1
  127. package/buckaroo_js/components/DFViewerParts/HistogramCell.js +0 -184
  128. package/buckaroo_js/components/DFViewerParts/HistogramCell.js.map +0 -1
  129. package/buckaroo_js/components/DFViewerParts/SeriesSummaryTooltip.d.ts +0 -5
  130. package/buckaroo_js/components/DFViewerParts/SeriesSummaryTooltip.d.ts.map +0 -1
  131. package/buckaroo_js/components/DFViewerParts/SeriesSummaryTooltip.js +0 -18
  132. package/buckaroo_js/components/DFViewerParts/SeriesSummaryTooltip.js.map +0 -1
  133. package/buckaroo_js/components/DFViewerParts/gridUtils.d.ts +0 -24
  134. package/buckaroo_js/components/DFViewerParts/gridUtils.d.ts.map +0 -1
  135. package/buckaroo_js/components/DFViewerParts/gridUtils.js +0 -230
  136. package/buckaroo_js/components/DFViewerParts/gridUtils.js.map +0 -1
  137. package/buckaroo_js/components/DependentTabs.d.ts.map +0 -1
  138. package/buckaroo_js/components/DependentTabs.js +0 -108
  139. package/buckaroo_js/components/DependentTabs.js.map +0 -1
  140. package/buckaroo_js/components/OperationDetail.d.ts.map +0 -1
  141. package/buckaroo_js/components/OperationDetail.js +0 -144
  142. package/buckaroo_js/components/OperationDetail.js.map +0 -1
  143. package/buckaroo_js/components/OperationUtils.d.ts.map +0 -1
  144. package/buckaroo_js/components/OperationUtils.js +0 -14
  145. package/buckaroo_js/components/OperationUtils.js.map +0 -1
  146. package/buckaroo_js/components/Operations.d.ts +0 -24
  147. package/buckaroo_js/components/Operations.d.ts.map +0 -1
  148. package/buckaroo_js/components/Operations.js +0 -209
  149. package/buckaroo_js/components/Operations.js.map +0 -1
  150. package/buckaroo_js/components/StatusBar.d.ts +0 -12
  151. package/buckaroo_js/components/StatusBar.d.ts.map +0 -1
  152. package/buckaroo_js/components/StatusBar.js +0 -155
  153. package/buckaroo_js/components/StatusBar.js.map +0 -1
  154. package/buckaroo_js/components/WidgetTypes.d.ts.map +0 -1
  155. package/buckaroo_js/components/WidgetTypes.js +0 -3
  156. package/buckaroo_js/components/WidgetTypes.js.map +0 -1
  157. package/buckaroo_js/components/bakedOperationDefaults.d.ts +0 -5
  158. package/buckaroo_js/components/bakedOperationDefaults.d.ts.map +0 -1
  159. package/buckaroo_js/components/bakedOperationDefaults.js +0 -15
  160. package/buckaroo_js/components/bakedOperationDefaults.js.map +0 -1
  161. package/buckaroo_js/components/utils.d.ts +0 -294
  162. package/buckaroo_js/components/utils.d.ts.map +0 -1
  163. package/buckaroo_js/components/utils.js +0 -143
  164. package/buckaroo_js/components/utils.js.map +0 -1
  165. package/buckaroo_js/extension.d.ts +0 -2
  166. package/buckaroo_js/extension.d.ts.map +0 -1
  167. package/buckaroo_js/extension.js +0 -20
  168. package/buckaroo_js/extension.js.map +0 -1
  169. package/buckaroo_js/index.d.ts +0 -25
  170. package/buckaroo_js/index.d.ts.map +0 -1
  171. package/buckaroo_js/index.js +0 -46
  172. package/buckaroo_js/index.js.map +0 -1
  173. package/buckaroo_js/vendor/RechartExtra.d.ts +0 -38
  174. package/buckaroo_js/vendor/RechartExtra.d.ts.map +0 -1
  175. package/buckaroo_js/vendor/RechartExtra.js +0 -17
  176. package/buckaroo_js/vendor/RechartExtra.js.map +0 -1
  177. package/buckaroo_js/vendor/RechartTooltip.d.ts +0 -82
  178. package/buckaroo_js/vendor/RechartTooltip.d.ts.map +0 -1
  179. package/buckaroo_js/vendor/RechartTooltip.js +0 -231
  180. package/buckaroo_js/vendor/RechartTooltip.js.map +0 -1
  181. package/codecov.yml +0 -16
  182. package/eslint.config.mjs +0 -88
  183. package/examples/App.tsx +0 -160
  184. package/examples/CodeBlock.tsx +0 -27
  185. package/examples/CodePenButton.tsx +0 -72
  186. package/examples/ReadmeBlock.tsx +0 -11
  187. package/examples/app.css +0 -29
  188. package/examples/ex/ColumnsEditorEx.tsx +0 -5
  189. package/examples/ex/CommandViewerEx.tsx +0 -18
  190. package/examples/ex/DFViewerEx.tsx +0 -3
  191. package/examples/ex/DFViewerEx_large.tsx +0 -266
  192. package/examples/ex/DFViewerEx_real_summary.tsx +0 -18
  193. package/examples/ex/DFViewerEx_short_data.tsx +0 -22
  194. package/examples/ex/DFViewerEx_string_index.tsx +0 -1012
  195. package/examples/ex/HistogramEx.tsx +0 -66
  196. package/examples/ex/StatusBarEx.tsx +0 -46
  197. package/examples/ex/WidgetDCFCellEx.tsx +0 -6
  198. package/examples/example.css +0 -20
  199. package/examples/index-iframe.hnottml +0 -24
  200. package/examples/index-react18.tsx +0 -8
  201. package/examples/index.html +0 -20
  202. package/examples/jsx-loader.ts +0 -16
  203. package/examples/tsconfig.json +0 -31
  204. package/index.d.ts +0 -2
  205. package/index.d.ts.map +0 -1
  206. package/index.js +0 -7
  207. package/index.js.map +0 -1
  208. package/jest.config.js +0 -24
  209. package/screen-animation.gif +0 -0
  210. package/src/buckaroo_js/baked_data/colorMap.ts +0 -523
  211. package/src/buckaroo_js/baked_data/staticData.ts +0 -503
  212. package/src/buckaroo_js/components/ColumnsEditor.tsx +0 -66
  213. package/src/buckaroo_js/components/CommandUtils.ts +0 -40
  214. package/src/buckaroo_js/components/DCFCell.tsx +0 -175
  215. package/src/buckaroo_js/components/DFViewerParts/DFViewer.tsx +0 -215
  216. package/src/buckaroo_js/components/DFViewerParts/DFWhole.ts +0 -190
  217. package/src/buckaroo_js/components/DFViewerParts/Displayer.ts +0 -215
  218. package/src/buckaroo_js/components/DFViewerParts/HistogramCell.tsx +0 -251
  219. package/src/buckaroo_js/components/DFViewerParts/SeriesSummaryTooltip.tsx +0 -20
  220. package/src/buckaroo_js/components/DFViewerParts/gridUtils.ts +0 -290
  221. package/src/buckaroo_js/components/DependentTabs.tsx +0 -134
  222. package/src/buckaroo_js/components/OperationDetail.tsx +0 -203
  223. package/src/buckaroo_js/components/OperationUtils.ts +0 -33
  224. package/src/buckaroo_js/components/Operations.tsx +0 -243
  225. package/src/buckaroo_js/components/StatusBar.tsx +0 -190
  226. package/src/buckaroo_js/components/WidgetTypes.tsx +0 -42
  227. package/src/buckaroo_js/components/bakedOperationDefaults.ts +0 -14
  228. package/src/buckaroo_js/components/utils.ts +0 -60
  229. package/src/buckaroo_js/extension.ts +0 -15
  230. package/src/buckaroo_js/index.ts +0 -34
  231. package/src/buckaroo_js/style/dcf-npm.css +0 -244
  232. package/src/buckaroo_js/style/icons/arrow-down-short-dark.svg +0 -4
  233. package/src/buckaroo_js/style/icons/arrow-down-short.svg +0 -4
  234. package/src/buckaroo_js/style/icons/arrow-up-short-dark.svg +0 -4
  235. package/src/buckaroo_js/style/icons/arrow-up-short.svg +0 -4
  236. package/src/buckaroo_js/style/icons/filter-dark.svg +0 -3
  237. package/src/buckaroo_js/style/icons/filter.svg +0 -3
  238. package/src/buckaroo_js/vendor/RechartExtra.ts +0 -60
  239. package/src/buckaroo_js/vendor/RechartTooltip.tsx +0 -356
  240. package/src/index.tsx +0 -3
  241. package/tsconfig.json +0 -41
  242. package/webpack.config.ts +0 -98
@@ -1,243 +0,0 @@
1
- import React, {useState} from 'react';
2
- import _ from 'lodash';
3
- import {Operation, SetOperationsFunc, OperationEventFunc, NoArgEventFunc} from './OperationUtils';
4
- import {CommandConfigT} from './CommandUtils';
5
- import {replaceInArr} from './utils';
6
-
7
- import {OperationDetail} from './OperationDetail';
8
- import {AgGridReact} from 'ag-grid-react'; // the AG Grid React Component
9
- import {ColDef, GridOptions} from 'ag-grid-community';
10
- //import { CustomCellRendererProps } from '@ag-grid-community/react';
11
-
12
- import {updateAtMatch} from './utils';
13
- import 'ag-grid-community/styles/ag-grid.css';
14
- import 'ag-grid-community/styles/ag-theme-alpine.css';
15
-
16
- export const OperationsList = ({
17
- operations,
18
- activeKey,
19
- setActiveKey,
20
- delKey
21
- }: {
22
- operations: Operation[];
23
- activeKey?: string;
24
- setActiveKey: React.Dispatch<React.SetStateAction<string>>;
25
- delKey: any;
26
- }) => {
27
- const renderOperation = (params: any) => (
28
- <span className='missionSpan'>
29
- <span
30
- style={{
31
- height: 30,
32
- width: 30,
33
- margin: 3,
34
- paddingBottom: 8,
35
- float: 'left',
36
- background: 'grey'
37
- }}
38
- onClick={delKey(params.value[0])}
39
- >
40
- X
41
- </span>
42
- <span>{params.value[1]}</span>
43
- </span>
44
- );
45
-
46
- const getColumns = (passedOperations: Operation[]): ColDef[] =>
47
- _.map(Array.from(passedOperations.entries()), ([index, element]) => {
48
- const name = element[0]['symbol'];
49
- const key = name + index.toString();
50
- const column = {
51
- field: key,
52
- headerName: name,
53
- cellRenderer: renderOperation
54
- }; // width: 20, maxWidth: 60};
55
- return column;
56
- });
57
-
58
- const rowElements: Record<string, [string, string]>[] = _.map(
59
- Array.from(operations.entries()),
60
- ([index, element]) => {
61
- const name = element[0]['symbol'];
62
- const key = name + index.toString();
63
- const rowEl: Record<string, [string, string]> = {};
64
- rowEl[key] = [key, element[2]]; //key, colName
65
- return rowEl;
66
- }
67
- );
68
- const rows = [_.merge({}, ...rowElements)];
69
- const columns = getColumns(operations);
70
-
71
- const styledColumns = updateAtMatch(
72
- _.clone(columns),
73
- activeKey || '___never',
74
- {
75
- cellStyle: {background: 'var(--ag-range-selection-background-color-3)'}
76
- },
77
- {cellStyle: {}}
78
- );
79
-
80
- const gridOptions: GridOptions = {
81
- rowSelection: 'single',
82
- headerHeight: 30,
83
- onCellClicked: (event) => {
84
- const colName = event.column.getColId();
85
- setActiveKey(colName);
86
- }
87
- };
88
- return (
89
- <div style={{height: 78, width: 1000}} className='ag-theme-alpine'>
90
- <AgGridReact
91
- gridOptions={gridOptions}
92
- rowData={rows}
93
- columnDefs={styledColumns}
94
- ></AgGridReact>
95
- </div>
96
- );
97
- };
98
-
99
- export const OperationAdder = ({
100
- column,
101
- addOperationCb,
102
- defaultArgs
103
- }: {
104
- column: string;
105
- addOperationCb: any;
106
- defaultArgs: any;
107
- }): JSX.Element => {
108
- const addOperationByName = (localOperationName: string) => {
109
- return () => {
110
- const defaultOperation = defaultArgs[localOperationName];
111
- addOperationCb(replaceInArr(defaultOperation, 'col', column));
112
- };
113
- };
114
-
115
- return (
116
- <div className='operation-adder'>
117
- <span className={'column-name'}> Column: {column}</span>
118
- <fieldset>
119
- {_.keys(defaultArgs).map((optionVal) => (
120
- <button key={optionVal} onClick={addOperationByName(optionVal)}>
121
- {' '}
122
- {optionVal}{' '}
123
- </button>
124
- ))}
125
- </fieldset>
126
- </div>
127
- );
128
- };
129
-
130
- export const OperationViewer = ({
131
- operations,
132
- setOperations,
133
- activeColumn,
134
- allColumns,
135
- commandConfig
136
- }: {
137
- operations: Operation[];
138
- setOperations: SetOperationsFunc;
139
- activeColumn: string;
140
- allColumns: string[];
141
- commandConfig: CommandConfigT;
142
- }) => {
143
- const opToKey = (idx: number, op: Operation): string => {
144
- const name = op[0]['symbol'];
145
- return name + idx.toString();
146
- };
147
-
148
- const operationObjs = _.map(Array.from(operations.entries()), ([index, element]) => {
149
- const rowEl: Record<string, Operation> = {};
150
- rowEl[opToKey(index, element)] = element;
151
- return rowEl;
152
- });
153
- //why am I doing this? probably something so I gauruntee a clean dict
154
-
155
- const operationDict = _.merge({}, ...operationObjs);
156
-
157
- const idxObjs = _.map(Array.from(operations.entries()), ([index, element]) => {
158
- const rowEl: Record<string, number> = {};
159
- rowEl[opToKey(index, element)] = index;
160
- return rowEl;
161
- });
162
- const keyToIdx = _.merge({}, ...idxObjs);
163
-
164
- // previously was null
165
- const [activeKey, setActiveKey] = useState('');
166
-
167
- function getSetOperation(key: string): OperationEventFunc {
168
- return (newOperation: Operation) => {
169
- const index = keyToIdx[key];
170
- const nextOperations = operations.map((c, i) => {
171
- if (i === index) {
172
- return newOperation;
173
- } else {
174
- return c;
175
- }
176
- });
177
- console.log('about to call setOperations', key, newOperation);
178
- setOperations(nextOperations);
179
- };
180
- }
181
-
182
- function getDeleteOperation(key: string): NoArgEventFunc {
183
- return (): void => {
184
- const index = keyToIdx[key];
185
- const nextOperations = operations.map((c, i) => {
186
- if (i === index) {
187
- return undefined;
188
- } else {
189
- return c;
190
- }
191
- });
192
- //const newIdx = Math.max(0, index - 1);
193
- const newOps = _.filter(nextOperations) as Operation[];
194
- console.log('getDeleteOperations', operations.length, newOps.length);
195
- setOperations(newOps);
196
- //setActiveKey(opToKey(newIdx, newOps[newIdx]));
197
- //setActiveKey('');
198
- };
199
- }
200
-
201
- const getColumns = (passedOperations: Operation[]): ColDef[] =>
202
- _.map(Array.from(passedOperations.entries()), ([index, element]) => {
203
- const name = element[0]['symbol'];
204
- const key = name + index.toString();
205
- const column = {field: key, headerName: name}; // width: 20, maxWidth: 60};
206
- return column;
207
- });
208
- const addOperation: OperationEventFunc = (newOperation: Operation) => {
209
- const newOperationArr = [...operations, newOperation];
210
- setOperations(newOperationArr);
211
- const newOperationKey = getColumns(newOperationArr)[newOperationArr.length - 1].field;
212
- if (newOperationKey !== undefined) {
213
- setActiveKey(newOperationKey);
214
- }
215
- };
216
- const {argspecs, defaultArgs} = commandConfig;
217
- return (
218
- <div className='command-viewer'>
219
- <OperationAdder
220
- column={activeColumn}
221
- addOperationCb={addOperation}
222
- defaultArgs={defaultArgs}
223
- />
224
- <div className='operations-box'>
225
- <h4> Operations </h4>
226
- <OperationsList
227
- operations={operations}
228
- activeKey={activeKey}
229
- setActiveKey={setActiveKey}
230
- delKey={getDeleteOperation}
231
- />
232
- </div>
233
- {activeKey && (
234
- <OperationDetail
235
- command={operationDict[activeKey]}
236
- setCommand={getSetOperation(activeKey)}
237
- columns={allColumns}
238
- commandPatterns={argspecs}
239
- />
240
- )}
241
- </div>
242
- );
243
- };
@@ -1,190 +0,0 @@
1
- // https://plnkr.co/edit/QTNwBb2VEn81lf4t?open=index.tsx
2
- import React, {useRef, useCallback} from 'react';
3
- import _ from 'lodash';
4
- import {AgGridReact} from 'ag-grid-react'; // the AG Grid React Component
5
- import {ColDef, GridOptions} from 'ag-grid-community';
6
- import {basicIntFormatter} from './DFViewerParts/Displayer';
7
- import {DFMeta} from './WidgetTypes';
8
- import {BuckarooOptions} from './WidgetTypes';
9
- import {BuckarooState, BKeys} from './WidgetTypes';
10
- export type setColumFunc = (newCol: string) => void;
11
-
12
- const helpCell = function (params: any) {
13
- return (
14
- <a
15
- href='https://buckaroo-data.readthedocs.io/en/latest/feature_reference.html'
16
- target='_blank'
17
- rel='noopener noreferrer'
18
- >
19
- ?
20
- </a>
21
- );
22
- };
23
-
24
- export function StatusBar({
25
- dfMeta,
26
- buckarooState,
27
- setBuckarooState,
28
- buckarooOptions
29
- }: {
30
- dfMeta: DFMeta;
31
- buckarooState: BuckarooState;
32
- setBuckarooState: React.Dispatch<React.SetStateAction<BuckarooState>>;
33
- buckarooOptions: BuckarooOptions;
34
- }) {
35
- /*
36
- AgGridReact
37
- rowData={rowData}
38
- columnDefs={columns}
39
- singleClickEdit={true}
40
- stopEditingWhenCellsLoseFocus={true}
41
- */
42
-
43
- //console.log('initial buckarooState', buckarooState);
44
- // const optionCycles = _.fromPairs(
45
- // // _.map(buckarooOptions, (v: any, k) => [k, ( k==='df_display' ? v : _.concat([false], v) ) ])
46
- // _.map(buckarooOptions, (v: any, k) => [k, ( k==='post_processing' ? v : _.concat([false], v) ) ])
47
-
48
- // ) as Record<BKeys, any[]>;
49
- const optionCycles = buckarooOptions;
50
- const idxs = _.fromPairs(
51
- _.map(_.keys(optionCycles), (k) => [
52
- k,
53
- _.indexOf(optionCycles[k as BKeys], buckarooState[k as BKeys])
54
- ])
55
- );
56
-
57
- const nextIndex = (curIdx: number, arr: any[]) => {
58
- if (curIdx === arr.length - 1) {
59
- return 0;
60
- }
61
- return curIdx + 1;
62
- };
63
-
64
- const newBuckarooState = (k: BKeys) => {
65
- const arr = optionCycles[k];
66
- const curIdx = idxs[k];
67
- const nextIdx = nextIndex(curIdx, arr);
68
- const newVal = arr[nextIdx];
69
- const newState = _.clone(buckarooState);
70
- newState[k] = newVal;
71
- return newState;
72
- };
73
- const updateDict = (event: any) => {
74
- const colName = event.column.getColId();
75
- if (colName === 'quick_command_args' || colName === 'search') {
76
- return;
77
- }
78
- if (_.includes(_.keys(buckarooState), colName)) {
79
- const nbstate = newBuckarooState(colName as BKeys);
80
- setBuckarooState(nbstate);
81
- }
82
- };
83
-
84
- const handleCellChange = useCallback((params: {oldValue: any; newValue: any}) => {
85
- const {oldValue, newValue} = params;
86
-
87
- if (oldValue !== newValue && newValue !== null) {
88
- //console.log('Edited cell:', newValue);
89
- const newState = {
90
- ...buckarooState,
91
- quick_command_args: {search: [newValue]}
92
- };
93
- //console.log('handleCellChange', buckarooState, newState);
94
- setBuckarooState(newState);
95
- }
96
- }, []);
97
-
98
- const columnDefs: ColDef[] = [
99
- {
100
- field: 'search',
101
- headerName: 'search',
102
- width: 200,
103
- editable: true,
104
- onCellValueChanged: handleCellChange
105
- //hide: !showSearch,
106
- },
107
- {
108
- field: 'df_display',
109
- headerName: 'Σ', //note the greek symbols instead of icons which require buildchain work
110
- headerTooltip: 'Summary Stats',
111
- width: 120
112
- },
113
- /*
114
- {
115
- field: 'auto_clean',
116
- //headerName: 'Σ', //note the greek symbols instead of icons which require buildchain work
117
- headerName: 'auto cleaning',
118
- headerTooltip: 'Auto Cleaning config',
119
- width: 120,
120
- },
121
- */
122
- {
123
- field: 'post_processing',
124
- // headerName: "Θ",
125
- headerName: 'post processing',
126
- headerTooltip: 'post process method',
127
- width: 100
128
- },
129
- {
130
- field: 'show_commands',
131
- headerName: 'λ',
132
- headerTooltip: 'Show Commands',
133
- width: 30
134
- },
135
-
136
- {field: 'sampled', headerName: 'Ξ', headerTooltip: 'Sampled', width: 30},
137
- {
138
- field: 'help',
139
- headerName: '?',
140
- headerTooltip: 'Help',
141
- width: 30,
142
- cellRenderer: helpCell
143
- },
144
- {field: 'total_rows', width: 100},
145
- {field: 'filtered_rows', headerName: 'filtered', width: 85},
146
- {field: 'rows_shown', headerName: 'displayed', width: 85},
147
- {field: 'columns', width: 75}
148
- ];
149
-
150
- const searchArg = buckarooState.quick_command_args?.search;
151
- const searchStr = searchArg && searchArg.length === 1 ? searchArg[0] : '';
152
-
153
- const rowData = [
154
- {
155
- total_rows: basicIntFormatter.format(dfMeta.total_rows),
156
- columns: dfMeta.columns,
157
- rows_shown: basicIntFormatter.format(dfMeta.rows_shown),
158
- sampled: buckarooState.sampled || '0',
159
- auto_clean: buckarooState.auto_clean || '0',
160
- df_display: buckarooState.df_display,
161
- filtered_rows: basicIntFormatter.format(dfMeta.filtered_rows),
162
- post_processing: buckarooState.post_processing,
163
- show_commands: buckarooState.show_commands || '0',
164
- search: searchStr
165
- }
166
- ];
167
-
168
- const gridOptions: GridOptions = {
169
- suppressRowClickSelection: true
170
- };
171
-
172
- const gridRef = useRef<AgGridReact<unknown>>(null);
173
- const defaultColDef = {
174
- cellStyle: {textAlign: 'left'}
175
- };
176
- return (
177
- <div className='statusBar'>
178
- <div style={{height: 50}} className='theme-hanger ag-theme-alpine-dark'>
179
- <AgGridReact
180
- ref={gridRef}
181
- onCellClicked={updateDict}
182
- gridOptions={gridOptions}
183
- defaultColDef={defaultColDef}
184
- rowData={rowData}
185
- columnDefs={columnDefs}
186
- ></AgGridReact>
187
- </div>
188
- </div>
189
- );
190
- }
@@ -1,42 +0,0 @@
1
- export interface DFMeta {
2
- // static,
3
- total_rows: number;
4
- columns: number;
5
- filtered_rows: number;
6
- rows_shown: number;
7
- }
8
- export interface BuckarooOptions {
9
- sampled: string[];
10
- auto_clean: string[];
11
- post_processing: string[];
12
- df_display: string[]; // keys into Into df_display_args
13
- show_commands: string[];
14
- }
15
-
16
- export type QuickAtom = number | string;
17
- export type QuickArg = QuickAtom[];
18
- export interface BuckarooState {
19
- sampled: string | false;
20
- auto_clean: string | false;
21
- quick_command_args: Record<string, QuickArg>;
22
- post_processing: string | false;
23
- df_display: string; //at least one dataframe must always be displayed
24
- show_commands: string | false;
25
- }
26
-
27
- export type BKeys = keyof BuckarooOptions;
28
-
29
- // df_dict: Record<string, DFWhole>;
30
- // df_meta: DFMeta;
31
- /*
32
-
33
- df_dict: Record<string, DFWhole>;
34
- df_meta: DFMeta;
35
- operations: Operation[];
36
- on_operations: (ops: Operation[]) => void;
37
- operation_results: OperationResult;
38
- commandConfig: CommandConfigT;
39
- buckaroo_state: BuckarooState;
40
- on_buckaroo_state: React.Dispatch<React.SetStateAction<BuckarooState>>;
41
- buckaroo_options: BuckarooOptions;
42
- */
@@ -1,14 +0,0 @@
1
- import {OperationDefaultArgs} from './OperationUtils';
2
- import {sym} from './utils';
3
- import {symDf, CommandConfigT, bakedArgSpecs} from './CommandUtils';
4
-
5
- export const bakedOperationDefaults: OperationDefaultArgs = {
6
- dropcol: [sym('dropcol'), symDf, 'col'],
7
- fillna: [sym('fillna'), symDf, 'col', 8],
8
- resample: [sym('resample'), symDf, 'col', 'monthly', {}]
9
- };
10
-
11
- export const bakedCommandConfig: CommandConfigT = {
12
- argspecs: bakedArgSpecs,
13
- defaultArgs: bakedOperationDefaults
14
- };
@@ -1,60 +0,0 @@
1
- import _ from 'lodash';
2
- import {DFWhole} from './DFViewerParts/DFWhole';
3
- import {ColDef} from 'ag-grid-community';
4
-
5
- export type setDFFunc = (newDf: DFWhole) => void;
6
-
7
- export const requestDf = (url: string, setCallBack: setDFFunc) => {
8
- const retPromise = fetch(url).then(async (response) => {
9
- const tableDf = await response.json();
10
- setCallBack(tableDf);
11
- });
12
- return retPromise;
13
- };
14
-
15
- export const sym = (symbolName: string) => {
16
- return {symbol: symbolName};
17
- };
18
-
19
- export function replaceInArr<T>(arr: T[], old: T, subst: T): T[] {
20
- return arr.map((item: T) => (item === old ? subst : item));
21
- }
22
-
23
- export function replaceAtIdx<T>(arr: T[], idx: number, subst: T): T[] {
24
- return arr.map((item: T, innerIdx: number) => (innerIdx === idx ? subst : item));
25
- }
26
-
27
- export function replaceAtKey<T>(obj: Record<string, T>, key: string, subst: T): Record<string, T> {
28
- const objCopy = _.clone(obj);
29
- objCopy[key] = subst;
30
- return objCopy;
31
- }
32
-
33
- export const objWithoutNull = (obj: Record<string, string>, extraStrips: string[] = []) =>
34
- _.pickBy(obj, (x) => ![null, undefined, ...extraStrips].includes(x));
35
- export const updateAtMatch = (
36
- cols: ColDef[],
37
- key: string,
38
- subst: Partial<ColDef>,
39
- negative: Partial<ColDef>
40
- ) => {
41
- const retColumns = cols.map((x) => {
42
- if (x.field === key) {
43
- return {...x, ...subst};
44
- } else {
45
- return {...x, ...negative};
46
- }
47
- });
48
- return retColumns;
49
- };
50
-
51
- export const replaceAtMatch = (cols: ColDef[], key: string, subst: Partial<ColDef>) => {
52
- const retColumns = cols.map((x) => {
53
- if (x.field === key) {
54
- return {...x, ...subst};
55
- } else {
56
- return {...x};
57
- }
58
- });
59
- return retColumns;
60
- };
@@ -1,15 +0,0 @@
1
- // Copyright (c) Jupyter Development Team.
2
- // Distributed under the terms of the Modified BSD License.
3
-
4
- // Entry point for the notebook bundle containing custom model definitions.
5
- //
6
- // Setup notebook base URL
7
- //
8
- // Some static assets may be required by the custom widget javascript. The base
9
- // url for the notebook is not known at build time and is therefore computed
10
- // dynamically.
11
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
- (window as any).__webpack_public_path__ =
13
- document.querySelector('body')!.getAttribute('data-base-url') + 'nbextensions/buckaroo';
14
-
15
- export * from './index';
@@ -1,34 +0,0 @@
1
- // Copyright (c) Bloomberg
2
- // Distributed under the terms of the Modified BSD License.
3
-
4
- import {ColumnsEditor, ColumnsEditorEx} from './components/ColumnsEditor';
5
- import {WidgetDCFCellExample} from './components/DCFCell';
6
- import {DFViewer, DFViewerEx} from './components/DFViewerParts/DFViewer';
7
- import {HistogramCell} from './components/DFViewerParts/HistogramCell';
8
- import {DependentTabs} from './components/DependentTabs';
9
- import {OperationViewer} from './components/Operations';
10
- //import { DFData, DFViewerConfig } from './components/DFViewerParts/DFWhole';
11
- import {StatusBar} from './components/StatusBar';
12
-
13
- // In case of classic Jupyter Notebook and embed, we provide the PhosphorJS CSS
14
-
15
- export * as bakedData from './baked_data/staticData';
16
-
17
- export const extraComponents = {
18
- ColumnsEditor,
19
- DependentTabs,
20
- OperationViewer,
21
- WidgetDCFCellExample,
22
- ColumnsEditorEx,
23
- DFViewer,
24
- DFViewerEx,
25
- StatusBar,
26
- HistogramCell
27
- };
28
-
29
- /*
30
- export const typing = {
31
- DFData,
32
- DFViewerConfig
33
- };
34
- */