@redsift/table 9.3.0-muiv5 → 9.3.1-muiv5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _mui_x_data_grid_pro from '@mui/x-data-grid-pro';
2
- import { GridFilterItem, GridCellParams, GridFilterOperator, GridFilterInputMultipleValue, DataGridProProps, GridToolbarExportProps, GridToolbarFilterButtonProps, GridFilterModel, GridToolbarColumnsButton, GridToolbarDensitySelector } from '@mui/x-data-grid-pro';
2
+ import { GridFilterItem, GridCellParams, GridFilterOperator, GridFilterInputMultipleValue, DataGridProProps, GridFilterModel, GridToolbarExportProps, GridToolbarFilterButtonProps, GridToolbarColumnsButton, GridToolbarDensitySelector } from '@mui/x-data-grid-pro';
3
3
  export { GridAlignment, GridColDef, GridColumns, GridFilterItem, GridFilterModel, GridSelectionModel, getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators } from '@mui/x-data-grid-pro';
4
4
  import { Comp, IconProps, NotificationsColorPalette, ProductColorPalette, ShieldVariant } from '@redsift/design-system';
5
- import React, { ReactNode, RefObject, ComponentProps } from 'react';
5
+ import React, { ReactNode, ComponentProps, RefObject } from 'react';
6
6
  import { TablePaginationProps } from '@mui/material';
7
7
 
8
8
  declare const DETAIL_PANEL_TOGGLE_COL_DEF: _mui_x_data_grid_pro.GridColDef<any, any, any>;
