-
Notifications
You must be signed in to change notification settings - Fork 481
/
Copy path1200.7b6f46087b4d874f.js
1 lines (1 loc) · 2.68 KB
/
1200.7b6f46087b4d874f.js
1
(self.webpackChunkdemo=self.webpackChunkdemo||[]).push([[1200],{1200:e=>{e.exports="import {NgIf} from '@angular/common';\nimport {Component} from '@angular/core';\nimport {changeDetection} from '@demo/emulate/change-detection';\nimport {encapsulation} from '@demo/emulate/encapsulation';\nimport {TuiDay, TuiDayRange} from '@taiga-ui/cdk';\nimport {TuiLink} from '@taiga-ui/core';\nimport {TuiCalendarRange, TuiDayRangePeriod} from '@taiga-ui/kit';\n\nconst today = TuiDay.currentLocal();\nconst startOfWeek = today.append({day: -today.dayOfWeek()});\nconst startOfMonth = today.append({day: 1 - today.day});\nconst startOfQuarter = startOfMonth.append({month: -(startOfMonth.month % 3)});\n\n@Component({\n standalone: true,\n exportAs: \"Example5\",\n imports: [NgIf, TuiCalendarRange, TuiLink],\n templateUrl: './index.html',\n encapsulation,\n changeDetection,\n})\nexport default class Example {\n protected readonly items = [\n new TuiDayRangePeriod(\n new TuiDayRange(today.append({day: -30}), today),\n 'Default',\n ),\n new TuiDayRangePeriod(new TuiDayRange(startOfWeek, today), 'Week'),\n new TuiDayRangePeriod(new TuiDayRange(startOfMonth, today), 'Month'),\n new TuiDayRangePeriod(new TuiDayRange(startOfQuarter, today), 'Quarter'),\n ];\n\n protected selected: TuiDayRangePeriod | null = this.default;\n protected value: TuiDayRange | null = this.default.range;\n\n public get default(): TuiDayRangePeriod {\n return this.items[0]!;\n }\n\n public get isDefault(): boolean {\n return this.selected === this.default;\n }\n\n public get isSelected(): boolean {\n return !!this.items.find((item) => item === this.selected);\n }\n\n public get isLastVisible(): boolean {\n return this.selected === this.items[this.items.length - 1];\n }\n\n public get opposite(): TuiDayRangePeriod | null {\n if (!this.isSelected) {\n return null;\n }\n\n switch (this.selected) {\n case this.default:\n return null;\n case this.items[1]:\n return this.items[2]!;\n case this.items[2]:\n return this.items[3]!;\n case this.items[3]:\n return null;\n default:\n return null;\n }\n }\n\n public onValue(value: TuiDayRange | null): void {\n this.value = value;\n }\n\n public reset(): void {\n this.selected = this.default;\n this.value = this.selected.range;\n }\n\n public toggle(): void {\n this.selected = this.opposite;\n this.value = this.selected?.range ?? null;\n }\n}\n"}}]);