willba-component-library 0.4.1 → 0.4.3
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 +17 -100
- package/lib/components/FilterCalendar/FilterCalendar.d.ts +2 -1
- package/lib/core/components/calendar/hooks/useCalendarLoadingSpinner.d.ts +3 -1
- package/lib/core/components/calendar/hooks/useCalendarTooltips.d.ts +3 -1
- package/lib/core/utils/getQueryRoot.d.ts +1 -0
- package/lib/embed.d.ts +0 -20
- package/lib/embed.esm.js +4 -4
- package/lib/embed.esm.js.map +1 -1
- package/lib/embed.umd.js +4 -4
- package/lib/embed.umd.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.esm.js +46 -31
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +46 -31
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,126 +1,43 @@
|
|
|
1
1
|
## Description
|
|
2
2
|
|
|
3
|
-
Willba
|
|
3
|
+
Willba Filter Bar is a search component for booking and event sites. Drop it onto any website with two lines of HTML — it pulls its settings from the provided domain and renders ready to use.
|
|
4
4
|
|
|
5
5
|
<div style="display: flex; gap: 20px;">
|
|
6
6
|
<img src="https://lh3.googleusercontent.com/d/1n5U0vBMseBci4xV5wH8vApeAcRjcyos_" alt="Filter Bar Calendar" style="width: auto; max-width: 50%;">
|
|
7
7
|
<img src="https://lh3.googleusercontent.com/d/1KCTqGgM2IZDY2nZ1ZTDf9WgX_zhmVB6D" alt="Filter Bar Guests" style="width: auto; max-width: 50%;">
|
|
8
8
|
</div>
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Adding to your site
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
| --------------------- | --------------- |
|
|
14
|
-
| `<willba-filter-bar>` | `FilterBar` |
|
|
15
|
-
|
|
16
|
-
## Use in a React app
|
|
17
|
-
|
|
18
|
-
Install:
|
|
19
|
-
|
|
20
|
-
```sh
|
|
21
|
-
npm install willba-component-library
|
|
22
|
-
# or
|
|
23
|
-
yarn add willba-component-library
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Import and render:
|
|
27
|
-
|
|
28
|
-
```jsx
|
|
29
|
-
import { FilterBar } from 'willba-component-library'
|
|
30
|
-
|
|
31
|
-
export function MyPage() {
|
|
32
|
-
return (
|
|
33
|
-
<FilterBar
|
|
34
|
-
redirectUrl="https://store.vendor.willba.app/"
|
|
35
|
-
language="en"
|
|
36
|
-
mode="dark"
|
|
37
|
-
tabs={[
|
|
38
|
-
{ label: 'Rooms', path: '/rooms', default: true, order: 1 },
|
|
39
|
-
{ label: 'Events', path: '/events', default: false, order: 2 },
|
|
40
|
-
]}
|
|
41
|
-
ageCategories={[
|
|
42
|
-
{ id: '1', name: 'Adults', minVal: 1, sortOrder: 1 },
|
|
43
|
-
{ id: '2', name: 'Children', minVal: 0, sortOrder: 2 },
|
|
44
|
-
]}
|
|
45
|
-
locations={{
|
|
46
|
-
multiSelect: false,
|
|
47
|
-
data: [{ id: 1, label: 'Helsinki', description: 'Capital of Finland' }],
|
|
48
|
-
}}
|
|
49
|
-
/>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
See [FilterBar props](#filterbar-props) for all available props. TypeScript types are exported as `FilterBarTypes` and `FilterCalendarTypes`.
|
|
55
|
-
|
|
56
|
-
## Use as a script tag (WordPress, plain HTML, anywhere)
|
|
57
|
-
|
|
58
|
-
Two lines. Set `domain` to the host that serves the filter bar config — the element fetches it on mount and renders.
|
|
12
|
+
Paste these two lines into any page — WordPress, plain HTML, anywhere. Set `domain` to your store URL, and the filter bar will load its settings and appear ready to use.
|
|
59
13
|
|
|
60
14
|
```html
|
|
61
15
|
<willba-filter-bar
|
|
62
16
|
domain="customer.willba.store"
|
|
63
17
|
mode="dark"
|
|
64
18
|
></willba-filter-bar>
|
|
65
|
-
<script src="https://cdn.jsdelivr.net/npm/willba-component-library@0.4.
|
|
19
|
+
<script src="https://cdn.jsdelivr.net/npm/willba-component-library@0.4.3/lib/embed.umd.js"></script>
|
|
66
20
|
```
|
|
67
21
|
|
|
68
|
-
The
|
|
22
|
+
The filter bar is fully self-contained and runs isolated from the rest of the page — your theme, plugins, and other scripts won't interfere with it, and it won't affect them.
|
|
69
23
|
|
|
70
24
|
### Available HTML attributes
|
|
71
25
|
|
|
72
|
-
| Attribute
|
|
73
|
-
|
|
|
74
|
-
| `domain`
|
|
75
|
-
| `mode`
|
|
76
|
-
| `
|
|
77
|
-
| `fallback-locale` | Locale to use if `navigator.language` is unavailable. | `"fi"` |
|
|
78
|
-
| `redirect-url` | URL to redirect to after submit. | `https://{domain}` |
|
|
79
|
-
|
|
80
|
-
Protocol is auto-detected: `http://` for `localhost` / `127.0.0.1` hosts, `https://` everywhere else.
|
|
26
|
+
| Attribute | Purpose | Default |
|
|
27
|
+
| ------------ | ------------------------------------------------------------------------------------- | ------------- |
|
|
28
|
+
| `domain` | Host that serves the filter bar settings. | (required) |
|
|
29
|
+
| `mode` | `"dark"` or `"light"`. | `"light"` |
|
|
30
|
+
| `full-width` | Add this attribute to make the filter bar stretch to the full width of its container. | not stretched |
|
|
81
31
|
|
|
82
|
-
###
|
|
32
|
+
### Positioning on the page
|
|
83
33
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
```
|
|
87
|
-
API response → HTML attributes → el.props (programmatic)
|
|
88
|
-
(lowest) (highest)
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
So a customer's API can ship sensible defaults, and a single embed can override `mode` or `language` per page without touching the API.
|
|
92
|
-
|
|
93
|
-
### Programmatic control (advanced)
|
|
94
|
-
|
|
95
|
-
For full programmatic control — including complex props like `tabs`, `locations`, `ageCategories`, `palette` that don't fit in HTML attributes — set `.props` directly:
|
|
34
|
+
You can wrap the element however you like — it behaves like any block-level HTML element. Use `style` or your own CSS class on `<willba-filter-bar>` to control margin, alignment, max-width, etc.
|
|
96
35
|
|
|
97
36
|
```html
|
|
98
|
-
<willba-filter-bar
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
redirectUrl: 'https://store.vendor.willba.app/',
|
|
103
|
-
language: 'en',
|
|
104
|
-
mode: 'dark',
|
|
105
|
-
tabs: [{ label: 'Rooms', path: '/rooms', default: true, order: 1 }],
|
|
106
|
-
ageCategories: [{ id: '1', name: 'Adults', minVal: 1, sortOrder: 1 }],
|
|
107
|
-
locations: { multiSelect: false, data: [{ id: 1, label: 'Helsinki' }] },
|
|
108
|
-
}
|
|
109
|
-
</script>
|
|
37
|
+
<willba-filter-bar
|
|
38
|
+
domain="customer.willba.store"
|
|
39
|
+
style="display: block; max-width: 900px; margin: 40px auto;"
|
|
40
|
+
></willba-filter-bar>
|
|
110
41
|
```
|
|
111
42
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
## FilterBar props
|
|
115
|
-
|
|
116
|
-
| Name | Value | Description |
|
|
117
|
-
| -------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
118
|
-
| redirectUrl | `"string"` | Specifies the base URL to which the component should redirect after submitting the filters. For example: `'https://store.vendor.willba.app/'` |
|
|
119
|
-
| language | `"string"` | Specifies the language of the filter bar. Available options are Finnish ("fi") and English ("en"). For example: `'en'` |
|
|
120
|
-
| palette | `{}` | The palette defines the colors of the filter bar. Override the colors using the following format: `{ primary: string, secondary: string, error: string }`. For example: `{ primary: '#2a5a44', secondary: '#2a5a44', error: '#ff0000' }` |
|
|
121
|
-
| disableCalendarDates | `{}` | Disable dates on the calendar by page using the following format: `{ disabledDatesByPage: [{ offset: number, page: string }] }`. For example: `{ disabledDatesByPage: [{ offset: 7, page: '/rooms' }, { offset: -1, page: '/events' }] }` |
|
|
122
|
-
| mode | `"string"` | Specify the color theme for the filter bar tabs as either light or dark using the following format: `'dark'` or `'light'` |
|
|
123
|
-
| 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 }]` |
|
|
124
|
-
| fullWidth | `true` | Specify whether the filter bar width should be dynamic or fixed. |
|
|
125
|
-
| 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' }]` |
|
|
126
|
-
| 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' }] }` |
|
|
43
|
+
Note: only outer-layout styles (margin, padding, display, width, max-width, alignment) affect the element. The filter bar's internal styling is sealed and cannot be customized from the host page.
|
|
@@ -2,4 +2,5 @@ import React from 'react';
|
|
|
2
2
|
import { FilterCalendarTypes } from './FilterCalendarTypes';
|
|
3
3
|
import '../../themes/Default.css';
|
|
4
4
|
import './FilterCalendar.css';
|
|
5
|
-
|
|
5
|
+
declare const FilterCalendar: (props: FilterCalendarTypes) => React.JSX.Element;
|
|
6
|
+
export default FilterCalendar;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
1
2
|
type Props = {
|
|
2
3
|
loadingData?: boolean;
|
|
4
|
+
rootRef?: RefObject<HTMLElement | null>;
|
|
3
5
|
};
|
|
4
|
-
export declare const useCalendarLoadingSpinner: ({ loadingData }: Props) => void;
|
|
6
|
+
export declare const useCalendarLoadingSpinner: ({ loadingData, rootRef }: Props) => void;
|
|
5
7
|
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
1
2
|
type Props = {
|
|
2
3
|
showFeedback?: boolean;
|
|
4
|
+
rootRef?: RefObject<HTMLElement | null>;
|
|
3
5
|
};
|
|
4
|
-
export declare const useCalendarTooltips: ({ showFeedback }: Props) => void;
|
|
6
|
+
export declare const useCalendarTooltips: ({ showFeedback, rootRef }: Props) => void;
|
|
5
7
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getQueryRoot: (el: Element | null | undefined) => Document | ShadowRoot;
|
package/lib/embed.d.ts
CHANGED
|
@@ -1,21 +1 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FilterBarTypes } from './components/FilterBar/FilterBarTypes';
|
|
3
|
-
declare abstract class WillbaElement<P extends object> extends HTMLElement {
|
|
4
|
-
private _props;
|
|
5
|
-
private _root;
|
|
6
|
-
private _shadow;
|
|
7
|
-
private _container;
|
|
8
|
-
set props(value: Partial<P>);
|
|
9
|
-
get props(): Partial<P>;
|
|
10
|
-
protected abstract renderReact(props: Partial<P>): React.ReactNode;
|
|
11
|
-
connectedCallback(): void;
|
|
12
|
-
disconnectedCallback(): void;
|
|
13
|
-
private _render;
|
|
14
|
-
}
|
|
15
|
-
export declare class WillbaFilterBarElement extends WillbaElement<FilterBarTypes> {
|
|
16
|
-
private _autoFetchTriggered;
|
|
17
|
-
protected renderReact(props: Partial<FilterBarTypes>): React.JSX.Element;
|
|
18
|
-
connectedCallback(): void;
|
|
19
|
-
private _loadConfigFromApi;
|
|
20
|
-
}
|
|
21
1
|
export {};
|