From dc2fd9559d60315b1ae74e1f284cff40eadb22e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= <20689156+shortcuts@users.noreply.github.com> Date: Mon, 5 Jul 2021 10:58:11 +0200 Subject: [PATCH] feat(ts): use `Partial` exports (#4803) --- src/widgets/answers/answers.tsx | 26 +++---- src/widgets/breadcrumb/breadcrumb.tsx | 26 +++---- .../clear-refinements/clear-refinements.tsx | 16 ++--- .../current-refinements.tsx | 18 ++--- src/widgets/geo-search/geo-search.ts | 34 ++++----- .../hierarchical-menu/hierarchical-menu.tsx | 36 +++++----- src/widgets/hits-per-page/hits-per-page.tsx | 10 +-- src/widgets/hits/hits.tsx | 20 +++--- src/widgets/infinite-hits/infinite-hits.tsx | 32 ++++----- src/widgets/menu-select/menu-select.tsx | 20 +++--- src/widgets/menu/menu.tsx | 32 ++++----- src/widgets/numeric-menu/numeric-menu.tsx | 26 +++---- src/widgets/pagination/pagination.tsx | 40 +++++------ src/widgets/panel/panel.tsx | 32 ++++----- src/widgets/powered-by/powered-by.tsx | 10 +-- .../query-rule-custom-data.tsx | 12 ++-- src/widgets/range-input/range-input.tsx | 30 ++++---- src/widgets/range-slider/range-slider.tsx | 8 +-- src/widgets/rating-menu/rating-menu.tsx | 34 ++++----- .../refinement-list/refinement-list.tsx | 72 +++++++++---------- src/widgets/relevant-sort/relevant-sort.tsx | 18 ++--- src/widgets/search-box/search-box.tsx | 32 ++++----- src/widgets/sort-by/sort-by.tsx | 10 +-- src/widgets/stats/stats.tsx | 14 ++-- .../toggle-refinement/toggle-refinement.tsx | 18 ++--- src/widgets/voice-search/voice-search.tsx | 18 ++--- 26 files changed, 322 insertions(+), 322 deletions(-) diff --git a/src/widgets/answers/answers.tsx b/src/widgets/answers/answers.tsx index abe6ecc880..b2dd8de456 100644 --- a/src/widgets/answers/answers.tsx +++ b/src/widgets/answers/answers.tsx @@ -49,11 +49,11 @@ const renderer = ({ ); }; -export type AnswersTemplates = { +export type AnswersTemplates = Partial<{ /** * Template to use for the header. This template will receive an object containing `hits` and `isLoading`. */ - header?: Template<{ + header: Template<{ hits: Hit[]; isLoading: boolean; }>; @@ -61,45 +61,45 @@ export type AnswersTemplates = { /** * Template to use for the loader. */ - loader?: Template; + loader: Template; /** * Template to use for each result. This template will receive an object containing a single record. */ - item?: Template; -}; + item: Template; +}>; -export type AnswersCSSClasses = { +export type AnswersCSSClasses = Partial<{ /** * CSS class to add to the root element of the widget. */ - root?: string | string[]; + root: string | string[]; /** * CSS class to add to the wrapping element when no results. */ - emptyRoot?: string | string[]; + emptyRoot: string | string[]; /** * CSS classes to add to the header. */ - header?: string | string[]; + header: string | string[]; /** * CSS classes to add to the loader. */ - loader?: string | string[]; + loader: string | string[]; /** * CSS class to add to the list of results. */ - list?: string | string[]; + list: string | string[]; /** * CSS class to add to each result. */ - item?: string | string[]; -}; + item: string | string[]; +}>; export type AnswersWidgetParams = { /** diff --git a/src/widgets/breadcrumb/breadcrumb.tsx b/src/widgets/breadcrumb/breadcrumb.tsx index bc7a3d899d..6836221f7d 100644 --- a/src/widgets/breadcrumb/breadcrumb.tsx +++ b/src/widgets/breadcrumb/breadcrumb.tsx @@ -52,54 +52,54 @@ const renderer = ({ ); }; -export type BreadcrumbCSSClasses = { +export type BreadcrumbCSSClasses = Partial<{ /** * CSS class to add to the root element of the widget. */ - root?: string | string[]; + root: string | string[]; /** * CSS class to add to the root element of the widget if there are no refinements. */ - noRefinementRoot?: string | string[]; + noRefinementRoot: string | string[]; /** * CSS class to add to the list element. */ - list?: string | string[]; + list: string | string[]; /** * CSS class to add to the items of the list. The items contains the link and the separator. */ - item?: string | string[]; + item: string | string[]; /** * CSS class to add to the selected item in the list: the last one or the home if there are no refinements. */ - selectedItem?: string | string[]; + selectedItem: string | string[]; /** * CSS class to add to the separator. */ - separator?: string | string[]; + separator: string | string[]; /** * CSS class to add to the links in the items. */ - link?: string | string[]; -}; + link: string | string[]; +}>; -export type BreadcrumbTemplates = { +export type BreadcrumbTemplates = Partial<{ /** * Label of the breadcrumb's first element. */ - home?: Template; + home: Template; /** * Symbol used to separate the elements of the breadcrumb. */ - separator?: Template; -}; + separator: Template; +}>; export type BreadcrumbWidgetParams = { /** diff --git a/src/widgets/clear-refinements/clear-refinements.tsx b/src/widgets/clear-refinements/clear-refinements.tsx index 83de9e8ddf..f0248060a2 100644 --- a/src/widgets/clear-refinements/clear-refinements.tsx +++ b/src/widgets/clear-refinements/clear-refinements.tsx @@ -45,29 +45,29 @@ const renderer = ({ containerNode, cssClasses, renderState, templates }) => ( ); }; -export type ClearRefinementsCSSClasses = { +export type ClearRefinementsCSSClasses = Partial<{ /** * CSS class to add to the wrapper element. */ - root?: string | string[]; + root: string | string[]; /** * CSS class to add to the button of the widget. */ - button?: string | string[]; + button: string | string[]; /** * CSS class to add to the button when there are no refinements. */ - disabledButton?: string | string[]; -}; + disabledButton: string | string[]; +}>; -export type ClearRefinementsTemplates = { +export type ClearRefinementsTemplates = Partial<{ /** * Template for the content of the button */ - resetLabel?: Template; -}; + resetLabel: Template; +}>; export type ClearRefinementsWidgetParams = { /** diff --git a/src/widgets/current-refinements/current-refinements.tsx b/src/widgets/current-refinements/current-refinements.tsx index c915e4c2c1..4969dc622c 100644 --- a/src/widgets/current-refinements/current-refinements.tsx +++ b/src/widgets/current-refinements/current-refinements.tsx @@ -14,42 +14,42 @@ import { import { component } from '../../lib/suit'; import { WidgetFactory } from '../../types'; -export type CurrentRefinementsCSSClasses = { +export type CurrentRefinementsCSSClasses = Partial<{ /** * CSS class to add to the root element. */ - root?: string | string[]; + root: string | string[]; /** * CSS class to add to the list element. */ - list?: string | string[]; + list: string | string[]; /** * CSS class to add to the each item element. */ - item?: string | string[]; + item: string | string[]; /** * CSS class to add to the label element. */ - label?: string | string[]; + label: string | string[]; /** * CSS class to add to the category element. */ - category?: string | string[]; + category: string | string[]; /** * CSS class to add to the categoryLabel element. */ - categoryLabel?: string | string[]; + categoryLabel: string | string[]; /** * CSS class to add to the delete element. */ - delete?: string | string[]; -}; + delete: string | string[]; +}>; export type CurrentRefinementsWidgetParams = { /** diff --git a/src/widgets/geo-search/geo-search.ts b/src/widgets/geo-search/geo-search.ts index a070526ef7..ba7420c361 100644 --- a/src/widgets/geo-search/geo-search.ts +++ b/src/widgets/geo-search/geo-search.ts @@ -21,39 +21,39 @@ import { GeoLoc, Template, WidgetFactory } from '../../types'; const withUsage = createDocumentationMessageGenerator({ name: 'geo-search' }); const suit = component('GeoSearch'); -export type GeoSearchTemplates = { +export type GeoSearchTemplates = Partial<{ /** Template to use for the marker. */ - HTMLMarker?: Template; + HTMLMarker: Template; /** Template for the reset button. */ - reset?: Template; + reset: Template; /** Template for the toggle label. */ - toggle?: Template; + toggle: Template; /** Template for the redo button. */ - redo?: Template; -}; + redo: Template; +}>; export type GeoSearchComponentTemplates = Required; -export type GeoSearchCSSClasses = { +export type GeoSearchCSSClasses = Partial<{ /** The root div of the widget. */ - root?: string | string[]; + root: string | string[]; /** The map container of the widget. */ - map?: string | string[]; + map: string | string[]; /** The control element of the widget. */ - control?: string | string[]; + control: string | string[]; /** The label of the control element. */ - label?: string | string[]; + label: string | string[]; /** The selected label of the control element. */ - selectedLabel?: string | string[]; + selectedLabel: string | string[]; /** The input of the control element. */ - input?: string | string[]; + input: string | string[]; /** The redo search button. */ - redo?: string | string[]; + redo: string | string[]; /** The disabled redo search button. */ - disabledRedo?: string | string[]; + disabledRedo: string | string[]; /** The reset refinement button. */ - reset?: string | string[]; -}; + reset: string | string[]; +}>; export type GeoSearchMarker = { /** diff --git a/src/widgets/hierarchical-menu/hierarchical-menu.tsx b/src/widgets/hierarchical-menu/hierarchical-menu.tsx index 68715fd459..f18602207e 100644 --- a/src/widgets/hierarchical-menu/hierarchical-menu.tsx +++ b/src/widgets/hierarchical-menu/hierarchical-menu.tsx @@ -31,11 +31,11 @@ const withUsage = createDocumentationMessageGenerator({ }); const suit = component('HierarchicalMenu'); -type HierarchicalMenuTemplates = { +type HierarchicalMenuTemplates = Partial<{ /** * Item template, provided with `name`, `count`, `isRefined`, `url` data properties. */ - item?: Template<{ + item: Template<{ name: string; count: number; isRefined: boolean; @@ -44,59 +44,59 @@ type HierarchicalMenuTemplates = { /** * Template used for the show more text, provided with `isShowingMore` data property. */ - showMoreText?: Template<{ isShowingMore: boolean }>; -}; + showMoreText: Template<{ isShowingMore: boolean }>; +}>; -export type HierarchicalMenuCSSClasses = { +export type HierarchicalMenuCSSClasses = Partial<{ /** * CSS class to add to the root element. */ - root?: string | string[]; + root: string | string[]; /** * CSS class to add to the root element when no refinements. */ - noRefinementRoot?: string | string[]; + noRefinementRoot: string | string[]; /** * CSS class to add to the list element. */ - list?: string | string[]; + list: string | string[]; /** * CSS class to add to the child list element. */ - childList?: string | string[]; + childList: string | string[]; /** * CSS class to add to each item element. */ - item?: string | string[]; + item: string | string[]; /** * CSS class to add to each selected item element. */ - selectedItem?: string | string[]; + selectedItem: string | string[]; /** * CSS class to add to each parent item element. */ - parentItem?: string | string[]; + parentItem: string | string[]; /** * CSS class to add to each link (when using the default template). */ - link?: string | string[]; + link: string | string[]; /** * CSS class to add to each label (when using the default template). */ - label?: string | string[]; + label: string | string[]; /** * CSS class to add to each count element (when using the default template). */ - count?: string | string[]; + count: string | string[]; /** * CSS class to add to the show more element. */ - showMore?: string | string[]; + showMore: string | string[]; /** * CSS class to add to the disabled show more element. */ - disabledShowMore?: string | string[]; -}; + disabledShowMore: string | string[]; +}>; export type HierarchicalMenuComponentCSSClasses = ComponentCSSClasses< HierarchicalMenuCSSClasses diff --git a/src/widgets/hits-per-page/hits-per-page.tsx b/src/widgets/hits-per-page/hits-per-page.tsx index 8f2acec743..f036236bf1 100644 --- a/src/widgets/hits-per-page/hits-per-page.tsx +++ b/src/widgets/hits-per-page/hits-per-page.tsx @@ -43,22 +43,22 @@ const renderer = ({ containerNode, cssClasses }) => ( ); }; -export type HitsPerPageCSSClasses = { +export type HitsPerPageCSSClasses = Partial<{ /** * CSS classes added to the outer `
`. */ - root?: string | string[]; + root: string | string[]; /** * CSS classes added to the parent ``. */ - select?: string | string[]; + select: string | string[]; /** * CSS classes added to each `