Skip to content

Commit

Permalink
Suppress import cycle between templates/options
Browse files Browse the repository at this point in the history
  • Loading branch information
Xon committed Aug 31, 2024
1 parent 59525d2 commit 1801a04
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions public/types/src/scripts/interfaces/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { InputChoice } from './input-choice';
import { ClassNames } from './class-names';
import { PositionOptionsType } from './position-options-type';
import { Types } from './types';
import { Templates } from './templates';
import { CallbackOnCreateTemplatesFn } from './templates';
export declare const ObjectsInConfig: string[];
/**
* Choices options interface
Expand Down Expand Up @@ -537,7 +537,7 @@ export interface Options {
* @example
* ```
* const example = new Choices(element, {
* callbackOnCreateTemplates: function (template, originalTemplates) {
* callbackOnCreateTemplates: function (template, originalTemplates, getClassNames) {
* var classNames = this.config.classNames;
* return {
* item: (data) => {
Expand All @@ -561,6 +561,6 @@ export interface Options {
*
* @default null
*/
callbackOnCreateTemplates: ((template: Types.StrToEl, escapeForTemplate: Types.EscapeForTemplateFn, getClassNames: Types.GetClassNamesFn) => Partial<Templates>) | null;
callbackOnCreateTemplates: CallbackOnCreateTemplatesFn | null;
appendGroupInSearch: false;
}
1 change: 1 addition & 0 deletions public/types/src/scripts/interfaces/templates.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export declare const NoticeTypes: {
readonly generic: "";
};
export type NoticeType = Types.ValueOf<typeof NoticeTypes>;
export type CallbackOnCreateTemplatesFn = (template: Types.StrToEl, escapeForTemplate: Types.EscapeForTemplateFn, getClassNames: Types.GetClassNamesFn) => Partial<Templates>;
export interface Templates {
containerOuter(options: TemplateOptions, dir: HTMLElement['dir'], isSelectElement: boolean, isSelectOneElement: boolean, searchEnabled: boolean, passedElementType: PassedElementType, labelId: string): HTMLDivElement;
containerInner({ classNames: { containerInner } }: TemplateOptions): HTMLDivElement;
Expand Down
7 changes: 4 additions & 3 deletions src/scripts/interfaces/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { InputChoice } from './input-choice';
import { ClassNames } from './class-names';
import { PositionOptionsType } from './position-options-type';
import { Types } from './types';
import { Templates } from './templates';
// eslint-disable-next-line import/no-cycle
import { CallbackOnCreateTemplatesFn } from './templates';

export const ObjectsInConfig: string[] = ['fuseOptions', 'classNames'];

Expand Down Expand Up @@ -588,7 +589,7 @@ export interface Options {
* @example
* ```
* const example = new Choices(element, {
* callbackOnCreateTemplates: function (template, originalTemplates) {
* callbackOnCreateTemplates: function (template, originalTemplates, getClassNames) {
* var classNames = this.config.classNames;
* return {
* item: (data) => {
Expand All @@ -612,7 +613,7 @@ export interface Options {
*
* @default null
*/
callbackOnCreateTemplates: ((template: Types.StrToEl, escapeForTemplate: Types.EscapeForTemplateFn, getClassNames: Types.GetClassNamesFn) => Partial<Templates>) | null;
callbackOnCreateTemplates: CallbackOnCreateTemplatesFn | null;

appendGroupInSearch: false;
}
8 changes: 7 additions & 1 deletion src/scripts/interfaces/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PassedElementType } from './passed-element-type';
import { StringPreEscaped } from './string-pre-escaped';
import { ChoiceFull } from './choice-full';
import { GroupFull } from './group-full';

// eslint-disable-next-line import/no-cycle
import { Options } from './options';
import { Types } from './types';

Expand All @@ -25,6 +25,12 @@ export const NoticeTypes = {
} as const;
export type NoticeType = Types.ValueOf<typeof NoticeTypes>;

export type CallbackOnCreateTemplatesFn = (
template: Types.StrToEl,
escapeForTemplate: Types.EscapeForTemplateFn,
getClassNames: Types.GetClassNamesFn,
) => Partial<Templates>;

export interface Templates {
containerOuter(
options: TemplateOptions,
Expand Down

0 comments on commit 1801a04

Please sign in to comment.