react-science 0.32.2 → 0.34.0

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 (207) hide show
  1. package/lib/app/about/AboutDialogToolbarButton.d.ts.map +1 -1
  2. package/lib/app/about/AboutDialogToolbarButton.js +2 -9
  3. package/lib/app/about/AboutDialogToolbarButton.js.map +1 -1
  4. package/lib/app/kinds/ir/IrPeaksPanel.js +1 -1
  5. package/lib/app/kinds/ir/IrPeaksPanel.js.map +1 -1
  6. package/lib/app/panels/SignalProcessingPanel.js +1 -1
  7. package/lib/app/panels/SignalProcessingPanel.js.map +1 -1
  8. package/lib/app/panels/measurements/MeasurementsPanel.d.ts +1 -1
  9. package/lib/app/panels/measurements/MeasurementsPanel.d.ts.map +1 -1
  10. package/lib/app/panels/measurements/MeasurementsPanel.js +20 -12
  11. package/lib/app/panels/measurements/MeasurementsPanel.js.map +1 -1
  12. package/lib/app/panels/measurements/MeasurementsTable.d.ts +1 -1
  13. package/lib/app/panels/measurements/MeasurementsTable.d.ts.map +1 -1
  14. package/lib/app/panels/measurements/MeasurementsTable.js +15 -12
  15. package/lib/app/panels/measurements/MeasurementsTable.js.map +1 -1
  16. package/lib/components/color-picker/color-picker-dropdown/ColorPickerDropdown.d.ts +4 -1
  17. package/lib/components/color-picker/color-picker-dropdown/ColorPickerDropdown.d.ts.map +1 -1
  18. package/lib/components/color-picker/color-picker-dropdown/ColorPickerDropdown.js +3 -17
  19. package/lib/components/color-picker/color-picker-dropdown/ColorPickerDropdown.js.map +1 -1
  20. package/lib/components/dialog/ConfirmDialog.d.ts +12 -0
  21. package/lib/components/dialog/ConfirmDialog.d.ts.map +1 -0
  22. package/lib/components/dialog/ConfirmDialog.js +22 -0
  23. package/lib/components/dialog/ConfirmDialog.js.map +1 -0
  24. package/lib/components/dialog/index.d.ts +2 -0
  25. package/lib/components/dialog/index.d.ts.map +1 -0
  26. package/lib/components/{tabs → dialog}/index.js +1 -1
  27. package/lib/components/dialog/index.js.map +1 -0
  28. package/lib/components/index.d.ts +1 -2
  29. package/lib/components/index.d.ts.map +1 -1
  30. package/lib/components/index.js +1 -2
  31. package/lib/components/index.js.map +1 -1
  32. package/lib/components/info-panel/InfoPanel.d.ts +0 -1
  33. package/lib/components/info-panel/InfoPanel.d.ts.map +1 -1
  34. package/lib/components/info-panel/InfoPanel.js +2 -8
  35. package/lib/components/info-panel/InfoPanel.js.map +1 -1
  36. package/lib/components/layout-manager/LayoutManager.d.ts.map +1 -1
  37. package/lib/components/layout-manager/LayoutManager.js +0 -2
  38. package/lib/components/layout-manager/LayoutManager.js.map +1 -1
  39. package/lib/components/root-layout/RootLayout.js +1 -1
  40. package/lib/components/root-layout/RootLayout.js.map +1 -1
  41. package/lib/components/table/Table.d.ts +8 -3
  42. package/lib/components/table/Table.d.ts.map +1 -1
  43. package/lib/components/table/Table.js +14 -65
  44. package/lib/components/table/Table.js.map +1 -1
  45. package/lib/components/table/TableHeader.d.ts +3 -0
  46. package/lib/components/table/TableHeader.d.ts.map +1 -0
  47. package/lib/components/table/TableHeader.js +10 -0
  48. package/lib/components/table/TableHeader.js.map +1 -0
  49. package/lib/components/table/TableRow.d.ts +3 -0
  50. package/lib/components/table/TableRow.d.ts.map +1 -0
  51. package/lib/components/table/TableRow.js +57 -0
  52. package/lib/components/table/TableRow.js.map +1 -0
  53. package/lib/components/table/tableContext.d.ts +10 -0
  54. package/lib/components/table/tableContext.d.ts.map +1 -0
  55. package/lib/components/table/tableContext.js +11 -0
  56. package/lib/components/table/tableContext.js.map +1 -0
  57. package/lib/components/toolbar/PanelPreferencesToolbar.d.ts.map +1 -1
  58. package/lib/components/toolbar/PanelPreferencesToolbar.js +2 -2
  59. package/lib/components/toolbar/PanelPreferencesToolbar.js.map +1 -1
  60. package/lib/components/toolbar/Toolbar.d.ts +8 -5
  61. package/lib/components/toolbar/Toolbar.d.ts.map +1 -1
  62. package/lib/components/toolbar/Toolbar.js +12 -9
  63. package/lib/components/toolbar/Toolbar.js.map +1 -1
  64. package/lib-esm/app/about/AboutDialogToolbarButton.d.ts.map +1 -1
  65. package/lib-esm/app/about/AboutDialogToolbarButton.js +4 -8
  66. package/lib-esm/app/about/AboutDialogToolbarButton.js.map +1 -1
  67. package/lib-esm/app/kinds/ir/IrPeaksPanel.js +1 -1
  68. package/lib-esm/app/kinds/ir/IrPeaksPanel.js.map +1 -1
  69. package/lib-esm/app/panels/SignalProcessingPanel.js +1 -1
  70. package/lib-esm/app/panels/SignalProcessingPanel.js.map +1 -1
  71. package/lib-esm/app/panels/measurements/MeasurementsPanel.d.ts +1 -1
  72. package/lib-esm/app/panels/measurements/MeasurementsPanel.d.ts.map +1 -1
  73. package/lib-esm/app/panels/measurements/MeasurementsPanel.js +16 -8
  74. package/lib-esm/app/panels/measurements/MeasurementsPanel.js.map +1 -1
  75. package/lib-esm/app/panels/measurements/MeasurementsTable.d.ts +1 -1
  76. package/lib-esm/app/panels/measurements/MeasurementsTable.d.ts.map +1 -1
  77. package/lib-esm/app/panels/measurements/MeasurementsTable.js +11 -8
  78. package/lib-esm/app/panels/measurements/MeasurementsTable.js.map +1 -1
  79. package/lib-esm/components/color-picker/color-picker-dropdown/ColorPickerDropdown.d.ts +4 -1
  80. package/lib-esm/components/color-picker/color-picker-dropdown/ColorPickerDropdown.d.ts.map +1 -1
  81. package/lib-esm/components/color-picker/color-picker-dropdown/ColorPickerDropdown.js +4 -18
  82. package/lib-esm/components/color-picker/color-picker-dropdown/ColorPickerDropdown.js.map +1 -1
  83. package/lib-esm/components/dialog/ConfirmDialog.d.ts +12 -0
  84. package/lib-esm/components/dialog/ConfirmDialog.d.ts.map +1 -0
  85. package/lib-esm/components/dialog/ConfirmDialog.js +18 -0
  86. package/lib-esm/components/dialog/ConfirmDialog.js.map +1 -0
  87. package/lib-esm/components/dialog/index.d.ts +2 -0
  88. package/lib-esm/components/dialog/index.d.ts.map +1 -0
  89. package/lib-esm/components/dialog/index.js +2 -0
  90. package/lib-esm/components/dialog/index.js.map +1 -0
  91. package/lib-esm/components/index.d.ts +1 -2
  92. package/lib-esm/components/index.d.ts.map +1 -1
  93. package/lib-esm/components/index.js +1 -2
  94. package/lib-esm/components/index.js.map +1 -1
  95. package/lib-esm/components/info-panel/InfoPanel.d.ts +0 -1
  96. package/lib-esm/components/info-panel/InfoPanel.d.ts.map +1 -1
  97. package/lib-esm/components/info-panel/InfoPanel.js +2 -8
  98. package/lib-esm/components/info-panel/InfoPanel.js.map +1 -1
  99. package/lib-esm/components/layout-manager/LayoutManager.d.ts.map +1 -1
  100. package/lib-esm/components/layout-manager/LayoutManager.js +0 -2
  101. package/lib-esm/components/layout-manager/LayoutManager.js.map +1 -1
  102. package/lib-esm/components/root-layout/RootLayout.js +1 -1
  103. package/lib-esm/components/root-layout/RootLayout.js.map +1 -1
  104. package/lib-esm/components/table/Table.d.ts +8 -3
  105. package/lib-esm/components/table/Table.d.ts.map +1 -1
  106. package/lib-esm/components/table/Table.js +12 -63
  107. package/lib-esm/components/table/Table.js.map +1 -1
  108. package/lib-esm/components/table/TableHeader.d.ts +3 -0
  109. package/lib-esm/components/table/TableHeader.d.ts.map +1 -0
  110. package/lib-esm/components/table/TableHeader.js +6 -0
  111. package/lib-esm/components/table/TableHeader.js.map +1 -0
  112. package/lib-esm/components/table/TableRow.d.ts +3 -0
  113. package/lib-esm/components/table/TableRow.d.ts.map +1 -0
  114. package/lib-esm/components/table/TableRow.js +53 -0
  115. package/lib-esm/components/table/TableRow.js.map +1 -0
  116. package/lib-esm/components/table/tableContext.d.ts +10 -0
  117. package/lib-esm/components/table/tableContext.d.ts.map +1 -0
  118. package/lib-esm/components/table/tableContext.js +7 -0
  119. package/lib-esm/components/table/tableContext.js.map +1 -0
  120. package/lib-esm/components/toolbar/PanelPreferencesToolbar.d.ts.map +1 -1
  121. package/lib-esm/components/toolbar/PanelPreferencesToolbar.js +2 -2
  122. package/lib-esm/components/toolbar/PanelPreferencesToolbar.js.map +1 -1
  123. package/lib-esm/components/toolbar/Toolbar.d.ts +8 -5
  124. package/lib-esm/components/toolbar/Toolbar.d.ts.map +1 -1
  125. package/lib-esm/components/toolbar/Toolbar.js +12 -9
  126. package/lib-esm/components/toolbar/Toolbar.js.map +1 -1
  127. package/package.json +30 -30
  128. package/src/app/about/AboutDialogToolbarButton.tsx +10 -14
  129. package/src/app/kinds/ir/IrPeaksPanel.tsx +1 -1
  130. package/src/app/panels/SignalProcessingPanel.tsx +5 -5
  131. package/src/app/panels/measurements/MeasurementsPanel.tsx +33 -15
  132. package/src/app/panels/measurements/MeasurementsTable.tsx +33 -26
  133. package/src/components/color-picker/color-picker-dropdown/ColorPickerDropdown.tsx +17 -37
  134. package/src/components/dialog/ConfirmDialog.tsx +65 -0
  135. package/src/components/dialog/index.ts +1 -0
  136. package/src/components/index.ts +1 -2
  137. package/src/components/info-panel/InfoPanel.tsx +4 -17
  138. package/src/components/layout-manager/LayoutManager.tsx +0 -2
  139. package/src/components/root-layout/RootLayout.tsx +1 -1
  140. package/src/components/table/Table.tsx +37 -96
  141. package/src/components/table/TableHeader.tsx +12 -0
  142. package/src/components/table/TableRow.tsx +89 -0
  143. package/src/components/table/tableContext.ts +7 -0
  144. package/src/components/toolbar/PanelPreferencesToolbar.tsx +17 -3
  145. package/src/components/toolbar/Toolbar.tsx +22 -13
  146. package/lib/components/modal/ConfirmModal.d.ts +0 -17
  147. package/lib/components/modal/ConfirmModal.d.ts.map +0 -1
  148. package/lib/components/modal/ConfirmModal.js +0 -71
  149. package/lib/components/modal/ConfirmModal.js.map +0 -1
  150. package/lib/components/modal/Modal.d.ts +0 -25
  151. package/lib/components/modal/Modal.d.ts.map +0 -1
  152. package/lib/components/modal/Modal.js +0 -85
  153. package/lib/components/modal/Modal.js.map +0 -1
  154. package/lib/components/modal/index.d.ts +0 -3
  155. package/lib/components/modal/index.d.ts.map +0 -1
  156. package/lib/components/modal/index.js +0 -19
  157. package/lib/components/modal/index.js.map +0 -1
  158. package/lib/components/modal/useDialog.d.ts +0 -19
  159. package/lib/components/modal/useDialog.d.ts.map +0 -1
  160. package/lib/components/modal/useDialog.js +0 -51
  161. package/lib/components/modal/useDialog.js.map +0 -1
  162. package/lib/components/tabs/Tabs.d.ts +0 -16
  163. package/lib/components/tabs/Tabs.d.ts.map +0 -1
  164. package/lib/components/tabs/Tabs.js +0 -99
  165. package/lib/components/tabs/Tabs.js.map +0 -1
  166. package/lib/components/tabs/TabsContext.d.ts +0 -8
  167. package/lib/components/tabs/TabsContext.d.ts.map +0 -1
  168. package/lib/components/tabs/TabsContext.js +0 -20
  169. package/lib/components/tabs/TabsContext.js.map +0 -1
  170. package/lib/components/tabs/index.d.ts +0 -2
  171. package/lib/components/tabs/index.d.ts.map +0 -1
  172. package/lib/components/tabs/index.js.map +0 -1
  173. package/lib-esm/components/modal/ConfirmModal.d.ts +0 -17
  174. package/lib-esm/components/modal/ConfirmModal.d.ts.map +0 -1
  175. package/lib-esm/components/modal/ConfirmModal.js +0 -64
  176. package/lib-esm/components/modal/ConfirmModal.js.map +0 -1
  177. package/lib-esm/components/modal/Modal.d.ts +0 -25
  178. package/lib-esm/components/modal/Modal.d.ts.map +0 -1
  179. package/lib-esm/components/modal/Modal.js +0 -78
  180. package/lib-esm/components/modal/Modal.js.map +0 -1
  181. package/lib-esm/components/modal/index.d.ts +0 -3
  182. package/lib-esm/components/modal/index.d.ts.map +0 -1
  183. package/lib-esm/components/modal/index.js +0 -3
  184. package/lib-esm/components/modal/index.js.map +0 -1
  185. package/lib-esm/components/modal/useDialog.d.ts +0 -19
  186. package/lib-esm/components/modal/useDialog.d.ts.map +0 -1
  187. package/lib-esm/components/modal/useDialog.js +0 -47
  188. package/lib-esm/components/modal/useDialog.js.map +0 -1
  189. package/lib-esm/components/tabs/Tabs.d.ts +0 -16
  190. package/lib-esm/components/tabs/Tabs.d.ts.map +0 -1
  191. package/lib-esm/components/tabs/Tabs.js +0 -95
  192. package/lib-esm/components/tabs/Tabs.js.map +0 -1
  193. package/lib-esm/components/tabs/TabsContext.d.ts +0 -8
  194. package/lib-esm/components/tabs/TabsContext.d.ts.map +0 -1
  195. package/lib-esm/components/tabs/TabsContext.js +0 -15
  196. package/lib-esm/components/tabs/TabsContext.js.map +0 -1
  197. package/lib-esm/components/tabs/index.d.ts +0 -2
  198. package/lib-esm/components/tabs/index.d.ts.map +0 -1
  199. package/lib-esm/components/tabs/index.js +0 -2
  200. package/lib-esm/components/tabs/index.js.map +0 -1
  201. package/src/components/modal/ConfirmModal.tsx +0 -134
  202. package/src/components/modal/Modal.tsx +0 -143
  203. package/src/components/modal/index.ts +0 -2
  204. package/src/components/modal/useDialog.ts +0 -95
  205. package/src/components/tabs/Tabs.tsx +0 -189
  206. package/src/components/tabs/TabsContext.tsx +0 -22
  207. package/src/components/tabs/index.ts +0 -1
