How to use @microsoft/sp-lodash-subset - 10 common examples

To help you get started, we’ve selected a few @microsoft/sp-lodash-subset examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SharePoint / sp-dev-fx-webparts / samples / react-content-query-webpart / src / controls / PropertyPaneQueryFilterPanel / components / QueryFilter / QueryFilter.tsx View on Github external
private onDateExpressionChange(newValue: string): string {

        // Validates the picker
        let regex = new RegExp(/^\[Today\](\s{0,}[\+-]\s{0,}\[{0,1}\d{1,4}\]{0,1}){0,1}$/);
        let isValid = regex.test(newValue) || isEmpty(newValue);
        let errorMsg = isValid ? '' : this.props.strings.datePickerExpressionError;
        
        if(isValid) {
            // If the change is NOT triggered by the date picker change
            if(!(isEmpty(newValue) && this.state.filter.value != null)) {
                this.state.filter.value = null;
                this.state.filter.expression = newValue;
                this.setState({ filter: this.state.filter, pickersKey: this.state.pickersKey });
                this.onAnyChange();
            }
        }

        return errorMsg;
    }
github SharePoint / sp-dev-fx-webparts / samples / react-search-refiners / spfx / src / webparts / searchResults / SearchResultsWebPart.ts View on Github external
},
                    ]
                })
            );
        }
        // Only show the template external URL for 'Custom' option
        if (this.properties.selectedLayout === ResultsLayoutOption.Custom) {
            stylingFields.splice(6, 0, PropertyPaneTextField('externalTemplateUrl', {
                label: strings.TemplateUrlFieldLabel,
                placeholder: strings.TemplateUrlPlaceholder,
                deferredValidationTime: 500,
                onGetErrorMessage: this._onTemplateUrlChange.bind(this)
            }));
        }
        if (this.codeRendererIsSelected()) {
            const currentCodeRenderer = find(this._codeRenderers, (renderer) => renderer.id === (this.properties.selectedLayout as any));
            if (!this.properties.customTemplateFieldValues) {
                this.properties.customTemplateFieldValues = currentCodeRenderer.customFields.map(field => {
                    return {
                        fieldName: field,
                        searchProperty: ''
                    };
                });
            }
            if (currentCodeRenderer.customFields && currentCodeRenderer.customFields.length > 0) {
                const searchPropertyOptions = this.properties.selectedProperties.split(',').map(prop => {
                    return ({
                        key: prop,
                        text: prop
                    });
                });
                stylingFields.push(PropertyFieldCollectionData('customTemplateFieldValues', {
github SharePoint / sp-dev-fx-webparts / samples / react-visio / src / shared / services / VisioService.ts View on Github external
private _onSelectionChanged = async (args: Visio.SelectionChangedEventArgs): Promise => {

    try {
      console.log("Selection Changed Event " + JSON.stringify(args));

      if (args.shapeNames.length > 0 && this._shapes && this._shapes.length > 0) {

        // get name of selected item
        const selectedShapeText: string = args.shapeNames[0];

        // find selected shape on the list of pre-loaded shapes
        this._selectedShape = find(this._shapes,
          s => s.name === selectedShapeText
        );

        // call delegate function from the react component
        this.onSelectionChanged(this._selectedShape);

      } else {
        // shape was deselected
        this._selectedShape = null;
      }
    } catch (error) {
      this.logError(error);
    }
  }
github SharePoint / sp-dev-fx-webparts / samples / react-content-query-webpart / src / webparts / contentQuery / components / ContentQuery.tsx View on Github external
return (
      <div>

        {loading}

        {error}

        {/* Shows the validation checklist if mandatory properties aren't all configured */}
        { !mandatoryFieldsConfigured &amp;&amp; !this.state.loading &amp;&amp; !this.state.error &amp;&amp;
          <div>
              { this.props.strings.mandatoryProperties }
              
              
              
              
              
              
          </div>
        }

        {/* Shows the query results once loaded */}
        { mandatoryFieldsConfigured &amp;&amp; !this.state.loading &amp;&amp; !this.state.error &amp;&amp;
          <div></div>
        }

      </div>
    );
  }
}
github SharePoint / sp-dev-fx-webparts / samples / react-content-query-webpart / src / controls / PropertyPaneQueryFilterPanel / components / QueryFilterPanel / QueryFilterPanel.tsx View on Github external
private isFilterEmpty(filter:IQueryFilter) {
        let isFilterEmpty = false;

        // If the filter has no field
        if(filter.field == null) {
            isFilterEmpty = true;
        }

        // If the filter has a null or empty value
        if(filter.value == null || isEmpty(filter.value.toString())) {
            
            // And has no date time expression
            if(isEmpty(filter.expression)) {

                // And isn't a [Me] switch
                if(!filter.me) {

                    // And isn't a  or  operator
                    if(filter.operator != QueryFilterOperator.IsNull &amp;&amp; filter.operator != QueryFilterOperator.IsNotNull) {
                        isFilterEmpty = true;
                    }
                }
            }
        }
        return isFilterEmpty;
    }
github SharePoint / sp-dev-fx-webparts / samples / react-content-query-webpart / src / webparts / contentQuery / components / ContentQuery.tsx View on Github external
const mandatoryFieldsConfigured = this.areMandatoryFieldsConfigured();

    return (
      <div>

        {loading}

        {error}

        {/* Shows the validation checklist if mandatory properties aren't all configured */}
        { !mandatoryFieldsConfigured &amp;&amp; !this.state.loading &amp;&amp; !this.state.error &amp;&amp;
          <div>
              { this.props.strings.mandatoryProperties }
              
              
              
              
              
              
          </div>
        }

        {/* Shows the query results once loaded */}
        { mandatoryFieldsConfigured &amp;&amp; !this.state.loading &amp;&amp; !this.state.error &amp;&amp;
          <div></div>
        }

      </div>
    );
  }
}
github SharePoint / sp-dev-fx-webparts / samples / react-content-query-webpart / src / common / services / ContentQueryService.ts View on Github external
public getFilterFields(webUrl: string, listId: string):Promise {
        Log.verbose(this.logSource, "Loading dropdown options for toolpart property 'Filters'...", this.context.serviceScope);

        // Resolves an empty array if no web or no list has been selected
        if (isEmpty(webUrl) || isEmpty(listId)) {
            return Promise.resolve(new Array());
        }

        // Resolves the already loaded data if available
        if(this.filterFields) {
            return Promise.resolve(this.filterFields);
        }

        // Otherwise gets the options asynchronously
        return new Promise((resolve, reject) =&gt; {
            this.listService.getListFields(webUrl, listId, ['InternalName', 'Title', 'TypeAsString'], 'Title').then((data:any) =&gt; {
                let fields:any[] = data.value;
                let options:IQueryFilterField[] = fields.map((field) =&gt; { return { 
                    internalName: field.InternalName, 
                    displayName: field.Title,
                    type: this.getFieldTypeFromString(field.TypeAsString)
github SharePoint / sp-dev-fx-webparts / samples / react-calendar / src / webparts / calendar / components / Calendar.tsx View on Github external
private async loadEvents() {
    try {
      // Teste Properties
      if (!this.props.list || !this.props.siteUrl || !this.props.eventStartDate.value || !this.props.eventEndDate.value) return;

      this.userListPermissions = await this.spService.getUserPermissions(this.props.siteUrl, this.props.list);
      const eventsData: IEventData[] = await this.spService.getEvents(escape(this.props.siteUrl), escape(this.props.list), this.props.eventStartDate.value, this.props.eventEndDate.value);
      this.setState({ eventData: eventsData, hasError: false, errorMessage: "" });
    } catch (error) {
      this.setState({ hasError: true, errorMessage: error.message, isloading: false });
    }
  }
  /**
github SharePoint / sp-dev-fx-webparts / samples / react-recaptcha / src / webparts / recaptcha / components / Recaptcha.tsx View on Github external
iconText='Configure your web part'  
                  description='Please configure the web part.'  
                  buttonLabel='Configure'  
                  hideButton={this.props.displayMode === DisplayMode.Read}  
                  onConfigure={() =&gt; this._onConfigure()} /&gt; 
              }  
  

      {/* Show description web part property, when set */} 
      {this.props.sitekey  &amp;&amp;  
        <div>
           <p>
        
        </p>
         { this.captcha = el; } }
        sitekey={escape(this.props.sitekey)}
        onChange={this.onChange} /&gt;
        <p>
            </p><p> { this._messageContainer = elm; }}&gt;
          </p>
        <p></p>

         this.buttonClicked()}   /&gt;
          </div> 
      }
      
    );
  }
github SharePoint / sp-dev-fx-extensions / samples / react-application-duetasks / src / extensions / dueTasks / DueTasksApplicationCustomizer.ts View on Github external
return;

    // Handling the top placeholder
    if (!this._topPlaceholder) {
      this._topPlaceholder = this.context.placeholderProvider.tryCreateContent(
        PlaceholderName.Top,
        {
          onDispose: this._onDispose
        });
    }

    if (this._topPlaceholder &amp;&amp; this._topPlaceholder.domElement) {
      this._topPlaceholder.domElement.innerHTML = `
                <div class="${styles.app}">
                  <div class="ms-bgColor-themeDark ms-fontColor-white ${styles.header}">
                    <i aria-hidden="true" class="ms-Icon ms-Icon--Info"></i> ${escape(strings.Message)}&nbsp;
                    <a href="${this._viewUrl}">${escape(strings.GoToList)}</a>
                  </div>
                </div>`;
    }
  }