react-science 19.2.0 → 19.3.1

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 (157) hide show
  1. package/lib/components/accordion/accordion.js +1 -1
  2. package/lib/components/color-picker/react-color/ColorPicker.d.ts.map +1 -1
  3. package/lib/components/color-picker/react-color/ColorPicker.js +7 -5
  4. package/lib/components/color-picker/react-color/ColorPicker.js.map +1 -1
  5. package/lib/components/doi/doi.js +2 -2
  6. package/lib/components/doi/doi.js.map +1 -1
  7. package/lib/components/doi/doi_logo.d.ts +6 -0
  8. package/lib/components/doi/doi_logo.d.ts.map +1 -0
  9. package/lib/components/doi/doi_logo.js +16 -0
  10. package/lib/components/doi/doi_logo.js.map +1 -0
  11. package/lib/components/form/components/input/checkbox.d.ts +3 -1
  12. package/lib/components/form/components/input/checkbox.d.ts.map +1 -1
  13. package/lib/components/form/components/input/checkbox.js +10 -3
  14. package/lib/components/form/components/input/checkbox.js.map +1 -1
  15. package/lib/components/form/components/input/input.d.ts +3 -5
  16. package/lib/components/form/components/input/input.d.ts.map +1 -1
  17. package/lib/components/form/components/input/input.js +4 -3
  18. package/lib/components/form/components/input/input.js.map +1 -1
  19. package/lib/components/form/components/input/numeric_input.d.ts +5 -4
  20. package/lib/components/form/components/input/numeric_input.d.ts.map +1 -1
  21. package/lib/components/form/components/input/numeric_input.js +4 -5
  22. package/lib/components/form/components/input/numeric_input.js.map +1 -1
  23. package/lib/components/form/components/input/select.d.ts +2 -3
  24. package/lib/components/form/components/input/select.d.ts.map +1 -1
  25. package/lib/components/form/components/input/select.js +4 -8
  26. package/lib/components/form/components/input/select.js.map +1 -1
  27. package/lib/components/form/components/input/switch.d.ts +4 -0
  28. package/lib/components/form/components/input/switch.d.ts.map +1 -1
  29. package/lib/components/form/components/input/switch.js +11 -3
  30. package/lib/components/form/components/input/switch.js.map +1 -1
  31. package/lib/components/form/components/input_groups/form.d.ts +8 -0
  32. package/lib/components/form/components/input_groups/form.d.ts.map +1 -0
  33. package/lib/components/form/components/input_groups/form.js +11 -0
  34. package/lib/components/form/components/input_groups/form.js.map +1 -0
  35. package/lib/components/form/components/input_groups/form_context.d.ts +8 -0
  36. package/lib/components/form/components/input_groups/form_context.d.ts.map +1 -0
  37. package/lib/components/form/components/input_groups/form_context.js +8 -0
  38. package/lib/components/form/components/input_groups/form_context.js.map +1 -0
  39. package/lib/components/form/components/input_groups/form_group.d.ts +25 -0
  40. package/lib/components/form/components/input_groups/form_group.d.ts.map +1 -0
  41. package/lib/components/form/components/input_groups/form_group.js +47 -0
  42. package/lib/components/form/components/input_groups/form_group.js.map +1 -0
  43. package/lib/components/form/components/input_groups/select.d.ts +3 -6
  44. package/lib/components/form/components/input_groups/select.d.ts.map +1 -1
  45. package/lib/components/form/components/input_groups/select.js +3 -6
  46. package/lib/components/form/components/input_groups/select.js.map +1 -1
  47. package/lib/components/form/components/layout/Section.d.ts +9 -0
  48. package/lib/components/form/components/layout/Section.d.ts.map +1 -0
  49. package/lib/components/form/components/layout/Section.js +38 -0
  50. package/lib/components/form/components/layout/Section.js.map +1 -0
  51. package/lib/components/form/context/use_ts_form.d.ts +4 -0
  52. package/lib/components/form/context/use_ts_form.d.ts.map +1 -1
  53. package/lib/components/form/context/use_ts_form.js +2 -0
  54. package/lib/components/form/context/use_ts_form.js.map +1 -1
  55. package/lib/components/index.d.ts +1 -0
  56. package/lib/components/index.d.ts.map +1 -1
  57. package/lib/components/index.js +1 -0
  58. package/lib/components/index.js.map +1 -1
  59. package/lib/components/info-panel/InfoPanel.d.ts.map +1 -1
  60. package/lib/components/info-panel/InfoPanel.js +3 -3
  61. package/lib/components/info-panel/InfoPanel.js.map +1 -1
  62. package/lib/components/input/radio-button-group/RadioButton.js +4 -4
  63. package/lib/components/input/radio-button-group/RadioButtonGroup.js +2 -2
  64. package/lib/components/root-layout/css-reset/customPreflight.js +1 -1
  65. package/lib/components/split_pane/use_split_pane_size.d.ts.map +1 -1
  66. package/lib/components/split_pane/use_split_pane_size.js +47 -46
  67. package/lib/components/split_pane/use_split_pane_size.js.map +1 -1
  68. package/lib/components/svg/index.d.ts +5 -0
  69. package/lib/components/svg/index.d.ts.map +1 -0
  70. package/lib/components/svg/index.js +5 -0
  71. package/lib/components/svg/index.js.map +1 -0
  72. package/lib/components/svg/styled/svg_styled_line.d.ts +6 -0
  73. package/lib/components/svg/styled/svg_styled_line.d.ts.map +1 -0
  74. package/lib/components/svg/styled/svg_styled_line.js +7 -0
  75. package/lib/components/svg/styled/svg_styled_line.js.map +1 -0
  76. package/lib/components/svg/styled/svg_styled_path.d.ts +6 -0
  77. package/lib/components/svg/styled/svg_styled_path.d.ts.map +1 -0
  78. package/lib/components/svg/styled/svg_styled_path.js +7 -0
  79. package/lib/components/svg/styled/svg_styled_path.js.map +1 -0
  80. package/lib/components/svg/styled/svg_styled_text.d.ts +6 -0
  81. package/lib/components/svg/styled/svg_styled_text.d.ts.map +1 -0
  82. package/lib/components/svg/styled/svg_styled_text.js +6 -0
  83. package/lib/components/svg/styled/svg_styled_text.js.map +1 -0
  84. package/lib/components/svg/styled/svg_styled_types.d.ts +56 -0
  85. package/lib/components/svg/styled/svg_styled_types.d.ts.map +1 -0
  86. package/lib/components/svg/styled/svg_styled_types.js +2 -0
  87. package/lib/components/svg/styled/svg_styled_types.js.map +1 -0
  88. package/lib/components/svg/styled/svg_styled_utils.d.ts +3 -0
  89. package/lib/components/svg/styled/svg_styled_utils.d.ts.map +1 -0
  90. package/lib/components/svg/styled/svg_styled_utils.js +10 -0
  91. package/lib/components/svg/styled/svg_styled_utils.js.map +1 -0
  92. package/lib/components/table/reorder_rows/draggable_row_tr.js +1 -1
  93. package/lib/components/table/reorder_rows/draggable_row_tr.js.map +1 -1
  94. package/lib/components/table/reorder_rows/item_order_provider.d.ts.map +1 -1
  95. package/lib/components/table/reorder_rows/item_order_provider.js +1 -1
  96. package/lib/components/table/reorder_rows/item_order_provider.js.map +1 -1
  97. package/lib/components/table/reorder_rows/use_drop_monitor.d.ts.map +1 -1
  98. package/lib/components/table/reorder_rows/use_drop_monitor.js +34 -33
  99. package/lib/components/table/reorder_rows/use_drop_monitor.js.map +1 -1
  100. package/lib/components/toolbar/PanelPreferencesToolbar.js +1 -1
  101. package/lib/components/toolbar/Toolbar.d.ts.map +1 -1
  102. package/lib/components/toolbar/Toolbar.js +5 -4
  103. package/lib/components/toolbar/Toolbar.js.map +1 -1
  104. package/lib/components/toolbar/TooltipHelpContent.js +3 -3
  105. package/package.json +37 -35
  106. package/src/components/accordion/accordion.tsx +1 -1
  107. package/src/components/color-picker/react-color/ColorPicker.tsx +8 -6
  108. package/src/components/doi/doi.tsx +2 -2
  109. package/src/components/doi/{Logo.tsx → doi_logo.tsx} +9 -5
  110. package/src/components/form/components/input/checkbox.tsx +23 -6
  111. package/src/components/form/components/input/input.tsx +35 -15
  112. package/src/components/form/components/input/numeric_input.tsx +30 -15
  113. package/src/components/form/components/input/select.tsx +24 -17
  114. package/src/components/form/components/input/switch.tsx +27 -5
  115. package/src/components/form/components/input_groups/form.tsx +24 -0
  116. package/src/components/form/components/input_groups/form_context.ts +11 -0
  117. package/src/components/form/components/input_groups/form_group.tsx +129 -0
  118. package/src/components/form/components/input_groups/select.tsx +25 -46
  119. package/src/components/form/components/layout/Section.tsx +57 -0
  120. package/src/components/form/context/use_ts_form.ts +2 -0
  121. package/src/components/index.ts +1 -0
  122. package/src/components/info-panel/InfoPanel.tsx +4 -3
  123. package/src/components/input/radio-button-group/RadioButton.tsx +4 -4
  124. package/src/components/input/radio-button-group/RadioButtonGroup.tsx +2 -2
  125. package/src/components/root-layout/css-reset/customPreflight.ts +1 -1
  126. package/src/components/split_pane/use_split_pane_size.tsx +54 -53
  127. package/src/components/svg/index.ts +4 -0
  128. package/src/components/svg/styled/svg_styled_line.tsx +27 -0
  129. package/src/components/svg/styled/svg_styled_path.tsx +29 -0
  130. package/src/components/svg/styled/svg_styled_text.tsx +12 -0
  131. package/src/components/svg/styled/svg_styled_types.ts +67 -0
  132. package/src/components/svg/styled/svg_styled_utils.ts +15 -0
  133. package/src/components/table/reorder_rows/draggable_row_tr.tsx +4 -4
  134. package/src/components/table/reorder_rows/item_order_provider.tsx +1 -2
  135. package/src/components/table/reorder_rows/use_drop_monitor.ts +45 -42
  136. package/src/components/toolbar/PanelPreferencesToolbar.tsx +1 -1
  137. package/src/components/toolbar/Toolbar.tsx +7 -4
  138. package/src/components/toolbar/TooltipHelpContent.tsx +3 -3
  139. package/lib/components/doi/Logo.d.ts +0 -6
  140. package/lib/components/doi/Logo.d.ts.map +0 -1
  141. package/lib/components/doi/Logo.js +0 -16
  142. package/lib/components/doi/Logo.js.map +0 -1
  143. package/lib/components/form/components/hooks/use_input_id.d.ts +0 -8
  144. package/lib/components/form/components/hooks/use_input_id.d.ts.map +0 -1
  145. package/lib/components/form/components/hooks/use_input_id.js +0 -15
  146. package/lib/components/form/components/hooks/use_input_id.js.map +0 -1
  147. package/lib/components/form/components/input_groups/input.d.ts +0 -20
  148. package/lib/components/form/components/input_groups/input.d.ts.map +0 -1
  149. package/lib/components/form/components/input_groups/input.js +0 -9
  150. package/lib/components/form/components/input_groups/input.js.map +0 -1
  151. package/lib/components/pdnd.cjs +0 -29
  152. package/lib/components/pdnd.cjs.map +0 -1
  153. package/lib/components/pdnd.d.cts +0 -10
  154. package/lib/components/pdnd.d.cts.map +0 -1
  155. package/src/components/form/components/hooks/use_input_id.ts +0 -19
  156. package/src/components/form/components/input_groups/input.tsx +0 -63
  157. package/src/components/pdnd.cts +0 -20
