@perawallet/react-ui-toolkit 2.0.0-beta.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.
Files changed (116) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +128 -0
  3. package/dist/Button.js +1 -0
  4. package/dist/Checkbox.js +1 -0
  5. package/dist/DateTimer-DIYsxSVY.js +1 -0
  6. package/dist/DateTimer.js +1 -0
  7. package/dist/FileInput.js +1 -0
  8. package/dist/FileUploadButton.js +1 -0
  9. package/dist/FormField.js +1 -0
  10. package/dist/Input.js +1 -0
  11. package/dist/List.js +1 -0
  12. package/dist/ListItem.js +1 -0
  13. package/dist/NumberInput.js +1 -0
  14. package/dist/PasswordInput.js +1 -0
  15. package/dist/ProgressBar.js +1 -0
  16. package/dist/Radio.js +1 -0
  17. package/dist/RadioGroup.js +1 -0
  18. package/dist/Select-CMiQfdu3.js +1 -0
  19. package/dist/Select.js +1 -0
  20. package/dist/Spinner.js +1 -0
  21. package/dist/Switch.js +1 -0
  22. package/dist/Textarea.js +1 -0
  23. package/dist/TimeInput.js +1 -0
  24. package/dist/Toast-9FKOjJle.js +1 -0
  25. package/dist/Toast.js +1 -0
  26. package/dist/Toggle.js +1 -0
  27. package/dist/TypeaheadInput.js +1 -0
  28. package/dist/TypeaheadSelect.js +1 -0
  29. package/dist/arrayUtils-BZ-V_2c9.js +1 -0
  30. package/dist/button/Button.d.ts +25 -0
  31. package/dist/button/file-upload/FileUploadButton.d.ts +9 -0
  32. package/dist/check-BSS-LBT3.js +1 -0
  33. package/dist/core/utils/array/arrayUtils.d.ts +13 -0
  34. package/dist/core/utils/device/deviceUtils.d.ts +2 -0
  35. package/dist/core/utils/dom/domUtils.d.ts +2 -0
  36. package/dist/core/utils/function/functionUtils.d.ts +7 -0
  37. package/dist/core/utils/hooks/useDateTimer.d.ts +17 -0
  38. package/dist/core/utils/hooks/useDebounce.d.ts +2 -0
  39. package/dist/core/utils/hooks/useOnClickOutside.d.ts +2 -0
  40. package/dist/core/utils/keyboard/keyboardEventConstants.d.ts +16 -0
  41. package/dist/core/utils/number/numberConstants.d.ts +5 -0
  42. package/dist/core/utils/number/numberTypes.d.ts +7 -0
  43. package/dist/core/utils/number/numberUtils.d.ts +44 -0
  44. package/dist/core/utils/string/stringConstants.d.ts +2 -0
  45. package/dist/core/utils/string/stringUtils.d.ts +5 -0
  46. package/dist/core/utils/test/testUtils.d.ts +19 -0
  47. package/dist/core/utils/time/timeConstants.d.ts +13 -0
  48. package/dist/core/utils/time/timeTypes.d.ts +13 -0
  49. package/dist/core/utils/time/timeUtils.d.ts +42 -0
  50. package/dist/date-timer/DateTimer.d.ts +4 -0
  51. package/dist/date-timer/util/dateTimerTypes.d.ts +18 -0
  52. package/dist/date-timer/util/dateTimerUtils.d.ts +7 -0
  53. package/dist/form/field/FormField.d.ts +14 -0
  54. package/dist/form/field/message/FormFieldMessage.d.ts +9 -0
  55. package/dist/form/input/Input.d.ts +14 -0
  56. package/dist/form/input/checkbox/CheckboxInput.d.ts +14 -0
  57. package/dist/form/input/file/FileInput.d.ts +19 -0
  58. package/dist/form/input/number/NumberInput.d.ts +6 -0
  59. package/dist/form/input/number/util/numberInputTypes.d.ts +14 -0
  60. package/dist/form/input/number/util/numberInputUtils.d.ts +42 -0
  61. package/dist/form/input/radio/RadioInput.d.ts +24 -0
  62. package/dist/form/input/radio/group/RadioGroup.d.ts +12 -0
  63. package/dist/form/input/typeahead/TypeaheadInput.d.ts +27 -0
  64. package/dist/form/input/util/inputTypes.d.ts +12 -0
  65. package/dist/form/password-input/PasswordInput.d.ts +9 -0
  66. package/dist/form/textarea/Textarea.d.ts +22 -0
  67. package/dist/form/time-input/TimeInput.d.ts +10 -0
  68. package/dist/index.d.ts +93 -0
  69. package/dist/index.js +1 -0
  70. package/dist/keyboardEventConstants-BL5de2V9.js +1 -0
  71. package/dist/list/List.d.ts +26 -0
  72. package/dist/list/description-term/DescriptionTerm.d.ts +16 -0
  73. package/dist/list/item/ListItem.d.ts +17 -0
  74. package/dist/list/util/listUtils.d.ts +7 -0
  75. package/dist/main.css +703 -0
  76. package/dist/numberUtils-CMCFc8Kh.js +1 -0
  77. package/dist/progress-bar/ProgressBar.d.ts +20 -0
  78. package/dist/select/Select.d.ts +19 -0
  79. package/dist/select/content/SelectContent.d.ts +9 -0
  80. package/dist/select/group/SelectGroup.d.ts +8 -0
  81. package/dist/select/item/SelectItem.d.ts +17 -0
  82. package/dist/select/item-list/SelectItemList.d.ts +13 -0
  83. package/dist/select/trigger/SelectTrigger.d.ts +6 -0
  84. package/dist/select/typeahead/TypeaheadSelect.d.ts +26 -0
  85. package/dist/select/typeahead/trigger/TypeheadSelectTrigger.d.ts +20 -0
  86. package/dist/select/typeahead/util/typeaheadSelectUtils.d.ts +3 -0
  87. package/dist/select/util/context/SelectContext.d.ts +7 -0
  88. package/dist/select/util/context/SelectContext.reducer.d.ts +3 -0
  89. package/dist/select/util/hook/useMultiSelect.d.ts +14 -0
  90. package/dist/select/util/hook/useSelectClassName.d.ts +12 -0
  91. package/dist/select/util/hook/useSelectKeyDown.d.ts +18 -0
  92. package/dist/select/util/hook/useSingleSelect.d.ts +13 -0
  93. package/dist/select/util/selectTypes.d.ts +40 -0
  94. package/dist/select/util/selectUtils.d.ts +9 -0
  95. package/dist/spinner/Spinner.d.ts +7 -0
  96. package/dist/switch/Switch.d.ts +10 -0
  97. package/dist/tab/Tab.d.ts +27 -0
  98. package/dist/tab/header/item/TabHeaderItem.d.ts +11 -0
  99. package/dist/tag/Tag.d.ts +15 -0
  100. package/dist/tag/util/tagUtils.d.ts +4 -0
  101. package/dist/timeUtils-BvuzU1KM.js +1 -0
  102. package/dist/toast/Toast.d.ts +11 -0
  103. package/dist/toast/ToastItemContext.d.ts +5 -0
  104. package/dist/toast/ToastProvider.d.ts +17 -0
  105. package/dist/toast/close-button/ToastCloseButton.d.ts +8 -0
  106. package/dist/toast/stack/ToastStack.d.ts +6 -0
  107. package/dist/toast/util/toastConstants.d.ts +4 -0
  108. package/dist/toast/util/toastHooks.d.ts +28 -0
  109. package/dist/toast/util/toastReducer.d.ts +5 -0
  110. package/dist/toast/util/toastTypes.d.ts +39 -0
  111. package/dist/toast/util/toastUtils.d.ts +3 -0
  112. package/dist/toggle/Toggle.d.ts +18 -0
  113. package/dist/toggle/item/ToggleItem.d.ts +11 -0
  114. package/dist/toggle/util/ToggleContext.d.ts +8 -0
  115. package/dist/useDebounce-CP74COv3.js +1 -0
  116. package/package.json +110 -0
