willba-component-library 0.1.81 → 0.1.83

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 CHANGED
@@ -27,11 +27,14 @@ ReactDOM.render(<App />, document.querySelector('#app'))
27
27
  or you can add the willba-component-library using scripts:
28
28
 
29
29
  ```html
30
- <div id="will-filter-bar" style="max-width: 1200px"></div>
30
+ <div
31
+ id="will-filter-bar"
32
+ style="max-width: 1200px; display: flex; justify-content: center;"
33
+ ></div>
31
34
 
32
- <script src="https://unpkg.com/react@18/umd/react.development.js"></script>
33
- <script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
34
- <script src="https://cdn.jsdelivr.net/npm/willba-component-library@0/lib/index.umd.js"></script>
35
+ <script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
36
+ <script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
37
+ <script src="https://cdn.jsdelivr.net/npm/willba-component-library@0.1.83/lib/index.umd.js"></script>
35
38
 
36
39
  <script>
37
40
  const filterBarElement = React.createElement
@@ -41,7 +44,45 @@ or you can add the willba-component-library using scripts:
41
44
 
42
45
  root.render(
43
46
  filterBarElement(WillFilterBar, {
44
- redirectUrl: 'http://localhost:4000/',
47
+ redirectUrl: 'https://www.google.com',
48
+ language: 'en',
49
+ calendarOffset: {
50
+ rooms: 7,
51
+ events: -1,
52
+ },
53
+ mode: 'dark',
54
+ ageCategories: [
55
+ {
56
+ id: '2',
57
+ name: 'Alle 6 vuotiaat',
58
+ minVal: 0,
59
+ sortOrder: 3,
60
+ },
61
+ {
62
+ id: '3',
63
+ name: '6-16 vuotiaat',
64
+ minVal: 0,
65
+ sortOrder: 2,
66
+ },
67
+ {
68
+ id: '1',
69
+ name: 'Aikuiset',
70
+ minVal: 1,
71
+ sortOrder: 1,
72
+ },
73
+ ],
74
+ tabs: [
75
+ {
76
+ path: '/rooms',
77
+ default: true,
78
+ order: 2,
79
+ },
80
+ {
81
+ path: '/events',
82
+ default: false,
83
+ order: 1,
84
+ },
85
+ ],
45
86
  })
46
87
  )
47
88
  </script>
@@ -49,9 +90,15 @@ or you can add the willba-component-library using scripts:
49
90
 
50
91
  ## Props of FilterBar
51
92
 
52
- | Name | Value | Description |
53
- | ------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------- |
54
- | redirectUrl | `"string"` | Define the URL where the component showld redirect on filtering. |
55
- | language | `"fi" , "en"` | Specify the language, available languages Finnish and English. |
56
- | ageCategories | `[{}]` | Specify age categories for guests: filter: [{id: string, name: string, minAge: number , maxAge: number , minVal: number}] |
57
- | palette | `{}` | Override color: palette: {primary: string, secondary: string}. |
93
+ | Name | Value | Description |
94
+ | -------------- | ------------- | ---------------------------------------------------------------------------------------------------------------- |
95
+ | redirectUrl | `"string"` | Define the URL where the component should redirect on filtering. |
96
+ | language | `"fi" , "en"` | Specify the language, available languages Finnish and English. |
97
+ | ageCategories | `[{}]` | Specify age categories for guests: [{id: string, name: string, , minVal: number, sortOrder: number}] |
98
+ | palette | `{}` | Override color: palette: {primary: string, secondary: string}. |
99
+ | calendarOffset | `{}` | Calendar disabled date starting from today: {rooms: number, events: number}. |
100
+ | fullWidth | `true` | Filter bar width, dynamic or fixed. |
101
+ | |
102
+ | mode | `"light"` | Filter bar tabs color: light or dark |
103
+ | |
104
+ | tabs | `[{}]` | Filter bar tabs management: [{path: string, default: boolean, order: number, label: { en: string, fi: string}}]. |
package/lib/index.d.ts CHANGED
@@ -70,4 +70,4 @@ type FilterBarProps = {
70
70
  };
71
71
  declare function FilterBar({ language, ageCategories, redirectUrl, palette, onSubmit, fullWidth, calendarOffset, mode, tabs, }: FilterBarProps): React.JSX.Element | null;
72
72
 
73
- export { Button, FilterBar };
73
+ export { Button, FilterBar, Tab };
package/lib/index.esm.js CHANGED
@@ -3970,13 +3970,26 @@ var useFilterBar = function (_a) {
3970
3970
  return;
3971
3971
  var defaultTab = (tabs === null || tabs === void 0 ? void 0 : tabs.length) === 1 ? tabs[0] : tabs === null || tabs === void 0 ? void 0 : tabs.find(function (tab) { return tab.default; });
3972
3972
  var findMatchingPath = function () {
3973
+ var e_1, _a;
3973
3974
  var paths = [Pages.EVENTS, Pages.ROOMS];
3974
- return paths.find(function (path) {
3975
- return window.location.pathname.includes(path) ||
3976
- (defaultTab && defaultTab.path === path);
3977
- });
3975
+ try {
3976
+ for (var paths_1 = __values(paths), paths_1_1 = paths_1.next(); !paths_1_1.done; paths_1_1 = paths_1.next()) {
3977
+ var path = paths_1_1.value;
3978
+ if (window.location.pathname.includes(path)) {
3979
+ return path;
3980
+ }
3981
+ }
3982
+ }
3983
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3984
+ finally {
3985
+ try {
3986
+ if (paths_1_1 && !paths_1_1.done && (_a = paths_1.return)) _a.call(paths_1);
3987
+ }
3988
+ finally { if (e_1) throw e_1.error; }
3989
+ }
3990
+ return defaultTab ? defaultTab.path : Pages.EVENTS;
3978
3991
  };
3979
- var currentPath = findMatchingPath() || Pages.EVENTS;
3992
+ var currentPath = findMatchingPath();
3980
3993
  setSelectedPath(currentPath);
3981
3994
  }, []);
3982
3995
  var updateGuestsCount = function (id, newCount) {
@@ -3989,7 +4002,7 @@ var useFilterBar = function (_a) {
3989
4002
  setSelectedFilter(id);
3990
4003
  };
3991
4004
  var handleSubmit = function () {
3992
- var e_1, _a;
4005
+ var e_2, _a;
3993
4006
  var newParams = {
3994
4007
  startDate: (calendarRange === null || calendarRange === void 0 ? void 0 : calendarRange.from)
3995
4008
  ? format(calendarRange.from, 'yyyy-MM-dd')
@@ -4010,12 +4023,12 @@ var useFilterBar = function (_a) {
4010
4023
  }
4011
4024
  }
4012
4025
  }
4013
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
4026
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
4014
4027
  finally {
4015
4028
  try {
4016
4029
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
4017
4030
  }
4018
- finally { if (e_1) throw e_1.error; }
4031
+ finally { if (e_2) throw e_2.error; }
4019
4032
  }
4020
4033
  handleSelectedFilter(false);
4021
4034
  return onSubmit && selectedPath === Pages.ROOMS