Skip to content

Commit

Permalink
Merge pull request #594 from pnp/dev
Browse files Browse the repository at this point in the history
3.15.1
  • Loading branch information
AJIXuMuK authored Dec 2, 2023
2 parents a984175 + 0ed95b3 commit e68db52
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 72 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -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)",
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
15 changes: 14 additions & 1 deletion docs/documentation/docs/about/release-notes.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion src/common/telemetry/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version: string = "3.15.0";
export const version: string = "3.15.1";
Original file line number Diff line number Diff line change
@@ -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<IPropertyFieldChoiceGroupWithCalloutPropsInternal> {
public targetProperty: string;
public type: PropertyPaneFieldType = PropertyPaneFieldType.Custom;
public properties: IPropertyFieldChoiceGroupWithCalloutPropsInternal;
class PropertyFieldChoiceGroupWithCalloutBuilder
implements
IPropertyPaneField<IPropertyFieldChoiceGroupWithCalloutPropsInternal>
{
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<IChoiceGroupOption>(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<HTMLElement | HTMLInputElement>,
option?: IChoiceGroupOption
): void {
if (this._onChangeCallback && option) {
this._onChangeCallback(this.targetProperty, option.key);
}
}
}

export function PropertyFieldChoiceGroupWithCallout(targetProperty: string, properties: IPropertyFieldChoiceGroupWithCalloutProps): IPropertyPaneField<IPropertyFieldChoiceGroupWithCalloutPropsInternal> {
return new PropertyFieldChoiceGroupWithCalloutBuilder(targetProperty, {
...properties,
onRender: null,
onDispose: null
});
export function PropertyFieldChoiceGroupWithCallout(
targetProperty: string,
properties: IPropertyFieldChoiceGroupWithCalloutProps
): IPropertyPaneField<IPropertyFieldChoiceGroupWithCalloutPropsInternal> {
return new PropertyFieldChoiceGroupWithCalloutBuilder(targetProperty, {
...properties,
onRender: null,
onDispose: null,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<IPropertyFieldChoiceGroupWithCalloutHostProps, null> {
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 (
<div>
<PropertyFieldHeader {...(this.props as IPlaceholderWithCalloutProps)} />
<ChoiceGroup {...omit(this.props, ['label'])} />
</div>
);
}
public render(): JSX.Element {
return (
<div>
<PropertyFieldHeader
{...(this.props as IPlaceholderWithCalloutProps)}
/>
<ChoiceGroup {...omit(this.props, ['label'])} />
</div>
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"description": "PropertyControlsTest",
"dropdownInfoHeaderKey": "gryffindor",
"htmlCode":"<div>Hello</div>",
"choiceGroupWithCalloutValue": "iOS",
"orderedItems": [
{"text": "Cat", "iconName": "Cat"},
{"text": "Pig", "iconName": "Savings"},
Expand Down

0 comments on commit e68db52

Please sign in to comment.