@neo4j-ndl/react 4.8.3 → 4.8.5

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 (100) hide show
  1. package/lib/cjs/accordion/Accordion.js +1 -1
  2. package/lib/cjs/accordion/Accordion.js.map +1 -1
  3. package/lib/cjs/ai/prompt/Prompt.js +1 -1
  4. package/lib/cjs/ai/prompt/Prompt.js.map +1 -1
  5. package/lib/cjs/ai/suggestion/Suggestion.js +1 -1
  6. package/lib/cjs/ai/suggestion/Suggestion.js.map +1 -1
  7. package/lib/cjs/breadcrumbs/Breadcrumbs.js +1 -1
  8. package/lib/cjs/breadcrumbs/Breadcrumbs.js.map +1 -1
  9. package/lib/cjs/breadcrumbs/stories/breadcrumbs-header.story.js +1 -1
  10. package/lib/cjs/breadcrumbs/stories/breadcrumbs-header.story.js.map +1 -1
  11. package/lib/cjs/color-picker/ColorPicker.js +1 -1
  12. package/lib/cjs/color-picker/ColorPicker.js.map +1 -1
  13. package/lib/cjs/date-picker/DatePicker.js +2 -2
  14. package/lib/cjs/date-picker/DatePicker.js.map +1 -1
  15. package/lib/cjs/graph-label/GraphLabel.js +5 -1
  16. package/lib/cjs/graph-label/GraphLabel.js.map +1 -1
  17. package/lib/cjs/inline-edit/InlineEdit.js +1 -1
  18. package/lib/cjs/inline-edit/InlineEdit.js.map +1 -1
  19. package/lib/cjs/select/Select.js +2 -1
  20. package/lib/cjs/select/Select.js.map +1 -1
  21. package/lib/cjs/select-icon-button/SelectIconButton.js +1 -1
  22. package/lib/cjs/select-icon-button/SelectIconButton.js.map +1 -1
  23. package/lib/cjs/side-navigation/SideNavigation.js +1 -1
  24. package/lib/cjs/side-navigation/SideNavigation.js.map +1 -1
  25. package/lib/cjs/tabs/Tabs.js +1 -1
  26. package/lib/cjs/tabs/Tabs.js.map +1 -1
  27. package/lib/cjs/text-area/TextArea.js +13 -1
  28. package/lib/cjs/text-area/TextArea.js.map +1 -1
  29. package/lib/cjs/text-input/TextInput.js +21 -3
  30. package/lib/cjs/text-input/TextInput.js.map +1 -1
  31. package/lib/cjs/timezone-picker/stories/timezone-picker-dst-aware.story.js +2 -2
  32. package/lib/cjs/timezone-picker/stories/timezone-picker-dst-aware.story.js.map +1 -1
  33. package/lib/cjs/tooltip/Tooltip.js +1 -1
  34. package/lib/cjs/tooltip/Tooltip.js.map +1 -1
  35. package/lib/cjs/tree-view/TreeItemWrapper.js +1 -1
  36. package/lib/cjs/tree-view/TreeItemWrapper.js.map +1 -1
  37. package/lib/cjs/tree-view/TreeViewTextItem.js +2 -2
  38. package/lib/cjs/tree-view/TreeViewTextItem.js.map +1 -1
  39. package/lib/cjs/tree-view/stories/treeview-custom.story.js +1 -1
  40. package/lib/cjs/tree-view/stories/treeview-custom.story.js.map +1 -1
  41. package/lib/esm/accordion/Accordion.js +1 -1
  42. package/lib/esm/accordion/Accordion.js.map +1 -1
  43. package/lib/esm/ai/prompt/Prompt.js +1 -1
  44. package/lib/esm/ai/prompt/Prompt.js.map +1 -1
  45. package/lib/esm/ai/suggestion/Suggestion.js +1 -1
  46. package/lib/esm/ai/suggestion/Suggestion.js.map +1 -1
  47. package/lib/esm/breadcrumbs/Breadcrumbs.js +1 -1
  48. package/lib/esm/breadcrumbs/Breadcrumbs.js.map +1 -1
  49. package/lib/esm/breadcrumbs/stories/breadcrumbs-header.story.js +1 -1
  50. package/lib/esm/breadcrumbs/stories/breadcrumbs-header.story.js.map +1 -1
  51. package/lib/esm/color-picker/ColorPicker.js +1 -1
  52. package/lib/esm/color-picker/ColorPicker.js.map +1 -1
  53. package/lib/esm/date-picker/DatePicker.js +2 -2
  54. package/lib/esm/date-picker/DatePicker.js.map +1 -1
  55. package/lib/esm/graph-label/GraphLabel.js +5 -1
  56. package/lib/esm/graph-label/GraphLabel.js.map +1 -1
  57. package/lib/esm/inline-edit/InlineEdit.js +1 -1
  58. package/lib/esm/inline-edit/InlineEdit.js.map +1 -1
  59. package/lib/esm/select/Select.js +2 -1
  60. package/lib/esm/select/Select.js.map +1 -1
  61. package/lib/esm/select-icon-button/SelectIconButton.js +1 -1
  62. package/lib/esm/select-icon-button/SelectIconButton.js.map +1 -1
  63. package/lib/esm/side-navigation/SideNavigation.js +1 -1
  64. package/lib/esm/side-navigation/SideNavigation.js.map +1 -1
  65. package/lib/esm/tabs/Tabs.js +1 -1
  66. package/lib/esm/tabs/Tabs.js.map +1 -1
  67. package/lib/esm/text-area/TextArea.js +14 -2
  68. package/lib/esm/text-area/TextArea.js.map +1 -1
  69. package/lib/esm/text-input/TextInput.js +21 -3
  70. package/lib/esm/text-input/TextInput.js.map +1 -1
  71. package/lib/esm/timezone-picker/stories/timezone-picker-dst-aware.story.js +2 -2
  72. package/lib/esm/timezone-picker/stories/timezone-picker-dst-aware.story.js.map +1 -1
  73. package/lib/esm/tooltip/Tooltip.js +1 -1
  74. package/lib/esm/tooltip/Tooltip.js.map +1 -1
  75. package/lib/esm/tree-view/TreeItemWrapper.js +1 -1
  76. package/lib/esm/tree-view/TreeItemWrapper.js.map +1 -1
  77. package/lib/esm/tree-view/TreeViewTextItem.js +2 -2
  78. package/lib/esm/tree-view/TreeViewTextItem.js.map +1 -1
  79. package/lib/esm/tree-view/stories/treeview-custom.story.js +1 -1
  80. package/lib/esm/tree-view/stories/treeview-custom.story.js.map +1 -1
  81. package/lib/types/accordion/Accordion.d.ts.map +1 -1
  82. package/lib/types/ai/prompt/Prompt.d.ts.map +1 -1
  83. package/lib/types/ai/suggestion/Suggestion.d.ts.map +1 -1
  84. package/lib/types/breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  85. package/lib/types/breadcrumbs/stories/breadcrumbs-header.story.d.ts.map +1 -1
  86. package/lib/types/date-picker/DatePicker.d.ts.map +1 -1
  87. package/lib/types/graph-label/GraphLabel.d.ts.map +1 -1
  88. package/lib/types/inline-edit/InlineEdit.d.ts.map +1 -1
  89. package/lib/types/select/Select.d.ts.map +1 -1
  90. package/lib/types/select-icon-button/SelectIconButton.d.ts.map +1 -1
  91. package/lib/types/side-navigation/SideNavigation.d.ts.map +1 -1
  92. package/lib/types/tabs/Tabs.d.ts.map +1 -1
  93. package/lib/types/text-area/TextArea.d.ts.map +1 -1
  94. package/lib/types/text-input/TextInput.d.ts.map +1 -1
  95. package/lib/types/timezone-picker/stories/timezone-picker-dst-aware.story.d.ts.map +1 -1
  96. package/lib/types/tooltip/Tooltip.d.ts.map +1 -1
  97. package/lib/types/tree-view/TreeItemWrapper.d.ts.map +1 -1
  98. package/lib/types/tree-view/TreeViewTextItem.d.ts.map +1 -1
  99. package/lib/types/tree-view/stories/treeview-custom.story.d.ts.map +1 -1
  100. package/package.json +2 -2
@@ -30,14 +30,14 @@ const Component = () => {
30
30
  // Create summer and winter dates for DST demonstration
31
31
  const summerDate = new Date('2024-07-15T12:00:00'); // July (DST in effect)
32
32
  const winterDate = new Date('2024-01-15T12:00:00'); // January (Standard time)
33
- return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: '2rem' }, children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h3", { style: { marginBottom: '1rem' }, children: "DST-Aware Timezone Picker Demo" }), (0, jsx_runtime_1.jsx)("p", { style: { color: '#666', marginBottom: '1rem' }, children: "The timezone offsets change based on the reference date to account for Daylight Saving Time." })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: '1rem', marginBottom: '1rem' }, children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => setReferenceDate(summerDate), style: {
33
+ return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: '2rem' }, children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h3", { style: { marginBottom: '1rem' }, children: "DST-Aware Timezone Picker Demo" }), (0, jsx_runtime_1.jsx)("p", { style: { color: '#666', marginBottom: '1rem' }, children: "The timezone offsets change based on the reference date to account for Daylight Saving Time." })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: '1rem', marginBottom: '1rem' }, children: [(0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => setReferenceDate(summerDate), style: {
34
34
  backgroundColor: referenceDate === summerDate ? '#0066cc' : 'white',
35
35
  border: '1px solid #ccc',
36
36
  borderRadius: '4px',
37
37
  color: referenceDate === summerDate ? 'white' : 'black',
38
38
  cursor: 'pointer',
39
39
  padding: '0.5rem 1rem',
