willba-component-library 0.0.73 → 0.0.75
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/lib/index.esm.js +260 -2
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +265 -7
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +269 -10
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/rollup.config.mjs +1 -3
package/lib/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react'
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.
|
|
5
|
-
})(this, (function (exports, React__default
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.WillbaComponentLibrary = {}, global.React));
|
|
5
|
+
})(this, (function (exports, React__default) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
|
8
8
|
var n = Object.create(null);
|
|
@@ -128,6 +128,265 @@
|
|
|
128
128
|
return (React__default.createElement("button", { type: "button", className: classNames("storybook-button", "storybook-button--".concat(size), "storybook-button--".concat(type)), style: textColor ? { color: textColor } : {}, onClick: onClick }, "".concat(label, " ").concat(theState)));
|
|
129
129
|
};
|
|
130
130
|
|
|
131
|
+
function warn() {
|
|
132
|
+
if (console && console.warn) {
|
|
133
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
134
|
+
args[_key] = arguments[_key];
|
|
135
|
+
}
|
|
136
|
+
if (typeof args[0] === 'string') args[0] = `react-i18next:: ${args[0]}`;
|
|
137
|
+
console.warn(...args);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const alreadyWarned = {};
|
|
141
|
+
function warnOnce() {
|
|
142
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
143
|
+
args[_key2] = arguments[_key2];
|
|
144
|
+
}
|
|
145
|
+
if (typeof args[0] === 'string' && alreadyWarned[args[0]]) return;
|
|
146
|
+
if (typeof args[0] === 'string') alreadyWarned[args[0]] = new Date();
|
|
147
|
+
warn(...args);
|
|
148
|
+
}
|
|
149
|
+
const loadedClb = (i18n, cb) => () => {
|
|
150
|
+
if (i18n.isInitialized) {
|
|
151
|
+
cb();
|
|
152
|
+
} else {
|
|
153
|
+
const initialized = () => {
|
|
154
|
+
setTimeout(() => {
|
|
155
|
+
i18n.off('initialized', initialized);
|
|
156
|
+
}, 0);
|
|
157
|
+
cb();
|
|
158
|
+
};
|
|
159
|
+
i18n.on('initialized', initialized);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
function loadNamespaces(i18n, ns, cb) {
|
|
163
|
+
i18n.loadNamespaces(ns, loadedClb(i18n, cb));
|
|
164
|
+
}
|
|
165
|
+
function loadLanguages(i18n, lng, ns, cb) {
|
|
166
|
+
if (typeof ns === 'string') ns = [ns];
|
|
167
|
+
ns.forEach(n => {
|
|
168
|
+
if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n);
|
|
169
|
+
});
|
|
170
|
+
i18n.loadLanguages(lng, loadedClb(i18n, cb));
|
|
171
|
+
}
|
|
172
|
+
function oldI18nextHasLoadedNamespace(ns, i18n) {
|
|
173
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
174
|
+
const lng = i18n.languages[0];
|
|
175
|
+
const fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
|
|
176
|
+
const lastLng = i18n.languages[i18n.languages.length - 1];
|
|
177
|
+
if (lng.toLowerCase() === 'cimode') return true;
|
|
178
|
+
const loadNotPending = (l, n) => {
|
|
179
|
+
const loadState = i18n.services.backendConnector.state[`${l}|${n}`];
|
|
180
|
+
return loadState === -1 || loadState === 2;
|
|
181
|
+
};
|
|
182
|
+
if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false;
|
|
183
|
+
if (i18n.hasResourceBundle(lng, ns)) return true;
|
|
184
|
+
if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
|
|
185
|
+
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
function hasLoadedNamespace(ns, i18n) {
|
|
189
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
190
|
+
if (!i18n.languages || !i18n.languages.length) {
|
|
191
|
+
warnOnce('i18n.languages were undefined or empty', i18n.languages);
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
const isNewerI18next = i18n.options.ignoreJSONStructure !== undefined;
|
|
195
|
+
if (!isNewerI18next) {
|
|
196
|
+
return oldI18nextHasLoadedNamespace(ns, i18n, options);
|
|
197
|
+
}
|
|
198
|
+
return i18n.hasLoadedNamespace(ns, {
|
|
199
|
+
lng: options.lng,
|
|
200
|
+
precheck: (i18nInstance, loadNotPending) => {
|
|
201
|
+
if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
|
|
207
|
+
const htmlEntities = {
|
|
208
|
+
'&': '&',
|
|
209
|
+
'&': '&',
|
|
210
|
+
'<': '<',
|
|
211
|
+
'<': '<',
|
|
212
|
+
'>': '>',
|
|
213
|
+
'>': '>',
|
|
214
|
+
''': "'",
|
|
215
|
+
''': "'",
|
|
216
|
+
'"': '"',
|
|
217
|
+
'"': '"',
|
|
218
|
+
' ': ' ',
|
|
219
|
+
' ': ' ',
|
|
220
|
+
'©': '©',
|
|
221
|
+
'©': '©',
|
|
222
|
+
'®': '®',
|
|
223
|
+
'®': '®',
|
|
224
|
+
'…': '…',
|
|
225
|
+
'…': '…',
|
|
226
|
+
'/': '/',
|
|
227
|
+
'/': '/'
|
|
228
|
+
};
|
|
229
|
+
const unescapeHtmlEntity = m => htmlEntities[m];
|
|
230
|
+
const unescape = text => text.replace(matchHtmlEntity, unescapeHtmlEntity);
|
|
231
|
+
|
|
232
|
+
let defaultOptions$1 = {
|
|
233
|
+
bindI18n: 'languageChanged',
|
|
234
|
+
bindI18nStore: '',
|
|
235
|
+
transEmptyNodeValue: '',
|
|
236
|
+
transSupportBasicHtmlNodes: true,
|
|
237
|
+
transWrapTextNodes: '',
|
|
238
|
+
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
|
|
239
|
+
useSuspense: true,
|
|
240
|
+
unescape
|
|
241
|
+
};
|
|
242
|
+
function setDefaults() {
|
|
243
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
244
|
+
defaultOptions$1 = {
|
|
245
|
+
...defaultOptions$1,
|
|
246
|
+
...options
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
function getDefaults() {
|
|
250
|
+
return defaultOptions$1;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
let i18nInstance;
|
|
254
|
+
function setI18n(instance) {
|
|
255
|
+
i18nInstance = instance;
|
|
256
|
+
}
|
|
257
|
+
function getI18n() {
|
|
258
|
+
return i18nInstance;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const initReactI18next = {
|
|
262
|
+
type: '3rdParty',
|
|
263
|
+
init(instance) {
|
|
264
|
+
setDefaults(instance.options.react);
|
|
265
|
+
setI18n(instance);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const I18nContext = React__default.createContext();
|
|
270
|
+
class ReportNamespaces {
|
|
271
|
+
constructor() {
|
|
272
|
+
this.usedNamespaces = {};
|
|
273
|
+
}
|
|
274
|
+
addUsedNamespaces(namespaces) {
|
|
275
|
+
namespaces.forEach(ns => {
|
|
276
|
+
if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
getUsedNamespaces() {
|
|
280
|
+
return Object.keys(this.usedNamespaces);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const usePrevious = (value, ignore) => {
|
|
285
|
+
const ref = React__default.useRef();
|
|
286
|
+
React__default.useEffect(() => {
|
|
287
|
+
ref.current = ignore ? ref.current : value;
|
|
288
|
+
}, [value, ignore]);
|
|
289
|
+
return ref.current;
|
|
290
|
+
};
|
|
291
|
+
function useTranslation(ns) {
|
|
292
|
+
let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
293
|
+
const {
|
|
294
|
+
i18n: i18nFromProps
|
|
295
|
+
} = props;
|
|
296
|
+
const {
|
|
297
|
+
i18n: i18nFromContext,
|
|
298
|
+
defaultNS: defaultNSFromContext
|
|
299
|
+
} = React__default.useContext(I18nContext) || {};
|
|
300
|
+
const i18n = i18nFromProps || i18nFromContext || getI18n();
|
|
301
|
+
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
|
|
302
|
+
if (!i18n) {
|
|
303
|
+
warnOnce('You will need to pass in an i18next instance by using initReactI18next');
|
|
304
|
+
const notReadyT = (k, optsOrDefaultValue) => {
|
|
305
|
+
if (typeof optsOrDefaultValue === 'string') return optsOrDefaultValue;
|
|
306
|
+
if (optsOrDefaultValue && typeof optsOrDefaultValue === 'object' && typeof optsOrDefaultValue.defaultValue === 'string') return optsOrDefaultValue.defaultValue;
|
|
307
|
+
return Array.isArray(k) ? k[k.length - 1] : k;
|
|
308
|
+
};
|
|
309
|
+
const retNotReady = [notReadyT, {}, false];
|
|
310
|
+
retNotReady.t = notReadyT;
|
|
311
|
+
retNotReady.i18n = {};
|
|
312
|
+
retNotReady.ready = false;
|
|
313
|
+
return retNotReady;
|
|
314
|
+
}
|
|
315
|
+
if (i18n.options.react && i18n.options.react.wait !== undefined) warnOnce('It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
|
|
316
|
+
const i18nOptions = {
|
|
317
|
+
...getDefaults(),
|
|
318
|
+
...i18n.options.react,
|
|
319
|
+
...props
|
|
320
|
+
};
|
|
321
|
+
const {
|
|
322
|
+
useSuspense,
|
|
323
|
+
keyPrefix
|
|
324
|
+
} = i18nOptions;
|
|
325
|
+
let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
|
|
326
|
+
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
|
|
327
|
+
if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
|
|
328
|
+
const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => hasLoadedNamespace(n, i18n, i18nOptions));
|
|
329
|
+
function getT() {
|
|
330
|
+
return i18n.getFixedT(props.lng || null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
|
|
331
|
+
}
|
|
332
|
+
const [t, setT] = React__default.useState(getT);
|
|
333
|
+
let joinedNS = namespaces.join();
|
|
334
|
+
if (props.lng) joinedNS = `${props.lng}${joinedNS}`;
|
|
335
|
+
const previousJoinedNS = usePrevious(joinedNS);
|
|
336
|
+
const isMounted = React__default.useRef(true);
|
|
337
|
+
React__default.useEffect(() => {
|
|
338
|
+
const {
|
|
339
|
+
bindI18n,
|
|
340
|
+
bindI18nStore
|
|
341
|
+
} = i18nOptions;
|
|
342
|
+
isMounted.current = true;
|
|
343
|
+
if (!ready && !useSuspense) {
|
|
344
|
+
if (props.lng) {
|
|
345
|
+
loadLanguages(i18n, props.lng, namespaces, () => {
|
|
346
|
+
if (isMounted.current) setT(getT);
|
|
347
|
+
});
|
|
348
|
+
} else {
|
|
349
|
+
loadNamespaces(i18n, namespaces, () => {
|
|
350
|
+
if (isMounted.current) setT(getT);
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
|
|
355
|
+
setT(getT);
|
|
356
|
+
}
|
|
357
|
+
function boundReset() {
|
|
358
|
+
if (isMounted.current) setT(getT);
|
|
359
|
+
}
|
|
360
|
+
if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
|
|
361
|
+
if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset);
|
|
362
|
+
return () => {
|
|
363
|
+
isMounted.current = false;
|
|
364
|
+
if (bindI18n && i18n) bindI18n.split(' ').forEach(e => i18n.off(e, boundReset));
|
|
365
|
+
if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(e => i18n.store.off(e, boundReset));
|
|
366
|
+
};
|
|
367
|
+
}, [i18n, joinedNS]);
|
|
368
|
+
const isInitial = React__default.useRef(true);
|
|
369
|
+
React__default.useEffect(() => {
|
|
370
|
+
if (isMounted.current && !isInitial.current) {
|
|
371
|
+
setT(getT);
|
|
372
|
+
}
|
|
373
|
+
isInitial.current = false;
|
|
374
|
+
}, [i18n, keyPrefix]);
|
|
375
|
+
const ret = [t, i18n, ready];
|
|
376
|
+
ret.t = t;
|
|
377
|
+
ret.i18n = i18n;
|
|
378
|
+
ret.ready = ready;
|
|
379
|
+
if (ready) return ret;
|
|
380
|
+
if (!ready && !useSuspense) return ret;
|
|
381
|
+
throw new Promise(resolve => {
|
|
382
|
+
if (props.lng) {
|
|
383
|
+
loadLanguages(i18n, props.lng, namespaces, () => resolve());
|
|
384
|
+
} else {
|
|
385
|
+
loadNamespaces(i18n, namespaces, () => resolve());
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
131
390
|
var css_248z$8 = ".will-filter-bar-divider {\n width: 1px;\n margin: 0 10px;\n height: 35px;\n background-color: #384265;\n}\n\n@media (max-width: 1024px) {\n .will-filter-bar-divider {\n width: 100%;\n margin: 0 10px;\n height: 1px;\n background-color: #384265;\n }\n}";
|
|
132
391
|
styleInject(css_248z$8);
|
|
133
392
|
|
|
@@ -148,7 +407,7 @@
|
|
|
148
407
|
|
|
149
408
|
function SubmitButton(_a) {
|
|
150
409
|
var onClick = _a.onClick;
|
|
151
|
-
var t =
|
|
410
|
+
var t = useTranslation('filterBar').t;
|
|
152
411
|
return (React__default.createElement("button", { className: "will-filter-bar-submit-button", onClick: onClick },
|
|
153
412
|
React__default.createElement("span", null),
|
|
154
413
|
t('submit.label')));
|
|
@@ -5718,7 +5977,7 @@
|
|
|
5718
5977
|
var currentMonth = new Date();
|
|
5719
5978
|
function Calendar(_a) {
|
|
5720
5979
|
var calendarRange = _a.calendarRange, setCalendarRange = _a.setCalendarRange;
|
|
5721
|
-
var t =
|
|
5980
|
+
var t = useTranslation('filterBar').t;
|
|
5722
5981
|
//const isTablet = useMediaQuery({ maxWidth: 1024 })
|
|
5723
5982
|
var defaultCalendarSelected = {
|
|
5724
5983
|
from: currentMonth,
|
|
@@ -5742,7 +6001,7 @@
|
|
|
5742
6001
|
|
|
5743
6002
|
function Guests(_a) {
|
|
5744
6003
|
var guestsAdults = _a.guestsAdults, guestsKids = _a.guestsKids, decrementAdults = _a.decrementAdults, incrementAdults = _a.incrementAdults, decrementKids = _a.decrementKids, incrementKids = _a.incrementKids;
|
|
5745
|
-
var t =
|
|
6004
|
+
var t = useTranslation('filterBar').t;
|
|
5746
6005
|
return (React__default.createElement("div", { className: "will-filter-bar-guests" },
|
|
5747
6006
|
React__default.createElement("h3", { className: "will-guests-filter-title" }, t('guests.title')),
|
|
5748
6007
|
React__default.createElement("p", { className: "will-guests-filter-subtitle" }, t('guests.subtitle')),
|
|
@@ -5772,7 +6031,7 @@
|
|
|
5772
6031
|
|
|
5773
6032
|
function Categories(_a) {
|
|
5774
6033
|
_a.categories; var setCategories = _a.setCategories;
|
|
5775
|
-
var t =
|
|
6034
|
+
var t = useTranslation('filterBar').t;
|
|
5776
6035
|
var categoriesPlaceholder = [
|
|
5777
6036
|
'Weekend',
|
|
5778
6037
|
'Week',
|
|
@@ -8177,7 +8436,7 @@
|
|
|
8177
8436
|
|
|
8178
8437
|
var urlParams = new URLSearchParams(window.location.search);
|
|
8179
8438
|
var localeFromUrl = urlParams.get('locale') || 'fi';
|
|
8180
|
-
instance.use(
|
|
8439
|
+
instance.use(initReactI18next).init({
|
|
8181
8440
|
resources: {
|
|
8182
8441
|
en: { filterBar: enFilterBar },
|
|
8183
8442
|
fi: { filterBar: fiFilterBar },
|
|
@@ -8198,7 +8457,7 @@
|
|
|
8198
8457
|
// Trigger a re-render by updating the rerenderKey
|
|
8199
8458
|
setRerenderKey(function (prevKey) { return prevKey + 1; });
|
|
8200
8459
|
}, [language]);
|
|
8201
|
-
var t =
|
|
8460
|
+
var t = useTranslation('filterBar').t;
|
|
8202
8461
|
var _c = useFilterBar(), selectedFilter = _c.selectedFilter, guestsAdults = _c.guestsAdults, guestsKids = _c.guestsKids, categories = _c.categories, calendarRange = _c.calendarRange, setCalendarRange = _c.setCalendarRange, setGuestsAdults = _c.setGuestsAdults, setGuestsKids = _c.setGuestsKids, setCategories = _c.setCategories, handleSelectedFilter = _c.handleSelectedFilter, handleSubmit = _c.handleSubmit;
|
|
8203
8462
|
return (React__default.createElement(React__default.Fragment, null,
|
|
8204
8463
|
selectedFilter && (React__default.createElement("div", { className: "will-filter-bar will-filter-bar-underlay", onClick: function () {
|