Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: optimize document api usage #548

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/beige-bananas-grin-233.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@alauda/ui': minor
---

- [BREAKING CHANGE] refactor: remove unnecessary exports
2 changes: 1 addition & 1 deletion src/anchor/anchor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
tap,
} from 'rxjs';

import { buildBem, isTemplateRef, last } from '../utils';
import { buildBem, isTemplateRef, last } from '../internal/utils';

import { AnchorDirectiveChild } from './anchor.directive';
import { AnchorItem, AnchorTreeItem } from './types';
Expand Down
2 changes: 1 addition & 1 deletion src/anchor/anchor.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '@angular/core';
import { Subject, fromEvent, merge, startWith, takeUntil } from 'rxjs';

import { observeResizeOn } from '../utils';
import { observeResizeOn } from '../internal/utils';

import { AnchorComponent } from './anchor.component';

Expand Down
2 changes: 1 addition & 1 deletion src/anchor/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { last } from '../utils';
import { last } from '../internal/utils';

import { AnchorItem, AnchorTreeItem } from './types';

Expand Down
2 changes: 1 addition & 1 deletion src/autocomplete/autocomplete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
withLatestFrom,
} from 'rxjs';

import { publishRef } from '../utils';
import { publishRef } from '../internal/utils';

import { AutocompletePlaceholderComponent } from './autocomplete-placeholder.component';
import { AutoCompleteDirective } from './autocomplete.directive';
Expand Down
2 changes: 1 addition & 1 deletion src/autocomplete/autocomplete.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import {
distinctUntilChanged,
} from 'rxjs';

import { scrollIntoView } from '../internal/utils';
import { BaseTooltip, TooltipTrigger, TooltipType } from '../tooltip';
import { AnimationType } from '../tooltip/animations';
import { scrollIntoView } from '../utils';

import { AutocompleteComponent } from './autocomplete.component';
import { AutoCompleteContext, SuggestionFilterFn } from './autocomplete.types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@angular/core';
import { Observable, combineLatest, of, map, startWith, switchMap } from 'rxjs';

import { publishRef } from '../../utils';
import { publishRef } from '../../internal/utils';
import { SuggestionComponent } from '../suggestion/suggestion.component';

