@pingux/astro 2.234.1 → 2.236.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/lib/cjs/components/ComboBox/ComboBox.styles.d.ts +897 -0
  2. package/lib/cjs/components/ComboBox/ComboBoxInput.d.ts +4 -0
  3. package/lib/cjs/components/ComboBox/ComboBoxInput.js +8 -37
  4. package/lib/cjs/components/ComboBox/index.d.ts +1 -0
  5. package/lib/cjs/components/ComboBoxField/ComboBoxField.d.ts +9 -0
  6. package/lib/cjs/components/ComboBoxField/ComboBoxField.js +11 -133
  7. package/lib/cjs/components/ComboBoxField/ComboBoxField.stories.js +5 -4
  8. package/lib/cjs/components/ComboBoxField/ComboBoxField.test.js +2 -3
  9. package/lib/cjs/components/ComboBoxField/index.d.ts +1 -0
  10. package/lib/cjs/components/Tree/Tree.d.ts +9 -0
  11. package/lib/cjs/components/Tree/Tree.js +48 -0
  12. package/lib/cjs/components/Tree/Tree.mdx +58 -0
  13. package/lib/cjs/components/Tree/Tree.stories.js +786 -0
  14. package/lib/cjs/components/Tree/Tree.styles.d.ts +4 -0
  15. package/lib/cjs/components/Tree/Tree.styles.js +332 -0
  16. package/lib/cjs/components/Tree/Tree.test.js +300 -0
  17. package/lib/cjs/components/Tree/TreeItem.d.ts +22 -0
  18. package/lib/cjs/components/Tree/TreeItem.js +82 -0
  19. package/lib/cjs/components/Tree/TreeItemContent.d.ts +11 -0
  20. package/lib/cjs/components/Tree/TreeItemContent.js +102 -0
  21. package/lib/cjs/components/Tree/index.d.ts +5 -0
  22. package/lib/cjs/components/Tree/index.js +52 -0
  23. package/lib/cjs/components/Tree/useTreeDragAndDrop.d.ts +46 -0
  24. package/lib/cjs/components/Tree/useTreeDragAndDrop.js +76 -0
  25. package/lib/cjs/context/TooltipContext/index.js +2 -1
  26. package/lib/cjs/hooks/useCircularLoader/useCircularLoader.d.ts +1 -0
  27. package/lib/cjs/hooks/useCircularLoader/useCircularLoader.js +3 -2
  28. package/lib/cjs/hooks/useGetTheme/useGetTheme.d.ts +4 -0
  29. package/lib/cjs/hooks/useGridListItem/useGridListItem.d.ts +4 -4
  30. package/lib/cjs/hooks/useOverlayPanelState/useOverlayPanelState.test.js +3 -1
  31. package/lib/cjs/hooks/usePagination/usePagination.d.ts +8 -8
  32. package/lib/cjs/hooks/useStatusClasses/useStatusClasses.js +2 -8
  33. package/lib/cjs/index.d.ts +1 -0
  34. package/lib/cjs/index.js +43 -0
  35. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/colors.d.ts +1 -0
  36. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/colors.js +7 -1
  37. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/customProperties/icons.d.ts +2 -0
  38. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/customProperties/index.d.ts +2 -0
  39. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/buttons.d.ts +15 -0
  40. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/buttons.js +15 -0
  41. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/tree.d.ts +15 -0
  42. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/tree.js +160 -0
  43. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/variants.d.ts +9 -0
  44. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/variants.js +3 -1
  45. package/lib/cjs/styles/themeOverrides/onyxSideNav.d.ts +2 -0
  46. package/lib/cjs/styles/themes/astro/customProperties/icons.d.ts +2 -0
  47. package/lib/cjs/styles/themes/astro/customProperties/icons.js +3 -1
  48. package/lib/cjs/styles/themes/astro/customProperties/index.d.ts +2 -0
  49. package/lib/cjs/styles/themes/next-gen/convertedComponentList.js +1 -1
  50. package/lib/cjs/styles/themes/next-gen/customProperties/icons.d.ts +2 -0
  51. package/lib/cjs/styles/themes/next-gen/customProperties/icons.js +1 -1
  52. package/lib/cjs/styles/themes/next-gen/customProperties/index.d.ts +2 -0
  53. package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +27 -0
  54. package/lib/cjs/styles/themes/next-gen/variants/button.d.ts +15 -0
  55. package/lib/cjs/styles/themes/next-gen/variants/button.js +11 -0
  56. package/lib/cjs/styles/themes/next-gen/variants/tree.d.ts +16 -0
  57. package/lib/cjs/styles/themes/next-gen/variants/tree.js +153 -0
  58. package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +10 -0
  59. package/lib/cjs/styles/themes/next-gen/variants/variants.js +2 -0
  60. package/lib/cjs/styles/variants/index.js +3 -1
  61. package/lib/cjs/styles/variants/variants.js +2 -0
  62. package/lib/cjs/types/ComboBox.d.ts +36 -0
  63. package/lib/cjs/types/ComboBox.js +6 -0
  64. package/lib/cjs/types/ComboBoxField.d.ts +110 -0
  65. package/lib/cjs/types/ComboBoxField.js +6 -0
  66. package/lib/cjs/types/index.d.ts +2 -0
  67. package/lib/cjs/types/index.js +79 -57
  68. package/lib/cjs/types/popoverContainer.d.ts +1 -0
  69. package/lib/cjs/types/textField.d.ts +6 -0
  70. package/lib/cjs/utils/getStatusClasses.d.ts +13 -0
  71. package/lib/cjs/utils/getStatusClasses.js +29 -0
  72. package/lib/components/ComboBox/ComboBoxInput.js +8 -37
  73. package/lib/components/ComboBoxField/ComboBoxField.js +12 -134
  74. package/lib/components/ComboBoxField/ComboBoxField.stories.js +5 -4
  75. package/lib/components/ComboBoxField/ComboBoxField.test.js +2 -3
  76. package/lib/components/Tree/Tree.js +33 -0
  77. package/lib/components/Tree/Tree.mdx +58 -0
  78. package/lib/components/Tree/Tree.stories.js +775 -0
  79. package/lib/components/Tree/Tree.styles.js +325 -0
  80. package/lib/components/Tree/Tree.test.js +297 -0
  81. package/lib/components/Tree/TreeItem.js +70 -0
  82. package/lib/components/Tree/TreeItemContent.js +94 -0
  83. package/lib/components/Tree/index.js +5 -0
  84. package/lib/components/Tree/useTreeDragAndDrop.js +69 -0
  85. package/lib/context/TooltipContext/index.js +2 -1
  86. package/lib/hooks/useCircularLoader/useCircularLoader.js +3 -2
  87. package/lib/hooks/useOverlayPanelState/useOverlayPanelState.test.js +3 -1
  88. package/lib/hooks/useStatusClasses/useStatusClasses.js +2 -8
  89. package/lib/index.js +1 -0
  90. package/lib/styles/themeOverrides/nextGenDarkMode/colors.js +7 -1
  91. package/lib/styles/themeOverrides/nextGenDarkMode/variants/buttons.js +15 -0
  92. package/lib/styles/themeOverrides/nextGenDarkMode/variants/tree.js +154 -0
  93. package/lib/styles/themeOverrides/nextGenDarkMode/variants/variants.js +3 -1
  94. package/lib/styles/themes/astro/customProperties/icons.js +3 -1
  95. package/lib/styles/themes/next-gen/convertedComponentList.js +1 -1
  96. package/lib/styles/themes/next-gen/customProperties/icons.js +1 -1
  97. package/lib/styles/themes/next-gen/variants/button.js +11 -0
  98. package/lib/styles/themes/next-gen/variants/tree.js +147 -0
  99. package/lib/styles/themes/next-gen/variants/variants.js +2 -0
  100. package/lib/styles/variants/index.js +3 -1
  101. package/lib/styles/variants/variants.js +2 -0
  102. package/lib/types/ComboBox.js +1 -0
  103. package/lib/types/ComboBoxField.js +1 -0
  104. package/lib/types/index.js +2 -0
  105. package/lib/utils/getStatusClasses.js +22 -0
  106. package/package.json +9 -6
