mui-spfx-controls
Version:
SPFx component library built with MUI
172 lines • 9.08 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var sp_core_library_1 = require("@microsoft/sp-core-library");
var sp_property_pane_1 = require("@microsoft/sp-property-pane");
var sp_webpart_base_1 = require("@microsoft/sp-webpart-base");
var spfx_property_controls_1 = require("@pnp/spfx-property-controls");
var strings = tslib_1.__importStar(require("ListFormWebPartStrings"));
var React = tslib_1.__importStar(require("react"));
var ReactDom = tslib_1.__importStar(require("react-dom"));
var validateUserFunction_1 = require("../../utils/validateUserFunction");
var ListFormDisplay_1 = tslib_1.__importDefault(require("./ListFormDisplay"));
var ListFormWebPart = /** @class */ (function (_super) {
tslib_1.__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_1.default, {
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 tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__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 sp_core_library_1.Version.parse('1.0');
},
enumerable: false,
configurable: true
});
ListFormWebPart.prototype.parseOnSaveFn = function (value) {
var parsedFn = (0, validateUserFunction_1.validateUserFunction)(value);
this.properties.onSave = parsedFn;
};
ListFormWebPart.prototype.getPropertyPaneConfiguration = function () {
var _this = this;
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription,
},
groups: [
{
groupName: strings.BasicGroupName,
groupFields: [
(0, spfx_property_controls_1.PropertyFieldListPicker)('list', {
label: strings.ListFieldLabel,
selectedList: this.properties.list,
includeHidden: false,
orderBy: spfx_property_controls_1.PropertyFieldListPickerOrderBy.Title,
disabled: false,
onPropertyChange: this.onPropertyPaneFieldChanged.bind(this),
properties: this.properties,
context: this.context,
key: 'listPickerFieldId',
}),
(0, spfx_property_controls_1.PropertyFieldColumnPicker)('fields', {
label: strings.ColumnsFieldLabel,
context: this.context,
selectedColumn: this.properties.fields,
listId: this.properties.list,
disabled: false,
orderBy: spfx_property_controls_1.PropertyFieldColumnPickerOrderBy.Title,
onPropertyChange: this.onPropertyPaneFieldChanged.bind(this),
properties: this.properties,
deferredValidationTime: 0,
key: 'columnPickerFieldId',
displayHiddenColumns: false,
columnReturnProperty: spfx_property_controls_1.IColumnReturnProperty['Internal Name'],
multiSelect: true,
}),
(0, sp_property_pane_1.PropertyPaneDropdown)('paperVariant', {
label: strings.PaperVariantFieldLabel,
selectedKey: 'elevation',
options: [
{
key: 'outlined',
text: 'outlined',
},
{
key: 'elevation',
text: 'elevation',
},
],
}),
(0, sp_property_pane_1.PropertyPaneTextField)('label', {
label: strings.LabelFieldLabel,
}),
(0, sp_property_pane_1.PropertyPaneTextField)('paperElevation', {
label: strings.PaperElevationFieldLabel,
}),
(0, sp_property_pane_1.PropertyPaneDropdown)('inputVariant', {
label: strings.InputVariantFieldLabel,
selectedKey: 'outlined',
options: [
{
key: 'outlined',
text: 'outlined',
},
{
key: 'standard',
text: 'standard',
},
{
key: 'filled',
text: 'filled',
},
],
}),
(0, sp_property_pane_1.PropertyPaneDropdown)('inputSize', {
label: strings.InputSizeFieldLabel,
selectedKey: 'medium',
options: [
{
key: 'small',
text: 'small',
},
{
key: 'medium',
text: 'medium',
},
],
}),
(0, sp_property_pane_1.PropertyPaneTextField)('fieldSpacing', {
label: strings.FieldSpacingFieldLabel,
}),
(0, spfx_property_controls_1.PropertyFieldMonacoEditor)('stringOnSave', {
key: 'editor-onsaveFn',
value: this.properties.stringOnSave,
language: spfx_property_controls_1.Elanguages.javascript,
showMiniMap: true,
showLineNumbers: true,
onChange: function (newValue) { return _this.parseOnSaveFn(newValue); },
}),
],
},
],
},
],
};
};
return ListFormWebPart;
}(sp_webpart_base_1.BaseClientSideWebPart));
exports.default = ListFormWebPart;
//# sourceMappingURL=ListFormWebPart.js.map