40
- }, children: "Summer Date (July 15, 2024)" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => setReferenceDate(winterDate), style: {
40
+ }, children: "Summer Date (July 15, 2024)" }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => setReferenceDate(winterDate), style: {
41
41
  backgroundColor: referenceDate === winterDate ? '#0066cc' : 'white',
42
42
  border: '1px solid #ccc',
43
43
  borderRadius: '4px',
@@ -1 +1 @@
1
- {"version":3,"file":"timezone-picker-dst-aware.story.js","sourceRoot":"","sources":["../../../../src/timezone-picker/stories/timezone-picker-dst-aware.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAkD;AAClD,iCAAiC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAC3C,IAAA,gBAAQ,EAAS,kBAAkB,CAAC,CAAC;IACvC,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAChD,IAAI,IAAI,CAAC,YAAY,CAAC,CACvB,CAAC;IAEF,uDAAuD;IACvD,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,uBAAuB;IAC3E,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,0BAA0B;IAE9E,OAAO,CACL,iCAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAA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E,SAAS;oBAC1B,YAAY,EAAE,KAAK;oBAEnB,OAAO,EAAE,MAAM;iBAChB,aAED,0CACE,oEAAmC,OAAE,gBAAgB,IACnD,EACJ,0CACE,iEAAgC,OAAE,aAAa,CAAC,kBAAkB,EAAE,IAClE,EACJ,0CACE,0DAAyB,uEAEvB,IACA,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { TimeZonePicker } from '@neo4j-ndl/react';\nimport { useState } from 'react';\n\nconst Component = () => {\n const [selectedTimeZone, setSelectedTimeZone] =\n useState<string>('Europe/Stockholm');\n const [referenceDate, setReferenceDate] = useState<Date>(\n new Date('2025-01-01'),\n );\n\n // Create summer and winter dates for DST demonstration\n const summerDate = new Date('2024-07-15T12:00:00'); // July (DST in effect)\n const winterDate = new Date('2024-01-15T12:00:00'); // January (Standard time)\n\n return (\n <div style={{ display: 'flex', flexDirection: 'column', gap: '2rem' }}>\n <div>\n <h3 style={{ marginBottom: '1rem' }}>DST-Aware Timezone Picker Demo</h3>\n <p style={{ color: '#666', marginBottom: '1rem' }}>\n The timezone offsets change based on the reference date to account for\n Daylight Saving Time.\n </p>\n </div>\n\n <div style={{ display: 'flex', gap: '1rem', marginBottom: '1rem' }}>\n <button\n onClick={() => setReferenceDate(summerDate)}\n style={{\n backgroundColor: referenceDate === summerDate ? '#0066cc' : 'white',\n border: '1px solid #ccc',\n borderRadius: '4px',\n color: referenceDate === summerDate ? 'white' : 'black',\n cursor: 'pointer',\n padding: '0.5rem 1rem',\n }}\n >\n Summer Date (July 15, 2024)\n </button>\n <button\n onClick={() => setReferenceDate(winterDate)}\n style={{\n backgroundColor: referenceDate === winterDate ? '#0066cc' : 'white',\n border: '1px solid #ccc',\n borderRadius: '4px',\n color: referenceDate === winterDate ? 'white' : 'black',\n cursor: 'pointer',\n padding: '0.5rem 1rem',\n }}\n >\n Winter Date (January 15, 2024)\n </button>\n </div>\n\n <TimeZonePicker\n label=\"Select Timezone\"\n value={selectedTimeZone}\n onChange={setSelectedTimeZone}\n referenceDate={referenceDate}\n />\n\n <div\n style={{\n backgroundColor: '#f5f5f5',\n borderRadius: '4px',\n\n padding: '1rem',\n }}\n >\n <p>\n <strong>Selected Timezone:</strong> {selectedTimeZone}\n </p>\n <p>\n <strong>Reference Date:</strong> {referenceDate.toLocaleDateString()}\n </p>\n <p>\n <strong>Example:</strong> New York shows GMT-4 in summer (EDT) and\n GMT-5 in winter (EST)\n </p>\n </div>\n </div>\n );\n};\n\nexport default Component;\n"]}
1
+ {"version":3,"file":"timezone-picker-dst-aware.story.js","sourceRoot":"","sources":["../../../../src/timezone-picker/stories/timezone-picker-dst-aware.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAkD;AAClD,iCAAiC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAC3C,IAAA,gBAAQ,EAAS,kBAAkB,CAAC,CAAC;IACvC,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAChD,IAAI,IAAI,CAAC,YAAY,CAAC,CACvB,CAAC;IAEF,uDAAuD;IACvD,MAAM,UAAU,GAAG,IAAI,IA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OAAO;4BACvD,MAAM,EAAE,SAAS;4BACjB,OAAO,EAAE,aAAa;yBACvB,+CAGM,IACL,EAEN,uBAAC,sBAAc,IACb,KAAK,EAAC,iBAAiB,EACvB,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,mBAAmB,EAC7B,aAAa,EAAE,aAAa,GAC5B,EAEF,iCACE,KAAK,EAAE;oBACL,eAAe,EAAE,SAAS;oBAC1B,YAAY,EAAE,KAAK;oBAEnB,OAAO,EAAE,MAAM;iBAChB,aAED,0CACE,oEAAmC,OAAE,gBAAgB,IACnD,EACJ,0CACE,iEAAgC,OAAE,aAAa,CAAC,kBAAkB,EAAE,IAClE,EACJ,0CACE,0DAAyB,uEAEvB,IACA,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { TimeZonePicker } from '@neo4j-ndl/react';\nimport { useState } from 'react';\n\nconst Component = () => {\n const [selectedTimeZone, setSelectedTimeZone] =\n useState<string>('Europe/Stockholm');\n const [referenceDate, setReferenceDate] = useState<Date>(\n new Date('2025-01-01'),\n );\n\n // Create summer and winter dates for DST demonstration\n const summerDate = new Date('2024-07-15T12:00:00'); // July (DST in effect)\n const winterDate = new Date('2024-01-15T12:00:00'); // January (Standard time)\n\n return (\n <div style={{ display: 'flex', flexDirection: 'column', gap: '2rem' }}>\n <div>\n <h3 style={{ marginBottom: '1rem' }}>DST-Aware Timezone Picker Demo</h3>\n <p style={{ color: '#666', marginBottom: '1rem' }}>\n The timezone offsets change based on the reference date to account for\n Daylight Saving Time.\n </p>\n </div>\n\n <div style={{ display: 'flex', gap: '1rem', marginBottom: '1rem' }}>\n <button\n type=\"button\"\n onClick={() => setReferenceDate(summerDate)}\n style={{\n backgroundColor: referenceDate === summerDate ? '#0066cc' : 'white',\n border: '1px solid #ccc',\n borderRadius: '4px',\n color: referenceDate === summerDate ? 'white' : 'black',\n cursor: 'pointer',\n padding: '0.5rem 1rem',\n }}\n >\n Summer Date (July 15, 2024)\n </button>\n <button\n type=\"button\"\n onClick={() => setReferenceDate(winterDate)}\n style={{\n backgroundColor: referenceDate === winterDate ? '#0066cc' : 'white',\n border: '1px solid #ccc',\n borderRadius: '4px',\n color: referenceDate === winterDate ? 'white' : 'black',\n cursor: 'pointer',\n padding: '0.5rem 1rem',\n }}\n >\n Winter Date (January 15, 2024)\n </button>\n </div>\n\n <TimeZonePicker\n label=\"Select Timezone\"\n value={selectedTimeZone}\n onChange={setSelectedTimeZone}\n referenceDate={referenceDate}\n />\n\n <div\n style={{\n backgroundColor: '#f5f5f5',\n borderRadius: '4px',\n\n padding: '1rem',\n }}\n >\n <p>\n <strong>Selected Timezone:</strong> {selectedTimeZone}\n </p>\n <p>\n <strong>Reference Date:</strong> {referenceDate.toLocaleDateString()}\n </p>\n <p>\n <strong>Example:</strong> New York shows GMT-4 in summer (EDT) and\n GMT-5 in winter (EST)\n </p>\n </div>\n </div>\n );\n};\n\nexport default Component;\n"]}
@@ -85,7 +85,7 @@ const TooltipTrigger = (_a) => {
85
85
  const props = Object.assign(Object.assign(Object.assign({ className: triggerClasses }, htmlAttributes), childrenProps), { ref: mergedRefs });
86
86
  return (0, react_2.cloneElement)(children, context.getReferenceProps(props));
87
87
  }
88
- return ((0, jsx_runtime_1.jsx)("button", Object.assign({ className: triggerClasses, style: style, ref: mergedRefs }, context.getReferenceProps(htmlAttributes), restProps, { children: children })));
88
+ return ((0, jsx_runtime_1.jsx)("button", Object.assign({ type: "button", className: triggerClasses, style: style, ref: mergedRefs }, context.getReferenceProps(htmlAttributes), restProps, { children: children })));
89
89
  };
90
90
  const TooltipContent = (_a) => {
91
91
  var { children, style, htmlAttributes, className, ref } = _a, restProps = __rest(_a, ["children", "style", "htmlAttributes", "className", "ref"]);
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAO4B;AAC5B,4DAAoC;AAEpC,iCAAqD;AAGrD,0DAAsD;AACtD,6DAA6D;AAC7D,oCAA0C;AAC1C,8CAAoE;AACpE,+CAA8E;AA+B9E,MAAM,gBAAgB,GAAG,CAAC,EACxB,QAAQ,EACR,UAAU,GAAG,KAAK,EAClB,IAAI,EACJ,aAAa,EACb,SAAS,EACT,MAAM,EACN,YAAY,EACZ,UAAU,EAAE,cAAc,EAC1B,gBAAgB,EAAE,YAAY,EAC9B,UAAU,EACV,2BAA2B,EAC3B,iBAAiB,GACJ,EAAE,EAAE;IACjB,MAAM,cAAc,GAAG,IAAA,kCAAiB,GAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC;IACvD,MAAM,UAAU,GAAG,CAAC,cAAc,CAAC;IAEnC,MAAM,OAAO,GAAG,IAAA,wBAAU,EAAC;QACzB,iBAAiB;QACjB,UAAU;QACV,UAAU;QACV,aAAa;QACb,2HAA2H;QAC3H,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;QAC5C,UAAU,EAAE,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,UAAU;QACxC,YAAY;QACZ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CAAC,MAAM,CAAC,gBAAgB,EAAE;IAC9C,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,cAAc;CACxB,CAAC,CAAC;AAEM,0BAAO","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n type AutoUpdateOptions,\n FloatingFocusManager,\n FloatingPortal,\n type Placement,\n type UseFloatingOptions,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { cloneElement, isValidElement } from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { useNeedleTheme } from '../theme';\nimport { Typography, type TypographyVariants } from '../typography';\nimport { TooltipContext, useTooltip, useTooltipContext } from './use-tooltip';\n\nexport type TooltipProps = {\n /** Content displayed inside the tooltip. Wraps `Tooltip.Trigger`, `Tooltip.Content`, and optional parts */\n children: React.ReactNode;\n /** Whether the tooltip is disabled */\n isDisabled?: boolean;\n /** Whether the tooltip should be open on first render */\n isInitialOpen?: boolean;\n /** Placement of the tooltip content relative to the trigger */\n placement?: Placement;\n /** Controls the open state . If omitted, the tooltip manages its own state */\n isOpen?: boolean;\n /** Visual style of the tooltip content. `simple` renders plain text, `rich` renders a composable panel */\n type: 'simple' | 'rich';\n /** Whether the content is rendered in a portal. */\n isPortaled?: boolean;\n /** Callback fired when the open state changes, if omitted, the tooltip manages its own state using internal hooks */\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n /** Positioning strategy of the tooltip. Defaults to `fixed` when inside a dialog, otherwise `absolute` */\n floatingStrategy?: 'absolute' | 'fixed';\n /** Hover open/close delays in milliseconds */\n hoverDelay?: {\n open: number;\n close: number;\n };\n /** Whether the tooltip should close when the reference element is clicked. Useful when the trigger moves after click. */\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n};\n\nconst TooltipComponent = ({\n children,\n isDisabled = false,\n type,\n isInitialOpen,\n placement,\n isOpen,\n onOpenChange,\n isPortaled: isPortaledProp,\n floatingStrategy: strategyProp,\n hoverDelay,\n shouldCloseOnReferenceClick,\n autoUpdateOptions,\n}: TooltipProps) => {\n const isInsideDialog = useIsInsideDialog();\n const strategy = isInsideDialog ? 'fixed' : 'absolute';\n const isPortaled = !isInsideDialog;\n\n const tooltip = useTooltip({\n autoUpdateOptions,\n hoverDelay,\n isDisabled,\n isInitialOpen,\n // if isDisabled is true tooltip will not open otherwise either controlled or uncontrolled depending on if isOpen is passed\n isOpen: isDisabled === true ? false : isOpen,\n isPortaled: isPortaledProp ?? isPortaled,\n onOpenChange,\n placement,\n shouldCloseOnReferenceClick,\n strategy: strategyProp ?? strategy,\n type,\n });\n\n return (\n <TooltipContext.Provider value={tooltip}>\n {children}\n </TooltipContext.Provider>\n );\n};\n\nTooltipComponent.displayName = 'Tooltip';\n\ntype TooltipTriggerProps = {\n /** Content displayed inside the trigger element */\n children: React.ReactNode;\n /** Whether the trigger element can be any element without an extra button wrapper. The child element will be cloned with the necessary trigger props and merged refs */\n hasButtonWrapper?: boolean;\n};\n\nconst TooltipTrigger = ({\n children,\n hasButtonWrapper = false,\n htmlAttributes,\n className,\n style,\n ref,\n ...restProps\n}: CommonProps<'button', TooltipTriggerProps>) => {\n const context = useTooltipContext();\n\n // Example from floating-ui\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const childrenProps = (children as any).props;\n const mergedRefs = useMergeRefs([\n context.refs.setReference,\n ref,\n childrenProps?.ref,\n ]);\n\n const triggerClasses = classNames(\n {\n 'ndl-closed': !context.isOpen,\n 'ndl-open': context.isOpen,\n },\n 'ndl-tooltip-trigger',\n className,\n );\n\n // `hasButtonWrapper=true` allows the user to pass any element as the anchor\n if (hasButtonWrapper && isValidElement(children)) {\n const props: Record<string, unknown> = {\n className: triggerClasses,\n ...htmlAttributes,\n ...childrenProps,\n ref: mergedRefs,\n };\n return cloneElement(children, context.getReferenceProps(props));\n }\n\n return (\n <button\n className={triggerClasses}\n style={style}\n ref={mergedRefs}\n {...context.getReferenceProps(htmlAttributes)}\n {...restProps}\n >\n {children}\n </button>\n );\n};\n\ntype TooltipContentProps = {\n /** Content displayed inside the tooltip */\n children: React.ReactNode;\n};\n\nconst TooltipContent = ({\n children,\n style,\n htmlAttributes,\n className,\n ref,\n ...restProps\n}: CommonProps<'div', TooltipContentProps>) => {\n const context = useTooltipContext();\n const mergedRef = useMergeRefs([context.refs.setFloating, ref]);\n const { themeClassName } = useNeedleTheme();\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-content', themeClassName, className, {\n 'ndl-tooltip-content-rich': context.type === 'rich',\n 'ndl-tooltip-content-simple': context.type === 'simple',\n });\n\n if (context.type === 'simple') {\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps(htmlAttributes)}\n >\n <Typography variant=\"body-medium\">{children}</Typography>\n </div>\n </ConditionalWrap>\n );\n }\n\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <FloatingFocusManager\n context={context.context}\n returnFocus={true}\n modal={false}\n initialFocus={-1}\n closeOnFocusOut\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps(htmlAttributes)}\n >\n {children}\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\ntype TooltipHeaderProps = {\n /** Content displayed inside the header */\n children: React.ReactNode;\n /** @deprecated Use `typographyVariant` instead */\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n typographyVariant?: TypographyVariants;\n};\n\nconst TooltipHeader = ({\n children,\n passThroughProps,\n typographyVariant = 'subheading-medium',\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipHeaderProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-header', className);\n\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant={typographyVariant}\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\nexport type TooltipBodyProps = {\n /** Content displayed inside the body */\n children: React.ReactNode;\n /** Additional props to pass to the Typography component */\n // TODO v5: Deprecate passThroughProps and use restProps instead\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n};\n\nconst TooltipBody = ({\n children,\n className,\n style,\n htmlAttributes,\n passThroughProps,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipBodyProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-body', className);\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant=\"body-medium\"\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\ntype ToolTipActionsProps = {\n /** Content displayed inside the actions container */\n children: React.ReactNode;\n};\n\nconst Actions = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ToolTipActionsProps>) => {\n const context = useTooltipContext();\n const mergedRefs = useMergeRefs([context.refs.setFloating, ref]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-actions', className);\n\n return (\n <div\n className={classes}\n ref={mergedRefs}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nconst Tooltip = Object.assign(TooltipComponent, {\n Actions: Actions,\n Body: TooltipBody,\n Content: TooltipContent,\n Header: TooltipHeader,\n Trigger: TooltipTrigger,\n});\n\nexport { Tooltip };\n"]}
1
+ {"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAO4B;AAC5B,4DAAoC;AAEpC,iCAAqD;AAGrD,0DAAsD;AACtD,6DAA6D;AAC7D,oCAA0C;AAC1C,8CAAoE;AACpE,+CAA8E;AA+B9E,MAAM,gBAAgB,GAAG,CAAC,EACxB,QAAQ,EACR,UAAU,GAAG,KAAK,EAClB,IAAI,EACJ,aAAa,EACb,SAAS,EACT,MAAM,EACN,YAAY,EACZ,UAAU,EAAE,cAAc,EAC1B,gBAAgB,EAAE,YAAY,EAC9B,UAAU,EACV,2BAA2B,EAC3B,iBAAiB,GACJ,EAAE,EAAE;IACjB,MAAM,cAAc,GAAG,IAAA,kCAAiB,GAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC;IACvD,MAAM,UAAU,GAAG,CAAC,cAAc,CAAC;IAEnC,MAAM,OAAO,GAAG,IAAA,wBAAU,EAAC;QACzB,iBAAiB;QACjB,UAAU;QACV,UAAU;QACV,aAAa;QACb,2HAA2H;QAC3H,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,KA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,UAAU,EACf,KAAK,EAAE,KAAK,IACR,SAAS,EACT,cAAc,cAEjB,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE;IAC9C,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,cAAc;CACxB,CAAC,CAAC;AAEM,0BAAO","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n type AutoUpdateOptions,\n FloatingFocusManager,\n FloatingPortal,\n type Placement,\n type UseFloatingOptions,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { cloneElement, isValidElement } from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { useNeedleTheme } from '../theme';\nimport { Typography, type TypographyVariants } from '../typography';\nimport { TooltipContext, useTooltip, useTooltipContext } from './use-tooltip';\n\nexport type TooltipProps = {\n /** Content displayed inside the tooltip. Wraps `Tooltip.Trigger`, `Tooltip.Content`, and optional parts */\n children: React.ReactNode;\n /** Whether the tooltip is disabled */\n isDisabled?: boolean;\n /** Whether the tooltip should be open on first render */\n isInitialOpen?: boolean;\n /** Placement of the tooltip content relative to the trigger */\n placement?: Placement;\n /** Controls the open state . If omitted, the tooltip manages its own state */\n isOpen?: boolean;\n /** Visual style of the tooltip content. `simple` renders plain text, `rich` renders a composable panel */\n type: 'simple' | 'rich';\n /** Whether the content is rendered in a portal. */\n isPortaled?: boolean;\n /** Callback fired when the open state changes, if omitted, the tooltip manages its own state using internal hooks */\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n /** Positioning strategy of the tooltip. Defaults to `fixed` when inside a dialog, otherwise `absolute` */\n floatingStrategy?: 'absolute' | 'fixed';\n /** Hover open/close delays in milliseconds */\n hoverDelay?: {\n open: number;\n close: number;\n };\n /** Whether the tooltip should close when the reference element is clicked. Useful when the trigger moves after click. */\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n};\n\nconst TooltipComponent = ({\n children,\n isDisabled = false,\n type,\n isInitialOpen,\n placement,\n isOpen,\n onOpenChange,\n isPortaled: isPortaledProp,\n floatingStrategy: strategyProp,\n hoverDelay,\n shouldCloseOnReferenceClick,\n autoUpdateOptions,\n}: TooltipProps) => {\n const isInsideDialog = useIsInsideDialog();\n const strategy = isInsideDialog ? 'fixed' : 'absolute';\n const isPortaled = !isInsideDialog;\n\n const tooltip = useTooltip({\n autoUpdateOptions,\n hoverDelay,\n isDisabled,\n isInitialOpen,\n // if isDisabled is true tooltip will not open otherwise either controlled or uncontrolled depending on if isOpen is passed\n isOpen: isDisabled === true ? false : isOpen,\n isPortaled: isPortaledProp ?? isPortaled,\n onOpenChange,\n placement,\n shouldCloseOnReferenceClick,\n strategy: strategyProp ?? strategy,\n type,\n });\n\n return (\n <TooltipContext.Provider value={tooltip}>\n {children}\n </TooltipContext.Provider>\n );\n};\n\nTooltipComponent.displayName = 'Tooltip';\n\ntype TooltipTriggerProps = {\n /** Content displayed inside the trigger element */\n children: React.ReactNode;\n /** Whether the trigger element can be any element without an extra button wrapper. The child element will be cloned with the necessary trigger props and merged refs */\n hasButtonWrapper?: boolean;\n};\n\nconst TooltipTrigger = ({\n children,\n hasButtonWrapper = false,\n htmlAttributes,\n className,\n style,\n ref,\n ...restProps\n}: CommonProps<'button', TooltipTriggerProps>) => {\n const context = useTooltipContext();\n\n // Example from floating-ui\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const childrenProps = (children as any).props;\n const mergedRefs = useMergeRefs([\n context.refs.setReference,\n ref,\n childrenProps?.ref,\n ]);\n\n const triggerClasses = classNames(\n {\n 'ndl-closed': !context.isOpen,\n 'ndl-open': context.isOpen,\n },\n 'ndl-tooltip-trigger',\n className,\n );\n\n // `hasButtonWrapper=true` allows the user to pass any element as the anchor\n if (hasButtonWrapper && isValidElement(children)) {\n const props: Record<string, unknown> = {\n className: triggerClasses,\n ...htmlAttributes,\n ...childrenProps,\n ref: mergedRefs,\n };\n return cloneElement(children, context.getReferenceProps(props));\n }\n\n return (\n <button\n type=\"button\"\n className={triggerClasses}\n style={style}\n ref={mergedRefs}\n {...context.getReferenceProps(htmlAttributes)}\n {...restProps}\n >\n {children}\n </button>\n );\n};\n\ntype TooltipContentProps = {\n /** Content displayed inside the tooltip */\n children: React.ReactNode;\n};\n\nconst TooltipContent = ({\n children,\n style,\n htmlAttributes,\n className,\n ref,\n ...restProps\n}: CommonProps<'div', TooltipContentProps>) => {\n const context = useTooltipContext();\n const mergedRef = useMergeRefs([context.refs.setFloating, ref]);\n const { themeClassName } = useNeedleTheme();\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-content', themeClassName, className, {\n 'ndl-tooltip-content-rich': context.type === 'rich',\n 'ndl-tooltip-content-simple': context.type === 'simple',\n });\n\n if (context.type === 'simple') {\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps(htmlAttributes)}\n >\n <Typography variant=\"body-medium\">{children}</Typography>\n </div>\n </ConditionalWrap>\n );\n }\n\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <FloatingFocusManager\n context={context.context}\n returnFocus={true}\n modal={false}\n initialFocus={-1}\n closeOnFocusOut\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps(htmlAttributes)}\n >\n {children}\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\ntype TooltipHeaderProps = {\n /** Content displayed inside the header */\n children: React.ReactNode;\n /** @deprecated Use `typographyVariant` instead */\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n typographyVariant?: TypographyVariants;\n};\n\nconst TooltipHeader = ({\n children,\n passThroughProps,\n typographyVariant = 'subheading-medium',\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipHeaderProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-header', className);\n\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant={typographyVariant}\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\nexport type TooltipBodyProps = {\n /** Content displayed inside the body */\n children: React.ReactNode;\n /** Additional props to pass to the Typography component */\n // TODO v5: Deprecate passThroughProps and use restProps instead\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n};\n\nconst TooltipBody = ({\n children,\n className,\n style,\n htmlAttributes,\n passThroughProps,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipBodyProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-body', className);\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant=\"body-medium\"\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\ntype ToolTipActionsProps = {\n /** Content displayed inside the actions container */\n children: React.ReactNode;\n};\n\nconst Actions = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ToolTipActionsProps>) => {\n const context = useTooltipContext();\n const mergedRefs = useMergeRefs([context.refs.setFloating, ref]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-actions', className);\n\n return (\n <div\n className={classes}\n ref={mergedRefs}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nconst Tooltip = Object.assign(TooltipComponent, {\n Actions: Actions,\n Body: TooltipBody,\n Content: TooltipContent,\n Header: TooltipHeader,\n Trigger: TooltipTrigger,\n});\n\nexport { Tooltip };\n"]}
@@ -173,7 +173,7 @@ function TreeItemWrapperInner(_a) {
173
173
  'ndl-tree-view-list-item': true,
174
174
  'ndl-tree-view-list-item-disable-interaction': shouldDisableInteraction,
175
175
  'ndl-tree-view-list-item-placeholder': isGhost,
176
- }), style: Object.assign(Object.assign({}, style), { paddingLeft: isIndicator ? `${depth * indentationWidth}px` : 0 }), role: "treeitem", onFocus: onFocus, "aria-selected": item.isSelected && !item.isSkeletonLoading, "aria-expanded": item.canHaveSubItems ? !item.isCollapsed : undefined, onKeyDown: (event) => onWrapperKeyDown(event, shouldDisableInteraction !== null && shouldDisableInteraction !== void 0 ? shouldDisableInteraction : false, wrapperRef, onCollapse, item), children: (0, jsx_runtime_1.jsxs)("div", { role: "presentation", className: "ndl-tree-view-list-item-content", ref: ref, onKeyDown: (event) => onInnerDivKeyDown(event, shouldDisableInteraction !== null && shouldDisableInteraction !== void 0 ? shouldDisableInteraction : false, wrapperRef), children: [!shouldDisableSorting && ((0, jsx_runtime_1.jsx)("button", Object.assign({ className: "ndl-tree-view-drag-handle", ref: setActivatorNodeRef, "aria-label": "Pick up" }, dragHandleProps, { tabIndex: tabIndex, children: (0, jsx_runtime_1.jsx)(icons_1.DragIcon, {}) }))), trails.map((trail, index) => {
176
+ }), style: Object.assign(Object.assign({}, style), { paddingLeft: isIndicator ? `${depth * indentationWidth}px` : 0 }), role: "treeitem", onFocus: onFocus, "aria-selected": item.isSelected && !item.isSkeletonLoading, "aria-expanded": item.canHaveSubItems ? !item.isCollapsed : undefined, onKeyDown: (event) => onWrapperKeyDown(event, shouldDisableInteraction !== null && shouldDisableInteraction !== void 0 ? shouldDisableInteraction : false, wrapperRef, onCollapse, item), children: (0, jsx_runtime_1.jsxs)("div", { role: "presentation", className: "ndl-tree-view-list-item-content", ref: ref, onKeyDown: (event) => onInnerDivKeyDown(event, shouldDisableInteraction !== null && shouldDisableInteraction !== void 0 ? shouldDisableInteraction : false, wrapperRef), children: [!shouldDisableSorting && ((0, jsx_runtime_1.jsx)("button", Object.assign({ type: "button", className: "ndl-tree-view-drag-handle", ref: setActivatorNodeRef, "aria-label": "Pick up" }, dragHandleProps, { tabIndex: tabIndex, children: (0, jsx_runtime_1.jsx)(icons_1.DragIcon, {}) }))), trails.map((trail, index) => {
177
177
  return (0, jsx_runtime_1.jsx)(TreeViewTrail_1.Trail, { variant: trail }, index);
178
178
  }), children] }) }));
179
179
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TreeItemWrapper.js","sourceRoot":"","sources":["../../../src/tree-view/TreeItemWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AAEpC,iCAA+B;AAE/B,4CAA+E;AAC/E,oCAAoC;AACpC,6EAKsC;AAEtC,mDAAwC;AAExC;;;;;;;;;GASG;AAEH,MAAM,gBAAgB,GAAG,CACvB,KAA0B,EAC1B,wBAAiC,EACjC,UAA+C,EAC/C,UAAoC,EACpC,IAAuC,EACvC,EAAE;IACF,IAAI,wBAAwB,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC5D,OAA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AoB,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useRef } from 'react';\n\nimport { findFocusableChildren, findFocusableSibling } from '../_common/utils';\nimport { DragIcon } from '../icons';\nimport {\n focusCellInNextRow,\n focusCellInPreviousRow,\n focusNextRow,\n focusPreviousRow,\n} from './tree-view-keyboard-helpers';\nimport { type TreeItem, type TreeItemComponentProps } from './tree-view-types';\nimport { Trail } from './TreeViewTrail';\n\n/**\n * Handles keydown events for when the item itself is focused (wrapperRef.current)\n * Moves the focus between the item and its children as well as toggles collapsing of the item\n * @param event\n * @param shouldDisableInteraction\n * @param wrapperRef\n * @param onCollapse\n * @param item\n * @returns\n */\n\nconst onWrapperKeyDown = (\n event: React.KeyboardEvent,\n shouldDisableInteraction: boolean,\n wrapperRef: React.RefObject<HTMLElement | null>,\n onCollapse: (() => void) | undefined,\n item: TreeItem<Record<string, unknown>>,\n) => {\n if (shouldDisableInteraction || wrapperRef.current === null) {\n return;\n }\n\n if (event.key === 'Enter' && onCollapse) {\n onCollapse();\n } else if (event.key === 'ArrowRight') {\n event.preventDefault();\n if (item.canHaveSubItems && item.isCollapsed && onCollapse) {\n onCollapse();\n } else {\n const focusable = findFocusableChildren(wrapperRef.current);\n const [firstElement] = focusable;\n if (firstElement instanceof HTMLElement) {\n firstElement.focus();\n }\n }\n\n event.preventDefault();\n } else if (event.key === 'ArrowLeft') {\n event.preventDefault();\n if (item.canHaveSubItems && !item.isCollapsed && onCollapse) {\n onCollapse();\n } else {\n focusPreviousRow(wrapperRef.current);\n }\n } else if (event.key === 'ArrowDown') {\n event.preventDefault();\n focusNextRow(wrapperRef.current);\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n focusPreviousRow(wrapperRef.current);\n }\n};\n\n/**\n * Handles keydown events for when one of the items children is focused\n * Moves the focus between the children of the item and up to the parent if needed.\n * Stops the event from propagating to the parent since it has it own keydown handler\n * The parent is the wrapperRef.current and uses onWrapperKeyDown\n * @param event\n * @param shouldDisableInteraction\n * @param wrapperRef\n */\nconst onInnerDivKeyDown = (\n event: React.KeyboardEvent,\n shouldDisableInteraction: boolean,\n wrapperRef: React.RefObject<HTMLElement | null>,\n) => {\n if (shouldDisableInteraction) {\n return;\n }\n event.stopPropagation();\n if (event.key === 'ArrowRight') {\n event.preventDefault();\n const nextElement = findFocusableSibling(wrapperRef, 'next');\n if (nextElement) {\n nextElement.focus();\n }\n } else if (event.key === 'ArrowLeft') {\n event.preventDefault();\n const previousElement = findFocusableSibling(wrapperRef, 'prev');\n if (previousElement) {\n previousElement.focus();\n } else {\n wrapperRef.current?.focus();\n }\n } else if (event.key === 'ArrowDown' && wrapperRef.current !== null) {\n event.preventDefault();\n focusCellInNextRow(wrapperRef.current);\n } else if (event.key === 'ArrowUp' && wrapperRef.current !== null) {\n event.preventDefault();\n focusCellInPreviousRow(wrapperRef.current);\n } else if (event.shiftKey && event.key === 'Tab') {\n const previousElement = findFocusableSibling(wrapperRef, 'prev');\n if (previousElement) {\n event.preventDefault();\n previousElement.focus();\n }\n } else if (event.key === 'Tab') {\n if (event.shiftKey) {\n return;\n }\n\n const nextElement = findFocusableSibling(wrapperRef, 'next');\n if (nextElement) {\n nextElement.focus();\n event.preventDefault();\n }\n }\n};\n\n/**\n * Used as a helper function to wrap the TreeItem component\n * This adds the drag handle and trail to the start of a tree item.\n * Useful if you want to add additional functionality to the tree item but still keep the drag handle and trail\n * Is also used internally to create the TreeViewTextItem component\n */\nfunction TreeItemWrapperInner<T extends Record<string, unknown>>({\n depth,\n shouldDisableInteraction,\n shouldDisableSorting,\n isGhost,\n isIndicator,\n onCollapse,\n item,\n setNodeRef,\n setActivatorNodeRef,\n dragHandleProps,\n style,\n className,\n trails,\n children,\n indentationWidth,\n tabIndex,\n onFocus,\n ref,\n // Need to destruct to avoid passing it to the component\n // oxlint-disable-next-line no-unused-vars\n ...restProps\n}: React.PropsWithChildren<TreeItemComponentProps<T>>) {\n const wrapperRef = useRef<HTMLElement | null>(null);\n\n return (\n <li\n ref={(el) => {\n wrapperRef.current = el;\n\n if (el === null) {\n return;\n }\n setNodeRef(el);\n }}\n className={classNames({\n className,\n indicator: isIndicator,\n 'ndl-tree-view-list-item': true,\n 'ndl-tree-view-list-item-disable-interaction': shouldDisableInteraction,\n 'ndl-tree-view-list-item-placeholder': isGhost,\n })}\n style={{\n ...style,\n paddingLeft: isIndicator ? `${depth * indentationWidth}px` : 0,\n }}\n role=\"treeitem\"\n onFocus={onFocus}\n aria-selected={item.isSelected && !item.isSkeletonLoading}\n aria-expanded={item.canHaveSubItems ? !item.isCollapsed : undefined}\n onKeyDown={(event) =>\n onWrapperKeyDown(\n event,\n shouldDisableInteraction ?? false,\n wrapperRef,\n onCollapse,\n item,\n )\n }\n >\n <div\n role=\"presentation\"\n className=\"ndl-tree-view-list-item-content\"\n ref={ref}\n onKeyDown={(event) =>\n onInnerDivKeyDown(\n event,\n shouldDisableInteraction ?? false,\n wrapperRef,\n )\n }\n >\n {!shouldDisableSorting && (\n <button\n className=\"ndl-tree-view-drag-handle\"\n ref={setActivatorNodeRef}\n aria-label=\"Pick up\"\n {...dragHandleProps}\n tabIndex={tabIndex}\n >\n <DragIcon />\n </button>\n )}\n {trails.map((trail, index) => {\n return <Trail key={index} variant={trail} />;\n })}\n\n {children}\n </div>\n </li>\n );\n}\n\nexport const TreeItemWrapper = TreeItemWrapperInner;\n"]}
1
+ {"version":3,"file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K,EACjC,UAAU,CACX,aAGF,CAAC,oBAAoB,IAAI,CACxB,iDACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,2BAA2B,EACrC,GAAG,EAAE,mBAAmB,gBACb,SAAS,IAChB,eAAe,IACnB,QAAQ,EAAE,QAAQ,YAElB,uBAAC,gBAAQ,KAAG,IACL,CACV,EACA,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;oBAC3B,OAAO,uBAAC,qBAAK,IAAa,OAAO,EAAE,KAAK,IAArB,KAAK,CAAoB,CAAC;gBAC/C,CAAC,CAAC,EAED,QAAQ,IACL,GACH,CACN,CAAC;AACJ,CAAC;AAEY,QAAA,eAAe,GAAG,oBAAoB,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useRef } from 'react';\n\nimport { findFocusableChildren, findFocusableSibling } from '../_common/utils';\nimport { DragIcon } from '../icons';\nimport {\n focusCellInNextRow,\n focusCellInPreviousRow,\n focusNextRow,\n focusPreviousRow,\n} from './tree-view-keyboard-helpers';\nimport { type TreeItem, type TreeItemComponentProps } from './tree-view-types';\nimport { Trail } from './TreeViewTrail';\n\n/**\n * Handles keydown events for when the item itself is focused (wrapperRef.current)\n * Moves the focus between the item and its children as well as toggles collapsing of the item\n * @param event\n * @param shouldDisableInteraction\n * @param wrapperRef\n * @param onCollapse\n * @param item\n * @returns\n */\n\nconst onWrapperKeyDown = (\n event: React.KeyboardEvent,\n shouldDisableInteraction: boolean,\n wrapperRef: React.RefObject<HTMLElement | null>,\n onCollapse: (() => void) | undefined,\n item: TreeItem<Record<string, unknown>>,\n) => {\n if (shouldDisableInteraction || wrapperRef.current === null) {\n return;\n }\n\n if (event.key === 'Enter' && onCollapse) {\n onCollapse();\n } else if (event.key === 'ArrowRight') {\n event.preventDefault();\n if (item.canHaveSubItems && item.isCollapsed && onCollapse) {\n onCollapse();\n } else {\n const focusable = findFocusableChildren(wrapperRef.current);\n const [firstElement] = focusable;\n if (firstElement instanceof HTMLElement) {\n firstElement.focus();\n }\n }\n\n event.preventDefault();\n } else if (event.key === 'ArrowLeft') {\n event.preventDefault();\n if (item.canHaveSubItems && !item.isCollapsed && onCollapse) {\n onCollapse();\n } else {\n focusPreviousRow(wrapperRef.current);\n }\n } else if (event.key === 'ArrowDown') {\n event.preventDefault();\n focusNextRow(wrapperRef.current);\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n focusPreviousRow(wrapperRef.current);\n }\n};\n\n/**\n * Handles keydown events for when one of the items children is focused\n * Moves the focus between the children of the item and up to the parent if needed.\n * Stops the event from propagating to the parent since it has it own keydown handler\n * The parent is the wrapperRef.current and uses onWrapperKeyDown\n * @param event\n * @param shouldDisableInteraction\n * @param wrapperRef\n */\nconst onInnerDivKeyDown = (\n event: React.KeyboardEvent,\n shouldDisableInteraction: boolean,\n wrapperRef: React.RefObject<HTMLElement | null>,\n) => {\n if (shouldDisableInteraction) {\n return;\n }\n event.stopPropagation();\n if (event.key === 'ArrowRight') {\n event.preventDefault();\n const nextElement = findFocusableSibling(wrapperRef, 'next');\n if (nextElement) {\n nextElement.focus();\n }\n } else if (event.key === 'ArrowLeft') {\n event.preventDefault();\n const previousElement = findFocusableSibling(wrapperRef, 'prev');\n if (previousElement) {\n previousElement.focus();\n } else {\n wrapperRef.current?.focus();\n }\n } else if (event.key === 'ArrowDown' && wrapperRef.current !== null) {\n event.preventDefault();\n focusCellInNextRow(wrapperRef.current);\n } else if (event.key === 'ArrowUp' && wrapperRef.current !== null) {\n event.preventDefault();\n focusCellInPreviousRow(wrapperRef.current);\n } else if (event.shiftKey && event.key === 'Tab') {\n const previousElement = findFocusableSibling(wrapperRef, 'prev');\n if (previousElement) {\n event.preventDefault();\n previousElement.focus();\n }\n } else if (event.key === 'Tab') {\n if (event.shiftKey) {\n return;\n }\n\n const nextElement = findFocusableSibling(wrapperRef, 'next');\n if (nextElement) {\n nextElement.focus();\n event.preventDefault();\n }\n }\n};\n\n/**\n * Used as a helper function to wrap the TreeItem component\n * This adds the drag handle and trail to the start of a tree item.\n * Useful if you want to add additional functionality to the tree item but still keep the drag handle and trail\n * Is also used internally to create the TreeViewTextItem component\n */\nfunction TreeItemWrapperInner<T extends Record<string, unknown>>({\n depth,\n shouldDisableInteraction,\n shouldDisableSorting,\n isGhost,\n isIndicator,\n onCollapse,\n item,\n setNodeRef,\n setActivatorNodeRef,\n dragHandleProps,\n style,\n className,\n trails,\n children,\n indentationWidth,\n tabIndex,\n onFocus,\n ref,\n // Need to destruct to avoid passing it to the component\n // oxlint-disable-next-line no-unused-vars\n ...restProps\n}: React.PropsWithChildren<TreeItemComponentProps<T>>) {\n const wrapperRef = useRef<HTMLElement | null>(null);\n\n return (\n <li\n ref={(el) => {\n wrapperRef.current = el;\n\n if (el === null) {\n return;\n }\n setNodeRef(el);\n }}\n className={classNames({\n className,\n indicator: isIndicator,\n 'ndl-tree-view-list-item': true,\n 'ndl-tree-view-list-item-disable-interaction': shouldDisableInteraction,\n 'ndl-tree-view-list-item-placeholder': isGhost,\n })}\n style={{\n ...style,\n paddingLeft: isIndicator ? `${depth * indentationWidth}px` : 0,\n }}\n role=\"treeitem\"\n onFocus={onFocus}\n aria-selected={item.isSelected && !item.isSkeletonLoading}\n aria-expanded={item.canHaveSubItems ? !item.isCollapsed : undefined}\n onKeyDown={(event) =>\n onWrapperKeyDown(\n event,\n shouldDisableInteraction ?? false,\n wrapperRef,\n onCollapse,\n item,\n )\n }\n >\n <div\n role=\"presentation\"\n className=\"ndl-tree-view-list-item-content\"\n ref={ref}\n onKeyDown={(event) =>\n onInnerDivKeyDown(\n event,\n shouldDisableInteraction ?? false,\n wrapperRef,\n )\n }\n >\n {!shouldDisableSorting && (\n <button\n type=\"button\"\n className=\"ndl-tree-view-drag-handle\"\n ref={setActivatorNodeRef}\n aria-label=\"Pick up\"\n {...dragHandleProps}\n tabIndex={tabIndex}\n >\n <DragIcon />\n </button>\n )}\n {trails.map((trail, index) => {\n return <Trail key={index} variant={trail} />;\n })}\n\n {children}\n </div>\n </li>\n );\n}\n\nexport const TreeItemWrapper = TreeItemWrapperInner;\n"]}
@@ -81,7 +81,7 @@ const TreeViewTextItem = (_a) => {
81
81
  : false;
82
82
  return ((0, jsx_runtime_1.jsxs)(TreeItemWrapper_1.TreeItemWrapper, Object.assign({ depth: depth, shouldDisableInteraction: shouldDisableInteraction, shouldDisableSorting: shouldDisableSorting, isGhost: isGhost, indentationWidth: indentationWidth, isIndicator: isIndicator, isCollapsed: isCollapsed, onCollapse: onCollapse, item: item, parent: parent, isOver: isOver, isOverParent: isOverParent, setNodeRef: setNodeRef, setActivatorNodeRef: setActivatorNodeRef, dragHandleProps: dragHandleProps, style: style, trails: trails,
83
83
  // oxlint-disable-next-line @typescript-eslint/no-empty-function
84
- onItemsChanged: () => { }, ref: ref, items: items, tabIndex: tabIndex }, restProps, { children: [item.canHaveSubItems && onCollapse && ((0, jsx_runtime_1.jsxs)("button", { className: "ndl-tree-view-collapse-button", onClick: () => onCollapse(), "aria-label": item.isCollapsed ? 'Expand' : 'Collapse', "aria-expanded": item.isCollapsed ? 'false' : 'true', "aria-pressed": !item.isCollapsed,
84
+ onItemsChanged: () => { }, ref: ref, items: items, tabIndex: tabIndex }, restProps, { children: [item.canHaveSubItems && onCollapse && ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "ndl-tree-view-collapse-button", onClick: () => onCollapse(), "aria-label": item.isCollapsed ? 'Expand' : 'Collapse', "aria-expanded": item.isCollapsed ? 'false' : 'true', "aria-pressed": !item.isCollapsed,
85
85
  /**
86
86
  * Tab index is set to -1 to prevent the item from being focused when the tree is navigated with tab
87
87
  * since we use the arrow keys instead
@@ -136,7 +136,7 @@ const TreeViewTextItem = (_a) => {
136
136
  }
137
137
  }
138
138
  onItemsChanged(newItems, { item, reason: 'selected' });
139
- }, "aria-label": item.data.text }) }))), (0, jsx_runtime_1.jsx)(skeleton_1.Skeleton, Object.assign({ onBackground: "weak", shape: "rectangular", height: "20px" }, item.skeletonProps, { isLoading: item.isSkeletonLoading, children: (0, jsx_runtime_1.jsx)(conditional_wrap_1.ConditionalWrap, { shouldWrap: item.data.onTextClick !== undefined, wrap: (children) => ((0, jsx_runtime_1.jsx)("button", { onClick: item.data.onTextClick, className: "ndl-tree-view-text-clickable", tabIndex: tabIndex, children: children })), children: (0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: item.canHaveSubItems ? 'subheading-small' : 'body-medium', htmlAttributes: {
139
+ }, "aria-label": item.data.text }) }))), (0, jsx_runtime_1.jsx)(skeleton_1.Skeleton, Object.assign({ onBackground: "weak", shape: "rectangular", height: "20px" }, item.skeletonProps, { isLoading: item.isSkeletonLoading, children: (0, jsx_runtime_1.jsx)(conditional_wrap_1.ConditionalWrap, { shouldWrap: item.data.onTextClick !== undefined, wrap: (children) => ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: item.data.onTextClick, className: "ndl-tree-view-text-clickable", tabIndex: tabIndex, children: children })), children: (0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: item.canHaveSubItems ? 'subheading-small' : 'body-medium', htmlAttributes: {
140
140
  style: {
141
141
  overflow: 'hidden',
142
142
  textOverflow: 'ellipsis',
@@ -1 +1 @@
1
- {"version":3,"file":"TreeViewTextItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewTextItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAsBA,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AE,EAAE;wBACtC,OAAO,CACL,uBAAC,mCAAe,kBAEd,SAAS,EAAC,sBAAsB,EAChC,IAAI,EAAC,OAAO,IACR,MAAM,CAAC,WAAW,IACtB,cAAc,kBACZ,QAAQ,IACL,MAAM,CAAC,WAAW,CAAC,cAAc,aAGrC,MAAM,CAAC,IAAI,KATP,KAAK,CAUM,CACnB,CAAC;oBACJ,CAAC,CAAC,GACA,KACU,CACnB,CAAC;AACJ,CAAC,CAAC;AA5MW,QAAA,gBAAgB,oBA4M3B","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport type React from 'react';\n\nimport { Checkbox } from '../checkbox';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { ChevronDownIconOutline, ChevronRightIconOutline } from '../icons';\nimport { Skeleton } from '../skeleton';\nimport { Typography } from '../typography';\nimport {\n type FlattenedTreeItem,\n type TextItemData,\n type TreeItemComponentProps,\n} from './tree-view-types';\nimport { TreeItemWrapper } from './TreeItemWrapper';\n\n/**\n * checks if any parent is checked\n * @param item\n * @param items\n * @returns\n */\nconst parentIsCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const parent = items.find((i) => i.id === item.parentId);\n if (parent) {\n if (parent.isSelected) {\n return true;\n }\n return parentIsCheckedRecursively(parent, items);\n }\n return false;\n};\n\n/**\n * checks if any children are checked\n * @param item\n * @param items\n * @returns\n */\nconst childrenCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const children = items.filter((i) => i.parentId === item.id);\n if (children.length === 0) {\n return false;\n }\n return children.some(\n (i) => i.isSelected || childrenCheckedRecursively(i, items),\n );\n};\n\nexport const TreeViewTextItem = <T extends TextItemData>({\n depth,\n shouldDisableInteraction,\n shouldDisableSorting,\n isGhost,\n indentationWidth,\n isIndicator,\n isCollapsed,\n onCollapse,\n item,\n parent,\n isOver,\n isOverParent,\n setNodeRef,\n setActivatorNodeRef,\n dragHandleProps,\n style,\n trails,\n onItemsChanged,\n items,\n tabIndex,\n ref,\n ...restProps\n}: TreeItemComponentProps<T> & { ref?: React.Ref<HTMLElement> }) => {\n const isAnyParentChecked = parentIsCheckedRecursively(item, items);\n const isAnyChildChecked = childrenCheckedRecursively(item, items);\n\n const isIndeterminate =\n isAnyChildChecked === true &&\n isAnyParentChecked === false &&\n item.isSelected === false\n ? true\n : false;\n\n return (\n <TreeItemWrapper\n depth={depth}\n shouldDisableInteraction={shouldDisableInteraction}\n shouldDisableSorting={shouldDisableSorting}\n isGhost={isGhost}\n indentationWidth={indentationWidth}\n isIndicator={isIndicator}\n isCollapsed={isCollapsed}\n onCollapse={onCollapse}\n item={item}\n parent={parent}\n isOver={isOver}\n isOverParent={isOverParent}\n setNodeRef={setNodeRef}\n setActivatorNodeRef={setActivatorNodeRef}\n dragHandleProps={dragHandleProps}\n style={style}\n trails={trails}\n // oxlint-disable-next-line @typescript-eslint/no-empty-function\n onItemsChanged={() => {}}\n ref={ref}\n items={items}\n tabIndex={tabIndex}\n {...restProps}\n >\n {item.canHaveSubItems && onCollapse && (\n <button\n className=\"ndl-tree-view-collapse-button\"\n onClick={() => onCollapse()}\n aria-label={item.isCollapsed ? 'Expand' : 'Collapse'}\n aria-expanded={item.isCollapsed ? 'false' : 'true'}\n aria-pressed={!item.isCollapsed}\n /**\n * Tab index is set to -1 to prevent the item from being focused when the tree is navigated with tab\n * since we use the arrow keys instead\n */\n tabIndex={tabIndex}\n >\n {item.isCollapsed && <ChevronRightIconOutline className=\"ndl-icon\" />}\n {!item.isCollapsed && <ChevronDownIconOutline className=\"ndl-icon\" />}\n </button>\n )}\n {item.isSelected !== undefined && (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <Checkbox\n isIndeterminate={isIndeterminate}\n isChecked={item.isSelected}\n ariaLabel={item.data.text}\n htmlAttributes={{\n tabIndex,\n }}\n onChange={(event) => {\n const newItems = items.map((i) => {\n if (i.id === item.id) {\n return {\n ...i,\n isSelected: event.target.checked,\n };\n }\n return i;\n });\n\n // Uncheck parents if a child is unchecked\n if (!event.target.checked) {\n let parentId = item.parentId;\n while (parentId !== null) {\n const parent = newItems.find(\n (newItem) => newItem.id === parentId,\n );\n if (parent) {\n newItems.forEach((newItem) => {\n if (newItem.id === parent.id) {\n newItem.isSelected = false;\n }\n });\n parentId = parent.parentId;\n } else {\n parentId = null;\n }\n }\n }\n // Check children if a parent is checked\n if (item.canHaveSubItems) {\n const childIdsToUncheck = items\n .filter((i) => i.parentId === item.id)\n .map((i) => i.id);\n while (childIdsToUncheck.length > 0) {\n const childId = childIdsToUncheck.pop();\n const child = items.find((i) => i.id === childId);\n if (child) {\n newItems.forEach((newItem) => {\n if (newItem.id === child.id) {\n newItem.isSelected = event.target.checked;\n }\n });\n newItems\n .filter((i) => i.parentId === child.id)\n .forEach((i) => {\n childIdsToUncheck.push(i.id);\n });\n }\n }\n }\n onItemsChanged(newItems, { item, reason: 'selected' });\n }}\n aria-label={item.data.text}\n />\n </Skeleton>\n )}\n\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n height=\"20px\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <ConditionalWrap\n shouldWrap={item.data.onTextClick !== undefined}\n wrap={(children) => (\n <button\n onClick={item.data.onTextClick}\n className=\"ndl-tree-view-text-clickable\"\n tabIndex={tabIndex}\n >\n {children}\n </button>\n )}\n >\n <Typography\n variant={item.canHaveSubItems ? 'subheading-small' : 'body-medium'}\n htmlAttributes={{\n style: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n },\n }}\n >\n {item.data.text}\n </Typography>\n </ConditionalWrap>\n </Skeleton>\n <div className=\"ndl-tree-view-actions\">\n {item.data.actions &&\n item.data.actions.map((action, index) => {\n return (\n <CleanIconButton\n key={index}\n className=\"ndl-tree-view-action\"\n size=\"small\"\n {...action.buttonProps}\n htmlAttributes={{\n tabIndex,\n ...action.buttonProps.htmlAttributes,\n }}\n >\n {action.icon}\n </CleanIconButton>\n );\n })}\n </div>\n </TreeItemWrapper>\n );\n};\n"]}
1
+ {"version":3,"file":"TreeViewTextItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewTextItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAsBA,0CAAuC;AACvC,4DAAuD;AACvD,0DAAsD;AACtD,oCAA2E;AAC3E,0CAAuC;AACvC,8CAA2C;AAM3C,uDAAoD;AAEpD;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,CACjC,IAAqC,EACrC,KAAwC,EAC/B,EAAE;IACX,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzD,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,0BAA0B,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,CACjC,IAAqC,EACrC,KAAwC,EAC/B,EA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AAC,IAAI,CAAC,WAAW,KAAK,SAAS,EAC/C,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAClB,mCACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAC9B,SAAS,EAAC,8BAA8B,EACxC,QAAQ,EAAE,QAAQ,YAEjB,QAAQ,GACF,CACV,YAED,uBAAC,uBAAU,IACT,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,aAAa,EAClE,cAAc,EAAE;4BACd,KAAK,EAAE;gCACL,QAAQ,EAAE,QAAQ;gCAClB,YAAY,EAAE,UAAU;gCACxB,UAAU,EAAE,QAAQ;6BACrB;yBACF,YAEA,IAAI,CAAC,IAAI,CAAC,IAAI,GACJ,GACG,IACT,EACX,gCAAK,SAAS,EAAC,uBAAuB,YACnC,IAAI,CAAC,IAAI,CAAC,OAAO;oBAChB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;wBACtC,OAAO,CACL,uBAAC,mCAAe,kBAEd,SAAS,EAAC,sBAAsB,EAChC,IAAI,EAAC,OAAO,IACR,MAAM,CAAC,WAAW,IACtB,cAAc,kBACZ,QAAQ,IACL,MAAM,CAAC,WAAW,CAAC,cAAc,aAGrC,MAAM,CAAC,IAAI,KATP,KAAK,CAUM,CACnB,CAAC;oBACJ,CAAC,CAAC,GACA,KACU,CACnB,CAAC;AACJ,CAAC,CAAC;AA9MW,QAAA,gBAAgB,oBA8M3B","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport type React from 'react';\n\nimport { Checkbox } from '../checkbox';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { ChevronDownIconOutline, ChevronRightIconOutline } from '../icons';\nimport { Skeleton } from '../skeleton';\nimport { Typography } from '../typography';\nimport {\n type FlattenedTreeItem,\n type TextItemData,\n type TreeItemComponentProps,\n} from './tree-view-types';\nimport { TreeItemWrapper } from './TreeItemWrapper';\n\n/**\n * checks if any parent is checked\n * @param item\n * @param items\n * @returns\n */\nconst parentIsCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const parent = items.find((i) => i.id === item.parentId);\n if (parent) {\n if (parent.isSelected) {\n return true;\n }\n return parentIsCheckedRecursively(parent, items);\n }\n return false;\n};\n\n/**\n * checks if any children are checked\n * @param item\n * @param items\n * @returns\n */\nconst childrenCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const children = items.filter((i) => i.parentId === item.id);\n if (children.length === 0) {\n return false;\n }\n return children.some(\n (i) => i.isSelected || childrenCheckedRecursively(i, items),\n );\n};\n\nexport const TreeViewTextItem = <T extends TextItemData>({\n depth,\n shouldDisableInteraction,\n shouldDisableSorting,\n isGhost,\n indentationWidth,\n isIndicator,\n isCollapsed,\n onCollapse,\n item,\n parent,\n isOver,\n isOverParent,\n setNodeRef,\n setActivatorNodeRef,\n dragHandleProps,\n style,\n trails,\n onItemsChanged,\n items,\n tabIndex,\n ref,\n ...restProps\n}: TreeItemComponentProps<T> & { ref?: React.Ref<HTMLElement> }) => {\n const isAnyParentChecked = parentIsCheckedRecursively(item, items);\n const isAnyChildChecked = childrenCheckedRecursively(item, items);\n\n const isIndeterminate =\n isAnyChildChecked === true &&\n isAnyParentChecked === false &&\n item.isSelected === false\n ? true\n : false;\n\n return (\n <TreeItemWrapper\n depth={depth}\n shouldDisableInteraction={shouldDisableInteraction}\n shouldDisableSorting={shouldDisableSorting}\n isGhost={isGhost}\n indentationWidth={indentationWidth}\n isIndicator={isIndicator}\n isCollapsed={isCollapsed}\n onCollapse={onCollapse}\n item={item}\n parent={parent}\n isOver={isOver}\n isOverParent={isOverParent}\n setNodeRef={setNodeRef}\n setActivatorNodeRef={setActivatorNodeRef}\n dragHandleProps={dragHandleProps}\n style={style}\n trails={trails}\n // oxlint-disable-next-line @typescript-eslint/no-empty-function\n onItemsChanged={() => {}}\n ref={ref}\n items={items}\n tabIndex={tabIndex}\n {...restProps}\n >\n {item.canHaveSubItems && onCollapse && (\n <button\n type=\"button\"\n className=\"ndl-tree-view-collapse-button\"\n onClick={() => onCollapse()}\n aria-label={item.isCollapsed ? 'Expand' : 'Collapse'}\n aria-expanded={item.isCollapsed ? 'false' : 'true'}\n aria-pressed={!item.isCollapsed}\n /**\n * Tab index is set to -1 to prevent the item from being focused when the tree is navigated with tab\n * since we use the arrow keys instead\n */\n tabIndex={tabIndex}\n >\n {item.isCollapsed && <ChevronRightIconOutline className=\"ndl-icon\" />}\n {!item.isCollapsed && <ChevronDownIconOutline className=\"ndl-icon\" />}\n </button>\n )}\n {item.isSelected !== undefined && (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <Checkbox\n isIndeterminate={isIndeterminate}\n isChecked={item.isSelected}\n ariaLabel={item.data.text}\n htmlAttributes={{\n tabIndex,\n }}\n onChange={(event) => {\n const newItems = items.map((i) => {\n if (i.id === item.id) {\n return {\n ...i,\n isSelected: event.target.checked,\n };\n }\n return i;\n });\n\n // Uncheck parents if a child is unchecked\n if (!event.target.checked) {\n let parentId = item.parentId;\n while (parentId !== null) {\n const parent = newItems.find(\n (newItem) => newItem.id === parentId,\n );\n if (parent) {\n newItems.forEach((newItem) => {\n if (newItem.id === parent.id) {\n newItem.isSelected = false;\n }\n });\n parentId = parent.parentId;\n } else {\n parentId = null;\n }\n }\n }\n // Check children if a parent is checked\n if (item.canHaveSubItems) {\n const childIdsToUncheck = items\n .filter((i) => i.parentId === item.id)\n .map((i) => i.id);\n while (childIdsToUncheck.length > 0) {\n const childId = childIdsToUncheck.pop();\n const child = items.find((i) => i.id === childId);\n if (child) {\n newItems.forEach((newItem) => {\n if (newItem.id === child.id) {\n newItem.isSelected = event.target.checked;\n }\n });\n newItems\n .filter((i) => i.parentId === child.id)\n .forEach((i) => {\n childIdsToUncheck.push(i.id);\n });\n }\n }\n }\n onItemsChanged(newItems, { item, reason: 'selected' });\n }}\n aria-label={item.data.text}\n />\n </Skeleton>\n )}\n\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n height=\"20px\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <ConditionalWrap\n shouldWrap={item.data.onTextClick !== undefined}\n wrap={(children) => (\n <button\n type=\"button\"\n onClick={item.data.onTextClick}\n className=\"ndl-tree-view-text-clickable\"\n tabIndex={tabIndex}\n >\n {children}\n </button>\n )}\n >\n <Typography\n variant={item.canHaveSubItems ? 'subheading-small' : 'body-medium'}\n htmlAttributes={{\n style: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n },\n }}\n >\n {item.data.text}\n </Typography>\n </ConditionalWrap>\n </Skeleton>\n <div className=\"ndl-tree-view-actions\">\n {item.data.actions &&\n item.data.actions.map((action, index) => {\n return (\n <CleanIconButton\n key={index}\n className=\"ndl-tree-view-action\"\n size=\"small\"\n {...action.buttonProps}\n htmlAttributes={{\n tabIndex,\n ...action.buttonProps.htmlAttributes,\n }}\n >\n {action.icon}\n </CleanIconButton>\n );\n })}\n </div>\n </TreeItemWrapper>\n );\n};\n"]}
@@ -83,7 +83,7 @@ const Component = () => {
83
83
  background: !restProps.item.canHaveSubItems
84
84
  ? 'linear-gradient(in hsl longer hue 45deg, red 0 0)'
85
85
  : '',
86
- }, children: [restProps.item.canHaveSubItems && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(icons_1.FolderIconOutline, { className: "n-h-5 w-h-5" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => restProps.onCollapse && restProps.onCollapse(), children: restProps.item.isCollapsed ? ((0, jsx_runtime_1.jsx)(icons_1.ChevronUpIconSolid, { className: "n-h-5 w-h-5" })) : ((0, jsx_runtime_1.jsx)(icons_1.ChevronDownIconSolid, { className: "n-h-5 w-h-5" })) })] })), 'custom' in restProps.item.data &&
86
+ }, children: [restProps.item.canHaveSubItems && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(icons_1.FolderIconOutline, { className: "n-h-5 w-h-5" }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => restProps.onCollapse && restProps.onCollapse(), children: restProps.item.isCollapsed ? ((0, jsx_runtime_1.jsx)(icons_1.ChevronUpIconSolid, { className: "n-h-5 w-h-5" })) : ((0, jsx_runtime_1.jsx)(icons_1.ChevronDownIconSolid, { className: "n-h-5 w-h-5" })) })] })), 'custom' in restProps.item.data &&
87
87
  typeof restProps.item.data.custom === 'string' &&
88
88
  restProps.item.data.custom] }) })));