@@ -0,0 +1,65 @@
1
+ /** @jsxImportSource @emotion/react */
2
+ import {
3
+ Dialog,
4
+ DialogBody,
5
+ DialogFooter,
6
+ DialogProps,
7
+ } from '@blueprintjs/core';
8
+ import { css } from '@emotion/react';
9
+
10
+ import { Button } from '..';
11
+
12
+ interface ConfirmDialogProps extends Omit<DialogProps, 'isCloseButtonShown'> {
13
+ onConfirm: () => void;
14
+ onCancel?: () => void;
15
+ saveText?: string;
16
+ cancelText?: string;
17
+ headerColor: string;
18
+ }
19
+
20
+ export function ConfirmDialog(props: ConfirmDialogProps) {
21
+ const {
22
+ saveText = 'Save',
23
+ cancelText = 'Cancel',
24
+ headerColor,
25
+ onClose,
26
+ onCancel = onClose,
27
+ onConfirm,
28
+ children,
29
+ ...otherProps
30
+ } = props;
31
+
32
+ return (
33
+ <Dialog
34
+ onClose={onClose}
35
+ {...otherProps}
36
+ title=" "
37
+ isCloseButtonShown={false}
38
+ css={css`
39
+ .bp5-dialog-header {
40
+ background-color: ${headerColor};
41
+ min-height: 0px;
42
+ }
43
+ `}
44
+ >
45
+ <DialogBody>{children}</DialogBody>
46
+ <DialogFooter
47
+ minimal
48
+ actions={[
49
+ <Button
50
+ key="cancel"
51
+ intent="danger"
52
+ text={cancelText}
53
+ onClick={onCancel}
54
+ />,
55
+ <Button
56
+ key="save"
57
+ intent="primary"
58
+ text={saveText}
59
+ onClick={onConfirm}
60
+ />,
61
+ ]}
62
+ />
63
+ </Dialog>
64
+ );
65
+ }
@@ -0,0 +1 @@
1
+ export * from './ConfirmDialog';
@@ -8,11 +8,10 @@ export * from './header/index';
8
8
  export * from './hooks/index';
