willba-component-library 0.3.12 → 0.3.13

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 (26) hide show
  1. package/README.md +6 -18
  2. package/package.json +1 -1
  3. package/src/assets/IconsSvg.tsx +2 -0
  4. package/src/components/Button/Button.stories.tsx +1 -0
  5. package/src/components/Button/Button.tsx +1 -1
  6. package/src/components/FilterBar/FilterBar.stories.tsx +1 -0
  7. package/src/components/FilterBar/FilterBar.tsx +1 -1
  8. package/src/components/FilterBar/components/buttons/select-button/SelectButton.tsx +1 -1
  9. package/src/components/FilterBar/components/buttons/tab-button/TabButton.tsx +2 -0
  10. package/src/components/FilterBar/components/cards/image-card/ImageCard.tsx +1 -1
  11. package/src/components/FilterBar/components/categories/Categories.tsx +1 -2
  12. package/src/components/FilterBar/components/common/FilterSectionHeader.tsx +1 -1
  13. package/src/components/FilterBar/components/dates/Dates.tsx +1 -1
  14. package/src/components/FilterBar/components/divider/Divider.tsx +2 -0
  15. package/src/components/FilterBar/components/guests/GuestCount/GuestCount.tsx +1 -1
  16. package/src/components/FilterBar/components/guests/Guests.tsx +1 -1
  17. package/src/components/FilterBar/components/locations/Locations.tsx +1 -1
  18. package/src/components/FilterBar/utils/calculateDropdownPosition.tsx +0 -10
  19. package/src/components/FilterCalendar/FilterCalendar.tsx +1 -0
  20. package/src/components/FilterCalendar/components/Footer.tsx +1 -0
  21. package/src/core/components/buttons/close-button/CloseButton.tsx +1 -0
  22. package/src/core/components/buttons/submit-button/SubmitButton.tsx +1 -0
  23. package/src/core/components/calendar/Calendar.tsx +1 -1
  24. package/stories/Button.tsx +2 -0
  25. package/stories/Header.tsx +1 -0
  26. package/stories/Page.tsx +1 -1
package/README.md CHANGED
@@ -66,19 +66,13 @@ function App() {
66
66
  ]}
67
67
  tabs={[
68
68
  {
69
- label: {
70
- en: 'Rooms',
71
- fi: 'Hilat',
72
- },
69
+ label: 'Rooms',
73
70
  path: '/rooms',
74
71
  default: true,
75
72
  order: 2,
76
73
  },
77
74
  {
78
- label: {
79
- en: 'Events',
80
- fi: 'Tapahtumat',
81
- },
75
+ label: 'Events',
82
76
  path: '/events',
83
77
  default: false,
84
78
  order: 1,
@@ -90,14 +84,8 @@ function App() {
90
84
  data: [
91
85
  {
92
86
  id: 1,
93
- label: [
94
- { content: 'Helsinki', locale: 'en' },
95
- { content: 'Helsinki', locale: 'fi' },
96
- ],
97
- description: [
98
- { content: 'Capital of Finland', locale: 'en' },
99
- { content: 'Suomen pääkaupunki', locale: 'fi' },
100
- ],
87
+ label: 'Helsinki',
88
+ description: 'Capital of Finland',
101
89
  imageUrl: 'https://example.com/helsinki.jpg',
102
90
  },
103
91
  ],
@@ -182,5 +170,5 @@ ReactDOM.render(<App />, document.querySelector('#app'))
182
170
  | mode | `"string"` | Specify the color theme for the filter bar tabs as either light or dark using the following format: `'dark'` or `'light'` |
183
171
  | ageCategories | `[{}]` | The ageCategories prop will determine the types of guests that can be selected. Specify the age categories for guests using the following format: `[{ id: string, name: string, minVal: number, sortOrder: number }]`. For example: `[{ id: '1', name: 'Aikuiset', minVal: 1, sortOrder: 1 }]` |
184
172
  | fullWidth | `true` | Specify whether the filter bar width should be dynamic or fixed. |
185
- | tabs | `[{}]` | Manage the filter bar tabs using the following format: `[{path: string, default: boolean, order: number, label: { en: string, fi: string }}]`. For example: `[{ path: '/rooms', default: true, order: 2, label: { en: 'Rooms', fi: 'Hilat' }}]` |
186
- | locations | `{}` | Configures location filter. Format: `{ multiSelect: boolean, disabled?: boolean, data: Location[] }` where Location = `{ id: number, label: LocaleTranslation, description?: LocaleTranslation, imageUrl?: string }` and LocaleTranslation = `Array<{ content: string, locale: string }>`. `multiSelect` enables multi-selection, `disabled` disables the filter, `description` shows under title, `imageUrl` displays location image. Example: `{ multiSelect: false, disabled: false, data: [{ id: 1, label: [{ content: 'Helsinki', locale: 'en' }, { content: 'Helsinki', locale: 'fi' }], description: [{ content: 'Capital', locale: 'en' }, { content: 'Pääkaupunki', locale: 'fi' }], imageUrl: 'https://example.com/helsinki.jpg' }] }` |
173
+ | tabs | `[{}]` | Manage the filter bar tabs using the following format: `[{path: string, default: boolean, order: number, label?: string}]`. The label should be pre-localized. For example: `[{ path: '/rooms', default: true, order: 2, label: 'Rooms' }]` |
174
+ | locations | `{}` | Configures location filter. Format: `{ multiSelect: boolean, disabled?: boolean, data: Location[] }` where Location = `{ id: number, label: string, description?: string \| null, imageUrl?: string \| null }`. The label and description should be pre-localized. `multiSelect` enables multi-selection, `disabled` disables the filter, `description` shows under title, `imageUrl` displays location image. Example: `{ multiSelect: false, disabled: false, data: [{ id: 1, label: 'Helsinki', description: 'Capital of Finland', imageUrl: 'https://example.com/helsinki.jpg' }] }` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "willba-component-library",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "description": "A custom UI component library",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
@@ -1,3 +1,5 @@
1
+ import React from 'react'
2
+
1
3
  type Icon = 'spinner' | 'warning'
2
4
 
3
5
  type Props = {
@@ -1,3 +1,4 @@
1
+ import React from 'react'
1
2
  import type { Meta, StoryObj } from '@storybook/react'
2
3
  import Button from './Button'
3
4
 
@@ -1,4 +1,4 @@
1
- import { useState, MouseEvent } from 'react'
1
+ import React, { useState, MouseEvent } from 'react'
2
2
  import classNames from 'classnames'
3
3
  import './button.css'
4
4
 
@@ -1,3 +1,4 @@
1
+ import React from 'react'
1
2
  import type { Meta, StoryObj } from '@storybook/react'
2
3
 
3
4
  import FilterBar from './FilterBar'
@@ -1,4 +1,4 @@
1
- import {
1
+ import React, {
2
2
  CSSProperties,
3
3
  MutableRefObject,
4
4
  useEffect,
@@ -1,4 +1,4 @@
1
- import { forwardRef } from 'react'
1
+ import React, { forwardRef } from 'react'
2
2
 
3
3
  import './SelectButton.css'
4
4
 
@@ -1,3 +1,5 @@
1
+ import React from 'react'
2
+
1
3
  import './TabButton.css'
2
4
 
3
5
  type Props = {
@@ -1,4 +1,4 @@
1
- import { forwardRef } from 'react'
1
+ import React, { forwardRef } from 'react'
2
2
 
3
3
  import './ImageCard.css'
4
4
 
@@ -1,5 +1,4 @@
1
- import { useState } from 'react'
2
-
1
+ import React, { useState } from 'react'
3
2
  import { useTranslation } from 'react-i18next'
4
3
 
5
4
  import './Categories.css'
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react'
1
+ import React, { ReactNode } from 'react'
2
2
 
3
3
  import './FilterSectionHeader.css'
4
4
 
@@ -1,4 +1,4 @@
1
- import { RefObject, forwardRef } from 'react'
1
+ import React, { RefObject, forwardRef } from 'react'
2
2
 
3
3
  import { DateRange } from 'react-day-picker'
4
4
  import { Calendar } from '../../../../core/components'
@@ -1,3 +1,5 @@
1
+ import React from 'react'
2
+
1
3
  import './Divider.css'
2
4
 
3
5
  export const Divider = () => {
@@ -1,4 +1,4 @@
1
- import { FC, useEffect } from 'react'
1
+ import React, { FC, useEffect } from 'react'
2
2
 
3
3
  import { GuestsCountPropsType } from '../../../FilterBarTypes'
4
4
 
@@ -1,4 +1,4 @@
1
- import { forwardRef } from 'react'
1
+ import React, { forwardRef } from 'react'
2
2
  import { useTranslation } from 'react-i18next'
3
3
 
4
4
  import { useAutoFocus } from '../../../../core/hooks'
@@ -1,4 +1,4 @@
1
- import { forwardRef, useEffect, useRef } from 'react'
1
+ import React, { forwardRef, useEffect, useRef } from 'react'
2
2
  import { useTranslation } from 'react-i18next'
3
3
 
4
4
  import './Locations.css'
@@ -18,8 +18,6 @@ export const calculateDropdownPosition = ({
18
18
  guestsButtonRef,
19
19
  isMobile,
20
20
  }: CalculateDropdownPositionParams): CSSProperties => {
21
- // On mobile, don't apply any positioning - let CSS handle it naturally
22
- // Dropdowns will start from leftmost point with position: relative
23
21
  if (isMobile) {
24
22
  return {}
25
23
  }
@@ -31,7 +29,6 @@ export const calculateDropdownPosition = ({
31
29
 
32
30
  switch (filterSection) {
33
31
  case FilterSections.LOCATIONS:
34
- // Locations: Start from beginning, hug content
35
32
  if (locationsButtonRef.current) {
36
33
  const buttonRect = locationsButtonRef.current.getBoundingClientRect()
37
34
  const relativeLeft = buttonRect.left - containerRect.left
@@ -44,8 +41,6 @@ export const calculateDropdownPosition = ({
44
41
  break
45
42
 
46
43
  case FilterSections.CALENDAR:
47
- // Calendar: Two months side-by-side, needs ~650-700px
48
- // Start from dates button, but push left if not enough space
49
44
  if (datesButtonRef.current) {
50
45
  const buttonRect = datesButtonRef.current.getBoundingClientRect()
51
46
  const relativeLeft = buttonRect.left - containerRect.left
@@ -53,7 +48,6 @@ export const calculateDropdownPosition = ({
53
48
  const calendarMinWidth = 650
54
49
 
55
50
  if (availableWidth < calendarMinWidth) {
56
- // Not enough space, align to the right edge
57
51
  return {
58
52
  left: 'auto',
59
53
  right: containerLeft,
@@ -61,7 +55,6 @@ export const calculateDropdownPosition = ({
61
55
  maxWidth: `${containerRect.width}px`,
62
56
  }
63
57
  } else {
64
- // Enough space, start from dates button
65
58
  return {
66
59
  left: relativeLeft,
67
60
  right: 'auto',
@@ -72,7 +65,6 @@ export const calculateDropdownPosition = ({
72
65
  break
73
66
 
74
67
  case FilterSections.GUESTS:
75
- // Guests: Start from guests button, push left if not enough space
76
68
  if (guestsButtonRef.current) {
77
69
  const buttonRect = guestsButtonRef.current.getBoundingClientRect()
78
70
  const relativeLeft = buttonRect.left - containerRect.left
@@ -80,7 +72,6 @@ export const calculateDropdownPosition = ({
80
72
  const dropdownMinWidth = 350
81
73
 
82
74
  if (availableWidth < dropdownMinWidth) {
83
- // Not enough space, align to the right
84
75
  return {
85
76
  left: 'auto',
86
77
  right: containerLeft,
@@ -88,7 +79,6 @@ export const calculateDropdownPosition = ({
88
79
  maxWidth: `${containerRect.width}px`,
89
80
  }
90
81
  } else {
91
- // Enough space, start from button
92
82
  return {
93
83
  left: relativeLeft,
94
84
  right: 'auto',
@@ -1,3 +1,4 @@
1
+ import React from 'react'
1
2
  import { useTranslation } from 'react-i18next'
2
3
 
3
4
  import useTheme from '../../themes/useTheme'
@@ -1,3 +1,4 @@
1
+ import React from 'react'
1
2
  import { useTranslation } from 'react-i18next'
2
3
  import { useMediaQuery } from 'react-responsive'
3
4
  import { DateRange } from 'react-day-picker'
@@ -1,3 +1,4 @@
1
+ import React from 'react'
1
2
  import { IoIosCloseCircleOutline } from 'react-icons/io'
2
3
 
3
4
  import './CloseButton.css'
@@ -1,3 +1,4 @@
1
+ import React from 'react'
1
2
  import { FaSpinner } from 'react-icons/fa'
2
3
  import { ReactNode } from 'react'
3
4
 
@@ -1,4 +1,4 @@
1
- import { forwardRef } from 'react'
1
+ import React, { forwardRef } from 'react'
2
2
  import { addDays, startOfDay } from 'date-fns'
3
3
  import { fi, enUS } from 'date-fns/locale'
4
4
  import { useTranslation } from 'react-i18next'
@@ -1,3 +1,5 @@
1
+ import React from 'react'
2
+
1
3
  import './button.css'
2
4
 
3
5
  interface ButtonProps {
@@ -1,3 +1,4 @@
1
+ import React from 'react'
1
2
  import { Button } from './Button'
2
3
  import './header.css'
3
4
 
package/stories/Page.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { FC, useState } from 'react'
1
+ import React, { FC, useState } from 'react'
2
2
 
3
3
  import { Header } from './Header'
4
4
  import './page.css'