buckaroo-js-core 0.8.5 → 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 (244) 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 -5
  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 -98
  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 -220
  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/OtherRenderers.d.ts +0 -7
  130. package/buckaroo_js/components/DFViewerParts/OtherRenderers.d.ts.map +0 -1
  131. package/buckaroo_js/components/DFViewerParts/OtherRenderers.js +0 -29
  132. package/buckaroo_js/components/DFViewerParts/OtherRenderers.js.map +0 -1
  133. package/buckaroo_js/components/DFViewerParts/SeriesSummaryTooltip.d.ts +0 -5
  134. package/buckaroo_js/components/DFViewerParts/SeriesSummaryTooltip.d.ts.map +0 -1
  135. package/buckaroo_js/components/DFViewerParts/SeriesSummaryTooltip.js +0 -18
  136. package/buckaroo_js/components/DFViewerParts/SeriesSummaryTooltip.js.map +0 -1
  137. package/buckaroo_js/components/DFViewerParts/gridUtils.d.ts +0 -24
  138. package/buckaroo_js/components/DFViewerParts/gridUtils.d.ts.map +0 -1
  139. package/buckaroo_js/components/DFViewerParts/gridUtils.js +0 -230
  140. package/buckaroo_js/components/DFViewerParts/gridUtils.js.map +0 -1
  141. package/buckaroo_js/components/DependentTabs.d.ts.map +0 -1
  142. package/buckaroo_js/components/DependentTabs.js +0 -108
  143. package/buckaroo_js/components/DependentTabs.js.map +0 -1
  144. package/buckaroo_js/components/OperationDetail.d.ts.map +0 -1
  145. package/buckaroo_js/components/OperationDetail.js +0 -144
  146. package/buckaroo_js/components/OperationDetail.js.map +0 -1
  147. package/buckaroo_js/components/OperationUtils.d.ts.map +0 -1
  148. package/buckaroo_js/components/OperationUtils.js +0 -14
  149. package/buckaroo_js/components/OperationUtils.js.map +0 -1
  150. package/buckaroo_js/components/Operations.d.ts +0 -24
  151. package/buckaroo_js/components/Operations.d.ts.map +0 -1
  152. package/buckaroo_js/components/Operations.js +0 -209
  153. package/buckaroo_js/components/Operations.js.map +0 -1
  154. package/buckaroo_js/components/StatusBar.d.ts +0 -12
  155. package/buckaroo_js/components/StatusBar.d.ts.map +0 -1
  156. package/buckaroo_js/components/StatusBar.js +0 -155
  157. package/buckaroo_js/components/StatusBar.js.map +0 -1
  158. package/buckaroo_js/components/WidgetTypes.d.ts.map +0 -1
  159. package/buckaroo_js/components/WidgetTypes.js +0 -3
  160. package/buckaroo_js/components/WidgetTypes.js.map +0 -1
  161. package/buckaroo_js/components/bakedOperationDefaults.d.ts +0 -5
  162. package/buckaroo_js/components/bakedOperationDefaults.d.ts.map +0 -1
  163. package/buckaroo_js/components/bakedOperationDefaults.js +0 -15
  164. package/buckaroo_js/components/bakedOperationDefaults.js.map +0 -1
  165. package/buckaroo_js/components/utils.d.ts +0 -294
  166. package/buckaroo_js/components/utils.d.ts.map +0 -1
  167. package/buckaroo_js/components/utils.js +0 -143
  168. package/buckaroo_js/components/utils.js.map +0 -1
  169. package/buckaroo_js/extension.d.ts +0 -2
  170. package/buckaroo_js/extension.d.ts.map +0 -1
  171. package/buckaroo_js/extension.js +0 -20
  172. package/buckaroo_js/extension.js.map +0 -1
  173. package/buckaroo_js/index.d.ts +0 -24
  174. package/buckaroo_js/index.d.ts.map +0 -1
  175. package/buckaroo_js/index.js +0 -44
  176. package/buckaroo_js/index.js.map +0 -1
  177. package/buckaroo_js/vendor/RechartExtra.d.ts +0 -38
  178. package/buckaroo_js/vendor/RechartExtra.d.ts.map +0 -1
  179. package/buckaroo_js/vendor/RechartExtra.js +0 -17
  180. package/buckaroo_js/vendor/RechartExtra.js.map +0 -1
  181. package/buckaroo_js/vendor/RechartTooltip.d.ts +0 -82
  182. package/buckaroo_js/vendor/RechartTooltip.d.ts.map +0 -1
  183. package/buckaroo_js/vendor/RechartTooltip.js +0 -231
  184. package/buckaroo_js/vendor/RechartTooltip.js.map +0 -1
  185. package/codecov.yml +0 -16
  186. package/eslint.config.mjs +0 -88
  187. package/examples/App.tsx +0 -160
  188. package/examples/CodeBlock.tsx +0 -27
  189. package/examples/CodePenButton.tsx +0 -72
  190. package/examples/ReadmeBlock.tsx +0 -11
  191. package/examples/app.css +0 -29
  192. package/examples/ex/ColumnsEditorEx.tsx +0 -5
  193. package/examples/ex/CommandViewerEx.tsx +0 -18
  194. package/examples/ex/DFViewerEx.tsx +0 -3
  195. package/examples/ex/DFViewerEx_large.tsx +0 -266
  196. package/examples/ex/DFViewerEx_real_summary.tsx +0 -18
  197. package/examples/ex/DFViewerEx_short_data.tsx +0 -22
  198. package/examples/ex/DFViewerEx_string_index.tsx +0 -1012
  199. package/examples/ex/HistogramEx.tsx +0 -41
  200. package/examples/ex/StatusBarEx.tsx +0 -46
  201. package/examples/ex/WidgetDCFCellEx.tsx +0 -6
  202. package/examples/example.css +0 -20
  203. package/examples/index-iframe.hnottml +0 -24
  204. package/examples/index-react18.tsx +0 -8
  205. package/examples/index.html +0 -20
  206. package/examples/jsx-loader.ts +0 -16
  207. package/examples/tsconfig.json +0 -31
  208. package/index.d.ts +0 -2
  209. package/index.d.ts.map +0 -1
  210. package/index.js +0 -7
  211. package/index.js.map +0 -1
  212. package/jest.config.js +0 -24
  213. package/screen-animation.gif +0 -0
  214. package/src/buckaroo_js/baked_data/colorMap.ts +0 -523
  215. package/src/buckaroo_js/baked_data/staticData.ts +0 -503
  216. package/src/buckaroo_js/components/ColumnsEditor.tsx +0 -66
  217. package/src/buckaroo_js/components/CommandUtils.ts +0 -40
  218. package/src/buckaroo_js/components/DCFCell.tsx +0 -175
  219. package/src/buckaroo_js/components/DFViewerParts/DFViewer.tsx +0 -215
  220. package/src/buckaroo_js/components/DFViewerParts/DFWhole.ts +0 -190
  221. package/src/buckaroo_js/components/DFViewerParts/Displayer.ts +0 -218
  222. package/src/buckaroo_js/components/DFViewerParts/OtherRenderers.tsx +0 -28
  223. package/src/buckaroo_js/components/DFViewerParts/SeriesSummaryTooltip.tsx +0 -20
  224. package/src/buckaroo_js/components/DFViewerParts/gridUtils.ts +0 -291
  225. package/src/buckaroo_js/components/DependentTabs.tsx +0 -134
  226. package/src/buckaroo_js/components/OperationDetail.tsx +0 -203
  227. package/src/buckaroo_js/components/OperationUtils.ts +0 -33
  228. package/src/buckaroo_js/components/Operations.tsx +0 -243
  229. package/src/buckaroo_js/components/StatusBar.tsx +0 -190
  230. package/src/buckaroo_js/components/WidgetTypes.tsx +0 -42
  231. package/src/buckaroo_js/components/bakedOperationDefaults.ts +0 -14
  232. package/src/buckaroo_js/components/utils.ts +0 -60
  233. package/src/buckaroo_js/extension.ts +0 -15
  234. package/src/buckaroo_js/index.ts +0 -32
  235. package/src/buckaroo_js/style/dcf-npm.css +0 -244
  236. package/src/buckaroo_js/style/icons/arrow-down-short-dark.svg +0 -4
  237. package/src/buckaroo_js/style/icons/arrow-down-short.svg +0 -4
  238. package/src/buckaroo_js/style/icons/arrow-up-short-dark.svg +0 -4
  239. package/src/buckaroo_js/style/icons/arrow-up-short.svg +0 -4
  240. package/src/buckaroo_js/style/icons/filter-dark.svg +0 -3
  241. package/src/buckaroo_js/style/icons/filter.svg +0 -3
  242. package/src/index.tsx +0 -3
  243. package/tsconfig.json +0 -41
  244. package/webpack.config.ts +0 -98
