@thecb/components 9.2.0-beta.9 → 9.2.0
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/dist/index.cjs.js +513 -468
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +60 -6
- package/dist/index.esm.js +512 -468
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/dropdown/Dropdown.js +70 -36
- package/src/components/atoms/dropdown/Dropdown.theme.js +8 -2
- package/src/components/molecules/popover/Popover.js +1 -1
- package/src/components/molecules/radio-section/radio-button/RadioButton.js +7 -5
- package/src/components/molecules/radio-section/radio-button/RadioButton.theme.js +2 -2
- package/src/components/molecules/terms-and-conditions/TermsAndConditionsControlV2.js +1 -1
- package/src/components/molecules/toast-notification/ToastNotification.js +5 -6
- package/src/components/molecules/toast-notification/ToastNotification.stories.js +4 -4
- package/src/constants/colors.js +2 -0
- package/src/hooks/index.js +3 -0
- package/src/{util/hooks → hooks}/use-toast-notification/index.d.ts +6 -6
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -1
- package/src/types/common/ToastVariants.ts +1 -1
- package/src/util/index.js +2 -2
- package/src/util/hooks/index.js +0 -1
- /package/src/{util/useOutsideClick.js → hooks/use-outside-click/index.js} +0 -0
- /package/src/{util/useScrollTo.js → hooks/use-scroll-to/index.js} +0 -0
- /package/src/{util/hooks → hooks}/use-toast-notification/index.js +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -298,6 +298,57 @@ declare namespace index_d {
|
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
+
/*
|
|
302
|
+
Hook that assigns a click event listener to the main document element
|
|
303
|
+
Returns a ref to attach to another element (like an icon/button that triggers a popover)
|
|
304
|
+
If a click event gets captured by the document and the assigned element isn't the target
|
|
305
|
+
hook will run whatever handler is passed (eg a function that closes a popover)
|
|
306
|
+
|
|
307
|
+
See popover component for implementation
|
|
308
|
+
|
|
309
|
+
*/
|
|
310
|
+
|
|
311
|
+
declare const useOutsideClickHook = handler => {
|
|
312
|
+
const ref = useRef();
|
|
313
|
+
|
|
314
|
+
useEffect(() => {
|
|
315
|
+
const handleOutsideClick = e => {
|
|
316
|
+
if (ref.current && !ref.current.contains(e.target)) {
|
|
317
|
+
handler();
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
document.addEventListener("click", handleOutsideClick, true);
|
|
321
|
+
|
|
322
|
+
return () => {
|
|
323
|
+
document.removeEventListener("click", handleOutsideClick, true);
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
}, [ref]);
|
|
327
|
+
|
|
328
|
+
return ref;
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
/*
|
|
332
|
+
Hook that takes an ID selector for an element on the screen
|
|
333
|
+
And optionally values for top position, left position, smooth behavior
|
|
334
|
+
Finds element on screen and scrolls it to the provided coordinates
|
|
335
|
+
|
|
336
|
+
(string, number, number, string, number) => undefined;
|
|
337
|
+
*/
|
|
338
|
+
|
|
339
|
+
declare const useScrollTo = (id, top = 0, left = 0, behavior = "auto", delay) => {
|
|
340
|
+
let scrollItem;
|
|
341
|
+
if (delay) {
|
|
342
|
+
setTimeout(() => {
|
|
343
|
+
scrollItem = document.getElementById(id);
|
|
344
|
+
scrollItem?.scrollTo({ top, left, behavior });
|
|
345
|
+
}, delay);
|
|
346
|
+
} else {
|
|
347
|
+
scrollItem = document.getElementById(id);
|
|
348
|
+
scrollItem?.scrollTo({ top, left, behavior });
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
|
|
301
352
|
interface Field {
|
|
302
353
|
hasErrors: boolean;
|
|
303
354
|
dirty: boolean;
|
|
@@ -359,36 +410,39 @@ interface ErrorMessageDictionary {
|
|
|
359
410
|
|
|
360
411
|
enum ToastVariants {
|
|
361
412
|
ERROR = "error",
|
|
362
|
-
SUCCESS = "success"
|
|
413
|
+
SUCCESS = "success"
|
|
363
414
|
}
|
|
364
415
|
|
|
365
|
-
interface
|
|
416
|
+
interface UseToastOptions {
|
|
366
417
|
timeout?: number;
|
|
367
418
|
}
|
|
368
419
|
|
|
369
420
|
interface UseToastResult {
|
|
370
421
|
isToastOpen: boolean;
|
|
371
|
-
toastVariant:
|
|
422
|
+
toastVariant: string | ToastVariants;
|
|
372
423
|
toastMessage: string;
|
|
373
424
|
showToast: ({
|
|
374
425
|
message,
|
|
375
|
-
variant
|
|
426
|
+
variant
|
|
376
427
|
}: {
|
|
377
428
|
message: string;
|
|
378
|
-
variant: ToastVariants;
|
|
429
|
+
variant: string | ToastVariants;
|
|
379
430
|
}) => void;
|
|
380
431
|
hideToast: () => void;
|
|
381
432
|
}
|
|
382
433
|
|
|
383
434
|
declare function useToastNotification(
|
|
384
|
-
|
|
435
|
+
options?: UseToastOptions
|
|
385
436
|
): UseToastResult;
|
|
386
437
|
|
|
387
438
|
|
|
388
439
|
|
|
440
|
+
declare const index_useScrollTo: typeof useScrollTo;
|
|
389
441
|
declare const index_useToastNotification: typeof useToastNotification;
|
|
390
442
|
declare namespace index {
|
|
391
443
|
export {
|
|
444
|
+
useOutsideClickHook as useOutsideClick,
|
|
445
|
+
index_useScrollTo as useScrollTo,
|
|
392
446
|
index_useToastNotification as useToastNotification,
|
|
393
447
|
};
|
|
394
448
|
}
|