@pingux/astro 2.154.1 → 2.155.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/lib/cjs/components/Button/Buttons.styles.d.ts +859 -0
  2. package/lib/cjs/components/Button/Buttons.styles.js +17 -1
  3. package/lib/cjs/components/Card/Card.mdx +5 -1
  4. package/lib/cjs/components/Card/Card.stories.d.ts +1 -0
  5. package/lib/cjs/components/Card/Card.stories.js +11 -2
  6. package/lib/cjs/components/SearchNav/MoreItemsPopover.d.ts +4 -0
  7. package/lib/cjs/components/SearchNav/MoreItemsPopover.js +74 -0
  8. package/lib/cjs/components/SearchNav/SearchNav.chromatic.stories.d.ts +6 -0
  9. package/lib/cjs/components/SearchNav/SearchNav.chromatic.stories.js +101 -0
  10. package/lib/cjs/components/SearchNav/SearchNav.d.ts +13 -0
  11. package/lib/cjs/components/SearchNav/SearchNav.js +218 -0
  12. package/lib/cjs/components/SearchNav/SearchNav.stories.d.ts +6 -0
  13. package/lib/cjs/components/SearchNav/SearchNav.stories.js +76 -0
  14. package/lib/cjs/components/SearchNav/SearchNav.styles.d.ts +33 -0
  15. package/lib/cjs/components/SearchNav/SearchNav.styles.js +51 -0
  16. package/lib/cjs/components/SearchNav/SearchNav.test.d.ts +1 -0
  17. package/lib/cjs/components/SearchNav/SearchNav.test.js +610 -0
  18. package/lib/cjs/components/SearchNav/SearchNavTab.d.ts +4 -0
  19. package/lib/cjs/components/SearchNav/SearchNavTab.js +69 -0
  20. package/lib/cjs/components/SearchNav/index.d.ts +1 -0
  21. package/lib/cjs/components/SearchNav/index.js +14 -0
  22. package/lib/cjs/components/Text/Text.styles.d.ts +2548 -0
  23. package/lib/cjs/components/Text/Text.styles.js +23 -1
  24. package/lib/cjs/index.d.ts +2 -0
  25. package/lib/cjs/index.js +45 -26
  26. package/lib/cjs/styles/colors.d.ts +6 -0
  27. package/lib/cjs/styles/colors.js +4 -0
  28. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/colors.d.ts +1 -0
  29. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/colors.js +2 -1
  30. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/buttons.d.ts +9 -0
  31. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/buttons.js +10 -0
  32. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/cards.d.ts +14 -0
  33. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/cards.js +18 -4
  34. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/text.d.ts +12 -0
  35. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/text.js +12 -0
  36. package/lib/cjs/styles/themes/next-gen/convertedComponentList.d.ts +1 -0
  37. package/lib/cjs/styles/themes/next-gen/convertedComponentList.js +3 -2
  38. package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +37 -2
  39. package/lib/cjs/styles/themes/next-gen/next-gen.js +3 -0
  40. package/lib/cjs/styles/themes/next-gen/variants/button.d.ts +9 -0
  41. package/lib/cjs/styles/themes/next-gen/variants/button.js +10 -0
  42. package/lib/cjs/styles/themes/next-gen/variants/cards.d.ts +19 -2
  43. package/lib/cjs/styles/themes/next-gen/variants/cards.js +14 -5
  44. package/lib/cjs/styles/themes/next-gen/variants/searchNav.d.ts +6 -0
  45. package/lib/cjs/styles/themes/next-gen/variants/searchNav.js +14 -0
  46. package/lib/cjs/styles/themes/next-gen/variants/text.d.ts +1 -0
  47. package/lib/cjs/styles/themes/next-gen/variants/text.js +2 -1
  48. package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +5 -0
  49. package/lib/cjs/styles/themes/next-gen/variants/variants.js +2 -0
  50. package/lib/cjs/styles/variants/variants.js +2 -0
  51. package/lib/cjs/types/searchNav.d.ts +49 -0
  52. package/lib/cjs/types/searchNav.js +6 -0
  53. package/lib/components/Button/Buttons.styles.js +18 -2
  54. package/lib/components/Card/Card.mdx +5 -1
  55. package/lib/components/Card/Card.stories.js +8 -0
  56. package/lib/components/SearchNav/MoreItemsPopover.js +60 -0
  57. package/lib/components/SearchNav/SearchNav.chromatic.stories.js +86 -0
  58. package/lib/components/SearchNav/SearchNav.js +203 -0
  59. package/lib/components/SearchNav/SearchNav.stories.js +61 -0
  60. package/lib/components/SearchNav/SearchNav.styles.js +43 -0
  61. package/lib/components/SearchNav/SearchNav.test.js +601 -0
  62. package/lib/components/SearchNav/SearchNavTab.js +55 -0
  63. package/lib/components/SearchNav/index.js +1 -0
  64. package/lib/components/Text/Text.styles.js +21 -1
  65. package/lib/index.js +2 -0
  66. package/lib/styles/colors.js +4 -0
  67. package/lib/styles/themeOverrides/nextGenDarkMode/colors.js +2 -1
  68. package/lib/styles/themeOverrides/nextGenDarkMode/variants/buttons.js +10 -0
  69. package/lib/styles/themeOverrides/nextGenDarkMode/variants/cards.js +18 -4
  70. package/lib/styles/themeOverrides/nextGenDarkMode/variants/text.js +12 -0
  71. package/lib/styles/themes/next-gen/convertedComponentList.js +3 -2
  72. package/lib/styles/themes/next-gen/next-gen.js +3 -0
  73. package/lib/styles/themes/next-gen/variants/button.js +10 -0
  74. package/lib/styles/themes/next-gen/variants/cards.js +14 -5
  75. package/lib/styles/themes/next-gen/variants/searchNav.js +6 -0
  76. package/lib/styles/themes/next-gen/variants/text.js +2 -1
  77. package/lib/styles/themes/next-gen/variants/variants.js +2 -0
  78. package/lib/styles/variants/variants.js +2 -0
  79. package/lib/types/searchNav.js +1 -0
  80. package/package.json +1 -1
