@neo4j-ndl/react 1.9.0 → 1.10.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - cd2e749: fix accordion typography import
8
+
9
+ ## 1.10.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 95c8c78: new accordion component
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [95c8c78]
18
+ - @neo4j-ndl/base@1.10.0
19
+
3
20
  ## 1.9.0
4
21
 
5
22
  ### Minor Changes
@@ -0,0 +1,241 @@
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.Accordion = 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 classnames_1 = __importDefault(require("classnames"));
40
+ const react_1 = require("react");
41
+ const helpers_1 = require("../helpers");
42
+ const icons_1 = require("../icons");
43
+ const typography_1 = require("../typography");
44
+ const getAccordionItem = (activeElement, accordionElement, iterator) => {
45
+ var _a;
46
+ const accordionItemElement = activeElement.parentElement;
47
+ let newItemElement = iterator(accordionElement, accordionItemElement);
48
+ let childItemElement = null;
49
+ // Iterate over next element until we find a menu item
50
+ // Iterate a maximum of 10 times looking for an element
51
+ for (let i = 0; i < 10; i++) {
52
+ // Can't find new element, break
53
+ if (!newItemElement) {
54
+ return null;
55
+ }
56
+ const role = (_a = newItemElement.firstElementChild) === null || _a === void 0 ? void 0 : _a.getAttribute('role');
57
+ if (role === 'heading') {
58
+ childItemElement = newItemElement;
59
+ break;
60
+ }
61
+ newItemElement = iterator(accordionElement, newItemElement);
62
+ }
63
+ return childItemElement;
64
+ };
65
+ // Gets next sibling child, looping at the end
66
+ const nextElement = (accordionElement, currentElement) => {
67
+ var _a, _b;
68
+ if (currentElement === accordionElement ||
69
+ !(currentElement === null || currentElement === void 0 ? void 0 : currentElement.nextElementSibling)) {
70
+ const nextItem = accordionElement.firstChild;
71
+ const firstAccordionItemHeaderElement = (_a = accordionElement === null || accordionElement === void 0 ? void 0 : accordionElement.firstElementChild) === null || _a === void 0 ? void 0 : _a.firstElementChild;
72
+ return (firstAccordionItemHeaderElement === null || firstAccordionItemHeaderElement === void 0 ? void 0 : firstAccordionItemHeaderElement.className.includes('ndl-accordion-item-header-disabled'))
73
+ ? nextElement(accordionElement, nextItem)
74
+ : nextItem;
75
+ }
76
+ else if (currentElement === null || currentElement === void 0 ? void 0 : currentElement.nextElementSibling) {
77
+ const nextItem = currentElement.nextElementSibling;
78
+ return ((_b = currentElement.nextElementSibling.firstElementChild) === null || _b === void 0 ? void 0 : _b.className.includes('ndl-accordion-item-header-disabled'))
79
+ ? nextElement(accordionElement, nextItem)
80
+ : nextItem;
81
+ }
82
+ return null;
83
+ };
84
+ // Gets prev sibling child, looping at the top
85
+ const previousElement = (accordionElement, currentElement) => {
86
+ var _a, _b;
87
+ if (currentElement === accordionElement ||
88
+ !(currentElement === null || currentElement === void 0 ? void 0 : currentElement.previousElementSibling)) {
89
+ const prevItem = accordionElement.lastElementChild;
90
+ const lastAccordionItemHeaderElement = (_a = accordionElement === null || accordionElement === void 0 ? void 0 : accordionElement.lastElementChild) === null || _a === void 0 ? void 0 : _a.firstElementChild;
91
+ return (lastAccordionItemHeaderElement === null || lastAccordionItemHeaderElement === void 0 ? void 0 : lastAccordionItemHeaderElement.className.includes('ndl-accordion-item-header-disabled'))
92
+ ? previousElement(accordionElement, prevItem)
93
+ : prevItem;
94
+ }
95
+ else if (currentElement === null || currentElement === void 0 ? void 0 : currentElement.previousElementSibling) {
96
+ const prevItem = currentElement.previousElementSibling;
97
+ return ((_b = currentElement.previousElementSibling.firstElementChild) === null || _b === void 0 ? void 0 : _b.className.includes('ndl-accordion-item-header-disabled'))
98
+ ? previousElement(accordionElement, prevItem)
99
+ : prevItem;
100
+ }
101
+ return null;
102
+ };
103
+ const AccordionContext = (0, react_1.createContext)(null);
104
+ const useAccordionContext = () => {
105
+ const context = (0, react_1.useContext)(AccordionContext);
106
+ if (context === null) {
107
+ throw new Error('Accordion used without context');
108
+ }
109
+ return context;
110
+ };
111
+ const Accordion = (0, helpers_1.forwardRef)(function Accordion(_a, ref) {
112
+ var { as = 'div', children, className } = _a, restProps = __rest(_a, ["as", "children", "className"]);
113
+ const accordionRef = (0, react_1.useRef)(null);
114
+ // The following function includes code needed to be
115
+ // able to navigate with the arrow keys (not tab).
116
+ const handleKeyDown = (event) => {
117
+ const accordionElement = accordionRef.current;
118
+ if (!accordionElement) {
119
+ return;
120
+ }
121
+ const activeElement = document.activeElement;
122
+ if (event.key == 'ArrowDown') {
123
+ event.preventDefault();
124
+ event.stopPropagation();
125
+ const newFocusedElement = getAccordionItem(activeElement, accordionElement, nextElement);
126
+ const newHeader = newFocusedElement === null || newFocusedElement === void 0 ? void 0 : newFocusedElement.firstElementChild;
127
+ newHeader.focus();
128
+ }
129
+ else if (event.key == 'ArrowUp') {
130
+ event.preventDefault();
131
+ event.stopPropagation();
132
+ const newFocusedElement = getAccordionItem(activeElement, accordionElement, previousElement);
133
+ const newHeader = newFocusedElement === null || newFocusedElement === void 0 ? void 0 : newFocusedElement.firstElementChild;
134
+ newHeader.focus();
135
+ }
136
+ else if (event.key == ' ' || event.key == 'Enter') {
137
+ event.preventDefault();
138
+ event.stopPropagation();
139
+ const buttonElement = activeElement.getElementsByClassName('ndl-accordion-item-header-button')[0];
140
+ buttonElement.click();
141
+ }
142
+ };
143
+ (0, react_1.useImperativeHandle)(ref, () => accordionRef.current);
144
+ const classes = (0, classnames_1.default)('ndl-accordion', className);
145
+ const Component = as;
146
+ const { onChange, multiple } = restProps, rootProps = __rest(restProps, ["onChange", "multiple"]);
147
+ const contextValue = multiple
148
+ ? {
149
+ onChange,
150
+ multiple,
151
+ expandedItemIds: restProps.expandedItemIds,
152
+ }
153
+ : {
154
+ onChange,
155
+ multiple,
156
+ expandedItemId: restProps.expandedItemId,
157
+ };
158
+ return ((0, jsx_runtime_1.jsx)(Component, Object.assign({}, rootProps, { className: classes, ref: accordionRef, onKeyDown: handleKeyDown }, { children: (0, jsx_runtime_1.jsx)(AccordionContext.Provider, Object.assign({ value: contextValue }, { children: children })) })));
159
+ });
160
+ const createItemId = (type, id) => `ndl-accordionitem${type}id-${id}`;
161
+ const Item = (_a) => {
162
+ var { itemId, children, title, className = '', arrowPosition = 'right', disabled = false, onExpandedChange } = _a, restProps = __rest(_a, ["itemId", "children", "title", "className", "arrowPosition", "disabled", "onExpandedChange"]);
163
+ const contentRef = (0, react_1.useRef)(null);
164
+ const innerContentRef = (0, react_1.useRef)(null);
165
+ const itemElementId = createItemId('item', itemId);
166
+ const headerElementId = createItemId('header', itemId);
167
+ const buttonElementId = createItemId('button', itemId);
168
+ const panelElementId = createItemId('panel', itemId);
169
+ const context = useAccordionContext();
170
+ const { multiple } = context;
171
+ const isExpanded = multiple
172
+ ? context.expandedItemIds.includes(itemId)
173
+ : context.expandedItemId === itemId;
174
+ const handleOnClick = (0, react_1.useCallback)(() => {
175
+ var _a, _b;
176
+ if (disabled)
177
+ return;
178
+ // Custom callback to call.
179
+ if (onExpandedChange !== undefined)
180
+ onExpandedChange(!isExpanded);
181
+ if (multiple) {
182
+ const { expandedItemIds, onChange } = context;
183
+ // Multiple expanded.
184
+ if (isExpanded) {
185
+ // Remove from list.
186
+ const newArray = expandedItemIds.filter((activeId) => activeId !== itemId);
187
+ onChange(newArray);
188
+ }
189
+ else if (!isExpanded) {
190
+ // Add to list.
191
+ const newArray = [...expandedItemIds];
192
+ newArray.push(itemId);
193
+ onChange(newArray);
194
+ }
195
+ }
196
+ else {
197
+ const { onChange } = context;
198
+ // Single expanded.
199
+ if (isExpanded) {
200
+ // Set null.
201
+ onChange(null);
202
+ }
203
+ else if (!isExpanded) {
204
+ // Set to id.
205
+ onChange(itemId);
206
+ }
207
+ }
208
+ // The W3 WAI-ARIA states that focus can only happen on the header not the header button.
209
+ (_b = (_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.focus();
210
+ }, [isExpanded, multiple, disabled, itemId, onExpandedChange, context]);
211
+ const classes = (0, classnames_1.default)('ndl-accordion-item', className, {
212
+ 'ndl-accordion-item-disabled': disabled,
213
+ });
214
+ const headerClasses = (0, classnames_1.default)('ndl-accordion-item-header', {
215
+ 'ndl-accordion-item-header-disabled': disabled,
216
+ });
217
+ const iconClasses = (0, classnames_1.default)('ndl-accordion-item-header-icon-wrapper', {
218
+ 'ndl-accordion-item-header-icon-wrapper-right': arrowPosition === 'right',
219
+ });
220
+ const buttonClasses = (0, classnames_1.default)('ndl-accordion-item-header-button', {
221
+ 'ndl-accordion-item-header-button-disabled': disabled,
222
+ });
223
+ const titleClasses = (0, classnames_1.default)('ndl-accordion-item-header-button-title', {
224
+ 'ndl-accordion-item-header-button-title': disabled,
225
+ 'ndl-accordion-item-header-button-title-right': arrowPosition === 'right',
226
+ });
227
+ const contentClasses = (0, classnames_1.default)('ndl-accordion-item-content', {
228
+ 'ndl-accordion-item-content-expanded': isExpanded,
229
+ 'ndl-accordion-item-content-right': arrowPosition === 'right',
230
+ });
231
+ const headerTitle = (0, jsx_runtime_1.jsx)("span", Object.assign({ className: titleClasses }, { children: title }));
232
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, restProps, { className: classes, id: itemElementId }, { children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, Object.assign({ variant: "subheading-medium", className: headerClasses, role: "heading", tabIndex: disabled ? -1 : 0, id: headerElementId, "aria-level": "2" }, { children: (0, jsx_runtime_1.jsx)("button", Object.assign({ id: buttonElementId, onClick: handleOnClick, className: buttonClasses, "aria-expanded": isExpanded, "aria-disabled": disabled, "aria-label": title, "aria-controls": panelElementId, tabIndex: -1 }, { children: (0, jsx_runtime_1.jsxs)("span", Object.assign({ className: iconClasses }, { children: [headerTitle, (0, jsx_runtime_1.jsx)(icons_1.ChevronDownIconOutline, { className: (0, classnames_1.default)('ndl-accordion-item-header-icon', {
233
+ '-n-rotate-180': isExpanded,
234
+ }) })] })) })) })), (0, jsx_runtime_1.jsx)("div", Object.assign({ id: panelElementId, ref: contentRef, className: contentClasses, "aria-hidden": !isExpanded, "aria-labelledby": buttonElementId, role: "region" }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ ref: innerContentRef, className: "ndl-accordion-item-content-inner" }, { children: (0, jsx_runtime_1.jsx)(typography_1.Typography, Object.assign({ variant: "body-medium", className: "n-text-palette-neutral-text-weak", as: "div" }, { children: children })) })) }))] })));
235
+ };
236
+ // Issue with TypeScript forwardRef and subcomponents: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34757#issuecomment-894053907
237
+ // Fixes issue with: Accordion.Item = Item;
238
+ const AccordionNamespace = Object.assign(Accordion, { Item });
239
+ exports.Accordion = AccordionNamespace;
240
+ exports.default = Accordion;
241
+ //# sourceMappingURL=Accordion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../../../src/accordion/Accordion.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,4DAAoC;AACpC,iCAMe;AACf,wCAAqD;AACrD,oCAAkD;AAClD,8CAA2C;AAE3C,MAAM,gBAAgB,GAAG,CACvB,aAA0B,EAC1B,gBAA6B,EAC7B,QAGuB,EACH,EAAE;;IACtB,MAAM,oBAAoB,GAAG,aAAa,CAAC,aAAa,CAAC;IACzD,IAAI,cAAc,GAAG,QAAQ,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;IACtE,IAAI,gBAAgB,GAAG,IAAI,CAAC;IAE5B,sDAAsD;IACtD,uDAAuD;IACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE;QAC3B,gCAAgC;QAChC,IAAI,CAAC,cAAc,EAAE;YACnB,OAAO,IAAI,CAAC;SACb;QACD,MAAM,IAAI,GAAG,MAAA,cAAc,CAAC,iBAAiB,0CAAE,YAAY,CAAC,MAAM,CAAC,CAAC;QACpE,IAAI,IAAI,KAAK,SAAS,EAAE;YACtB,gBAAgB,GAAG,cAAc,CAAC;YAClC,MAAM;SACP;QACD,cAAc,GAAG,QAAQ,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;KAC7D;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAEF,8CAA8C;AAC9C,MAAM,WAAW,GAAG,CAClB,gBAA6B,EAC7B,cAAkC,EACd,EAAE;;IACtB,IACE,cAA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G,gBAEd,iDACE,EAAE,EAAE,eAAe,EACnB,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,aAAa,mBACT,UAAU,mBACV,QAAQ,gBACX,KAAK,mBACF,cAAc,EAC7B,QAAQ,EAAE,CAAC,CAAC,gBAEZ,gDAAM,SAAS,EAAE,WAAW,iBACzB,WAAW,EACZ,uBAAC,8BAAsB,IACrB,SAAS,EAAE,IAAA,oBAAU,EAAC,gCAAgC,EAAE;oCACtD,eAAe,EAAE,UAAU;iCAC5B,CAAC,GACF,KACG,IACA,IACE,EACb,8CACE,EAAE,EAAE,cAAc,EAClB,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,cAAc,iBACZ,CAAC,UAAU,qBACP,eAAe,EAChC,IAAI,EAAC,QAAQ,gBAEb,8CAAK,GAAG,EAAE,eAAe,EAAE,SAAS,EAAC,kCAAkC,gBACrE,uBAAC,uBAAU,kBACT,OAAO,EAAC,aAAa,EACrB,SAAS,EAAC,kCAAkC,EAC5C,EAAE,EAAC,KAAK,gBAEP,QAAQ,IACE,IACT,IACF,KACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,6IAA6I;AAC7I,2CAA2C;AAC3C,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AAG/B,uCAAS;AAExC,kBAAe,SAAS,CAAC"}
@@ -0,0 +1,38 @@
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
29
+ }) : (function(o, m, k, k2) {
30
+ if (k2 === undefined) k2 = k;
31
+ o[k2] = m[k];
32
+ }));
33
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
34
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ __exportStar(require("./Accordion"), exports);
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/accordion/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AAEH,8CAA4B"}
package/lib/cjs/index.js CHANGED
@@ -34,6 +34,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
34
34
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
35
35
  };
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
+ __exportStar(require("./accordion"), exports);
37
38
  __exportStar(require("./button"), exports);
