MCPcopy Create free account
hub / github.com/microsoft/SandDance / _Search

Function _Search

docs/app/js/sanddance-app.js:12567–12780  ·  view source on GitHub ↗
(_props)

Source from the content-addressed store, hash-verified

12565 });
12566}
12567function _Search(_props) {
12568 class __Search extends (0, _base.base).react.Component {
12569 constructor(props){
12570 super(props);
12571 this.state = this.getInitialState(this.props);
12572 this.dropdownRef = (0, _base.base).react.createRef();
12573 props.explorer.dialogFocusHandler.focus = ()=>{
12574 var _a;
12575 return (_a = this.dropdownRef.current) === null || _a === void 0 ? void 0 : _a.focus();
12576 };
12577 }
12578 getInitialState(props) {
12579 const initialState = {
12580 groups: props.initializer.search || [
12581 this.newGroup(0, null)
12582 ],
12583 sortedColumns: [
12584 ...props.initializer.columns
12585 ].sort((a, b)=>a.name.localeCompare(b.name)),
12586 initializer: props.initializer
12587 };
12588 initialState.groups.forEach((group)=>{
12589 group.expressions.forEach((ex)=>ex.unlocked = group.expressions.length <= 2);
12590 });
12591 return initialState;
12592 }
12593 componentDidUpdate() {
12594 if (!(0, _sanddanceReact.util).deepCompare(this.props.initializer, this.state.initializer)) this.setState(this.getInitialState(this.props));
12595 }
12596 validateAndSearch() {
12597 const groups = [
12598 ...this.state.groups
12599 ];
12600 groups.forEach((group)=>{
12601 group.expressions.forEach(validateExpression);
12602 const errors = group.expressions.reduce((p, c)=>p || c.errorMessage, "");
12603 if (errors) this.setState({
12604 groups
12605 });
12606 else this.props.onSelect(this.state.groups);
12607 });
12608 }
12609 newGroup(key, clause) {
12610 const group = {
12611 key,
12612 clause,
12613 expressions: [
12614 this.newExpression(0, null)
12615 ]
12616 };
12617 return group;
12618 }
12619 updateGroup(partialGroup, groupIndex) {
12620 const groups = [
12621 ...this.state.groups
12622 ];
12623 const group = Object.assign(Object.assign({}, groups[groupIndex]), partialGroup);
12624 groups[groupIndex] = group;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected