@neo4j-ndl/react 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/{input/Input.js → _common/input/RadioAndCheckboxWrapper.js} +6 -6
- package/lib/cjs/_common/input/RadioAndCheckboxWrapper.js.map +1 -0
- package/lib/cjs/_common/input/types.js +3 -0
- package/lib/cjs/_common/input/types.js.map +1 -0
- package/lib/cjs/_common/utils.js +59 -0
- package/lib/cjs/_common/utils.js.map +1 -0
- package/lib/cjs/button/Button.js +18 -13
- package/lib/cjs/button/Button.js.map +1 -1
- package/lib/cjs/button/IconButton.js +85 -0
- package/lib/cjs/button/IconButton.js.map +1 -0
- package/lib/cjs/button/IconButtonArray.js +52 -0
- package/lib/cjs/button/IconButtonArray.js.map +1 -0
- package/lib/cjs/button/index.js +2 -0
- package/lib/cjs/button/index.js.map +1 -1
- package/lib/cjs/checkbox/Checkbox.js +2 -2
- package/lib/cjs/checkbox/Checkbox.js.map +1 -1
- package/lib/cjs/context-menu/ContextMenu.js +7 -13
- package/lib/cjs/context-menu/ContextMenu.js.map +1 -1
- package/lib/cjs/dialog/Dialog.js +161 -0
- package/lib/cjs/dialog/Dialog.js.map +1 -0
- package/lib/cjs/dialog/index.js +38 -0
- package/lib/cjs/dialog/index.js.map +1 -0
- package/lib/cjs/index.js +3 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/label/Label.js +3 -1
- package/lib/cjs/label/Label.js.map +1 -1
- package/lib/cjs/modal/Modal.js +105 -0
- package/lib/cjs/modal/Modal.js.map +1 -0
- package/lib/cjs/modal/index.js +38 -0
- package/lib/cjs/modal/index.js.map +1 -0
- package/lib/cjs/popover/Popover.js +11 -47
- package/lib/cjs/popover/Popover.js.map +1 -1
- package/lib/cjs/portal/Portal.js +52 -0
- package/lib/cjs/portal/Portal.js.map +1 -0
- package/lib/cjs/portal/index.js +38 -0
- package/lib/cjs/portal/index.js.map +1 -0
- package/lib/cjs/radio/Radio.js +2 -2
- package/lib/cjs/radio/Radio.js.map +1 -1
- package/lib/cjs/switch/Switch.js +2 -2
- package/lib/cjs/switch/Switch.js.map +1 -1
- package/lib/cjs/table/Table.js +5 -5
- package/lib/cjs/table/Table.js.map +1 -1
- package/lib/cjs/tabs/Tabs.js +4 -3
- package/lib/cjs/tabs/Tabs.js.map +1 -1
- package/lib/cjs/text-input/TextInput.js +72 -0
- package/lib/cjs/text-input/TextInput.js.map +1 -0
- package/lib/cjs/{input → text-input}/index.js +3 -3
- package/lib/cjs/text-input/index.js.map +1 -0
- package/lib/cjs/trap-focus/TrapFocus.js +310 -0
- package/lib/cjs/trap-focus/TrapFocus.js.map +1 -0
- package/lib/cjs/trap-focus/index.js +38 -0
- package/lib/cjs/trap-focus/index.js.map +1 -0
- package/lib/esm/{input/Input.js → _common/input/RadioAndCheckboxWrapper.js} +6 -6
- package/lib/esm/_common/input/RadioAndCheckboxWrapper.js.map +1 -0
- package/lib/esm/_common/input/types.js +2 -0
- package/lib/esm/_common/input/types.js.map +1 -0
- package/lib/esm/_common/utils.js +52 -0
- package/lib/esm/_common/utils.js.map +1 -0
- package/lib/esm/button/Button.js +16 -9
- package/lib/esm/button/Button.js.map +1 -1
- package/lib/esm/button/IconButton.js +79 -0
- package/lib/esm/button/IconButton.js.map +1 -0
- package/lib/esm/button/IconButtonArray.js +46 -0
- package/lib/esm/button/IconButtonArray.js.map +1 -0
- package/lib/esm/button/index.js +2 -0
- package/lib/esm/button/index.js.map +1 -1
- package/lib/esm/checkbox/Checkbox.js +2 -2
- package/lib/esm/checkbox/Checkbox.js.map +1 -1
- package/lib/esm/context-menu/ContextMenu.js +7 -13
- package/lib/esm/context-menu/ContextMenu.js.map +1 -1
- package/lib/esm/dialog/Dialog.js +131 -0
- package/lib/esm/dialog/Dialog.js.map +1 -0
- package/lib/esm/{input → dialog}/index.js +1 -1
- package/lib/esm/dialog/index.js.map +1 -0
- package/lib/esm/index.js +3 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/label/Label.js +3 -1
- package/lib/esm/label/Label.js.map +1 -1
- package/lib/esm/modal/Modal.js +75 -0
- package/lib/esm/modal/Modal.js.map +1 -0
- package/lib/esm/modal/index.js +22 -0
- package/lib/esm/modal/index.js.map +1 -0
- package/lib/esm/popover/Popover.js +11 -24
- package/lib/esm/popover/Popover.js.map +1 -1
- package/lib/esm/portal/Portal.js +25 -0
- package/lib/esm/portal/Portal.js.map +1 -0
- package/lib/esm/portal/index.js +22 -0
- package/lib/esm/portal/index.js.map +1 -0
- package/lib/esm/radio/Radio.js +2 -2
- package/lib/esm/radio/Radio.js.map +1 -1
- package/lib/esm/switch/Switch.js +2 -2
- package/lib/esm/switch/Switch.js.map +1 -1
- package/lib/esm/table/Table.js +5 -5
- package/lib/esm/table/Table.js.map +1 -1
- package/lib/esm/tabs/Tabs.js +4 -3
- package/lib/esm/tabs/Tabs.js.map +1 -1
- package/lib/esm/text-input/TextInput.js +67 -0
- package/lib/esm/text-input/TextInput.js.map +1 -0
- package/lib/esm/text-input/index.js +22 -0
- package/lib/esm/text-input/index.js.map +1 -0
- package/lib/esm/trap-focus/TrapFocus.js +283 -0
- package/lib/esm/trap-focus/TrapFocus.js.map +1 -0
- package/lib/esm/trap-focus/index.js +22 -0
- package/lib/esm/trap-focus/index.js.map +1 -0
- package/lib/types/_common/input/RadioAndCheckboxWrapper.d.ts +37 -0
- package/lib/types/_common/input/types.d.ts +31 -0
- package/lib/types/_common/utils.d.ts +29 -0
- package/lib/types/alert/Alert.d.ts +1 -1
- package/lib/types/button/Button.d.ts +3 -4
- package/lib/types/button/IconButton.d.ts +47 -0
- package/lib/types/button/IconButtonArray.d.ts +37 -0
- package/lib/types/button/index.d.ts +2 -0
- package/lib/types/checkbox/Checkbox.d.ts +2 -2
- package/lib/types/context-menu/ContextMenu.d.ts +4 -1
- package/lib/types/dialog/Dialog.d.ts +55 -0
- package/lib/types/{input → dialog}/index.d.ts +1 -1
- package/lib/types/index.d.ts +3 -0
- package/lib/types/modal/Modal.d.ts +34 -0
- package/lib/types/modal/index.d.ts +21 -0
- package/lib/types/popover/Popover.d.ts +4 -2
- package/lib/types/portal/Portal.d.ts +27 -0
- package/lib/types/portal/index.d.ts +21 -0
- package/lib/types/radio/Radio.d.ts +2 -2
- package/lib/types/switch/Switch.d.ts +2 -2
- package/lib/types/table/Table.d.ts +1 -8
- package/lib/types/tabs/Tabs.d.ts +3 -4
- package/lib/types/text-input/TextInput.d.ts +55 -0
- package/lib/types/text-input/index.d.ts +21 -0
- package/lib/types/trap-focus/TrapFocus.d.ts +35 -0
- package/lib/types/trap-focus/index.d.ts +21 -0
- package/package.json +3 -4
- package/lib/cjs/input/Input.js.map +0 -1
- package/lib/cjs/input/index.js.map +0 -1
- package/lib/esm/input/Input.js.map +0 -1
- package/lib/esm/input/index.js.map +0 -1
- package/lib/types/input/Input.d.ts +0 -44
|
@@ -45,16 +45,16 @@ const classnames_1 = __importDefault(require("classnames"));
|
|
|
45
45
|
*
|
|
46
46
|
*
|
|
47
47
|
*/
|
|
48
|
-
const
|
|
49
|
-
const { label, fluid, labelBefore } = props, otherInputProps = __rest(props, ["label", "fluid", "labelBefore"]);
|
|
50
|
-
const containerWrappingClass = (0, classnames_1.default)(
|
|
48
|
+
const RadioAndCheckboxWrapper = (props, ref) => {
|
|
49
|
+
const { label, fluid, labelBefore, type = 'text' } = props, otherInputProps = __rest(props, ["label", "fluid", "labelBefore", "type"]);
|
|
50
|
+
const containerWrappingClass = (0, classnames_1.default)(`ndl-form-item ndl-type-${type}`, {
|
|
51
51
|
disabled: otherInputProps.disabled,
|
|
52
52
|
});
|
|
53
53
|
const labelWrappingClass = (0, classnames_1.default)(`form-item-label`, {
|
|
54
54
|
fluid,
|
|
55
55
|
'label-before': labelBefore,
|
|
56
56
|
});
|
|
57
|
-
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: containerWrappingClass }, { children: (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: labelWrappingClass }, { children: [(0, jsx_runtime_1.jsx)("input", Object.assign({}, otherInputProps, { ref: ref })), label] })) })));
|
|
57
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: containerWrappingClass }, { children: (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: labelWrappingClass }, { children: [(0, jsx_runtime_1.jsx)("input", Object.assign({}, otherInputProps, { ref: ref, type: type })), (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "form-label-text" }, { children: label }))] })) })));
|
|
58
58
|
};
|
|
59
|
-
exports.default = (0, react_1.forwardRef)(
|
|
60
|
-
//# sourceMappingURL=
|
|
59
|
+
exports.default = (0, react_1.forwardRef)(RadioAndCheckboxWrapper);
|
|
60
|
+
//# sourceMappingURL=RadioAndCheckboxWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioAndCheckboxWrapper.js","sourceRoot":"","sources":["../../../../src/_common/input/RadioAndCheckboxWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,iCAAiD;AACjD,4DAAoC;AAmBpC,qCAAqC;AAErC;;;;;;GAMG;AAEH,MAAM,uBAAuB,GAAG,CAC9B,KAA4B,EAC5B,GAAmC,EACnC,EAAE;IACF,MAAM,EACJ,KAAK,EACL,KAAK,EACL,WAAW,EACX,IAAI,GAAG,MAAM,KAEX,KAAK,EADJ,eAAe,UAChB,KAAK,EANH,yCAML,CAAQ,CAAC;IAEV,MAAM,sBAAsB,GAAG,IAAA,oBAAU,EAAC,0BAA0B,IAAI,EAAE,EAAE;QAC1E,QAAQ,EAAE,eAAe,CAAC,QAAQ;KACnC,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,IAAA,oBAAU,EAAC,iBAAiB,EAAE;QACvD,KAAK;QACL,cAAc,EAAE,WAAW;KAC5B,CAAC,CAAC;IAEH,OAAO,CACL,8CAAK,SAAS,EAAE,sBAAsB,gBAGpC,iDAAO,SAAS,EAAE,kBAAkB,iBAClC,kDAAW,eAAe,IAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,IAAI,EACpD,+CAAM,SAAS,EAAC,iBAAiB,gBAAE,KAAK,IAAQ,KAC1C,IACJ,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,IAAA,kBAAU,EAAC,uBAAuB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/_common/input/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.useDocumentScrollToggle = exports.needleWarningMessage = exports.removeSpaces = exports.removeNewlines = void 0;
|
|
24
|
+
const react_1 = require("react");
|
|
25
|
+
const removeNewlines = (input) => input.replace(/(\r\n|\n|\r)/gm, '');
|
|
26
|
+
exports.removeNewlines = removeNewlines;
|
|
27
|
+
/** Remove extra spaces from sting */
|
|
28
|
+
const removeSpaces = (input) => input.replace(/\s+/g, ' ').trim();
|
|
29
|
+
exports.removeSpaces = removeSpaces;
|
|
30
|
+
const needleWarningMessage = (message) => console.warn(`[🪡 Needle]: ${message}`);
|
|
31
|
+
exports.needleWarningMessage = needleWarningMessage;
|
|
32
|
+
const getScrollbarSize = (doc) => {
|
|
33
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
|
|
34
|
+
const documentWidth = doc.documentElement.clientWidth;
|
|
35
|
+
return Math.abs(window.innerWidth - documentWidth);
|
|
36
|
+
};
|
|
37
|
+
const getPaddingRight = (element) => parseInt(window.getComputedStyle(element).paddingRight, 10) || 0;
|
|
38
|
+
/**
|
|
39
|
+
* Toggles scroll on the provided document.
|
|
40
|
+
* Useful for disabling scroll when a popup is open (ie ContextMenu/Modal)
|
|
41
|
+
*/
|
|
42
|
+
const useDocumentScrollToggle = () => {
|
|
43
|
+
const bodyPadding = (0, react_1.useRef)(0);
|
|
44
|
+
return (0, react_1.useCallback)((disable, doc = document) => {
|
|
45
|
+
if (disable) {
|
|
46
|
+
const existingPaddingRight = getPaddingRight(doc.body);
|
|
47
|
+
bodyPadding.current = existingPaddingRight;
|
|
48
|
+
const newPaddingRight = existingPaddingRight + getScrollbarSize(doc);
|
|
49
|
+
doc.body.style.overflow = 'hidden';
|
|
50
|
+
doc.body.style.paddingRight = `${newPaddingRight}px`;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
doc.body.style.overflow = '';
|
|
54
|
+
doc.body.style.paddingRight = `${bodyPadding.current}px`;
|
|
55
|
+
}
|
|
56
|
+
}, []);
|
|
57
|
+
};
|
|
58
|
+
exports.useDocumentScrollToggle = useDocumentScrollToggle;
|
|
59
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/_common/utils.ts"],"names":[],"mappings":";AAAA;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GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;YACrE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;YACnC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,GAAG,eAAe,IAAI,CAAC;SACtD;aAAM;YACL,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC;YAC7B,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,GAAG,WAAW,CAAC,OAAO,IAAI,CAAC;SAC1D;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC;AAfW,QAAA,uBAAuB,2BAelC"}
|
package/lib/cjs/button/Button.js
CHANGED
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Button =
|
|
17
|
+
exports.Button = void 0;
|
|
18
18
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
19
|
/**
|
|
20
20
|
*
|
|
@@ -39,13 +39,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
39
39
|
const react_1 = __importDefault(require("react"));
|
|
40
40
|
const classnames_1 = __importDefault(require("classnames"));
|
|
41
41
|
const loading_spinner_1 = require("../loading-spinner");
|
|
42
|
-
const
|
|
43
|
-
exports.removeNewlines = removeNewlines;
|
|
44
|
-
/** Remove extra spaces from sting */
|
|
45
|
-
const removeSpaces = (input) => input.replace(/\s+/g, ' ').trim();
|
|
46
|
-
exports.removeSpaces = removeSpaces;
|
|
42
|
+
const utils_1 = require("../_common/utils");
|
|
47
43
|
exports.Button = react_1.default.forwardRef(function Button(_a, ref) {
|
|
48
|
-
var { children, as, type = 'button', loading = false, color = 'primary', disabled = false, fill = 'filled', rectangle = false, buttonSize = '
|
|
44
|
+
var { children, as, type = 'button', loading = false, color = 'primary', disabled = false, fill = 'filled', rectangle = false, buttonSize = 'medium', className, onClick, floating = false, tabIndex = 0 } = _a, props = __rest(_a, ["children", "as", "type", "loading", "color", "disabled", "fill", "rectangle", "buttonSize", "className", "onClick", "floating", "tabIndex"]);
|
|
49
45
|
let Component = as || 'button';
|
|
50
46
|
if (!as && props.href) {
|
|
51
47
|
Component = 'a';
|
|
@@ -55,6 +51,7 @@ exports.Button = react_1.default.forwardRef(function Button(_a, ref) {
|
|
|
55
51
|
disabled: disabled,
|
|
56
52
|
loading: loading,
|
|
57
53
|
rectangle: rectangle,
|
|
54
|
+
'floating-btn': floating,
|
|
58
55
|
/** Now check button is outlined or filled */
|
|
59
56
|
/**
|
|
60
57
|
* Notice:
|
|
@@ -65,11 +62,15 @@ exports.Button = react_1.default.forwardRef(function Button(_a, ref) {
|
|
|
65
62
|
${color === 'neutral'
|
|
66
63
|
? `n-bg-light-${color}-bg-strongest`
|
|
67
64
|
: `n-bg-light-${color}-bg-strong`}
|
|
68
|
-
${interactable &&
|
|
65
|
+
${interactable &&
|
|
66
|
+
`hover:n-bg-light-${color}-hover-strong
|
|
67
|
+
active:n-bg-light-${color}-pressed-strong`}
|
|
69
68
|
`]: fill === 'filled',
|
|
70
69
|
[`
|
|
71
70
|
n-text-light-${color}-text
|
|
72
|
-
${interactable &&
|
|
71
|
+
${interactable &&
|
|
72
|
+
`hover:n-bg-light-${color}-hover-weak
|
|
73
|
+
active:n-bg-light-${color}-pressed-weak`}
|
|
73
74
|
n-border-light-${color}-bg-strong
|
|
74
75
|
`]: fill === 'outlined' && color !== 'neutral',
|
|
75
76
|
/**
|
|
@@ -77,21 +78,25 @@ exports.Button = react_1.default.forwardRef(function Button(_a, ref) {
|
|
|
77
78
|
* the same principles with colored variations
|
|
78
79
|
*/
|
|
79
80
|
[`
|
|
80
|
-
|
|
81
|
+
n-text-light-neutral-text-weak
|
|
81
82
|
n-bg-${color}-10
|
|
82
83
|
${interactable && `hover:n-bg-${color}-20`}
|
|
83
|
-
n-border
|
|
84
|
+
n-border-light-neutral-border-strong
|
|
85
|
+
active:n-bg-light-neutral-pressed
|
|
84
86
|
`]: fill === 'outlined' && color === 'neutral',
|
|
85
87
|
[`
|
|
86
88
|
n-text-${color}-50
|
|
87
|
-
${interactable &&
|
|
89
|
+
${interactable &&
|
|
90
|
+
`hover:n-bg-${color}-10
|
|
91
|
+
active:n-bg-light-${color}-pressed-weak
|
|
92
|
+
`}
|
|
88
93
|
`]: fill === 'text' && color !== 'neutral',
|
|
89
94
|
[`
|
|
90
95
|
n-text-light-neutral-text-weak
|
|
91
96
|
${interactable && `hover:n-bg-light-neutral-bg-default`}
|
|
92
97
|
`]: fill === 'text' && color == 'neutral',
|
|
93
98
|
});
|
|
94
|
-
const sanitisedClasses = (0,
|
|
99
|
+
const sanitisedClasses = (0, utils_1.removeSpaces)((0, utils_1.removeNewlines)(classes));
|
|
95
100
|
const handleClick = (e) => {
|
|
96
101
|
if (!interactable) {
|
|
97
102
|
// By default, a <button /> element with disabled set to true will not get its
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/button/Button.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,kDAA0B;AAC1B,4DAAoC;AAEpC,wDAAoD;
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/button/Button.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,kDAA0B;AAC1B,4DAAoC;AAEpC,wDAAoD;AAEpD,4CAAgE;AAgCnD,QAAA,MAAM,GAAG,eAAK,CAAC,UAAU,CAAC,SAAS,MAAM,CACpD,EAec,EACd,GAAG;QAhBH,EACE,QAAQ,EACR,EAAE,EACF,IAAI,GAAG,QAAQ,EACf,OAAO,GAAG,KAAK,EACf,K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C"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.IconButton = void 0;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) "Neo4j"
|
|
22
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
23
|
+
*
|
|
24
|
+
* This file is part of Neo4j.
|
|
25
|
+
*
|
|
26
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
27
|
+
* it under the terms of the GNU General Public License as published by
|
|
28
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
29
|
+
* (at your option) any later version.
|
|
30
|
+
*
|
|
31
|
+
* This program is distributed in the hope that it will be useful,
|
|
32
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
33
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
34
|
+
* GNU General Public License for more details.
|
|
35
|
+
*
|
|
36
|
+
* You should have received a copy of the GNU General Public License
|
|
37
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
38
|
+
*/
|
|
39
|
+
const react_1 = __importDefault(require("react"));
|
|
40
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
41
|
+
const loading_spinner_1 = require("../loading-spinner");
|
|
42
|
+
const utils_1 = require("../_common/utils");
|
|
43
|
+
exports.IconButton = react_1.default.forwardRef(function Button(_a, ref) {
|
|
44
|
+
var { children, as, type = 'button', loading = false, disabled = false, buttonSize = 'medium', className, onClick, grouped, floating = false, danger, clean } = _a, props = __rest(_a, ["children", "as", "type", "loading", "disabled", "buttonSize", "className", "onClick", "grouped", "floating", "danger", "clean"]);
|
|
45
|
+
let Component = as || 'button';
|
|
46
|
+
if (!as && props.href) {
|
|
47
|
+
Component = 'a';
|
|
48
|
+
}
|
|
49
|
+
const interactable = !disabled && !loading;
|
|
50
|
+
const classes = (0, classnames_1.default)(`ndl-icon-btn ${buttonSize} ${className}`, {
|
|
51
|
+
grouped,
|
|
52
|
+
disabled,
|
|
53
|
+
loading,
|
|
54
|
+
floating,
|
|
55
|
+
danger,
|
|
56
|
+
clean,
|
|
57
|
+
});
|
|
58
|
+
if (clean && floating) {
|
|
59
|
+
(0, utils_1.needleWarningMessage)("Can't have 'clean' and 'floating' props true at the same time");
|
|
60
|
+
}
|
|
61
|
+
if (!props['aria-label']) {
|
|
62
|
+
(0, utils_1.needleWarningMessage)('Icon buttons do not have text, be sure to include an aria-label for screen readers link: https://dequeuniversity.com/rules/axe/4.4/button-name?application=axeAPI');
|
|
63
|
+
}
|
|
64
|
+
const handleClick = (e) => {
|
|
65
|
+
if (!interactable) {
|
|
66
|
+
// By default, a <button /> element with disabled set to true will not get its
|
|
67
|
+
// on click handler called. To support the same behavior on <a /> tags we
|
|
68
|
+
// swallow the event here when disabled, since the <a /> tag with disabled set to
|
|
69
|
+
// true will have its onClick handler called
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
e.stopPropagation();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (onClick) {
|
|
75
|
+
onClick(e);
|
|
76
|
+
}
|
|
77
|
+
else if (!props.href) {
|
|
78
|
+
console.error('onClick was not provided');
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
return ((0, jsx_runtime_1.jsx)(Component
|
|
82
|
+
/** First props and then className to avoid overriding in classNames */
|
|
83
|
+
, Object.assign({}, props, (Component === 'button' ? { type } : {}), { onClick: handleClick, disabled: !interactable, className: classes, ref: ref }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "ndl-icon" }, { children: loading ? ((0, jsx_runtime_1.jsx)(loading_spinner_1.LoadingSpinner, { className: "n-my-auto n-mr-1", size: "small" })) : (children) })) })));
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=IconButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconButton.js","sourceRoot":"","sources":["../../../src/button/IconButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,kDAA0B;AAC1B,4DAAoC;AACpC,wDAAoD;AAEpD,4CAAwD;AAmC3C,QAAA,UAAU,GAAG,eAAK,CAAC,UAAU,CAAC,SAAS,MAAM,CACxD,EAckB,EAClB,GAAG;QAfH,EACE,QAAQ,EACR,EAAE,EACF,IAAI,GAAG,QAAQ,EACf,OAAO,GAAG,KAAK,EACf,QAAQ,GAAG,KAAK,EAChB,UAAU,GAAG,QAAQ,EACrB,SAAS,EACT,OAAO,EACP,OAAO,EACP,QAAQ,GAAG,KAAK,EAChB,MAAM,EACN,KAAK,OAEW,EADb,KAAK,cAbV,iIAcC,CADS;IAIV,IAAI,SAAS,GAAG,EAAE,IAAI,QAAQ,CAAC;IAE/B,IAAI,CAAC,EAAE,IAAI,KAAK,CAAC,IAAI,EAAE;QACrB,SAAS,GAAG,GAAG,CAAC;KACjB;IAED,MAAM,YAAY,GAAG,CAAC,QAAQ,IAAI,CAAC,OAAO,CAAC;IAE3C,MAAM,OAAO,GAAG,IAAA,o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+1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.IconButtonArray = void 0;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) "Neo4j"
|
|
22
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
23
|
+
*
|
|
24
|
+
* This file is part of Neo4j.
|
|
25
|
+
*
|
|
26
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
27
|
+
* it under the terms of the GNU General Public License as published by
|
|
28
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
29
|
+
* (at your option) any later version.
|
|
30
|
+
*
|
|
31
|
+
* This program is distributed in the hope that it will be useful,
|
|
32
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
33
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
34
|
+
* GNU General Public License for more details.
|
|
35
|
+
*
|
|
36
|
+
* You should have received a copy of the GNU General Public License
|
|
37
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
38
|
+
*/
|
|
39
|
+
const react_1 = __importDefault(require("react"));
|
|
40
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
41
|
+
exports.IconButtonArray = react_1.default.forwardRef(function Button(_a, ref) {
|
|
42
|
+
var { children, as, className, floating = false, orientation = 'horizontal' } = _a, props = __rest(_a, ["children", "as", "className", "floating", "orientation"]);
|
|
43
|
+
const Component = as || 'div';
|
|
44
|
+
const classes = (0, classnames_1.default)(`ndl-icon-btn-array`, {
|
|
45
|
+
'n-flex-row': orientation === 'horizontal',
|
|
46
|
+
'n-flex-col': orientation === 'vertical',
|
|
47
|
+
'array-floating': floating,
|
|
48
|
+
[`${className}`]: className,
|
|
49
|
+
});
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)(Component, Object.assign({}, props, { className: classes, ref: ref }, { children: children })));
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=IconButtonArray.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconButtonArray.js","sourceRoot":"","sources":["../../../src/button/IconButtonArray.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,kDAA0B;AAC1B,4DAAoC;AAqBvB,QAAA,eAAe,GAAG,eAAK,CAAC,UAAU,CAAC,SAAS,MAAM,CAC7D,EAOuB,EACvB,GAAG;QARH,EACE,QAAQ,EACR,EAAE,EACF,SAAS,EACT,QAAQ,GAAG,KAAK,EAChB,WAAW,GAAG,YAAY,OAEL,EADlB,KAAK,cANV,0DAOC,CADS;IAIV,MAAM,SAAS,GAAG,EAAE,IAAI,KAAK,CAAC;IAE9B,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,oBAAoB,EAAE;QAC/C,YAAY,EAAE,WAAW,KAAK,YAAY;QAC1C,YAAY,EAAE,WAAW,KAAK,UAAU;QACxC,gBAAgB,EAAE,QAAQ;QAC1B,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,SAAS;KAC5B,CAAC,CAAC;IAEH,OAAO,CACL,uBAAC,SAAS,oBAAK,KAAK,IAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,gBAC/C,QAAQ,IACC,CACb,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/lib/cjs/button/index.js
CHANGED
|
@@ -35,4 +35,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
35
35
|
};
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
__exportStar(require("./Button"), exports);
|
|
38
|
+
__exportStar(require("./IconButton"), exports);
|
|
39
|
+
__exportStar(require("./IconButtonArray"), exports);
|
|
38
40
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/button/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AAEH,2CAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/button/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,+CAA6B;AAC7B,oDAAkC"}
|
|
@@ -25,7 +25,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
25
25
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
26
26
|
*/
|
|
27
27
|
const react_1 = __importDefault(require("react"));
|
|
28
|
-
const
|
|
28
|
+
const RadioAndCheckboxWrapper_1 = __importDefault(require("../_common/input/RadioAndCheckboxWrapper"));
|
|
29
29
|
/**
|
|
30
30
|
*
|
|
31
31
|
*
|
|
@@ -45,7 +45,7 @@ const Checkbox = react_1.default.forwardRef((props, ref) => {
|
|
|
45
45
|
if (!props['aria-label'] && !props.label) {
|
|
46
46
|
console.warn('To be accesible the input component requires either `aria-label` or `label` prop: https://dequeuniversity.com/rules/axe/4.2/label?application=axeAPI');
|
|
47
47
|
}
|
|
48
|
-
return (0, jsx_runtime_1.jsx)(
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(RadioAndCheckboxWrapper_1.default, Object.assign({}, props, { ref: ref, type: "checkbox", role: "checkbox" })));
|
|
49
49
|
});
|
|
50
50
|
Checkbox.displayName = 'Checkbox';
|
|
51
51
|
exports.default = Checkbox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/checkbox/Checkbox.tsx"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,kDAA0B;AAC1B,
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/checkbox/Checkbox.tsx"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,kDAA0B;AAC1B,uGAEkD;AAElD;;;;;;GAMG;AAEH,qCAAqC;AAErC;;;;;;GAMG;AAEH,MAAM,QAAQ,GAAG,eAAK,CAAC,UAAU,CAC/B,CAAC,KAA4B,EAAE,GAAyC,EAAE,EAAE;IAC1E,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;QACxC,OAAO,CAAC,IAAI,CACV,sJAAsJ,CACvJ,CAAC;KACH;IAED,OAAO,CACL,uBAAC,iCAAuB,oBAClB,KAAK,IACT,GAAG,EAAE,GAAG,EACR,IAAI,EAAC,UAAU,EACf,IAAI,EAAC,UAAU,IACf,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC;AAElC,kBAAe,QAAQ,CAAC"}
|
|
@@ -74,15 +74,15 @@ const useMenuContext = () => {
|
|
|
74
74
|
exports.Menu = (0, react_1.forwardRef)(function Menu(_a, ref) {
|
|
75
75
|
var { menuSize = 'small', className, minWidth = 250, open, onClose, children } = _a, rest = __rest(_a, ["menuSize", "className", "minWidth", "open", "onClose", "children"]);
|
|
76
76
|
const menuRef = (0, react_1.useRef)();
|
|
77
|
-
const
|
|
77
|
+
const focusMenuItems = (0, react_1.useCallback)(() => {
|
|
78
78
|
const menu = menuRef.current;
|
|
79
79
|
if (!menu)
|
|
80
80
|
return;
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
81
|
+
const menuItems = menu.querySelectorAll(':scope > .menu-items');
|
|
82
|
+
if (menuItems.length === 0) {
|
|
83
83
|
menu.focus();
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
menuItems[0].focus();
|
|
86
86
|
}, []);
|
|
87
87
|
// Override ref to map to internal ref
|
|
88
88
|
// as well as change focus to focus the
|
|
@@ -92,19 +92,13 @@ exports.Menu = (0, react_1.forwardRef)(function Menu(_a, ref) {
|
|
|
92
92
|
if (!menu) {
|
|
93
93
|
return null;
|
|
94
94
|
}
|
|
95
|
-
return Object.assign(Object.assign({}, menu), { focus:
|
|
95
|
+
return Object.assign(Object.assign({}, menu), { focus: focusMenuItems });
|
|
96
96
|
});
|
|
97
|
-
// Focus first menu item on open.
|
|
98
|
-
// This effect is separate from the above
|
|
99
|
-
// `setPositiongStyles` effect as the above
|
|
100
|
-
// is triggered on every render usually as
|
|
101
|
-
// anchorOrigin and transformOrigin
|
|
102
|
-
// are typically not memoized
|
|
103
97
|
(0, react_1.useEffect)(() => {
|
|
104
98
|
if (open) {
|
|
105
|
-
|
|
99
|
+
focusMenuItems();
|
|
106
100
|
}
|
|
107
|
-
}, [open,
|
|
101
|
+
}, [open, focusMenuItems]);
|
|
108
102
|
const classes = (0, classnames_1.default)('ndl-menu', menuSize, className);
|
|
109
103
|
return ((0, jsx_runtime_1.jsx)(MenuContext.Provider, Object.assign({ value: { onClose } }, { children: (0, jsx_runtime_1.jsx)(popover_1.Popover, Object.assign({ tabIndex: -1 }, rest, { open: open, style: Object.assign({ minWidth }, (rest.style || {})), className: classes, ref: menuRef, onClose: onClose }, { children: children })) })));
|
|
110
104
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.js","sourceRoot":"","sources":["../../../src/context-menu/ContextMenu.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,+CAOe;AACf,oCAAoC;AACpC,wCAAmD;AACnD,4DAAoC;
|
|
1
|
+
{"version":3,"file":"ContextMenu.js","sourceRoot":"","sources":["../../../src/context-menu/ContextMenu.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,+CAOe;AACf,oCAAoC;AACpC,wCAAmD;AACnD,4DAAoC;AAoBpC,MAAM,WAAW,GAAG,eAAK,CAAC,aAAa,CAAyB,IAAI,CAAC,CAAC;AAEtE,MAAM,cAAc,GAAG,GAAG,EAAE;IAC1B,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,WAAW,CAAC,CAAC;IACxC,IAAI,OAAO,KAAK,IAAI,EAAE;QACpB,MAAM,IAAI,KAAK,CACb,6EAA6E,CAC9E,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAQW,QAAA,IAAI,GAAG,IAAA,kBAAU,EAAC,SAAS,IAAI,CAC1C,EAQmB,EACnB,GAAG;QATH,EACE,QAAQ,GAAG,OAAO,EAClB,SAAS,EACT,QAAQ,GAAG,GAAG,EACd,IAAI,EACJ,OAAO,EACP,QAAQ,OAES,EADd,IAAI,cAPT,oEAQC,CADQ;IAIT,MAAM,OAAO,GAAG,IAAA,cAAM,GAAe,CAAC;IAEtC,MAAM,cAAc,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QACtC,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,IAAI;YAAE,OAAO;QAElB,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAg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EAAC,mBAAmB,gBAAE,KAAK,IAAO,EAChD,8CACE,QAAQ,EAAE,CAAC,EACX,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,WAAW,EACtB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAC,kBAAkB,gBAE5B,uBAAC,gBAAQ,IAAC,QAAQ,EAAC,OAAO,GAAG,IACzB,KACF,EACL,WAAW,IAAI,CACd,8CAAK,SAAS,EAAC,yBAAyB,gBAAE,WAAW,IAAO,CAC7D,KACS,CACb,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.Dialog = exports.DialogCloseReason = void 0;
|
|
41
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* Copyright (c) "Neo4j"
|
|
45
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
46
|
+
*
|
|
47
|
+
* This file is part of Neo4j.
|
|
48
|
+
*
|
|
49
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
50
|
+
* it under the terms of the GNU General Public License as published by
|
|
51
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
52
|
+
* (at your option) any later version.
|
|
53
|
+
*
|
|
54
|
+
* This program is distributed in the hope that it will be useful,
|
|
55
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
56
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
57
|
+
* GNU General Public License for more details.
|
|
58
|
+
*
|
|
59
|
+
* You should have received a copy of the GNU General Public License
|
|
60
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
61
|
+
*/
|
|
62
|
+
const react_1 = __importStar(require("react"));
|
|
63
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
64
|
+
const icons_1 = require("../icons");
|
|
65
|
+
const button_1 = require("../button");
|
|
66
|
+
const modal_1 = require("../modal");
|
|
67
|
+
// Should extend ModalCloseReason
|
|
68
|
+
var DialogCloseReason;
|
|
69
|
+
(function (DialogCloseReason) {
|
|
70
|
+
DialogCloseReason["BACKDROP_CLICK"] = "backdropClick";
|
|
71
|
+
DialogCloseReason["ESCAPE_KEY_DOWN"] = "escapeKeyDown";
|
|
72
|
+
DialogCloseReason["CLOSE_BUTTON_CLICK"] = "closeButtonClick";
|
|
73
|
+
})(DialogCloseReason = exports.DialogCloseReason || (exports.DialogCloseReason = {}));
|
|
74
|
+
const DialogContext = react_1.default.createContext(null);
|
|
75
|
+
const useDialogContext = () => {
|
|
76
|
+
const value = (0, react_1.useContext)(DialogContext);
|
|
77
|
+
if (!value) {
|
|
78
|
+
throw new Error('Accessing `useDialogContext` outside of the context provider');
|
|
79
|
+
}
|
|
80
|
+
return value;
|
|
81
|
+
};
|
|
82
|
+
const convertCloseReason = (reason) => {
|
|
83
|
+
const dialogReason = reason;
|
|
84
|
+
if (Object.values(DialogCloseReason).includes(dialogReason)) {
|
|
85
|
+
return dialogReason;
|
|
86
|
+
}
|
|
87
|
+
throw new Error(`Unknown reason '${reason}' received from popup`);
|
|
88
|
+
};
|
|
89
|
+
const typeIcons = {
|
|
90
|
+
warning: 'ExclamationIcon',
|
|
91
|
+
danger: 'ExclamationCircleIcon',
|
|
92
|
+
info: 'InformationCircleIcon',
|
|
93
|
+
success: 'CheckCircleIcon',
|
|
94
|
+
};
|
|
95
|
+
const Dialog = (_a) => {
|
|
96
|
+
var { open, onClose, children, type, className, size, disableCloseButton = false } = _a, rest = __rest(_a, ["open", "onClose", "children", "type", "className", "size", "disableCloseButton"]);
|
|
97
|
+
const handleCloseClick = (e) => {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
onClose && onClose(e, DialogCloseReason.CLOSE_BUTTON_CLICK);
|
|
100
|
+
};
|
|
101
|
+
const handleClose = (e, reason) => {
|
|
102
|
+
onClose && onClose(e, reason ? convertCloseReason(reason) : undefined);
|
|
103
|
+
};
|
|
104
|
+
if (!open) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
const classes = (0, classnames_1.default)('ndl-dialog', className, {
|
|
108
|
+
'with-icon': !!type,
|
|
109
|
+
'with-close-button': !disableCloseButton,
|
|
110
|
+
});
|
|
111
|
+
const contentWrapperClasses = (0, classnames_1.default)('n-flex n-flex-nowrap', {
|
|
112
|
+
'n-mt-10': !!type,
|
|
113
|
+
});
|
|
114
|
+
return ((0, jsx_runtime_1.jsx)(modal_1.Modal, Object.assign({}, rest, { open: open, onClose: handleClose, className: classes, size: size, role: "dialog" }, { children: (0, jsx_runtime_1.jsxs)(DialogContext.Provider, Object.assign({ value: { type } }, { children: [!disableCloseButton && ((0, jsx_runtime_1.jsx)(button_1.IconButton, Object.assign({ clean: true, buttonSize: "large", className: "dialog-close", onClick: handleCloseClick, role: "button", "data-testid": "dialog-close", "aria-label": "close" }, { children: (0, jsx_runtime_1.jsx)(icons_1.HeroIcon, { iconName: "XIcon" }) }))), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: contentWrapperClasses }, { children: [type && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: `dialog-type-icon ${type}`, "data-testid": "dialog-type-icon" }, { children: (0, jsx_runtime_1.jsx)(icons_1.HeroIcon, { iconName: typeIcons[type], strokeWidth: "0.8" }) }))), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "n-flex n-flex-col n-flex-1 n-w-full" }, { children: children }))] }))] })) })));
|
|
115
|
+
};
|
|
116
|
+
exports.Dialog = Dialog;
|
|
117
|
+
const Actions = (_a) => {
|
|
118
|
+
var { children, className = '' } = _a, rest = __rest(_a, ["children", "className"]);
|
|
119
|
+
const { type } = useDialogContext();
|
|
120
|
+
const classes = (0, classnames_1.default)('ndl-dialog-actions', className);
|
|
121
|
+
let childrenToRender = children;
|
|
122
|
+
// For danger dialogs, we want to convert primary buttons to danger buttons by default
|
|
123
|
+
if (type === 'danger') {
|
|
124
|
+
childrenToRender = react_1.default.Children.map(children, (element) => {
|
|
125
|
+
if (!react_1.default.isValidElement(element))
|
|
126
|
+
return;
|
|
127
|
+
const { color } = element.props;
|
|
128
|
+
if (!color || color === 'primary') {
|
|
129
|
+
return react_1.default.cloneElement(element, Object.assign(Object.assign({}, element.props), { color: 'danger' }));
|
|
130
|
+
}
|
|
131
|
+
return element;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({}, rest, { className: classes }, { children: childrenToRender })));
|
|
135
|
+
};
|
|
136
|
+
exports.Dialog.Actions = Actions;
|
|
137
|
+
const Header = (_a) => {
|
|
138
|
+
var { children, className = '' } = _a, rest = __rest(_a, ["children", "className"]);
|
|
139
|
+
const classes = (0, classnames_1.default)('ndl-dialog-header', className);
|
|
140
|
+
return ((0, jsx_runtime_1.jsx)("h4", Object.assign({}, rest, { className: classes }, { children: children })));
|
|
141
|
+
};
|
|
142
|
+
exports.Dialog.Header = Header;
|
|
143
|
+
const Subtitle = (_a) => {
|
|
144
|
+
var { children, className } = _a, rest = __rest(_a, ["children", "className"]);
|
|
145
|
+
const classes = (0, classnames_1.default)('ndl-dialog-subtitle body-large', className);
|
|
146
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({}, rest, { className: classes }, { children: children })));
|
|
147
|
+
};
|
|
148
|
+
exports.Dialog.Subtitle = Subtitle;
|
|
149
|
+
const Description = (_a) => {
|
|
150
|
+
var { children, className = '' } = _a, rest = __rest(_a, ["children", "className"]);
|
|
151
|
+
const classes = (0, classnames_1.default)('ndl-dialog-description body-medium', className);
|
|
152
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({}, rest, { className: classes }, { children: children })));
|
|
153
|
+
};
|
|
154
|
+
exports.Dialog.Description = Description;
|
|
155
|
+
const Content = (_a) => {
|
|
156
|
+
var { children, className = '' } = _a, rest = __rest(_a, ["children", "className"]);
|
|
157
|
+
const classes = (0, classnames_1.default)('ndl-dialog-content', className);
|
|
158
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({}, rest, { className: classes }, { children: children })));
|
|
159
|
+
};
|
|
160
|
+
exports.Dialog.Content = Content;
|
|
161
|
+
//# sourceMappingURL=Dialog.js.map
|