@hyphen/hyphen-components 2.9.0 → 2.9.2

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.
Files changed (153) hide show
  1. package/dist/components/Alert/Alert.constants.d.ts +8 -0
  2. package/dist/components/Alert/Alert.d.ts +51 -0
  3. package/dist/components/Alert/Alert.stories.d.ts +8 -0
  4. package/dist/components/Alert/Alert.types.d.ts +7 -0
  5. package/dist/components/Badge/Badge.d.ts +31 -0
  6. package/dist/components/Badge/Badge.stories.d.ts +8 -0
  7. package/dist/components/Box/Box.d.ts +228 -0
  8. package/dist/components/Box/Box.stories.d.ts +42 -0
  9. package/dist/components/Button/Button.constants.d.ts +3 -0
  10. package/dist/components/Button/Button.d.ts +83 -0
  11. package/dist/components/Button/Button.stories.d.ts +14 -0
  12. package/dist/components/Card/Card.d.ts +17 -0
  13. package/dist/components/Card/Card.stories.d.ts +8 -0
  14. package/dist/components/Card/components/CardFooter/CardFooter.d.ts +13 -0
  15. package/dist/components/Card/components/CardHeader/CardHeader.d.ts +21 -0
  16. package/dist/components/Card/components/CardSection/CardSection.d.ts +46 -0
  17. package/dist/components/Card/components/index.d.ts +3 -0
  18. package/dist/components/CheckboxInput/CheckboxInput.d.ts +72 -0
  19. package/dist/components/CheckboxInput/CheckboxInput.stories.d.ts +18 -0
  20. package/dist/components/CheckboxInput/components/Checkbox.d.ts +71 -0
  21. package/dist/components/CheckboxInput/components/CheckboxIcon.d.ts +27 -0
  22. package/dist/components/DateInput/DateInput.d.ts +55 -0
  23. package/dist/components/DateInput/DateInput.stories.d.ts +11 -0
  24. package/dist/components/DatePicker/DatePicker.d.ts +86 -0
  25. package/dist/components/DatePicker/DatePicker.stories.d.ts +13 -0
  26. package/dist/components/Details/Details.d.ts +15 -0
  27. package/dist/components/Details/Details.stories.d.ts +6 -0
  28. package/dist/components/Details/DetailsSummary.d.ts +7 -0
  29. package/dist/components/Drawer/Drawer.d.ts +88 -0
  30. package/dist/components/Drawer/Drawer.stories.d.ts +15 -0
  31. package/dist/components/FormControl/FormControl.d.ts +38 -0
  32. package/dist/components/FormLabel/FormLabel.d.ts +41 -0
  33. package/dist/components/FormLabel/FormLabel.stories.d.ts +6 -0
  34. package/dist/components/Formik/Formik.stories.d.ts +18 -0
  35. package/dist/components/Formik/FormikCheckboxInput/FormikCheckboxInput.d.ts +12 -0
  36. package/dist/components/Formik/FormikRadioGroup/FormikRadioGroup.d.ts +12 -0
  37. package/dist/components/Formik/FormikSelectInput/FormikSelectInput.d.ts +12 -0
  38. package/dist/components/Formik/FormikSelectInputInset/FormikSelectInputInset.d.ts +12 -0
  39. package/dist/components/Formik/FormikSelectInputNative/FormikSelectInputNative.d.ts +12 -0
  40. package/dist/components/Formik/FormikTextInput/FormikTextInput.d.ts +12 -0
  41. package/dist/components/Formik/FormikTextInputInset/FormikTextInputInset.d.ts +12 -0
  42. package/dist/components/Formik/FormikTextareaInput/FormikTextareaInput.d.ts +12 -0
  43. package/dist/components/Formik/FormikTextareaInputInset/FormikTextareaInputInset.d.ts +12 -0
  44. package/dist/components/Formik/FormikTimePicker/FormikTimePicker.d.ts +12 -0
  45. package/dist/components/Formik/FormikTimePickerNative/FormikTimePickerNative.d.ts +12 -0
  46. package/dist/components/Formik/FormikToggle/FormikToggle.d.ts +12 -0
  47. package/dist/components/Heading/Heading.constants.d.ts +10 -0
  48. package/dist/components/Heading/Heading.d.ts +35 -0
  49. package/dist/components/Heading/Heading.stories.d.ts +9 -0
  50. package/dist/components/HelpText/HelpText.d.ts +12 -0
  51. package/dist/components/Icon/Icon.d.ts +22 -0
  52. package/dist/components/Icon/Icon.stories.d.ts +10 -0
  53. package/dist/components/InputValidationMessage/InputValidationMessage.d.ts +9 -0
  54. package/dist/components/Modal/Modal.d.ts +75 -0
  55. package/dist/components/Modal/Modal.stories.d.ts +11 -0
  56. package/dist/components/Modal/components/ModalBody/ModalBody.d.ts +4 -0
  57. package/dist/components/Modal/components/ModalFooter/ModalFooter.d.ts +4 -0
  58. package/dist/components/Modal/components/ModalHeader/ModalHeader.d.ts +16 -0
  59. package/dist/components/Modal/components/index.d.ts +4 -0
  60. package/dist/components/Pagination/Pagination.d.ts +51 -0
  61. package/dist/components/Pagination/Pagination.stories.d.ts +8 -0
  62. package/dist/components/Pagination/Pagination.utilities.d.ts +11 -0
  63. package/dist/components/Popover/Popover.d.ts +80 -0
  64. package/dist/components/Popover/Popover.stories.d.ts +14 -0
  65. package/dist/components/RadioGroup/RadioGroup.d.ts +75 -0
  66. package/dist/components/RadioGroup/RadioGroup.stories.d.ts +16 -0
  67. package/dist/components/RadioGroup/RadioInput/RadioInput.d.ts +57 -0
  68. package/dist/components/RadioGroup/RadioInput/RadioInputIcon.d.ts +27 -0
  69. package/dist/components/ResponsiveProvider/ResponsiveProvider.d.ts +17 -0
  70. package/dist/components/ResponsiveProvider/ResponsiveProvider.stories.d.ts +7 -0
  71. package/dist/components/SelectInput/SelectInput.d.ts +110 -0
  72. package/dist/components/SelectInput/SelectInput.stories.d.ts +20 -0
  73. package/dist/components/SelectInputInset/SelectInputInset.d.ts +92 -0
  74. package/dist/components/SelectInputInset/SelectInputInset.stories.d.ts +12 -0
  75. package/dist/components/SelectInputNative/SelectInputNative.d.ts +43 -0
  76. package/dist/components/SelectInputNative/SelectInputNative.stories.d.ts +16 -0
  77. package/dist/components/Spinner/Spinner.d.ts +12 -0
  78. package/dist/components/Spinner/Spinner.stories.d.ts +8 -0
  79. package/dist/components/Table/Table.d.ts +86 -0
  80. package/dist/components/Table/Table.stories.d.ts +31 -0
  81. package/dist/components/Table/TableBody/TableBody.d.ts +52 -0
  82. package/dist/components/Table/TableBody/TableBodyCell/TableBodyCell.d.ts +45 -0
  83. package/dist/components/Table/TableHead/TableHead.d.ts +46 -0
  84. package/dist/components/Table/TableHead/TableHeaderCell/TableHeaderCell.d.ts +65 -0
  85. package/dist/components/Table/common/TableRow/TableRow.d.ts +67 -0
  86. package/dist/components/TextInput/TextInput.d.ts +106 -0
  87. package/dist/components/TextInput/TextInput.stories.d.ts +19 -0
  88. package/dist/components/TextInputInset/TextInputInset.d.ts +102 -0
  89. package/dist/components/TextInputInset/TextInputInset.stories.d.ts +13 -0
  90. package/dist/components/TextareaInput/TextareaInput.d.ts +97 -0
  91. package/dist/components/TextareaInput/TextareaInput.stories.d.ts +23 -0
  92. package/dist/components/TextareaInputInset/TextareaInputInset.d.ts +105 -0
  93. package/dist/components/TextareaInputInset/TextareaInputInset.stories.d.ts +12 -0
  94. package/dist/components/ThemeProvider/ThemeProvider.d.ts +14 -0
  95. package/dist/components/ThemeProvider/ThemeProvider.stories.d.ts +6 -0
  96. package/dist/components/TimePicker/TimePicker.d.ts +35 -0
  97. package/dist/components/TimePicker/TimePicker.stories.d.ts +12 -0
  98. package/dist/components/TimePickerNative/TimePickerNative.d.ts +39 -0
  99. package/dist/components/TimePickerNative/TimePickerNative.stories.d.ts +11 -0
  100. package/dist/components/Toast/Toast.store.d.ts +36 -0
  101. package/dist/components/Toast/Toast.stories.d.ts +14 -0
  102. package/dist/components/Toast/Toast.types.d.ts +75 -0
  103. package/dist/components/Toast/ToastContainer.d.ts +43 -0
  104. package/dist/components/Toast/ToastNotification.d.ts +28 -0
  105. package/dist/components/Toast/index.d.ts +4 -0
  106. package/dist/components/Toast/toast.d.ts +20 -0
  107. package/dist/components/Toast/useToasts.d.ts +14 -0
  108. package/dist/components/Toggle/Toggle.d.ts +64 -0
  109. package/dist/components/Toggle/Toggle.stories.d.ts +12 -0
  110. package/dist/constants/keyCodes.d.ts +2 -0
  111. package/dist/css/fonts.css +33 -0
  112. package/dist/css/index.css +32 -0
  113. package/dist/css/reset.css +98 -0
  114. package/dist/css/utilities.css +6049 -0
  115. package/dist/css/variables.css +418 -0
  116. package/dist/hooks/index.d.ts +4 -0
  117. package/dist/hooks/useBreakpoint/useBreakpoint.d.ts +9 -0
  118. package/dist/hooks/useBreakpoint/useBreakpoint.stories.d.ts +6 -0
  119. package/dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayouEffect.d.ts +2 -0
  120. package/dist/hooks/useOpenClose/useOpenClose.d.ts +39 -0
  121. package/dist/hooks/useOpenClose/useOpenClose.stories.d.ts +6 -0
  122. package/dist/hooks/useWindowSize/useWindowSize.d.ts +7 -0
  123. package/dist/hooks/useWindowSize/useWindowSize.stories.d.ts +6 -0
  124. package/dist/hyphen-components.cjs.development.js +4724 -0
  125. package/dist/hyphen-components.cjs.development.js.map +1 -0
  126. package/dist/hyphen-components.cjs.production.min.js +2 -0
  127. package/dist/hyphen-components.cjs.production.min.js.map +1 -0
  128. package/dist/hyphen-components.esm.js +4661 -0
  129. package/dist/hyphen-components.esm.js.map +1 -0
  130. package/dist/index.d.ts +48 -0
  131. package/dist/index.js +8 -0
  132. package/dist/lib/cssShorthandToClasses.d.ts +4 -0
  133. package/dist/lib/doesStringIncludeCssUnit.d.ts +1 -0
  134. package/dist/lib/generateResponsiveClasses.d.ts +2 -0
  135. package/dist/lib/getAutoCompleteValue.d.ts +1 -0
  136. package/dist/lib/getColumnKeys.d.ts +3 -0
  137. package/dist/lib/getDimensionCss.d.ts +12 -0
  138. package/dist/lib/getElementType.d.ts +14 -0
  139. package/dist/lib/getFlexCss.d.ts +9 -0
  140. package/dist/lib/index.d.ts +15 -0
  141. package/dist/lib/isFunction.d.ts +2 -0
  142. package/dist/lib/mergeRefs.d.ts +2 -0
  143. package/dist/lib/prefersReducedMotion.d.ts +1 -0
  144. package/dist/lib/react-children-utilities/filter.d.ts +3 -0
  145. package/dist/lib/react-children-utilities/index.d.ts +1 -0
  146. package/dist/lib/reactRouterClickHandler.d.ts +12 -0
  147. package/dist/lib/resolveValue.d.ts +2 -0
  148. package/dist/lib/tokens.d.ts +22 -0
  149. package/dist/modes.d.ts +8 -0
  150. package/dist/types/index.d.ts +101 -0
  151. package/dist/types/lib.types.d.ts +3 -0
  152. package/package.json +2 -1
  153. package/src/components/Box/Box.tsx +1 -3
