@mikezimm/npmfunctions
Version:
Functions used in my SPFx webparts
141 lines (140 loc) • 5.69 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.makePropDataSliders = exports.makePropDataText = exports.makePropDataToggles = exports.WebPartInfoGroup = exports.ValidLocalLanguages = exports.JSON_Edit_Link = void 0;
var sp_property_pane_1 = require("@microsoft/sp-property-pane");
var PropertyPaneWebPartInformation_1 = require("@pnp/spfx-property-controls/lib/PropertyPaneWebPartInformation");
var stringCase_1 = require("../Strings/stringCase");
var fpsLogo326_1 = require("../../SVGIcons/fpsLogo326");
exports.JSON_Edit_Link = (0, sp_property_pane_1.PropertyPaneLink)('JSON Link', {
text: 'Use this site to more easily work on JSON',
href: 'https://codebeautify.org/jsonviewer',
target: '_blank',
});
exports.ValidLocalLanguages = (0, sp_property_pane_1.PropertyPaneLink)('languagesLink', {
text: 'See list of valid languages',
href: 'https://docs.microsoft.com/en-us/previous-versions/windows/desktop/indexsrv/valid-locale-identifiers',
target: '_blank',
});
function WebPartInfoGroup(gitRepoLinks, shortDescription) {
var infoGroup = { groupName: 'Web Part Info',
isCollapsed: true,
groupFields: [
(0, PropertyPaneWebPartInformation_1.PropertyPaneWebPartInformation)({
description: "<img src='".concat(fpsLogo326_1.fpsLogo326, "'/>"),
key: 'webPartInfoId'
}),
(0, PropertyPaneWebPartInformation_1.PropertyPaneWebPartInformation)({
description: "<p><i>\"If you change the way you look at things, the things you look at change.\"</i></p>",
key: 'webPartInfoId2'
}),
/*
PropertyPanePropertyEditor({
webpart: this,
key: 'propertyEditor'
}) ,
*/
(0, PropertyPaneWebPartInformation_1.PropertyPaneWebPartInformation)({
description: shortDescription,
key: 'webPartInfoId3'
}),
(0, sp_property_pane_1.PropertyPaneLink)('About Link', {
text: 'Github Repo: ' + gitRepoLinks.desc,
href: gitRepoLinks.href,
target: gitRepoLinks.target,
}),
(0, sp_property_pane_1.PropertyPaneLink)('Issues Link', {
text: 'Report Issues: ' + gitRepoLinks.desc,
href: gitRepoLinks.href + '/issues',
target: gitRepoLinks.target,
}),
]
};
return infoGroup;
}
exports.WebPartInfoGroup = WebPartInfoGroup;
/**
* makePropDataToggles creates an array of data Toggle elements based on a camelCase string array like prop keys
* and turns the keys into Sentance Case text
* @param props
* @param off
* @param on
* @param checked
*/
function makePropDataToggles(newProps, prevArray, off, on, checked, disabled) {
if (prevArray === void 0) { prevArray = []; }
if (off === void 0) { off = 'Off'; }
if (on === void 0) { on = 'On'; }
if (checked === void 0) { checked = true; }
if (disabled === void 0) { disabled = false; }
var newArray = prevArray;
newProps.map(function (propName) {
var newLabel = (0, stringCase_1.camelToSentanceCase)(propName);
newArray.push((0, sp_property_pane_1.PropertyPaneToggle)(propName, {
label: newLabel,
onAriaLabel: newLabel + ' ' + on,
offAriaLabel: newLabel + ' ' + off,
offText: off,
onText: on,
disabled: disabled,
checked: checked,
}));
});
return newArray;
}
exports.makePropDataToggles = makePropDataToggles;
/**
* makePropDataText creates an array of data Toggle elements based on a camelCase string array like prop keys
* and turns the keys into Sentance Case text
*
* @param newProps
* @param prevArray
* @param description
* @param disabled
*/
function makePropDataText(newProps, prevArray, description, disabled) {
if (prevArray === void 0) { prevArray = []; }
if (description === void 0) { description = ''; }
if (disabled === void 0) { disabled = false; }
var newArray = prevArray;
newProps.map(function (propName) {
var newLabel = (0, stringCase_1.camelToSentanceCase)(propName);
newArray.push((0, sp_property_pane_1.PropertyPaneTextField)(propName, {
label: newLabel,
ariaLabel: newLabel,
disabled: disabled,
description: description,
}));
});
return newArray;
}
exports.makePropDataText = makePropDataText;
/**
* makePropDataSliders creates an array of data Slider elements based on a camelCase string array like prop keys
* and turns the keys into Sentance Case text
* @param newProps
* @param prevArray
* @param min
* @param max
* @param step
* @param disabled
*/
function makePropDataSliders(newProps, prevArray, min, max, step, disabled) {
if (prevArray === void 0) { prevArray = []; }
if (disabled === void 0) { disabled = false; }
var newArray = prevArray;
newProps.map(function (propName) {
var newLabel = (0, stringCase_1.camelToSentanceCase)(propName);
newArray.push((0, sp_property_pane_1.PropertyPaneSlider)(propName, {
label: newLabel,
ariaLabel: newLabel,
disabled: disabled,
min: min,
max: max,
step: step,
showValue: true,
}));
});
return newArray;
}
exports.makePropDataSliders = makePropDataSliders;
//# sourceMappingURL=zReusablePropPane.js.map
;