Skip to content

Commit

Permalink
fix(kit): fix by review
Browse files Browse the repository at this point in the history
  • Loading branch information
WoodenPC authored and nsbarsukov committed Jul 20, 2023
1 parent a3376a3 commit 2cc73ff
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('DateRange | CustomRangeSeparator', () => {
.as('input');
});

it.only('14.12.1997~09.07.2015', () => {
it('14.12.1997~09.07.2015', () => {
cy.get('@input')
.type('14121997972015')
.should('have.value', '14.12.1997~09.07.2015');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import {
MaskitoDateSegments,
} from '@maskito/kit';
import {TuiDocExample} from '@taiga-ui/addon-doc';
import {CHAR_EN_DASH, CHAR_NO_BREAK_SPACE, tuiPure} from '@taiga-ui/cdk';
import {DEFAULT_DATE_RANGE_SEPARATOR} from 'projects/kit/src/lib/masks/date-range';
import {tuiPure} from '@taiga-ui/cdk';

type GeneratorOptions = Required<
NonNullable<Parameters<typeof maskitoDateRangeOptionsGenerator>[0]>
Expand Down Expand Up @@ -66,15 +65,17 @@ export class DateRangeMaskDocComponent implements GeneratorOptions {
max = new Date(this.maxStr);
minLength: Partial<MaskitoDateSegments<number>> = {};
maxLength: Partial<MaskitoDateSegments<number>> = {};
rangeSeparator = DEFAULT_DATE_RANGE_SEPARATOR;
rangeSeparator = ' – ';

maskitoOptions: MaskitoOptions = maskitoDateRangeOptionsGenerator(this);

@tuiPure
getPlaceholder(mode: MaskitoDateMode, separator: string): string {
const datesSep = `${CHAR_NO_BREAK_SPACE}${CHAR_EN_DASH}${CHAR_NO_BREAK_SPACE}`;

return `${mode.replace(/\//g, separator)}${datesSep}${mode.replace(
getPlaceholder(
mode: MaskitoDateMode,
separator: string,
rangeSeparator: string,
): string {
return `${mode.replace(/\//g, separator)}${rangeSeparator}${mode.replace(
/\//g,
separator,
)}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@
<ng-template>
<tui-input
tuiTextfieldCustomContent="tuiIconCalendarLarge"
[tuiTextfieldFiller]="getPlaceholder(mode, separator)"
[tuiTextfieldFiller]="
getPlaceholder(mode, separator, rangeSeparator)
"
[formControl]="apiPageControl"
>
Enter dates
Expand Down Expand Up @@ -172,7 +174,7 @@
[(documentationPropertyValue)]="rangeSeparator"
(documentationPropertyValueChange)="updateOptions()"
>
Range separator
Separator between dates of the date range.
<p>
<strong>Default:</strong>
<code> – </code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import mask from './mask';
template: `
<tui-input
tuiTextfieldCustomContent="tuiIconCalendarLarge"
[tuiHintContent]="hint"
[tuiTextfieldLabelOutside]="true"
[tuiTextfieldFiller]="filler"
[style.max-width.rem]="30"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@ import {maskitoDateRangeOptionsGenerator} from '@maskito/kit';

export default maskitoDateRangeOptionsGenerator({
mode: 'dd/mm/yyyy',
minLength: {day: 3},
maxLength: {month: 1},
rangeSeparator: ' ~ ',
});
4 changes: 1 addition & 3 deletions projects/kit/src/lib/masks/date-range/date-range-mask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ import {MaskitoDateMode, MaskitoDateSegments} from '../../types';
import {createMinMaxRangeLengthPostprocessor} from './processors/min-max-range-length-postprocessor';
import {createSwapDatesPostprocessor} from './processors/swap-dates-postprocessor';

export const DEFAULT_DATE_RANGE_SEPARATOR = `${CHAR_NO_BREAK_SPACE}${CHAR_EN_DASH}${CHAR_NO_BREAK_SPACE}`;

export function maskitoDateRangeOptionsGenerator({
mode,
separator = '.',
min,
max,
minLength,
maxLength,
rangeSeparator = DEFAULT_DATE_RANGE_SEPARATOR,
rangeSeparator = `${CHAR_NO_BREAK_SPACE}${CHAR_EN_DASH}${CHAR_NO_BREAK_SPACE}`,
}: {
mode: MaskitoDateMode;
separator?: string;
Expand Down

0 comments on commit 2cc73ff

Please sign in to comment.