diff --git a/CHANGELOG.json b/CHANGELOG.json index 32faff88..8ce6c152 100644 --- a/CHANGELOG.json +++ b/CHANGELOG.json @@ -1,10 +1,31 @@ { "versions": [ + { + "version": "3.16.0", + "changes": { + "new": [], + "enhancements": [], + "fixes": [] + }, + "contributions": [] + }, + { + "version": "3.15.1", + "changes": { + "new": [], + "enhancements": [], + "fixes": [ + "`PropertyFieldChoiceGroupWithCallout` deletes properties [#592](https://github.com/pnp/sp-dev-fx-property-controls/issues/592)" + ] + }, + "contributions": [] + }, { "version": "3.15.0", "changes": { "new": [], "enhancements": [ + "SharePoint Framework v1.18.2 support" ], "fixes": [ "`Localization`: Errors in en-gb loc file [#582](https://github.com/pnp/sp-dev-fx-property-controls/pull/582)", diff --git a/CHANGELOG.md b/CHANGELOG.md index 639dbda4..9ba84b86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,28 @@ # Releases +## 3.16.0 + +## 3.15.1 + +### Fixes + +- `PropertyFieldChoiceGroupWithCallout` deletes properties [#592](https://github.com/pnp/sp-dev-fx-property-controls/issues/592) + ## 3.15.0 +### Enhancements + +- SharePoint Framework v1.18.2 support + ### Fixes - `Localization`: Errors in en-gb loc file [#582](https://github.com/pnp/sp-dev-fx-property-controls/pull/582) - `Localization`: Errors in german language [#589](https://github.com/pnp/sp-dev-fx-property-controls/pull/589) +- `PropertyFieldFilePicker`: fix Tiles view [#562](https://github.com/pnp/sp-dev-fx-property-controls/issues/562) ### Contributors -Special thanks to our contributors (in alphabetical order): [andrew-lott](https://github.com/andrew-lott), [Tom F.](https://github.com/tpf89). +Special thanks to our contributors (in alphabetical order): [andrew-lott](https://github.com/andrew-lott), [Clem S-K](https://github.com/ClemSK), [Tom F.](https://github.com/tpf89). ## 3.14.0 diff --git a/docs/documentation/docs/about/release-notes.md b/docs/documentation/docs/about/release-notes.md index 639dbda4..9ba84b86 100644 --- a/docs/documentation/docs/about/release-notes.md +++ b/docs/documentation/docs/about/release-notes.md @@ -1,15 +1,28 @@ # Releases +## 3.16.0 + +## 3.15.1 + +### Fixes + +- `PropertyFieldChoiceGroupWithCallout` deletes properties [#592](https://github.com/pnp/sp-dev-fx-property-controls/issues/592) + ## 3.15.0 +### Enhancements + +- SharePoint Framework v1.18.2 support + ### Fixes - `Localization`: Errors in en-gb loc file [#582](https://github.com/pnp/sp-dev-fx-property-controls/pull/582) - `Localization`: Errors in german language [#589](https://github.com/pnp/sp-dev-fx-property-controls/pull/589) +- `PropertyFieldFilePicker`: fix Tiles view [#562](https://github.com/pnp/sp-dev-fx-property-controls/issues/562) ### Contributors -Special thanks to our contributors (in alphabetical order): [andrew-lott](https://github.com/andrew-lott), [Tom F.](https://github.com/tpf89). +Special thanks to our contributors (in alphabetical order): [andrew-lott](https://github.com/andrew-lott), [Clem S-K](https://github.com/ClemSK), [Tom F.](https://github.com/tpf89). ## 3.14.0 diff --git a/package-lock.json b/package-lock.json index e7ae1c56..aeb6dbd1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@pnp/spfx-property-controls", - "version": "3.15.0", + "version": "3.15.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@pnp/spfx-property-controls", - "version": "3.15.0", + "version": "3.15.1", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 48d6c276..fa5ecbc6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@pnp/spfx-property-controls", "description": "Reusable property pane controls for SharePoint Framework solutions", - "version": "3.15.0", + "version": "3.15.1", "engines": { "node": ">=16.13.0 <17.0.0 || >=18.17.1 <19.0.0" }, diff --git a/src/common/telemetry/version.ts b/src/common/telemetry/version.ts index 2a1654fe..d2256110 100644 --- a/src/common/telemetry/version.ts +++ b/src/common/telemetry/version.ts @@ -1 +1 @@ -export const version: string = "3.15.0"; \ No newline at end of file +export const version: string = "3.15.1"; \ No newline at end of file diff --git a/src/propertyFields/choiceGroupWithCallout/PropertyFieldChoiceGroupWithCallout.ts b/src/propertyFields/choiceGroupWithCallout/PropertyFieldChoiceGroupWithCallout.ts index 87e808cb..3456109d 100644 --- a/src/propertyFields/choiceGroupWithCallout/PropertyFieldChoiceGroupWithCallout.ts +++ b/src/propertyFields/choiceGroupWithCallout/PropertyFieldChoiceGroupWithCallout.ts @@ -1,72 +1,101 @@ import * as React from 'react'; import * as ReactDOM from 'react-dom'; import { - IPropertyPaneField, - PropertyPaneFieldType + IPropertyPaneField, + PropertyPaneFieldType, } from '@microsoft/sp-property-pane'; import omit from 'lodash/omit'; import PropertyFieldToggleWithCalloutHost from './PropertyFieldChoiceGroupWithCalloutHost'; -import {IPropertyFieldChoiceGroupWithCalloutPropsInternal, IPropertyFieldChoiceGroupWithCalloutProps} from './IPropertyFieldChoiceGroupWithCallout'; +import { + IPropertyFieldChoiceGroupWithCalloutPropsInternal, + IPropertyFieldChoiceGroupWithCalloutProps, +} from './IPropertyFieldChoiceGroupWithCallout'; import { IChoiceGroupOption } from '@fluentui/react/lib/components/ChoiceGroup'; -class PropertyFieldChoiceGroupWithCalloutBuilder implements IPropertyPaneField { - public targetProperty: string; - public type: PropertyPaneFieldType = PropertyPaneFieldType.Custom; - public properties: IPropertyFieldChoiceGroupWithCalloutPropsInternal; +class PropertyFieldChoiceGroupWithCalloutBuilder + implements + IPropertyPaneField +{ + public targetProperty: string; + public type: PropertyPaneFieldType = PropertyPaneFieldType.Custom; + public properties: IPropertyFieldChoiceGroupWithCalloutPropsInternal; - private _onChangeCallback: (targetProperty?: string, newValue?: any) => void; // eslint-disable-line @typescript-eslint/no-explicit-any + private _onChangeCallback: (targetProperty?: string, newValue?: any) => void; // eslint-disable-line @typescript-eslint/no-explicit-any - public constructor(_targetProperty: string, _properties: IPropertyFieldChoiceGroupWithCalloutPropsInternal) { - this.targetProperty = _targetProperty; - this.properties = _properties; + public constructor( + _targetProperty: string, + _properties: IPropertyFieldChoiceGroupWithCalloutPropsInternal + ) { + this.targetProperty = _targetProperty; + this.properties = _properties; - this.properties.onRender = this._render.bind(this); - this.properties.onDispose = this._dispose.bind(this); - } + this.properties.onRender = this._render.bind(this); + this.properties.onDispose = this._dispose.bind(this); + } - private _render(elem: HTMLElement, context?: any, changeCallback?: (targetProperty?: string, newValue?: any) => void): void { // eslint-disable-line @typescript-eslint/no-explicit-any - // IPropertyPaneChoiceGroupOption should be manually converted to IChoiceGroupOption - const options: IChoiceGroupOption[] = this.properties.options.map(o => { - return { - ...omit(o, ['key', 'iconProps']), - iconProps: o.iconProps && { - iconName: o.iconProps.officeFabricIconFontName - }, - key: o.key.toString() - }; - }); - const props = this.properties as IPropertyFieldChoiceGroupWithCalloutProps; - - const element = React.createElement(PropertyFieldToggleWithCalloutHost, { - ...omit(props, ['options']), - options: options, - onChange: this._onChanged.bind(this) - }); - - ReactDOM.render(element, elem); - - if (changeCallback) { - this._onChangeCallback = changeCallback; - } - } + private _render( + elem: HTMLElement, + context?: any, + changeCallback?: (targetProperty?: string, newValue?: any) => void + ): void { + // eslint-disable-line @typescript-eslint/no-explicit-any + // IPropertyPaneChoiceGroupOption should be manually converted to IChoiceGroupOption + + const options: IChoiceGroupOption[] = []; + let selectedKey: string | number | undefined = undefined; + + this.properties.options.forEach((o) => { + options.push({ + ...omit(o, ['key', 'iconProps']), + iconProps: o.iconProps && { + iconName: o.iconProps.officeFabricIconFontName, + }, + key: o.key.toString(), + }); + + if (o.checked) { + selectedKey = o.key; + } + }); + const props = this.properties as IPropertyFieldChoiceGroupWithCalloutProps; + + const element = React.createElement(PropertyFieldToggleWithCalloutHost, { + ...omit(props, ['options']), + options: options, + onChange: this._onChanged.bind(this), + selectedKey: selectedKey, + }); - private _dispose(elem: HTMLElement): void { - ReactDOM.unmountComponentAtNode(elem); + ReactDOM.render(element, elem); + + if (changeCallback) { + this._onChangeCallback = changeCallback; } + } + + private _dispose(elem: HTMLElement): void { + ReactDOM.unmountComponentAtNode(elem); + } - private _onChanged(option: IChoiceGroupOption): void { - if (this._onChangeCallback) { - this._onChangeCallback(this.targetProperty, option.key); - } + private _onChanged( + ev?: React.FormEvent, + option?: IChoiceGroupOption + ): void { + if (this._onChangeCallback && option) { + this._onChangeCallback(this.targetProperty, option.key); } + } } -export function PropertyFieldChoiceGroupWithCallout(targetProperty: string, properties: IPropertyFieldChoiceGroupWithCalloutProps): IPropertyPaneField { - return new PropertyFieldChoiceGroupWithCalloutBuilder(targetProperty, { - ...properties, - onRender: null, - onDispose: null - }); +export function PropertyFieldChoiceGroupWithCallout( + targetProperty: string, + properties: IPropertyFieldChoiceGroupWithCalloutProps +): IPropertyPaneField { + return new PropertyFieldChoiceGroupWithCalloutBuilder(targetProperty, { + ...properties, + onRender: null, + onDispose: null, + }); } diff --git a/src/propertyFields/choiceGroupWithCallout/PropertyFieldChoiceGroupWithCalloutHost.tsx b/src/propertyFields/choiceGroupWithCallout/PropertyFieldChoiceGroupWithCalloutHost.tsx index 57b4fb4e..5e98e015 100644 --- a/src/propertyFields/choiceGroupWithCallout/PropertyFieldChoiceGroupWithCalloutHost.tsx +++ b/src/propertyFields/choiceGroupWithCallout/PropertyFieldChoiceGroupWithCalloutHost.tsx @@ -8,21 +8,26 @@ import { IPropertyFieldChoiceGroupWithCalloutHostProps } from './IPropertyFieldC import * as telemetry from '../../common/telemetry'; import { ChoiceGroup } from '@fluentui/react/lib/components/ChoiceGroup'; -export default class PropertyFieldToggleWithCalloutHost extends React.Component { - constructor(props: IPropertyFieldChoiceGroupWithCalloutHostProps) { - super(props); +export default class PropertyFieldToggleWithCalloutHost extends React.Component< + IPropertyFieldChoiceGroupWithCalloutHostProps, + null +> { + constructor(props: IPropertyFieldChoiceGroupWithCalloutHostProps) { + super(props); - telemetry.track('PropertyFieldToggleWithCallout', { - disabled: props.disabled - }); - } + telemetry.track('PropertyFieldToggleWithCallout', { + disabled: props.disabled, + }); + } - public render(): JSX.Element { - return ( -
- - -
- ); - } + public render(): JSX.Element { + return ( +
+ + +
+ ); + } } diff --git a/src/webparts/propertyControlsTest/PropertyControlsTestWebPart.manifest.json b/src/webparts/propertyControlsTest/PropertyControlsTestWebPart.manifest.json index 48e65a3d..26dafa3d 100644 --- a/src/webparts/propertyControlsTest/PropertyControlsTestWebPart.manifest.json +++ b/src/webparts/propertyControlsTest/PropertyControlsTestWebPart.manifest.json @@ -24,6 +24,7 @@ "description": "PropertyControlsTest", "dropdownInfoHeaderKey": "gryffindor", "htmlCode":"
Hello
", + "choiceGroupWithCalloutValue": "iOS", "orderedItems": [ {"text": "Cat", "iconName": "Cat"}, {"text": "Pig", "iconName": "Savings"},