-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react instantsearch widget): add connector and widget metadata (a…
- Loading branch information
Showing
6 changed files
with
64 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
src/templates/React InstantSearch widget/src/lib/widget.tsx.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { {{ pascalCaseName }}Component } from './component'; | ||
import { connect{{ pascalCaseName }} } from './connector'; | ||
|
||
import type { ElementType } from 'react'; | ||
|
||
type WidgetParams = { | ||
/** | ||
* Placeholder text for input element. | ||
*/ | ||
placeholder?: string; | ||
}; | ||
|
||
export const {{ pascalCaseName }}: ElementType<WidgetParams> = | ||
connect{{ pascalCaseName }}({{ pascalCaseName }}Component); | ||
export const {{ pascalCaseName }}: React.ElementType<WidgetParams> = connect{{ pascalCaseName }}( | ||
{{ pascalCaseName }}Component, | ||
{ $$widgetType: '{{ widgetType }}' } | ||
); |
17 changes: 17 additions & 0 deletions
17
src/templates/React InstantSearch widget/src/types/connector.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { | ||
ConnectedComponentClass, | ||
ConnectorProvided, | ||
} from 'react-instantsearch-core'; | ||
|
||
type AdditionalWidgetProperties = { | ||
$$widgetType?: string; | ||
}; | ||
|
||
export type Connector<TProvided = {}, TExposed = {}> = (( | ||
stateless: React.FunctionComponent<ConnectorProvided<TProvided>>, | ||
additionalWidgetProperties: AdditionalWidgetProperties | ||
) => React.ComponentClass<TExposed>) & | ||
(<TProps extends Partial<ConnectorProvided<TProvided>>>( | ||
Composed: React.ComponentType<TProps>, | ||
additionalWidgetProperties: AdditionalWidgetProperties | ||
) => ConnectedComponentClass<TProps, ConnectorProvided<TProvided>, TExposed>); |