@neo4j-ndl/react 0.7.2 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/lib/cjs/code-block/CodeBlock.js +104 -0
  2. package/lib/cjs/code-block/CodeBlock.js.map +1 -0
  3. package/lib/cjs/code-block/index.js +38 -0
  4. package/lib/cjs/code-block/index.js.map +1 -0
  5. package/lib/cjs/code-block/languages.js +302 -0
  6. package/lib/cjs/code-block/languages.js.map +1 -0
  7. package/lib/cjs/dropdown/Dropdown.js +1 -1
  8. package/lib/cjs/dropdown/Dropdown.js.map +1 -1
  9. package/lib/cjs/graph-label/GraphLabel.js +80 -42
  10. package/lib/cjs/graph-label/GraphLabel.js.map +1 -1
  11. package/lib/cjs/graph-label/color.js +87 -0
  12. package/lib/cjs/graph-label/color.js.map +1 -0
  13. package/lib/cjs/index.js +1 -0
  14. package/lib/cjs/index.js.map +1 -1
  15. package/lib/esm/code-block/CodeBlock.js +75 -0
  16. package/lib/esm/code-block/CodeBlock.js.map +1 -0
  17. package/lib/esm/code-block/index.js +22 -0
  18. package/lib/esm/code-block/index.js.map +1 -0
  19. package/lib/esm/code-block/languages.js +301 -0
  20. package/lib/esm/code-block/languages.js.map +1 -0
  21. package/lib/esm/dropdown/Dropdown.js +1 -1
  22. package/lib/esm/dropdown/Dropdown.js.map +1 -1
  23. package/lib/esm/graph-label/GraphLabel.js +57 -42
  24. package/lib/esm/graph-label/GraphLabel.js.map +1 -1
  25. package/lib/esm/graph-label/color.js +77 -0
  26. package/lib/esm/graph-label/color.js.map +1 -0
  27. package/lib/esm/index.js +1 -0
  28. package/lib/esm/index.js.map +1 -1
  29. package/lib/types/code-block/CodeBlock.d.ts +34 -0
  30. package/lib/types/code-block/index.d.ts +21 -0
  31. package/lib/types/code-block/languages.d.ts +23 -0
  32. package/lib/types/graph-label/GraphLabel.d.ts +11 -38
  33. package/lib/types/graph-label/color.d.ts +41 -0
  34. package/lib/types/index.d.ts +1 -0
  35. package/package.json +6 -3
