MCPcopy
hub / github.com/palantir/blueprint / render

Method render

packages/datetime/src/dateInput.tsx:206–267  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

204 }
205
206 public render() {
207 const { value, valueString } = this.state;
208 const dateString = this.state.isInputFocused ? valueString : getFormattedDateString(value, this.props);
209 const dateValue = isDateValid(value) ? value : null;
210 const dayPickerProps = {
211 ...this.props.dayPickerProps,
212 // dom elements for the updated month is not available when
213 // onMonthChange is called. setTimeout is necessary to wait
214 // for the updated month to be rendered
215 onMonthChange: (month: Date) => {
216 Utils.safeInvoke(this.props.dayPickerProps.onMonthChange, month);
217 this.setTimeout(this.registerPopoverBlurHandler);
218 },
219 };
220
221 const wrappedPopoverContent = (
222 <div ref={ref => (this.popoverContentEl = ref)}>
223 <DatePicker
224 {...this.props}
225 dayPickerProps={dayPickerProps}
226 onChange={this.handleDateChange}
227 value={dateValue}
228 onShortcutChange={this.handleShortcutChange}
229 selectedShortcutIndex={this.state.selectedShortcutIndex}
230 />
231 </div>
232 );
233
234 // assign default empty object here to prevent mutation
235 const { inputProps = {}, popoverProps = {} } = this.props;
236 const isErrorState = value != null && (!isDateValid(value) || !this.isDateInRange(value));
237 return (
238 <Popover
239 isOpen={this.state.isOpen && !this.props.disabled}
240 fill={this.props.fill}
241 {...popoverProps}
242 autoFocus={false}
243 className={classNames(popoverProps.className, this.props.className)}
244 content={wrappedPopoverContent}
245 enforceFocus={false}
246 onClose={this.handleClosePopover}
247 popoverClassName={classNames(Classes.DATEINPUT_POPOVER, popoverProps.popoverClassName)}
248 >
249 <InputGroup
250 autoComplete="off"
251 intent={isErrorState ? Intent.DANGER : Intent.NONE}
252 placeholder={this.props.placeholder}
253 rightElement={this.props.rightElement}
254 type="text"
255 {...inputProps}
256 disabled={this.props.disabled}
257 inputRef={this.refHandlers.input}
258 onBlur={this.handleInputBlur}
259 onChange={this.handleInputChange}
260 onClick={this.handleInputClick}
261 onFocus={this.handleInputFocus}
262 onKeyDown={this.handleInputKeyDown}
263 value={dateString}

Callers

nothing calls this directly

Calls 3

isDateInRangeMethod · 0.95
getFormattedDateStringFunction · 0.90
isDateValidFunction · 0.90

Tested by

no test coverage detected