@Component({
Expand Down
7 changes: 6 additions & 1 deletion src/autocomplete/suggestion/suggestion.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import {
tap,
} from 'rxjs';

import { Bem, buildBem, coerceAttrBoolean, publishRef } from '../../utils';
import {
Bem,
buildBem,
coerceAttrBoolean,
publishRef,
} from '../../internal/utils';
import { AutocompleteComponent } from '../autocomplete.component';

@Component({
Expand Down
2 changes: 1 addition & 1 deletion src/button/button.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, DebugElement } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';

import { ComponentSize } from '../types';
import { ComponentSize } from '../internal/types';

import { ButtonComponent } from './button.component';
import { ButtonType } from './button.types';
Expand Down
2 changes: 1 addition & 1 deletion src/button/button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@angular/core';

import { IconComponent } from '../icon/icon.component';
import { ComponentSize } from '../types';
import { ComponentSize } from '../internal/types';

import { ButtonType } from './button.types';

Expand Down
2 changes: 1 addition & 1 deletion src/button/button.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ValueOf } from '../types';
import { ValueOf } from '../internal/types';

export const ButtonType = {
Default: 'default',
Expand Down
2 changes: 1 addition & 1 deletion src/date-picker/calendar/header/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import dayjs, { ConfigType, Dayjs } from 'dayjs';
import { ButtonComponent } from '../../../button/button.component';
import { I18nPipe } from '../../../i18n/i18n.pipe';
import { IconComponent } from '../../../icon/icon.component';
import { buildBem } from '../../../utils';
import { buildBem } from '../../../internal/utils';
import {
CalendarHeaderRange,
DateNavRange,
Expand Down
2 changes: 1 addition & 1 deletion src/date-picker/calendar/panel/picker-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import isBetween from 'dayjs/plugin/isBetween';

import { ButtonComponent } from '../../../button/button.component';
import { I18nPipe } from '../../../i18n/i18n.pipe';
import { buildBem } from '../../../utils';
import { buildBem } from '../../../internal/utils';
import { DateNavRange } from '../../date-picker.type';
import {
DAY,
Expand Down
2 changes: 1 addition & 1 deletion src/date-picker/calendar/range-picker-panel/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import dayjs, { Dayjs } from 'dayjs';

import { CommonFormControl } from '../../../form/common-form';
import { I18nPipe } from '../../../i18n/i18n.pipe';
import { buildBem } from '../../../internal/utils';
import { TimePickerComponent } from '../../../time-picker/component';
import { TimePickerModel } from '../../../time-picker/time-picker.type';
import { buildBem } from '../../../utils';
import { DateNavRange, DisabledTimeFn, Side } from '../../date-picker.type';
import { DatePickerType, MONTH, YEAR } from '../constant';
import { CalendarFooterComponent } from '../footer/component';
Expand Down
2 changes: 1 addition & 1 deletion src/date-picker/date-picker/date-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
import dayjs, { ConfigType, Dayjs } from 'dayjs';

import { CommonFormControl } from '../../form/common-form';
import { ComponentSize } from '../../internal/types';
import { TooltipDirective } from '../../tooltip/tooltip.directive';
import { ComponentSize } from '../../types';
import { DatePickerType } from '../calendar/constant';
import { DatePickerPanelComponent } from '../calendar/date-picker-panel/component';
import { DateNavRange, DisabledTimeFn } from '../date-picker.type';
Expand Down
2 changes: 1 addition & 1 deletion src/date-picker/range-picker/range-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
import dayjs, { ConfigType, Dayjs } from 'dayjs';

import { CommonFormControl } from '../../form';
import { ComponentSize } from '../../internal/types';
import { TooltipDirective } from '../../tooltip/tooltip.directive';
import { ComponentSize } from '../../types';
import { DateRangePickerPanelComponent } from '../calendar/range-picker-panel/component';
import { DisabledDateFn, DisabledTimeFn } from '../date-picker.type';
import { DatePickerTriggerComponent } from '../trigger/trigger.component';
Expand Down
4 changes: 2 additions & 2 deletions src/date-picker/trigger/trigger.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { Dayjs } from 'dayjs';
import { I18nPipe } from '../../i18n/i18n.pipe';
import { IconComponent } from '../../icon/icon.component';
import { InputComponent } from '../../input/input.component';
import { ComponentSize } from '../../types';
import { buildBem } from '../../utils';
import { ComponentSize } from '../../internal/types';
import { buildBem } from '../../internal/utils';

const bem = buildBem('aui-date-picker-trigger');

Expand Down
2 changes: 1 addition & 1 deletion src/dialog/confirm-dialog/confirm-dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { firstValueFrom, Observable } from 'rxjs';

import { ButtonComponent } from '../../button/button.component';
import { IconComponent } from '../../icon/icon.component';
import { Bem, buildBem, isString, isTemplateRef } from '../../utils';
import { Bem, buildBem, isString, isTemplateRef } from '../../internal/utils';
import { DialogRef } from '../dialog-ref';
import {
BeforeAction,
Expand Down
2 changes: 1 addition & 1 deletion src/dialog/dialog-animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@angular/animations';

import { AnimationDuration } from '../core/animation/animation-consts';
import { getAnimationQueryMetadatas } from '../utils/animations';
import { getAnimationQueryMetadatas } from '../internal/utils/animations';

export const ZOOM_CLASS_NAME_MAP = {
enter: 'aui-zoom-enter',
Expand Down
2 changes: 1 addition & 1 deletion src/dialog/dialog-content/dialog-content.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ViewEncapsulation,
} from '@angular/core';

import { Bem, buildBem } from '../../utils';
import { Bem, buildBem } from '../../internal/utils';

@Component({
selector: 'aui-dialog-content',
Expand Down
2 changes: 1 addition & 1 deletion src/dialog/dialog-content/dialog-footer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ViewEncapsulation,
} from '@angular/core';

import { Bem, buildBem } from '../../utils';
import { Bem, buildBem } from '../../internal/utils';

@Component({
selector: 'aui-dialog-footer',
Expand Down
2 changes: 1 addition & 1 deletion src/dialog/dialog-content/dialog-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@angular/core';

import { IconComponent } from '../../icon/icon.component';
import { Bem, buildBem } from '../../utils';
import { Bem, buildBem } from '../../internal/utils';
import { DialogRef } from '../dialog-ref';
import { DialogService } from '../dialog.service';
import { getClosestDialog } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion src/dialog/dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { debounceTime, filter, fromEvent } from 'rxjs';

import { Bem, buildBem, getElementOffset } from '../utils';
import { Bem, buildBem, getElementOffset } from '../internal/utils';

import {
dialogAnimations,
Expand Down
2 changes: 1 addition & 1 deletion src/drawer/component/internal/internal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { BehaviorSubject, Subject } from 'rxjs';

import { TimingFunction } from '../../../core/animation/animation-consts';
import { IconComponent } from '../../../icon/icon.component';
import { handlePixel, isTemplateRef } from '../../../utils';
import { handlePixel, isTemplateRef } from '../../../internal/utils';
import { DrawerOptions, DrawerSize } from '../../types';

export const DATA = new InjectionToken('drawer-data');
Expand Down
2 changes: 1 addition & 1 deletion src/drawer/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentType } from '@angular/cdk/portal';
import { TemplateRef } from '@angular/core';

import { ValueOf } from '../types';
import { ValueOf } from '../internal/types';

export const DrawerSize = {
Small: 'small',
Expand Down
4 changes: 2 additions & 2 deletions src/dropdown/dropdown-button/dropdown-button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { Observable, map, startWith } from 'rxjs';
import { ButtonType } from '../../button';
import { ButtonComponent } from '../../button/button.component';
import { IconComponent } from '../../icon/icon.component';
import { ComponentSize } from '../../types';
import { Bem, buildBem, coerceAttrBoolean } from '../../utils';
import { ComponentSize } from '../../internal/types';
import { Bem, buildBem, coerceAttrBoolean } from '../../internal/utils';
import { DropdownDirective } from '../dropdown.directive';
import { MenuItemComponent } from '../menu-item/menu-item.component';

Expand Down
2 changes: 1 addition & 1 deletion src/dropdown/dropdown.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ValueOf } from '../types';
import { ValueOf } from '../internal/types';

export const MenuItemType = {
Default: 'default',
Expand Down
2 changes: 1 addition & 1 deletion src/dropdown/menu-item/menu-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ViewEncapsulation,
} from '@angular/core';

import { Bem, buildBem } from '../../utils';
import { Bem, buildBem } from '../../internal/utils';
import { MenuItemType } from '../dropdown.types';

@Component({
Expand Down
4 changes: 2 additions & 2 deletions src/dropdown/menu/menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
ViewEncapsulation,
} from '@angular/core';

import { ComponentSize } from '../../types';
import { Bem, buildBem } from '../../utils';
import { ComponentSize } from '../../internal/types';
import { Bem, buildBem } from '../../internal/utils';

@Component({
selector: 'aui-menu',
Expand Down
4 changes: 2 additions & 2 deletions src/dropdown/submenu/submenu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
} from '@angular/core';

import { IconComponent } from '../../icon/icon.component';
import { ComponentSize } from '../../internal/types';
import { Bem, buildBem } from '../../internal/utils';
import { TooltipTrigger } from '../../tooltip';
import { TooltipActiveDirective } from '../../tooltip/tooltip-active.directive';
import { TooltipDirective } from '../../tooltip/tooltip.directive';
import { ComponentSize } from '../../types';
import { Bem, buildBem } from '../../utils';
import { MenuComponent } from '../menu/menu.component';
import { MenuItemComponent } from '../menu-item/menu-item.component';

Expand Down
2 changes: 1 addition & 1 deletion src/form/common-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { ControlValueAccessor } from '@angular/forms';
import { ReplaySubject } from 'rxjs';

import { coerceAttrBoolean } from '../utils';
import { coerceAttrBoolean } from '../internal/utils';

/**
* form control 内部不保持 value 属性,当不使用 ngModel 时可以通过 [(value)] 实现双向绑定;
Expand Down
2 changes: 1 addition & 1 deletion src/form/form-item/form-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
takeUntil,
} from 'rxjs';

import { Bem, buildBem, publishRef } from '../../utils';
import { Bem, buildBem, publishRef } from '../../internal/utils';
import { FormDirective } from '../form.directive';
import { FormItemWidth, LabelPosition } from '../form.types';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/form/form.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ValueOf } from '../types';
import { ValueOf } from '../internal/types';

export const LabelPosition = {
Top: 'top',
Expand Down
2 changes: 1 addition & 1 deletion src/form/helper-directives.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Directive, Input } from '@angular/core';

import { coerceAttrBoolean } from '../utils';
import { coerceAttrBoolean } from '../internal/utils';

@Directive({
selector: 'label[auiFormItemLabel]',
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/i18n.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
import { Subject, takeUntil } from 'rxjs';

import { I18nService } from './i18n.service';
import { StringMap } from './i18n.type';

@Pipe({
name: 'auiI18n',
Expand All @@ -26,7 +25,7 @@ export class I18nPipe implements PipeTransform, OnDestroy {
.subscribe(() => this.cdr.markForCheck());
}

transform(value: any, data?: StringMap) {
transform(value: any, data?: Record<string, string>) {
return this.i18n.translate(value, data);
}

Expand Down
8 changes: 6 additions & 2 deletions src/i18n/i18n.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject, Injectable, isDevMode } from '@angular/core';
import { BehaviorSubject, Observable, map } from 'rxjs';

import { I18NInterface, I18NInterfaceToken, StringMap } from './i18n.type';
import { I18NInterface, I18NInterfaceToken } from './i18n.type';

@Injectable({
providedIn: 'root',
Expand All @@ -27,7 +27,11 @@ export class I18nService {
return this._i18n;
}

translate(key: string, data?: StringMap, ignoreNonExist = false) {
translate(
key: string,
data?: Record<string, string>,
ignoreNonExist = false,
) {
let content = this._i18n.translation[key];
if (content == null) {
if (isDevMode() && !ignoreNonExist) {
Expand Down
2 changes: 0 additions & 2 deletions src/i18n/i18n.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ export interface I18NInterface {
translation: Record<string, string>;
}

export type StringMap = Record<string, string>;

export const I18NInterfaceToken = new InjectionToken('i18n token', {
factory: () => en,
});
2 changes: 1 addition & 1 deletion src/icon/icon.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
ViewEncapsulation,
} from '@angular/core';

import { Bem, buildBem, handlePixel } from '../internal/utils';
import { ThemePickerPipe } from '../theme/theme.pipe';
import { Bem, buildBem, handlePixel } from '../utils';

import { IconRegisterService } from './icon-register.service';

Expand Down
15 changes: 13 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ export * from './i18n';
export * from './icon';
export * from './inline-alert';
export * from './input';
export { ComponentSize } from './internal/types';
export {
AttrBoolean,
Bem,
buildBem,
coerceAttrBoolean,
coerceString,
getCompatibleStylesRenderer,
handlePixel,
isTemplateRef,
observeMutationOn,
observeResizeOn,
} from './internal/utils';
export * from './message';
export * from './notification';
export * from './paginator';
Expand All @@ -34,5 +47,3 @@ export * from './theme';
export * from './time-picker';
export * from './tooltip';
export * from './tree-select';
export * from './types';
export * from './utils';
Loading
Loading