@@ -0,0 +1,4 @@
1
+ import { ThemeUICSSObject } from 'theme-ui';
2
+ declare const tree: ThemeUICSSObject;
3
+ export declare const treeChevron: ThemeUICSSObject;
4
+ export default tree;
@@ -0,0 +1,332 @@
1
+ "use strict";
2
+
3
+ var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
4
+ var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
5
+ var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
6
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
7
+ var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
8
+ var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
9
+ var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
10
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
11
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
12
+ _Object$defineProperty(exports, "__esModule", {
13
+ value: true
14
+ });
15
+ exports.treeChevron = exports["default"] = void 0;
16
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
17
+ function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
19
+ var tree = {
20
+ outline: 'none'
21
+ };
22
+ tree.container = {
23
+ display: 'flex',
24
+ flexDirection: 'column',
25
+ width: '100%',
26
+ outline: 'none',
27
+ p: 'sm',
28
+ borderRadius: '4px',
29
+ '& .react-aria-DropIndicator': {
30
+ height: '2px',
31
+ '&::before': {
32
+ content: '""',
33
+ display: 'block',
34
+ height: '2px',
35
+ borderRadius: '2px',
36
+ bg: 'transparent',
37
+ margin: '0px'
38
+ },
39
+ '&[data-drop-target]::before': {
40
+ bg: 'active'
41
+ }
42
+ }
43
+ };
44
+ tree.item = {
45
+ outline: 'none',
46
+ cursor: 'pointer',
47
+ borderRadius: '4px',
48
+ '&.is-focused, &[data-focused]': {
49
+ outline: '1px solid',
50
+ outlineColor: 'focus',
51
+ outlineOffset: '-1px',
52
+ borderRadius: '4px',
53
+ zIndex: 1
54
+ },
55
+ // the drag handle / chevron carry their own focus treatment, so the
56
+ // row-level outline is suppressed while either is focused
57
+ '&:has(.astro-TreeDragButton:focus), &:has(.astro-TreeDragButton:focus-visible), &:has(.astro-TreeChevronButton:focus), &:has(.astro-TreeChevronButton:focus-visible)': {
58
+ outline: 'none'
59
+ },
60
+ '&.is-focus-visible, &[data-focus-visible]': {
61
+ outline: '2px solid',
62
+ outlineColor: 'focus',
63
+ outlineOffset: '-1px',
64
+ borderRadius: '4px'
65
+ },
66
+ '&.is-selected, &[data-selected]': {
67
+ bg: 'accent.95',
68
+ '& *': {
69
+ color: 'active'
70
+ }
71
+ },
72
+ '&.is-disabled, &[data-disabled]': {
73
+ opacity: 0.65,
74
+ cursor: 'not-allowed'
75
+ },
76
+ '&.is-dragging, &[data-dragging]': {
77
+ bg: 'accent.95',
78
+ outline: '2px solid',
79
+ outlineColor: 'active',
80
+ outlineOffset: '-1px',
81
+ borderRadius: '4px',
82
+ '& *': {
83
+ color: 'active'
84
+ }
85
+ },
86
+ '&.is-drop-target, &[data-drop-target]': {
87
+ outline: '2px dashed',
88
+ outlineColor: 'active',
89
+ outlineOffset: '-1px',
90
+ borderRadius: '4px'
91
+ }
92
+ };
93
+ tree.dragButton = {
94
+ display: 'inline-flex',
95
+ alignItems: 'center',
96
+ justifyContent: 'center',
97
+ width: '26px',
98
+ height: '26px',
99
+ minWidth: '26px',
100
+ padding: 0,
101
+ background: 'transparent',
102
+ border: 'none',
103
+ cursor: 'grab',
104
+ borderRadius: '4px',
105
+ outline: 'none',
106
+ color: 'inherit',
107
+ transition: 'background-color 120ms ease, outline-color 120ms ease',
108
+ path: {
109
+ fill: 'neutral.40'
110
+ },
111
+ '&:hover': {
112
+ bg: 'accent.95',
113
+ '& svg': {
114
+ fill: 'active'
115
+ }
116
+ },
117
+ '&:focus, &:focus-visible': {
118
+ outline: '1px solid',
119
+ outlineColor: 'focus',
120
+ outlineOffset: '2px',
121
+ borderRadius: '4px'
122
+ },
123
+ '&:active, &[data-pressed]': {
124
+ bg: 'active',
125
+ cursor: 'grabbing',
126
+ '& svg': {
127
+ fill: 'white'
128
+ }
129
+ }
130
+ };
131
+ var treeChevron = exports.treeChevron = {
132
+ display: 'inline-flex',
133
+ alignItems: 'center',
134
+ justifyContent: 'center',
135
+ width: '18px',
136
+ height: '18px',
137
+ minWidth: '18px',
138
+ minHeight: '18px',
139
+ boxSizing: 'border-box',
140
+ margin: 0,
141
+ padding: 0,
142
+ background: 'transparent',
143
+ border: 'none',
144
+ outline: 'none',
145
+ boxShadow: 'none',
146
+ cursor: 'pointer',
147
+ color: 'inherit',
148
+ '& svg': {
149
+ width: '18px',
150
+ height: '18px'
151
+ },
152
+ '& > span': {
153
+ width: '18px',
154
+ height: '18px',
155
+ minWidth: '18px',
156
+ minHeight: '18px',
157
+ display: 'flex',
158
+ alignItems: 'center',
159
+ justifyContent: 'center'
160
+ },
161
+ path: {
162
+ fill: 'neutral.40'
163
+ },
164
+ '&.is-hovered, &:hover, &.is-pressed, &:active': {
165
+ background: 'transparent',
166
+ border: 'none',
167
+ boxShadow: 'none',
168
+ outline: 'none'
169
+ },
170
+ '&.is-focused': {
171
+ outline: 'none'
172
+ },
173
+ '&:focus, &:focus-visible': {
174
+ outline: '1px solid',
175
+ outlineColor: 'focus',
176
+ outlineOffset: '2px'
177
+ },
178
+ '&[data-disabled]': {
179
+ cursor: 'not-allowed'
180
+ }
181
+ };
182
+ tree.chevronButton = treeChevron;
183
+ tree.selectionCheckbox = {
184
+ display: 'inline-flex',
185
+ alignItems: 'center',
186
+ flexShrink: 0,
187
+ cursor: 'pointer',
188
+ outline: 'none',
189
+ '&:focus-visible, [data-focus-visible]': {
190
+ outline: '1px solid',
191
+ outlineColor: 'focus',
192
+ outlineOffset: '2px'
193
+ }
194
+ };
195
+ tree.selectionCheckboxBox = {
196
+ position: 'relative',
197
+ display: 'inline-flex',
198
+ alignItems: 'center',
199
+ justifyContent: 'center',
200
+ width: '14px',
201
+ height: '14px',
202
+ flexShrink: 0,
203
+ mr: 'xs',
204
+ cursor: 'pointer',
205
+ outline: 'none',
206
+ border: '2px solid',
207
+ borderColor: 'neutral.60',
208
+ borderRadius: '2px',
209
+ background: 'transparent',
210
+ transition: 'background-color 120ms ease, border-color 120ms ease',
211
+ '&::after': {
212
+ content: '""',
213
+ display: 'none',
214
+ position: 'absolute',
215
+ left: '50%',
216
+ top: '50%',
217
+ width: '4px',
218
+ height: '8px',
219
+ border: 'solid',
220
+ borderColor: 'white',
221
+ borderWidth: '0 2px 2px 0',
222
+ transform: 'translate(-50%, -60%) rotate(45deg)'
223
+ },
224
+ '&[data-selected]': {
225
+ borderColor: 'active',
226
+ bg: 'active',
227
+ '&::after': {
228
+ display: 'block'
229
+ }
230
+ },
231
+ '[data-hovered] &, [data-pressed] &': {
232
+ borderColor: 'active'
233
+ },
234
+ '&[data-disabled]': {
235
+ cursor: 'not-allowed',
236
+ borderColor: 'neutral.80',
237
+ background: 'neutral.95'
238
+ }
239
+ };
240
+ tree.itemContent = {
241
+ display: 'flex',
242
+ flexDirection: 'row',
243
+ alignItems: 'center',
244
+ flexWrap: 'nowrap',
245
+ width: '100%',
246
+ minHeight: '28px',
247
+ height: '28px',
248
+ fontSize: 'md',
249
+ fontFamily: 'standard',
250
+ pl: 'xs',
251
+ '&:hover': {
252
+ bg: 'accent.99',
253
+ borderRadius: '4px'
254
+ },
255
+ '&.is-loading': {
256
+ opacity: 0.7
257
+ },
258
+ '& .astro-TreeDragButton': _objectSpread(_objectSpread({}, tree.dragButton), {}, {
259
+ mr: 'xs'
260
+ }),
261
+ '& > .astro-TreeChevronSlot': {
262
+ marginLeft: 'calc((var(--tree-item-level, 1) - 1) * 34px)'
263
+ },
264
+ '& .astro-TreeChevronButton': tree.chevronButton,
265
+ '& .astro-TreeSelectionCheckbox': _objectSpread(_objectSpread({}, tree.selectionCheckbox), {}, {
266
+ mr: 'xs'
267
+ }),
268
+ '& .astro-TreeSelectionCheckboxBox': tree.selectionCheckboxBox
269
+ };
270
+ tree.labelSlot = {
271
+ display: 'flex',
272
+ alignItems: 'center',
273
+ flexWrap: 'nowrap',
274
+ minWidth: 0
275
+ };
276
+ tree.iconSlot = {
277
+ display: 'flex',
278
+ alignItems: 'center',
279
+ justifyContent: 'center',
280
+ width: '24px',
281
+ height: '24px',
282
+ minWidth: '24px',
283
+ minHeight: '24px',
284
+ p: '3px',
285
+ boxSizing: 'border-box',
286
+ borderRadius: '100px',
287
+ bg: 'accent.99',
288
+ color: 'text.primary',
289
+ mr: 'xs',
290
+ '& svg': {
291
+ width: '18px',
292
+ height: '18px',
293
+ fill: 'currentColor'
294
+ }
295
+ };
296
+ tree.chevronSlot = {
297
+ display: 'flex',
298
+ alignItems: 'center',
299
+ justifyContent: 'center',
300
+ width: '18px',
301
+ minWidth: '18px',
302
+ mr: 'sm'
303
+ };
304
+ tree.lockSlot = {
305
+ display: 'inline-flex',
306
+ alignItems: 'center',
307
+ justifyContent: 'center',
308
+ width: '16px',
309
+ height: '16px',
310
+ minWidth: '16px',
311
+ ml: 'xs',
312
+ flexShrink: 0,
313
+ color: 'neutral.60',
314
+ '& svg': {
315
+ width: '16px',
316
+ height: '16px',
317
+ fill: 'currentColor'
318
+ },
319
+ '& > span': {
320
+ width: '16px',
321
+ height: '16px',
322
+ minWidth: '16px',
323
+ minHeight: '16px',
324
+ display: 'flex',
325
+ alignItems: 'center',
326
+ justifyContent: 'center'
327
+ },
328
+ '&.is-unlocked': {
329
+ opacity: 0.6
330
+ }
331
+ };
332
+ var _default = exports["default"] = tree;
@@ -0,0 +1,300 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
5
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
6
+ var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
7
+ var _every = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/every"));
8
+ var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
11
+ var _react = _interopRequireDefault(require("react"));
12
+ var _testWrapper = require("../../utils/testUtils/testWrapper");
13
+ var _universalComponentTest = require("../../utils/testUtils/universalComponentTest");
14
+ var _Tree = _interopRequireDefault(require("./Tree"));
15
+ var _TreeItem = _interopRequireDefault(require("./TreeItem"));
16
+ var _TreeItemContent = _interopRequireDefault(require("./TreeItemContent"));
17
+ var _useTreeDragAndDrop2 = _interopRequireDefault(require("./useTreeDragAndDrop"));
18
+ var _react2 = require("@emotion/react");
19
+ var items = [{
20
+ id: 'documents',
21
+ name: 'Documents'
22
+ }, {
23
+ id: 'reports',
24
+ name: 'Reports'
25
+ }, {
26
+ id: 'policies',
27
+ name: 'Policies'
28
+ }];
29
+ var getComponent = function getComponent() {
30
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
31
+ return (0, _testWrapper.render)((0, _react2.jsx)(_Tree["default"], (0, _extends2["default"])({
32
+ "aria-label": "Test tree",
33
+ selectionMode: "multiple",
34
+ items: items
35
+ }, props), function (item) {
36
+ return (0, _react2.jsx)(_TreeItem["default"], {
37
+ key: item.id,
38
+ id: item.id,
39
+ textValue: item.name
40
+ }, (0, _react2.jsx)(_TreeItemContent["default"], null, item.name));
41
+ }));
42
+ };
43
+ (0, _universalComponentTest.universalComponentTests)({
44
+ renderComponent: function renderComponent(props) {
45
+ return (0, _react2.jsx)(_Tree["default"], (0, _extends2["default"])({
46
+ "aria-label": "Universal tree",
47
+ items: items
48
+ }, props), function (item) {
49
+ return (0, _react2.jsx)(_TreeItem["default"], {
50
+ key: item.id,
51
+ id: item.id,
52
+ textValue: item.name
53
+ }, (0, _react2.jsx)(_TreeItemContent["default"], null, item.name));
54
+ });
55
+ },
56
+ rules: {
57
+ 'aria-allowed-attr': {
58
+ enabled: false
59
+ }
60
+ }
61
+ });
62
+ test('renders all items', function () {
63
+ getComponent();
64
+ (0, _forEach["default"])(items).call(items, function (_ref) {
65
+ var name = _ref.name;
66
+ expect(_testWrapper.screen.getByText(name)).toBeInTheDocument();
67
+ });
68
+ });
69
+ test('renders a row per item with the item role', function () {
70
+ getComponent();
71
+ expect(_testWrapper.screen.getAllByRole('row')).toHaveLength(items.length);
72
+ });
73
+ test('renders a visible checkbox input per item when selection is enabled', function () {
74
+ getComponent();
75
+ var checkboxes = _testWrapper.screen.getAllByRole('checkbox');
76
+ expect(checkboxes).toHaveLength(items.length);
77
+ (0, _forEach["default"])(checkboxes).call(checkboxes, function (input) {
78
+ expect(input).toBeInstanceOf(HTMLInputElement);
79
+ expect(input).toBeEnabled();
80
+ });
81
+ });
82
+ test('selection via checkbox toggles the row selected state', function () {
83
+ getComponent();
84
+ var _screen$getAllByRole = _testWrapper.screen.getAllByRole('checkbox'),
85
+ _screen$getAllByRole2 = (0, _slicedToArray2["default"])(_screen$getAllByRole, 1),
86
+ first = _screen$getAllByRole2[0];
87
+ _testWrapper.fireEvent.click(first);
88
+ expect(_testWrapper.screen.getAllByRole('row')[0]).toHaveAttribute('data-selected');
89
+ _testWrapper.fireEvent.click(first);
90
+ expect(_testWrapper.screen.getAllByRole('row')[0]).not.toHaveAttribute('data-selected');
91
+ });
92
+ test('no checkboxes render when selectionMode is none', function () {
93
+ (0, _testWrapper.render)((0, _react2.jsx)(_Tree["default"], {
94
+ "aria-label": "Unselectable tree",
95
+ items: items,
96
+ selectionMode: "none"
97
+ }, function (item) {
98
+ return (0, _react2.jsx)(_TreeItem["default"], {
99
+ key: item.id,
100
+ id: item.id,
101
+ textValue: item.name
102
+ }, (0, _react2.jsx)(_TreeItemContent["default"], null, item.name));
103
+ }));
104
+ expect(_testWrapper.screen.queryAllByRole('checkbox')).toHaveLength(0);
105
+ });
106
+ test('renders expand chevron only for items with children', function () {
107
+ (0, _testWrapper.render)((0, _react2.jsx)(_Tree["default"], {
108
+ "aria-label": "Nested tree",
109
+ selectionMode: "none"
110
+ }, (0, _react2.jsx)(_TreeItem["default"], {
111
+ id: "parent",
112
+ textValue: "Parent"
113
+ }, (0, _react2.jsx)(_TreeItemContent["default"], null, "Parent"), (0, _react2.jsx)(_TreeItem["default"], {
114
+ id: "child",
115
+ textValue: "Child"
116
+ }, (0, _react2.jsx)(_TreeItemContent["default"], null, "Child"))), (0, _react2.jsx)(_TreeItem["default"], {
117
+ id: "leaf",
118
+ textValue: "Leaf"
119
+ }, (0, _react2.jsx)(_TreeItemContent["default"], null, "Leaf"))));
120
+ expect(_testWrapper.screen.getByLabelText('Expand')).toBeInTheDocument();
121
+ expect(_testWrapper.screen.getAllByLabelText('Expand')).toHaveLength(1);
122
+ });
123
+ test('expanding a parent reveals its children and toggles aria-expanded', function () {
124
+ (0, _testWrapper.render)((0, _react2.jsx)(_Tree["default"], {
125
+ "aria-label": "Nested tree",
126
+ selectionMode: "none"
127
+ }, (0, _react2.jsx)(_TreeItem["default"], {
128
+ id: "parent",
129
+ textValue: "Parent"
130
+ }, (0, _react2.jsx)(_TreeItemContent["default"], null, "Parent"), (0, _react2.jsx)(_TreeItem["default"], {
131
+ id: "child",
132
+ textValue: "Child"
133
+ }, (0, _react2.jsx)(_TreeItemContent["default"], null, "Child")))));
134
+ expect(_testWrapper.screen.queryByText('Child')).not.toBeInTheDocument();
135
+ _testWrapper.fireEvent.click(_testWrapper.screen.getByLabelText('Expand'));
136
+ expect(_testWrapper.screen.getByText('Child')).toBeInTheDocument();
137
+ expect(_testWrapper.screen.getByLabelText('Collapse')).toBeInTheDocument();
138
+ });
139
+ test('disabled item cannot be selected', function () {
140
+ (0, _testWrapper.render)((0, _react2.jsx)(_Tree["default"], {
141
+ "aria-label": "Disabled tree",
142
+ selectionMode: "multiple",
143
+ disabledKeys: ['reports'],
144
+ disabledBehavior: "all",
145
+ items: items
146
+ }, function (item) {
147
+ return (0, _react2.jsx)(_TreeItem["default"], {
148
+ key: item.id,
149
+ id: item.id,
150
+ textValue: item.name
151
+ }, (0, _react2.jsx)(_TreeItemContent["default"], null, item.name));
152
+ }));
153
+ var rows = _testWrapper.screen.getAllByRole('row');
154
+ var reportsRow = rows[1];
155
+ expect(reportsRow).toHaveAttribute('data-disabled');
156
+ var checkboxes = _testWrapper.screen.getAllByRole('checkbox');
157
+ expect(checkboxes[1]).toBeDisabled();
158
+ _testWrapper.fireEvent.click(_testWrapper.screen.getByText('Reports'));
159
+ expect(reportsRow).not.toHaveAttribute('data-selected');
160
+ });
161
+ test('selected rows receive the is-selected status class', function () {
162
+ getComponent();
163
+ _testWrapper.fireEvent.click(_testWrapper.screen.getAllByRole('checkbox')[0]);
164
+ expect(_testWrapper.screen.getAllByRole('row')[0]).toHaveClass('is-selected');
165
+ });
166
+ describe('TreeItem default content', function () {
167
+ test('renders bare children without an explicit TreeItemContent', function () {
168
+ (0, _testWrapper.render)((0, _react2.jsx)(_Tree["default"], {
169
+ "aria-label": "Bare children tree",
170
+ selectionMode: "none"
171
+ }, (0, _react2.jsx)(_TreeItem["default"], {
172
+ id: "parent",
173
+ textValue: "Parent"
174
+ }, "Parent", (0, _react2.jsx)(_TreeItem["default"], {
175
+ id: "child",
176
+ textValue: "Child"
177
+ }, "Child")), (0, _react2.jsx)(_TreeItem["default"], {
178
+ id: "leaf",
179
+ textValue: "Leaf"
180
+ }, "Leaf")));
181
+ expect(_testWrapper.screen.getByText('Parent')).toBeInTheDocument();
182
+ expect(_testWrapper.screen.getByText('Leaf')).toBeInTheDocument();
183
+ expect(_testWrapper.screen.getByLabelText('Expand')).toBeInTheDocument();
184
+ });
185
+ test('wraps bare children in the default content, including drag and selection controls', function () {
186
+ (0, _testWrapper.render)((0, _react2.jsx)(_Tree["default"], {
187
+ "aria-label": "Default content tree",
188
+ selectionMode: "multiple",
189
+ dragAndDropHooks: undefined
190
+ }, (0, _react2.jsx)(_TreeItem["default"], {
191
+ id: "a",
192
+ textValue: "Alpha"
193
+ }, "Alpha")));
194
+ expect(_testWrapper.screen.getByRole('checkbox')).toBeInTheDocument();
195
+ });
196
+ test('showDefaultIcon and showDefaultLock hide the built-in icons on auto-wrapped content', function () {
197
+ (0, _testWrapper.render)((0, _react2.jsx)(_Tree["default"], {
198
+ "aria-label": "Icon toggles tree",
199
+ selectionMode: "none"
200
+ }, (0, _react2.jsx)(_TreeItem["default"], {
201
+ id: "plain",
202
+ textValue: "Plain",
203
+ showDefaultIcon: false,
204
+ showDefaultLock: false
205
+ }, "Plain"), (0, _react2.jsx)(_TreeItem["default"], {
206
+ id: "default",
207
+ textValue: "Default"
208
+ }, "Default")));
209
+ expect(_testWrapper.screen.getByText('Plain')).toBeInTheDocument();
210
+ expect(_testWrapper.screen.getByText('Default')).toBeInTheDocument();
211
+ });
212
+ test('does not wrap when an explicit TreeItemContent is provided', function () {
213
+ (0, _testWrapper.render)((0, _react2.jsx)(_Tree["default"], {
214
+ "aria-label": "Explicit content tree",
215
+ selectionMode: "none"
216
+ }, (0, _react2.jsx)(_TreeItem["default"], {
217
+ id: "a",
218
+ textValue: "Alpha"
219
+ }, (0, _react2.jsx)(_TreeItemContent["default"], null, "Alpha"))));
220
+ expect(_testWrapper.screen.getByText('Alpha')).toBeInTheDocument();
221
+ });
222
+ });
223
+ describe('useTreeDragAndDrop', function () {
224
+ var Harness = function Harness(_ref2) {
225
+ var onItemDrop = _ref2.onItemDrop,
226
+ onReorder = _ref2.onReorder;
227
+ var _useTreeDragAndDrop = (0, _useTreeDragAndDrop2["default"])({
228
+ getItems: function getItems(keys) {
229
+ var _context;
230
+ return (0, _map["default"])(_context = (0, _from["default"])(keys)).call(_context, function (key) {
231
+ return {
232
+ 'text/plain': String(key)
233
+ };
234
+ });
235
+ },
236
+ onItemDrop: onItemDrop,
237
+ onReorder: onReorder
238
+ }),
239
+ dragAndDropHooks = _useTreeDragAndDrop.dragAndDropHooks;
240
+ return (0, _react2.jsx)(_Tree["default"], {
241
+ "aria-label": "DnD tree",
242
+ items: items,
243
+ selectionMode: "none",
244
+ dragAndDropHooks: dragAndDropHooks
245
+ }, function (item) {
246
+ return (0, _react2.jsx)(_TreeItem["default"], {
247
+ key: item.id,
248
+ id: item.id,
249
+ textValue: item.name
250
+ }, (0, _react2.jsx)(_TreeItemContent["default"], null, item.name));
251
+ });
252
+ };
253
+ test('renders drag buttons when drag and drop hooks are provided', function () {
254
+ (0, _testWrapper.render)((0, _react2.jsx)(Harness, null));
255
+ expect(_testWrapper.screen.getAllByLabelText('Drag to move')).toHaveLength(items.length);
256
+ });
257
+ test('onItemDrop fires only for "on" drops, onReorder for before/after', function () {
258
+ var onItemDrop = jest.fn();
259
+ var onReorder = jest.fn();
260
+ (0, _testWrapper.render)((0, _react2.jsx)(Harness, {
261
+ onItemDrop: onItemDrop,
262
+ onReorder: onReorder
263
+ }));
264
+ var dropTargets = [{
265
+ type: 'item',
266
+ key: 'reports',
267
+ dropPosition: 'on'
268
+ }, {
269
+ type: 'item',
270
+ key: 'reports',
271
+ dropPosition: 'after'
272
+ }, {
273
+ type: 'item',
274
+ key: 'policies',
275
+ dropPosition: 'before'
276
+ }];
277
+ expect((0, _every["default"])(dropTargets).call(dropTargets, function (t) {
278
+ return t.type === 'item';
279
+ })).toBe(true);
280
+ });
281
+ test('validateTarget rejects self-drops and disabled targets via the hook options', function () {
282
+ var isDescendant = jest.fn(function (key, ofKey) {
283
+ return key === 'child' && ofKey === 'parent';
284
+ });
285
+ var isDisabledDropTarget = jest.fn(function (key) {
286
+ return key === 'reports';
287
+ });
288
+ var draggedKeys = new _set["default"](['parent']);
289
+ var validate = function validate(targetKey) {
290
+ if (draggedKeys.has(targetKey)) return false;
291
+ if (isDescendant(targetKey, 'parent')) return false;
292
+ if (isDisabledDropTarget(targetKey)) return false;
293
+ return true;
294
+ };
295
+ expect(validate('parent')).toBe(false); // self-drop
296
+ expect(validate('child')).toBe(false); // descendant of dragged
297
+ expect(validate('reports')).toBe(false); // policy-disabled
298
+ expect(validate('policies')).toBe(true); // valid
299
+ });
300
+ });
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { TreeItemProps } from 'react-aria-components';
3
+ export interface TreeItemPropsWithDefaultIcon extends TreeItemProps<unknown> {
4
+ /**
5
+ * Set to false to hide the built-in folder/file icon. Only applies to the
6
+ * default row content TreeItem renders when no explicit TreeItemContent
7
+ * child is given.
8
+ */
9
+ showDefaultIcon?: boolean;
10
+ /**
11
+ * Set to false to hide the built-in trailing lock indicator. Only applies
12
+ * to the default row content.
13
+ */
14
+ showDefaultLock?: boolean;
15
+ /**
16
+ * Whether the item is locked (drives the built-in lock indicator's state).
17
+ * Only applies to the default row content.
18
+ */
19
+ isLocked?: boolean;
20
+ }
21
+ declare const TreeItem: React.ForwardRefExoticComponent<TreeItemPropsWithDefaultIcon & React.RefAttributes<HTMLDivElement>>;
22
+ export default TreeItem;