willba-component-library 0.0.71 → 0.0.73
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 +2 -260
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +7 -265
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +10 -269
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/rollup.config.mjs +2 -0
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'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MyComponentLibrary = {}, global.React));
|
|
5
|
-
})(this, (function (exports, React__default) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-i18next')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-i18next'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MyComponentLibrary = {}, global.React, global.ReactI18next));
|
|
5
|
+
})(this, (function (exports, React__default, reactI18next) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
|
8
8
|
var n = Object.create(null);
|
|
@@ -128,265 +128,6 @@
|
|
|
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
|
-
|
|
390
131
|
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}";
|
|
391
132
|
styleInject(css_248z$8);
|
|
392
133
|
|
|
@@ -407,7 +148,7 @@
|
|
|
407
148
|
|
|
408
149
|
function SubmitButton(_a) {
|
|
409
150
|
var onClick = _a.onClick;
|
|
410
|
-
var t = useTranslation('filterBar').t;
|
|
151
|
+
var t = reactI18next.useTranslation('filterBar').t;
|
|
411
152
|
return (React__default.createElement("button", { className: "will-filter-bar-submit-button", onClick: onClick },
|
|
412
153
|
React__default.createElement("span", null),
|
|
413
154
|
t('submit.label')));
|
|
@@ -5977,7 +5718,7 @@
|
|
|
5977
5718
|
var currentMonth = new Date();
|
|
5978
5719
|
function Calendar(_a) {
|
|
5979
5720
|
var calendarRange = _a.calendarRange, setCalendarRange = _a.setCalendarRange;
|
|
5980
|
-
var t = useTranslation('filterBar').t;
|
|
5721
|
+
var t = reactI18next.useTranslation('filterBar').t;
|
|
5981
5722
|
//const isTablet = useMediaQuery({ maxWidth: 1024 })
|
|
5982
5723
|
var defaultCalendarSelected = {
|
|
5983
5724
|
from: currentMonth,
|
|
@@ -6001,7 +5742,7 @@
|
|
|
6001
5742
|
|
|
6002
5743
|
function Guests(_a) {
|
|
6003
5744
|
var guestsAdults = _a.guestsAdults, guestsKids = _a.guestsKids, decrementAdults = _a.decrementAdults, incrementAdults = _a.incrementAdults, decrementKids = _a.decrementKids, incrementKids = _a.incrementKids;
|
|
6004
|
-
var t = useTranslation('filterBar').t;
|
|
5745
|
+
var t = reactI18next.useTranslation('filterBar').t;
|
|
6005
5746
|
return (React__default.createElement("div", { className: "will-filter-bar-guests" },
|
|
6006
5747
|
React__default.createElement("h3", { className: "will-guests-filter-title" }, t('guests.title')),
|
|
6007
5748
|
React__default.createElement("p", { className: "will-guests-filter-subtitle" }, t('guests.subtitle')),
|
|
@@ -6031,7 +5772,7 @@
|
|
|
6031
5772
|
|
|
6032
5773
|
function Categories(_a) {
|
|
6033
5774
|
_a.categories; var setCategories = _a.setCategories;
|
|
6034
|
-
var t = useTranslation('filterBar').t;
|
|
5775
|
+
var t = reactI18next.useTranslation('filterBar').t;
|
|
6035
5776
|
var categoriesPlaceholder = [
|
|
6036
5777
|
'Weekend',
|
|
6037
5778
|
'Week',
|
|
@@ -8436,7 +8177,7 @@
|
|
|
8436
8177
|
|
|
8437
8178
|
var urlParams = new URLSearchParams(window.location.search);
|
|
8438
8179
|
var localeFromUrl = urlParams.get('locale') || 'fi';
|
|
8439
|
-
instance.use(initReactI18next).init({
|
|
8180
|
+
instance.use(reactI18next.initReactI18next).init({
|
|
8440
8181
|
resources: {
|
|
8441
8182
|
en: { filterBar: enFilterBar },
|
|
8442
8183
|
fi: { filterBar: fiFilterBar },
|
|
@@ -8457,7 +8198,7 @@
|
|
|
8457
8198
|
// Trigger a re-render by updating the rerenderKey
|
|
8458
8199
|
setRerenderKey(function (prevKey) { return prevKey + 1; });
|
|
8459
8200
|
}, [language]);
|
|
8460
|
-
var t = useTranslation('filterBar').t;
|
|
8201
|
+
var t = reactI18next.useTranslation('filterBar').t;
|
|
8461
8202
|
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;
|
|
8462
8203
|
return (React__default.createElement(React__default.Fragment, null,
|
|
8463
8204
|
selectedFilter && (React__default.createElement("div", { className: "will-filter-bar will-filter-bar-underlay", onClick: function () {
|