@@ -1,4 +1,27 @@
1
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
+ };
2
25
  var __rest = (this && this.__rest) || function (s, e) {
3
26
  var t = {};
4
27
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -35,8 +58,10 @@ const jsx_runtime_1 = require("react/jsx-runtime");
35
58
  * You should have received a copy of the GNU General Public License
36
59
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
37
60
  */
38
- const react_1 = __importDefault(require("react"));
61
+ const react_1 = __importStar(require("react"));
39
62
  const classnames_1 = __importDefault(require("classnames"));
63
+ const tokens_1 = __importDefault(require("@neo4j-ndl/base/lib/tokens/js/tokens"));
64
+ const color_1 = require("./color");
40
65
  /**
41
66
  *
42
67
  *
@@ -44,7 +69,9 @@ const classnames_1 = __importDefault(require("classnames"));
44
69
  *
45
70
  *
46
71
  */
47
- const HexagonEnd = ({ direction = 'left' }) => ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `ndl-hexagon-end ${direction}` }, { children: [(0, jsx_runtime_1.jsxs)("svg", Object.assign({ width: "8", height: "24", viewBox: "0 0 7 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [(0, jsx_runtime_1.jsx)("path", { className: "ndl-hexagon-end-inner", fillRule: "evenodd", clipRule: "evenodd", d: "M5.73024 1.03676C6.08165 0.397331 6.75338 0 7.48301 0H9V24H7.483C6.75338 24 6.08165 23.6027 5.73024 22.9632L0.315027 13.1094C-0.105009 12.4376 -0.105009 11.5624 0.315026 10.8906L5.73024 1.03676Z" }), (0, jsx_runtime_1.jsx)("path", { className: "ndl-hexagon-end-outer", d: "M 9 0 V -0.5 H 9.5 V 0.5 H 9 Z M 9 24 H 9 V 24 Z M 0.315 13.1094 L 0.739 12.8443 L 0.7464 12.8563 L 0.7532 12.8686 L 0.315 13.1094 Z M 0.315 10.8906 L 0.7532 11.1314 L 0.7464 11.1437 L 0.739 11.1557 L 0.315 10.8906 Z M 5.7302 22.9632 L 6.1684 22.7224 L 5.7302 22.9632 Z M 5.7302 1.0368 L 6.1684 1.2776 L 5.7302 1.0368 Z M 9 0.5 H 7.483 V -0.5 H 9 V 0.5 Z M 9 23.5 H 9.5 V 24.5 H 9 Z M 7.483 23.5 H 9 V 24.5 H 7.483 V 23.5 Z M 5.292 23.204 L -0.1232 13.3502 L 0.7532 12.8686 L 6.1684 22.7224 L 5.292 23.204 Z M -0.1089 13.3745 C -0.6304 12.5405 -0.6304 11.4595 -0.1089 10.6255 L 0.739 11.1557 C 0.4203 11.6653 0.4203 12.3347 0.739 12.8443 L -0.1089 13.3745 Z M -0.1232 10.6498 L 5.292 0.796 L 6.1684 1.2776 L 0.7532 11.1314 L -0.1232 10.6498 Z M 7.483 24.5 C 6.571 24.5 5.7313 24.0033 5.292 23.204 L 6.1684 22.7224 C 6.432 23.202 6.9358 23.5 7.483 23.5 V 24.5 Z M 7.483 0.5 C 6.9358 0.5 6.432 0.798 6.1684 1.2776 L 5.292 0.796 C 5.7313 -0.0033 6.571 -0.5 7.483 -0.5 V 0.5 Z", mask: "url(#ndl-relationship-label-mask-outer-border)" })] })), (0, jsx_runtime_1.jsx)("svg", Object.assign({ className: "ndl-hexagon-end-active", width: "13", height: "30", viewBox: "0 0 13 30", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M10.075 2C9.12474 2 8.24318 2.54521 7.74867 3.43873L2.21419 13.4387C1.68353 14.3976 1.68353 15.6024 2.21419 16.5613L7.74867 26.5613C8.24318 27.4548 9.12474 28 10.075 28H13V30H10.075C8.49126 30 7.022 29.0913 6.1978 27.6021L0.663324 17.6021C-0.221109 16.0041 -0.221108 13.9959 0.663325 12.3979L6.1978 2.39789C7.022 0.90869 8.49126 0 10.075 0H13V2H10.075Z" }) }))] })));
72
+ const HexagonEnd = ({ direction = 'left', color }) => {
73
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `ndl-hexagon-end ${direction}` }, { children: [(0, jsx_runtime_1.jsx)("svg", Object.assign({ width: "8", height: "24", viewBox: "0 0 7 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: (0, jsx_runtime_1.jsx)("path", { className: "ndl-hexagon-end-inner", style: { fill: color }, fillRule: "evenodd", clipRule: "evenodd", d: "M5.73024 1.03676C6.08165 0.397331 6.75338 0 7.48301 0H9V24H7.483C6.75338 24 6.08165 23.6027 5.73024 22.9632L0.315027 13.1094C-0.105009 12.4376 -0.105009 11.5624 0.315026 10.8906L5.73024 1.03676Z" }) })), (0, jsx_runtime_1.jsx)("svg", Object.assign({ className: "ndl-hexagon-end-active", width: "13", height: "30", viewBox: "0 0 13 30", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M10.075 2C9.12474 2 8.24318 2.54521 7.74867 3.43873L2.21419 13.4387C1.68353 14.3976 1.68353 15.6024 2.21419 16.5613L7.74867 26.5613C8.24318 27.4548 9.12474 28 10.075 28H13V30H10.075C8.49126 30 7.022 29.0913 6.1978 27.6021L0.663324 17.6021C-0.221109 16.0041 -0.221108 13.9959 0.663325 12.3979L6.1978 2.39789C7.022 0.90869 8.49126 0 10.075 0H13V2H10.075Z" }) }))] })));
74
+ };
48
75
  /**
49
76
  *
50
77
  *
@@ -53,7 +80,16 @@ const HexagonEnd = ({ direction = 'left' }) => ((0, jsx_runtime_1.jsxs)("div", O
53
80
  *
54
81
  */