@@ -0,0 +1,601 @@
1
+ import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
2
+ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
3
+ import _createClass from "@babel/runtime-corejs3/helpers/esm/createClass";
4
+ import _classCallCheck from "@babel/runtime-corejs3/helpers/esm/classCallCheck";
5
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
6
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
7
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
8
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context7; _forEachInstanceProperty(_context7 = ["next", "throw", "return"]).call(_context7, function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = _Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return _reverseInstanceProperty(keys).call(keys), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { var _context8; if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context8 = this.tryEntries).call(_context8, resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
9
+ import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
10
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
11
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
12
+ import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
13
+ import _Object$create from "@babel/runtime-corejs3/core-js-stable/object/create";
14
+ import _Object$getPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/get-prototype-of";
15
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
16
+ import _Object$setPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/set-prototype-of";
17
+ import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
18
+ import _reverseInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reverse";
19
+ import React, { useState } from 'react';
20
+ import userEvent from '@testing-library/user-event';
21
+ import { Box, Text } from '../../index';
22
+ import { act, render, screen, waitFor } from '../../utils/testUtils/testWrapper';
23
+ import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
24
+ import SearchNav, { calculateVisibleCount, measureItemWidths } from './SearchNav';
25
+ import { jsx as ___EmotionJSX } from "@emotion/react";
26
+ var items = [{
27
+ text: 'Overview',
28
+ key: 'Overview',
29
+ children: ___EmotionJSX(Text, null, "Overview body")
30
+ }, {
31
+ text: 'Configuration',
32
+ key: 'Configuration',
33
+ children: ___EmotionJSX(Text, null, "Configuration body")
34
+ }, {
35
+ text: 'Resources',
36
+ key: 'Resources',
37
+ children: ___EmotionJSX(Text, null, "Resources body")
38
+ }, {
39
+ text: 'Policies',
40
+ key: 'Policies',
41
+ children: ___EmotionJSX(Text, null, "Policies body")
42
+ }, {
43
+ text: 'Attribute Mappings',
44
+ key: 'Attribute Mappings',
45
+ children: ___EmotionJSX(Text, null, "Attribute body")
46
+ }, {
47
+ text: 'Access',
48
+ key: 'Access',
49
+ children: ___EmotionJSX(Text, null, "Access body")
50
+ }, {
51
+ text: 'Integration',
52
+ key: 'Integration',
53
+ children: ___EmotionJSX(Text, null, "Integration body")
54
+ }];
55
+ var testId = 'searchNavId';
56
+ var onSelectionChangeCallback = jest.fn();
57
+ var onOpenChangeCallback = jest.fn();
58
+ var defaultProps = {
59
+ items: items,
60
+ 'data-testid': testId,
61
+ onSelectionChange: onSelectionChangeCallback
62
+ };
63
+ var MORE_BUTTON_TEXT = 'More';
64
+ var TAB_ITEM_WIDTH = 100;
65
+ var offsetWidthMock;
66
+ var mockContainerWidth = 0;
67
+ var TestComponent = function TestComponent(props) {
68
+ var _items$find;
69
+ var _useState = useState(items[0].key),
70
+ _useState2 = _slicedToArray(_useState, 2),
71
+ selectedKey = _useState2[0],
72
+ setSelectedKey = _useState2[1];
73
+ var setSelectedKeyCallback = function setSelectedKeyCallback(e) {
74
+ setSelectedKey(e);
75
+ };
76
+ return ___EmotionJSX(Box, {
77
+ maxWidth: "600px"
78
+ }, ___EmotionJSX(SearchNav, _extends({}, props, {
79
+ items: items,
80
+ selectedKey: selectedKey,
81
+ setSelectedKey: function setSelectedKey(e) {
82
+ return setSelectedKeyCallback(e);
83
+ }
84
+ })), (_items$find = _findInstanceProperty(items).call(items, function (item) {
85
+ return item.key === selectedKey;
86
+ })) === null || _items$find === void 0 ? void 0 : _items$find.children);
87
+ };
88
+ var resizeObserverCallback = null;
89
+
90
+ // Mock the global ResizeObserver
91
+ var MockResizeObserver = /*#__PURE__*/_createClass(function MockResizeObserver(callback) {
92
+ _classCallCheck(this, MockResizeObserver);
93
+ _defineProperty(this, "observe", jest.fn());
94
+ _defineProperty(this, "unobserve", jest.fn());
95
+ _defineProperty(this, "disconnect", jest.fn());
96
+ resizeObserverCallback = callback;
97
+ });
98
+ beforeAll(function () {
99
+ // Overwrite the global ResizeObserver for testing environment
100
+ _Object$defineProperty(global, 'ResizeObserver', {
101
+ value: MockResizeObserver,
102
+ writable: true
103
+ });
104
+ });
105
+ beforeEach(function () {
106
+ mockContainerWidth = 1000; // Default large container width
107
+
108
+ // Mock offsetWidth to return different values for container and children
109
+ offsetWidthMock = jest.spyOn(window.HTMLElement.prototype, 'offsetWidth', 'get').mockImplementation(function () {
110
+ // The tab list container is identified by its role="list"
111
+ if (this.getAttribute('role') === 'list') {
112
+ return mockContainerWidth;
113
+ }
114
+ // The individual items are the <Text> components in the hidden box
115
+ return TAB_ITEM_WIDTH;
116
+ });
117
+ jest.useFakeTimers();
118
+ });
119
+ afterEach(function () {
120
+ offsetWidthMock.mockRestore();
121
+ jest.useRealTimers();
122
+ });
123
+
124
+ // Needs to be added to each components test file
125
+ universalComponentTests({
126
+ renderComponent: function renderComponent(props) {
127
+ return ___EmotionJSX(SearchNav, _extends({}, props, {
128
+ items: items
129
+ }));
130
+ }
131
+ });
132
+ var getComponent = function getComponent(props) {
133
+ return render(___EmotionJSX(TestComponent, _extends({}, defaultProps, props)));
134
+ };
135
+ var MORE_BUTTON_WIDTH = 60; // Use the value from your component
136
+
137
+ describe('Pure Functions Tests', function () {
138
+ // Test the measurement function
139
+ it('measureItemWidths correctly measures the offsetWidth of items', function () {
140
+ // Mock the input data: items array and a refs object with mock offsetWidths
141
+ var mockItems = [{
142
+ key: '1',
143
+ text: 'Item One'
144
+ }, {
145
+ key: '2',
146
+ text: 'Item Two'
147
+ }];
148
+ var mockMeasurementRefs = {
149
+ current: {
150
+ '1': {
151
+ offsetWidth: 100
152
+ },
153
+ '2': {
154
+ offsetWidth: 150
155
+ },
156
+ '3': null // handle missing refs
157
+ }
158
+ };
159
+
160
+ var widths = measureItemWidths(mockItems, mockMeasurementRefs);
161
+
162
+ // Assert the expected output
163
+ expect(widths).toEqual({
164
+ '1': 100,
165
+ '2': 150
166
+ });
167
+ });
168
+
169
+ // Test the core logic for calculating visible count
170
+ describe('calculateVisibleCount', function () {
171
+ var mockOrderedItems = _sliceInstanceProperty(items).call(items, 0, 3); // Overview, Configuration, Resources
172
+ // Mock widths for these 3 items (width + margin)
173
+ // Overview: 90 + 10 = 100 total width
174
+ // Config: 120 + 10 = 130 total width
175
+ // Resources: 100 + 10 = 110 total width
176
+ var mockItemWidths = {
177
+ 'Overview': 90,
178
+ 'Configuration': 120,
179
+ 'Resources': 100
180
+ };
181
+ var moreButtonWidth = MORE_BUTTON_WIDTH; // 60px
182
+
183
+ it('returns the total count when all items fit within the container', function () {
184
+ // Container width: 100 + 130 + 110 = 340 needed. Set wide enough (e.g., 500)
185
+ var containerWidthFull = 500;
186
+ var visibleCount = calculateVisibleCount(containerWidthFull, moreButtonWidth, mockOrderedItems, mockItemWidths);
187
+ expect(visibleCount).toBe(3);
188
+ });
189
+ it('breaks when adding an item and the required space for the "More" button exceeds container width', function () {
190
+ // Set container width to only allow the first two items and the "More" button
191
+ var containerWidthPartial = 290;
192
+ var visibleCount = calculateVisibleCount(containerWidthPartial, moreButtonWidth, mockOrderedItems, mockItemWidths);
193
+ // It should fit the first two, but break on the third, so count should be 2.
194
+ expect(visibleCount).toBe(2);
195
+ });
196
+ it('handles an edge case where no items can be visible', function () {
197
+ // Container width is too small to even fit one item's width + the "More" button width
198
+ var containerWidthTiny = 100;
199
+ var visibleCount = calculateVisibleCount(containerWidthTiny, moreButtonWidth, mockOrderedItems, mockItemWidths);
200
+ expect(visibleCount).toBe(0);
201
+ });
202
+ });
203
+ });
204
+ test('component does render', function () {
205
+ getComponent({
206
+ items: items
207
+ });
208
+ var searcgNavComponent = screen.getByTestId(testId);
209
+ expect(searcgNavComponent).toBeInTheDocument();
210
+ });
211
+ test('visible tab selection updates the selected key and content', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
212
+ var resourcesTab;
213
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
214
+ while (1) switch (_context.prev = _context.next) {
215
+ case 0:
216
+ // Setup: Ensure all tabs fit (default mockContainerWidth=1000)
217
+ getComponent({
218
+ items: items
219
+ });
220
+ jest.advanceTimersByTime(100);
221
+
222
+ // Initial state: 'Overview' is selected
223
+ expect(screen.getByText('Overview body')).toBeInTheDocument();
224
+
225
+ // Click 'Resources' tab
226
+ resourcesTab = screen.getByRole('link', {
227
+ name: 'Resources'
228
+ });
229
+ userEvent.click(resourcesTab);
230
+
231
+ // Expect selected key and content to change
232
+ _context.next = 7;
233
+ return screen.findByText('Resources body');
234
+ case 7:
235
+ case "end":
236
+ return _context.stop();
237
+ }
238
+ }, _callee);
239
+ })));
240
+ test('tabs show a "More" button when content overflows', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
241
+ var tabs, moreButton, hiddenItem;
242
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
243
+ while (1) switch (_context2.prev = _context2.next) {
244
+ case 0:
245
+ // Use a mock setup that only allows ONE tab to fit:
246
+ offsetWidthMock.mockImplementation(function () {
247
+ if (this.getAttribute('role') === 'list') {
248
+ // Container size only slightly larger than Tab 1's required width (100 + 30 = 130)
249
+ return 250;
250
+ }
251
+ return 100; // Item width
252
+ });
253
+
254
+ getComponent({
255
+ items: items
256
+ });
257
+
258
+ // Advance timers to trigger the visibility calculation
259
+ jest.advanceTimersByTime(100);
260
+
261
+ // Expect 1 visible tab and 2 hidden tabs
262
+ tabs = screen.getByRole('link');
263
+ expect(tabs).toBeInTheDocument(); // Only 'Tab 1' is visible
264
+
265
+ // Expect the "More" button to show the other 2 tabs
266
+ moreButton = screen.getByText(MORE_BUTTON_TEXT);
267
+ expect(moreButton).toBeInTheDocument();
268
+
269
+ // Test selection from the menu
270
+ userEvent.click(moreButton);
271
+ hiddenItem = screen.getByRole('menuitem', {
272
+ name: 'Access'
273
+ });
274
+ userEvent.click(hiddenItem);
275
+
276
+ // // Expect Tab 2 content to be shown
277
+ if (!items[1].children) {
278
+ _context2.next = 13;
279
+ break;
280
+ }
281
+ _context2.next = 13;
282
+ return screen.findByText('Access body');
283
+ case 13:
284
+ expect(onSelectionChangeCallback).toHaveBeenCalled();
285
+ case 14:
286
+ case "end":
287
+ return _context2.stop();
288
+ }
289
+ }, _callee2);
290
+ })));
291
+ test('hidden tab selection updates key, content, and triggers swap', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
292
+ var moreButton, resourcesMenuItem;
293
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
294
+ while (1) switch (_context3.prev = _context3.next) {
295
+ case 0:
296
+ // Setup: Mock widths so only the first 2 tabs fit (2 * 110 = 220 + 40(More) = 260)
297
+ // Set container to 300px
298
+ mockContainerWidth = 300;
299
+ getComponent({
300
+ items: items,
301
+ onOpenChange: onOpenChangeCallback
302
+ });
303
+ jest.advanceTimersByTime(100);
304
+
305
+ // Initial check: 'Resources' is hidden, 'More' button is visible
306
+ moreButton = screen.getByText(MORE_BUTTON_TEXT);
307
+ expect(moreButton).toBeInTheDocument();
308
+
309
+ // Click 'More' button to open menu
310
+ userEvent.click(moreButton);
311
+
312
+ // Click 'Resources' (hidden item 3)
313
+ resourcesMenuItem = screen.getByRole('menuitem', {
314
+ name: 'Resources'
315
+ });
316
+ userEvent.click(resourcesMenuItem);
317
+
318
+ // 1. Expect content update
319
+ _context3.next = 10;
320
+ return screen.findByText('Resources body');
321
+ case 10:
322
+ _context3.next = 12;
323
+ return waitFor(function () {
324
+ // Check the final tab in the visible list (which should be 'Resources')
325
+ var visibleTabs = screen.getAllByRole('link');
326
+
327
+ // We expect 2 visible tabs: Tab 1 ('Overview') and the newly swapped-in tab ('Resources')
328
+ // We expect the 'More' button to be the third listitem
329
+ expect(visibleTabs.length).toBe(2);
330
+ });
331
+ case 12:
332
+ // 2. Expect swap: 'Resources' should now be visible as the
333
+ // second tab (since 'Configuration' was the second tab)
334
+ userEvent.click(moreButton);
335
+ _context3.next = 15;
336
+ return waitFor(function () {
337
+ // The displaced tab ('Configuration') should now be in the menu
338
+ expect(screen.getByRole('menuitem', {
339
+ name: 'Configuration'
340
+ })).toBeInTheDocument();
341
+ });
342
+ case 15:
343
+ expect(onOpenChangeCallback).toHaveBeenCalled();
344
+ case 16:
345
+ case "end":
346
+ return _context3.stop();
347
+ }
348
+ }, _callee3);
349
+ })));
350
+ test('resizing container to be very small hides all but one tab', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
351
+ var moreButton, longMenuItem;
352
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
353
+ while (1) switch (_context4.prev = _context4.next) {
354
+ case 0:
355
+ // Start large (mockContainerWidth = 1000)
356
+ mockContainerWidth = 1000;
357
+ getComponent({
358
+ items: items
359
+ });
360
+
361
+ // Initial calculation (from useLayoutEffect)
362
+ jest.advanceTimersByTime(100);
363
+
364
+ // Initial check: All 7 tabs should be visible
365
+ expect(screen.queryByText(MORE_BUTTON_TEXT)).not.toBeInTheDocument();
366
+
367
+ // --- Resize Step ---
368
+
369
+ // 1. Shrink: Set container size to allow only 1 tab (110px) + More button (40px) = 150px
370
+ mockContainerWidth = 250;
371
+
372
+ // 2. Manually trigger the ResizeObserver callback
373
+ // This tells the component the container dimensions have changed.
374
+
375
+ act(function () {
376
+ if (resizeObserverCallback) {
377
+ resizeObserverCallback([{
378
+ contentRect: {
379
+ width: mockContainerWidth
380
+ }
381
+ }]);
382
+ }
383
+ });
384
+
385
+ // 3. Advance timers to process state updates from the calculation
386
+ act(function () {
387
+ jest.advanceTimersByTime(100);
388
+ });
389
+
390
+ // 4. Final check: Only the first tab ('Overview') should remain visible
391
+ _context4.next = 9;
392
+ return waitFor(function () {
393
+ // The first tab should be visible
394
+ expect(screen.getByRole('link', {
395
+ name: 'Overview'
396
+ })).toBeInTheDocument();
397
+ });
398
+ case 9:
399
+ _context4.next = 11;
400
+ return waitFor(function () {
401
+ // The second tab should be hidden
402
+ expect(screen.queryByRole('link', {
403
+ name: 'Configuration'
404
+ })).not.toBeInTheDocument();
405
+ });
406
+ case 11:
407
+ _context4.next = 13;
408
+ return waitFor(function () {
409
+ expect(screen.getByText(MORE_BUTTON_TEXT)).toBeInTheDocument();
410
+ });
411
+ case 13:
412
+ _context4.next = 15;
413
+ return waitFor(function () {
414
+ var visibleListItems = screen.getAllByRole('listitem');
415
+ expect(visibleListItems.length).toBe(2);
416
+ });
417
+ case 15:
418
+ mockContainerWidth = 540;
419
+ act(function () {
420
+ if (resizeObserverCallback) {
421
+ resizeObserverCallback([{
422
+ contentRect: {
423
+ width: mockContainerWidth
424
+ }
425
+ }]);
426
+ }
427
+ });
428
+
429
+ // 3. Advance timers to process state updates from the calculation
430
+ act(function () {
431
+ jest.advanceTimersByTime(100);
432
+ });
433
+
434
+ // 4. Final check: Only the first tab ('Overview') should remain visible
435
+ _context4.next = 20;
436
+ return waitFor(function () {
437
+ // The first tab should be visible
438
+ expect(screen.getAllByRole('link').length).toBe(4);
439
+ });
440
+ case 20:
441
+ // await waitFor(() => {
442
+ moreButton = screen.getByText(MORE_BUTTON_TEXT);
443
+ expect(moreButton).toBeInTheDocument();
444
+
445
+ // Click 'More' button to open menu
446
+ userEvent.click(moreButton);
447
+
448
+ // Click 'Resources' (hidden item 3)
449
+ longMenuItem = screen.getByRole('menuitem', {
450
+ name: 'Attribute Mappings'
451
+ });
452
+ userEvent.click(longMenuItem);
453
+ act(function () {
454
+ jest.advanceTimersByTime(100);
455
+ });
456
+ case 26:
457
+ case "end":
458
+ return _context4.stop();
459
+ }
460
+ }, _callee4);
461
+ })));
462
+ test('recalculates visible items when More button causes an item to be hidden', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
463
+ var visibleListItems;
464
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
465
+ while (1) switch (_context5.prev = _context5.next) {
466
+ case 0:
467
+ // Setup: Container wide enough for 3 tabs, but NOT 3 tabs + More button.
468
+ mockContainerWidth = 350; // Max allowed width
469
+
470
+ // We ensure the mock returns 100 for items and 60 for the More button.
471
+ offsetWidthMock.mockImplementation(function () {
472
+ if (this.getAttribute('role') === 'list') {
473
+ return mockContainerWidth;
474
+ }
475
+ // Assume the 'More' button element has a specific class/role/text for measurement
476
+ // If your More button component has a fixed width in the test environment (60),
477
+ // this mock might not be necessary, but we include it for safety.
478
+ if (this.textContent === 'More') {
479
+ return 60;
480
+ }
481
+ return 100; // Item width
482
+ });
483
+
484
+ getComponent({
485
+ items: items
486
+ });
487
+
488
+ // Manually trigger the ResizeObserver/LayoutEffect calculation
489
+ act(function () {
490
+ if (resizeObserverCallback) {
491
+ resizeObserverCallback([{
492
+ contentRect: {
493
+ width: mockContainerWidth
494
+ }
495
+ }]);
496
+ jest.advanceTimersByTime(100);
497
+ } else {
498
+ act(function () {
499
+ jest.advanceTimersByTime(100);
500
+ });
501
+ }
502
+ });
503
+
504
+ // Wait for the state update (numVisibleItems = 2)
505
+ // await waitFor(() => {
506
+ // We expect only 2 tabs to be visible (Overview, Configuration)
507
+ // Tab 3 ('Resources') should be hidden.
508
+
509
+ expect(screen.getByRole('link', {
510
+ name: 'Overview'
511
+ })).toBeInTheDocument();
512
+ expect(screen.getByRole('link', {
513
+ name: 'Configuration'
514
+ })).toBeInTheDocument();
515
+ expect(screen.queryByRole('link', {
516
+ name: 'Resources'
517
+ })).not.toBeInTheDocument();
518
+
519
+ // The More button must be visible
520
+ expect(screen.getByText(MORE_BUTTON_TEXT)).toBeInTheDocument();
521
+
522
+ // Check the final count
523
+ visibleListItems = screen.getAllByRole('listitem');
524
+ expect(visibleListItems.length).toBe(3); // 2 tabs + 1 More button
525
+ // });
526
+ case 10:
527
+ case "end":
528
+ return _context5.stop();
529
+ }
530
+ }, _callee5);
531
+ })));
532
+ test('covers adjustment logic when More button overflows last item', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
533
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
534
+ while (1) switch (_context6.prev = _context6.next) {
535
+ case 0:
536
+ // Force a tight scenario:
537
+ // Container: 279. Max fit for 2 tabs (220). Max fit for 2 tabs + More (280).
538
+ mockContainerWidth = 279;
539
+
540
+ // We ensure the mock returns 100 for items and 60 for the More button.
541
+ offsetWidthMock.mockImplementation(function () {
542
+ if (this.getAttribute('role') === 'list') {
543
+ return mockContainerWidth;
544
+ }
545
+ if (this.textContent === 'More') {
546
+ return 60; // More button width
547
+ }
548
+
549
+ return 100; // Item width
550
+ });
551
+
552
+ getComponent({
553
+ items: items
554
+ });
555
+
556
+ // Manually trigger the ResizeObserver calculation
557
+ act(function () {
558
+ if (resizeObserverCallback) {
559
+ resizeObserverCallback([{
560
+ contentRect: {
561
+ width: mockContainerWidth
562
+ }
563
+ }]);
564
+ }
565
+ jest.advanceTimersByTime(100);
566
+ });
567
+
568
+ // Wait for the state update (numVisibleItems will be 1)
569
+ _context6.next = 6;
570
+ return waitFor(function () {
571
+ // The while loop should have run once, reducing visibleCount from 2 to 1.
572
+
573
+ expect(screen.getByRole('link', {
574
+ name: 'Overview'
575
+ })).toBeInTheDocument();
576
+ });
577
+ case 6:
578
+ _context6.next = 8;
579
+ return waitFor(function () {
580
+ expect(screen.queryByRole('link', {
581
+ name: 'Configuration'
582
+ })).not.toBeInTheDocument();
583
+ });
584
+ case 8:
585
+ _context6.next = 10;
586
+ return waitFor(function () {
587
+ expect(screen.getByText(MORE_BUTTON_TEXT)).toBeInTheDocument();
588
+ });
589
+ case 10:
590
+ _context6.next = 12;
591
+ return waitFor(function () {
592
+ // Total visible items: 1 tab + 1 More button
593
+ var visibleListItems = screen.getAllByRole('listitem');
594
+ expect(visibleListItems.length).toBe(2);
595
+ });
596
+ case 12:
597
+ case "end":
598
+ return _context6.stop();
599
+ }
600
+ }, _callee6);
601
+ })));
@@ -0,0 +1,55 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import React, { useRef } from 'react';
3
+ import { useFocusRing } from '@react-aria/focus';
4
+ import { useHover, usePress } from '@react-aria/interactions';
5
+ import { mergeProps } from '@react-aria/utils';
6
+ import { useStatusClasses } from '../../hooks';
7
+ import { Box, Text } from '../../index';
8
+ import { jsx as ___EmotionJSX } from "@emotion/react";
9
+ var SearchNavTab = function SearchNavTab(props) {
10
+ var className = props.className,
11
+ item = props.item,
12
+ labelProps = props.labelProps,
13
+ selectedKey = props.selectedKey,
14
+ setSelectedKey = props.setSelectedKey,
15
+ tabProps = props.tabProps;
16
+ var key = item.key,
17
+ text = item.text;
18
+ var isSelected = selectedKey === key;
19
+ var tabRef = useRef(null);
20
+ var _useFocusRing = useFocusRing(),
21
+ isFocusVisible = _useFocusRing.isFocusVisible,
22
+ focusProps = _useFocusRing.focusProps;
23
+ var _useHover = useHover({}),
24
+ hoverProps = _useHover.hoverProps,
25
+ isHovered = _useHover.isHovered;
26
+ var onPressCallback = function onPressCallback() {
27
+ setSelectedKey(key);
28
+ };
29
+ var _usePress = usePress({
30
+ ref: tabRef,
31
+ onPress: onPressCallback
32
+ }),
33
+ pressProps = _usePress.pressProps,
34
+ isPressed = _usePress.isPressed;
35
+ var _useStatusClasses = useStatusClasses(className, {
36
+ 'is-focused': isFocusVisible,
37
+ isHovered: isHovered,
38
+ isPressed: isPressed,
39
+ isSelected: isSelected
40
+ }),
41
+ classNames = _useStatusClasses.classNames;
42
+ return ___EmotionJSX(Box, _extends({
43
+ ref: tabRef,
44
+ variant: "searchNav.tab",
45
+ role: "listitem",
46
+ tabIndex: 0
47
+ }, mergeProps(tabProps, hoverProps, focusProps, pressProps), {
48
+ className: classNames
49
+ }), ___EmotionJSX(Text, _extends({
50
+ className: classNames,
51
+ role: "link",
52
+ variant: "searchNavTabLabel"
53
+ }, labelProps), text));
54
+ };
55
+ export default SearchNavTab;
@@ -0,0 +1 @@
1
+ export { default } from './SearchNav';