@@ -1,203 +0,0 @@
1
- import _ from 'lodash';
2
- import {Operation, SettableArg, OperationEventFunc} from './OperationUtils';
3
- import {ActualArg, CommandArgSpec} from './CommandUtils';
4
- import {objWithoutNull, replaceAtIdx, replaceAtKey} from './utils';
5
- import React from 'react';
6
-
7
- export const OperationDetail = ({
8
- command,
9
- setCommand,
10
- columns,
11
- commandPatterns
12
- }: {
13
- command: Operation;
14
- setCommand: OperationEventFunc;
15
- columns: string[];
16
- commandPatterns: CommandArgSpec;
17
- }) => {
18
- if (command === undefined) {
19
- return <span></span>;
20
- }
21
- const commandName = command[0]['symbol'];
22
- const pattern = commandPatterns[commandName];
23
-
24
- if (!_.isArray(pattern)) {
25
- //we shouldn't get here
26
- return <h2>unknown command {commandName}</h2>;
27
- } else if (_.isEqual(pattern, [null])) {
28
- return <div className='operation-detail'></div>;
29
- } else {
30
- const fullPattern = pattern as ActualArg[];
31
- return (
32
- <div className='operation-detail'>
33
- <ArgGetters
34
- command={command}
35
- fullPattern={fullPattern}
36
- setCommand={setCommand}
37
- columns={columns}
38
- />
39
- </div>
40
- );
41
- }
42
- return <h2></h2>;
43
- };
44
-
45
- export const ArgGetters = ({
46
- command,
47
- fullPattern,
48
- setCommand,
49
- columns
50
- }: {
51
- command: Operation;
52
- fullPattern: ActualArg[];
53
- setCommand: OperationEventFunc;
54
- columns: string[];
55
- }) => {
56
- /* reads the argspec and sets up the proper getters/setters */
57
- const makeArgGetter = (pattern: ActualArg) => {
58
- const idx = pattern[0];
59
- const val = command[idx] as SettableArg;
60
- const valSetter = (newVal: unknown) => {
61
- const newCommand = replaceAtIdx(command, idx, newVal);
62
- //console.log('newCommand', newCommand);
63
- setCommand(newCommand as Operation);
64
- };
65
- return (
66
- <div key={idx}>
67
- <ArgGetter
68
- argProps={pattern}
69
- renderKey={idx}
70
- val={val}
71
- setter={valSetter}
72
- columns={columns}
73
- />
74
- </div>
75
- );
76
- };
77
- return <div className='arg-getters'>{fullPattern.map(makeArgGetter)}</div>;
78
- };
79
-
80
- const ArgGetter = ({
81
- argProps,
82
- val,
83
- setter,
84
- columns,
85
- renderKey
86
- }: {
87
- argProps: ActualArg;
88
- val: SettableArg;
89
- setter: (arg: SettableArg) => void;
90
- columns: string[];
91
- renderKey: number;
92
- }) => {
93
- const [_argPos, label, argType, lastArg] = argProps;
94
-
95
- const defaultShim = (event: {target: {value: SettableArg}}) => setter(event.target.value);
96
- if (argType === 'enum' && _.isArray(lastArg)) {
97
- return (
98
- <fieldset key={renderKey}>
99
- <label> {label} </label>
100
- <select defaultValue={val as string} onChange={defaultShim}>
101
- {lastArg.map((optionVal) => (
102
- <option key={optionVal} value={optionVal}>
103
- {optionVal}
104
- </option>
105
- ))}
106
- </select>
107
- </fieldset>
108
- );
109
- } else if (argType === 'type') {
110
- if (lastArg === 'integer') {
111
- const valSetterShim = (event: {target: {value: string}}) =>
112
- setter(parseInt(event.target.value));
113
- return (
114
- <fieldset key={renderKey}>
115
- <label> {label} </label>
116
- <input
117
- type='number'
118
- defaultValue={val as number}
119
- step='1'
120
- onChange={valSetterShim}
121
- />
122
- </fieldset>
123
- );
124
- } else if (lastArg === 'float') {
125
- const valSetterShim = (event: {target: {value: string}}) =>
126
- setter(parseFloat(event.target.value));
127
- return (
128
- <fieldset key={renderKey}>
129
- <label> {label} </label>
130
- <input
131
- type='number'
132
- step='0.01'
133
- defaultValue={val as number}
134
- onChange={valSetterShim}
135
- />
136
- </fieldset>
137
- );
138
- } else if (lastArg === 'string') {
139
- const valSetterShim = (event: {target: {value: string}}) => setter(event.target.value);
140
- return (
141
- <fieldset key={renderKey}>
142
- <label> {label} </label>
143
- <input type='text' defaultValue={val as string} onChange={valSetterShim} />
144
- </fieldset>
145
- );
146
- } else {
147
- return (
148
- <fieldset key={renderKey}>
149
- <label> {label} </label>
150
- <input value='dont know' />
151
- </fieldset>
152
- );
153
- }
154
- } else if (argType === 'colEnum') {
155
- const widgetRow = columns.map((colName: string) => {
156
- const colSetter = (event: {target: {value: any}}) => {
157
- const newColVal = event.target.value;
158
- if (_.isString(newColVal)) {
159
- const updatedColDict = replaceAtKey(
160
- val as Record<string, string>,
161
- colName,
162
- newColVal as string
163
- ); // as Record<string, string>
164
- setter(objWithoutNull(updatedColDict, ['null']));
165
- }
166
- };
167
- const colVal = _.get(val, colName, 'null');
168
- if (!_.isArray(lastArg)) {
169
- return <h3> arg error</h3>;
170
- }
171
- return (
172
- <td key={renderKey + colName}>
173
- <select defaultValue={colVal} onChange={colSetter}>
174
- {lastArg.map((optionVal) => (
175
- <option key={optionVal} value={optionVal}>
176
- {optionVal}
177
- </option>
178
- ))}
179
- </select>
180
- </td>
181
- );
182
- });
183
-
184
- return (
185
- <div className='col-enum' key={renderKey}>
186
- <table>
187
- <thead>
188
- <tr>
189
- {columns.map((colName) => (
190
- <th key={colName}>{colName}</th>
191
- ))}
192
- </tr>
193
- </thead>
194
- <tbody>
195
- <tr>{widgetRow}</tr>
196
- </tbody>
197
- </table>
198
- </div>
199
- );
200
- } else {
201
- return <h3> unknown argtype </h3>;
202
- }
203
- };
@@ -1,33 +0,0 @@
1
- /*
2
- used for manipulating the JSON Flavored lisp of operations and commands
3
- */
4
- import _ from 'lodash';
5
- import {SymbolT, ColEnumArgs, SymbolDf, symDf} from './CommandUtils';
6
-
7
- export const sym = (symbolName: string) => {
8
- return {symbol: symbolName};
9
- };
10
-
11
- export type Atom = number | string | SymbolT | ColEnumArgs;
12
- export type SettableArg = number | string | ColEnumArgs;
13
-
14
- export type OperationSingleColumn = [SymbolT, SymbolDf, string];
15
- export type OperationSingleArg = [SymbolT, SymbolDf, string, Atom];
16
- export type OperationTwoArg = [SymbolT, SymbolDf, string, Atom, Atom];
17
- export type Operation = OperationSingleColumn | OperationSingleArg | OperationTwoArg;
18
-
19
- export type SetOperationFunc = (newCommand: Operation) => void;
20
- export type SetOperationsFunc = (newCommands: Operation[]) => void;
21
-
22
- export type OperationDefaultArgs = Record<string, Operation>;
23
-
24
- //const ArgNames = ['Idx', 'label', 'specName', 'extraSpecArgs'];
25
- export const bakedOperations: Operation[] = [
26
- [sym('dropcol'), symDf, 'col1'],
27
- [sym('fillna'), symDf, 'col2', 5],
28
- [sym('resample'), symDf, 'month', 'monthly', {}]
29
- ];
30
-
31
- //this will become OperationEventFunc
32
- export type OperationEventFunc = (newCommand: Operation) => void;
33
- export type NoArgEventFunc = () => void;
@@ -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
- }