Skip to content

Commit d675c96

Browse files
Added new control "CustomLabel"
1 parent 1d7ac66 commit d675c96

File tree

16 files changed

+9785
-0
lines changed

16 files changed

+9785
-0
lines changed

CustomLabelControl/.eslintrc.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"eslint:recommended"
8+
],
9+
"globals": {
10+
"ComponentFramework": true
11+
},
12+
"parser": "@typescript-eslint/parser",
13+
"parserOptions": {
14+
"ecmaVersion": 12,
15+
"sourceType": "module"
16+
},
17+
"plugins": [
18+
"@microsoft/power-apps",
19+
"@typescript-eslint"
20+
],
21+
"rules": {
22+
"no-unused-vars": "off"
23+
}
24+
}

CustomLabelControl/.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
6+
# generated directory
7+
**/generated
8+
9+
# output directory
10+
/out
11+
12+
# msbuild output directories
13+
/bin
14+
/obj
15+
16+
# MSBuild Binary and Structured Log
17+
*.binlog
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "all",
4+
"singleQuote": false,
5+
"printWidth": 250,
6+
"tabWidth": 4,
7+
"endOfLine": "auto"
8+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest>
3+
<control namespace="Maverick.Controls" constructor="CustomLabel" version="0.0.4" display-name-key="CustomLabel" description-key="CustomLabel description" control-type="virtual">
4+
<!--external-service-usage node declares whether this 3rd party PCF control is using external service or not, if yes, this control will be considered as premium and please also add the external domain it is using.
5+
If it is not using any external service, please set the enabled="false" and DO NOT add any domain below. The "enabled" will be false by default.
6+
Example1:
7+
<external-service-usage enabled="true">
8+
<domain>www.Microsoft.com</domain>
9+
</external-service-usage>
10+
Example2:
11+
<external-service-usage enabled="false">
12+
</external-service-usage>
13+
-->
14+
<external-service-usage enabled="false">
15+
<!--UNCOMMENT TO ADD EXTERNAL DOMAINS
16+
<domain></domain>
17+
<domain></domain>
18+
-->
19+
</external-service-usage>
20+
<!-- property node identifies a specific, configurable piece of data that the control expects from CDS -->
21+
<property name="primary" display-name-key="Primary" description-key="Primary" usage="bound" required="true" of-type-group="AllTypes" />
22+
<property name="labelText" display-name-key="Label Text" description-key="Provide the label text you want to display" usage="input" required="true" of-type="SingleLine.Text" />
23+
<property name="isBold" display-name-key="Make it bold?" description-key="Make the entire label text as bold" usage="input" required="false" of-type="TwoOptions" />
24+
<property name="isItalic" display-name-key="Make it italic?" usage="input" required="false" of-type="TwoOptions" />
25+
<!--
26+
Property node's of-type attribute can be of-type-group attribute.
27+
Example:
28+
<type-group name="numbers">
29+
<type>Whole.None</type>
30+
<type>Currency</type>
31+
<type>FP</type>
32+
<type>Decimal</type>
33+
</type-group>
34+
<property name="sampleProperty" display-name-key="Property_Display_Key" description-key="Property_Desc_Key" of-type-group="numbers" usage="bound" required="true" />
35+
-->
36+
<resources>
37+
<code path="index.ts" order="1" />
38+
<platform-library name="React" version="16.8.6" />
39+
<platform-library name="Fluent" version="8.29.0" />
40+
<!-- UNCOMMENT TO ADD MORE RESOURCES
41+
<css path="css/CustomLabel.css" order="1" />
42+
<resx path="strings/CustomLabel.1033.resx" version="1.0.0" />
43+
-->
44+
</resources>
45+
<!-- UNCOMMENT TO ENABLE THE SPECIFIED API
46+
<feature-usage>
47+
<uses-feature name="Device.captureAudio" required="true" />
48+
<uses-feature name="Device.captureImage" required="true" />
49+
<uses-feature name="Device.captureVideo" required="true" />
50+
<uses-feature name="Device.getBarcodeValue" required="true" />
51+
<uses-feature name="Device.getCurrentPosition" required="true" />
52+
<uses-feature name="Device.pickFile" required="true" />
53+
<uses-feature name="Utility" required="true" />
54+
<uses-feature name="WebAPI" required="true" />
55+
</feature-usage>
56+
-->
57+
<type-group name="AllTypes">
58+
<type>Currency</type>
59+
<type>DateAndTime.DateAndTime</type>
60+
<type>DateAndTime.DateOnly</type>
61+
<type>Decimal</type>
62+
<type>SingleLine.Email</type>
63+
<type>SingleLine.Phone</type>
64+
<type>SingleLine.Text</type>
65+
<type>SingleLine.TextArea</type>
66+
<type>SingleLine.Ticker</type>
67+
<type>SingleLine.URL</type>
68+
<type>Whole.None</type>
69+
<type>Lookup.Simple</type>
70+
</type-group>
71+
</control>
72+
</manifest>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Label } from "@fluentui/react/lib/Label";
2+
import React from "react";
3+
4+
export type FluentLabelProps = {
5+
labelText: string;
6+
isBold?: boolean;
7+
isItalic?: boolean;
8+
};
9+
10+
const FluentLabel = ({ labelText, isBold, isItalic }: FluentLabelProps) => {
11+
return <Label style={{ fontWeight: isBold ? "bold" : "normal", fontStyle: isItalic ? "italic" : "normal" }}>{labelText}</Label>;
12+
};
13+
14+
export default FluentLabel;
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React from "react";
2+
import FluentLabel, { FluentLabelProps } from "./components/FluentLabel";
3+
import { IInputs, IOutputs } from "./generated/ManifestTypes";
4+
5+
export class CustomLabel implements ComponentFramework.ReactControl<IInputs, IOutputs> {
6+
private theContainer: HTMLDivElement;
7+
8+
/**
9+
* React properties
10+
*/
11+
private props: FluentLabelProps = {
12+
labelText: "Hello World",
13+
};
14+
15+
/**
16+
* Empty constructor.
17+
*/
18+
constructor() {}
19+
20+
/**
21+
* Used to initialize the control instance. Controls can kick off remote server calls and other initialization actions here.
22+
* Data-set values are not initialized here, use updateView.
23+
* @param context The entire property bag available to control via Context Object; It contains values as set up by the customizer mapped to property names defined in the manifest, as well as utility functions.
24+
* @param notifyOutputChanged A callback method to alert the framework that the control has new outputs ready to be retrieved asynchronously.
25+
* @param state A piece of data that persists in one session for a single user. Can be set at any point in a controls life cycle by calling 'setControlState' in the Mode interface.
26+
* @param container If a control is marked control-type='standard', it will receive an empty div element within which it can render its content.
27+
*/
28+
public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container: HTMLDivElement): void {
29+
this.theContainer = container;
30+
}
31+
32+
/**
33+
* Called when any value in the property bag has changed. This includes field values, data-sets, global values such as container height and width, offline status, control metadata values such as label, visible, etc.
34+
* @param context The entire property bag available to control via Context Object; It contains values as set up by the customizer mapped to names defined in the manifest, as well as utility functions
35+
*/
36+
public updateView(context: ComponentFramework.Context<IInputs>): React.ReactElement {
37+
// Get the label text from the component properties
38+
if (context.parameters.labelText.raw) {
39+
this.props.labelText = context.parameters.labelText.raw;
40+
}
41+
42+
if (context.parameters.isBold.raw) {
43+
this.props.isBold = context.parameters.isBold.raw;
44+
}
45+
46+
if (context.parameters.isItalic.raw) {
47+
this.props.isItalic = context.parameters.isItalic.raw;
48+
}
49+
50+
// Render the React component
51+
return React.createElement(FluentLabel, this.props);
52+
}
53+
54+
/**
55+
* It is called by the framework prior to a control receiving new data.
56+
* @returns an object based on nomenclature defined in manifest, expecting object[s] for property marked as “bound” or “output”
57+
*/
58+
public getOutputs(): IOutputs {
59+
return {};
60+
}
61+
62+
/**
63+
* Called when the control is to be removed from the DOM tree. Controls should use this call for cleanup.
64+
* i.e. cancelling any pending remote calls, removing listeners, etc.
65+
*/
66+
public destroy(): void {
67+
// Add code to cleanup control if necessary
68+
}
69+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<PowerAppsTargetsPath>$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\PowerApps</PowerAppsTargetsPath>
5+
</PropertyGroup>
6+
7+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
8+
<Import Project="$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Pcf.props" Condition="Exists('$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Pcf.props')" />
9+
10+
<PropertyGroup>
11+
<Name>CustomLabelControl</Name>
12+
<ProjectGuid>b8bceaf7-e1bd-4286-97bb-5724ff85873d</ProjectGuid>
13+
<OutputPath>$(MSBuildThisFileDirectory)out\controls</OutputPath>
14+
</PropertyGroup>
15+
16+
<PropertyGroup>
17+
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
18+
<!--Remove TargetFramework when this is available in 16.1-->
19+
<TargetFramework>net462</TargetFramework>
20+
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
21+
</PropertyGroup>
22+
23+
<ItemGroup>
24+
<PackageReference Include="Microsoft.PowerApps.MSBuild.Pcf" Version="1.*" />
25+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
26+
</ItemGroup>
27+
28+
<ItemGroup>
29+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\.gitignore" />
30+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\bin\**" />
31+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\obj\**" />
32+
<ExcludeDirectories Include="$(OutputPath)\**" />
33+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.pcfproj" />
34+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.pcfproj.user" />
35+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.sln" />
36+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\node_modules\**" />
37+
</ItemGroup>
38+
39+
<ItemGroup>
40+
<None Include="$(MSBuildThisFileDirectory)\**" Exclude="@(ExcludeDirectories)" />
41+
</ItemGroup>
42+
43+
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
44+
<Import Project="$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Pcf.targets" Condition="Exists('$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Pcf.targets')" />
45+
46+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# msbuild output directories
4+
/bin
5+
/obj
6+
7+
# MSBuild Binary and Structured Log
8+
*.binlog
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<PowerAppsTargetsPath>$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\PowerApps</PowerAppsTargetsPath>
5+
</PropertyGroup>
6+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
7+
<Import Project="$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.props" Condition="Exists('$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.props')" />
8+
<PropertyGroup>
9+
<ProjectGuid>9f6bfc6b-a627-4a8c-a946-e0a3e703c93d</ProjectGuid>
10+
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
11+
<!--Remove TargetFramework when this is available in 16.1-->
12+
<TargetFramework>net462</TargetFramework>
13+
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
14+
<SolutionRootPath>src</SolutionRootPath>
15+
</PropertyGroup>
16+
<!--
17+
Solution Packager overrides, un-comment to use: SolutionPackagerType (Managed, Unmanaged, Both)
18+
Solution Localization Control, if you want to enabled localization of your solution, un-comment SolutionPackageEnableLocalization and set the value to true. - Requires use of -loc flag on Solution Clone or Sync
19+
-->
20+
<!--
21+
<PropertyGroup>
22+
<SolutionPackageType>Managed</SolutionPackageType>
23+
<SolutionPackageEnableLocalization>false</SolutionPackageEnableLocalization>
24+
</PropertyGroup>
25+
-->
26+
<ItemGroup>
27+
<PackageReference Include="Microsoft.PowerApps.MSBuild.Solution" Version="1.*" />
28+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
29+
</ItemGroup>
30+
<ItemGroup>
31+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\.gitignore" />
32+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\bin\**" />
33+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\obj\**" />
34+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.cdsproj" />
35+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.cdsproj.user" />
36+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.sln" />
37+
</ItemGroup>
38+
<ItemGroup>
39+
<None Include="$(MSBuildThisFileDirectory)\**" Exclude="@(ExcludeDirectories)" />
40+
<Content Include="$(SolutionPackageZipFilePath)">
41+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
42+
</Content>
43+
</ItemGroup>
44+
<ItemGroup>
45+
<ProjectReference Include="..\..\CustomLabelControl.pcfproj" />
46+
</ItemGroup>
47+
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
48+
<Import Project="$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.targets" Condition="Exists('$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.targets')" />
49+
<PropertyGroup>
50+
<SolutionPackageType>Both</SolutionPackageType>
51+
</PropertyGroup>
52+
</Project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ImportExportXml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3+
<Entities />
4+
<Roles />
5+
<Workflows />
6+
<FieldSecurityProfiles />
7+
<Templates />
8+
<EntityMaps />
9+
<EntityRelationships />
10+
<OrganizationSettings />
11+
<optionsets />
12+
<CustomControls />
13+
<SolutionPluginAssemblies />
14+
<EntityDataProviders />
15+
<Languages>
16+
<Language>1033</Language>
17+
</Languages>
18+
</ImportExportXml>

0 commit comments

Comments
 (0)