89
89
  } }));
@@ -1 +1 @@
1
- {"version":3,"file":"treeview-custom.story.js","sourceRoot":"","sources":["../../../../src/tree-view/stories/treeview-custom.story.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,mDAAiD;AAEjD,4CAA4C;AAC5C,kDAIgC;AAEhC,iCAAiC;AAEjC,MAAM,UAAU,GAAmD;IACjE;QACE,eAAe,EAAE,IAAI;QACrB,IAAI,EAAE;YACJ,MAAM,EAAE,aAAa;SACtB;QACD,EAAE,E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AAiB,IAAC,SAAS,EAAC,aAAa,GAAG,EAC7C,mCACE,OAAO,EAAE,GAAG,EAAE,CACZ,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,UAAU,EAAE,YAG/C,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAC5B,uBAAC,0BAAkB,IAAC,SAAS,EAAC,aAAa,GAAG,CAC/C,CAAC,CAAC,CAAC,CACF,uBAAC,4BAAoB,IAAC,SAAS,EAAC,aAAa,GAAG,CACjD,GACM,IACR,CACJ,EACA,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI;4BAC9B,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,QAAQ;4BAC9C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,IACxB,IACmB,CAC5B,CAAC;QACJ,CAAC,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { TreeView } from '@neo4j-ndl/react';\nimport {\n ChevronDownIconSolid,\n ChevronUpIconSolid,\n FolderIconOutline,\n} from '@neo4j-ndl/react/icons';\nimport type React from 'react';\nimport { useState } from 'react';\n\nconst TREE_ITEMS: React.ComponentProps<typeof TreeView>['items'] = [\n {\n canHaveSubItems: true,\n data: {\n custom: 'Custom Root',\n },\n id: 'Root',\n isCollapsed: false,\n isSelected: false,\n subItems: [\n {\n canHaveSubItems: false,\n data: {\n custom: 'Custom child 1',\n },\n id: 'Child 1',\n isSelected: false,\n },\n {\n canHaveSubItems: false,\n data: {\n custom: 'Custom child 2',\n },\n id: 'Child 2',\n isSelected: false,\n },\n {\n canHaveSubItems: false,\n data: {\n custom: 'Custom child 3',\n },\n id: 'Child 3',\n isSelected: false,\n },\n ],\n },\n];\n\nconst Component = () => {\n const [items, setItems] = useState(TREE_ITEMS);\n\n return (\n <TreeView\n items={items}\n onItemsChanged={(newItems) => {\n setItems(newItems);\n }}\n TreeItemComponent={function CustomTreeItem({\n ref,\n onItemsChanged,\n ...restProps\n }: React.ComponentProps<typeof TreeView.TreeItemWrapper>) {\n return (\n <TreeView.TreeItemWrapper\n {...restProps}\n onItemsChanged={onItemsChanged}\n ref={ref}\n >\n <div\n className=\"n-items-center n-flex n-flex-row\"\n style={{\n background: !restProps.item.canHaveSubItems\n ? 'linear-gradient(in hsl longer hue 45deg, red 0 0)'\n : '',\n }}\n >\n {restProps.item.canHaveSubItems && (\n <>\n <FolderIconOutline className=\"n-h-5 w-h-5\" />\n <button\n onClick={() =>\n restProps.onCollapse && restProps.onCollapse()\n }\n >\n {restProps.item.isCollapsed ? (\n <ChevronUpIconSolid className=\"n-h-5 w-h-5\" />\n ) : (\n <ChevronDownIconSolid className=\"n-h-5 w-h-5\" />\n )}\n </button>\n </>\n )}\n {'custom' in restProps.item.data &&\n typeof restProps.item.data.custom === 'string' &&\n restProps.item.data.custom}\n </div>\n </TreeView.TreeItemWrapper>\n );\n }}\n />\n );\n};\n\nexport default Component;\n"]}
1
+ {"version":3,"file":"treeview-custom.story.js","sourceRoot":"","sources":["../../../../src/tree-view/stories/treeview-custom.story.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,mDAAiD;AAEjD,4CAA4C;AAC5C,kDAIgC;AAEhC,iC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BACzC,CAAC,CAAC,mDAAmD;4BACrD,CAAC,CAAC,EAAE;qBACP,aAEA,SAAS,CAAC,IAAI,CAAC,eAAe,IAAI,CACjC,6DACE,uBAAC,yBAAiB,IAAC,SAAS,EAAC,aAAa,GAAG,EAC7C,mCACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE,CACZ,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,UAAU,EAAE,YAG/C,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAC5B,uBAAC,0BAAkB,IAAC,SAAS,EAAC,aAAa,GAAG,CAC/C,CAAC,CAAC,CAAC,CACF,uBAAC,4BAAoB,IAAC,SAAS,EAAC,aAAa,GAAG,CACjD,GACM,IACR,CACJ,EACA,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI;4BAC9B,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,QAAQ;4BAC9C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,IACxB,IACmB,CAC5B,CAAC;QACJ,CAAC,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { TreeView } from '@neo4j-ndl/react';\nimport {\n ChevronDownIconSolid,\n ChevronUpIconSolid,\n FolderIconOutline,\n} from '@neo4j-ndl/react/icons';\nimport type React from 'react';\nimport { useState } from 'react';\n\nconst TREE_ITEMS: React.ComponentProps<typeof TreeView>['items'] = [\n {\n canHaveSubItems: true,\n data: {\n custom: 'Custom Root',\n },\n id: 'Root',\n isCollapsed: false,\n isSelected: false,\n subItems: [\n {\n canHaveSubItems: false,\n data: {\n custom: 'Custom child 1',\n },\n id: 'Child 1',\n isSelected: false,\n },\n {\n canHaveSubItems: false,\n data: {\n custom: 'Custom child 2',\n },\n id: 'Child 2',\n isSelected: false,\n },\n {\n canHaveSubItems: false,\n data: {\n custom: 'Custom child 3',\n },\n id: 'Child 3',\n isSelected: false,\n },\n ],\n },\n];\n\nconst Component = () => {\n const [items, setItems] = useState(TREE_ITEMS);\n\n return (\n <TreeView\n items={items}\n onItemsChanged={(newItems) => {\n setItems(newItems);\n }}\n TreeItemComponent={function CustomTreeItem({\n ref,\n onItemsChanged,\n ...restProps\n }: React.ComponentProps<typeof TreeView.TreeItemWrapper>) {\n return (\n <TreeView.TreeItemWrapper\n {...restProps}\n onItemsChanged={onItemsChanged}\n ref={ref}\n >\n <div\n className=\"n-items-center n-flex n-flex-row\"\n style={{\n background: !restProps.item.canHaveSubItems\n ? 'linear-gradient(in hsl longer hue 45deg, red 0 0)'\n : '',\n }}\n >\n {restProps.item.canHaveSubItems && (\n <>\n <FolderIconOutline className=\"n-h-5 w-h-5\" />\n <button\n type=\"button\"\n onClick={() =>\n restProps.onCollapse && restProps.onCollapse()\n }\n >\n {restProps.item.isCollapsed ? (\n <ChevronUpIconSolid className=\"n-h-5 w-h-5\" />\n ) : (\n <ChevronDownIconSolid className=\"n-h-5 w-h-5\" />\n )}\n </button>\n </>\n )}\n {'custom' in restProps.item.data &&\n typeof restProps.item.data.custom === 'string' &&\n restProps.item.data.custom}\n </div>\n </TreeView.TreeItemWrapper>\n );\n }}\n />\n );\n};\n\nexport default Component;\n"]}
@@ -184,7 +184,7 @@ const BaseAccordionItem = ({ itemId, children, title, className = '', arrowPosit
184
184
  'ndl-accordion-item-content-expanded': isExpanded,
185
185
  'ndl-accordion-item-content-leading': arrowPosition === 'leading',
186
186
  });
