@thecb/components 9.2.0-beta.6 → 9.2.0-beta.8
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 +49 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +96 -60
- package/dist/index.esm.js +49 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/toast-notification/ToastNotification.stories.js +43 -12
- package/src/components/molecules/toast-notification/index.d.ts +1 -1
- package/src/index.d.ts +2 -1
- package/src/types/common/ToastVariants.ts +6 -0
- package/src/types/common/index.ts +1 -0
- package/src/util/hooks/index.js +1 -0
- package/src/util/hooks/use-toast-notification/index.d.ts +23 -0
- package/src/util/hooks/use-toast-notification/index.js +38 -0
- package/src/util/index.js +9 -1
package/dist/index.d.ts
CHANGED
|
@@ -298,6 +298,101 @@ declare namespace index_d {
|
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
+
interface Field {
|
|
302
|
+
hasErrors: boolean;
|
|
303
|
+
dirty: boolean;
|
|
304
|
+
rawValue: string;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
interface ReduxAction<T = string, P = {}> {
|
|
308
|
+
type: T;
|
|
309
|
+
payload?: P;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* These types should be moved to and referenced from redux-freeform if it implements TypeScript
|
|
314
|
+
*/
|
|
315
|
+
|
|
316
|
+
type ValidatorFn = (value: string) => boolean;
|
|
317
|
+
|
|
318
|
+
interface FieldActionPayload {
|
|
319
|
+
fieldName: string;
|
|
320
|
+
value?: string;
|
|
321
|
+
validator?: ValidatorFn;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
type SetAction = ReduxAction<"field/SET", FieldActionPayload>;
|
|
325
|
+
type AddValidatorAction = ReduxAction<
|
|
326
|
+
"field/ADD_VALIDATOR",
|
|
327
|
+
FieldActionPayload
|
|
328
|
+
>;
|
|
329
|
+
type RemoveValidatorAction = ReduxAction<
|
|
330
|
+
"field/REMOVE_VALIDATOR",
|
|
331
|
+
FieldActionPayload
|
|
332
|
+
>;
|
|
333
|
+
type ClearAction = ReduxAction<"field/CLEAR">;
|
|
334
|
+
|
|
335
|
+
interface FieldActions {
|
|
336
|
+
set?: (fieldName: string) => (value: string) => SetAction;
|
|
337
|
+
addValidator?: (
|
|
338
|
+
fieldName: string
|
|
339
|
+
) => (validator: ValidatorFn) => AddValidatorAction;
|
|
340
|
+
removeValidator?: (
|
|
341
|
+
fieldName: string
|
|
342
|
+
) => (validator: ValidatorFn) => RemoveValidatorAction;
|
|
343
|
+
clear?: () => ClearAction;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
interface FormSelectOption {
|
|
347
|
+
text?: string;
|
|
348
|
+
value?: string;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
interface SearchableSelectOption {
|
|
352
|
+
name?: string;
|
|
353
|
+
value?: string;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
interface ErrorMessageDictionary {
|
|
357
|
+
[fieldName: string]: string;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
enum ToastVariants {
|
|
361
|
+
ERROR = "error",
|
|
362
|
+
SUCCESS = "success",
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
interface UseToastProps {
|
|
366
|
+
timeout?: number;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
interface UseToastResult {
|
|
370
|
+
isToastOpen: boolean;
|
|
371
|
+
toastVariant: "" | ToastVariants;
|
|
372
|
+
toastMessage: string;
|
|
373
|
+
showToast: ({
|
|
374
|
+
message,
|
|
375
|
+
variant,
|
|
376
|
+
}: {
|
|
377
|
+
message: string;
|
|
378
|
+
variant: ToastVariants;
|
|
379
|
+
}) => void;
|
|
380
|
+
hideToast: () => void;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
declare function useToastNotification({
|
|
384
|
+
timeout,
|
|
385
|
+
}: UseToastProps): UseToastResult;
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
declare const index_useToastNotification: typeof useToastNotification;
|
|
390
|
+
declare namespace index {
|
|
391
|
+
export {
|
|
392
|
+
index_useToastNotification as useToastNotification,
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
|
|
301
396
|
type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
|
|
302
397
|
|
|
303
398
|
interface AlertProps {
|
|
@@ -382,65 +477,6 @@ interface CardProps {
|
|
|
382
477
|
declare const Card: React.FC<Expand<CardProps> &
|
|
383
478
|
React.HTMLAttributes<HTMLElement>>;
|
|
384
479
|
|
|
385
|
-
interface Field {
|
|
386
|
-
hasErrors: boolean;
|
|
387
|
-
dirty: boolean;
|
|
388
|
-
rawValue: string;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
interface ReduxAction<T = string, P = {}> {
|
|
392
|
-
type: T;
|
|
393
|
-
payload?: P;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* These types should be moved to and referenced from redux-freeform if it implements TypeScript
|
|
398
|
-
*/
|
|
399
|
-
|
|
400
|
-
type ValidatorFn = (value: string) => boolean;
|
|
401
|
-
|
|
402
|
-
interface FieldActionPayload {
|
|
403
|
-
fieldName: string;
|
|
404
|
-
value?: string;
|
|
405
|
-
validator?: ValidatorFn;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
type SetAction = ReduxAction<"field/SET", FieldActionPayload>;
|
|
409
|
-
type AddValidatorAction = ReduxAction<
|
|
410
|
-
"field/ADD_VALIDATOR",
|
|
411
|
-
FieldActionPayload
|
|
412
|
-
>;
|
|
413
|
-
type RemoveValidatorAction = ReduxAction<
|
|
414
|
-
"field/REMOVE_VALIDATOR",
|
|
415
|
-
FieldActionPayload
|
|
416
|
-
>;
|
|
417
|
-
type ClearAction = ReduxAction<"field/CLEAR">;
|
|
418
|
-
|
|
419
|
-
interface FieldActions {
|
|
420
|
-
set?: (fieldName: string) => (value: string) => SetAction;
|
|
421
|
-
addValidator?: (
|
|
422
|
-
fieldName: string
|
|
423
|
-
) => (validator: ValidatorFn) => AddValidatorAction;
|
|
424
|
-
removeValidator?: (
|
|
425
|
-
fieldName: string
|
|
426
|
-
) => (validator: ValidatorFn) => RemoveValidatorAction;
|
|
427
|
-
clear?: () => ClearAction;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
interface FormSelectOption {
|
|
431
|
-
text?: string;
|
|
432
|
-
value?: string;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
interface SearchableSelectOption {
|
|
436
|
-
name?: string;
|
|
437
|
-
value?: string;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
interface ErrorMessageDictionary {
|
|
441
|
-
[fieldName: string]: string;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
480
|
interface FormInputProps {
|
|
445
481
|
extraStyles?: string;
|
|
446
482
|
field?: Field;
|
|
@@ -1095,5 +1131,5 @@ interface DefaultPageTemplateProps {
|
|
|
1095
1131
|
declare const DefaultPageTemplate: React.FC<Expand<DefaultPageTemplateProps> &
|
|
1096
1132
|
React.HTMLAttributes<HTMLElement>>;
|
|
1097
1133
|
|
|
1098
|
-
export { AddValidatorAction, Alert, AlertProps, ArrowDownCircleIconSmall, ArrowDownCircleIconSmallProps, ArrowLeftCircleIconMedium, ArrowLeftCircleIconMediumProps, ArrowLeftCircleIconSmall, ArrowLeftCircleIconSmallProps, ArrowRightCircleIconSmall, ArrowRightCircleIconSmallProps, ArrowUpCircleIconSmall, ArrowUpCircleIconSmallProps, BankIconLarge, BankIconLargeProps, Box, BoxProps, ButtonWithAction, ButtonWithActionProps, ButtonWithLink, ButtonWithLinkProps, Card, CardProps, Center, CenterProps, ChargebackIconMedium, ChargebackIconMediumProps, ChargebackIconSmall, ChargebackIconSmallProps, ChargebackReversalIconMedium, ChargebackReversalIconMediumProps, ChargebackReversalIconSmall, ChargebackReversalIconSmallProps, ClearAction, Cluster, ClusterProps, CollapsibleSection, CollapsibleSectionProps, Copyable, CopyableProps, Cover, CoverProps, DefaultPageTemplate, DefaultPageTemplateProps, EditableTable, EditableTableProps, ErrorMessageDictionary, ExternalLink, ExternalLinkProps, Field, FieldActionPayload, FieldActions, FooterWithSubfooter, FooterWithSubfooterProps, FormInput, FormInputProps, FormSelect, FormSelectOption, FormSelectProps, GuidedCheckoutImage, HistoryIconSmall, InternalLink, InternalLinkProps, KioskImage, Loading, LoadingProps, NavFooter, NavFooterProps, NavHeader, NavHeaderProps, NavTabs, NavTabsProps, Paragraph, ParagraphProps, PointOfSaleImage, Popover, PopoverProps, ProfileImage, RadioGroup, RadioGroupProps, ReduxAction, RefundIconMedium, RefundIconMediumProps, RefundIconSmall, RefundIconSmallProps, RemoveValidatorAction, RevenueManagementImage, SearchableSelect, SearchableSelectOption, SearchableSelectProps, SetAction, Spinner, SpinnerProps, Stack, StackProps, StandardCheckoutImage, SuccessfulIconMedium, SuccessfulIconMediumProps, SuccessfulIconSmall, SuccessfulIconSmallProps, Switcher, SwitcherProps, Table, TableBody, TableBodyProps, TableCell, TableCellProps, TableHead, TableHeadProps, TableHeading, TableHeadingProps, TableListItem, TableListItemProps, TableProps, TableRow, TableRowProps, Text, TextProps, Title, TitleProps, ToastNotification, ToastNotificationProps, ValidatorFn, XCircleIconMedium, XCircleIconMediumProps, XCircleIconSmall, XCircleIconSmallProps, index_d as constants };
|
|
1134
|
+
export { AddValidatorAction, Alert, AlertProps, ArrowDownCircleIconSmall, ArrowDownCircleIconSmallProps, ArrowLeftCircleIconMedium, ArrowLeftCircleIconMediumProps, ArrowLeftCircleIconSmall, ArrowLeftCircleIconSmallProps, ArrowRightCircleIconSmall, ArrowRightCircleIconSmallProps, ArrowUpCircleIconSmall, ArrowUpCircleIconSmallProps, BankIconLarge, BankIconLargeProps, Box, BoxProps, ButtonWithAction, ButtonWithActionProps, ButtonWithLink, ButtonWithLinkProps, Card, CardProps, Center, CenterProps, ChargebackIconMedium, ChargebackIconMediumProps, ChargebackIconSmall, ChargebackIconSmallProps, ChargebackReversalIconMedium, ChargebackReversalIconMediumProps, ChargebackReversalIconSmall, ChargebackReversalIconSmallProps, ClearAction, Cluster, ClusterProps, CollapsibleSection, CollapsibleSectionProps, Copyable, CopyableProps, Cover, CoverProps, DefaultPageTemplate, DefaultPageTemplateProps, EditableTable, EditableTableProps, ErrorMessageDictionary, ExternalLink, ExternalLinkProps, Field, FieldActionPayload, FieldActions, FooterWithSubfooter, FooterWithSubfooterProps, FormInput, FormInputProps, FormSelect, FormSelectOption, FormSelectProps, GuidedCheckoutImage, HistoryIconSmall, InternalLink, InternalLinkProps, KioskImage, Loading, LoadingProps, NavFooter, NavFooterProps, NavHeader, NavHeaderProps, NavTabs, NavTabsProps, Paragraph, ParagraphProps, PointOfSaleImage, Popover, PopoverProps, ProfileImage, RadioGroup, RadioGroupProps, ReduxAction, RefundIconMedium, RefundIconMediumProps, RefundIconSmall, RefundIconSmallProps, RemoveValidatorAction, RevenueManagementImage, SearchableSelect, SearchableSelectOption, SearchableSelectProps, SetAction, Spinner, SpinnerProps, Stack, StackProps, StandardCheckoutImage, SuccessfulIconMedium, SuccessfulIconMediumProps, SuccessfulIconSmall, SuccessfulIconSmallProps, Switcher, SwitcherProps, Table, TableBody, TableBodyProps, TableCell, TableCellProps, TableHead, TableHeadProps, TableHeading, TableHeadingProps, TableListItem, TableListItemProps, TableProps, TableRow, TableRowProps, Text, TextProps, Title, TitleProps, ToastNotification, ToastNotificationProps, ToastVariants, ValidatorFn, XCircleIconMedium, XCircleIconMediumProps, XCircleIconSmall, XCircleIconSmallProps, index_d as constants, index as hooks };
|
|
1099
1135
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.esm.js
CHANGED
|
@@ -25578,6 +25578,53 @@ var useOutsideClickHook = function useOutsideClickHook(handler) {
|
|
|
25578
25578
|
return ref;
|
|
25579
25579
|
};
|
|
25580
25580
|
|
|
25581
|
+
var initialToastState = {
|
|
25582
|
+
isOpen: false,
|
|
25583
|
+
variant: "",
|
|
25584
|
+
message: ""
|
|
25585
|
+
};
|
|
25586
|
+
|
|
25587
|
+
var useToastNotification = function useToastNotification() {
|
|
25588
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
25589
|
+
_ref$timeout = _ref.timeout,
|
|
25590
|
+
timeout = _ref$timeout === void 0 ? 5000 : _ref$timeout;
|
|
25591
|
+
|
|
25592
|
+
var _useState = useState(initialToastState),
|
|
25593
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25594
|
+
toastState = _useState2[0],
|
|
25595
|
+
setToastState = _useState2[1];
|
|
25596
|
+
|
|
25597
|
+
useEffect$1(function () {
|
|
25598
|
+
if (toastState.isOpen) {
|
|
25599
|
+
setTimeout(function () {
|
|
25600
|
+
setToastState(initialToastState);
|
|
25601
|
+
}, timeout);
|
|
25602
|
+
}
|
|
25603
|
+
}, [timeout, toastState.isOpen]);
|
|
25604
|
+
|
|
25605
|
+
var showToast = function showToast(_ref2) {
|
|
25606
|
+
var message = _ref2.message,
|
|
25607
|
+
variant = _ref2.variant;
|
|
25608
|
+
return setToastState({
|
|
25609
|
+
isOpen: true,
|
|
25610
|
+
variant: variant,
|
|
25611
|
+
message: message
|
|
25612
|
+
});
|
|
25613
|
+
};
|
|
25614
|
+
|
|
25615
|
+
var hideToast = function hideToast() {
|
|
25616
|
+
return setToastState(initialToastState);
|
|
25617
|
+
};
|
|
25618
|
+
|
|
25619
|
+
return {
|
|
25620
|
+
isToastOpen: toastState.isOpen,
|
|
25621
|
+
toastVariant: toastState.variant,
|
|
25622
|
+
toastMessage: toastState.message,
|
|
25623
|
+
showToast: showToast,
|
|
25624
|
+
hideToast: hideToast
|
|
25625
|
+
};
|
|
25626
|
+
};
|
|
25627
|
+
|
|
25581
25628
|
|
|
25582
25629
|
|
|
25583
25630
|
var index$4 = /*#__PURE__*/Object.freeze({
|
|
@@ -25586,7 +25633,8 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
25586
25633
|
general: general,
|
|
25587
25634
|
theme: themeUtils,
|
|
25588
25635
|
useFocusInvalidInput: useFocusInvalidInput,
|
|
25589
|
-
useOutsideClick: useOutsideClickHook
|
|
25636
|
+
useOutsideClick: useOutsideClickHook,
|
|
25637
|
+
useToastNotification: useToastNotification
|
|
25590
25638
|
});
|
|
25591
25639
|
|
|
25592
25640
|
var hoverColor$4 = "#116285";
|