@deephaven/components 0.22.3-beta.18 → 0.22.3-beta.21
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/AutoCompleteInput.js +12 -85
- package/dist/AutoCompleteInput.js.map +1 -1
- package/dist/AutoResizeTextarea.d.ts +5 -5
- package/dist/AutoResizeTextarea.d.ts.map +1 -1
- package/dist/AutoResizeTextarea.js +8 -23
- package/dist/AutoResizeTextarea.js.map +1 -1
- package/dist/BasicModal.d.ts +28 -1
- package/dist/BasicModal.d.ts.map +1 -1
- package/dist/BasicModal.js +2 -8
- package/dist/BasicModal.js.map +1 -1
- package/dist/Button.js +8 -34
- package/dist/Button.js.map +1 -1
- package/dist/ButtonGroup.d.ts +6 -6
- package/dist/ButtonGroup.d.ts.map +1 -1
- package/dist/ButtonGroup.js +2 -4
- package/dist/ButtonGroup.js.map +1 -1
- package/dist/ButtonOld.js.map +1 -1
- package/dist/CardFlip.d.ts +1 -1
- package/dist/CardFlip.d.ts.map +1 -1
- package/dist/CardFlip.js +2 -7
- package/dist/CardFlip.js.map +1 -1
- package/dist/Checkbox.js +3 -14
- package/dist/Checkbox.js.map +1 -1
- package/dist/Collapse.js +0 -15
- package/dist/Collapse.js.map +1 -1
- package/dist/ComboBox.js +4 -83
- package/dist/ComboBox.js.map +1 -1
- package/dist/CopyButton.d.ts +1 -1
- package/dist/CopyButton.d.ts.map +1 -1
- package/dist/CopyButton.js +2 -4
- package/dist/CopyButton.js.map +1 -1
- package/dist/CustomTimeSelect.js +2 -86
- package/dist/CustomTimeSelect.js.map +1 -1
- package/dist/DateInput.js.map +1 -1
- package/dist/DateInputUtils.js +0 -7
- package/dist/DateInputUtils.js.map +1 -1
- package/dist/DateTimeInput.js +7 -10
- package/dist/DateTimeInput.js.map +1 -1
- package/dist/DebouncedSearchInput.js +0 -14
- package/dist/DebouncedSearchInput.js.map +1 -1
- package/dist/DragUtils.js +4 -16
- package/dist/DragUtils.js.map +1 -1
- package/dist/DraggableItemList.d.ts.map +1 -1
- package/dist/DraggableItemList.js +22 -44
- package/dist/DraggableItemList.js.map +1 -1
- package/dist/EditableItemList.d.ts +1 -1
- package/dist/EditableItemList.d.ts.map +1 -1
- package/dist/EditableItemList.js +2 -6
- package/dist/EditableItemList.js.map +1 -1
- package/dist/HierarchicalCheckboxMenu.js +6 -28
- package/dist/HierarchicalCheckboxMenu.js.map +1 -1
- package/dist/ItemList.d.ts.map +1 -1
- package/dist/ItemList.js +22 -115
- package/dist/ItemList.js.map +1 -1
- package/dist/ItemListItem.d.ts +0 -1
- package/dist/ItemListItem.d.ts.map +1 -1
- package/dist/ItemListItem.js +26 -50
- package/dist/ItemListItem.js.map +1 -1
- package/dist/LoadingOverlay.d.ts +1 -1
- package/dist/LoadingOverlay.d.ts.map +1 -1
- package/dist/LoadingOverlay.js +3 -5
- package/dist/LoadingOverlay.js.map +1 -1
- package/dist/LoadingSpinner.d.ts +1 -1
- package/dist/LoadingSpinner.d.ts.map +1 -1
- package/dist/LoadingSpinner.js +2 -4
- package/dist/LoadingSpinner.js.map +1 -1
- package/dist/MaskedInput.js +26 -85
- package/dist/MaskedInput.js.map +1 -1
- package/dist/Option.d.ts +1 -1
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +2 -4
- package/dist/Option.js.map +1 -1
- package/dist/RadioGroup.d.ts +1 -1
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RadioGroup.js +4 -6
- package/dist/RadioGroup.js.map +1 -1
- package/dist/RadioItem.js +0 -1
- package/dist/RadioItem.js.map +1 -1
- package/dist/SearchInput.js +2 -13
- package/dist/SearchInput.js.map +1 -1
- package/dist/Select.d.ts +1 -1
- package/dist/Select.d.ts.map +1 -1
- package/dist/Select.js +2 -4
- package/dist/Select.js.map +1 -1
- package/dist/SelectValueList.js +0 -28
- package/dist/SelectValueList.js.map +1 -1
- package/dist/SocketedButton.js.map +1 -1
- package/dist/ThemeExport.js +0 -4
- package/dist/ThemeExport.js.map +1 -1
- package/dist/TimeInput.js +2 -12
- package/dist/TimeInput.js.map +1 -1
- package/dist/TimeSlider.d.ts +1 -1
- package/dist/TimeSlider.d.ts.map +1 -1
- package/dist/TimeSlider.js +19 -33
- package/dist/TimeSlider.js.map +1 -1
- package/dist/ToastNotification.d.ts +4 -4
- package/dist/ToastNotification.d.ts.map +1 -1
- package/dist/ToastNotification.js +2 -4
- package/dist/ToastNotification.js.map +1 -1
- package/dist/UISwitch.d.ts +1 -1
- package/dist/UISwitch.d.ts.map +1 -1
- package/dist/UISwitch.js +2 -4
- package/dist/UISwitch.js.map +1 -1
- package/dist/ValidateLabelInput.d.ts.map +1 -1
- package/dist/ValidateLabelInput.js +3 -3
- package/dist/ValidateLabelInput.js.map +1 -1
- package/dist/context-actions/ContextActionUtils.js +9 -40
- package/dist/context-actions/ContextActionUtils.js.map +1 -1
- package/dist/context-actions/ContextActions.js +1 -34
- package/dist/context-actions/ContextActions.js.map +1 -1
- package/dist/context-actions/ContextMenu.js +29 -110
- package/dist/context-actions/ContextMenu.js.map +1 -1
- package/dist/context-actions/ContextMenuItem.d.ts.map +1 -1
- package/dist/context-actions/ContextMenuItem.js +3 -19
- package/dist/context-actions/ContextMenuItem.js.map +1 -1
- package/dist/context-actions/ContextMenuRoot.js +7 -26
- package/dist/context-actions/ContextMenuRoot.js.map +1 -1
- package/dist/context-actions/GlobalContextAction.js +0 -15
- package/dist/context-actions/GlobalContextAction.js.map +1 -1
- package/dist/context-actions/GlobalContextActions.js +0 -6
- package/dist/context-actions/GlobalContextActions.js.map +1 -1
- package/dist/context-actions/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/menu-actions/DropdownMenu.js +4 -32
- package/dist/menu-actions/DropdownMenu.js.map +1 -1
- package/dist/menu-actions/Menu.js +7 -52
- package/dist/menu-actions/Menu.js.map +1 -1
- package/dist/menu-actions/index.d.ts +2 -1
- package/dist/menu-actions/index.d.ts.map +1 -1
- package/dist/menu-actions/index.js +2 -2
- package/dist/menu-actions/index.js.map +1 -1
- package/dist/modal/Modal.d.ts +2 -2
- package/dist/modal/Modal.d.ts.map +1 -1
- package/dist/modal/Modal.js +3 -9
- package/dist/modal/Modal.js.map +1 -1
- package/dist/modal/ModalBody.d.ts +1 -1
- package/dist/modal/ModalBody.d.ts.map +1 -1
- package/dist/modal/ModalBody.js +2 -4
- package/dist/modal/ModalBody.js.map +1 -1
- package/dist/modal/ModalFooter.d.ts +1 -1
- package/dist/modal/ModalFooter.d.ts.map +1 -1
- package/dist/modal/ModalFooter.js +2 -4
- package/dist/modal/ModalFooter.js.map +1 -1
- package/dist/modal/ModalHeader.d.ts +1 -1
- package/dist/modal/ModalHeader.d.ts.map +1 -1
- package/dist/modal/ModalHeader.js +2 -4
- package/dist/modal/ModalHeader.js.map +1 -1
- package/dist/modal/index.js.map +1 -1
- package/dist/navigation/Menu.d.ts +1 -1
- package/dist/navigation/Menu.d.ts.map +1 -1
- package/dist/navigation/Menu.js +2 -2
- package/dist/navigation/Menu.js.map +1 -1
- package/dist/navigation/MenuItem.d.ts +1 -1
- package/dist/navigation/MenuItem.d.ts.map +1 -1
- package/dist/navigation/MenuItem.js +4 -7
- package/dist/navigation/MenuItem.js.map +1 -1
- package/dist/navigation/Page.d.ts +1 -1
- package/dist/navigation/Page.d.ts.map +1 -1
- package/dist/navigation/Page.js +2 -3
- package/dist/navigation/Page.js.map +1 -1
- package/dist/navigation/Stack.d.ts +1 -1
- package/dist/navigation/Stack.d.ts.map +1 -1
- package/dist/navigation/Stack.js +3 -6
- package/dist/navigation/Stack.js.map +1 -1
- package/dist/navigation/index.js.map +1 -1
- package/dist/popper/Popper.d.ts.map +1 -1
- package/dist/popper/Popper.js +13 -46
- package/dist/popper/Popper.js.map +1 -1
- package/dist/popper/Tooltip.js +0 -56
- package/dist/popper/Tooltip.js.map +1 -1
- package/dist/popper/index.js.map +1 -1
- package/dist/shortcuts/GlobalShortcuts.js.map +1 -1
- package/dist/shortcuts/Shortcut.js +19 -76
- package/dist/shortcuts/Shortcut.js.map +1 -1
- package/dist/shortcuts/ShortcutRegistry.js +3 -18
- package/dist/shortcuts/ShortcutRegistry.js.map +1 -1
- package/dist/shortcuts/index.js.map +1 -1
- package/package.json +8 -8
|
@@ -2,14 +2,13 @@ import React, { useState, useRef, useEffect } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import "./AutoResizeTextarea.css";
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Makes a textarea that auto resizes based on contents, its height grows with new lines.
|
|
8
7
|
* If a delimeter is set, such as " -" or " ", as used by jvm args or env vars
|
|
9
8
|
* then the field will also "explode" the value by the delimiter over new lines
|
|
10
9
|
* on focus, and implode on blur. By default, it doesn't word wrap.
|
|
11
10
|
*/
|
|
12
|
-
|
|
11
|
+
function AutoResizeTextarea(_ref) {
|
|
13
12
|
var {
|
|
14
13
|
className = '',
|
|
15
14
|
value: propsValue,
|
|
@@ -28,7 +27,6 @@ var AutoResizeTextarea = _ref => {
|
|
|
28
27
|
// keep state value in sync with prop changes
|
|
29
28
|
setValue(propsValue);
|
|
30
29
|
}, [propsValue]);
|
|
31
|
-
|
|
32
30
|
function explode(input) {
|
|
33
31
|
// split by delimiter, commonly " " or " -"
|
|
34
32
|
// strip empty strings (if delimiter is space, and there are multiple spaces in a row)
|
|
@@ -36,68 +34,56 @@ var AutoResizeTextarea = _ref => {
|
|
|
36
34
|
return input.trim().split(delimiter).filter(string => string) // remove empty strings
|
|
37
35
|
.join("\n".concat(delimiter.trim()));
|
|
38
36
|
}
|
|
39
|
-
|
|
40
37
|
function implode(input) {
|
|
41
38
|
return input.split('\n').map(string => string.trim()).join(' ');
|
|
42
39
|
}
|
|
43
|
-
|
|
44
40
|
function reCalculateLayout() {
|
|
45
41
|
if (!element.current) {
|
|
46
42
|
return;
|
|
47
43
|
}
|
|
48
|
-
|
|
49
44
|
element.current.style.height = '0'; // shrink component to get scrollHeight
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
var resizedHeight = element.current.scrollHeight + (element.current.offsetHeight - element.current.clientHeight);
|
|
46
|
+
// accounts for border, padding is captured by scroll height
|
|
53
47
|
if (resizedHeight > 0) element.current.style.height = "".concat(resizedHeight, "px");
|
|
54
48
|
}
|
|
55
|
-
|
|
56
49
|
function handleChange(event) {
|
|
57
50
|
var newValue = event.target.value;
|
|
58
|
-
|
|
59
51
|
if (isPastedChange) {
|
|
60
52
|
if (delimiter) newValue = explode(newValue);
|
|
61
53
|
setIsPastedChange(false);
|
|
62
54
|
}
|
|
63
|
-
|
|
64
55
|
setValue(newValue);
|
|
65
56
|
onChange(newValue);
|
|
66
57
|
}
|
|
67
|
-
|
|
68
58
|
function handleFocus() {
|
|
69
59
|
if (!element.current) {
|
|
70
60
|
return;
|
|
71
61
|
}
|
|
72
|
-
|
|
73
62
|
if (delimiter) {
|
|
74
63
|
setValue(explode(value));
|
|
75
64
|
reCalculateLayout();
|
|
76
65
|
}
|
|
66
|
+
element.current.scrollLeft = 0;
|
|
67
|
+
// scroll left as it can be disorienting if you click on a long line
|
|
68
|
+
}
|
|
77
69
|
|
|
78
|
-
|
|
79
|
-
} // make it explode when dragging the resize handle
|
|
70
|
+
// make it explode when dragging the resize handle
|
|
80
71
|
// by making it trigger focus (which normally doesn't
|
|
81
72
|
// trigger when just resizing).
|
|
82
|
-
|
|
83
|
-
|
|
84
73
|
function handleMouseDown() {
|
|
85
74
|
if (!element.current) return;
|
|
86
75
|
if (document.activeElement === element.current) return;
|
|
87
76
|
element.current.focus();
|
|
88
77
|
}
|
|
89
|
-
|
|
90
78
|
function handleBlur() {
|
|
91
79
|
if (delimiter) {
|
|
92
80
|
setValue(implode(value));
|
|
93
81
|
onChange(implode(value));
|
|
94
82
|
}
|
|
95
83
|
}
|
|
96
|
-
|
|
97
84
|
function handlePaste() {
|
|
98
85
|
setIsPastedChange(true);
|
|
99
86
|
}
|
|
100
|
-
|
|
101
87
|
useEffect(function reCalculate() {
|
|
102
88
|
reCalculateLayout();
|
|
103
89
|
}, [value]);
|
|
@@ -117,8 +103,7 @@ var AutoResizeTextarea = _ref => {
|
|
|
117
103
|
disabled: disabled,
|
|
118
104
|
"data-testid": dataTestId
|
|
119
105
|
});
|
|
120
|
-
}
|
|
121
|
-
|
|
106
|
+
}
|
|
122
107
|
AutoResizeTextarea.propTypes = {
|
|
123
108
|
value: PropTypes.string.isRequired,
|
|
124
109
|
onChange: PropTypes.func.isRequired,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoResizeTextarea.js","names":["React","useState","useRef","useEffect","PropTypes","classNames","AutoResizeTextarea","className","value","propsValue","onChange","spellCheck","placeholder","disabled","delimiter","id","dataTestId","setValue","isPastedChange","setIsPastedChange","element","syncStateWithProp","explode","input","trim","split","filter","string","join","implode","map","reCalculateLayout","current","style","height","resizedHeight","scrollHeight","offsetHeight","clientHeight","handleChange","event","newValue","target","handleFocus","scrollLeft","handleMouseDown","document","activeElement","focus","handleBlur","handlePaste","reCalculate","propTypes","isRequired","func","bool","defaultProps","undefined"],"sources":["../src/AutoResizeTextarea.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\n\nimport './AutoResizeTextarea.scss';\n\ninterface AutoResizeTextareaProps {\n value: string;\n onChange: (val: string) => void;\n className?: string;\n spellCheck?: boolean;\n placeholder?: string;\n disabled?: boolean;\n delimiter?: string;\n id?: string;\n 'data-testid'?: string;\n}\n\n/**\n * Makes a textarea that auto resizes based on contents, its height grows with new lines.\n * If a delimeter is set, such as \" -\" or \" \", as used by jvm args or env vars\n * then the field will also \"explode\" the value by the delimiter over new lines\n * on focus, and implode on blur. By default, it doesn't word wrap.\n */\
|
|
1
|
+
{"version":3,"file":"AutoResizeTextarea.js","names":["React","useState","useRef","useEffect","PropTypes","classNames","AutoResizeTextarea","className","value","propsValue","onChange","spellCheck","placeholder","disabled","delimiter","id","dataTestId","setValue","isPastedChange","setIsPastedChange","element","syncStateWithProp","explode","input","trim","split","filter","string","join","implode","map","reCalculateLayout","current","style","height","resizedHeight","scrollHeight","offsetHeight","clientHeight","handleChange","event","newValue","target","handleFocus","scrollLeft","handleMouseDown","document","activeElement","focus","handleBlur","handlePaste","reCalculate","propTypes","isRequired","func","bool","defaultProps","undefined"],"sources":["../src/AutoResizeTextarea.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\n\nimport './AutoResizeTextarea.scss';\n\ninterface AutoResizeTextareaProps {\n value: string;\n onChange: (val: string) => void;\n className?: string;\n spellCheck?: boolean;\n placeholder?: string;\n disabled?: boolean;\n delimiter?: string;\n id?: string;\n 'data-testid'?: string;\n}\n\n/**\n * Makes a textarea that auto resizes based on contents, its height grows with new lines.\n * If a delimeter is set, such as \" -\" or \" \", as used by jvm args or env vars\n * then the field will also \"explode\" the value by the delimiter over new lines\n * on focus, and implode on blur. By default, it doesn't word wrap.\n */\nfunction AutoResizeTextarea({\n className = '',\n value: propsValue,\n onChange,\n spellCheck = false,\n placeholder = '',\n disabled = false,\n delimiter = '',\n id = '',\n 'data-testid': dataTestId,\n}: AutoResizeTextareaProps): JSX.Element {\n const [value, setValue] = useState(propsValue);\n const [isPastedChange, setIsPastedChange] = useState(false);\n const element = useRef<HTMLTextAreaElement>(null);\n\n useEffect(\n function syncStateWithProp() {\n // keep state value in sync with prop changes\n setValue(propsValue);\n },\n [propsValue]\n );\n\n function explode(input: string) {\n // split by delimiter, commonly \" \" or \" -\"\n // strip empty strings (if delimiter is space, and there are multiple spaces in a row)\n // and join with new line and a trimmed delimeter (get rid of leading spaces)\n return input\n .trim()\n .split(delimiter)\n .filter(string => string) // remove empty strings\n .join(`\\n${delimiter.trim()}`);\n }\n\n function implode(input: string) {\n return input\n .split('\\n')\n .map(string => string.trim())\n .join(' ');\n }\n\n function reCalculateLayout() {\n if (!element.current) {\n return;\n }\n element.current.style.height = '0'; // shrink component to get scrollHeight\n const resizedHeight =\n element.current.scrollHeight +\n (element.current.offsetHeight - element.current.clientHeight);\n // accounts for border, padding is captured by scroll height\n if (resizedHeight > 0) element.current.style.height = `${resizedHeight}px`;\n }\n\n function handleChange(event: React.ChangeEvent<HTMLTextAreaElement>) {\n let newValue = event.target.value;\n if (isPastedChange) {\n if (delimiter) newValue = explode(newValue);\n setIsPastedChange(false);\n }\n setValue(newValue);\n onChange(newValue);\n }\n\n function handleFocus() {\n if (!element.current) {\n return;\n }\n if (delimiter) {\n setValue(explode(value));\n reCalculateLayout();\n }\n element.current.scrollLeft = 0;\n // scroll left as it can be disorienting if you click on a long line\n }\n\n // make it explode when dragging the resize handle\n // by making it trigger focus (which normally doesn't\n // trigger when just resizing).\n function handleMouseDown() {\n if (!element.current) return;\n if (document.activeElement === element.current) return;\n element.current.focus();\n }\n\n function handleBlur() {\n if (delimiter) {\n setValue(implode(value));\n onChange(implode(value));\n }\n }\n\n function handlePaste() {\n setIsPastedChange(true);\n }\n\n useEffect(\n function reCalculate() {\n reCalculateLayout();\n },\n [value]\n );\n\n return (\n <textarea\n ref={element}\n id={id}\n className={classNames(className, 'auto-resize-textarea form-control')}\n placeholder={placeholder}\n value={value}\n rows={1}\n onChange={handleChange}\n onFocus={handleFocus}\n onMouseDown={handleMouseDown}\n onBlur={handleBlur}\n onPaste={handlePaste}\n spellCheck={spellCheck}\n disabled={disabled}\n data-testid={dataTestId}\n />\n );\n}\n\nAutoResizeTextarea.propTypes = {\n value: PropTypes.string.isRequired,\n onChange: PropTypes.func.isRequired,\n className: PropTypes.string,\n placeholder: PropTypes.string,\n spellCheck: PropTypes.bool,\n disabled: PropTypes.bool,\n delimiter: PropTypes.string,\n id: PropTypes.string,\n 'data-testid': PropTypes.string,\n};\n\nAutoResizeTextarea.defaultProps = {\n className: '',\n id: '',\n placeholder: '',\n disabled: false,\n spellCheck: false,\n delimiter: '',\n 'data-testid': undefined,\n};\n\nexport default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fF,UAAU,EAAE,KAAK;EACjBG,SAAS,EAAE,EAAE;EACb,aAAa,EAAE2C;AACjB,CAAC;AAED,eAAenD,kBAAkB"}
|
package/dist/BasicModal.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
2
3
|
interface BasicModalProps {
|
|
3
4
|
isOpen: boolean;
|
|
4
5
|
headerText: string;
|
|
@@ -26,6 +27,32 @@ interface BasicModalProps {
|
|
|
26
27
|
* @param confirmButtonText optional text for the confirm button, defaults to 'Okay'
|
|
27
28
|
* @param discardButtonText optional text for the discard button, defaults to 'Discard'
|
|
28
29
|
*/
|
|
29
|
-
declare
|
|
30
|
+
declare function BasicModal(props: BasicModalProps): JSX.Element;
|
|
31
|
+
declare namespace BasicModal {
|
|
32
|
+
var propTypes: {
|
|
33
|
+
isOpen: PropTypes.Validator<boolean>;
|
|
34
|
+
headerText: PropTypes.Validator<string>;
|
|
35
|
+
bodyText: PropTypes.Validator<string | ((...args: any[]) => any)>;
|
|
36
|
+
onCancel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
37
|
+
onConfirm: PropTypes.Validator<(...args: any[]) => any>;
|
|
38
|
+
onDiscard: PropTypes.Requireable<(...args: any[]) => any>;
|
|
39
|
+
onModalDisable: PropTypes.Requireable<(...args: any[]) => any>;
|
|
40
|
+
cancelButtonText: PropTypes.Requireable<string>;
|
|
41
|
+
confirmButtonText: PropTypes.Requireable<string>;
|
|
42
|
+
discardButtonText: PropTypes.Requireable<string>;
|
|
43
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
44
|
+
'data-testid': PropTypes.Requireable<string>;
|
|
45
|
+
};
|
|
46
|
+
var defaultProps: {
|
|
47
|
+
children: undefined;
|
|
48
|
+
cancelButtonText: string;
|
|
49
|
+
confirmButtonText: string;
|
|
50
|
+
discardButtonText: string;
|
|
51
|
+
onCancel: undefined;
|
|
52
|
+
onDiscard: undefined;
|
|
53
|
+
onModalDisable: undefined;
|
|
54
|
+
'data-testid': undefined;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
30
57
|
export default BasicModal;
|
|
31
58
|
//# sourceMappingURL=BasicModal.d.ts.map
|
package/dist/BasicModal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicModal.d.ts","sourceRoot":"","sources":["../src/BasicModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BasicModal.d.ts","sourceRoot":"","sources":["../src/BasicModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,SAAS,MAAM,YAAY,CAAC;AAKnC,UAAU,eAAe;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,eA8GzC;kBA9GQ,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;AA0InB,eAAe,UAAU,CAAC"}
|
package/dist/BasicModal.js
CHANGED
|
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import ButtonGroup from "./ButtonGroup.js";
|
|
4
4
|
import Button from "./Button.js";
|
|
5
5
|
import { Modal, ModalBody, ModalFooter, ModalHeader } from "./modal/index.js";
|
|
6
|
-
|
|
7
6
|
/**
|
|
8
7
|
* A basic modal dialog with two buttons: cancel / confirm.
|
|
9
8
|
*
|
|
@@ -17,7 +16,7 @@ import { Modal, ModalBody, ModalFooter, ModalHeader } from "./modal/index.js";
|
|
|
17
16
|
* @param confirmButtonText optional text for the confirm button, defaults to 'Okay'
|
|
18
17
|
* @param discardButtonText optional text for the discard button, defaults to 'Discard'
|
|
19
18
|
*/
|
|
20
|
-
|
|
19
|
+
function BasicModal(props) {
|
|
21
20
|
var {
|
|
22
21
|
isOpen,
|
|
23
22
|
headerText,
|
|
@@ -38,21 +37,17 @@ var BasicModal = props => {
|
|
|
38
37
|
if (disableModalCheckbox.current !== null && disableModalCheckbox.current.checked && onModalDisable) {
|
|
39
38
|
onModalDisable();
|
|
40
39
|
}
|
|
41
|
-
|
|
42
40
|
onConfirm();
|
|
43
41
|
}, [onConfirm, onModalDisable]);
|
|
44
42
|
var modalBody = '';
|
|
45
|
-
|
|
46
43
|
if (isOpen) {
|
|
47
44
|
modalBody = typeof bodyText === 'function' ? bodyText() : bodyText;
|
|
48
45
|
}
|
|
49
|
-
|
|
50
46
|
return /*#__PURE__*/React.createElement(Modal, {
|
|
51
47
|
isOpen: isOpen,
|
|
52
48
|
className: "theme-bg-light",
|
|
53
49
|
onOpened: () => {
|
|
54
50
|
var _confirmButton$curren;
|
|
55
|
-
|
|
56
51
|
(_confirmButton$curren = confirmButton.current) === null || _confirmButton$curren === void 0 ? void 0 : _confirmButton$curren.focus();
|
|
57
52
|
}
|
|
58
53
|
}, /*#__PURE__*/React.createElement(ModalHeader, {
|
|
@@ -86,8 +81,7 @@ var BasicModal = props => {
|
|
|
86
81
|
ref: confirmButton,
|
|
87
82
|
"data-testid": dataTestId !== undefined ? "".concat(dataTestId, "-btn-confirm") : undefined
|
|
88
83
|
}, confirmButtonText), children)));
|
|
89
|
-
}
|
|
90
|
-
|
|
84
|
+
}
|
|
91
85
|
BasicModal.propTypes = {
|
|
92
86
|
isOpen: PropTypes.bool.isRequired,
|
|
93
87
|
headerText: PropTypes.string.isRequired,
|
package/dist/BasicModal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicModal.js","names":["React","useRef","useCallback","PropTypes","ButtonGroup","Button","Modal","ModalBody","ModalFooter","ModalHeader","BasicModal","props","isOpen","headerText","bodyText","onCancel","onConfirm","onDiscard","onModalDisable","cancelButtonText","confirmButtonText","discardButtonText","children","dataTestId","confirmButton","disableModalCheckbox","onConfirmClicked","current","checked","modalBody","focus","undefined","propTypes","bool","isRequired","string","oneOfType","func","node","defaultProps"],"sources":["../src/BasicModal.tsx"],"sourcesContent":["import React, { useRef, useCallback } from 'react';\nimport PropTypes from 'prop-types';\nimport ButtonGroup from './ButtonGroup';\nimport Button from './Button';\nimport { Modal, ModalBody, ModalFooter, ModalHeader } from './modal';\n\ninterface BasicModalProps {\n isOpen: boolean;\n headerText: string;\n bodyText: string | (() => string);\n onCancel?: () => void;\n onConfirm: () => void;\n onDiscard?: () => void;\n onModalDisable?: () => void;\n cancelButtonText?: string;\n confirmButtonText?: string;\n discardButtonText?: string;\n children?: React.ReactNode;\n 'data-testid'?: string;\n}\n\n/**\n * A basic modal dialog with two buttons: cancel / confirm.\n *\n * @param isOpen indicates if the modal dialog is open\n * @param headerText text displayed in the modal header\n * @param bodyText text displayed in the modal body\n * @param onCancel callback for the cancel button; if not provided, button not shown\n * @param onConfirm callback for the confirm button\n * @param onDiscard callback for the discard button; if not provided, button not shown\n * @param cancelButtonText optional text for the cancel button, defaults to 'Cancel'\n * @param confirmButtonText optional text for the confirm button, defaults to 'Okay'\n * @param discardButtonText optional text for the discard button, defaults to 'Discard'\n */\
|
|
1
|
+
{"version":3,"file":"BasicModal.js","names":["React","useRef","useCallback","PropTypes","ButtonGroup","Button","Modal","ModalBody","ModalFooter","ModalHeader","BasicModal","props","isOpen","headerText","bodyText","onCancel","onConfirm","onDiscard","onModalDisable","cancelButtonText","confirmButtonText","discardButtonText","children","dataTestId","confirmButton","disableModalCheckbox","onConfirmClicked","current","checked","modalBody","focus","undefined","propTypes","bool","isRequired","string","oneOfType","func","node","defaultProps"],"sources":["../src/BasicModal.tsx"],"sourcesContent":["import React, { useRef, useCallback } from 'react';\nimport PropTypes from 'prop-types';\nimport ButtonGroup from './ButtonGroup';\nimport Button from './Button';\nimport { Modal, ModalBody, ModalFooter, ModalHeader } from './modal';\n\ninterface BasicModalProps {\n isOpen: boolean;\n headerText: string;\n bodyText: string | (() => string);\n onCancel?: () => void;\n onConfirm: () => void;\n onDiscard?: () => void;\n onModalDisable?: () => void;\n cancelButtonText?: string;\n confirmButtonText?: string;\n discardButtonText?: string;\n children?: React.ReactNode;\n 'data-testid'?: string;\n}\n\n/**\n * A basic modal dialog with two buttons: cancel / confirm.\n *\n * @param isOpen indicates if the modal dialog is open\n * @param headerText text displayed in the modal header\n * @param bodyText text displayed in the modal body\n * @param onCancel callback for the cancel button; if not provided, button not shown\n * @param onConfirm callback for the confirm button\n * @param onDiscard callback for the discard button; if not provided, button not shown\n * @param cancelButtonText optional text for the cancel button, defaults to 'Cancel'\n * @param confirmButtonText optional text for the confirm button, defaults to 'Okay'\n * @param discardButtonText optional text for the discard button, defaults to 'Discard'\n */\nfunction BasicModal(props: BasicModalProps) {\n const {\n isOpen,\n headerText,\n bodyText,\n onCancel,\n onConfirm,\n onDiscard,\n onModalDisable,\n cancelButtonText = 'Cancel',\n confirmButtonText = 'Okay',\n discardButtonText = 'Discard',\n children,\n 'data-testid': dataTestId,\n } = props;\n\n const confirmButton = useRef<HTMLButtonElement>(null);\n\n const disableModalCheckbox = useRef<HTMLInputElement>(null);\n\n const onConfirmClicked = useCallback(() => {\n if (\n disableModalCheckbox.current !== null &&\n disableModalCheckbox.current.checked &&\n onModalDisable\n ) {\n onModalDisable();\n }\n onConfirm();\n }, [onConfirm, onModalDisable]);\n\n let modalBody = '';\n if (isOpen) {\n modalBody = typeof bodyText === 'function' ? bodyText() : bodyText;\n }\n\n return (\n <Modal\n isOpen={isOpen}\n className=\"theme-bg-light\"\n onOpened={() => {\n confirmButton.current?.focus();\n }}\n >\n <ModalHeader closeButton={false}>{headerText}</ModalHeader>\n <ModalBody>{modalBody}</ModalBody>\n <ModalFooter>\n {onModalDisable && (\n <div className=\"custom-control custom-checkbox form-group mr-auto\">\n <input\n type=\"checkbox\"\n className=\"custom-control-input\"\n id=\"move-confirmation-checkbox\"\n defaultChecked={false}\n ref={disableModalCheckbox}\n data-testid={\n dataTestId !== undefined\n ? `${dataTestId}-checkbox-confirm`\n : undefined\n }\n />\n <label\n className=\"custom-control-label\"\n htmlFor=\"move-confirmation-checkbox\"\n >\n Don't ask me again\n </label>\n </div>\n )}\n {onDiscard && (\n <Button\n kind=\"secondary\"\n className=\"mr-auto\"\n data-dismiss=\"modal\"\n onClick={onDiscard}\n data-testid={\n dataTestId !== undefined ? `${dataTestId}-btn-discard` : undefined\n }\n >\n {discardButtonText}\n </Button>\n )}\n {onCancel && (\n <Button\n kind=\"secondary\"\n data-dismiss=\"modal\"\n onClick={onCancel}\n data-testid={\n dataTestId !== undefined ? `${dataTestId}-btn-cancel` : undefined\n }\n >\n {cancelButtonText}\n </Button>\n )}\n <ButtonGroup>\n <Button\n kind=\"primary\"\n onClick={onConfirmClicked}\n ref={confirmButton}\n data-testid={\n dataTestId !== undefined ? `${dataTestId}-btn-confirm` : undefined\n }\n >\n {confirmButtonText}\n </Button>\n {children}\n </ButtonGroup>\n </ModalFooter>\n </Modal>\n );\n}\n\nBasicModal.propTypes = {\n isOpen: PropTypes.bool.isRequired,\n headerText: PropTypes.string.isRequired,\n bodyText: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).isRequired,\n onCancel: PropTypes.func,\n onConfirm: PropTypes.func.isRequired,\n onDiscard: PropTypes.func,\n onModalDisable: PropTypes.func,\n cancelButtonText: PropTypes.string,\n confirmButtonText: PropTypes.string,\n discardButtonText: PropTypes.string,\n children: PropTypes.node,\n 'data-testid': PropTypes.string,\n};\n\nBasicModal.defaultProps = {\n children: undefined,\n cancelButtonText: 'Cancel',\n confirmButtonText: 'Okay',\n discardButtonText: 'Discard',\n onCancel: undefined,\n onDiscard: undefined,\n onModalDisable: undefined,\n 'data-testid': undefined,\n};\n\nexport default BasicModal;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,WAAW,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAAC,OAC5BC,WAAW;AAAA,OACXC,MAAM;AAAA,SACJC,KAAK,EAAEC,SAAS,EAAEC,WAAW,EAAEC,WAAW;AAiBnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,UAAU,CAACC,KAAsB,EAAE;EAC1C,IAAM;IACJC,MAAM;IACNC,UAAU;IACVC,QAAQ;IACRC,QAAQ;IACRC,SAAS;IACTC,SAAS;IACTC,cAAc;IACdC,gBAAgB,GAAG,QAAQ;IAC3BC,iBAAiB,GAAG,MAAM;IAC1BC,iBAAiB,GAAG,SAAS;IAC7BC,QAAQ;IACR,aAAa,EAAEC;EACjB,CAAC,GAAGZ,KAAK;EAET,IAAMa,aAAa,GAAGvB,MAAM,CAAoB,IAAI,CAAC;EAErD,IAAMwB,oBAAoB,GAAGxB,MAAM,CAAmB,IAAI,CAAC;EAE3D,IAAMyB,gBAAgB,GAAGxB,WAAW,CAAC,MAAM;IACzC,IACEuB,oBAAoB,CAACE,OAAO,KAAK,IAAI,IACrCF,oBAAoB,CAACE,OAAO,CAACC,OAAO,IACpCV,cAAc,EACd;MACAA,cAAc,EAAE;IAClB;IACAF,SAAS,EAAE;EACb,CAAC,EAAE,CAACA,SAAS,EAAEE,cAAc,CAAC,CAAC;EAE/B,IAAIW,SAAS,GAAG,EAAE;EAClB,IAAIjB,MAAM,EAAE;IACViB,SAAS,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aAAMR,UAAU,oBAAiBQ;EAC1D,GAEAX,iBAAiB,CACX,EACRE,QAAQ,CACG,CACF,CACR;AAEZ;AAEAZ,UAAU,CAACsB,SAAS,GAAG;EACrBpB,MAAM,EAAET,SAAS,CAAC8B,IAAI,CAACC,UAAU;EACjCrB,UAAU,EAAEV,SAAS,CAACgC,MAAM,CAACD,UAAU;EACvCpB,QAAQ,EAAEX,SAAS,CAACiC,SAAS,CAAC,CAACjC,SAAS,CAACgC,MAAM,EAAEhC,SAAS,CAACkC,IAAI,CAAC,CAAC,CAACH,UAAU;EAC5EnB,QAAQ,EAAEZ,SAAS,CAACkC,IAAI;EACxBrB,SAAS,EAAEb,SAAS,CAACkC,IAAI,CAACH,UAAU;EACpCjB,SAAS,EAAEd,SAAS,CAACkC,IAAI;EACzBnB,cAAc,EAAEf,SAAS,CAACkC,IAAI;EAC9BlB,gBAAgB,EAAEhB,SAAS,CAACgC,MAAM;EAClCf,iBAAiB,EAAEjB,SAAS,CAACgC,MAAM;EACnCd,iBAAiB,EAAElB,SAAS,CAACgC,MAAM;EACnCb,QAAQ,EAAEnB,SAAS,CAACmC,IAAI;EACxB,aAAa,EAAEnC,SAAS,CAACgC;AAC3B,CAAC;AAEDzB,UAAU,CAAC6B,YAAY,GAAG;EACxBjB,QAAQ,EAAES,SAAS;EACnBZ,gBAAgB,EAAE,QAAQ;EAC1BC,iBAAiB,EAAE,MAAM;EACzBC,iBAAiB,EAAE,SAAS;EAC5BN,QAAQ,EAAEgB,SAAS;EACnBd,SAAS,EAAEc,SAAS;EACpBb,cAAc,EAAEa,SAAS;EACzB,aAAa,EAAEA;AACjB,CAAC;AAED,eAAerB,UAAU"}
|
package/dist/Button.js
CHANGED
|
@@ -5,27 +5,20 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
5
5
|
import { Tooltip } from "./popper/index.js";
|
|
6
6
|
var BUTTON_KINDS = ['primary', 'secondary', 'tertiary', 'success', 'danger', 'inline', 'ghost'];
|
|
7
7
|
var VARIANT_KINDS = ['group-end'];
|
|
8
|
-
|
|
9
8
|
function getClassName(kind, iconOnly) {
|
|
10
9
|
switch (kind) {
|
|
11
10
|
case 'primary':
|
|
12
11
|
return 'btn-primary';
|
|
13
|
-
|
|
14
12
|
case 'secondary':
|
|
15
13
|
return 'btn-outline-primary';
|
|
16
|
-
|
|
17
14
|
case 'tertiary':
|
|
18
15
|
return 'btn-secondary';
|
|
19
|
-
|
|
20
16
|
case 'success':
|
|
21
17
|
return 'btn-success';
|
|
22
|
-
|
|
23
18
|
case 'danger':
|
|
24
19
|
return 'btn-danger';
|
|
25
|
-
|
|
26
20
|
case 'inline':
|
|
27
21
|
return 'btn-inline';
|
|
28
|
-
|
|
29
22
|
case 'ghost':
|
|
30
23
|
return classNames('btn-link', {
|
|
31
24
|
'btn-link-icon': iconOnly,
|
|
@@ -33,14 +26,12 @@ function getClassName(kind, iconOnly) {
|
|
|
33
26
|
});
|
|
34
27
|
}
|
|
35
28
|
}
|
|
36
|
-
|
|
37
29
|
function getVariantClasses(kind) {
|
|
38
30
|
switch (kind) {
|
|
39
31
|
case 'group-end':
|
|
40
32
|
return classNames('pl-2', 'pr-3');
|
|
41
33
|
}
|
|
42
34
|
}
|
|
43
|
-
|
|
44
35
|
var Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
45
36
|
var {
|
|
46
37
|
kind,
|
|
@@ -67,36 +58,30 @@ var Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
67
58
|
var iconOnly = Boolean(icon && children == null);
|
|
68
59
|
var btnClassName = getClassName(kind, iconOnly);
|
|
69
60
|
var variantClassName;
|
|
70
|
-
|
|
71
61
|
if (variant) {
|
|
72
62
|
variantClassName = getVariantClasses(variant);
|
|
73
63
|
}
|
|
74
|
-
|
|
75
64
|
var iconElem;
|
|
76
|
-
|
|
77
65
|
if (icon) {
|
|
78
66
|
iconElem = /*#__PURE__*/React.isValidElement(icon) ? icon : /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
79
67
|
icon: icon
|
|
80
68
|
});
|
|
81
69
|
}
|
|
82
|
-
|
|
83
70
|
var tooltipElem;
|
|
84
|
-
|
|
85
71
|
if (tooltip !== undefined) {
|
|
86
72
|
tooltipElem = typeof tooltip === 'string' ? /*#__PURE__*/React.createElement(Tooltip, null, tooltip) : tooltip;
|
|
87
|
-
}
|
|
88
|
-
// if tooltip is also a string and aria-label is not set
|
|
89
|
-
|
|
73
|
+
}
|
|
90
74
|
|
|
75
|
+
// use tooltip as arial-label for iconOnly buttons only
|
|
76
|
+
// if tooltip is also a string and aria-label is not set
|
|
91
77
|
var ariaLabelString = ariaLabel;
|
|
92
|
-
|
|
93
78
|
if (ariaLabel === undefined && iconOnly && tooltip != null && typeof tooltip === 'string') {
|
|
94
79
|
ariaLabelString = tooltip;
|
|
95
80
|
}
|
|
96
|
-
|
|
97
81
|
var button = /*#__PURE__*/React.createElement("button", {
|
|
98
82
|
"data-testid": dataTestId,
|
|
99
|
-
ref: ref
|
|
83
|
+
ref: ref
|
|
84
|
+
// eslint-disable-next-line react/button-has-type
|
|
100
85
|
,
|
|
101
86
|
type: type,
|
|
102
87
|
className: classNames('btn', btnClassName, variantClassName, {
|
|
@@ -113,7 +98,9 @@ var Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
113
98
|
disabled: disabled,
|
|
114
99
|
tabIndex: tabIndex,
|
|
115
100
|
"aria-label": ariaLabelString
|
|
116
|
-
}, icon && iconElem, children, tooltip != null && (disabled === undefined || !disabled) && tooltipElem);
|
|
101
|
+
}, icon && iconElem, children, tooltip != null && (disabled === undefined || !disabled) && tooltipElem);
|
|
102
|
+
|
|
103
|
+
// disabled buttons tooltips need a wrapped element to receive pointer events
|
|
117
104
|
// https://jakearchibald.com/2017/events-and-disabled-form-fields/
|
|
118
105
|
|
|
119
106
|
return disabled !== undefined && disabled ? /*#__PURE__*/React.createElement("span", {
|
|
@@ -125,58 +112,45 @@ Button.propTypes = {
|
|
|
125
112
|
kind: PropTypes.oneOf(BUTTON_KINDS).isRequired,
|
|
126
113
|
variant: PropTypes.oneOf(VARIANT_KINDS),
|
|
127
114
|
type: PropTypes.oneOf(['submit', 'reset', 'button']),
|
|
128
|
-
|
|
129
115
|
tooltip(props) {
|
|
130
116
|
var {
|
|
131
117
|
tooltip,
|
|
132
118
|
icon,
|
|
133
119
|
children
|
|
134
120
|
} = props;
|
|
135
|
-
|
|
136
121
|
if (tooltip === undefined && icon != null && children == null) {
|
|
137
122
|
return new Error('Tooltip is required for icon only buttons');
|
|
138
123
|
}
|
|
139
|
-
|
|
140
124
|
return null;
|
|
141
125
|
},
|
|
142
|
-
|
|
143
126
|
icon(props) {
|
|
144
127
|
var {
|
|
145
128
|
children,
|
|
146
129
|
icon
|
|
147
130
|
} = props;
|
|
148
|
-
|
|
149
131
|
if (icon == null && children == null) {
|
|
150
132
|
return new Error('Icon is required if no children are provided');
|
|
151
133
|
}
|
|
152
|
-
|
|
153
134
|
if (children == null && ! /*#__PURE__*/React.isValidElement(icon) && (icon == null || icon.iconName === '' || icon.iconName == null)) {
|
|
154
135
|
return new Error('Icon must be react element or fontawesome IconDefinition');
|
|
155
136
|
}
|
|
156
|
-
|
|
157
137
|
return null;
|
|
158
138
|
},
|
|
159
|
-
|
|
160
139
|
disabled: PropTypes.bool,
|
|
161
140
|
active: PropTypes.bool,
|
|
162
|
-
|
|
163
141
|
onClick(props) {
|
|
164
142
|
var {
|
|
165
143
|
onClick,
|
|
166
144
|
type
|
|
167
145
|
} = props;
|
|
168
|
-
|
|
169
146
|
if (type === 'button' && typeof onClick !== 'function') {
|
|
170
147
|
return new Error('type button requires an onClick function');
|
|
171
148
|
}
|
|
172
|
-
|
|
173
149
|
if (onClick !== undefined && typeof onClick !== 'function') {
|
|
174
150
|
return new Error('onClick must be a function');
|
|
175
151
|
}
|
|
176
|
-
|
|
177
152
|
return null;
|
|
178
153
|
},
|
|
179
|
-
|
|
180
154
|
onContextMenu: PropTypes.func,
|
|
181
155
|
onMouseUp: PropTypes.func,
|
|
182
156
|
onMouseDown: PropTypes.func,
|
package/dist/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","names":["React","PropTypes","classNames","FontAwesomeIcon","Tooltip","BUTTON_KINDS","VARIANT_KINDS","getClassName","kind","iconOnly","getVariantClasses","Button","forwardRef","props","ref","variant","type","tooltip","icon","disabled","active","onClick","onContextMenu","onMouseDown","onMouseUp","onMouseEnter","onMouseLeave","onKeyDown","className","style","children","tabIndex","dataTestId","ariaLabel","Boolean","btnClassName","variantClassName","iconElem","isValidElement","tooltipElem","undefined","ariaLabelString","button","displayName","propTypes","oneOf","isRequired","Error","iconName","bool","func","number","node","string","object","defaultProps"],"sources":["../src/Button.tsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { IconDefinition } from '@fortawesome/fontawesome-svg-core';\nimport { Tooltip } from './popper';\n\nconst BUTTON_KINDS = [\n 'primary',\n 'secondary',\n 'tertiary',\n 'success',\n 'danger',\n 'inline',\n 'ghost',\n] as const;\ntype ButtonTuple = typeof BUTTON_KINDS;\nexport type ButtonKind = ButtonTuple[number];\n\nconst VARIANT_KINDS = ['group-end'] as const;\ntype VariantTuple = typeof VARIANT_KINDS;\ntype VariantKind = VariantTuple[number];\n\ntype ButtonTypes = 'submit' | 'reset' | 'button';\n\ninterface BaseButtonProps extends React.ComponentPropsWithRef<'button'> {\n kind: ButtonKind;\n type?: ButtonTypes;\n variant?: VariantKind;\n tooltip?: string | JSX.Element;\n icon?: IconDefinition | JSX.Element;\n active?: boolean;\n 'data-testid'?: string;\n}\n\ntype ButtonWithChildren = BaseButtonProps & {\n children: React.ReactNode;\n};\n\ntype IconOnlyButtonStringTooltip = BaseButtonProps & {\n tooltip: string;\n icon: IconDefinition | JSX.Element;\n children?: undefined;\n};\n\ntype IconOnlyButtonJsxTooltip = BaseButtonProps & {\n tooltip: JSX.Element;\n 'aria-label': string;\n icon: IconDefinition | JSX.Element;\n children?: undefined;\n};\n\ntype IconOnlyButton = IconOnlyButtonStringTooltip | IconOnlyButtonJsxTooltip;\n\ntype ButtonProps = IconOnlyButton | ButtonWithChildren;\n\nfunction getClassName(kind: ButtonKind, iconOnly: boolean): string {\n switch (kind) {\n case 'primary':\n return 'btn-primary';\n case 'secondary':\n return 'btn-outline-primary';\n case 'tertiary':\n return 'btn-secondary';\n case 'success':\n return 'btn-success';\n case 'danger':\n return 'btn-danger';\n case 'inline':\n return 'btn-inline';\n case 'ghost':\n return classNames('btn-link', {\n 'btn-link-icon': iconOnly,\n 'btn-link-icon-only': iconOnly,\n });\n }\n}\n\nfunction getVariantClasses(kind: VariantKind): string {\n switch (kind) {\n case 'group-end':\n return classNames('pl-2', 'pr-3');\n }\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (props: ButtonProps, ref) => {\n const {\n kind,\n variant,\n type,\n tooltip,\n icon,\n disabled,\n active,\n onClick,\n onContextMenu,\n onMouseDown,\n onMouseUp,\n onMouseEnter,\n onMouseLeave,\n onKeyDown,\n className,\n style,\n children,\n tabIndex,\n 'data-testid': dataTestId,\n 'aria-label': ariaLabel,\n } = props;\n\n const iconOnly = Boolean(icon && children == null);\n const btnClassName = getClassName(kind, iconOnly);\n\n let variantClassName;\n if (variant) {\n variantClassName = getVariantClasses(variant);\n }\n\n let iconElem: JSX.Element | undefined;\n if (icon) {\n iconElem = React.isValidElement(icon) ? (\n icon\n ) : (\n <FontAwesomeIcon icon={icon as IconDefinition} />\n );\n }\n\n let tooltipElem: JSX.Element | undefined;\n if (tooltip !== undefined) {\n tooltipElem =\n typeof tooltip === 'string' ? <Tooltip>{tooltip}</Tooltip> : tooltip;\n }\n\n // use tooltip as arial-label for iconOnly buttons only\n // if tooltip is also a string and aria-label is not set\n let ariaLabelString = ariaLabel;\n if (\n ariaLabel === undefined &&\n iconOnly &&\n tooltip != null &&\n typeof tooltip === 'string'\n ) {\n ariaLabelString = tooltip;\n }\n\n const button = (\n <button\n data-testid={dataTestId}\n ref={ref}\n // eslint-disable-next-line react/button-has-type\n type={type}\n className={classNames(\n 'btn',\n btnClassName,\n variantClassName,\n { active },\n className\n )}\n onClick={onClick}\n onContextMenu={onContextMenu}\n onMouseUp={onMouseUp}\n onMouseDown={onMouseDown}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onKeyDown={onKeyDown}\n style={style}\n disabled={disabled}\n tabIndex={tabIndex}\n aria-label={ariaLabelString}\n >\n {icon && iconElem}\n {children}\n {tooltip != null &&\n (disabled === undefined || !disabled) &&\n tooltipElem}\n </button>\n );\n\n // disabled buttons tooltips need a wrapped element to receive pointer events\n // https://jakearchibald.com/2017/events-and-disabled-form-fields/\n\n return disabled !== undefined && disabled ? (\n <span className=\"btn-disabled-wrapper\">\n {button}\n {tooltip !== undefined && tooltipElem}\n </span>\n ) : (\n button\n );\n }\n);\n\nButton.displayName = 'Button';\n\nButton.propTypes = {\n kind: PropTypes.oneOf(BUTTON_KINDS).isRequired,\n variant: PropTypes.oneOf(VARIANT_KINDS),\n type: PropTypes.oneOf<ButtonTypes>(['submit', 'reset', 'button']),\n tooltip(props) {\n const { tooltip, icon, children } = props;\n if (tooltip === undefined && icon != null && children == null) {\n return new Error('Tooltip is required for icon only buttons');\n }\n return null;\n },\n icon(props) {\n const { children, icon } = props;\n if (icon == null && children == null) {\n return new Error('Icon is required if no children are provided');\n }\n\n if (\n children == null &&\n !React.isValidElement(icon) &&\n (icon == null || icon.iconName === '' || icon.iconName == null)\n ) {\n return new Error(\n 'Icon must be react element or fontawesome IconDefinition'\n );\n }\n\n return null;\n },\n disabled: PropTypes.bool,\n active: PropTypes.bool,\n onClick(props) {\n const { onClick, type } = props;\n if (type === 'button' && typeof onClick !== 'function') {\n return new Error('type button requires an onClick function');\n }\n if (onClick !== undefined && typeof onClick !== 'function') {\n return new Error('onClick must be a function');\n }\n return null;\n },\n onContextMenu: PropTypes.func,\n onMouseUp: PropTypes.func,\n onMouseDown: PropTypes.func,\n onMouseEnter: PropTypes.func,\n onMouseLeave: PropTypes.func,\n onKeyDown: PropTypes.func,\n tabIndex: PropTypes.number,\n children: PropTypes.node,\n className: PropTypes.string,\n style: PropTypes.object,\n 'data-testid': PropTypes.string,\n};\n\nButton.defaultProps = {\n type: 'button',\n onClick: undefined,\n onContextMenu: undefined,\n onMouseUp: undefined,\n onMouseDown: undefined,\n onMouseEnter: undefined,\n onMouseLeave: undefined,\n onKeyDown: undefined,\n variant: undefined,\n tooltip: undefined,\n icon: undefined,\n disabled: false,\n active: undefined,\n tabIndex: undefined,\n children: undefined,\n className: undefined,\n style: {},\n 'data-testid': undefined,\n};\n\nexport default Button;\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,SAASC,eAAT,QAAgC,gCAAhC;SAESC,O;AAET,IAAMC,YAAY,GAAG,CACnB,SADmB,EAEnB,WAFmB,EAGnB,UAHmB,EAInB,SAJmB,EAKnB,QALmB,EAMnB,QANmB,EAOnB,OAPmB,CAArB;AAYA,IAAMC,aAAa,GAAG,CAAC,WAAD,CAAtB;;AAqCA,SAASC,YAAT,CAAsBC,IAAtB,EAAwCC,QAAxC,EAAmE;EACjE,QAAQD,IAAR;IACE,KAAK,SAAL;MACE,OAAO,aAAP;;IACF,KAAK,WAAL;MACE,OAAO,qBAAP;;IACF,KAAK,UAAL;MACE,OAAO,eAAP;;IACF,KAAK,SAAL;MACE,OAAO,aAAP;;IACF,KAAK,QAAL;MACE,OAAO,YAAP;;IACF,KAAK,QAAL;MACE,OAAO,YAAP;;IACF,KAAK,OAAL;MACE,OAAON,UAAU,CAAC,UAAD,EAAa;QAC5B,iBAAiBO,QADW;QAE5B,sBAAsBA;MAFM,CAAb,CAAjB;EAdJ;AAmBD;;AAED,SAASC,iBAAT,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VARIANT_KINDS","getClassName","kind","iconOnly","getVariantClasses","Button","forwardRef","props","ref","variant","type","tooltip","icon","disabled","active","onClick","onContextMenu","onMouseDown","onMouseUp","onMouseEnter","onMouseLeave","onKeyDown","className","style","children","tabIndex","dataTestId","ariaLabel","Boolean","btnClassName","variantClassName","iconElem","isValidElement","tooltipElem","undefined","ariaLabelString","button","displayName","propTypes","oneOf","isRequired","Error","iconName","bool","func","number","node","string","object","defaultProps"],"sources":["../src/Button.tsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { IconDefinition } from '@fortawesome/fontawesome-svg-core';\nimport { Tooltip } from './popper';\n\nconst BUTTON_KINDS = [\n 'primary',\n 'secondary',\n 'tertiary',\n 'success',\n 'danger',\n 'inline',\n 'ghost',\n] as const;\ntype ButtonTuple = typeof BUTTON_KINDS;\nexport type ButtonKind = ButtonTuple[number];\n\nconst VARIANT_KINDS = ['group-end'] as const;\ntype VariantTuple = typeof VARIANT_KINDS;\ntype VariantKind = VariantTuple[number];\n\ntype ButtonTypes = 'submit' | 'reset' | 'button';\n\ninterface BaseButtonProps extends React.ComponentPropsWithRef<'button'> {\n kind: ButtonKind;\n type?: ButtonTypes;\n variant?: VariantKind;\n tooltip?: string | JSX.Element;\n icon?: IconDefinition | JSX.Element;\n active?: boolean;\n 'data-testid'?: string;\n}\n\ntype ButtonWithChildren = BaseButtonProps & {\n children: React.ReactNode;\n};\n\ntype IconOnlyButtonStringTooltip = BaseButtonProps & {\n tooltip: string;\n icon: IconDefinition | JSX.Element;\n children?: undefined;\n};\n\ntype IconOnlyButtonJsxTooltip = BaseButtonProps & {\n tooltip: JSX.Element;\n 'aria-label': string;\n icon: IconDefinition | JSX.Element;\n children?: undefined;\n};\n\ntype IconOnlyButton = IconOnlyButtonStringTooltip | IconOnlyButtonJsxTooltip;\n\ntype ButtonProps = IconOnlyButton | ButtonWithChildren;\n\nfunction getClassName(kind: ButtonKind, iconOnly: boolean): string {\n switch (kind) {\n case 'primary':\n return 'btn-primary';\n case 'secondary':\n return 'btn-outline-primary';\n case 'tertiary':\n return 'btn-secondary';\n case 'success':\n return 'btn-success';\n case 'danger':\n return 'btn-danger';\n case 'inline':\n return 'btn-inline';\n case 'ghost':\n return classNames('btn-link', {\n 'btn-link-icon': iconOnly,\n 'btn-link-icon-only': iconOnly,\n });\n }\n}\n\nfunction getVariantClasses(kind: VariantKind): string {\n switch (kind) {\n case 'group-end':\n return classNames('pl-2', 'pr-3');\n }\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (props: ButtonProps, ref) => {\n const {\n kind,\n variant,\n type,\n tooltip,\n icon,\n disabled,\n active,\n onClick,\n onContextMenu,\n onMouseDown,\n onMouseUp,\n onMouseEnter,\n onMouseLeave,\n onKeyDown,\n className,\n style,\n children,\n tabIndex,\n 'data-testid': dataTestId,\n 'aria-label': ariaLabel,\n } = props;\n\n const iconOnly = Boolean(icon && children == null);\n const btnClassName = getClassName(kind, iconOnly);\n\n let variantClassName;\n if (variant) {\n variantClassName = getVariantClasses(variant);\n }\n\n let iconElem: JSX.Element | undefined;\n if (icon) {\n iconElem = React.isValidElement(icon) ? (\n icon\n ) : (\n <FontAwesomeIcon icon={icon as IconDefinition} />\n );\n }\n\n let tooltipElem: JSX.Element | undefined;\n if (tooltip !== undefined) {\n tooltipElem =\n typeof tooltip === 'string' ? <Tooltip>{tooltip}</Tooltip> : tooltip;\n }\n\n // use tooltip as arial-label for iconOnly buttons only\n // if tooltip is also a string and aria-label is not set\n let ariaLabelString = ariaLabel;\n if (\n ariaLabel === undefined &&\n iconOnly &&\n tooltip != null &&\n typeof tooltip === 'string'\n ) {\n ariaLabelString = tooltip;\n }\n\n const button = (\n <button\n data-testid={dataTestId}\n ref={ref}\n // eslint-disable-next-line react/button-has-type\n type={type}\n className={classNames(\n 'btn',\n btnClassName,\n variantClassName,\n { active },\n className\n )}\n onClick={onClick}\n onContextMenu={onContextMenu}\n onMouseUp={onMouseUp}\n onMouseDown={onMouseDown}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onKeyDown={onKeyDown}\n style={style}\n disabled={disabled}\n tabIndex={tabIndex}\n aria-label={ariaLabelString}\n >\n {icon && iconElem}\n {children}\n {tooltip != null &&\n (disabled === undefined || !disabled) &&\n tooltipElem}\n </button>\n );\n\n // disabled buttons tooltips need a wrapped element to receive pointer events\n // https://jakearchibald.com/2017/events-and-disabled-form-fields/\n\n return disabled !== undefined && disabled ? (\n <span className=\"btn-disabled-wrapper\">\n {button}\n {tooltip !== undefined && tooltipElem}\n </span>\n ) : (\n button\n );\n }\n);\n\nButton.displayName = 'Button';\n\nButton.propTypes = {\n kind: PropTypes.oneOf(BUTTON_KINDS).isRequired,\n variant: PropTypes.oneOf(VARIANT_KINDS),\n type: PropTypes.oneOf<ButtonTypes>(['submit', 'reset', 'button']),\n tooltip(props) {\n const { tooltip, icon, children } = props;\n if (tooltip === undefined && icon != null && children == null) {\n return new Error('Tooltip is required for icon only buttons');\n }\n return null;\n },\n icon(props) {\n const { children, icon } = props;\n if (icon == null && children == null) {\n return new Error('Icon is required if no children are provided');\n }\n\n if (\n children == null &&\n !React.isValidElement(icon) &&\n (icon == null || icon.iconName === '' || icon.iconName == null)\n ) {\n return new Error(\n 'Icon must be react element or fontawesome IconDefinition'\n );\n }\n\n return null;\n },\n disabled: PropTypes.bool,\n active: PropTypes.bool,\n onClick(props) {\n const { onClick, type } = props;\n if (type === 'button' && typeof onClick !== 'function') {\n return new Error('type button requires an onClick function');\n }\n if (onClick !== undefined && typeof onClick !== 'function') {\n return new Error('onClick must be a function');\n }\n return null;\n },\n onContextMenu: PropTypes.func,\n onMouseUp: PropTypes.func,\n onMouseDown: PropTypes.func,\n onMouseEnter: PropTypes.func,\n onMouseLeave: PropTypes.func,\n onKeyDown: PropTypes.func,\n tabIndex: PropTypes.number,\n children: PropTypes.node,\n className: PropTypes.string,\n style: PropTypes.object,\n 'data-testid': PropTypes.string,\n};\n\nButton.defaultProps = {\n type: 'button',\n onClick: undefined,\n onContextMenu: undefined,\n onMouseUp: undefined,\n onMouseDown: undefined,\n onMouseEnter: undefined,\n onMouseLeave: undefined,\n onKeyDown: undefined,\n variant: undefined,\n tooltip: undefined,\n icon: undefined,\n disabled: false,\n active: undefined,\n tabIndex: undefined,\n children: undefined,\n className: undefined,\n style: {},\n 'data-testid': undefined,\n};\n\nexport default Button;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,eAAe,QAAQ,gCAAgC;AAAC,SAExDC,OAAO;AAEhB,IAAMC,YAAY,GAAG,CACnB,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,OAAO,CACC;AAIV,IAAMC,aAAa,GAAG,CAAC,WAAW,CAAU;AAqC5C,SAASC,YAAY,CAACC,IAAgB,EAAEC,QAAiB,EAAU;EACjE,QAAQD,IAAI;IACV,KAAK,SAAS;MACZ,OAAO,aAAa;IACtB,KAAK,WAAW;MACd,OAAO,qBAAqB;IAC9B,KAAK,UAAU;MACb,OAAO,eAAe;IACxB,KAAK,SAAS;MACZ,OAAO,aAAa;IACtB,KAAK,QAAQ;MACX,OAAO,YAAY;IACrB,KAAK,QAAQ;MACX,OAAO,YAAY;IACrB,KAAK,OAAO;MACV,OAAON,UAAU,CAAC,UAAU,EAAE;QAC5B,eAAe,EAAEO,QAAQ;QACzB,oBAAoB,EAAEA;MACxB,CAAC,CAAC;EAAC;AAET;AAEA,SAASC,iBAAiB,CAACF,IAAiB,EAAU;EACpD,QAAQA,IAAI;IACV,KAAK,WAAW;MACd,OAAON,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC;EAAC;AAExC;AAEA,IAAMS,MAAM,gBAAGX,KAAK,CAACY,UAAU,CAC7B,CAACC,KAA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EAAE1B,SAAS,CAACiD,IAAI;EACzBnB,QAAQ,EAAE9B,SAAS,CAACkD,MAAM;EAC1BrB,QAAQ,EAAE7B,SAAS,CAACmD,IAAI;EACxBxB,SAAS,EAAE3B,SAAS,CAACoD,MAAM;EAC3BxB,KAAK,EAAE5B,SAAS,CAACqD,MAAM;EACvB,aAAa,EAAErD,SAAS,CAACoD;AAC3B,CAAC;AAED1C,MAAM,CAAC4C,YAAY,GAAG;EACpBvC,IAAI,EAAE,QAAQ;EACdK,OAAO,EAAEmB,SAAS;EAClBlB,aAAa,EAAEkB,SAAS;EACxBhB,SAAS,EAAEgB,SAAS;EACpBjB,WAAW,EAAEiB,SAAS;EACtBf,YAAY,EAAEe,SAAS;EACvBd,YAAY,EAAEc,SAAS;EACvBb,SAAS,EAAEa,SAAS;EACpBzB,OAAO,EAAEyB,SAAS;EAClBvB,OAAO,EAAEuB,SAAS;EAClBtB,IAAI,EAAEsB,SAAS;EACfrB,QAAQ,EAAE,KAAK;EACfC,MAAM,EAAEoB,SAAS;EACjBT,QAAQ,EAAES,SAAS;EACnBV,QAAQ,EAAEU,SAAS;EACnBZ,SAAS,EAAEY,SAAS;EACpBX,KAAK,EAAE,CAAC,CAAC;EACT,aAAa,EAAEW;AACjB,CAAC;AAED,eAAe7B,MAAM"}
|
package/dist/ButtonGroup.d.ts
CHANGED
|
@@ -6,20 +6,20 @@ interface ButtonGroupProps {
|
|
|
6
6
|
style?: React.CSSProperties;
|
|
7
7
|
'data-testid'?: string;
|
|
8
8
|
}
|
|
9
|
-
declare
|
|
10
|
-
|
|
11
|
-
displayName: string;
|
|
12
|
-
propTypes: {
|
|
9
|
+
declare function ButtonGroup(props: ButtonGroupProps): JSX.Element;
|
|
10
|
+
declare namespace ButtonGroup {
|
|
11
|
+
var displayName: string;
|
|
12
|
+
var propTypes: {
|
|
13
13
|
children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
|
14
14
|
className: PropTypes.Requireable<string>;
|
|
15
15
|
style: PropTypes.Requireable<object>;
|
|
16
16
|
'data-testid': PropTypes.Requireable<string>;
|
|
17
17
|
};
|
|
18
|
-
defaultProps: {
|
|
18
|
+
var defaultProps: {
|
|
19
19
|
className: null;
|
|
20
20
|
style: {};
|
|
21
21
|
'data-testid': undefined;
|
|
22
22
|
};
|
|
23
|
-
}
|
|
23
|
+
}
|
|
24
24
|
export default ButtonGroup;
|
|
25
25
|
//# sourceMappingURL=ButtonGroup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonGroup.d.ts","sourceRoot":"","sources":["../src/ButtonGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,UAAU,gBAAgB;IACxB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,
|
|
1
|
+
{"version":3,"file":"ButtonGroup.d.ts","sourceRoot":"","sources":["../src/ButtonGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,UAAU,gBAAgB;IACxB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,iBAAS,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAazD;kBAbQ,WAAW;;;;;;;;;;;;;;AA8BpB,eAAe,WAAW,CAAC"}
|
package/dist/ButtonGroup.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
|
-
var ButtonGroup = props => {
|
|
4
|
+
function ButtonGroup(props) {
|
|
6
5
|
var {
|
|
7
6
|
children,
|
|
8
7
|
className,
|
|
@@ -15,8 +14,7 @@ var ButtonGroup = props => {
|
|
|
15
14
|
role: "group",
|
|
16
15
|
"data-testid": dataTestId
|
|
17
16
|
}, children);
|
|
18
|
-
}
|
|
19
|
-
|
|
17
|
+
}
|
|
20
18
|
ButtonGroup.displayName = 'ButtonGroup';
|
|
21
19
|
ButtonGroup.propTypes = {
|
|
22
20
|
children: PropTypes.node.isRequired,
|
package/dist/ButtonGroup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonGroup.js","names":["React","classNames","PropTypes","ButtonGroup","props","children","className","style","dataTestId","displayName","propTypes","node","isRequired","string","object","defaultProps","undefined"],"sources":["../src/ButtonGroup.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\n\ninterface ButtonGroupProps {\n children?: React.ReactNode;\n className?: string;\n style?: React.CSSProperties;\n 'data-testid'?: string;\n}\n\
|
|
1
|
+
{"version":3,"file":"ButtonGroup.js","names":["React","classNames","PropTypes","ButtonGroup","props","children","className","style","dataTestId","displayName","propTypes","node","isRequired","string","object","defaultProps","undefined"],"sources":["../src/ButtonGroup.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\n\ninterface ButtonGroupProps {\n children?: React.ReactNode;\n className?: string;\n style?: React.CSSProperties;\n 'data-testid'?: string;\n}\n\nfunction ButtonGroup(props: ButtonGroupProps): JSX.Element {\n const { children, className, style, 'data-testid': dataTestId } = props;\n\n return (\n <div\n className={classNames('btn-group', className)}\n style={style}\n role=\"group\"\n data-testid={dataTestId}\n >\n {children}\n </div>\n );\n}\n\nButtonGroup.displayName = 'ButtonGroup';\n\nButtonGroup.propTypes = {\n children: PropTypes.node.isRequired,\n className: PropTypes.string,\n style: PropTypes.object,\n 'data-testid': PropTypes.string,\n};\n\nButtonGroup.defaultProps = {\n className: null,\n style: {},\n 'data-testid': undefined,\n};\n\nexport default ButtonGroup;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,SAAS,MAAM,YAAY;AASlC,SAASC,WAAW,CAACC,KAAuB,EAAe;EACzD,IAAM;IAAEC,QAAQ;IAAEC,SAAS;IAAEC,KAAK;IAAE,aAAa,EAAEC;EAAW,CAAC,GAAGJ,KAAK;EAEvE,oBACE;IACE,SAAS,EAAEH,UAAU,CAAC,WAAW,EAAEK,SAAS,CAAE;IAC9C,KAAK,EAAEC,KAAM;IACb,IAAI,EAAC,OAAO;IACZ,eAAaC;EAAW,GAEvBH,QAAQ,CACL;AAEV;AAEAF,WAAW,CAACM,WAAW,GAAG,aAAa;AAEvCN,WAAW,CAACO,SAAS,GAAG;EACtBL,QAAQ,EAAEH,SAAS,CAACS,IAAI,CAACC,UAAU;EACnCN,SAAS,EAAEJ,SAAS,CAACW,MAAM;EAC3BN,KAAK,EAAEL,SAAS,CAACY,MAAM;EACvB,aAAa,EAAEZ,SAAS,CAACW;AAC3B,CAAC;AAEDV,WAAW,CAACY,YAAY,GAAG;EACzBT,SAAS,EAAE,IAAI;EACfC,KAAK,EAAE,CAAC,CAAC;EACT,aAAa,EAAES;AACjB,CAAC;AAED,eAAeb,WAAW"}
|
package/dist/ButtonOld.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonOld.js","names":["React","classNames","PropTypes","Button","forwardRef","props","ref","children","className","disabled","onClick","style","id","displayName","propTypes","node","string","bool","func","shape","defaultProps"],"sources":["../src/ButtonOld.tsx"],"sourcesContent":["import React, { MouseEventHandler } from 'react';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\n\ninterface ButtonProps {\n children?: React.ReactNode;\n className?: string;\n disabled?: boolean;\n onClick?: MouseEventHandler<HTMLButtonElement>;\n style?: React.CSSProperties;\n id?: string;\n}\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (props: ButtonProps, ref) => {\n const { children, className, disabled, onClick, style, id } = props;\n return (\n <button\n ref={ref}\n type=\"button\"\n className={classNames('btn', className)}\n onClick={onClick}\n style={style}\n disabled={disabled}\n id={id}\n >\n {children}\n </button>\n );\n }\n);\n\nButton.displayName = 'Button';\n\nButton.propTypes = {\n children: PropTypes.node,\n className: PropTypes.string,\n disabled: PropTypes.bool,\n onClick: PropTypes.func,\n style: PropTypes.shape({}),\n id: PropTypes.string,\n};\n\nButton.defaultProps = {\n children: null,\n className: '',\n disabled: false,\n onClick: () => null,\n style: {},\n id: '',\n};\n\nexport default Button;\n"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"file":"ButtonOld.js","names":["React","classNames","PropTypes","Button","forwardRef","props","ref","children","className","disabled","onClick","style","id","displayName","propTypes","node","string","bool","func","shape","defaultProps"],"sources":["../src/ButtonOld.tsx"],"sourcesContent":["import React, { MouseEventHandler } from 'react';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\n\ninterface ButtonProps {\n children?: React.ReactNode;\n className?: string;\n disabled?: boolean;\n onClick?: MouseEventHandler<HTMLButtonElement>;\n style?: React.CSSProperties;\n id?: string;\n}\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (props: ButtonProps, ref) => {\n const { children, className, disabled, onClick, style, id } = props;\n return (\n <button\n ref={ref}\n type=\"button\"\n className={classNames('btn', className)}\n onClick={onClick}\n style={style}\n disabled={disabled}\n id={id}\n >\n {children}\n </button>\n );\n }\n);\n\nButton.displayName = 'Button';\n\nButton.propTypes = {\n children: PropTypes.node,\n className: PropTypes.string,\n disabled: PropTypes.bool,\n onClick: PropTypes.func,\n style: PropTypes.shape({}),\n id: PropTypes.string,\n};\n\nButton.defaultProps = {\n children: null,\n className: '',\n disabled: false,\n onClick: () => null,\n style: {},\n id: '',\n};\n\nexport default Button;\n"],"mappings":"AAAA,OAAOA,KAAK,MAA6B,OAAO;AAChD,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,SAAS,MAAM,YAAY;AAUlC,IAAMC,MAAM,gBAAGH,KAAK,CAACI,UAAU,CAC7B,CAACC,KAAkB,EAAEC,GAAG,KAAK;EAC3B,IAAM;IAAEC,QAAQ;IAAEC,SAAS;IAAEC,QAAQ;IAAEC,OAAO;IAAEC,KAAK;IAAEC;EAAG,CAAC,GAAGP,KAAK;EACnE,oBACE;IACE,GAAG,EAAEC,GAAI;IACT,IAAI,EAAC,QAAQ;IACb,SAAS,EAAEL,UAAU,CAAC,KAAK,EAAEO,SAAS,CAAE;IACxC,OAAO,EAAEE,OAAQ;IACjB,KAAK,EAAEC,KAAM;IACb,QAAQ,EAAEF,QAAS;IACnB,EAAE,EAAEG;EAAG,GAENL,QAAQ,CACF;AAEb,CAAC,CACF;AAEDJ,MAAM,CAACU,WAAW,GAAG,QAAQ;AAE7BV,MAAM,CAACW,SAAS,GAAG;EACjBP,QAAQ,EAAEL,SAAS,CAACa,IAAI;EACxBP,SAAS,EAAEN,SAAS,CAACc,MAAM;EAC3BP,QAAQ,EAAEP,SAAS,CAACe,IAAI;EACxBP,OAAO,EAAER,SAAS,CAACgB,IAAI;EACvBP,KAAK,EAAET,SAAS,CAACiB,KAAK,CAAC,CAAC,CAAC,CAAC;EAC1BP,EAAE,EAAEV,SAAS,CAACc;AAChB,CAAC;AAEDb,MAAM,CAACiB,YAAY,GAAG;EACpBb,QAAQ,EAAE,IAAI;EACdC,SAAS,EAAE,EAAE;EACbC,QAAQ,EAAE,KAAK;EACfC,OAAO,EAAE,MAAM,IAAI;EACnBC,KAAK,EAAE,CAAC,CAAC;EACTC,EAAE,EAAE;AACN,CAAC;AAED,eAAeT,MAAM"}
|