55
82
  const GraphLabel = react_1.default.forwardRef(function GraphLabel(_a, ref) {
56
- var { type = 'node', disabled = false, selected = false, as, onClick } = _a, props = __rest(_a, ["type", "disabled", "selected", "as", "onClick"]);
83
+ var { type = 'node', color, disabled = false, selected = false, as, onClick } = _a, props = __rest(_a, ["type", "color", "disabled", "selected", "as", "onClick"]);
84
+ const [isHover, setIsHover] = (0, react_1.useState)(false);
85
+ const handleMouseEnter = (event) => {
86
+ setIsHover(true);
87
+ props.onMouseEnter && props.onMouseEnter(event);
88
+ };
89
+ const handleMouseLeave = (event) => {
90
+ setIsHover(false);
91
+ props.onMouseLeave && props.onMouseLeave(event);
92
+ };
57
93
  const handleClick = (e) => {
58
94
  // By default, a <button /> element with disabled set to true will not get its
59
95
  // on click handler called. To support the same behavior on <a /> tags we
@@ -68,51 +104,53 @@ const GraphLabel = react_1.default.forwardRef(function GraphLabel(_a, ref) {
68
104
  onClick(e);
69
105
  }
70
106
  };
71
- switch (type) {
72
- case 'node':
73
- return ((0, jsx_runtime_1.jsx)(NodeLabel, Object.assign({}, props, { color: props.color, disabled: disabled, selected: selected, className: props.className, as: as, ref: ref, onClick: handleClick }, { children: props.children })));
74
- case 'relationship':
75
- return ((0, jsx_runtime_1.jsx)(RelationshipLabel, Object.assign({}, props, { disabled: disabled, selected: selected, as: as, ref: ref, onClick: handleClick }, { children: props.children })));
76
- case 'propertyKey':
77
- return ((0, jsx_runtime_1.jsx)(PropertyKeyLabel, Object.assign({}, props, { disabled: disabled, selected: selected, as: as, ref: ref, onClick: handleClick }, { children: props.children })));
78
- }
79
- });
80
- const NodeLabel = react_1.default.forwardRef(function NodeLabel(_a, ref) {
81
- var { children, disabled, selected, color = '', className, as } = _a, props = __rest(_a, ["children", "disabled", "selected", "color", "className", "as"]);
107
+ let backgroundColor = (0, react_1.useMemo)(() => {
108
+ if (!color) {
109
+ switch (type) {
110
+ case 'node':
111
+ return tokens_1.default.colors.warning[40];
112
+ case 'relationship':
113
+ return tokens_1.default.palette.light.neutral.bg.strong;
114
+ default:
115
+ return tokens_1.default.palette.light.neutral.bg.strongest;
116
+ }
117
+ }
118
+ return color;
119
+ }, [color, type]);
120
+ const hoverColor = (0, react_1.useMemo)(() => (0, color_1.getHoverColor)(backgroundColor ? backgroundColor : tokens_1.default.colors.warning[40]), [backgroundColor]);
121
+ const textColor = (0, react_1.useMemo)(() => (0, color_1.getTextColorFromBackground)(backgroundColor ? backgroundColor : tokens_1.default.colors.warning[40]), [backgroundColor]);
122
+ const disabledTextColor = (0, react_1.useMemo)(() => (0, color_1.getDisabledTextColor)(backgroundColor ? backgroundColor : tokens_1.default.colors.warning[40]), [backgroundColor]);
123
+ if (isHover && !disabled)
124
+ backgroundColor = hoverColor;
125
+ if (disabled)
126
+ backgroundColor = (0, color_1.getDisabledColor)(backgroundColor);
82
127
  let Component = 'button';
83
128
  if (as) {
84
129
  Component = as;
85
130
  }
86
- const classes = (0, classnames_1.default)('ndl-node-label', className, {
87
- disabled: disabled,
88
- selected: selected,
89
- 'n-bg-warning-40': !color && !className,
90
- });
91
- return ((0, jsx_runtime_1.jsx)(Component, Object.assign({}, props, { className: classes, ref: ref, style: Object.assign({ backgroundColor: color }, props.style) }, { children: children })));
92
- });
93
- const RelationshipLabel = react_1.default.forwardRef(function RelationshipLabel(_a, ref) {
94
- var { children, disabled, selected, as } = _a, props = __rest(_a, ["children", "disabled", "selected", "as"]);
95
- let Component = 'button';
96
- if (as) {
97
- Component = as;
131
+ if (type === 'node') {
132
+ const classes = (0, classnames_1.default)('ndl-node-label', props.className, {
133
+ disabled: disabled,
134
+ selected: selected,
135
+ });
136
+ return ((0, jsx_runtime_1.jsx)(Component, Object.assign({}, props, { className: classes, ref: ref, style: Object.assign({ backgroundColor: backgroundColor, color: disabled ? disabledTextColor : textColor }, props.style), onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }, { children: props.children })));
98
137
  }
99
- const classes = (0, classnames_1.default)('ndl-relationship-label', {
100
- disabled: disabled,
101
- selected: selected,
102
- });
103
- return ((0, jsx_runtime_1.jsxs)(Component, Object.assign({}, props, { className: classes, ref: ref }, { children: [(0, jsx_runtime_1.jsx)("svg", Object.assign({ style: { display: 'none' } }, { children: (0, jsx_runtime_1.jsx)("mask", Object.assign({ id: "ndl-relationship-label-mask-outer-border", fill: "white" }, { children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M5.73024 1.03676C6.08165 0.397331 6.75338 0 7.48301 0H9V24H7.483C6.75338 24 6.08165 23.6027 5.73024 22.9632L0.315027 13.1094C-0.105009 12.4376 -0.105009 11.5624 0.315026 10.8906L5.73024 1.03676Z" }) })) })), (0, jsx_runtime_1.jsx)(HexagonEnd, { direction: "left" }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "ndl-relationship-label-content" }, { children: children })), (0, jsx_runtime_1.jsx)(HexagonEnd, { direction: "right" })] })));
104
- });
105
- const PropertyKeyLabel = react_1.default.forwardRef(function PropertyKeyLabel(_a, ref) {
106
- var { children, disabled, selected, as } = _a, props = __rest(_a, ["children", "disabled", "selected", "as"]);
107
- let Component = 'button';
108
- if (as) {
109
- Component = as;
138
+ else if (type === 'relationship') {
139
+ const classes = (0, classnames_1.default)('ndl-relationship-label', {
140
+ disabled: disabled,
141
+ selected: selected,
142
+ });
143
+ return ((0, jsx_runtime_1.jsxs)(Component, Object.assign({}, props, { style: Object.assign(Object.assign({}, props.style), { color: disabled ? disabledTextColor : textColor }), className: classes, onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, ref: ref }, { children: [(0, jsx_runtime_1.jsx)("svg", Object.assign({ style: { display: 'none' } }, { children: (0, jsx_runtime_1.jsx)("mask", Object.assign({ id: "ndl-relationship-label-mask-outer-border", fill: "white" }, { children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M5.73024 1.03676C6.08165 0.397331 6.75338 0 7.48301 0H9V24H7.483C6.75338 24 6.08165 23.6027 5.73024 22.9632L0.315027 13.1094C-0.105009 12.4376 -0.105009 11.5624 0.315026 10.8906L5.73024 1.03676Z" }) })) })), (0, jsx_runtime_1.jsx)(HexagonEnd, { direction: "left", color: backgroundColor }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "ndl-relationship-label-content", style: {
144
+ backgroundColor: backgroundColor,
145
+ } }, { children: props.children })), (0, jsx_runtime_1.jsx)(HexagonEnd, { direction: "right", color: backgroundColor })] })));
146
+ }
147
+ else {
148
+ const classes = (0, classnames_1.default)('ndl-property-key-label', {
149
+ disabled: disabled,
150
+ selected: selected,
151
+ });
152
+ return ((0, jsx_runtime_1.jsx)(Component, Object.assign({}, props, { style: Object.assign({ backgroundColor: backgroundColor, color: disabled ? disabledTextColor : textColor }, props.style), className: classes, onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, ref: ref }, { children: props.children })));
110
153
  }
111
- const classes = (0, classnames_1.default)('ndl-property-key-label', {
112
- disabled: disabled,
113
- selected: selected,
114
- });
115
- return ((0, jsx_runtime_1.jsx)(Component, Object.assign({}, props, { className: classes, ref: ref }, { children: children })));
116
154
  });
117
155
  exports.default = GraphLabel;
118
156
  //# sourceMappingURL=GraphLabel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GraphLabel.js","sourceRoot":"","sources":["../../../src/graph-label/GraphLabel.tsx"],"names":[],"mappings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den 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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getDisabledColor = exports.getDisabledTextColor = exports.getHoverColor = exports.getTextColorFromBackground = void 0;
27
+ const tinycolor2_1 = __importDefault(require("tinycolor2"));
28
+ const tokens_1 = __importDefault(require("@neo4j-ndl/base/lib/tokens/js/tokens"));
29
+ /**
30
+ * Takes a color string and returns color string
31
+ * that is readable on top of that background. Prioritizes pallete
32
+ * text colors and uses black or white as fallback.
33
+ */
34
+ const getTextColorFromBackground = (color) => {
35
+ return tinycolor2_1.default
36
+ .mostReadable(color, [
37
+ tokens_1.default.palette.light.neutral.text.default,
38
+ tokens_1.default.palette.light.neutral.text.inverse,
39
+ ], {
40
+ includeFallbackColors: true,
41
+ })
42
+ .toString();
43
+ };
44
+ exports.getTextColorFromBackground = getTextColorFromBackground;
45
+ /**
46
+ * Takes a color string and returns a color string
47
+ * that is darker or ligher depending on the given color.
48
+ */
49
+ const getHoverColor = (color) => {
50
+ const hslColor = (0, tinycolor2_1.default)(color).toHsl();
51
+ if (hslColor.l < 0.5) {
52
+ return (0, tinycolor2_1.default)(color).lighten(10).toString();
53
+ }
54
+ return (0, tinycolor2_1.default)(color).darken(10).toString();
55
+ };
56
+ exports.getHoverColor = getHoverColor;
57
+ /**
58
+ * Returns the most readlabale color on the given background color
59
+ * as a string from a list of palette text colors
60
+ */
61
+ const getDisabledTextColor = (backgroundColor) => {
62
+ //TODO: update to token when dark theme is available
63
+ //inverse of text.weaker color should probably be replaced by token
64
+ const inverseTextColor = '#8e887f';
65
+ return tinycolor2_1.default
66
+ .mostReadable(backgroundColor, [
67
+ inverseTextColor,
68
+ tokens_1.default.palette.light.neutral.text.weakest,
69
+ tokens_1.default.palette.light.neutral.text.weak,
70
+ tokens_1.default.palette.light.neutral.text.weaker,
71
+ ])
72
+ .toString();
73
+ };
74
+ exports.getDisabledTextColor = getDisabledTextColor;
75
+ /**
76
+ * Takes a color string and returns a color string
77
+ * that is darker or ligher depending on the given color.
78
+ */
79
+ const getDisabledColor = (color) => {
80
+ const hslColor = (0, tinycolor2_1.default)(color).toHsl();
81
+ if (hslColor.l < 0.5) {
82
+ return (0, tinycolor2_1.default)(color).lighten(15).toString();
83
+ }
84
+ return (0, tinycolor2_1.default)(color).darken(15).toString();
85
+ };
86
+ exports.getDisabledColor = getDisabledColor;
87
+ //# sourceMappingURL=color.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color.js","sourceRoot":"","sources":["../../../src/graph-label/color.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;AAEH,4DAAmC;AACnC,kFAA0D;AAE1D;;;;GAIG;AACI,MAAM,0BAA0B,GAAG,CAAC,KAAa,EAAU,EAAE;IAClE,OAAO,oBAAS;SACb,YAAY,CACX,KAAK,EACL;QACE,gBAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO;QACzC,gBAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO;KAC1C,EACD;QACE,qBAAqB,EAAE,IAAI;KAC5B,CACF;SACA,QAAQ,EAAE,CAAC;AAChB,CAAC,CAAC;AAbW,QAAA,0BAA0B,8BAarC;AAEF;;;G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OAAO,IAAA,oBAAS,EAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AAChD,CAAC,CAAC;AANW,QAAA,gBAAgB,oBAM3B"}
package/lib/cjs/index.js CHANGED
@@ -57,4 +57,5 @@ __exportStar(require("./dropdown"), exports);
57
57
  __exportStar(require("./tag"), exports);
58
58
  __exportStar(require("./wizard"), exports);
59
59
  __exportStar(require("./graph-label"), exports);
60
+ __exportStar(require("./code-block"), exports);
60
61
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,0CAAwB;AACxB,0CAAwB;AACxB,4CAA0B;AAC1B,6CAA2B;AAC3B,2CAAyB;AACzB,0CAAwB;AACxB,iDAA+B;AAC/B,2CAAyB;AACzB,0CAAwB;AACxB,oDAAkC;AAClC,yCAAuB;AACvB,kDAAgC;AAChC,4CAA0B;AAC1B,0CAAwB;AACxB,iDAA+B;AAC/B,0CAAwB;AACxB,kDAAgC;AAChC,+CAA6B;AAC7B,6CAA2B;AAC3B,wCAAsB;AACtB,2CAAyB;AACzB,gDAA8B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,0CAAwB;AACxB,0CAAwB;AACxB,4CAA0B;AAC1B,6CAA2B;AAC3B,2CAAyB;AACzB,0CAAwB;AACxB,iDAA+B;AAC/B,2CAAyB;AACzB,0CAAwB;AACxB,oDAAkC;AAClC,yCAAuB;AACvB,kDAAgC;AAChC,4CAA0B;AAC1B,0CAAwB;AACxB,iDAA+B;AAC/B,0CAAwB;AACxB,kDAAgC;AAChC,+CAA6B;AAC7B,6CAA2B;AAC3B,wCAAsB;AACtB,2CAAyB;AACzB,gDAA8B;AAC9B,+CAA6B"}
@@ -0,0 +1,75 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
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
+ import ndlTokens from '@neo4j-ndl/base/lib/tokens/js/tokens';
23
+ import React, { useState } from 'react';
24
+ import classNames from 'classnames';
25
+ import { IconButton } from '../button';
26
+ import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
27
+ import { base16AteliersulphurpoolLight, coy, duotoneLight, ghcolors, prism, solarizedlight, vs, } from 'react-syntax-highlighter/dist/cjs/styles/prism';
28
+ export const CodeBlock = React.forwardRef(function CodeBlock({ as, code, language, showLineNumbers, theme, title, actions, disabled, }, ref) {
29
+ const Component = as || 'div';
30
+ const [isFocused, setIsFocused] = useState(false);
31
+ const getTheme = () => {
32
+ switch (theme) {
33
+ case 'vs':
34
+ return vs;
35
+ case 'base16-ateliersulphurpool.light':
36
+ return base16AteliersulphurpoolLight;
37
+ case 'coy':
38
+ return coy;
39
+ case 'duotone-light':
40
+ return duotoneLight;
41
+ case 'ghcolors':
42
+ return ghcolors;
43
+ case 'prism':
44
+ return prism;
45
+ case 'solarizedlight':
46
+ return solarizedlight;
47
+ default:
48
+ return vs;
49
+ }
50
+ };
51
+ const hasHeader = title || actions;
52
+ return (_jsxs(Component, Object.assign({ ref: ref, className: "ndl-code-block-container" }, { children: [hasHeader && (_jsxs("div", Object.assign({ className: classNames('ndl-code-block-title', {
53
+ disabled,
54
+ }) }, { children: [title && _jsx("h6", { children: title }), _jsx("div", { children: actions === null || actions === void 0 ? void 0 : actions.map((iconButtonProps, i) => (_jsx(IconButton, Object.assign({ clean: true, disabled: disabled }, iconButtonProps), i))) })] }))), _jsx("div", Object.assign({ className: classNames('highlight-wrapper', {
55
+ 'has-header': hasHeader,
56
+ focused: isFocused,
57
+ }), role: "textbox", "aria-label": `${title} code-snippet`, tabIndex: 0, onFocus: () => {
58
+ setIsFocused(true);
59
+ }, onBlur: () => setIsFocused(false) }, { children: _jsx(SyntaxHighlighter, Object.assign({ language: language, style: Object.assign(Object.assign({}, getTheme()), { 'pre[class*="language-"]': {
60
+ color: ndlTokens.palette.light.neutral.text.weak,
61
+ backgroundColor: ndlTokens.colors.neutral[20],
62
+ background: ndlTokens.colors.neutral[20],
63
+ lineHeight: '1',
64
+ border: 0,
65
+ padding: '0 1em 1em 1em',
66
+ overflowX: 'auto',
67
+ overflowY: 'auto',
68
+ opacity: disabled ? 0.5 : 1,
69
+ } }),
70
+ // Turn on 'showLineNumbers' & 'wrapLongLines' at the same time, the display is wrong
71
+ // https://github.com/react-syntax-highlighter/react-syntax-highlighter/issues/402
72
+ // wrapLongLines
73
+ codeTagProps: { className: 'n-code' }, showLineNumbers: showLineNumbers }, { children: code })) }))] })));
74
+ });
75
+ //# sourceMappingURL=CodeBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeBlock.js","sourceRoot":"","sources":["../../../src/code-block/CodeBlock.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,SAAS,MAAM,sCAAsC,CAAC;AAC7D,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,UAAU,MAAM,YAAY,CAAC;AAC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J,CAAC,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ *
3
+ * Copyright (c) "Neo4j"
4
+ * Neo4j Sweden AB [http://neo4j.com]
5
+ *
6
+ * This file is part of Neo4j.
7
+ *
8
+ * Neo4j is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+ export * from './CodeBlock';
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/code-block/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,aAAa,CAAC"}