willba-component-library 0.0.72 → 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 CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as React__default from 'react';
2
- import React__default__default, { useState, createContext, useContext, useRef, useEffect, forwardRef } from 'react';
2
+ import React__default__default, { useState, createContext, forwardRef, useContext, useEffect, useRef } from 'react';
3
+ import { useTranslation, initReactI18next } from 'react-i18next';
3
4
 
4
5
  function getDefaultExportFromCjs (x) {
5
6
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -106,265 +107,6 @@ var Button$1 = function (_a) {
106
107
  return (React__default__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)));
107
108
  };
108
109
 
109
- function warn() {
110
- if (console && console.warn) {
111
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
112
- args[_key] = arguments[_key];
113
- }
114
- if (typeof args[0] === 'string') args[0] = `react-i18next:: ${args[0]}`;
115
- console.warn(...args);
116
- }
117
- }
118
- const alreadyWarned = {};
119
- function warnOnce() {
120
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
121
- args[_key2] = arguments[_key2];
122
- }
123
- if (typeof args[0] === 'string' && alreadyWarned[args[0]]) return;
124
- if (typeof args[0] === 'string') alreadyWarned[args[0]] = new Date();
125
- warn(...args);
126
- }
127
- const loadedClb = (i18n, cb) => () => {
128
- if (i18n.isInitialized) {
129
- cb();
130
- } else {
131
- const initialized = () => {
132
- setTimeout(() => {
133
- i18n.off('initialized', initialized);
134
- }, 0);
135
- cb();
136
- };
137
- i18n.on('initialized', initialized);
138
- }
139
- };
140
- function loadNamespaces(i18n, ns, cb) {
141
- i18n.loadNamespaces(ns, loadedClb(i18n, cb));
142
- }
143
- function loadLanguages(i18n, lng, ns, cb) {
144
- if (typeof ns === 'string') ns = [ns];
145
- ns.forEach(n => {
146
- if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n);
147
- });
148
- i18n.loadLanguages(lng, loadedClb(i18n, cb));
149
- }
150
- function oldI18nextHasLoadedNamespace(ns, i18n) {
151
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
152
- const lng = i18n.languages[0];
153
- const fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
154
- const lastLng = i18n.languages[i18n.languages.length - 1];
155
- if (lng.toLowerCase() === 'cimode') return true;
156
- const loadNotPending = (l, n) => {
157
- const loadState = i18n.services.backendConnector.state[`${l}|${n}`];
158
- return loadState === -1 || loadState === 2;
159
- };
160
- if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false;
161
- if (i18n.hasResourceBundle(lng, ns)) return true;
162
- if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
163
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
164
- return false;
165
- }
166
- function hasLoadedNamespace(ns, i18n) {
167
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
168
- if (!i18n.languages || !i18n.languages.length) {
169
- warnOnce('i18n.languages were undefined or empty', i18n.languages);
170
- return true;
171
- }
172
- const isNewerI18next = i18n.options.ignoreJSONStructure !== undefined;
173
- if (!isNewerI18next) {
174
- return oldI18nextHasLoadedNamespace(ns, i18n, options);
175
- }
176
- return i18n.hasLoadedNamespace(ns, {
177
- lng: options.lng,
178
- precheck: (i18nInstance, loadNotPending) => {
179
- if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
180
- }
181
- });
182
- }
183
-
184
- const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
185
- const htmlEntities = {
186
- '&amp;': '&',
187
- '&#38;': '&',
188
- '&lt;': '<',
189
- '&#60;': '<',
190
- '&gt;': '>',
191
- '&#62;': '>',
192
- '&apos;': "'",
193
- '&#39;': "'",
194
- '&quot;': '"',
195
- '&#34;': '"',
196
- '&nbsp;': ' ',
197
- '&#160;': ' ',
198
- '&copy;': '©',
199
- '&#169;': '©',
200
- '&reg;': '®',
201
- '&#174;': '®',
202
- '&hellip;': '…',
203
- '&#8230;': '…',
204
- '&#x2F;': '/',
205
- '&#47;': '/'
206
- };
207
- const unescapeHtmlEntity = m => htmlEntities[m];
208
- const unescape = text => text.replace(matchHtmlEntity, unescapeHtmlEntity);
209
-
210
- let defaultOptions$1 = {
211
- bindI18n: 'languageChanged',
212
- bindI18nStore: '',
213
- transEmptyNodeValue: '',
214
- transSupportBasicHtmlNodes: true,
215
- transWrapTextNodes: '',
216
- transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
217
- useSuspense: true,
218
- unescape
219
- };
220
- function setDefaults() {
221
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
222
- defaultOptions$1 = {
223
- ...defaultOptions$1,
224
- ...options
225
- };
226
- }
227
- function getDefaults() {
228
- return defaultOptions$1;
229
- }
230
-
231
- let i18nInstance;
232
- function setI18n(instance) {
233
- i18nInstance = instance;
234
- }
235
- function getI18n() {
236
- return i18nInstance;
237
- }
238
-
239
- const initReactI18next = {
240
- type: '3rdParty',
241
- init(instance) {
242
- setDefaults(instance.options.react);
243
- setI18n(instance);
244
- }
245
- };
246
-
247
- const I18nContext = createContext();
248
- class ReportNamespaces {
249
- constructor() {
250
- this.usedNamespaces = {};
251
- }
252
- addUsedNamespaces(namespaces) {
253
- namespaces.forEach(ns => {
254
- if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true;
255
- });
256
- }
257
- getUsedNamespaces() {
258
- return Object.keys(this.usedNamespaces);
259
- }
260
- }
261
-
262
- const usePrevious = (value, ignore) => {
263
- const ref = useRef();
264
- useEffect(() => {
265
- ref.current = ignore ? ref.current : value;
266
- }, [value, ignore]);
267
- return ref.current;
268
- };
269
- function useTranslation(ns) {
270
- let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
271
- const {
272
- i18n: i18nFromProps
273
- } = props;
274
- const {
275
- i18n: i18nFromContext,
276
- defaultNS: defaultNSFromContext
277
- } = useContext(I18nContext) || {};
278
- const i18n = i18nFromProps || i18nFromContext || getI18n();
279
- if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
280
- if (!i18n) {
281
- warnOnce('You will need to pass in an i18next instance by using initReactI18next');
282
- const notReadyT = (k, optsOrDefaultValue) => {
283
- if (typeof optsOrDefaultValue === 'string') return optsOrDefaultValue;
284
- if (optsOrDefaultValue && typeof optsOrDefaultValue === 'object' && typeof optsOrDefaultValue.defaultValue === 'string') return optsOrDefaultValue.defaultValue;
285
- return Array.isArray(k) ? k[k.length - 1] : k;
286
- };
287
- const retNotReady = [notReadyT, {}, false];
288
- retNotReady.t = notReadyT;
289
- retNotReady.i18n = {};
290
- retNotReady.ready = false;
291
- return retNotReady;
292
- }
293
- 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.');
294
- const i18nOptions = {
295
- ...getDefaults(),
296
- ...i18n.options.react,
297
- ...props
298
- };
299
- const {
300
- useSuspense,
301
- keyPrefix
302
- } = i18nOptions;
303
- let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
304
- namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
305
- if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
306
- const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => hasLoadedNamespace(n, i18n, i18nOptions));
307
- function getT() {
308
- return i18n.getFixedT(props.lng || null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
309
- }
310
- const [t, setT] = useState(getT);
311
- let joinedNS = namespaces.join();
312
- if (props.lng) joinedNS = `${props.lng}${joinedNS}`;
313
- const previousJoinedNS = usePrevious(joinedNS);
314
- const isMounted = useRef(true);
315
- useEffect(() => {
316
- const {
317
- bindI18n,
318
- bindI18nStore
319
- } = i18nOptions;
320
- isMounted.current = true;
321
- if (!ready && !useSuspense) {
322
- if (props.lng) {
323
- loadLanguages(i18n, props.lng, namespaces, () => {
324
- if (isMounted.current) setT(getT);
325
- });
326
- } else {
327
- loadNamespaces(i18n, namespaces, () => {
328
- if (isMounted.current) setT(getT);
329
- });
330
- }
331
- }
332
- if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
333
- setT(getT);
334
- }
335
- function boundReset() {
336
- if (isMounted.current) setT(getT);
337
- }
338
- if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
339
- if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset);
340
- return () => {
341
- isMounted.current = false;
342
- if (bindI18n && i18n) bindI18n.split(' ').forEach(e => i18n.off(e, boundReset));
343
- if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(e => i18n.store.off(e, boundReset));
344
- };
345
- }, [i18n, joinedNS]);
346
- const isInitial = useRef(true);
347
- useEffect(() => {
348
- if (isMounted.current && !isInitial.current) {
349
- setT(getT);
350
- }
351
- isInitial.current = false;
352
- }, [i18n, keyPrefix]);
353
- const ret = [t, i18n, ready];
354
- ret.t = t;
355
- ret.i18n = i18n;
356
- ret.ready = ready;
357
- if (ready) return ret;
358
- if (!ready && !useSuspense) return ret;
359
- throw new Promise(resolve => {
360
- if (props.lng) {
361
- loadLanguages(i18n, props.lng, namespaces, () => resolve());
362
- } else {
363
- loadNamespaces(i18n, namespaces, () => resolve());
364
- }
365
- });
366
- }
367
-
368
110
  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}";
369
111
  styleInject(css_248z$8);
370
112