Skip to content

Commit

Permalink
feat(ts): use Partial exports (algolia#4803)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts authored Jul 5, 2021
1 parent 4d1d0c4 commit dc2fd95
Show file tree
Hide file tree
Showing 26 changed files with 322 additions and 322 deletions.
26 changes: 13 additions & 13 deletions src/widgets/answers/answers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,57 +49,57 @@ 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;
}>;

/**
* 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<Hit>;
};
item: Template<Hit>;
}>;

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 = {
/**
Expand Down
26 changes: 13 additions & 13 deletions src/widgets/breadcrumb/breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
/**
Expand Down
16 changes: 8 additions & 8 deletions src/widgets/clear-refinements/clear-refinements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
/**
Expand Down
18 changes: 9 additions & 9 deletions src/widgets/current-refinements/current-refinements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
/**
Expand Down
34 changes: 17 additions & 17 deletions src/widgets/geo-search/geo-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<GeoHit>;
HTMLMarker: Template<GeoHit>;
/** 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<GeoSearchTemplates>;

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<TOptions> = {
/**
Expand Down
36 changes: 18 additions & 18 deletions src/widgets/hierarchical-menu/hierarchical-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Loading

0 comments on commit dc2fd95

Please sign in to comment.