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.
Files changed (71) hide show
  1. package/README.md +1 -1
  2. package/lib/components/FilterBar/FilterBar.d.ts +2 -15
  3. package/lib/components/FilterBar/FilterBarTypes.d.ts +14 -3
  4. package/lib/components/FilterBar/components/buttons/index.d.ts +2 -2
  5. package/lib/components/FilterBar/components/index.d.ts +0 -1
  6. package/lib/components/FilterBar/hooks/index.d.ts +0 -2
  7. package/lib/components/FilterBar/utils/index.d.ts +0 -1
  8. package/lib/components/FilterCalendar/FilterCalendar.d.ts +5 -0
  9. package/lib/components/FilterCalendar/FilterCalendar.stories.d.ts +6 -0
  10. package/lib/components/FilterCalendar/FilterCalendarTypes.d.ts +8 -0
  11. package/lib/components/FilterCalendar/hooks/useFilterCalendar.d.ts +14 -0
  12. package/lib/components/FilterCalendar/index.d.ts +2 -0
  13. package/lib/core/components/buttons/close-button/CloseButton.d.ts +7 -0
  14. package/lib/core/components/buttons/submit-button/SubmitButton.d.ts +10 -0
  15. package/lib/core/components/calendar/Calendar.d.ts +5 -0
  16. package/lib/core/components/calendar/CalendarTypes.d.ts +15 -0
  17. package/lib/core/components/index.d.ts +3 -0
  18. package/lib/core/hooks/index.d.ts +3 -0
  19. package/lib/core/hooks/useAwaitRender.d.ts +1 -0
  20. package/lib/core/hooks/useCloseFilterSection.d.ts +8 -0
  21. package/lib/core/hooks/useUpdateTranslations.d.ts +5 -0
  22. package/lib/core/utils/index.d.ts +3 -0
  23. package/lib/core/utils/nightsCount.d.ts +6 -0
  24. package/lib/core/utils/parseDate.d.ts +6 -0
  25. package/lib/core/utils/parseDates.d.ts +6 -0
  26. package/lib/index.d.ts +40 -19
  27. package/lib/index.esm.js +6152 -6053
  28. package/lib/index.esm.js.map +1 -1
  29. package/lib/index.js +6151 -6051
  30. package/lib/index.js.map +1 -1
  31. package/lib/index.umd.js +6151 -6051
  32. package/lib/index.umd.js.map +1 -1
  33. package/lib/themes/useTheme.d.ts +4 -4
  34. package/package.json +1 -1
  35. package/src/components/FilterBar/FilterBar.tsx +20 -44
  36. package/src/components/FilterBar/FilterBarTypes.ts +16 -4
  37. package/src/components/FilterBar/components/buttons/index.ts +3 -2
  38. package/src/components/FilterBar/components/buttons/tab-button/TabButton.tsx +1 -1
  39. package/src/components/FilterBar/components/index.ts +0 -1
  40. package/src/components/FilterBar/hooks/index.ts +0 -2
  41. package/src/components/FilterBar/utils/index.tsx +0 -1
  42. package/src/components/FilterCalendar/FilterCalendar.css +67 -0
  43. package/src/components/FilterCalendar/FilterCalendar.stories.tsx +48 -0
  44. package/src/components/FilterCalendar/FilterCalendar.tsx +112 -0
  45. package/src/components/FilterCalendar/FilterCalendarTypes.ts +10 -0
  46. package/src/components/FilterCalendar/hooks/useFilterCalendar.ts +29 -0
  47. package/src/components/FilterCalendar/index.ts +3 -0
  48. package/src/{components/FilterBar → core}/components/buttons/submit-button/SubmitButton.css +6 -0
  49. package/src/core/components/buttons/submit-button/SubmitButton.tsx +28 -0
  50. package/src/{components/FilterBar → core}/components/calendar/Calendar.css +1 -12
  51. package/src/{components/FilterBar → core}/components/calendar/Calendar.tsx +15 -21
  52. package/src/core/components/calendar/CalendarTypes.ts +17 -0
  53. package/src/core/components/index.ts +4 -0
  54. package/src/core/hooks/index.ts +3 -0
  55. package/src/core/hooks/useAwaitRender.tsx +12 -0
  56. package/src/{components/FilterBar → core}/hooks/useCloseFilterSection.tsx +1 -0
  57. package/src/{components/FilterBar → core}/hooks/useUpdateTranslations.tsx +1 -1
  58. package/src/core/utils/index.ts +3 -0
  59. package/src/core/utils/nightsCount.tsx +19 -0
  60. package/src/core/utils/parseDate.tsx +9 -0
  61. package/src/i18n.ts +4 -2
  62. package/src/index.ts +2 -1
  63. package/src/locales/en/common.json +7 -0
  64. package/src/locales/en/filterBar.json +0 -3
  65. package/src/locales/fi/common.json +8 -0
  66. package/src/locales/fi/filterBar.json +0 -3
  67. package/src/themes/useTheme.tsx +2 -2
  68. package/src/components/FilterBar/components/buttons/submit-button/SubmitButton.tsx +0 -18
  69. /package/src/{components/FilterBar → core}/components/buttons/close-button/CloseButton.css +0 -0
  70. /package/src/{components/FilterBar → core}/components/buttons/close-button/CloseButton.tsx +0 -0
  71. /package/src/{components/FilterBar → core}/utils/parseDates.tsx +0 -0
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState } from 'react'
2
- import i18n from '../../../i18n'
2
+ import i18n from '../../i18n'
3
3
 
4
4
  type Props = { language?: string }
5
5
 
@@ -0,0 +1,3 @@
1
+ export { parseDates } from './parseDates'
2
+ export { parseDate } from './parseDate'
3
+ export { nightsCount } from './nightsCount'
@@ -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
+ }
@@ -0,0 +1,9 @@
1
+ import { format } from 'date-fns'
2
+
3
+ type Props = {
4
+ date?: Date
5
+ dateFormat?: string
6
+ }
7
+ export const parseDate = ({ date, dateFormat = 'dd.MM.yyyy' }: Props) => {
8
+ return date ? format(date, dateFormat) : null
9
+ }
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'
@@ -0,0 +1,7 @@
1
+ {
2
+ "night": "night",
3
+ "nights": "nights",
4
+ "checkIn": "check-in",
5
+ "checkOut": "check-out",
6
+ "search": "Search"
7
+ }
@@ -20,9 +20,6 @@
20
20
  "label": "Categories",
21
21
  "title": "Category"
22
22
  },
23
- "submit": {
24
- "label": "Search"
25
- },
26
23
  "tabs": {
27
24
  "events": "Events",
28
25
  "rooms": "Rooms"
@@ -0,0 +1,8 @@
1
+ {
2
+ "night": "yö",
3
+ "nights": "yötä",
4
+ "checkIn": "check-in",
5
+ "checkOut": "check-out",
6
+ "search": "Hae"
7
+ }
8
+
@@ -20,9 +20,6 @@
20
20
  "label": "Kategoriat",
21
21
  "title": "Kategoria"
22
22
  },
23
- "submit": {
24
- "label": "Hae"
25
- },
26
23
  "tabs": {
27
24
  "events": "Tapahtumat",
28
25
  "rooms": "Huoneet"
@@ -1,11 +1,11 @@
1
1
  import { CSSProperties } from 'react'
2
2
 
3
- export interface Palette {
3
+ export type Palette = {
4
4
  primary: string
5
5
  secondary: string
6
6
  }
7
7
 
8
- export interface ThemeProps {
8
+ export type ThemeProps = {
9
9
  palette?: Palette
10
10
  }
11
11
 
@@ -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
- }