9
9
  export * from './info-panel/index';
10
10
  export * from './layout-manager/index';
11
- export * from './modal/index';
11
+ export * from './dialog/index';
12
12
  export * from './root-layout/index';
13
13
  export * from './split-pane/index';
14
14
  export * from './table/index';
15
- export * from './tabs/index';
16
15
  export * from './toolbar/index';
17
16
  export * from './utils/index';
18
17
  export * as ValueRenderers from './value-renderers/index';
@@ -20,7 +20,6 @@ interface InfoPanelProps {
20
20
  data?: InfoPanelData[];
21
21
  titleStyle?: CSSProperties;
22
22
  inputStyle?: CSSProperties;
23
- tableStyle?: CSSProperties;
24
23
  }
25
24
  const style = {
26
25
  container: css({
@@ -37,23 +36,11 @@ const style = {
37
36
  gap: 5,
38
37
  padding: '5px 2px',
39
38
  }),
40
- table: css`
41
- width: 100%;
42
- td:first-of-type {
43
- width: 30%;
44
- }
45
- `,
46
39
  };
47
40
 
48
41
  export function InfoPanel(props: InfoPanelProps) {
49
42
  const [search, setSearch] = useState('');
50
- const {
51
- title = 'Information',
52
- data = [],
53
- titleStyle,
54
- inputStyle,
55
- tableStyle,
56
- } = props;
43
+ const { title = 'Information', data = [], titleStyle, inputStyle } = props;
57
44
  function viewData(data: Record<string, string | number | object>) {
58
45
  const exactMatch: Array<[string, string | number | object]> = [];
59
46
  const startsWith: Array<[string, string | number | object]> = [];
@@ -112,10 +99,10 @@ export function InfoPanel(props: InfoPanelProps) {
112
99
  {description}
113
100
  </Disclosure.Button>
114
101
  <Disclosure.Panel>
115
- <Table css={style.table} style={tableStyle}>
102
+ <Table bordered>
116
103
  <Table.Header>
117
- <ValueRenderers.Title value="Parameter" />
118
- <ValueRenderers.Title value="Value" />
104
+ <ValueRenderers.Header value="Parameter" />
105
+ <ValueRenderers.Header value="Value" />
119
106
  </Table.Header>
120
107
  {content}
121
108
  </Table>
@@ -8,13 +8,11 @@ import {
8
8
 
9
9
  import { Accordion } from '../accordion/Accordion';
10
10
  import { DropZone } from '../drop-zone/DropZone';
11
- import { Modal } from '../modal/Modal';
12
11
  import { SplitPane } from '../split-pane/SplitPane';
13
12
 
14
13
  const layoutComponents: ComponentsMap = {
15
14
  SplitPane,
16
15
  Accordion,
17
- Modal,
18
16
  DropZone,
19
17
  };
20
18
 
@@ -33,7 +33,7 @@ export function RootLayout(props: RootLayoutProps) {
33
33
  }, []);
34
34
 
35
35
  return (
36
- <div style={{ ...style, ...props.style }}>
36
+ <div style={{ ...style, ...props.style }} translate="no">
37
37
  <CustomDivPreflight ref={ref}>
38
38
  <RootLayoutProvider innerRef={rootRef}>
39
39
  <QueryClientProvider client={queryClient}>
@@ -1,55 +1,26 @@
1
1
  /** @jsxImportSource @emotion/react */
2
- import { css } from '@emotion/react';
2
+ import { HTMLTable } from '@blueprintjs/core';
3
3
  import {
4
4
  Children,
5
- createContext,
6
5
  isValidElement,
7
6
  ReactElement,
8
7
  ReactNode,
9
- useContext,
10
8
  useMemo,
11
9
  } from 'react';
12
10
 
13
- import {
14
- Boolean,
15
- Color,
16
- Component,
17
- Header,
18
- Number,
19
- Object,
20
- Text,
21
- Title,
22
- } from '../value-renderers';
23
-
24
- const styles = {
25
- border: css({
26
- border: '0.5px solid rgb(0, 0, 0)',
27
- padding: '5px',
28
- position: 'relative',
29
- }),
30
- noBorder: css({
31
- padding: '5px',
32
- position: 'relative',
33
- }),
34
- };
35
-
36
- const TableContext = createContext({ border: true });
37
- function useTableContext() {
38
- const context = useContext(TableContext);
39
- return context;
40
- }
11
+ import { TableHeader } from './TableHeader';
12
+ import { TableRow } from './TableRow';
13
+ import { TableContext } from './tableContext';
41
14
 
42
15
  function splitChildren(children: ReactNode) {
43
16
  const Rows: ReactElement[] = [];
44
17
  let Header: ReactElement | null = null;
45
18
  for (const child of Children.toArray(children)) {
46
19
  if (typeof child !== 'object' || !isValidElement(child)) {
47
- // eslint-disable-next-line no-console
48
- console.error('Invalid Table child:', child);
49
20
  throw new Error('invalid Table child');
50
- } else if (child.type === Table.Row) {
21
+ } else if (child.type === TableRow) {
51
22
  Rows.push(child);
52
- } else if (child.type === Table.Header) {
23
+ } else if (child.type === TableHeader) {
53
24
  Header = child;
54
25
  } else {
55
26
  throw new Error('invalid Table child');
@@ -59,76 +30,46 @@ function splitChildren(children: ReactNode) {
59
30
  }
60
31
  export interface TableProps extends React.HTMLAttributes<HTMLTableElement> {
61
32
  children?: ReactNode;
62
- border?: boolean;
33
+ bordered?: boolean;
34
+ compact?: boolean;
35
+ interactive?: boolean;
36
+ striped?: boolean;
37
+ hasBorder?: boolean;
38
+ color?: string;
63
39
  }
64
40
 
65
41
  export function Table(props: TableProps) {
66
- const { border = true, children, ...tableProps } = props;
42
+ const {
43
+ hasBorder = false,
44
+ bordered = false,
45
+ compact = false,
46
+ interactive = false,
47
+ striped = false,
48
+ color = '',
49
+ children,
50
+ ...tableProps
51
+ } = props;
67
52
  const { Header, Rows } = splitChildren(children);
68
- const tableContextValue = useMemo(() => ({ border }), [border]);
53
+
54
+ const tableContextValue = useMemo(
55
+ () => ({ hasBorder, color }),
56
+ [hasBorder, color],
57
+ );
69
58
  return (
70
59
  <TableContext.Provider value={tableContextValue}>
71
- <table {...tableProps}>
60
+ <HTMLTable
61
+ bordered={bordered}
62
+ compact={compact}
63
+ interactive={interactive}
64
+ striped={striped}
65
+ {...tableProps}
66
+ >
72
67
  {Header}
73
68
  <tbody>{Rows}</tbody>
74
- </table>
69
+ </HTMLTable>
75
70
  </TableContext.Provider>
76
71
  );
77
72
  }
78
73
 
79
- function useRowChildren(children: ReactNode) {
80
- const cells: ReactElement[] = [];
81
- const { border } = useTableContext();
82
- for (const child of Children.toArray(children)) {
83
- if (
84
- typeof child === 'object' &&
85
- isValidElement(child) &&
86
- (child.type === Color ||
87
- child.type === Boolean ||
88
- child.type === Text ||
89
- child.type === Number ||
90
- child.type === Title ||
91
- child.type === Object ||
92
- child.type === Header ||
93
- child.type === Component)
94
- ) {
95
- if (child.type === Header) {
96
- cells.push(
97
- <th key={child.key} css={border ? styles.border : styles.noBorder}>
98
- {child}
99
- </th>,
100
- );
101
- } else {
102
- cells.push(
103
- <td key={child.key} css={border ? styles.border : styles.noBorder}>
104
- {child}
105
- </td>,
106
- );
107
- }
108
- } else {
109
- // eslint-disable-next-line no-console
110
- console.error('Invalid Row child:', child);
111
- throw new Error('invalid Row child');
112
- }
113
- }
114
- return { cells };
115
- }
116
-
117
- function Row({ children, style = {}, border = false }: TableProps) {
118
- const { cells } = useRowChildren(children);
119
- return (
120
- <tr style={{ border: border ? '1px solid black' : '', ...style }}>
121
- {cells}
122
- </tr>
123
- );
124
- }
125
- Table.Row = Row;
126
- Table.Header = ({ children, style, border = false }: TableProps) => {
127
- return (
128
- <thead>
129
- <Table.Row border={border} style={style}>
130
- {children}
131
- </Table.Row>
132
- </thead>
133
- );
134
- };
74
+ Table.Row = TableRow;
75
+ Table.Header = TableHeader;
@@ -0,0 +1,12 @@
1
+ import type { TableProps } from './Table';
2
+ import { TableRow } from './TableRow';
3
+
4
+ export const TableHeader = ({ children, hasBorder, style }: TableProps) => {
5
+ return (
6
+ <thead>
7
+ <TableRow hasBorder={hasBorder} style={style}>
8
+ {children}
9
+ </TableRow>
10
+ </thead>
11
+ );
12
+ };
@@ -0,0 +1,89 @@
1
+ /** @jsxImportSource @emotion/react */
2
+ import { css } from '@emotion/react';
3
+ import { Children, isValidElement, ReactElement, ReactNode } from 'react';
4
+
5
+ import {
6
+ Boolean,
7
+ Color,
8
+ Component,
9
+ Header,
10
+ Number,
11
+ Object,
12
+ Text,
13
+ } from '../value-renderers';
14
+
15
+ import type { TableProps } from './Table';
16
+ import { useTableContext } from './tableContext';
17
+
18
+ const styles = {
19
+ hasBorder: css({
20
+ border: '0.5px solid rgb(0, 0, 0)',
21
+ padding: '5px',
22
+ position: 'relative',
23
+ }),
24
+ noBorder: css({
25
+ padding: '5px',
26
+ position: 'relative',
27
+ }),
28
+ };
29
+
30
+ export const TableRow = ({
31
+ children,
32
+ style = {},
33
+ hasBorder = false,
34
+ }: TableProps) => {
35
+ const { cells } = useRowChildren(children);
36
+ return (
37
+ <tr style={{ border: hasBorder ? '1px solid black' : '', ...style }}>
38
+ {cells}
39
+ </tr>
40
+ );
41
+ };
42
+
43
+ function useRowChildren(children: ReactNode) {
44
+ const cells: ReactElement[] = [];
45
+ const { hasBorder, color } = useTableContext();
46
+ for (const child of Children.toArray(children)) {
47
+ if (
48
+ typeof child === 'object' &&
49
+ isValidElement(child) &&
50
+ (child.type === Color ||
51
+ child.type === Boolean ||
52
+ child.type === Text ||
53
+ child.type === Number ||
54
+ child.type === Object ||
55
+ child.type === Header ||
56
+ child.type === Component)
57
+ ) {
58
+ if (child.type === Header) {
59
+ cells.push(
60
+ <th
61
+ key={child.key}
62
+ style={{ color }}
63
+ css={hasBorder ? styles.hasBorder : styles.noBorder}
64
+ >
65
+ {child}
66
+ </th>,
67
+ );
68
+ } else {
69
+ cells.push(
70
+ <td
71
+ key={child.key}
72
+ style={{
73
+ color,
74
+ position: 'relative',
75
+ }}
76
+ css={hasBorder ? styles.hasBorder : styles.noBorder}
77
+ >
78
+ {child}
79
+ </td>,
80
+ );
81
+ }
82
+ } else {
83
+ // eslint-disable-next-line no-console
84
+ console.error('Invalid Row child:', child);
85
+ throw new Error('invalid Row child');
86
+ }
87
+ }
88
+ return { cells };
89
+ }
@@ -0,0 +1,7 @@
1
+ import { createContext, useContext } from 'react';
2
+
3
+ export const TableContext = createContext({ hasBorder: true, color: '' });
4
+ export function useTableContext() {
5
+ const context = useContext(TableContext);
6
+ return context;
7
+ }
@@ -1,7 +1,7 @@
1
1
  /** @jsxImportSource @emotion/react */
2
2
  import { css } from '@emotion/react';
3
3
 
4
- import { Button } from '../button/Button';
4
+ import { Toolbar } from './Toolbar';
5
5
 
6
6
  interface PanelPreferencesToolbarProps {
7
7
  onClose?: () => void;
@@ -26,8 +26,22 @@ export function PanelPreferencesToolbar(props: PanelPreferencesToolbarProps) {
26
26
  const { onClose, onSave } = props;
27
27
  return (
28
28
  <div css={styles.toolbar}>
29
- <Button minimal onClick={onClose} intent="danger" icon="cross" />
30
- <Button minimal onClick={onSave} intent="success" icon="tick" />
29
+ <Toolbar>
30
+ <Toolbar.Item
31
+ title="close"
32
+ onClick={onClose}
33
+ intent="danger"
34
+ icon="cross"
35
+ noTooltip
36
+ />
37
+ <Toolbar.Item
38
+ title="save"
39
+ onClick={onSave}
40
+ intent="success"
41
+ icon="tick"
42
+ noTooltip
43
+ />
44
+ </Toolbar>
31
45
  </div>
32
46
  );
33
47
  }
@@ -17,11 +17,13 @@ import {
17
17
  useToolbarContext,
18
18
  } from './toolbarContext';
19
19
 
20
- export interface ToolbarProps {
21
- vertical?: boolean;
22
- large?: boolean;
20
+ interface ToolbarBaseProps {
23
21
  intent?: Intent;
24
22
  disabled?: boolean;
23
+ }
24
+ export interface ToolbarProps extends ToolbarBaseProps {
25
+ vertical?: boolean;
26
+ large?: boolean;
25
27
  children?:
26
28
  | Array<ReactElement<ToolbarItemProps>>
27
29
  | ReactElement<ToolbarItemProps>
@@ -30,14 +32,14 @@ export interface ToolbarProps {
30
32
  | null;
31
33
  }
32
34
 
33
- export interface ToolbarItemProps {
35
+ export interface ToolbarItemProps extends ToolbarBaseProps {
34
36
  id?: string;
35
37
  title: string;
36
38
  icon: ButtonProps['icon'];
37
39
  active?: boolean;
38
40
  onClick?: (item: ToolbarItemProps) => void;
39
41
  className?: string;
40
- intent?: Intent;
42
+ noTooltip?: boolean;
41
43
  }
42
44
 
43
45
  const border = '1px solid rgb(247, 247, 247)';
@@ -107,16 +109,19 @@ Toolbar.Item = function ToolbarItem(props: ToolbarItemProps) {
107
109
  title,
108
110
  id,
109
111
  intent: itemIntent,
112
+ disabled: itemDisabled,
113
+ noTooltip = false,
110
114
  ...other
111
115
  } = props;
112
116
 
113
117
  const {
114
118
  intent: toolbarIntent,
119
+ disabled: toolbarDisabled,
115
120
  large,
116
121
  vertical,
117
- disabled,
118
122
  } = useToolbarContext();
119
- const intent = itemIntent || toolbarIntent;
123
+ const intent = itemIntent ?? toolbarIntent;
124
+ const disabled = itemDisabled ?? toolbarDisabled;
120
125
  return (
121
126
  <Button
122
127
  minimal
@@ -139,12 +144,16 @@ Toolbar.Item = function ToolbarItem(props: ToolbarItemProps) {
139
144
  onClick={() => {
140
145
  onClick?.(props);
141
146
  }}
142
- tooltipProps={{
143
- content: title,
144
- placement: vertical ? 'right' : 'bottom',
145
- intent,
146
- compact: !large,
147
- }}
147
+ tooltipProps={
148
+ noTooltip
149
+ ? undefined
150
+ : {
151
+ content: title,
152
+ placement: vertical ? 'right' : 'bottom',
153
+ intent,
154
+ compact: !large,
155
+ }
156
+ }
148
157
  {...other}
149
158
  />
150
159
  );
@@ -1,17 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- interface ConfirmModalProps {
3
- children: ReactNode;
4
- isOpen: boolean;
5
- requestCloseOnEsc?: boolean;
6
- requestCloseOnBackdrop?: boolean;
7
- onConfirm: () => void;
8
- onCancel?: () => void;
9
- onRequestClose: () => void;
10
- saveText?: string;
11
- cancelText?: string;
12
- headerColor: string;
13
- maxWidth?: number;
14
- }
15
- export declare function ConfirmModal(props: ConfirmModalProps): import("react/jsx-runtime").JSX.Element | null;
16
- export {};
17
- //# sourceMappingURL=ConfirmModal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConfirmModal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/ConfirmModal.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASvC,UAAU,iBAAiB;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA8CD,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,kDAiEpD"}
@@ -1,71 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ConfirmModal = void 0;
7
- const jsx_runtime_1 = require("react/jsx-runtime");
8
- const styled_1 = __importDefault(require("@emotion/styled"));
9
- const react_1 = require("react");
10
- const __1 = require("..");
11
- const Portal_1 = require("../root-layout/Portal");
12
- const RootLayoutContext_1 = require("../root-layout/RootLayoutContext");
13
- const useDialog_1 = require("./useDialog");
14
- const ConfirmModalDialog = styled_1.default.dialog `
15
- background-color: transparent;
16
- :focus {
17
- outline: none;
18
- }
19
- ::backdrop {
20
- background-color: rgba(113, 113, 122, 0.75);
21
- }
22
- `;
23
- const ConfirmModalContents = styled_1.default.div `
24
- position: relative;
25
- display: flex;
26
- flex-direction: column;
27
- background-color: white;
28
- width: 100%;
29
- border-radius: 0.5rem;
30
- box-shadow:
31
- 0 0 0 0,
32
- 0 0px 16px rgba(0, 0, 0, 0.3);
33
- border-top: 10px solid ${({ headerColor }) => headerColor};
34
- `;
35
- const ConfirmModalChildrenRoot = styled_1.default.div `
36
- color: ${({ headerColor }) => headerColor};
37
- display: flex;
38
- flex: 1 1 0%;
39
- font-weight: bold;
40
- padding: 20px;
41
- font-size: 14px;
42
- `;
43
- const ConfirmModalFooter = styled_1.default.div `
44
- border-top: 2px solid rgb(247, 247, 247);
45
- padding: 10px 20px 10px 20px;
46
- display: flex;
47
- flex-direction: row-reverse;
48
- gap: 10px;
49
- `;
50
- function ConfirmModal(props) {
51
- const { isOpen, saveText = 'Save', cancelText = 'Cancel', headerColor, maxWidth, onRequestClose, onCancel = onRequestClose, onConfirm, requestCloseOnBackdrop = true, requestCloseOnEsc = true, children, } = props;
52
- const dialogRef = (0, react_1.useRef)(null);
53
- const { dialogProps, isModalShown } = (0, useDialog_1.useDialog)({
54
- dialogRef,
55
- isOpen,
56
- requestCloseOnEsc,
57
- requestCloseOnBackdrop,
58
- onRequestClose,
59
- });
60
- const [portalDomNode, setPortalDomNode] = (0, react_1.useState)(null);
61
- const dialogCallbackRef = (0, react_1.useCallback)((node) => {
62
- setPortalDomNode(node);
63
- }, []);
64
- (0, react_1.useImperativeHandle)(dialogCallbackRef, () => dialogRef.current);
65
- if (!isOpen) {
66
- return null;
67
- }
68
- return ((0, jsx_runtime_1.jsx)(Portal_1.Portal, { children: (0, jsx_runtime_1.jsx)(ConfirmModalDialog, { ...dialogProps, ref: dialogRef, children: isModalShown && ((0, jsx_runtime_1.jsx)(RootLayoutContext_1.RootLayoutProvider, { innerRef: portalDomNode, children: (0, jsx_runtime_1.jsxs)(ConfirmModalContents, { headerColor: headerColor, style: { maxWidth }, children: [(0, jsx_runtime_1.jsx)(ConfirmModalChildrenRoot, { headerColor: headerColor, children: children }), (0, jsx_runtime_1.jsxs)(ConfirmModalFooter, { children: [(0, jsx_runtime_1.jsx)(__1.Button, { intent: "primary", onClick: onConfirm, children: saveText }), (0, jsx_runtime_1.jsx)(__1.Button, { intent: "danger", onClick: onCancel, children: cancelText })] })] }) })) }) }));
69
- }
70
- exports.ConfirmModal = ConfirmModal;
71
- //# sourceMappingURL=ConfirmModal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConfirmModal.js","sourceRoot":"","sources":["../../../src/components/modal/ConfirmModal.tsx"],"names":[],"mappings":";;;;;;;AAAA,6DAAqC;AAErC,iCAA2E;AAE3E,0BAA4B;AAC5B,kDAA+C;AAC/C,wEAAsE;AAEtE,2CAAwC;AAgBxC,MAAM,kBAAkB,GAAG,gBAAM,CAAC,MAAM,CAAA;;;;;;;;CAQvC,CAAC;AAEF,MAAM,oBAAoB,GAAG,gBAAM,CAAC,GAAG,CAErC;;;;;;;;;;2BAUyB,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW;CAC1D,CAAC;AAEF,MAAM,wBAAwB,GAAG,gBAAM,CAAC,GAAG,CAAyB;WACzD,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW;;;;;;CAM1C,CAAC;AAEF,MAAM,kBAAkB,GAAG,gBAAM,CAAC,GAAG,CAAA;;;;;;CAMpC,CAAC;AAIF,SAAgB,YAAY,CAAC,KAAwB;IACnD,MAAM,EACJ,MAAM,EACN,QAAQ,GAAG,MAAM,EACjB,UAAU,GAAG,QAAQ,EACrB,WAAW,EACX,QAAQ,EACR,cAAc,EACd,QAAQ,GAAG,cAAc,EACzB,SAAS,EACT,sBAAsB,GAAG,IAAI,EAC7B,iBAAiB,GAAG,IAAI,EACxB,QAAQ,GACT,GAAG,KAAK,CAAC;IAEV,MAAM,SAAS,GAAG,IAAA,cAAM,EAAoB,IAAI,CAAC,CAAC;IAClD,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,IAAA,qBAAS,EAAC;QAC9C,SAAS;QACT,MAAM;QACN,iBAAiB;QACjB,sBAAsB;QACtB,cAAc;KACf,CAAC,CAAC;IACH,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GACrC,IAAA,gBAAQ,EAAyB,IAAI,CAAC,CAAC;IACzC,MAAM,iBAAiB,GAAG,IAAA,mBAAW,EAAC,CAAC,IAA4B,EAAE,EAAE;QACrE,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAA,2BAAmB,EACjB,iBAAiB,EACjB,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CACxB,CAAC;IAEF,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,uBAAC,eAAM,cACL,uBAAC,kBAAkB,OAAK,WAAW,EAAE,GAAG,EAAE,SAAS,YAChD,YAAY,IAAI,CACf,uBAAC,sCAAkB,IAAC,QAAQ,EAAE,aAAa,YACzC,wBAAC,oBAAoB,IACnB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,EAAE,QAAQ,EAAE,aAEnB,uBAAC,wBAAwB,IAAC,WAAW,EAAE,WAAW,YAC/C,QAAQ,GACgB,EAE3B,wBAAC,kBAAkB,eACjB,uBAAC,UAAM,IAAC,MAAM,EAAC,SAAS,EAAC,OAAO,EAAE,SAAS,YACxC,QAAQ,GACF,EACT,uBAAC,UAAM,IAAC,MAAM,EAAC,QAAQ,EAAC,OAAO,EAAE,QAAQ,YACtC,UAAU,GACJ,IACU,IACA,GACJ,CACtB,GACkB,GACd,CACV,CAAC;AACJ,CAAC;AAjED,oCAiEC"}
@@ -1,25 +0,0 @@
1
- import type { ReactElement, ReactNode } from 'react';
2
- export interface ModalProps {
3
- children: ReactElement | ReactElement[];
4
- isOpen: boolean;
5
- requestCloseOnEsc?: boolean;
6
- hasCloseButton?: boolean;
7
- requestCloseOnBackdrop?: boolean;
8
- onRequestClose: () => void;
9
- maxWidth?: number;
10
- width?: number;
11
- height?: number;
12
- }
13
- export declare function Modal(props: ModalProps): import("react/jsx-runtime").JSX.Element | null;
14
- export declare namespace Modal {
15
- var Header: (props: {
16
- children: ReactNode;
17
- }) => import("react/jsx-runtime").JSX.Element;
18
- var Body: (props: {
19
- children: ReactNode;
20
- }) => import("react/jsx-runtime").JSX.Element;
21
- var Footer: (props: {
22
- children: ReactNode;
23
- }) => import("react/jsx-runtime").JSX.Element;
24
- }
25
- //# sourceMappingURL=Modal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/Modal.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASrD,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA8CD,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,kDAgEtC;yBAhEe,KAAK"}