@@ -0,0 +1,19 @@
1
+ import type { JSX } from "react";
2
+ import "./_select.scss";
3
+ import type { Ref } from "react";
4
+ import SelectContent from "./content/SelectContent";
5
+ import SelectGroup from "./group/SelectGroup";
6
+ import SelectItem from "./item/SelectItem";
7
+ import SelectItemList from "./item-list/SelectItemList";
8
+ import SelectTrigger from "./trigger/SelectTrigger";
9
+ import type { Option, SelectProps } from "./util/selectTypes";
10
+ declare const _default: (<T extends Option = Option>(props: SelectProps<T> & {
11
+ ref?: Ref<HTMLDivElement>;
12
+ }) => JSX.Element) & {
13
+ Content: typeof SelectContent;
14
+ Group: typeof SelectGroup;
15
+ Item: typeof SelectItem;
16
+ Trigger: typeof SelectTrigger;
17
+ ItemList: typeof SelectItemList;
18
+ };
19
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import "./_select-content.scss";
2
+ import type React from "react";
3
+ export interface SelectContentProps {
4
+ children: React.ReactNode;
5
+ customClassName?: string;
6
+ testid?: string;
7
+ }
8
+ declare const SelectContent: React.ForwardRefExoticComponent<SelectContentProps & React.RefAttributes<HTMLDivElement>>;
9
+ export default SelectContent;
@@ -0,0 +1,8 @@
1
+ import type React from "react";
2
+ export type SelectGroupProps = Omit<React.HTMLAttributes<HTMLDivElement>, "className"> & {
3
+ customClassName?: string;
4
+ };
5
+ declare const SelectGroup: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<HTMLDivElement>, "className"> & {
6
+ customClassName?: string;
7
+ } & React.RefAttributes<HTMLDivElement>>;
8
+ export default SelectGroup;
@@ -0,0 +1,17 @@
1
+ import type { JSX } from "react";
2
+ import "./_select-item.scss";
3
+ import type React from "react";
4
+ import type { Ref } from "react";
5
+ import type { Option, SelectItemElement } from "../util/selectTypes";
6
+ export interface SelectItemProps<T extends Option = Option> {
7
+ option: T | null;
8
+ children: React.ReactNode;
9
+ customClassName?: string;
10
+ onKeyDown?: (option: T | null, event: React.KeyboardEvent<SelectItemElement>) => void;
11
+ as?: keyof Pick<JSX.IntrinsicElements, "div" | "li">;
12
+ testid?: string;
13
+ }
14
+ declare const _default: <T extends Option = Option>(props: SelectItemProps<T> & {
15
+ ref?: Ref<SelectItemElement>;
16
+ }) => JSX.Element;
17
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import type React from "react";
2
+ import type { JSX, Ref } from "react";
3
+ import type { ListProps } from "../..";
4
+ import type { Option } from "../util/selectTypes";
5
+ export type SelectItemListProps<T extends Option = Option> = {
6
+ options: T[];
7
+ contentRenderer: (option: T) => React.ReactNode;
8
+ customClassName?: string;
9
+ } & Omit<ListProps, "items" | "ref" | "children">;
10
+ declare const _default: <T extends Option = Option>(props: SelectItemListProps<T> & {
11
+ ref?: Ref<HTMLUListElement>;
12
+ }) => JSX.Element;
13
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import type React from "react";
2
+ import type { ButtonProps } from "../../button/Button";
3
+ import "./_select-trigger.scss";
4
+ export type SelectTriggerProps = Omit<ButtonProps, "type">;
5
+ declare const SelectTrigger: React.ForwardRefExoticComponent<SelectTriggerProps & React.RefAttributes<HTMLButtonElement>>;
6
+ export default SelectTrigger;
@@ -0,0 +1,26 @@
1
+ import type React from "react";
2
+ import type { TypeaheadInputProps } from "../../form/input/typeahead/TypeaheadInput";
3
+ import type { Option, TypeaheadSelectOption, TypeaheadSelectOptionSelectHandler } from "../util/selectTypes";
4
+ import "./_typeahead-select.scss";
5
+ export interface TypeaheadSelectProps<T extends TypeaheadSelectOption = TypeaheadSelectOption> {
6
+ selectedOptions: T[];
7
+ options: T[];
8
+ onSelect: TypeaheadSelectOptionSelectHandler<T>;
9
+ typeaheadProps: Pick<TypeaheadInputProps, "id" | "placeholder" | "name" | "onFocus" | "type">;
10
+ testid?: string;
11
+ onKeywordChange?: (value: string) => void;
12
+ initialKeyword?: string;
13
+ controlledKeyword?: string;
14
+ onTagRemove?: (option: Option) => void;
15
+ selectedOptionLimit?: number;
16
+ customClassName?: string;
17
+ shouldDisplaySelectedOptions?: boolean;
18
+ shouldFilterOptionsByKeyword?: boolean;
19
+ isDisabled?: boolean;
20
+ customSpinner?: React.ReactNode;
21
+ shouldShowEmptyOptions?: boolean;
22
+ canOpenDropdownMenu?: boolean;
23
+ areOptionsFetching?: boolean;
24
+ }
25
+ declare function TypeaheadSelect<T extends TypeaheadSelectOption = TypeaheadSelectOption>({ testid, options, selectedOptions, typeaheadProps, onTagRemove, onKeywordChange, onSelect, customClassName, selectedOptionLimit, shouldDisplaySelectedOptions, shouldFilterOptionsByKeyword, isDisabled, shouldShowEmptyOptions, canOpenDropdownMenu, areOptionsFetching, customSpinner, initialKeyword, controlledKeyword }: TypeaheadSelectProps<T>): React.JSX.Element;
26
+ export default TypeaheadSelect;
@@ -0,0 +1,20 @@
1
+ import "./_typehead-select-trigger.scss";
2
+ import type React from "react";
3
+ import type { TagShape } from "../../../tag/Tag";
4
+ export interface TypeheadSelectTriggerProps {
5
+ tags: TagShape[];
6
+ handleTagRemove: (tag: TagShape) => void;
7
+ customClassName?: string;
8
+ input?: React.ReactNode;
9
+ canOpenMenu?: boolean;
10
+ }
11
+ /**
12
+ * Not a `Select.Trigger`: that renders a `<button>`, and this trigger contains the search
13
+ * `<input>` and the tags' remove buttons. Interactive controls cannot be nested, and the
14
+ * button's click toggle meant clicking into the input while the menu was open closed it. The
15
+ * menu opens when the input inside gains focus (React's onFocus bubbles) and only ever opens —
16
+ * closing is the `Select`'s job (outside click, selection, keyboard). Deliberately no onClick:
17
+ * a click on a tag's remove button would bubble here too, and the input already fills the row.
18
+ */
19
+ declare function TypeheadSelectTrigger({ handleTagRemove, tags, customClassName, input, canOpenMenu }: TypeheadSelectTriggerProps): React.JSX.Element;
20
+ export default TypeheadSelectTrigger;
@@ -0,0 +1,3 @@
1
+ import type { TypeaheadSelectOption } from "../../util/selectTypes";
2
+ declare function filterOptionsByKeyword<T extends TypeaheadSelectOption = TypeaheadSelectOption>(options: T[], keyword: string): T[];
3
+ export { filterOptionsByKeyword };
@@ -0,0 +1,7 @@
1
+ import type { Dispatch } from "react";
2
+ import type { SelectContextValue, SelectStateAction } from "../selectTypes";
3
+ declare const SelectContext: import("react").Context<SelectContextValue | null>;
4
+ declare const SelectDispatchContext: import("react").Context<Dispatch<SelectStateAction> | null>;
5
+ declare function useSelectContext(): SelectContextValue;
6
+ declare function useSelectDispatchContext(): Dispatch<SelectStateAction>;
7
+ export { SelectContext, SelectDispatchContext, useSelectContext, useSelectDispatchContext };
@@ -0,0 +1,3 @@
1
+ import type { SelectOwnState, SelectStateAction } from "../selectTypes";
2
+ declare function selectStateReducer(state: SelectOwnState, action: SelectStateAction): SelectOwnState;
3
+ export { selectStateReducer };
@@ -0,0 +1,14 @@
1
+ import type { Option } from "../selectTypes";
2
+ /**
3
+ * A hook to handle default multi select behavior.
4
+ * @param initialValue - initial value of the select
5
+ * @returns {Object} - An object with the following properties:
6
+ * - value: the current value of the select
7
+ * - handleSelect: a function that can be used to set the value of the select with default behavior (if the value is exists,
8
+ * it will remove passed option from value, otherwise the option will be added to value)
9
+ */
10
+ declare function useMultiSelect<T extends Option = Option>(initialValue?: T[]): {
11
+ value: T[];
12
+ handleSelect: (option: T) => void;
13
+ };
14
+ export default useMultiSelect;
@@ -0,0 +1,12 @@
1
+ import type { SelectContextValue } from "../selectTypes";
2
+ /**
3
+ * A hook that returns the class name for the select component.
4
+ * @param state - Select state
5
+ * @param customClassName - Custom class name
6
+ * @returns {string} - Select container className according to the provided state object
7
+ * @example
8
+ * const selectClassName = useSelectClassName(state, customClassName);
9
+ * <div className={selectClassName} ... />
10
+ */
11
+ declare function useSelectClassName(state: SelectContextValue, customClassName?: string): string;
12
+ export default useSelectClassName;
@@ -0,0 +1,18 @@
1
+ import type React from "react";
2
+ import type { SelectContextValue, SelectStateAction } from "../selectTypes";
3
+ /**
4
+ * A hook for handle select key down event.
5
+ * @param state - Select state
6
+ * @param dispatch - Select state dispatch function
7
+ * @returns {Object} - An object that contains select key down handler
8
+ * @example
9
+ * const {handleSelectKeyDown} = useSelectKeyDown(state, dispatch);
10
+ * <div
11
+ * onKeyDown={handleSelectKeyDown}
12
+ * ...
13
+ * />
14
+ */
15
+ declare function useSelectKeyDown(state: SelectContextValue, dispatch: React.Dispatch<SelectStateAction>): {
16
+ handleSelectKeyDown: (event: React.KeyboardEvent<HTMLDivElement>) => void;
17
+ };
18
+ export default useSelectKeyDown;
@@ -0,0 +1,13 @@
1
+ import type { Option } from "../selectTypes";
2
+ /**
3
+ * A hook to handle default single select behavior.
4
+ * @param initialValue - initial value of the select
5
+ * @returns {Object} - An object with the following properties:
6
+ * - value: the current value of the select
7
+ * - handleSelect: a function that can be used to set the value of the select
8
+ */
9
+ declare function useSingleSelect<T extends Option = Option>(initialValue?: T): {
10
+ value: T | null;
11
+ handleSelect: (option: T | null) => void;
12
+ };
13
+ export default useSingleSelect;
@@ -0,0 +1,40 @@
1
+ import type React from "react";
2
+ interface Option {
3
+ id: string;
4
+ isDisabled?: boolean;
5
+ }
6
+ interface TypeaheadSelectOption extends Option {
7
+ title: string;
8
+ }
9
+ type SelectItemElement = HTMLLIElement | HTMLDivElement;
10
+ type OptionSelectHandler<T extends Option = Option> = (option: T | null, event?: React.SyntheticEvent<SelectItemElement>) => void;
11
+ type TypeaheadSelectOptionSelectHandler<T extends TypeaheadSelectOption = TypeaheadSelectOption> = (option: T, event?: React.SyntheticEvent<SelectItemElement>) => void;
12
+ type SelectRole = "listbox" | "menu";
13
+ interface SelectProps<T extends Option = Option> {
14
+ children: React.ReactNode;
15
+ options: (Option | null)[];
16
+ value: SelectValue<T>;
17
+ onSelect: OptionSelectHandler<T>;
18
+ role?: SelectRole;
19
+ hasError?: boolean;
20
+ customClassName?: string;
21
+ isDisabled?: boolean;
22
+ shouldCloseOnSelect?: boolean;
23
+ isMenuOpen?: boolean;
24
+ }
25
+ type SelectContextValue = Pick<SelectProps, "hasError" | "isDisabled" | "onSelect" | "shouldCloseOnSelect" | "value" | "role"> & SelectOwnState;
26
+ interface SelectOwnState {
27
+ isMenuOpen: boolean;
28
+ focusedOptionIndex: number;
29
+ options: (Option | null)[];
30
+ }
31
+ type SelectValue<T extends Option> = T | T[] | null;
32
+ type SelectStateAction = {
33
+ type: "TOGGLE_MENU_VISIBILITY";
34
+ } | {
35
+ type: "OPEN_MENU";
36
+ } | {
37
+ type: "SET_FOCUSED_OPTION_INDEX";
38
+ payload: number;
39
+ };
40
+ export type { Option, OptionSelectHandler, SelectContextValue, SelectItemElement, SelectOwnState, SelectProps, SelectRole, SelectStateAction, TypeaheadSelectOption, TypeaheadSelectOptionSelectHandler };
@@ -0,0 +1,9 @@
1
+ import type { SelectContextValue, SelectOwnState, SelectProps } from "./selectTypes";
2
+ /**
3
+ * Generates select state from provided props.
4
+ * @param {SelectContextValue} state - The current state of the select
5
+ * @param props - The props passed to the select
6
+ * @returns {SelectContextValue} - The new state of the select
7
+ */
8
+ declare function generateSelectState(state: SelectOwnState, props: SelectProps): SelectContextValue;
9
+ export { generateSelectState };
@@ -0,0 +1,7 @@
1
+ import "./_spinner.scss";
2
+ export interface SpinnerProps {
3
+ color?: string;
4
+ customClassName?: string;
5
+ }
6
+ declare function Spinner({ color, customClassName }: SpinnerProps): import("react").JSX.Element;
7
+ export default Spinner;
@@ -0,0 +1,10 @@
1
+ import "./_switch.scss";
2
+ export interface SwitchProps {
3
+ onToggle: () => void;
4
+ isToggledOn: boolean;
5
+ isDisabled?: boolean;
6
+ customClassName?: string;
7
+ testid?: string;
8
+ }
9
+ declare function Switch({ onToggle, isToggledOn, isDisabled, customClassName, testid }: SwitchProps): import("react").JSX.Element;
10
+ export default Switch;
@@ -0,0 +1,27 @@
1
+ import "./_tab.scss";
2
+ import type React from "react";
3
+ export type TabItem = {
4
+ id: string;
5
+ content: React.ReactNode;
6
+ icon?: React.ReactNode;
7
+ isDisabled?: boolean;
8
+ };
9
+ interface UncontrolledTabProps {
10
+ items: TabItem[];
11
+ children: React.ReactNode[];
12
+ testid?: string;
13
+ initialActiveTabIndex?: number;
14
+ customClassName?: string;
15
+ wrapperId?: string;
16
+ }
17
+ type ControlledTabProps = {
18
+ activeTabIndex: number;
19
+ onTabChange: (index: number) => void;
20
+ initialActiveTabIndex?: number;
21
+ } | {
22
+ activeTabIndex?: number;
23
+ onTabChange?: (index: number) => void;
24
+ };
25
+ export type TabProps = ControlledTabProps & UncontrolledTabProps;
26
+ declare function Tab({ testid, items, initialActiveTabIndex, activeTabIndex: activeTabIndexFromProps, children, customClassName, onTabChange, wrapperId }: TabProps): React.JSX.Element;
27
+ export default Tab;
@@ -0,0 +1,11 @@
1
+ import "./_tab-header-item.scss";
2
+ import type { TabItem } from "../../Tab";
3
+ type TabHeaderItemProps = {
4
+ tab: TabItem;
5
+ onClick: (index: number) => void;
6
+ isActive: boolean;
7
+ index: number;
8
+ testid?: string;
9
+ };
10
+ declare function TabHeaderItem({ testid, tab, onClick, index, isActive }: TabHeaderItemProps): import("react").JSX.Element;
11
+ export default TabHeaderItem;
@@ -0,0 +1,15 @@
1
+ import "./_tag.scss";
2
+ import type React from "react";
3
+ export interface TagShape<Context = any> {
4
+ id: string;
5
+ content: React.ReactNode;
6
+ context?: Context;
7
+ }
8
+ interface TagProps {
9
+ tag: TagShape;
10
+ testid?: string;
11
+ customClassName?: string;
12
+ onRemove?: (tag: TagShape) => void;
13
+ }
14
+ declare function Tag({ testid, tag, onRemove, customClassName }: TagProps): React.JSX.Element;
15
+ export default Tag;
@@ -0,0 +1,4 @@
1
+ import type { TypeaheadSelectOption } from "../../select/util/selectTypes";
2
+ import type { TagShape } from "../Tag";
3
+ declare function mapOptionsToTagShapes<T extends TypeaheadSelectOption = TypeaheadSelectOption>(options: T[]): TagShape<T>[];
4
+ export { mapOptionsToTagShapes };
@@ -0,0 +1 @@
1
+ "use strict";var e=require("date-fns/fp"),t=require("date-fns/locale"),r=require("date-fns-tz");const n=1e3,a=3600,o={DEFAULT:"MMM d, yyyy",LONG_TIME_FORMAT:"hh:mm a"};function i(e){return[e[0],e[1]].sort((e,t)=>e.getTime()-t.getTime())}exports.DATE_FORMAT=o,exports.SECOND_IN_MS=n,exports.calculateRemainingTimeBreakdown=function(e,t=0,r="down"){let o,s;e.length>1||"up"===r?[o,s]=i([e[0],e[1]||new Date]):(s=e[0],o=new Date);const g=s.getTime()-o.getTime(),l=(g-t)/n;return{delta:g,days:Math.floor(l/86400),hours:Math.floor(l/a%24),minutes:Math.floor(l%a/60),seconds:Math.floor(l%a%60)}},exports.formatDateWithOptions=function(n){const{format:a=o.DEFAULT,shouldShiftDateToCompensateForTimezone:i=!0,isProvidedDateInUTC:s=!0,timeZone:g}=n||{};return n=>{let o=n;return g?s&&(o=r.toZonedTime(n,g)):i&&(o=function(e){return new Date(e.getTime()- -1*e.getTimezoneOffset()*6e4)}(n)),g?r.format(o,a,{locale:t.enCA,timeZone:g}):e.formatWithOptions({locale:t.enCA},a)(o)}},exports.parseTime=function(e,t="g:i A"){const r=e.replace(/[^0-9]/g,"");let n,a,o=null!==e.match(/p/i);switch(r.length){case 4:n=parseInt(r[0]+r[1],10),a=parseInt(r[2]+r[3],10);break;case 3:n=parseInt(r[0],10),a=parseInt(r[1]+r[2],10);break;case 2:case 1:n=parseInt(r[0]+(r[1]||""),10),a=0;break;default:return""}return o&&n>0&&n<12&&(n+=12),n>=13&&n<=23&&(o=!0),(n<=0||n>=24)&&(n=0),(a<0||a>59)&&(a=0),t.replace(/g/g,0===n?"12":"g").replace(/g/g,n>12?(n-12).toString().padStart(2,"0"):n.toString().padStart(2,"0")).replace(/G/g,String(n)).replace(/h/g,String(n.toString().length>1?n>12?n-12:n:`0${n>12?n-12:n}`)).replace(/H/g,String(n.toString().length>1?n:`0${n}`)).replace(/i/g,String(a.toString().length>1?a:`0${a}`)).replace(/s/g,"00").replace(/a/g,o?"pm":"am").replace(/A/g,o?"PM":"AM")},exports.sortDateRange=i;
@@ -0,0 +1,11 @@
1
+ import ToastCloseButton from "./close-button/ToastCloseButton";
2
+ import type { ToastContextState } from "./util/toastTypes";
3
+ export interface ToastProps {
4
+ testid: string;
5
+ data: ToastContextState["toastStack"][0];
6
+ }
7
+ declare function Toast({ testid, data }: ToastProps): import("react").JSX.Element;
8
+ declare namespace Toast {
9
+ var CloseButton: typeof ToastCloseButton;
10
+ }
11
+ export default Toast;
@@ -0,0 +1,5 @@
1
+ type ToastItemContextValue = {
2
+ toastId: string;
3
+ };
4
+ declare const ToastItemContext: import("react").Context<ToastItemContextValue>;
5
+ export { ToastItemContext };
@@ -0,0 +1,17 @@
1
+ import type React from "react";
2
+ import type { ToastAction, ToastContextState } from "./util/toastTypes";
3
+ declare const ToastStateContext: React.Context<ToastContextState | null>;
4
+ declare const ToastDispatchContext: React.Context<React.Dispatch<ToastAction> | null>;
5
+ interface ToastContextProviderProps {
6
+ children: React.ReactNode;
7
+ customRootId?: string;
8
+ autoCloseToasts?: boolean;
9
+ limit?: number;
10
+ defaultAutoCloseTimeout?: number;
11
+ }
12
+ /**
13
+ * Wraps its children in a context provider
14
+ * these children can then use the useToast hook to show toast messages
15
+ */
16
+ declare function ToastContextProvider({ children, customRootId, autoCloseToasts, limit, defaultAutoCloseTimeout }: ToastContextProviderProps): React.JSX.Element;
17
+ export { ToastContextProvider, ToastDispatchContext, ToastStateContext };
@@ -0,0 +1,8 @@
1
+ import "./_toast-close-button.scss";
2
+ import type React from "react";
3
+ interface ToastCloseButtonProps {
4
+ children: React.ReactNode;
5
+ testid?: string;
6
+ }
7
+ declare function ToastCloseButton({ children, testid }: ToastCloseButtonProps): React.JSX.Element;
8
+ export default ToastCloseButton;
@@ -0,0 +1,6 @@
1
+ import "./_toast-stack.scss";
2
+ interface ToastStackProps {
3
+ customRootId?: string;
4
+ }
5
+ declare function ToastStack({ customRootId }: ToastStackProps): import("react").ReactPortal | null;
6
+ export default ToastStack;
@@ -0,0 +1,4 @@
1
+ import type { ToastContextState } from "./toastTypes";
2
+ declare const DEFAULT_TOAST_TIMEOUT = 4000;
3
+ declare const initialToastState: ToastContextState;
4
+ export { DEFAULT_TOAST_TIMEOUT, initialToastState };
@@ -0,0 +1,28 @@
1
+ import type { ToastContextState, ToastData } from "./toastTypes";
2
+ /**
3
+ * @returns {Object} Current value of ToastContextState
4
+ */
5
+ declare function useToastContextState(): ToastContextState;
6
+ declare function useToaster(): {
7
+ /**
8
+ * Display a Toast
9
+ * @returns {string} Toast's id
10
+ */
11
+ display: (toastData: ToastData) => string;
12
+ /**
13
+ * Hide a Toast with a given id
14
+ */
15
+ hide: (toastId: string) => void;
16
+ /**
17
+ * Updates the data for a Toast given its ID
18
+ */
19
+ update: (toastId: string, toastData: Partial<ToastData>) => void;
20
+ /**
21
+ * Hide all visible Toasts
22
+ */
23
+ hideAll: () => void;
24
+ };
25
+ declare function useToastItemContext(): {
26
+ toastId: string;
27
+ };
28
+ export { useToastContextState, useToaster, useToastItemContext };
@@ -0,0 +1,5 @@
1
+ import type { initialToastState } from "./toastConstants";
2
+ import type { ToastAction } from "./toastTypes";
3
+ type ToastState = typeof initialToastState;
4
+ declare function toastReducer(state: ToastState, action: ToastAction): ToastState;
5
+ export default toastReducer;
@@ -0,0 +1,39 @@
1
+ export interface ToastData {
2
+ render: () => React.ReactNode;
3
+ id?: string;
4
+ autoClose?: boolean;
5
+ timeout?: number;
6
+ customClassName?: string;
7
+ }
8
+ export type ToastAction = {
9
+ type: "DISPLAY";
10
+ toastData: Omit<ToastData, "id"> & {
11
+ id: string;
12
+ };
13
+ } | {
14
+ type: "HIDE";
15
+ toastId: string;
16
+ } | {
17
+ type: "HIDE_ALL";
18
+ } | {
19
+ type: "UPDATE";
20
+ toastId: string;
21
+ toastData: Partial<Omit<ToastData, "id">>;
22
+ } | {
23
+ type: "SET_LIMIT";
24
+ limit: number;
25
+ } | {
26
+ type: "SET_AUTO_CLOSE";
27
+ autoCloseToasts: boolean;
28
+ } | {
29
+ type: "SET_DEFAULT_AUTO_CLOSE_TIMEOUT_FOR_ALL_TOASTS";
30
+ timeout: undefined | number;
31
+ };
32
+ export interface ToastContextState {
33
+ toastStack: (Omit<ToastData, "id"> & {
34
+ id: string;
35
+ })[];
36
+ autoCloseToasts: boolean;
37
+ defaultAutoCloseTimeout: number;
38
+ limit?: number;
39
+ }
@@ -0,0 +1,3 @@
1
+ import type { ToastData } from "./toastTypes";
2
+ declare function isSameToast(toastId: string): (toast2: ToastData) => boolean;
3
+ export { isSameToast };
@@ -0,0 +1,18 @@
1
+ import "./_toggle.scss";
2
+ import type React from "react";
3
+ import ToggleItem from "./item/ToggleItem";
4
+ import { ToggleContext } from "./util/ToggleContext";
5
+ export interface ToggleProps {
6
+ children: React.ReactNode;
7
+ onToggle: (selectedItems: string[]) => void;
8
+ selectedItems: string[];
9
+ canSelectMultiple?: boolean;
10
+ position?: "vertical" | "horizontal";
11
+ isDisabled?: boolean;
12
+ customClassName?: string;
13
+ }
14
+ declare function Toggle({ children, onToggle, selectedItems, canSelectMultiple, position, isDisabled, customClassName }: ToggleProps): React.JSX.Element;
15
+ declare namespace Toggle {
16
+ var Item: typeof ToggleItem;
17
+ }
18
+ export { Toggle, ToggleContext };
@@ -0,0 +1,11 @@
1
+ import "./_toggle-item.scss";
2
+ import type React from "react";
3
+ export interface ToggleItemProps {
4
+ children: React.ReactNode;
5
+ dataId: string;
6
+ customClassName?: string;
7
+ isDisabled?: boolean;
8
+ testid?: string;
9
+ }
10
+ declare function ToggleItem({ children, dataId, customClassName, isDisabled, testid }: ToggleItemProps): React.JSX.Element;
11
+ export default ToggleItem;
@@ -0,0 +1,8 @@
1
+ type ToggleContextValue = {
2
+ selectedItems: string[];
3
+ onToggle: (selectedItems: string[]) => void;
4
+ canSelectMultiple?: boolean;
5
+ };
6
+ declare const ToggleContext: import("react").Context<ToggleContextValue>;
7
+ declare function useToggle(): ToggleContextValue;
8
+ export { ToggleContext, useToggle };
@@ -0,0 +1 @@
1
+ "use strict";var e=require("react");exports.useDebounce=function(t,r,u){const[c,s]=e.useState(r),n=e.useRef(c);return e.useEffect(()=>{let e;return n.current!==c&&(e=setTimeout(()=>{t(c)},u),n.current=c),()=>{clearTimeout(e)}},[n,t,c,u]),[c,s]};