From a32ae1f29afcc6e907bf6524f914f4b89d70b824 Mon Sep 17 00:00:00 2001 From: Flavien Normand Date: Tue, 14 Jan 2025 11:40:01 +0100 Subject: [PATCH] docs(date-range): add premade shortcuts story --- .../forms/date2/date-range-input.stories.ts | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/stories/documentation/forms/date2/date-range-input.stories.ts b/stories/documentation/forms/date2/date-range-input.stories.ts index af6b47d76b..0bc4dac090 100644 --- a/stories/documentation/forms/date2/date-range-input.stories.ts +++ b/stories/documentation/forms/date2/date-range-input.stories.ts @@ -1,6 +1,6 @@ import { LOCALE_ID } from '@angular/core'; import { FormsModule } from '@angular/forms'; -import { DateRangeInputComponent } from '@lucca-front/ng/date2'; +import { CalendarShortcut, DateRangeInputComponent, PremadeShortcuts } from '@lucca-front/ng/date2'; import { FormFieldComponent } from '@lucca-front/ng/form-field'; import { applicationConfig, Meta, moduleMetadata, StoryObj } from '@storybook/angular'; import { cleanupTemplate, generateInputs } from '../../../helpers/stories'; @@ -53,6 +53,52 @@ export default { } as Meta; export const Basic: StoryObj = { + args: { + hideToday: false, + hideWeekend: false, + clearable: false, + mode: 'day', + }, +}; + +const shortcutsStr = + "[\n {\n label: 'Since start of week',\n range: PremadeShortcuts['SinceStartOfWeek']('fr'),\n },\n {\n label: 'Last week',\n range: PremadeShortcuts['LastWeek']('fr'),\n },\n {\n label: 'Last month',\n range: PremadeShortcuts['LastMonth']('fr'),\n },\n]"; + +export const WithShortcuts: StoryObj = { + render: (args: any, { argTypes }) => { + const { min, max, selected, ...flags } = args; + return { + props: { + min: min ? new Date(min) : null, + max: max ? new Date(max) : null, + shortcuts: [ + { + label: 'Since start of week', + range: PremadeShortcuts['SinceStartOfWeek']('fr'), + }, + { + label: 'Last week', + range: PremadeShortcuts['LastWeek']('fr'), + }, + { + label: 'Last month', + range: PremadeShortcuts['LastMonth']('fr'), + }, + ] as CalendarShortcut[], + shortcutsStr, + }, + + template: cleanupTemplate(` + + + + + {{selected | json}} + +

Shortcuts:

+
{{shortcutsStr}}
`), + }; + }, args: { hideToday: false,