UNPKG

mui-spfx-controls

Version:
170 lines 8.68 kB
import { __awaiter, __extends, __generator } from "tslib"; import { Version } from '@microsoft/sp-core-library'; import { PropertyPaneDropdown, PropertyPaneTextField, } from '@microsoft/sp-property-pane'; import { BaseClientSideWebPart, } from '@microsoft/sp-webpart-base'; import { Elanguages, IColumnReturnProperty, PropertyFieldColumnPicker, PropertyFieldColumnPickerOrderBy, PropertyFieldListPicker, PropertyFieldListPickerOrderBy, PropertyFieldMonacoEditor, } from '@pnp/spfx-property-controls'; import * as strings from 'ListFormWebPartStrings'; import * as React from 'react'; import * as ReactDom from 'react-dom'; import { validateUserFunction } from '../../utils/validateUserFunction'; import ListFormDisplay from './ListFormDisplay'; var ListFormWebPart = /** @class */ (function (_super) { __extends(ListFormWebPart, _super); function ListFormWebPart() { return _super !== null && _super.apply(this, arguments) || this; } ListFormWebPart.prototype.handleCancel = function () { }; ListFormWebPart.prototype.render = function () { var element = React.createElement(ListFormDisplay, { context: this.context, list: this.properties.list, fields: this.properties.fields, label: this.properties.label, paperVariant: this.properties.paperVariant, paperElevation: this.properties.paperElevation, inputVariant: this.properties.inputVariant, inputSize: this.properties.inputSize, fieldSpacing: this.properties.fieldSpacing, onSave: this.properties.onSave || (function (formData) { return console.log(formData); }), onCancel: this.handleCancel, }); ReactDom.render(element, this.domElement); }; ListFormWebPart.prototype.onInit = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, _super.prototype.onInit.call(this)]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }; ListFormWebPart.prototype.onDispose = function () { ReactDom.unmountComponentAtNode(this.domElement); }; Object.defineProperty(ListFormWebPart.prototype, "dataVersion", { get: function () { return Version.parse('1.0'); }, enumerable: false, configurable: true }); ListFormWebPart.prototype.parseOnSaveFn = function (value) { var parsedFn = validateUserFunction(value); this.properties.onSave = parsedFn; }; ListFormWebPart.prototype.getPropertyPaneConfiguration = function () { var _this = this; return { pages: [ { header: { description: strings.PropertyPaneDescription, }, groups: [ { groupName: strings.BasicGroupName, groupFields: [ PropertyFieldListPicker('list', { label: strings.ListFieldLabel, selectedList: this.properties.list, includeHidden: false, orderBy: PropertyFieldListPickerOrderBy.Title, disabled: false, onPropertyChange: this.onPropertyPaneFieldChanged.bind(this), properties: this.properties, context: this.context, key: 'listPickerFieldId', }), PropertyFieldColumnPicker('fields', { label: strings.ColumnsFieldLabel, context: this.context, selectedColumn: this.properties.fields, listId: this.properties.list, disabled: false, orderBy: PropertyFieldColumnPickerOrderBy.Title, onPropertyChange: this.onPropertyPaneFieldChanged.bind(this), properties: this.properties, deferredValidationTime: 0, key: 'columnPickerFieldId', displayHiddenColumns: false, columnReturnProperty: IColumnReturnProperty['Internal Name'], multiSelect: true, }), PropertyPaneDropdown('paperVariant', { label: strings.PaperVariantFieldLabel, selectedKey: 'elevation', options: [ { key: 'outlined', text: 'outlined', }, { key: 'elevation', text: 'elevation', }, ], }), PropertyPaneTextField('label', { label: strings.LabelFieldLabel, }), PropertyPaneTextField('paperElevation', { label: strings.PaperElevationFieldLabel, }), PropertyPaneDropdown('inputVariant', { label: strings.InputVariantFieldLabel, selectedKey: 'outlined', options: [ { key: 'outlined', text: 'outlined', }, { key: 'standard', text: 'standard', }, { key: 'filled', text: 'filled', }, ], }), PropertyPaneDropdown('inputSize', { label: strings.InputSizeFieldLabel, selectedKey: 'medium', options: [ { key: 'small', text: 'small', }, { key: 'medium', text: 'medium', }, ], }), PropertyPaneTextField('fieldSpacing', { label: strings.FieldSpacingFieldLabel, }), PropertyFieldMonacoEditor('stringOnSave', { key: 'editor-onsaveFn', value: this.properties.stringOnSave, language: Elanguages.javascript, showMiniMap: true, showLineNumbers: true, onChange: function (newValue) { return _this.parseOnSaveFn(newValue); }, }), ], }, ], }, ], }; }; return ListFormWebPart; }(BaseClientSideWebPart)); export default ListFormWebPart; //# sourceMappingURL=ListFormWebPart.js.map