187
- return (_jsxs(Component, Object.assign({ className: classes, style: style, id: itemElementId }, htmlAttributes, { children: [_jsxs("div", { className: headerClasses, id: headerElementId, children: [_jsx("button", { id: buttonElementId, onClick: handleOnClick, className: buttonClasses, "aria-expanded": isExpanded, "aria-disabled": isDisabled, "aria-label": title, "aria-controls": panelElementId, disabled: isDisabled, children: _jsxs("span", { className: iconClasses, children: [_jsx(Typography, { variant: titleTypographyVariant, className: titleClasses, htmlAttributes: {
187
+ return (_jsxs(Component, Object.assign({ className: classes, style: style, id: itemElementId }, htmlAttributes, { children: [_jsxs("div", { className: headerClasses, id: headerElementId, children: [_jsx("button", { type: "button", id: buttonElementId, onClick: handleOnClick, className: buttonClasses, "aria-expanded": isExpanded, "aria-disabled": isDisabled, "aria-label": title, "aria-controls": panelElementId, disabled: isDisabled, children: _jsxs("span", { className: iconClasses, children: [_jsx(Typography, { variant: titleTypographyVariant, className: titleClasses, htmlAttributes: {
188
188
  'aria-level': 2,
189
189
  role: 'heading',
190
190
  }, children: title }), _jsx(ChevronDownIconOutline, { className: classNames('ndl-accordion-item-header-icon', {
@@ -1 +1 @@
1
- {"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../../../src/accordion/Accordion.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC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,OAEsC,EAD5C,SAAS,cAFZ,aAGD,CADa;IAEZ,MAAM,OAAO,GAAG,UAAU,CAAC,4BAA4B,EAAE,SAAS,CAAC,CAAC;IAEpE,OAAO,KAAC,iBAAiB,oBAAK,SAAS,IAAE,SAAS,EAAE,OAAO,IAAI,CAAC;AAClE,CAAC,CAAC;AACF,aAAa,CAAC,WAAW,GAAG,gBAAgB,CAAC;AAO7C,MAAM,SAAS,GAAG,CAGhB,EAG6C,EAAE,EAAE;QAHjD,EACA,SAAS,OAEoC,EAD1C,SAAS,cAFZ,aAGD,CADa;IAEZ,MAAM,OAAO,GAAG,UAAU,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAAC;IAElE,OAAO,CACL,KAAC,iBAAiB,oBAAK,SAAS,IAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,IAAI,CAC5E,CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,CAAC,WAAW,GAAG,qBAAqB,CAAC;AAE9C,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE;IAClD,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,aAAa;CACpB,CAAC,CAAC;AAEH,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useCallback, useImperativeHandle, useRef } from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { findUntil } from '../_common/utils';\nimport { Divider } from '../divider';\nimport { ChevronDownIconOutline } from '../icons';\nimport { Typography } from '../typography';\nimport { AccordionContext, useAccordionContext } from './accordion-context';\nimport {\n type AccordionItemId,\n type AccordionItemProps,\n type AccordionProps,\n type ClassicItemProps,\n type IsMultiple,\n type IsNotMultiple,\n} from './accordion-types';\n\nenum AccordionSelector {\n Item = '.ndl-accordion-item',\n ItemNotDisabled = '.ndl-accordion-item:not(.ndl-accordion-item-disabled)',\n}\n\nconst getAccordionItem = (\n accordionElement: Element,\n selector: string,\n direction: 'next' | 'prev' = 'next',\n): Element | null => {\n const itemParent = accordionElement.closest(AccordionSelector.Item);\n if (!itemParent) {\n return null;\n }\n\n return findUntil(direction, itemParent, selector);\n};\n\nconst AccordionComponent = function AccordionComponent<\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n children,\n as,\n isMultiple,\n onChange,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<U, AccordionProps<T>>) {\n const accordionRef = useRef<U>(null);\n\n useImperativeHandle(ref, () => accordionRef.current!);\n\n const Component: React.ElementType = as || 'div';\n\n // The following function includes code needed to be\n // able to navigate with the arrow keys (not tab).\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const accordionElement = accordionRef.current;\n if (!accordionElement) {\n return;\n }\n const activeElement = document.activeElement as HTMLElement;\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'next',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'prev',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n event.stopPropagation();\n activeElement.click();\n }\n };\n\n const focusAccordionItem = (accordionHtmlElement: HTMLElement) => {\n const accordionButton = accordionHtmlElement\n .getElementsByClassName('ndl-accordion-item-header-button')\n .item(0);\n\n if (accordionButton !== null && accordionButton instanceof HTMLElement) {\n accordionButton.focus();\n }\n };\n\n const classes = classNames('ndl-accordion', className);\n\n // Destructure and omit keys from DOM spread\n const { expandedItemIds, expandedItemId, ...restAccordionProps } =\n restProps as Record<string, unknown> as {\n expandedItemIds?: T[];\n expandedItemId?: T | null;\n [key: string]: unknown;\n };\n\n const contextValue = isMultiple\n ? ({\n expandedItemIds,\n isMultiple,\n onChange,\n } as IsMultiple<T>)\n : ({\n expandedItemId,\n isMultiple,\n onChange,\n } as IsNotMultiple<T>);\n\n return (\n <Component\n className={classes}\n style={style}\n ref={accordionRef}\n onKeyDown={handleKeyDown}\n role=\"presentation\"\n {...restAccordionProps}\n {...htmlAttributes}\n >\n <AccordionContext.Provider value={contextValue}>\n {children}\n </AccordionContext.Provider>\n </Component>\n );\n};\n\nconst createItemId = (type: string, id: AccordionItemId) =>\n `ndl-accordionitem${type}id-${id}`;\n\nconst BaseAccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n itemId,\n children,\n title,\n className = '',\n arrowPosition = 'leading',\n isDisabled = false,\n onExpandedChange,\n htmlAttributes,\n style,\n as,\n titleTypographyVariant = 'subheading-medium',\n hasDivider = true,\n trailingContent,\n}: PolymorphicCommonProps<U, AccordionItemProps<T>>) => {\n const contentRef = useRef<HTMLDivElement>(null);\n const innerContentRef = useRef<HTMLDivElement>(null);\n const itemElementId = createItemId('item', itemId);\n const headerElementId = createItemId('header', itemId);\n const buttonElementId = createItemId('button', itemId);\n const panelElementId = createItemId('panel', itemId);\n const Component: React.ElementType = as || 'div';\n\n const context = useAccordionContext();\n const { isMultiple } = context;\n\n const isExpanded = isMultiple\n ? context.expandedItemIds.includes(itemId)\n : context.expandedItemId === itemId;\n\n const handleOnClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n // Custom callback to call.\n if (onExpandedChange !== undefined) {\n onExpandedChange(!isExpanded);\n }\n\n if (isMultiple) {\n const { expandedItemIds, onChange }: IsMultiple<T> = context;\n // Multiple expanded.\n if (isExpanded) {\n // Remove from list.\n const newArray: T[] = expandedItemIds.filter(\n (activeId) => activeId !== itemId,\n );\n onChange(newArray);\n } else if (!isExpanded) {\n // Add to list.\n const newArray = [...expandedItemIds];\n newArray.push(itemId);\n onChange(newArray);\n }\n } else {\n const { onChange }: IsNotMultiple<T> = context;\n // Single expanded.\n if (isExpanded) {\n // Set null.\n onChange(null);\n } else if (!isExpanded) {\n // Set to id.\n onChange(itemId);\n }\n }\n\n // The W3 WAI-ARIA states that focus can only happen on the header not the header button.\n document.activeElement?.parentElement?.focus();\n }, [isExpanded, isMultiple, isDisabled, itemId, onExpandedChange, context]);\n\n const classes = classNames('ndl-accordion-item', className, {\n 'ndl-accordion-item-disabled': isDisabled,\n 'ndl-accordion-item-expanded': isExpanded,\n });\n\n const headerClasses = classNames('ndl-accordion-item-header', {\n 'ndl-accordion-item-header-disabled': isDisabled,\n });\n\n const iconClasses = classNames('ndl-accordion-item-header-icon-wrapper', {\n 'ndl-accordion-item-header-icon-wrapper-leading':\n arrowPosition === 'leading',\n });\n\n const buttonClasses = classNames('ndl-accordion-item-header-button', {\n 'ndl-accordion-item-header-button-disabled': isDisabled,\n });\n\n const titleClasses = classNames('ndl-accordion-item-header-button-title', {\n 'ndl-accordion-item-header-button-title': isDisabled,\n 'ndl-accordion-item-header-button-title-leading':\n arrowPosition === 'leading',\n });\n\n const contentClasses = classNames('ndl-accordion-item-content', {\n 'ndl-accordion-item-content-expanded': isExpanded,\n 'ndl-accordion-item-content-leading': arrowPosition === 'leading',\n });\n\n return (\n <Component\n className={classes}\n style={style}\n id={itemElementId}\n {...htmlAttributes}\n >\n <div className={headerClasses} id={headerElementId}>\n <button\n id={buttonElementId}\n onClick={handleOnClick}\n className={buttonClasses}\n aria-expanded={isExpanded}\n aria-disabled={isDisabled}\n aria-label={title}\n aria-controls={panelElementId}\n disabled={isDisabled}\n >\n <span className={iconClasses}>\n <Typography\n variant={titleTypographyVariant}\n className={titleClasses}\n htmlAttributes={{\n 'aria-level': 2,\n role: 'heading',\n }}\n >\n {title}\n </Typography>\n\n <ChevronDownIconOutline\n className={classNames('ndl-accordion-item-header-icon', {\n '-n-rotate-180': isExpanded,\n })}\n />\n </span>\n </button>\n {trailingContent && (\n <Typography as=\"div\" variant=\"body-medium\">\n {trailingContent}\n </Typography>\n )}\n </div>\n\n <div\n id={panelElementId}\n ref={contentRef}\n className={contentClasses}\n aria-hidden={!isExpanded}\n aria-labelledby={buttonElementId}\n role=\"region\"\n >\n {/* The <div> element has a child <button> element that allows keyboard interaction */}\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div\n ref={innerContentRef}\n className=\"ndl-accordion-item-content-inner\"\n onKeyDown={(event) => event.stopPropagation()}\n >\n <Typography\n variant=\"body-medium\"\n className=\"n-text-neutral-text-weak\"\n as=\"div\"\n >\n {children}\n </Typography>\n </div>\n </div>\n {hasDivider && <Divider />}\n </Component>\n );\n};\n\nconst AccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, ClassicItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-classic', className);\n\n return <BaseAccordionItem {...restProps} className={classes} />;\n};\nAccordionItem.displayName = 'Accordion.Item';\n\ntype CleanItemProps<T extends AccordionItemId> = Omit<\n AccordionItemProps<T>,\n 'hasDivider'\n>;\n\nconst CleanItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, CleanItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-clean', className);\n\n return (\n <BaseAccordionItem {...restProps} className={classes} hasDivider={false} />\n );\n};\n\nCleanItem.displayName = 'Accordion.CleanItem';\n\nconst Accordion = Object.assign(AccordionComponent, {\n CleanItem: CleanItem,\n Item: AccordionItem,\n});\n\nexport { Accordion };\n"]}
1
+ {"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../../../src/accordion/Accordion.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAU5E,IAAK,iBAGJ;AAHD,WAAK,iBAAiB;IACpB,iDAA4B,CAAA;IAC5B,8FAAyE,CAAA;AAC3E,CAAC,EAHI,iBAAiB,KAAjB,iBAAiB,QAGrB;AAED,MAAM,gBAAgB,GAAG,CACvB,gBAAyB,EACzB,QAAgB,EAChB,YAA6B,MAAM,EACnB,EAAE;IAClB,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACpE,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,SAAS,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,SAAS,kBAAkB,CAGpD,EAU6C;QAV7C,EACA,QAAQ,E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WAAW,GAAG,qBAAqB,CAAC;AAE9C,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE;IAClD,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,aAAa;CACpB,CAAC,CAAC;AAEH,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useCallback, useImperativeHandle, useRef } from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { findUntil } from '../_common/utils';\nimport { Divider } from '../divider';\nimport { ChevronDownIconOutline } from '../icons';\nimport { Typography } from '../typography';\nimport { AccordionContext, useAccordionContext } from './accordion-context';\nimport {\n type AccordionItemId,\n type AccordionItemProps,\n type AccordionProps,\n type ClassicItemProps,\n type IsMultiple,\n type IsNotMultiple,\n} from './accordion-types';\n\nenum AccordionSelector {\n Item = '.ndl-accordion-item',\n ItemNotDisabled = '.ndl-accordion-item:not(.ndl-accordion-item-disabled)',\n}\n\nconst getAccordionItem = (\n accordionElement: Element,\n selector: string,\n direction: 'next' | 'prev' = 'next',\n): Element | null => {\n const itemParent = accordionElement.closest(AccordionSelector.Item);\n if (!itemParent) {\n return null;\n }\n\n return findUntil(direction, itemParent, selector);\n};\n\nconst AccordionComponent = function AccordionComponent<\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n children,\n as,\n isMultiple,\n onChange,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<U, AccordionProps<T>>) {\n const accordionRef = useRef<U>(null);\n\n useImperativeHandle(ref, () => accordionRef.current!);\n\n const Component: React.ElementType = as || 'div';\n\n // The following function includes code needed to be\n // able to navigate with the arrow keys (not tab).\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const accordionElement = accordionRef.current;\n if (!accordionElement) {\n return;\n }\n const activeElement = document.activeElement as HTMLElement;\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'next',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'prev',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n event.stopPropagation();\n activeElement.click();\n }\n };\n\n const focusAccordionItem = (accordionHtmlElement: HTMLElement) => {\n const accordionButton = accordionHtmlElement\n .getElementsByClassName('ndl-accordion-item-header-button')\n .item(0);\n\n if (accordionButton !== null && accordionButton instanceof HTMLElement) {\n accordionButton.focus();\n }\n };\n\n const classes = classNames('ndl-accordion', className);\n\n // Destructure and omit keys from DOM spread\n const { expandedItemIds, expandedItemId, ...restAccordionProps } =\n restProps as Record<string, unknown> as {\n expandedItemIds?: T[];\n expandedItemId?: T | null;\n [key: string]: unknown;\n };\n\n const contextValue = isMultiple\n ? ({\n expandedItemIds,\n isMultiple,\n onChange,\n } as IsMultiple<T>)\n : ({\n expandedItemId,\n isMultiple,\n onChange,\n } as IsNotMultiple<T>);\n\n return (\n <Component\n className={classes}\n style={style}\n ref={accordionRef}\n onKeyDown={handleKeyDown}\n role=\"presentation\"\n {...restAccordionProps}\n {...htmlAttributes}\n >\n <AccordionContext.Provider value={contextValue}>\n {children}\n </AccordionContext.Provider>\n </Component>\n );\n};\n\nconst createItemId = (type: string, id: AccordionItemId) =>\n `ndl-accordionitem${type}id-${id}`;\n\nconst BaseAccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n itemId,\n children,\n title,\n className = '',\n arrowPosition = 'leading',\n isDisabled = false,\n onExpandedChange,\n htmlAttributes,\n style,\n as,\n titleTypographyVariant = 'subheading-medium',\n hasDivider = true,\n trailingContent,\n}: PolymorphicCommonProps<U, AccordionItemProps<T>>) => {\n const contentRef = useRef<HTMLDivElement>(null);\n const innerContentRef = useRef<HTMLDivElement>(null);\n const itemElementId = createItemId('item', itemId);\n const headerElementId = createItemId('header', itemId);\n const buttonElementId = createItemId('button', itemId);\n const panelElementId = createItemId('panel', itemId);\n const Component: React.ElementType = as || 'div';\n\n const context = useAccordionContext();\n const { isMultiple } = context;\n\n const isExpanded = isMultiple\n ? context.expandedItemIds.includes(itemId)\n : context.expandedItemId === itemId;\n\n const handleOnClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n // Custom callback to call.\n if (onExpandedChange !== undefined) {\n onExpandedChange(!isExpanded);\n }\n\n if (isMultiple) {\n const { expandedItemIds, onChange }: IsMultiple<T> = context;\n // Multiple expanded.\n if (isExpanded) {\n // Remove from list.\n const newArray: T[] = expandedItemIds.filter(\n (activeId) => activeId !== itemId,\n );\n onChange(newArray);\n } else if (!isExpanded) {\n // Add to list.\n const newArray = [...expandedItemIds];\n newArray.push(itemId);\n onChange(newArray);\n }\n } else {\n const { onChange }: IsNotMultiple<T> = context;\n // Single expanded.\n if (isExpanded) {\n // Set null.\n onChange(null);\n } else if (!isExpanded) {\n // Set to id.\n onChange(itemId);\n }\n }\n\n // The W3 WAI-ARIA states that focus can only happen on the header not the header button.\n document.activeElement?.parentElement?.focus();\n }, [isExpanded, isMultiple, isDisabled, itemId, onExpandedChange, context]);\n\n const classes = classNames('ndl-accordion-item', className, {\n 'ndl-accordion-item-disabled': isDisabled,\n 'ndl-accordion-item-expanded': isExpanded,\n });\n\n const headerClasses = classNames('ndl-accordion-item-header', {\n 'ndl-accordion-item-header-disabled': isDisabled,\n });\n\n const iconClasses = classNames('ndl-accordion-item-header-icon-wrapper', {\n 'ndl-accordion-item-header-icon-wrapper-leading':\n arrowPosition === 'leading',\n });\n\n const buttonClasses = classNames('ndl-accordion-item-header-button', {\n 'ndl-accordion-item-header-button-disabled': isDisabled,\n });\n\n const titleClasses = classNames('ndl-accordion-item-header-button-title', {\n 'ndl-accordion-item-header-button-title': isDisabled,\n 'ndl-accordion-item-header-button-title-leading':\n arrowPosition === 'leading',\n });\n\n const contentClasses = classNames('ndl-accordion-item-content', {\n 'ndl-accordion-item-content-expanded': isExpanded,\n 'ndl-accordion-item-content-leading': arrowPosition === 'leading',\n });\n\n return (\n <Component\n className={classes}\n style={style}\n id={itemElementId}\n {...htmlAttributes}\n >\n <div className={headerClasses} id={headerElementId}>\n <button\n type=\"button\"\n id={buttonElementId}\n onClick={handleOnClick}\n className={buttonClasses}\n aria-expanded={isExpanded}\n aria-disabled={isDisabled}\n aria-label={title}\n aria-controls={panelElementId}\n disabled={isDisabled}\n >\n <span className={iconClasses}>\n <Typography\n variant={titleTypographyVariant}\n className={titleClasses}\n htmlAttributes={{\n 'aria-level': 2,\n role: 'heading',\n }}\n >\n {title}\n </Typography>\n\n <ChevronDownIconOutline\n className={classNames('ndl-accordion-item-header-icon', {\n '-n-rotate-180': isExpanded,\n })}\n />\n </span>\n </button>\n {trailingContent && (\n <Typography as=\"div\" variant=\"body-medium\">\n {trailingContent}\n </Typography>\n )}\n </div>\n\n <div\n id={panelElementId}\n ref={contentRef}\n className={contentClasses}\n aria-hidden={!isExpanded}\n aria-labelledby={buttonElementId}\n role=\"region\"\n >\n {/* The <div> element has a child <button> element that allows keyboard interaction */}\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div\n ref={innerContentRef}\n className=\"ndl-accordion-item-content-inner\"\n onKeyDown={(event) => event.stopPropagation()}\n >\n <Typography\n variant=\"body-medium\"\n className=\"n-text-neutral-text-weak\"\n as=\"div\"\n >\n {children}\n </Typography>\n </div>\n </div>\n {hasDivider && <Divider />}\n </Component>\n );\n};\n\nconst AccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, ClassicItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-classic', className);\n\n return <BaseAccordionItem {...restProps} className={classes} />;\n};\nAccordionItem.displayName = 'Accordion.Item';\n\ntype CleanItemProps<T extends AccordionItemId> = Omit<\n AccordionItemProps<T>,\n 'hasDivider'\n>;\n\nconst CleanItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, CleanItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-clean', className);\n\n return (\n <BaseAccordionItem {...restProps} className={classes} hasDivider={false} />\n );\n};\n\nCleanItem.displayName = 'Accordion.CleanItem';\n\nconst Accordion = Object.assign(AccordionComponent, {\n CleanItem: CleanItem,\n Item: AccordionItem,\n});\n\nexport { Accordion };\n"]}
@@ -135,7 +135,7 @@ const PromptComponent = (_a) => {
135
135
  const SubmitPromptButton = ({ onSubmit, onCancel, isDisabled, isRunningPrompt, }) => {
136
136
  return (_jsx("div", { className: classNames('ndl-ai-prompt-button-container', {
137
137
  'ndl-in-loading': isRunningPrompt,
138
- }), children: _jsxs(Tooltip, { type: "simple", isDisabled: isDisabled || isRunningPrompt, hoverDelay: { close: 0, open: 500 }, shouldCloseOnReferenceClick: true, children: [_jsx(Tooltip.Trigger, { hasButtonWrapper: true, children: _jsx("button", { style: {
138
+ }), children: _jsxs(Tooltip, { type: "simple", isDisabled: isDisabled || isRunningPrompt, hoverDelay: { close: 0, open: 500 }, shouldCloseOnReferenceClick: true, children: [_jsx(Tooltip.Trigger, { hasButtonWrapper: true, children: _jsx("button", { type: "button", style: {
139
139
  borderRadius: isRunningPrompt
140
140
  ? 'var(--border-radius-sm)'
141
141
  : 'var(--border-radius-lg)',