38
39
  __exportStar(require("./label"), exports);
39
40
  __exportStar(require("./banner"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB;AACzB,4CAA0B;AAC1B,6CAA2B;AAC3B,2CAAyB;AACzB,0CAAwB;AACxB,iDAA+B;AAC/B,gDAA8B;AAC9B,2CAAyB;AACzB,0CAAwB;AACxB,oDAAkC;AAClC,yCAAuB;AACvB,kDAAgC;AAChC,4CAA0B;AAC1B,iDAA+B;AAC/B,qDAAmC;AACnC,0CAAwB;AACxB,kDAAgC;AAChC,+CAA6B;AAC7B,6CAA2B;AAC3B,8CAA4B;AAC5B,6CAA2B;AAC3B,wCAAsB;AACtB,2CAAyB;AACzB,2CAAyB;AACzB,gDAA8B;AAC9B,+CAA6B;AAC7B,sDAAoC;AACpC,qDAAmC;AACnC,oDAAkC;AAClC,+CAA6B;AAC7B,2CAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AAEH,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB;AACzB,4CAA0B;AAC1B,6CAA2B;AAC3B,2CAAyB;AACzB,0CAAwB;AACxB,iDAA+B;AAC/B,gDAA8B;AAC9B,2CAAyB;AACzB,0CAAwB;AACxB,oDAAkC;AAClC,yCAAuB;AACvB,kDAAgC;AAChC,4CAA0B;AAC1B,iDAA+B;AAC/B,qDAAmC;AACnC,0CAAwB;AACxB,kDAAgC;AAChC,+CAA6B;AAC7B,6CAA2B;AAC3B,8CAA4B;AAC5B,6CAA2B;AAC3B,wCAAsB;AACtB,2CAAyB;AACzB,2CAAyB;AACzB,gDAA8B;AAC9B,+CAA6B;AAC7B,sDAAoC;AACpC,qDAAmC;AACnC,oDAAkC;AAClC,+CAA6B;AAC7B,2CAAyB"}
@@ -0,0 +1,237 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ /**
14
+ *
15
+ * Copyright (c) "Neo4j"
16
+ * Neo4j Sweden AB [http://neo4j.com]
17
+ *
18
+ * This file is part of Neo4j.
19
+ *
20
+ * Neo4j is free software: you can redistribute it and/or modify
21
+ * it under the terms of the GNU General Public License as published by
22
+ * the Free Software Foundation, either version 3 of the License, or
23
+ * (at your option) any later version.
24
+ *
25
+ * This program is distributed in the hope that it will be useful,
26
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28
+ * GNU General Public License for more details.
29
+ *
30
+ * You should have received a copy of the GNU General Public License
31
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
32
+ */
33
+ import classNames from 'classnames';
34
+ import { useCallback, useRef, useImperativeHandle, createContext, useContext, } from 'react';
35
+ import { forwardRef } from '../helpers';
36
+ import { ChevronDownIconOutline } from '../icons';
37
+ import { Typography } from '../typography';
38
+ const getAccordionItem = (activeElement, accordionElement, iterator) => {
39
+ var _a;
40
+ const accordionItemElement = activeElement.parentElement;
41
+ let newItemElement = iterator(accordionElement, accordionItemElement);
42
+ let childItemElement = null;
43
+ // Iterate over next element until we find a menu item
44
+ // Iterate a maximum of 10 times looking for an element
45
+ for (let i = 0; i < 10; i++) {
46
+ // Can't find new element, break
47
+ if (!newItemElement) {
48
+ return null;
49
+ }
50
+ const role = (_a = newItemElement.firstElementChild) === null || _a === void 0 ? void 0 : _a.getAttribute('role');
51
+ if (role === 'heading') {
52
+ childItemElement = newItemElement;
53
+ break;
54
+ }
55
+ newItemElement = iterator(accordionElement, newItemElement);
56
+ }
57
+ return childItemElement;
58
+ };
59
+ // Gets next sibling child, looping at the end
60
+ const nextElement = (accordionElement, currentElement) => {
61
+ var _a, _b;
62
+ if (currentElement === accordionElement ||
63
+ !(currentElement === null || currentElement === void 0 ? void 0 : currentElement.nextElementSibling)) {
64
+ const nextItem = accordionElement.firstChild;
65
+ const firstAccordionItemHeaderElement = (_a = accordionElement === null || accordionElement === void 0 ? void 0 : accordionElement.firstElementChild) === null || _a === void 0 ? void 0 : _a.firstElementChild;
66
+ return (firstAccordionItemHeaderElement === null || firstAccordionItemHeaderElement === void 0 ? void 0 : firstAccordionItemHeaderElement.className.includes('ndl-accordion-item-header-disabled'))
67
+ ? nextElement(accordionElement, nextItem)
68
+ : nextItem;
69
+ }
70
+ else if (currentElement === null || currentElement === void 0 ? void 0 : currentElement.nextElementSibling) {
71
+ const nextItem = currentElement.nextElementSibling;
72
+ return ((_b = currentElement.nextElementSibling.firstElementChild) === null || _b === void 0 ? void 0 : _b.className.includes('ndl-accordion-item-header-disabled'))
73
+ ? nextElement(accordionElement, nextItem)
74
+ : nextItem;
75
+ }
76
+ return null;
77
+ };
78
+ // Gets prev sibling child, looping at the top
79
+ const previousElement = (accordionElement, currentElement) => {
80
+ var _a, _b;
81
+ if (currentElement === accordionElement ||
82
+ !(currentElement === null || currentElement === void 0 ? void 0 : currentElement.previousElementSibling)) {
83
+ const prevItem = accordionElement.lastElementChild;
84
+ const lastAccordionItemHeaderElement = (_a = accordionElement === null || accordionElement === void 0 ? void 0 : accordionElement.lastElementChild) === null || _a === void 0 ? void 0 : _a.firstElementChild;
85
+ return (lastAccordionItemHeaderElement === null || lastAccordionItemHeaderElement === void 0 ? void 0 : lastAccordionItemHeaderElement.className.includes('ndl-accordion-item-header-disabled'))
86
+ ? previousElement(accordionElement, prevItem)
87
+ : prevItem;
88
+ }
89
+ else if (currentElement === null || currentElement === void 0 ? void 0 : currentElement.previousElementSibling) {
90
+ const prevItem = currentElement.previousElementSibling;
91
+ return ((_b = currentElement.previousElementSibling.firstElementChild) === null || _b === void 0 ? void 0 : _b.className.includes('ndl-accordion-item-header-disabled'))
92
+ ? previousElement(accordionElement, prevItem)
93
+ : prevItem;
94
+ }
95
+ return null;
96
+ };
97
+ const AccordionContext = createContext(null);
98
+ const useAccordionContext = () => {
99
+ const context = useContext(AccordionContext);
100
+ if (context === null) {
101
+ throw new Error('Accordion used without context');
102
+ }
103
+ return context;
104
+ };
105
+ const Accordion = forwardRef(function Accordion(_a, ref) {
106
+ var { as = 'div', children, className } = _a, restProps = __rest(_a, ["as", "children", "className"]);
107
+ const accordionRef = useRef(null);
108
+ // The following function includes code needed to be
109
+ // able to navigate with the arrow keys (not tab).
110
+ const handleKeyDown = (event) => {
111
+ const accordionElement = accordionRef.current;
112
+ if (!accordionElement) {
113
+ return;
114
+ }
115
+ const activeElement = document.activeElement;
116
+ if (event.key == 'ArrowDown') {
117
+ event.preventDefault();
118
+ event.stopPropagation();
119
+ const newFocusedElement = getAccordionItem(activeElement, accordionElement, nextElement);
120
+ const newHeader = newFocusedElement === null || newFocusedElement === void 0 ? void 0 : newFocusedElement.firstElementChild;
121
+ newHeader.focus();
122
+ }
123
+ else if (event.key == 'ArrowUp') {
124
+ event.preventDefault();
125
+ event.stopPropagation();
126
+ const newFocusedElement = getAccordionItem(activeElement, accordionElement, previousElement);
127
+ const newHeader = newFocusedElement === null || newFocusedElement === void 0 ? void 0 : newFocusedElement.firstElementChild;
128
+ newHeader.focus();
129
+ }
130
+ else if (event.key == ' ' || event.key == 'Enter') {
131
+ event.preventDefault();
132
+ event.stopPropagation();
133
+ const buttonElement = activeElement.getElementsByClassName('ndl-accordion-item-header-button')[0];
134
+ buttonElement.click();
135
+ }
136
+ };
137
+ useImperativeHandle(ref, () => accordionRef.current);
138
+ const classes = classNames('ndl-accordion', className);
139
+ const Component = as;
140
+ const { onChange, multiple } = restProps, rootProps = __rest(restProps, ["onChange", "multiple"]);
141
+ const contextValue = multiple
142
+ ? {
143
+ onChange,
144
+ multiple,
145
+ expandedItemIds: restProps.expandedItemIds,
146
+ }
147
+ : {
148
+ onChange,
149
+ multiple,
150
+ expandedItemId: restProps.expandedItemId,
151
+ };
152
+ return (_jsx(Component, Object.assign({}, rootProps, { className: classes, ref: accordionRef, onKeyDown: handleKeyDown }, { children: _jsx(AccordionContext.Provider, Object.assign({ value: contextValue }, { children: children })) })));
153
+ });
154
+ const createItemId = (type, id) => `ndl-accordionitem${type}id-${id}`;
155
+ const Item = (_a) => {
156
+ var { itemId, children, title, className = '', arrowPosition = 'right', disabled = false, onExpandedChange } = _a, restProps = __rest(_a, ["itemId", "children", "title", "className", "arrowPosition", "disabled", "onExpandedChange"]);
157
+ const contentRef = useRef(null);
158
+ const innerContentRef = useRef(null);
159
+ const itemElementId = createItemId('item', itemId);
160
+ const headerElementId = createItemId('header', itemId);
161
+ const buttonElementId = createItemId('button', itemId);
162
+ const panelElementId = createItemId('panel', itemId);
163
+ const context = useAccordionContext();
164
+ const { multiple } = context;
165
+ const isExpanded = multiple
166
+ ? context.expandedItemIds.includes(itemId)
167
+ : context.expandedItemId === itemId;
168
+ const handleOnClick = useCallback(() => {
169
+ var _a, _b;
170
+ if (disabled)
171
+ return;
172
+ // Custom callback to call.
173
+ if (onExpandedChange !== undefined)
174
+ onExpandedChange(!isExpanded);
175
+ if (multiple) {
176
+ const { expandedItemIds, onChange } = context;
177
+ // Multiple expanded.
178
+ if (isExpanded) {
179
+ // Remove from list.
180
+ const newArray = expandedItemIds.filter((activeId) => activeId !== itemId);
181
+ onChange(newArray);
182
+ }
183
+ else if (!isExpanded) {
184
+ // Add to list.
185
+ const newArray = [...expandedItemIds];
186
+ newArray.push(itemId);
187
+ onChange(newArray);
188
+ }
189
+ }
190
+ else {
191
+ const { onChange } = context;
192
+ // Single expanded.
193
+ if (isExpanded) {
194
+ // Set null.
195
+ onChange(null);
196
+ }
197
+ else if (!isExpanded) {
198
+ // Set to id.
199
+ onChange(itemId);
200
+ }
201
+ }
202
+ // The W3 WAI-ARIA states that focus can only happen on the header not the header button.
203
+ (_b = (_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.focus();
204
+ }, [isExpanded, multiple, disabled, itemId, onExpandedChange, context]);
205
+ const classes = classNames('ndl-accordion-item', className, {
206
+ 'ndl-accordion-item-disabled': disabled,
207
+ });
208
+ const headerClasses = classNames('ndl-accordion-item-header', {
209
+ 'ndl-accordion-item-header-disabled': disabled,
210
+ });
211
+ const iconClasses = classNames('ndl-accordion-item-header-icon-wrapper', {
212
+ 'ndl-accordion-item-header-icon-wrapper-right': arrowPosition === 'right',
213
+ });
214
+ const buttonClasses = classNames('ndl-accordion-item-header-button', {
215
+ 'ndl-accordion-item-header-button-disabled': disabled,
216
+ });
217
+ const titleClasses = classNames('ndl-accordion-item-header-button-title', {
218
+ 'ndl-accordion-item-header-button-title': disabled,
219
+ 'ndl-accordion-item-header-button-title-right': arrowPosition === 'right',
220
+ });
221
+ const contentClasses = classNames('ndl-accordion-item-content', {
222
+ 'ndl-accordion-item-content-expanded': isExpanded,
223
+ 'ndl-accordion-item-content-right': arrowPosition === 'right',
224
+ });
225
+ const headerTitle = _jsx("span", Object.assign({ className: titleClasses }, { children: title }));
226
+ return (_jsxs("div", Object.assign({}, restProps, { className: classes, id: itemElementId }, { children: [_jsx(Typography, Object.assign({ variant: "subheading-medium", className: headerClasses, role: "heading", tabIndex: disabled ? -1 : 0, id: headerElementId, "aria-level": "2" }, { children: _jsx("button", Object.assign({ id: buttonElementId, onClick: handleOnClick, className: buttonClasses, "aria-expanded": isExpanded, "aria-disabled": disabled, "aria-label": title, "aria-controls": panelElementId, tabIndex: -1 }, { children: _jsxs("span", Object.assign({ className: iconClasses }, { children: [headerTitle, _jsx(ChevronDownIconOutline, { className: classNames('ndl-accordion-item-header-icon', {
227
+ '-n-rotate-180': isExpanded,
228
+ }) })] })) })) })), _jsx("div", Object.assign({ id: panelElementId, ref: contentRef, className: contentClasses, "aria-hidden": !isExpanded, "aria-labelledby": buttonElementId, role: "region" }, { children: _jsx("div", Object.assign({ ref: innerContentRef, className: "ndl-accordion-item-content-inner" }, { children: _jsx(Typography, Object.assign({ variant: "body-medium", className: "n-text-palette-neutral-text-weak", as: "div" }, { children: children })) })) }))] })));
229
+ };
230
+ // Issue with TypeScript forwardRef and subcomponents: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34757#issuecomment-894053907
231
+ // Fixes issue with: Accordion.Item = Item;
232
+ const AccordionNamespace = Object.assign(Accordion, { Item });
233
+ // Can now use <Accordion ...> and <Accordion.Item ...>
234
+ // TODO: This should be fixed in other places of code.
235
+ export { AccordionNamespace as Accordion };
236
+ export default Accordion;
237
+ //# sourceMappingURL=Accordion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../../../src/accordion/Accordion.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EACL,WAAW,EACX,MAAM,EACN,mBAAmB,EACnB,aAAa,EACb,UAAU,GACX,MAAM,OAAO,CAAC;AACf,OAAO,EAAe,UAAU,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,gBAAgB,GAAG,CACvB,aAA0B,EAC1B,gBAA6B,EAC7B,QAGuB,EACH,EAAE;;IACtB,MAAM,oBAAoB,GAAG,aAAa,CAAC,aAAa,CAAC;IACzD,IAAI,cAAc,GAAG,QAAQ,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;IACtE,IAAI,gBAAgB,GAAG,IAAI,CAAC;IAE5B,sDAAsD;IACtD,uDAAuD;IACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE;QAC3B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E3C,eAAe,SAAS,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 './Accordion';
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/accordion/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,aAAa,CAAC"}
package/lib/esm/index.js CHANGED
@@ -18,6 +18,7 @@
18
18
  * You should have received a copy of the GNU General Public License
19
19
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
  */
21
+ export * from './accordion';
21
22
  export * from './button';
22
23
  export * from './label';
23
24
  export * from './banner';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;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a,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,60 @@
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
+ /// <reference types="react" />
22
+ import { ElementBase } from '../helpers';
23
+ export declare type AccordionItemId = string | number;
24
+ export interface AccordionBase extends ElementBase<HTMLDivElement> {
25
+ children: React.ReactNode | string;
26
+ className?: string;
27
+ as?: string | React.ComponentType<any>;
28
+ }
29
+ interface IsNotMultiple<T extends AccordionItemId> {
30
+ multiple: false | undefined;
31
+ expandedItemId: T | null;
32
+ onChange: (expandedItemId: T | null) => void;
33
+ }
34
+ interface IsMultiple<T extends AccordionItemId> {
35
+ multiple: true;
36
+ expandedItemIds: T[];
37
+ onChange: (expandedItemIds: T[]) => void;
38
+ }
39
+ declare type AccordionIsMultiple<T extends AccordionItemId> = AccordionBase & IsMultiple<T>;
40
+ declare type AccordionIsNotMultiple<T extends AccordionItemId> = AccordionBase & IsNotMultiple<T>;
41
+ export declare type AccordionProps<T extends AccordionItemId> = AccordionIsMultiple<T> | AccordionIsNotMultiple<T>;
42
+ declare const Accordion: <T extends AccordionItemId>(props: AccordionProps<T> & import("react").RefAttributes<unknown>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
43
+ export declare type AccordionArrowPosition = 'left' | 'right';
44
+ export interface AccordionItemProps<T extends AccordionItemId> extends ElementBase<HTMLDivElement> {
45
+ /** The component item id. */
46
+ itemId: T;
47
+ /** The title. */
48
+ title: string;
49
+ /** Callback function on component item expand/collapse change. */
50
+ onExpandedChange?: (expanded: boolean) => void;
51
+ /** Which side the accordion arrow will appear. */
52
+ arrowPosition?: AccordionArrowPosition;
53
+ /** If the component item is disabled. */
54
+ disabled?: boolean;
55
+ }
56
+ declare const AccordionNamespace: (<T extends AccordionItemId>(props: AccordionProps<T> & import("react").RefAttributes<unknown>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null) & {
57
+ Item: <T_1 extends AccordionItemId>({ itemId, children, title, className, arrowPosition, disabled, onExpandedChange, ...restProps }: AccordionItemProps<T_1>) => JSX.Element;
58
+ };
59
+ export { AccordionNamespace as Accordion };
60
+ export default Accordion;
@@ -0,0 +1,21 @@
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 './Accordion';
@@ -29,7 +29,7 @@ declare const GraphLabel: React.ForwardRefExoticComponent<{
29
29
  className?: string | undefined;
30
30
  /** If the element is selected */
31
31
  selected?: boolean | undefined;
32
- } & Omit<React.HTMLProps<HTMLButtonElement>, "ref" | "size" | "as" | "selected" | "onChange"> & {
32
+ } & Omit<React.HTMLProps<HTMLButtonElement>, "as" | "selected" | "size" | "onChange" | "ref"> & {
33
33
  as?: string | React.ComponentType<any> | undefined;
34
34
  } & React.RefAttributes<HTMLDivElement>>;
35
35
  export default GraphLabel;
@@ -18,6 +18,7 @@
18
18
  * You should have received a copy of the GNU General Public License
19
19
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
  */
21
+ export * from './accordion';
21
22
  export * from './button';
22
23
  export * from './label';
23
24
  export * from './banner';
@@ -33,7 +33,7 @@ export interface SideNavigationProps extends ElementBase<HTMLDivElement> {
33
33
  }
34
34
  export declare const SideNavigation: React.ForwardRefExoticComponent<SideNavigationProps & React.RefAttributes<HTMLDivElement>>;
35
35
  export declare type SideNavigationListProps = ElementBase<HTMLUListElement>;
36
- export declare const SideNavigationList: (props: Omit<React.HTMLProps<HTMLUListElement>, "ref" | "size" | "as" | "selected" | "onChange"> & {
36
+ export declare const SideNavigationList: (props: Omit<React.HTMLProps<HTMLUListElement>, "as" | "selected" | "size" | "onChange" | "ref"> & {
37
37
  as?: string | React.ComponentType<any> | undefined;
38
38
  } & React.RefAttributes<HTMLUListElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
39
39
  export interface SideNavigationItemProps extends ElementBase<HTMLAnchorElement> {
@@ -45,7 +45,7 @@ export interface SideNavigationItemProps extends ElementBase<HTMLAnchorElement>
45
45
  }
46
46
  export declare const SideNavigationItem: (props: SideNavigationItemProps & React.RefAttributes<any>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
47
47
  export declare type SideNavigationGroupHeaderProps = ElementBase<HTMLParagraphElement>;
48
- export declare const SideNavigationGroupHeader: (props: Omit<React.HTMLProps<HTMLParagraphElement>, "ref" | "size" | "as" | "selected" | "onChange"> & {
48
+ export declare const SideNavigationGroupHeader: (props: Omit<React.HTMLProps<HTMLParagraphElement>, "as" | "selected" | "size" | "onChange" | "ref"> & {
49
49
  as?: string | React.ComponentType<any> | undefined;
50
50
  } & React.RefAttributes<HTMLParagraphElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
51
51
  export default SideNavigation;
@@ -52,7 +52,7 @@ declare const TableNameSpace: (<T extends unknown>(props: {
52
52
  focusableCells?: boolean | undefined;
53
53
  tableProps: TableType<T>;
54
54
  components?: TableComponentsInterface<T> | undefined;
55
- } & Omit<ElementBase<HTMLDivElement>, "data" | "as" | "controls" | "headers" | "rows"> & import("react").RefAttributes<HTMLDivElement>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null) & {
55
+ } & Omit<ElementBase<HTMLDivElement>, "as" | "controls" | "data" | "headers" | "rows"> & import("react").RefAttributes<HTMLDivElement>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null) & {
56
56
  RowActions: (props: ElementBase<HTMLDivElement>) => JSX.Element;
57
57
  };
58
58
  export default TableNameSpace;
@@ -70,7 +70,7 @@ declare const Table: {
70
70
  } & UseTableInstanceProps<T> & Partial<UsePaginationInstanceProps<T>> & {
71
71
  state: Partial<PaginationTableState<T>>;
72
72
  rows: Row<T>[];
73
- } & UsePaginationInstanceProps<T> & Pick<UseTableInstanceProps<T>, "headerGroups"> & UseSortByInstanceProps<T>> & Omit<ElementBase<HTMLDivElement>, "data" | "controls" | "headers" | "rows">): JSX.Element;
73
+ } & UsePaginationInstanceProps<T> & Pick<UseTableInstanceProps<T>, "headerGroups"> & UseSortByInstanceProps<T>> & Omit<ElementBase<HTMLDivElement>, "controls" | "data" | "headers" | "rows">): JSX.Element;
74
74
  RowActions: (props: ElementBase<HTMLDivElement>) => JSX.Element;
75
75
  };
76
76
  export default Table;
@@ -20,7 +20,7 @@
20
20
  */
21
21
  /// <reference types="react" />
22
22
  import { AsType, ConditionalTypography } from './types';
23
- export declare const Typography: <TVar extends "code" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "label" | "subheading-large" | "subheading-medium" | "subheading-small" | "body-large" | "body-medium" | "body-small", TAs extends AsType = undefined>(props: {
23
+ export declare const Typography: <TVar extends "label" | "code" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "subheading-large" | "subheading-medium" | "subheading-small" | "body-large" | "body-medium" | "body-small", TAs extends AsType = undefined>(props: {
24
24
  as?: TAs | undefined;
25
25
  variant: TVar;
26
26
  } & ConditionalTypography<TAs, TVar>) => JSX.Element;
@@ -43,7 +43,7 @@ export interface ViewSelectorProps<T extends ViewSelectorID> extends ElementBase
43
43
  children: React.ReactNode | string;
44
44
  }
45
45
  export declare const ViewSelector: <T extends ViewSelectorID>(props: ViewSelectorProps<T> & React.RefAttributes<unknown>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
46
- export declare const ViewSelectorItem: React.ForwardRefExoticComponent<Omit<React.HTMLProps<HTMLElement>, "ref" | "size" | "as" | "selected" | "onChange"> & {
46
+ export declare const ViewSelectorItem: React.ForwardRefExoticComponent<Omit<React.HTMLProps<HTMLElement>, "as" | "selected" | "size" | "onChange" | "ref"> & {
47
47
  as?: string | React.ComponentType<any> | undefined;
48
48
  } & {
49
49
  value: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-ndl/react",
3
- "version": "1.9.0",
3
+ "version": "1.10.1",
4
4
  "sideEffects": false,
5
5
  "description": "React implementation of Neo4j Design System",
6
6
  "keywords": [
@@ -93,7 +93,7 @@
93
93
  "@floating-ui/react": "^0.24.2",
94
94
  "@heroicons/react": "2.0.13",
95
95
  "@neo4j-cypher/react-codemirror": "^1.0.1",
96
- "@neo4j-ndl/base": "^1.9.0",
96
+ "@neo4j-ndl/base": "^1.10.0",
97
97
  "@tanstack/react-table": "^8.9.3",
98
98
  "classnames": "^2.3.1",
99
99
  "date-fns": "^2.30.0",