@@ -48,36 +48,143 @@ export enum PeriodicTableMode {
48
48
NONE = 'none'
49
49
}
50
50
51
+ /**
52
+ * Props for `MaterialsInput` that get drilled into `MaterialsInputBox`
53
+ */
51
54
export interface MaterialsInputSharedProps {
55
+ /**
56
+ * The current/initial value of the input.
57
+ * This value will be dynamically updated so it can be accessed via dash callbacks.
58
+ */
52
59
value ?: string ;
60
+ /**
61
+ * The current/initial type of the input.
62
+ * The type value changes dynamically based on the input value.
63
+ */
53
64
type ?: MaterialsInputType ;
65
+ /**
66
+ * List of input types that are allowed to be entered into the input.
67
+ * This determines which types the component will dynamically detect.
68
+ * Each item in the list must be a valid `MaterialsInputType`.
69
+ * e.g. `['elements', 'checmical_system', 'formula']`
70
+ */
54
71
allowedInputTypes ?: MaterialsInputType [ ] ;
72
+ /**
73
+ * Text to display in the input when there is no value.
74
+ */
55
75
placeholder ?: string ;
76
+ /**
77
+ * Text to display in the error tooltip when an invalid input value is detected.
78
+ */
56
79
errorMessage ?: string ;
80
+ /**
81
+ * Class name(s) to apply to the input element in addition to the
82
+ * 'input' class which is added automatically.
83
+ */
57
84
inputClassName ?: string ;
85
+ /**
86
+ * API URL route to use to send autocomplete requests to when typing in a formula.
87
+ */
58
88
autocompleteFormulaUrl ?: string ;
89
+ /**
90
+ * API key to send along with the autocomplete request.
91
+ */
59
92
autocompleteApiKey ?: string ;
93
+ /**
94
+ * List of labels and examples to display under the input when it is focused and there is no value.
95
+ * Each item must be an object with a `label` string and/or `examples` array.
96
+ * Strings in `examples` arrays will be clickable and will fill the input value with the example.
97
+ * e.g.
98
+ * `[
99
+ * {label: 'Search by formula', examples: ['NaCl', 'MnO2']},
100
+ * {label: 'See more examples in the documentation'}
101
+ * ]`
102
+ */
60
103
helpItems ?: InputHelpItem [ ] ;
104
+ /**
105
+ * The maximum number of elements that can be entered or selected in the periodic table.
106
+ */
61
107
maxElementSelectable ?: number ;
108
+ /**
109
+ * This prop is used internally by `MaterialsInputBox` and will be ignored if set on `MaterialsInput`.
110
+ */
62
111
showAutocomplete ?: boolean ;
112
+ /**
113
+ * This prop is used internally by `MaterialsInputBox` and will be ignored if set on `MaterialsInput`.
114
+ */
63
115
setShowAutocomplete ?: ( value : boolean ) => any ;
116
+ /**
117
+ * Function to run when the value changes.
118
+ */
64
119
onChange ?: ( value : string ) => any ;
120
+ /**
121
+ * Function to run when the input type changes.
122
+ */
65
123
onInputTypeChange ?: ( type : MaterialsInputType ) => any ;
124
+ /**
125
+ * Function to run when the submit button is clicked.
126
+ */
66
127
onSubmit ?: ( event : React . FormEvent | React . MouseEvent , value ?: string , filterProps ?: any ) => any ;
67
128
}
68
129
130
+ /**
131
+ * Props that are exclusively for `MaterialsInput` (not drilled into `MaterialsInputBox`)
132
+ */
69
133
export interface MaterialsInputProps extends MaterialsInputSharedProps {
134
+ /**
135
+ * The ID used to identify this component in Dash callbacks
136
+ */
70
137
id ?: string ;
138
+ /**
139
+ * Dash-assigned callback that should be called whenever any of the
140
+ * properties change
141
+ */
71
142
setProps ?: ( value : any ) => any ;
143
+ /**
144
+ * Class name(s) to append to the component's default class (`mpc-materials-input`)
145
+ */
72
146
className ?: string ;
147
+ /**
148
+ * Number of milliseconds to wait before registering the value change.
149
+ */
73
150
debounce ?: number ;
151
+ /**
152
+ * Control how or if the periodic table should display with the input.
153
+ * Must be a valid `PeriodicTableMode` ('toggle', 'focus', or 'none').
154
+ */
74
155
periodicTableMode ?: PeriodicTableMode ;
156
+ /**
157
+ * An alternative way to turn off the periodic table.
158
+ * This could likely be removed in the future.
159
+ */
75
160
hidePeriodicTable ?: boolean ;
161
+ /**
162
+ * Set to true to display a left-hand dropdown for displaying and changing
163
+ * the input type.
164
+ */
76
165
showTypeDropdown ?: boolean ;
166
+ /**
167
+ * Set to true to show a submit button on the right-hand side of the input.
168
+ */
77
169
showSubmitButton ?: boolean ;
170
+ /**
171
+ * This prop can be used by dash callbacks to listen for user clicks on the submit button.
172
+ */
78
173
submitButtonClicks ?: number ;
174
+ /**
175
+ * Text to display in the submit button.
176
+ */
79
177
submitButtonText ?: string ;
178
+ /**
179
+ * Text to display in a label box on the left-hand side of the input.
180
+ * If none is supplied, there will not be a label rendered.
181
+ */
80
182
label ?: string ;
183
+ /**
184
+ * Hide the wildcard asterisk button with the periodic table.
185
+ * Use this for situations where you want to support element or chemical system
186
+ * selections, but you can't support wildcard searches.
187
+ */
81
188
hideWildcardButton ?: boolean ;
82
189
/**
83
190
* Text to display in the periodic table help box when
@@ -91,12 +198,20 @@ export interface MaterialsInputProps extends MaterialsInputSharedProps {
91
198
* Supports markdown.
92
199
*/
93
200
elementsSelectHelpText ?: string ;
201
+ /**
202
+ * This prop is controlled automatically.
203
+ * It tells you whether the input is in the loading state or not.
204
+ */
94
205
loading ?: boolean ;
206
+ /**
207
+ * Function to call when the input value changes that will pass the
208
+ * updated props object to the function.
209
+ */
95
210
onPropsChange ?: ( propsObject : any ) => void ;
96
211
}
97
212
98
213
/**
99
- * An input field component for searching by mp-id, elements, or formula.
214
+ * An input field component for searching by mp-id, elements, chemical system, formula, or plain text .
100
215
* Renders a text input and a periodic table within a PeriodicContext to support
101
216
* two-way binding between the input and periodic table.
102
217
* i.e. when elements are typed into the field, they are selected in the table,
0 commit comments