UNPKG

@mikezimm/fps-library-v2

Version:

Library of reusable typescript/javascript functions, interfaces and constants

87 lines (84 loc) 2.97 kB
/** * CodeAnalizerComment: Updated 1 imports on 2024-09-22 14:49:52 * Update:: import { IPropertyPaneField } to '@mikezimm/fps-core-v7/lib/types/@msft/1.15.2/sp-property-pane;' */ /** * CodeAnalizerComment: Updated 1 imports on 2024-09-21 23:07:24 * Update:: import { camelToSentanceCase } to '@mikezimm/fps-core-v7/lib/logic/Strings/stringCase;' */ // was src\Services\PropPane\zReusablePropPane.ts import { PropertyPaneTextField, PropertyPaneToggle, PropertyPaneSlider, } from '@microsoft/sp-property-pane'; import { camelToSentanceCase } from '@mikezimm/fps-core-v7/lib/logic/Strings/stringCase'; /** * 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 */ export function makePropDataToggles(newProps, prevArray = [], off = 'Off', on = 'On', checked = true, disabled = false) { let newArray = prevArray; newProps.map(propName => { let newLabel = camelToSentanceCase(propName); newArray.push(PropertyPaneToggle(propName, { label: newLabel, onAriaLabel: newLabel + ' ' + on, offAriaLabel: newLabel + ' ' + off, offText: off, onText: on, disabled: disabled, checked: checked, })); }); return newArray; } /** * 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 */ export function makePropDataText(newProps, prevArray = [], description = '', disabled = false) { let newArray = prevArray; newProps.map(propName => { let newLabel = camelToSentanceCase(propName); newArray.push(PropertyPaneTextField(propName, { label: newLabel, ariaLabel: newLabel, disabled: disabled, description: description, })); }); return newArray; } /** * 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 */ export function makePropDataSliders(newProps, prevArray = [], min, max, step, disabled = false) { let newArray = prevArray; newProps.map(propName => { let newLabel = camelToSentanceCase(propName); newArray.push(PropertyPaneSlider(propName, { label: newLabel, ariaLabel: newLabel, disabled: disabled, min: min, max: max, step: step, showValue: true, })); }); return newArray; } //# sourceMappingURL=controls.js.map