From 0af5be679dc46078c987d44fdfe4fe5b0e6c59f5 Mon Sep 17 00:00:00 2001 From: Ramakrishnan Raman Date: Tue, 18 Apr 2023 13:46:13 +0530 Subject: [PATCH] feat: searchbox bordercolor property (#235) --- SearchBox/README.md | 2 ++ SearchBox/SearchBox/ControlManifest.Input.xml | 2 +- .../SearchBox/__mocks__/mock-parameters.ts | 1 + .../searchbox-lifecycle.test.ts.snap | 1 + .../SearchBox/components/Component.types.ts | 1 + SearchBox/SearchBox/components/SearchBox.tsx | 31 +++++++++++++------ SearchBox/SearchBox/index.ts | 5 ++- .../SearchBox/strings/SearchBox.1033.resx | 3 ++ 8 files changed, 35 insertions(+), 11 deletions(-) diff --git a/SearchBox/README.md b/SearchBox/README.md index 98e35d18..64952d4c 100644 --- a/SearchBox/README.md +++ b/SearchBox/README.md @@ -20,6 +20,8 @@ This code component provides a wrapper around the [Fluent UI SearchBox](https:// - **Delay Output** - To delay output by half a second. Useful when input is provided frequently within short duration. +- **Border color** - To define specific color for searchbox border. This exludes onhover & onfocus border color. + ## Additional properties - **Theme** - Accepts a JSON string that is generated using [Fluent UI Theme Designer (windows.net)](https://fabricweb.z5.web.core.windows.net/pr-deploy-site/refs/heads/master/theming-designer/). Leaving this blank will use the default theme defined by Power Apps. Leaving this blank will use the default theme defined by Power Apps. See [theming](theme.md) for guidance on how to configure. diff --git a/SearchBox/SearchBox/ControlManifest.Input.xml b/SearchBox/SearchBox/ControlManifest.Input.xml index 79eef71c..2c0be70e 100644 --- a/SearchBox/SearchBox/ControlManifest.Input.xml +++ b/SearchBox/SearchBox/ControlManifest.Input.xml @@ -1,7 +1,6 @@ - @@ -11,6 +10,7 @@ + diff --git a/SearchBox/SearchBox/__mocks__/mock-parameters.ts b/SearchBox/SearchBox/__mocks__/mock-parameters.ts index 2baedd8b..221317ff 100644 --- a/SearchBox/SearchBox/__mocks__/mock-parameters.ts +++ b/SearchBox/SearchBox/__mocks__/mock-parameters.ts @@ -14,5 +14,6 @@ export function getMockParameters(): IInputs { InputEvent: new MockStringProperty(), DelayOutput: new MockTwoOptionsProperty(), SearchText: new MockStringProperty(), + BorderColor: new MockStringProperty() }; } diff --git a/SearchBox/SearchBox/__tests__/__snapshots__/searchbox-lifecycle.test.ts.snap b/SearchBox/SearchBox/__tests__/__snapshots__/searchbox-lifecycle.test.ts.snap index 57d5b3b1..3aa88a38 100644 --- a/SearchBox/SearchBox/__tests__/__snapshots__/searchbox-lifecycle.test.ts.snap +++ b/SearchBox/SearchBox/__tests__/__snapshots__/searchbox-lifecycle.test.ts.snap @@ -3,6 +3,7 @@ exports[`SearchBox renders 1`] = ` { - const { onChange, themeJSON, ariaLabel, placeholderText, underLined, disabled, disableAnimation, setFocus, value } = - props; + const { + onChange, + themeJSON, + ariaLabel, + placeholderText, + underLined, + disabled, + disableAnimation, + setFocus, + value, + width, + borderColor, + } = props; const filterIcon: IIconProps = { iconName: props.iconName }; const [searchText, setSearchText] = React.useState(value); const rootRef = React.useRef(null); @@ -19,16 +30,19 @@ export const SearchBoxComponent = React.memo((props: ISearchBoxComponentProps) = React.useEffect(() => { value !== searchText && setSearchText(value); - }, [value, searchText]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [value]); function onChangeEvent(ev?: React.ChangeEvent, newValue?: string) { setSearchText(newValue); onChange(ev, newValue); } - const wrapperClass = mergeStyles({ - width: props.width, - }); + const searchboxStyles = React.useMemo(() => { + return { + root: { width: width, ...(borderColor && { borderColor: borderColor }) }, + } as ISearchBoxStyles; + }, [width, borderColor]); React.useEffect(() => { if (setFocus && setFocus !== '' && rootRef) { @@ -38,7 +52,6 @@ export const SearchBoxComponent = React.memo((props: ISearchBoxComponentProps) = } } }, [setFocus, rootRef]); - return ( diff --git a/SearchBox/SearchBox/index.ts b/SearchBox/SearchBox/index.ts index ca35409f..93e0f397 100644 --- a/SearchBox/SearchBox/index.ts +++ b/SearchBox/SearchBox/index.ts @@ -9,6 +9,7 @@ export class SearchBox implements ComponentFramework.ReactControl; notifyOutputChanged: ((debounce?: boolean) => void) | null; + notifyOutputChangedNoDebounce: () => void; searchTextValue: string; defaultValue: string; setFocus = ''; @@ -30,6 +31,7 @@ export class SearchBox implements ComponentFramework.ReactControl, notifyOutputChanged: () => void): void { this.notifyOutputChanged = notifyOutputChanged; + this.notifyOutputChangedNoDebounce = notifyOutputChanged; this.context = context; this.context.mode.trackContainerResize(true); if (this.notifyOutputChanged) { @@ -53,7 +55,7 @@ export class SearchBox implements ComponentFramework.ReactControl Default value to set for the search box. This can be used only once + + Border color + \ No newline at end of file