@@ -61,6 +61,8 @@ declare const STARTS_WITH_ANY_OF: {
61
61
 
62
62
  declare const getGridStringArrayOperators: () => GridFilterOperator<any, number | string | null, any>[];
63
63
 
64
+ declare function getCompletion(text: string, role: string, openai_api_key: string | undefined, model?: string): Promise<string>;
65
+
64
66
  interface DataGridProps extends Partial<Pick<DataGridProProps, 'rows'>>, Omit<DataGridProProps, 'rows'> {
65
67
  /** License key for MUI Datagrid Pro. */
66
68
  license?: string;
@@ -99,6 +101,21 @@ interface FilterConfig {
99
101
  openaiApiKey?: string;
100
102
  completionFunc?: (nlpFilterConfig: FilterConfig, prompt: string, model: string) => Promise<CompletionResponse>;
101
103
  }
104
+ interface GridToolbarFilterSemanticFieldProps extends ComponentProps<'form'> {
105
+ nlpFilterConfig: FilterConfig;
106
+ onFilterModelChange: (filterModel: GridFilterModel) => void;
107
+ }
108
+
109
+ declare const DEFAULT_OPERATORS: {
110
+ string: string[];
111
+ number: string[];
112
+ boolean: string[];
113
+ date: string[];
114
+ };
115
+ /**
116
+ * The GridToolbarFilterSemanticField component.
117
+ */
118
+ declare const GridToolbarFilterSemanticField: Comp<GridToolbarFilterSemanticFieldProps, HTMLFormElement>;
102
119
 
103
120
  type GridToolbarColumnsProps = Omit<typeof GridToolbarColumnsButton, 'ref'>;
104
121
  type GridToolbarDensityProps = Omit<typeof GridToolbarDensitySelector, 'ref'>;
@@ -174,4 +191,4 @@ interface TextCellProps extends ComponentProps<'div'> {
174
191
  */
175
192
  declare const TextCell: Comp<TextCellProps, HTMLDivElement>;
176
193
 
177
- export { CONTAINS_ANY_OF, CONTAINS_ANY_OF_I, DETAIL_PANEL_TOGGLE_COL_DEF, DataGrid, DataGridProps, ENDS_WITH_ANY_OF, IS_ANY_OF, IS_BETWEEN, IS_NOT_ANY_OF, STARTS_WITH_ANY_OF, StyledDataGridProps, TextCell, Toolbar, getGridNumericOperators, getGridStringArrayOperators, getGridStringOperators };
194
+ export { CONTAINS_ANY_OF, CONTAINS_ANY_OF_I, DEFAULT_OPERATORS, DETAIL_PANEL_TOGGLE_COL_DEF, DataGrid, DataGridProps, ENDS_WITH_ANY_OF, GridToolbarFilterSemanticField, IS_ANY_OF, IS_BETWEEN, IS_NOT_ANY_OF, STARTS_WITH_ANY_OF, StyledDataGridProps, TextCell, Toolbar, getCompletion, getGridNumericOperators, getGridStringArrayOperators, getGridStringOperators };
package/index.js CHANGED
@@ -17644,6 +17644,37 @@ const getGridStringArrayOperators = () => [CONTAINS_ANY_OF, ENDS_WITH_ANY_OF, IS
17644
17644
 
17645
17645
  const getGridStringOperators = () => [...getGridStringOperators$1(), ...getGridStringArrayOperators()];
17646
17646
 
17647
+ const API_URL = 'https://api.openai.com/v1/chat/completions';
17648
+ async function getCompletion(text, role, openai_api_key) {
17649
+ let model = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'gpt-3.5-turbo-0613';
17650
+ try {
17651
+ const messages = [{
17652
+ role: 'system',
17653
+ content: role
17654
+ }, {
17655
+ role: 'user',
17656
+ content: text
17657
+ }];
17658
+ const url = API_URL;
17659
+ const response = await fetch(url, {
17660
+ method: 'POST',
17661
+ headers: {
17662
+ 'Content-Type': 'application/json',
17663
+ Authorization: `Bearer ${openai_api_key}`
17664
+ },
17665
+ body: JSON.stringify({
17666
+ messages: messages,
17667
+ temperature: 0,
17668
+ model: model
17669
+ })
17670
+ });
17671
+ const data = await response.json();
17672
+ return data.choices[0].message.content;
17673
+ } catch (error) {
17674
+ return '';
17675
+ }
17676
+ }
17677
+
17647
17678
  // Store the license information in a global, so it can be shared
17648
17679
  // when module duplication occurs. The duplication of the modules can happen
17649
17680
  // if using multiple version of MUI X at the same time of the bundler
@@ -21657,37 +21688,6 @@ const StyledGridToolbarFilterSemanticField = styled$3.form`
21657
21688
  }
21658
21689
  `;
21659
21690
 
21660
- const API_URL = 'https://api.openai.com/v1/chat/completions';
21661
- async function getCompletion(text, role, openai_api_key) {
21662
- let model = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'gpt-3.5-turbo-0613';
21663
- try {
21664
- const messages = [{
21665
- role: 'system',
21666
- content: role
21667
- }, {
21668
- role: 'user',
21669
- content: text
21670
- }];
21671
- const url = API_URL;
21672
- const response = await fetch(url, {
21673
- method: 'POST',
21674
- headers: {
21675
- 'Content-Type': 'application/json',
21676
- Authorization: `Bearer ${openai_api_key}`
21677
- },
21678
- body: JSON.stringify({
21679
- messages: messages,
21680
- temperature: 0,
21681
- model: model
21682
- })
21683
- });
21684
- const data = await response.json();
21685
- return data.choices[0].message.content;
21686
- } catch (error) {
21687
- return '';
21688
- }
21689
- }
21690
-
21691
21691
  const _excluded$e = ["className", "nlpFilterConfig", "onFilterModelChange"];
21692
21692
  const COMPONENT_NAME$2 = 'GridToolbarFilterSemanticField';
21693
21693
  const CLASSNAME$2 = 'redsift-datagrid-toolbar-nlp-filter-field';
@@ -21696,6 +21696,12 @@ const DEFAULT_GPT_MODEL = 'gpt-4-0613';
21696
21696
  const DEFAULT_FILTER = {
21697
21697
  items: []
21698
21698
  };
21699
+ const DEFAULT_OPERATORS = {
21700
+ string: ['contains', 'equals', 'startsWith', 'endsWith', 'isEmpty', 'isNotEmpty', 'isAnyOf'],
21701
+ number: ['=', '!=', '>', '>=', '<', '<=', 'isEmpty', 'isNotEmpty', 'isAnyOf'],
21702
+ boolean: ['is'],
21703
+ date: ['is', 'not', 'after', 'onOrAfter', 'before', 'onOrBefore', 'isEmpty', 'isNotEmpty']
21704
+ };
21699
21705
  const getRole = config => {
21700
21706
  const today = new Date().toDateString();
21701
21707
  const columns = `[${config.columns.map(_ref => {
@@ -24714,5 +24720,5 @@ const TextCell = /*#__PURE__*/forwardRef((props, ref) => {
24714
24720
  TextCell.className = CLASSNAME;
24715
24721
  TextCell.displayName = COMPONENT_NAME;
24716
24722
 
24717
- export { CONTAINS_ANY_OF, CONTAINS_ANY_OF_I, DETAIL_PANEL_TOGGLE_COL_DEF, DataGrid, ENDS_WITH_ANY_OF, IS_ANY_OF, IS_BETWEEN, IS_NOT_ANY_OF, STARTS_WITH_ANY_OF, TextCell, Toolbar$2 as Toolbar, getGridNumericOperators, getGridStringArrayOperators, getGridStringOperators };
24723
+ export { CONTAINS_ANY_OF, CONTAINS_ANY_OF_I, DEFAULT_OPERATORS, DETAIL_PANEL_TOGGLE_COL_DEF, DataGrid, ENDS_WITH_ANY_OF, GridToolbarFilterSemanticField, IS_ANY_OF, IS_BETWEEN, IS_NOT_ANY_OF, STARTS_WITH_ANY_OF, TextCell, Toolbar$2 as Toolbar, getCompletion, getGridNumericOperators, getGridStringArrayOperators, getGridStringOperators };
24718
24724
  //# sourceMappingURL=index.js.map