@@ -0,0 +1,35 @@
1
+ import { FC } from 'react';
2
+ import { SelectInputProps } from '../SelectInput/SelectInput';
3
+ export type TimePickerProps = Omit<SelectInputProps, 'options'> & {
4
+ /**
5
+ * Options to govern the display of the option labels in the select.
6
+ * This is a direct passthrough to the second argument of JS `toLocaleTimeString`.
7
+ * [More](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)
8
+ */
9
+ dateDisplayOptions?: Intl.DateTimeFormatOptions;
10
+ /**
11
+ * End hour and minute
12
+ */
13
+ endTime?: {
14
+ hour: number;
15
+ minute: number;
16
+ };
17
+ /**
18
+ * Interval of displayed times (in seconds). Defaults to 900 seconds (15 minutes).
19
+ */
20
+ interval?: number;
21
+ /**
22
+ * Locale(s) to be passed down in order to format the label values in the select.
23
+ * This corresponds to the first argument of JS `toLocaleTimeString`.
24
+ * [More](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)
25
+ */
26
+ locales?: string | string[];
27
+ /**
28
+ * Start hour and minute
29
+ */
30
+ startTime?: {
31
+ hour: number;
32
+ minute: number;
33
+ };
34
+ };
35
+ export declare const TimePicker: FC<TimePickerProps>;
@@ -0,0 +1,12 @@
1
+ import type { Meta } from '@storybook/react';
2
+ import React from 'react';
3
+ import { TimePicker } from './TimePicker';
4
+ declare const meta: Meta<typeof TimePicker>;
5
+ export default meta;
6
+ export declare const Default: () => React.JSX.Element;
7
+ export declare const WithASpecificInterval: () => React.JSX.Element;
8
+ export declare const WithMinAndMaxTimes: () => React.JSX.Element;
9
+ export declare const WithCustomDateDisplay: () => React.JSX.Element;
10
+ export declare const WithOpenMenu: () => React.JSX.Element;
11
+ export declare const HelpText: () => React.JSX.Element;
12
+ export declare const Sizes: () => React.JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { FC } from 'react';
2
+ import { SelectInputNativeProps } from '../SelectInputNative/SelectInputNative';
3
+ export interface TimePickerNativeProps extends Omit<SelectInputNativeProps, 'options'> {
4
+ /**
5
+ * Options to govern the display of the option labels in the select.
6
+ * This is a direct passthrough to the second argument of JS `toLocaleTimeString`.
7
+ * [More](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)
8
+ */
9
+ dateDisplayOptions?: Intl.DateTimeFormatOptions;
10
+ /**
11
+ * End hour and minute
12
+ */
13
+ endTime?: {
14
+ hour: number;
15
+ minute: number;
16
+ };
17
+ /**
18
+ * Interval of displayed times (in seconds). Defaults to 900 seconds (15 minutes).
19
+ */
20
+ interval?: number;
21
+ /**
22
+ * Locale(s) to be passed down in order to format the label values in the select.
23
+ * This corresponds to the first argument of JS `toLocaleTimeString`.
24
+ * [More](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)
25
+ */
26
+ locales?: string | string[];
27
+ /**
28
+ * Start hour and minute
29
+ */
30
+ startTime?: {
31
+ hour: number;
32
+ minute: number;
33
+ };
34
+ /**
35
+ * Should be ISO timestamp as returned by `onChange`, and matching value of option object.
36
+ */
37
+ value: SelectInputNativeProps['value'];
38
+ }
39
+ export declare const TimePickerNative: FC<TimePickerNativeProps>;
@@ -0,0 +1,11 @@
1
+ import type { Meta } from '@storybook/react';
2
+ import React from 'react';
3
+ import { TimePickerNative } from './TimePickerNative';
4
+ declare const meta: Meta<typeof TimePickerNative>;
5
+ export default meta;
6
+ export declare const Default: () => React.JSX.Element;
7
+ export declare const WithASpecificInterval: () => React.JSX.Element;
8
+ export declare const WithMinAndMaxTimes: () => React.JSX.Element;
9
+ export declare const WithCustomDateDisplay: () => React.JSX.Element;
10
+ export declare const HelpText: () => React.JSX.Element;
11
+ export declare const Sizes: () => React.JSX.Element;
@@ -0,0 +1,36 @@
1
+ import { Toast, ExtendedToastOptions } from './Toast.types';
2
+ export declare enum ToastStoreActionType {
3
+ ADD_TOAST = "TOAST/ADD_TOAST",
4
+ UPDATE_TOAST = "TOAST/UPDATE_TOAST",
5
+ UPSERT_TOAST = "TOAST/UPSERT_TOAST",
6
+ DISMISS_TOAST = "TOAST/DISMISS_TOAST",
7
+ REMOVE_TOAST = "TOAST/REMOVE_TOAST",
8
+ START_PAUSE = "TOAST/START_PAUSE",
9
+ END_PAUSE = "TOAST/END_PAUSE"
10
+ }
11
+ type GenericAction<TActionType extends PropertyKey, TPayload extends Record<string, unknown>> = {
12
+ type: TActionType;
13
+ payload: TPayload;
14
+ };
15
+ type ToastStoreAction = GenericAction<ToastStoreActionType.ADD_TOAST, {
16
+ toast: Toast;
17
+ }> | GenericAction<ToastStoreActionType.UPSERT_TOAST, {
18
+ toast: Toast;
19
+ }> | GenericAction<ToastStoreActionType.UPDATE_TOAST, {
20
+ toast: Partial<Toast>;
21
+ }> | GenericAction<ToastStoreActionType.DISMISS_TOAST, {
22
+ toastId?: string;
23
+ }> | GenericAction<ToastStoreActionType.REMOVE_TOAST, {
24
+ toastId?: string;
25
+ }> | GenericAction<ToastStoreActionType.START_PAUSE, {
26
+ time: number;
27
+ }> | GenericAction<ToastStoreActionType.END_PAUSE, {
28
+ time: number;
29
+ }>;
30
+ interface ToastState {
31
+ toasts: Toast[];
32
+ pausedAt: number | undefined;
33
+ }
34
+ export declare const dispatch: (action: ToastStoreAction) => void;
35
+ export declare const useToastStore: (toastOptions?: ExtendedToastOptions) => ToastState;
36
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { Meta } from '@storybook/react';
2
+ import React from 'react';
3
+ import { ToastContainer } from './';
4
+ declare const meta: Meta<typeof ToastContainer>;
5
+ export default meta;
6
+ export declare const Example: () => React.JSX.Element;
7
+ export declare const Column: () => React.JSX.Element;
8
+ export declare const Position: () => React.JSX.Element;
9
+ export declare const Duration: () => React.JSX.Element;
10
+ export declare const NotDismissible: () => React.JSX.Element;
11
+ export declare const ProgrammaticDismiss: () => React.JSX.Element;
12
+ export declare const Compact: () => React.JSX.Element;
13
+ export declare const BasicTypes: () => React.JSX.Element;
14
+ export declare const AdvancedTypes: () => React.JSX.Element;
@@ -0,0 +1,75 @@
1
+ import React from 'react';
2
+ import { ValueOrFunction } from '../../types';
3
+ export type ToastType = 'success' | 'error' | 'loading' | 'blank' | 'custom';
4
+ export type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
5
+ export interface Toast {
6
+ /**
7
+ * Type of toast to create.
8
+ */
9
+ type: ToastType;
10
+ /**
11
+ * Unique id for the toast.
12
+ */
13
+ id: string;
14
+ /**
15
+ * Toast message
16
+ */
17
+ message: ValueOrFunction<React.ReactNode, Toast>;
18
+ /**
19
+ * Determine of toast layout is compact or default.
20
+ */
21
+ isCompact?: boolean;
22
+ /**
23
+ * Custom duration for toast.
24
+ */
25
+ duration?: number;
26
+ /**
27
+ * Amount of time the toast timeout has been paused for.
28
+ * When the toast timeout is paused, its auto-dismissal will be delayed.
29
+ */
30
+ pauseDuration: number;
31
+ /**
32
+ * Custom toast position, use as needed to override global position from ToastContainer.
33
+ */
34
+ position?: ToastPosition;
35
+ /**
36
+ * Accessibility options
37
+ */
38
+ ariaProps: {
39
+ role: 'status' | 'alert';
40
+ 'aria-live': 'assertive' | 'off' | 'polite';
41
+ };
42
+ /**
43
+ * Whether the toast can be dismissed (if true, the toast will include a close button)
44
+ */
45
+ canDismiss?: boolean;
46
+ /**
47
+ * Custom styles.
48
+ */
49
+ style?: React.CSSProperties;
50
+ /**
51
+ * Custom className
52
+ */
53
+ className?: string;
54
+ /**
55
+ * Epoch timestamp
56
+ */
57
+ createdAt: number;
58
+ /**
59
+ * Whether the toast is visible at the current time.
60
+ * Used in order to display a proper fade-out animation before the element is fully removed from the DOM.
61
+ */
62
+ visible: boolean;
63
+ /**
64
+ * Height of element (calculated with getBoundingClientRect)
65
+ */
66
+ height?: number;
67
+ }
68
+ export type ToastOptions = Partial<Pick<Toast, 'id' | 'duration' | 'ariaProps' | 'className' | 'style' | 'position' | 'canDismiss' | 'isCompact'>>;
69
+ /**
70
+ * Extends toast options so that you can include options for each type of toast in the options.
71
+ * e.g: { duration: 1000, success: { duration: 2000 } }
72
+ */
73
+ export type ExtendedToastOptions = ToastOptions & {
74
+ [key in ToastType]?: ToastOptions;
75
+ };
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { Toast, ToastPosition, ExtendedToastOptions } from './Toast.types';
3
+ export declare const createRectRef: (onRect: (rect: DOMRect) => void) => (el: HTMLElement | null) => void;
4
+ export interface ToastContainerProps {
5
+ /**
6
+ * Render function for each individual toast.
7
+ * This can be used to render custom toasts, although we recommend using the standard version,
8
+ * unless absolutely necessary.
9
+ */
10
+ children?: (t: Toast) => JSX.Element;
11
+ /**
12
+ * Style object for the toast container if needed.
13
+ */
14
+ containerStyle?: React.CSSProperties;
15
+ /**
16
+ * Custom classname for toast container if needed.
17
+ */
18
+ containerClassName?: string;
19
+ /**
20
+ * The vertical gap between each toast notification when multiple toasts are on screen (in pixels).
21
+ */
22
+ gutter?: number;
23
+ /**
24
+ * Global position for all toasts in container.
25
+ * NOTE: This can be overwritten by the position property of each individual toast.
26
+ */
27
+ position?: ToastPosition;
28
+ /**
29
+ * Display toasts in reverse order.
30
+ * NOTE: Reverse order in this case means that older toasts remain close to the position origin.
31
+ * and newer toasts appear further away from the origin.
32
+ */
33
+ reverseOrder?: boolean;
34
+ /**
35
+ * Global options for each toast. Can be overwritten for each individual toast as needed.
36
+ */
37
+ toastOptions?: ExtendedToastOptions;
38
+ /**
39
+ * Props spread into main container.
40
+ */
41
+ [x: string]: unknown;
42
+ }
43
+ export declare const ToastContainer: React.FC<ToastContainerProps>;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { Toast, ToastPosition } from './Toast.types';
3
+ interface ToastNotificationProps {
4
+ /**
5
+ * Toast object
6
+ */
7
+ toast: Toast;
8
+ /**
9
+ * Custom position for toast (overrides global container toast position).
10
+ */
11
+ position?: ToastPosition;
12
+ /**
13
+ * Custom styles for toast.
14
+ */
15
+ style?: React.CSSProperties;
16
+ /**
17
+ * Render function to create custom toast notification.
18
+ */
19
+ children?: (components: {
20
+ message: React.ReactNode;
21
+ }) => React.ReactNode;
22
+ /**
23
+ * Handler for when the dismiss button is pressed.
24
+ */
25
+ onDismiss?: () => void;
26
+ }
27
+ export declare const ToastNotification: React.FC<ToastNotificationProps>;
28
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './ToastContainer';
2
+ export * from './Toast.types';
3
+ export * from './toast';
4
+ export * from './useToasts';
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { ValueOrFunction } from '../../types';
3
+ import { Toast, ToastOptions, ExtendedToastOptions } from './Toast.types';
4
+ type Message = ValueOrFunction<React.ReactNode, Toast>;
5
+ type ToastHandler = (message: Message, options?: ToastOptions) => string;
6
+ declare const toast: {
7
+ (message: Message, opts?: ToastOptions): string;
8
+ error: ToastHandler;
9
+ success: ToastHandler;
10
+ loading: ToastHandler;
11
+ custom: ToastHandler;
12
+ dismiss(toastId?: string): void;
13
+ remove(toastId?: string): void;
14
+ async<T>(promise: Promise<T>, messages: {
15
+ loading: React.ReactNode;
16
+ success: ValueOrFunction<React.ReactNode, T>;
17
+ error: ValueOrFunction<React.ReactNode, unknown>;
18
+ }, opts?: ExtendedToastOptions): Promise<T>;
19
+ };
20
+ export { toast };
@@ -0,0 +1,14 @@
1
+ import { ExtendedToastOptions, Toast, ToastPosition } from './Toast.types';
2
+ export declare const useToasts: (toastOptions?: ExtendedToastOptions) => {
3
+ toasts: Toast[];
4
+ handlers: {
5
+ startPause: () => void;
6
+ endPause: () => void;
7
+ updateHeight: (toastId: string, height: number) => void;
8
+ calculateOffset: (currentToast: Toast, opts: {
9
+ reverseOrder: boolean;
10
+ gutter: number;
11
+ defaultPosition?: ToastPosition;
12
+ }) => number;
13
+ };
14
+ };
@@ -0,0 +1,64 @@
1
+ import React, { ChangeEvent, FC, FocusEvent, ReactNode } from 'react';
2
+ import { ResponsiveProp } from '../../types';
3
+ export type ToggleSize = 'sm' | 'md' | 'lg';
4
+ export interface ToggleProps {
5
+ /**
6
+ * The id attribute of the input.
7
+ */
8
+ id: string;
9
+ /**
10
+ * The toggle input "checked" attribute.
11
+ */
12
+ isChecked: boolean;
13
+ /**
14
+ * Custom content to be displayed to right of toggle.
15
+ */
16
+ label: string;
17
+ /**
18
+ * Callback function when input is changed.
19
+ */
20
+ onChange: (event: ChangeEvent<HTMLInputElement>) => void;
21
+ /**
22
+ * Additional classes to add.
23
+ */
24
+ className?: string;
25
+ /**
26
+ * Mark the input field as invalid and display a validation message.
27
+ * Pass a string or node to render a validation message below the input.
28
+ */
29
+ error?: ReactNode;
30
+ /**
31
+ * Additional clarifying text to help describe the input
32
+ */
33
+ helpText?: ReactNode;
34
+ /**
35
+ * Determines if the label is not shown for stylistic reasons.
36
+ * Note the label is still a required prop and will be used as the aria-label for accessibility reasons.
37
+ */
38
+ hideLabel?: boolean;
39
+ /**
40
+ * If the input should be disabled and not focusable.
41
+ */
42
+ isDisabled?: boolean;
43
+ /**
44
+ * The required and aria-required attributes on the input
45
+ */
46
+ isRequired?: boolean;
47
+ /**
48
+ * Callback function when input is blurred.
49
+ */
50
+ onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
51
+ /**
52
+ * Callback function when input is focused.
53
+ */
54
+ onFocus?: (event: FocusEvent<HTMLInputElement>) => void;
55
+ /**
56
+ * Visual indicator that the field is required, that gets appended to the label
57
+ */
58
+ requiredIndicator?: React.ReactNode;
59
+ /**
60
+ * The size of the toggle.
61
+ */
62
+ size?: ToggleSize | ResponsiveProp<ToggleSize>;
63
+ }
64
+ export declare const Toggle: FC<ToggleProps>;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import type { Meta } from '@storybook/react';
3
+ import { Toggle } from './Toggle';
4
+ declare const meta: Meta<typeof Toggle>;
5
+ export default meta;
6
+ export declare const Overview: () => React.JSX.Element;
7
+ export declare const Basic: () => React.JSX.Element;
8
+ export declare const HelpText: () => React.JSX.Element;
9
+ export declare const HiddenLabel: () => React.JSX.Element;
10
+ export declare const Sizes: () => React.JSX.Element;
11
+ export declare const Disabled: () => React.JSX.Element;
12
+ export declare const Error: () => React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ export declare const ENTER = 13;
2
+ export declare const SPACE = 32;