@@ -1,17 +1,25 @@
1
+ import { InputGroup } from '@blueprintjs/core';
1
2
  import type { ChangeEvent } from 'react';
2
3
 
3
4
  import { useFieldContext } from '../../context/use_ts_form.js';
4
- import { Input as FormGroupInput } from '../input_groups/input.js';
5
+ import type { FormGroupInputProps } from '../input_groups/form_group.js';
6
+ import { FormGroup } from '../input_groups/form_group.js';
5
7
 
6
- interface InputProps {
7
- label?: string;
8
- inline?: boolean;
9
- required?: boolean;
10
- placeholder?: string;
8
+ interface InputProps extends FormGroupInputProps {
9
+ type?: string;
11
10
  }
12
11
 
13
12
  export function Input(props: InputProps) {
14
- const { label, required, inline, placeholder } = props;
13
+ const {
14
+ label,
15
+ required,
16
+ placeholder,
17
+ type = 'text',
18
+ helpText,
19
+ layout,
20
+ fullWidth,
21
+ } = props;
22
+
15
23
  const field = useFieldContext<string>();
16
24
  const error = field
17
25
  .getMeta()
@@ -23,15 +31,27 @@ export function Input(props: InputProps) {
23
31
  }
24
32
 
25
33
  return (
26
- <FormGroupInput
34
+ <FormGroup
35
+ name={field.name}
36
+ label={label}
37
+ intent={error ? 'danger' : 'none'}
27
38
  required={required}
28
39
  error={error}
29
- formGroupProps={{ label, inline }}
30
- value={field.state.value}
31
- onChange={onChange}
32
- name={field.name}
33
- placeholder={placeholder}
34
- onBlur={field.handleBlur}
35
- />
40
+ helpText={helpText}
41
+ layout={layout}
42
+ fullWidth={fullWidth}
43
+ >
44
+ <InputGroup
45
+ id={field.name}
46
+ name={field.name}
47
+ required={required}
48
+ type={type}
49
+ onChange={onChange}
50
+ onBlur={field.handleBlur}
51
+ intent={error ? 'danger' : 'none'}
52
+ value={field.state.value}
53
+ placeholder={placeholder}
54
+ />
55
+ </FormGroup>
36
56
  );
37
57
  }
@@ -1,20 +1,30 @@
1
- import type { NumericInputProps as BPNumericInputProps } from '@blueprintjs/core';
2
- import { FormGroup, NumericInput as BPNumericInput } from '@blueprintjs/core';
1
+ import { NumericInput as BPNumericInput } from '@blueprintjs/core';
3
2
 
4
3
  import { useFieldContext } from '../../context/use_ts_form.js';
5
- import { useFieldId } from '../../utils/use_field_id.js';
6
4
  import { getIntent } from '../../utils/use_intent.js';
5
+ import type { FormGroupInputProps } from '../input_groups/form_group.js';
6
+ import { FormGroup } from '../input_groups/form_group.js';
7
7
 
8
- interface NumericInputProps
9
- extends Omit<BPNumericInputProps, 'defaultValue' | 'name'> {
10
- label?: string;
11
- required?: boolean;
8
+ interface NumericInputProps extends FormGroupInputProps {
9
+ step?: number;
10
+ min?: number;
11
+ max?: number;
12
12
  }
13
13
 
14
14
  export function NumericInput(props: NumericInputProps) {
15
- const { label, required, ...rest } = props;
15
+ const {
16
+ label,
17
+ required,
18
+ helpText,
19
+ placeholder,
20
+ step,
21
+ min,
22
+ max,
23
+ layout,
24
+ fullWidth,
25
+ } = props;
26
+
16
27
  const field = useFieldContext<string>();
17
- const id = useFieldId(field.name);
18
28
  const error = field
19
29
  .getMeta()
20
30
  .errors.map((e) => e.message)
@@ -28,21 +38,26 @@ export function NumericInput(props: NumericInputProps) {
28
38
 
29
39
  return (
30
40
  <FormGroup
31
- helperText={error}
41
+ name={field.name}
32
42
  label={label}
33
- labelFor={id}
34
43
  intent={intent}
35
- labelInfo={label && required && <span style={{ color: 'red' }}>*</span>}
44
+ required={required}
45
+ helpText={helpText}
46
+ layout={layout}
47
+ error={error}
48
+ fullWidth={fullWidth}
36
49
  >
37
50
  <BPNumericInput
38
- {...rest}
51
+ id={field.name}
39
52
  name={field.name}
53
+ stepSize={step}
54
+ min={min}
55
+ max={max}
40
56
  value={field.state.value ?? ''}
41
57
  onValueChange={onChange}
42
58
  intent={intent}
59
+ placeholder={placeholder}
43
60
  required={required}
44
- id={id}
45
- onBlur={field.handleBlur}
46
61
  />
47
62
  </FormGroup>
48
63
  );
@@ -1,6 +1,8 @@
1
1
  import { useFieldContext } from '../../context/use_ts_form.js';
2
2
  import { getIntent } from '../../utils/use_intent.js';
3
- import { Select as FormGroupSelect } from '../input_groups/select.js';
3
+ import type { FormGroupInputProps } from '../input_groups/form_group.js';
4
+ import { FormGroup } from '../input_groups/form_group.js';
5
+ import { Select as SelectInput } from '../input_groups/select.js';
4
6
  import type { SelectId } from '../util/select.js';
5
7
 
6
8
  interface SelectOptionType {
@@ -8,14 +10,12 @@ interface SelectOptionType {
8
10
  value: string;
9
11
  }
10
12
 
11
- interface SelectProps {
12
- label?: string;
13
+ interface SelectProps extends Omit<FormGroupInputProps, 'placeholder'> {
13
14
  items: SelectOptionType[];
14
- required?: boolean;
15
15
  }
16
16
 
17
17
  export function Select(props: SelectProps) {
18
- const { label, items, required } = props;
18
+ const { label, items, required, helpText, layout, fullWidth } = props;
19
19
 
20
20
  const field = useFieldContext<SelectId>();
21
21
  const error = field
@@ -31,17 +31,24 @@ export function Select(props: SelectProps) {
31
31
  }
32
32
 
33
33
  return (
34
- <FormGroupSelect
35
- formGroupProps={{
36
- required,
37
- label,
38
- intent,
39
- helperText: error ?? undefined,
40
- }}
41
- items={items}
42
- onChange={onItemSelect}
43
- selected={field.state.value}
44
- onBlur={field.handleBlur}
45
- />
34
+ <FormGroup
35
+ name={field.name}
36
+ required={required}
37
+ label={label}
38
+ intent={intent}
39
+ helpText={helpText}
40
+ error={error}
41
+ layout={layout}
42
+ fullWidth={fullWidth}
43
+ >
44
+ <SelectInput
45
+ onBlur={field.handleBlur}
46
+ items={items}
47
+ selected={field.state.value}
48
+ onChange={onItemSelect}
49
+ intent={intent}
50
+ name={field.name}
51
+ />
52
+ </FormGroup>
46
53
  );
47
54
  }
@@ -1,14 +1,27 @@
1
- import { FormGroup, Switch as BPSwitch } from '@blueprintjs/core';
1
+ import { Switch as BPSwitch } from '@blueprintjs/core';
2
+ import styled from '@emotion/styled';
2
3
  import type { ChangeEvent } from 'react';
3
4
 
4
5
  import { useFieldContext } from '../../context/use_ts_form.js';
6
+ import type { Layout } from '../input_groups/form_context.js';
7
+ import { FormGroup } from '../input_groups/form_group.js';
5
8
 
6
9
  interface SwitchProps {
7
10
  label?: string;
11
+ helpText?: string;
12
+ fullWidth?: boolean;
13
+ layout?: Layout;
8
14
  }
9
15
 
16
+ const StyledSwitch = styled(BPSwitch)`
17
+ margin: 0 !important;
18
+ height: 30px;
19
+ display: flex;
20
+ align-items: center;
21
+ `;
22
+
10
23
  export function Switch(props: SwitchProps) {
11
- const { label } = props;
24
+ const { label, layout, helpText, fullWidth } = props;
12
25
 
13
26
  const field = useFieldContext<boolean>();
14
27
  const error = field
@@ -21,12 +34,21 @@ export function Switch(props: SwitchProps) {
21
34
  }
22
35
 
23
36
  return (
24
- <FormGroup helperText={error ?? undefined} intent="danger">
25
- <BPSwitch
37
+ <FormGroup
38
+ name={field.name}
39
+ error={error}
40
+ intent={error ? 'danger' : undefined}
41
+ label={label}
42
+ layout={layout}
43
+ helpText={helpText}
44
+ fullWidth={fullWidth}
45
+ >
46
+ <StyledSwitch
47
+ name={field.name}
48
+ id={field.name}
26
49
  checked={field.state.value}
27
50
  onChange={onChange}
28
51
  onBlur={field.handleBlur}
29
- labelElement={label}
30
52
  />
31
53
  </FormGroup>
32
54
  );
@@ -0,0 +1,24 @@
1
+ import type { FormHTMLAttributes, ReactNode } from 'react';
2
+ import { useMemo } from 'react';
3
+
4
+ import type { Layout } from './form_context.js';
5
+ import { formContext } from './form_context.js';
6
+
7
+ export interface FormProps extends FormHTMLAttributes<HTMLFormElement> {
8
+ children: ReactNode;
9
+ layout?: Layout;
10
+ }
11
+
12
+ export function Form(props: FormProps) {
13
+ const { children, layout = 'stacked', ...otherProps } = props;
14
+
15
+ const contextValue = useMemo(() => {
16
+ return { layout };
17
+ }, [layout]);
18
+
19
+ return (
20
+ <formContext.Provider value={contextValue}>
21
+ <form {...otherProps}>{children}</form>
22
+ </formContext.Provider>
23
+ );
24
+ }
@@ -0,0 +1,11 @@
1
+ import { createContext, useContext } from 'react';
2
+
3
+ export type Layout = 'inline' | 'stacked';
4
+
5
+ export const formContext = createContext<{ layout: Layout }>({
6
+ layout: 'stacked',
7
+ });
8
+
9
+ export function useFormContext() {
10
+ return useContext(formContext);
11
+ }
@@ -0,0 +1,129 @@
1
+ import type { Intent } from '@blueprintjs/core';
2
+ import { Classes } from '@blueprintjs/core';
3
+ import styled from '@emotion/styled';
4
+ import type { ReactNode } from 'react';
5
+
6
+ import type { Layout } from './form_context.js';
7
+ import { useFormContext } from './form_context.js';
8
+
9
+ const INPUT_HEIGHT = 30;
10
+
11
+ const FormContainer = styled.div<{
12
+ layout?: Layout;
13
+ }>`
14
+ min-height: ${INPUT_HEIGHT}px;
15
+ width: 100%;
16
+ display: grid;
17
+ margin: 0;
18
+ grid-template-columns: ${(props) =>
19
+ props.layout === 'inline' ? '[label] 30% [input] 70%' : '1fr'};
20
+ grid-template-rows: ${(props) =>
21
+ props.layout === 'inline' ? 'auto auto' : 'auto'};
22
+ `;
23
+
24
+ const RequiredSpan = styled.span`
25
+ color: red;
26
+ `;
27
+
28
+ const ContainerElement = styled.div<{
29
+ height?: number | 'auto';
30
+ fullWidth?: boolean;
31
+ layout?: Layout;
32
+ }>`
33
+ display: inline-block;
34
+ grid-column: ${(props) =>
35
+ props.fullWidth
36
+ ? '1 / -1'
37
+ : props.layout === 'inline'
38
+ ? 'input'
39
+ : '1 / -1'};
40
+ height: ${(props) =>
41
+ props.height === 'auto' ? props.height : `${props.height}px`};
42
+ width: fit-content;
43
+ `;
44
+
45
+ const Label = styled.label<{ layout: Layout }>`
46
+ padding-top: calc(${INPUT_HEIGHT}px - 26px);
47
+ grid-column: ${(props) => (props.layout === 'inline' ? 'label' : '1 / -1')};
48
+ height: 30px;
49
+
50
+ @media (width < 48rem) {
51
+ padding: 0;
52
+ }
53
+ `;
54
+
55
+ const ErrorAndHelpText = styled.div`
56
+ display: flex;
57
+ flex-direction: column;
58
+ `;
59
+
60
+ export interface FormGroupInputProps {
61
+ label?: string;
62
+ required?: boolean;
63
+ placeholder?: string;
64
+ helpText?: string;
65
+ layout?: Layout;
66
+ fullWidth?: boolean;
67
+ }
68
+
69
+ interface FormGroupProps {
70
+ label?: string;
71
+ intent?: Intent;
72
+ name: string;
73
+ required?: boolean;
74
+ helpText?: string;
75
+ children?: ReactNode;
76
+ error?: string;
77
+ layout?: Layout;
78
+ fullWidth?: boolean;
79
+ }
80
+
81
+ export function FormGroup(props: FormGroupProps) {
82
+ const {
83
+ label,
84
+ intent = 'none',
85
+ name,
86
+ required,
87
+ children,
88
+ helpText,
89
+ error,
90
+ layout,
91
+ fullWidth = false,
92
+ } = props;
93
+
94
+ const { layout: formLayout } = useFormContext();
95
+
96
+ // If intent is undefined or none intentClass will return undefined
97
+ const intentClass = Classes.intentClass(intent) ?? '';
98
+
99
+ return (
100
+ <FormContainer
101
+ layout={layout || formLayout}
102
+ className={`${Classes.FORM_GROUP} ${intentClass}`}
103
+ >
104
+ {label && (
105
+ <Label
106
+ layout={layout || formLayout}
107
+ className={Classes.LABEL}
108
+ htmlFor={name}
109
+ >
110
+ {label}{' '}
111
+ {required && (
112
+ <RequiredSpan className={Classes.TEXT_MUTED}>*</RequiredSpan>
113
+ )}
114
+ </Label>
115
+ )}
116
+ <ContainerElement fullWidth={fullWidth} layout={layout || formLayout}>
117
+ {children}
118
+
119
+ <ErrorAndHelpText>
120
+ {helpText && (
121
+ <span className={Classes.FORM_HELPER_TEXT}>{helpText}</span>
122
+ )}
123
+
124
+ {error && <span className={Classes.FORM_HELPER_TEXT}>{error}</span>}
125
+ </ErrorAndHelpText>
126
+ </ContainerElement>
127
+ </FormContainer>
128
+ );
129
+ }
@@ -1,12 +1,10 @@
1
- import type { FormGroupProps } from '@blueprintjs/core';
2
- import { FormGroup } from '@blueprintjs/core';
1
+ import type { FormGroup, FormGroupProps } from '@blueprintjs/core';
3
2
  import type { SelectProps as BPSelectProps } from '@blueprintjs/select';
4
3
  import { Select as BPSelect } from '@blueprintjs/select';
5
4
  import type { ComponentProps, ReactElement, ReactNode } from 'react';
6
5
  import { useCallback, useMemo } from 'react';
7
6
 
8
7
  import { Button } from '../../../button/index.js';
9
- import { useInputId } from '../hooks/use_input_id.js';
10
8
  import type {
11
9
  GetOptionLabel,
12
10
  GetOptionValue,
@@ -94,7 +92,6 @@ export type SelectProps<OptionType, ID extends SelectId> = FieldGroupProps &
94
92
  interface RealSelectProps<OptionType, ID extends SelectId>
95
93
  extends Pick<BPSelectProps<OptionType>, 'filterable' | 'items'> {
96
94
  onBlur: () => void;
97
- id?: string;
98
95
  renderButton?: (
99
96
  state: SelectPropsRenderButtonState<OptionType>,
100
97
  onBlur: () => void,
@@ -104,12 +101,8 @@ interface RealSelectProps<OptionType, ID extends SelectId>
104
101
  onChange?: (selected: ID | undefined, option: OptionType | undefined) => void;
105
102
  getLabel?: GetOptionLabel<OptionType>;
106
103
  getValue?: GetOptionValue<OptionType, ID>;
107
- formGroupProps: Pick<
108
- ComponentProps<typeof FormGroup>,
109
- 'helperText' | 'intent' | 'label' | 'className' | 'inline'
110
- > & {
111
- required?: boolean;
112
- };
104
+ intent?: FormGroupProps['intent'];
105
+ name?: string;
113
106
  }
114
107
 
115
108
  export function Select<
@@ -118,17 +111,17 @@ export function Select<
118
111
  >(props: RealSelectProps<OptionType, ID>): ReactElement {
119
112
  const {
120
113
  renderButton,
121
- id,
122
114
  disabled,
123
115
  selected,
124
116
  getLabel: _getLabel,
125
117
  getValue: _getValue,
126
- formGroupProps: { className, helperText, inline, intent, label, required },
118
+ intent,
127
119
  // Weirdly, setting the filterable prop on BP's Select component activates the filter input
128
120
  filterable = false,
129
121
  items,
130
122
  onChange,
131
123
  onBlur,
124
+ name = null,
132
125
  } = props;
133
126
 
134
127
  const getValue: GetOptionValue<OptionType, ID> = _getValue ?? getSelectValue;
@@ -155,42 +148,28 @@ export function Select<
155
148
  [getValue, onChange],
156
149
  );
157
150
 
158
- const inputId = useInputId(id, null);
159
-
160
151
  return (
161
- <FormGroup
162
- label={label}
163
- labelFor={inputId}
164
- helperText={helperText}
165
- intent={intent}
166
- style={{ margin: 0, position: 'relative' }}
167
- className={className}
168
- inline={inline}
152
+ <BPSelect<OptionType>
153
+ filterable={filterable}
154
+ items={items}
155
+ onItemSelect={onItemSelect}
156
+ itemRenderer={itemRenderer}
169
157
  disabled={disabled}
170
- labelInfo={required && <span style={{ color: 'red' }}>*</span>}
171
158
  >
172
- <BPSelect<OptionType>
173
- filterable={filterable}
174
- items={items}
175
- onItemSelect={onItemSelect}
176
- itemRenderer={itemRenderer}
177
- disabled={disabled}
178
- >
179
- {renderButton ? (
180
- renderButton({ selectedOption, error: undefined }, onBlur)
181
- ) : (
182
- <Button
183
- id={inputId}
184
- text={getLabel(selectedOption) || 'Select ...'}
185
- endIcon="double-caret-vertical"
186
- variant="outlined"
187
- intent={intent}
188
- disabled={disabled}
189
- style={{ minWidth: 180 }}
190
- onBlur={onBlur}
191
- />
192
- )}
193
- </BPSelect>
194
- </FormGroup>
159
+ {renderButton ? (
160
+ renderButton({ selectedOption, error: undefined }, onBlur)
161
+ ) : (
162
+ <Button
163
+ id={name || undefined}
164
+ text={getLabel(selectedOption) || 'Select ...'}
165
+ endIcon="double-caret-vertical"
166
+ variant="outlined"
167
+ intent={intent}
168
+ disabled={disabled}
169
+ style={{ minWidth: 180 }}
170
+ onBlur={onBlur}
171
+ />
172
+ )}
173
+ </BPSelect>
195
174
  );
196
175
  }
@@ -0,0 +1,57 @@
1
+ import styled from '@emotion/styled';
2
+ import type { ReactNode } from 'react';
3
+
4
+ const ContainerInformation = styled.div`
5
+ display: flex;
6
+ flex-direction: column;
7
+
8
+ > h2 {
9
+ font-weight: 600;
10
+ font-size: 1rem;
11
+ line-height: 1.75rem;
12
+ }
13
+
14
+ > h3 {
15
+ color: #737373;
16
+ font-size: 0.875rem;
17
+ line-height: 1.5rem;
18
+ }
19
+ `;
20
+
21
+ const Container = styled.div`
22
+ margin-top: 15px;
23
+ gap: 5px;
24
+ display: flex;
25
+ flex-direction: column;
26
+ `;
27
+
28
+ const ContainerContent = styled.div`
29
+ outline: 1px solid rgb(17 24 39 / 5%);
30
+ box-shadow: 0 1px 2px 0 rgb(0 0 0 / 5%);
31
+ display: flex;
32
+ flex-direction: column;
33
+ gap: 2px;
34
+ border-radius: 0.75rem;
35
+ padding: 7px 10px 2px;
36
+ `;
37
+
38
+ interface SectionProps {
39
+ title: string;
40
+ description?: string;
41
+ children: ReactNode;
42
+ }
43
+
44
+ export function Section(props: SectionProps) {
45
+ const { title, description, children } = props;
46
+
47
+ return (
48
+ <Container>
49
+ <ContainerInformation>
50
+ <h2>{title}</h2>
51
+ <h3>{description}</h3>
52
+ </ContainerInformation>
53
+
54
+ <ContainerContent>{children}</ContainerContent>
55
+ </Container>
56
+ );
57
+ }
@@ -7,6 +7,7 @@ import { ResetButton } from '../components/input/reset_button.js';
7
7
  import { Select } from '../components/input/select.js';
8
8
  import { SubmitButton } from '../components/input/submit_button.js';
9
9
  import { Switch } from '../components/input/switch.js';
10
+ import { Section } from '../components/layout/Section.js';
10
11
 
11
12
  const { useFormContext, useFieldContext, formContext, fieldContext } =
12
13
  createFormHookContexts();
@@ -17,6 +18,7 @@ const { useAppForm, withForm } = createFormHook({
17
18
  formComponents: {
18
19
  SubmitButton,
19
20
  ResetButton,
21
+ Section,
20
22
  },
21
23
  fieldComponents: {
22
24
  Input,
@@ -19,4 +19,5 @@ export * from './activity_bar/index.js';
19
19
  export * from './activity_panel/index.js';
20
20
  export * from './utils/index.js';
21
21
  export * from './selected-total/index.js';
22
+ export * from './svg/index.js';
22
23
  export * as ValueRenderers from './value-renderers/index.js';
@@ -110,9 +110,10 @@ export function InfoPanel(props: InfoPanelProps) {
110
110
  const includes: InfoPanelDatum[] = [];
111
111
  const valueContains: InfoPanelDatum[] = [];
112
112
 
113
- for (const [parameter, value] of Object.entries(data).sort(([a], [b]) => {
114
- return a.localeCompare(b);
115
- })) {
113
+ const sortedDataEntries = Object.entries(data);
114
+ sortedDataEntries.sort(([a], [b]) => a.localeCompare(b));
115
+
116
+ for (const [parameter, value] of sortedDataEntries) {
116
117
  const lowerKey = parameter.toLowerCase();
117
118
  const lowerSearch = search.toLowerCase();
118
119
  if (lowerKey === lowerSearch) {
@@ -12,12 +12,12 @@ const HiddenInput = styled.input`
12
12
  padding: 0;
13
13
  margin: -1px;
14
14
  overflow: hidden;
15
- clip: rect(0, 0, 0, 0);
15
+ clip-path: inset(50%);
16
16
  white-space: nowrap;
17
17
  border-width: 0;
18
18
 
19
19
  /* Label associated with the checked input. */
20
- &:checked + label {
20
+ :checked + label {
21
21
  color: ${enabledColor};
22
22
  border-color: ${enabledColor};
23
23
  opacity: ${(props) => (props.disabled ? 0.25 : 1)};
@@ -25,7 +25,7 @@ const HiddenInput = styled.input`
25
25
  }
26
26
 
27
27
  /* Next label after the one that is checked. */
28
- &:checked + label + input + label {
28
+ :checked + label + input + label {
29
29
  border-left-width: 0;
30
30
  }
31
31
  `;
@@ -46,7 +46,7 @@ const Label = styled.label<{ size?: RadioProps['size']; disabled?: boolean }>`
46
46
  cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
47
47
  white-space: nowrap;
48
48
 
49
- &:hover {
49
+ :hover {
50
50
  color: ${enabledColor};
51
51
  }
52
52
  `;