willba-component-library 0.2.8 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/components/FilterBar/FilterBar.d.ts +2 -15
- package/lib/components/FilterBar/FilterBarTypes.d.ts +14 -3
- package/lib/components/FilterBar/components/buttons/index.d.ts +2 -2
- package/lib/components/FilterBar/components/index.d.ts +0 -1
- package/lib/components/FilterBar/hooks/index.d.ts +0 -2
- package/lib/components/FilterBar/utils/index.d.ts +0 -1
- package/lib/components/FilterCalendar/FilterCalendar.d.ts +5 -0
- package/lib/components/FilterCalendar/FilterCalendar.stories.d.ts +6 -0
- package/lib/components/FilterCalendar/FilterCalendarTypes.d.ts +8 -0
- package/lib/components/FilterCalendar/hooks/useFilterCalendar.d.ts +14 -0
- package/lib/components/FilterCalendar/index.d.ts +2 -0
- package/lib/core/components/buttons/close-button/CloseButton.d.ts +7 -0
- package/lib/core/components/buttons/submit-button/SubmitButton.d.ts +10 -0
- package/lib/core/components/calendar/Calendar.d.ts +5 -0
- package/lib/core/components/calendar/CalendarTypes.d.ts +15 -0
- package/lib/core/components/index.d.ts +3 -0
- package/lib/core/hooks/index.d.ts +3 -0
- package/lib/core/hooks/useAwaitRender.d.ts +1 -0
- package/lib/core/hooks/useCloseFilterSection.d.ts +8 -0
- package/lib/core/hooks/useUpdateTranslations.d.ts +5 -0
- package/lib/core/utils/index.d.ts +3 -0
- package/lib/core/utils/nightsCount.d.ts +6 -0
- package/lib/core/utils/parseDate.d.ts +6 -0
- package/lib/core/utils/parseDates.d.ts +6 -0
- package/lib/index.d.ts +40 -19
- package/lib/index.esm.js +6152 -6053
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +6151 -6051
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +6151 -6051
- package/lib/index.umd.js.map +1 -1
- package/lib/themes/useTheme.d.ts +4 -4
- package/package.json +1 -1
- package/src/components/FilterBar/FilterBar.tsx +20 -44
- package/src/components/FilterBar/FilterBarTypes.ts +16 -4
- package/src/components/FilterBar/components/buttons/index.ts +3 -2
- package/src/components/FilterBar/components/buttons/tab-button/TabButton.tsx +1 -1
- package/src/components/FilterBar/components/index.ts +0 -1
- package/src/components/FilterBar/hooks/index.ts +0 -2
- package/src/components/FilterBar/utils/index.tsx +0 -1
- package/src/components/FilterCalendar/FilterCalendar.css +67 -0
- package/src/components/FilterCalendar/FilterCalendar.stories.tsx +48 -0
- package/src/components/FilterCalendar/FilterCalendar.tsx +112 -0
- package/src/components/FilterCalendar/FilterCalendarTypes.ts +10 -0
- package/src/components/FilterCalendar/hooks/useFilterCalendar.ts +29 -0
- package/src/components/FilterCalendar/index.ts +3 -0
- package/src/{components/FilterBar → core}/components/buttons/submit-button/SubmitButton.css +6 -0
- package/src/core/components/buttons/submit-button/SubmitButton.tsx +28 -0
- package/src/{components/FilterBar → core}/components/calendar/Calendar.css +1 -12
- package/src/{components/FilterBar → core}/components/calendar/Calendar.tsx +15 -21
- package/src/core/components/calendar/CalendarTypes.ts +17 -0
- package/src/core/components/index.ts +4 -0
- package/src/core/hooks/index.ts +3 -0
- package/src/core/hooks/useAwaitRender.tsx +12 -0
- package/src/{components/FilterBar → core}/hooks/useCloseFilterSection.tsx +1 -0
- package/src/{components/FilterBar → core}/hooks/useUpdateTranslations.tsx +1 -1
- package/src/core/utils/index.ts +3 -0
- package/src/core/utils/nightsCount.tsx +19 -0
- package/src/core/utils/parseDate.tsx +9 -0
- package/src/i18n.ts +4 -2
- package/src/index.ts +2 -1
- package/src/locales/en/common.json +7 -0
- package/src/locales/en/filterBar.json +0 -3
- package/src/locales/fi/common.json +8 -0
- package/src/locales/fi/filterBar.json +0 -3
- package/src/themes/useTheme.tsx +2 -2
- package/src/components/FilterBar/components/buttons/submit-button/SubmitButton.tsx +0 -18
- /package/src/{components/FilterBar → core}/components/buttons/close-button/CloseButton.css +0 -0
- /package/src/{components/FilterBar → core}/components/buttons/close-button/CloseButton.tsx +0 -0
- /package/src/{components/FilterBar → core}/utils/parseDates.tsx +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { differenceInCalendarDays } from 'date-fns'
|
|
2
|
+
import { DateRange } from 'react-day-picker'
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
calendarRange?: DateRange
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const nightsCount = ({ calendarRange }: Props) => {
|
|
9
|
+
if (!calendarRange || !calendarRange.from || !calendarRange.to) {
|
|
10
|
+
return undefined
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const diffDays = differenceInCalendarDays(
|
|
14
|
+
calendarRange.to,
|
|
15
|
+
calendarRange.from
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return diffDays
|
|
19
|
+
}
|
package/src/i18n.ts
CHANGED
|
@@ -2,7 +2,9 @@ import i18n from 'i18next'
|
|
|
2
2
|
import { initReactI18next } from 'react-i18next'
|
|
3
3
|
|
|
4
4
|
import enFilterBar from './locales/en/filterBar.json'
|
|
5
|
+
import enCommon from './locales/en/common.json'
|
|
5
6
|
import fiFilterBar from './locales/fi/filterBar.json'
|
|
7
|
+
import fiCommon from './locales/fi/common.json'
|
|
6
8
|
|
|
7
9
|
const urlParams =
|
|
8
10
|
typeof window !== 'undefined'
|
|
@@ -12,8 +14,8 @@ const localeFromUrl = urlParams?.get('locale') || 'fi'
|
|
|
12
14
|
|
|
13
15
|
i18n.use(initReactI18next).init({
|
|
14
16
|
resources: {
|
|
15
|
-
en: { filterBar: enFilterBar },
|
|
16
|
-
fi: { filterBar: fiFilterBar },
|
|
17
|
+
en: { filterBar: enFilterBar, common: enCommon },
|
|
18
|
+
fi: { filterBar: fiFilterBar, common: fiCommon },
|
|
17
19
|
},
|
|
18
20
|
lng: localeFromUrl,
|
|
19
21
|
fallbackLng: 'fi',
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Button from './components/Button'
|
|
2
2
|
import FilterBar from './components/FilterBar'
|
|
3
|
+
import FilterCalendar from './components/FilterCalendar'
|
|
3
4
|
|
|
4
|
-
export { Button, FilterBar }
|
|
5
|
+
export { Button, FilterBar, FilterCalendar }
|
|
5
6
|
export type { Tab } from './components/FilterBar/FilterBarTypes'
|
package/src/themes/useTheme.tsx
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { useTranslation } from 'react-i18next'
|
|
3
|
-
import { FaSearch } from 'react-icons/fa'
|
|
4
|
-
|
|
5
|
-
import './SubmitButton.css'
|
|
6
|
-
|
|
7
|
-
export const SubmitButton = ({ onClick }: any) => {
|
|
8
|
-
const { t } = useTranslation('filterBar')
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<button className="will-filter-bar-submit-button" onClick={onClick}>
|
|
12
|
-
<span>
|
|
13
|
-
<FaSearch />
|
|
14
|
-
</span>
|
|
15
|
-
{t('submit.label')}
|
|
16
|
-
</button>
|
|
17
|
-
)
|
|
18
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|