@pingux/astro 2.121.1-alpha.2 → 2.122.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.
- package/lib/cjs/components/CodeEditor/CodeEditor.d.ts +4 -0
- package/lib/cjs/components/CodeEditor/CodeEditor.js +55 -0
- package/lib/cjs/components/CodeEditor/CodeEditor.mdx +35 -0
- package/lib/cjs/components/CodeEditor/CodeEditor.stories.d.ts +27 -0
- package/lib/cjs/components/CodeEditor/CodeEditor.stories.js +66 -0
- package/lib/cjs/components/CodeEditor/CodeEditor.styles.d.ts +10 -0
- package/lib/cjs/components/CodeEditor/CodeEditor.styles.js +30 -0
- package/lib/cjs/components/CodeEditor/CodeEditor.test.d.ts +1 -0
- package/lib/cjs/components/CodeEditor/CodeEditor.test.js +82 -0
- package/lib/cjs/components/CodeEditor/index.d.ts +1 -0
- package/lib/cjs/components/CodeEditor/index.js +14 -0
- package/lib/cjs/components/CodeView/CodeView.mdx +4 -1
- package/lib/cjs/components/MultivaluesField/CondensedMultivaluesField.js +9 -1
- package/lib/cjs/components/MultivaluesField/MultivaluesField.stories.js +147 -59
- package/lib/cjs/components/MultivaluesField/MultivaluesField.test.js +23 -4
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +8 -0
- package/lib/cjs/styles/variants/variants.js +2 -0
- package/lib/cjs/types/codeEditor.d.ts +15 -0
- package/lib/cjs/types/codeEditor.js +6 -0
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +60 -49
- package/lib/components/CodeEditor/CodeEditor.js +41 -0
- package/lib/components/CodeEditor/CodeEditor.mdx +35 -0
- package/lib/components/CodeEditor/CodeEditor.stories.js +54 -0
- package/lib/components/CodeEditor/CodeEditor.styles.js +22 -0
- package/lib/components/CodeEditor/CodeEditor.test.js +79 -0
- package/lib/components/CodeEditor/index.js +1 -0
- package/lib/components/CodeView/CodeView.mdx +4 -1
- package/lib/components/MultivaluesField/CondensedMultivaluesField.js +9 -1
- package/lib/components/MultivaluesField/MultivaluesField.stories.js +145 -58
- package/lib/components/MultivaluesField/MultivaluesField.test.js +23 -4
- package/lib/index.js +1 -0
- package/lib/styles/variants/variants.js +2 -0
- package/lib/types/codeEditor.js +1 -0
- package/lib/types/index.js +1 -0
- package/package.json +3 -1
@@ -0,0 +1,79 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
3
|
+
import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
|
4
|
+
import React from 'react';
|
5
|
+
import { CodeEditor } from '../../index';
|
6
|
+
import { act, fireEvent, render, screen } from '../../utils/testUtils/testWrapper';
|
7
|
+
import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
|
8
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
9
|
+
var testId = 'test-code-sample';
|
10
|
+
var defaultProps = {
|
11
|
+
'data-testid': testId
|
12
|
+
};
|
13
|
+
var jsCode = "\n function helloWorld() {\n console.log(\"Hello, World!\");\n }\n";
|
14
|
+
|
15
|
+
// Needs to be added to each components test file
|
16
|
+
universalComponentTests({
|
17
|
+
rules: {
|
18
|
+
'color-contrast': {
|
19
|
+
enabled: false
|
20
|
+
}
|
21
|
+
},
|
22
|
+
renderComponent: function renderComponent(props) {
|
23
|
+
return ___EmotionJSX(CodeEditor, _extends({}, defaultProps, props, {
|
24
|
+
value: jsCode,
|
25
|
+
language: "javascript"
|
26
|
+
}));
|
27
|
+
}
|
28
|
+
});
|
29
|
+
jest.mock('@monaco-editor/react', function () {
|
30
|
+
return {
|
31
|
+
__esModule: true,
|
32
|
+
"default": function _default(_ref) {
|
33
|
+
var _context;
|
34
|
+
var language = _ref.language,
|
35
|
+
value = _ref.value,
|
36
|
+
_onChange = _ref.onChange;
|
37
|
+
return ___EmotionJSX("textarea", {
|
38
|
+
"data-testid": "mock-monaco-editor",
|
39
|
+
onChange: function onChange(e) {
|
40
|
+
return _onChange(e.target.value);
|
41
|
+
},
|
42
|
+
value: _concatInstanceProperty(_context = "Editor Language: ".concat(language, ", Code:")).call(_context, value),
|
43
|
+
"aria-label": "Code editor"
|
44
|
+
});
|
45
|
+
}
|
46
|
+
};
|
47
|
+
});
|
48
|
+
describe('CodeEditor', function () {
|
49
|
+
it('renders with initial value', function () {
|
50
|
+
var value = 'console.log("Hello, World!");';
|
51
|
+
render(___EmotionJSX(CodeEditor, {
|
52
|
+
language: "javascript",
|
53
|
+
value: value
|
54
|
+
}));
|
55
|
+
expect(screen.getByTestId('mock-monaco-editor')).toBeInTheDocument();
|
56
|
+
expect(screen.getByText('Editor Language: javascript, Code:console.log("Hello, World!");')).toBeInTheDocument();
|
57
|
+
});
|
58
|
+
it('calls onChange when code changes', function () {
|
59
|
+
var value = 'console.log("Hello, World!");';
|
60
|
+
var mockOnChange = jest.fn();
|
61
|
+
render(___EmotionJSX(CodeEditor, {
|
62
|
+
language: "javascript",
|
63
|
+
value: value,
|
64
|
+
onChange: mockOnChange
|
65
|
+
}));
|
66
|
+
var editor = screen.getByTestId('mock-monaco-editor');
|
67
|
+
var newValue = _JSON$stringify([{
|
68
|
+
key: false
|
69
|
+
}]);
|
70
|
+
act(function () {
|
71
|
+
fireEvent.change(editor, {
|
72
|
+
target: {
|
73
|
+
value: newValue
|
74
|
+
}
|
75
|
+
});
|
76
|
+
});
|
77
|
+
expect(mockOnChange).toHaveBeenCalled();
|
78
|
+
});
|
79
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './CodeEditor';
|
@@ -5,7 +5,10 @@ import { Meta } from '@storybook/addon-docs';
|
|
5
5
|
# CodeView
|
6
6
|
|
7
7
|
This component is used for code syntax highlighting and is built on [prism-react-renderer](https://github.com/FormidableLabs/prism-react-renderer).
|
8
|
-
It should contain the language title and be formatted with indentations, line breaks, and comments, and should not contain complex code snippets.
|
8
|
+
It should contain the language title and be formatted with indentations, line breaks, and comments, and should not contain complex code snippets.
|
9
|
+
|
10
|
+
The CodeView component should be used for code snippets that need to be presented in a read-only format.
|
11
|
+
For more complex use cases that require an interactive environment, support for various programming languages, functionalities like linting, keyboard interactions, and real-time updates, use [CodeEditor](./?path=/docs/experimental-codeeditor--docs).
|
9
12
|
|
10
13
|
### Required Components
|
11
14
|
|
@@ -9,7 +9,7 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
9
9
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
10
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
11
11
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
12
|
-
var _excluded = ["defaultSelectedKeys", "direction", "disabledKeys", "containerProps", "hasAutoFocus", "hasNoSelectAll", "hasNoStatusIndicator", "helperText", "inputProps", "isDisabled", "isNotFlippable", "isReadOnly", "isRequired", "items", "label", "mode", "onBlur", "onFocus", "onInputChange", "onKeyDown", "onKeyUp", "onOpenChange", "onSelectionChange", "placeholder", "selectedKeys", "selectedOptionText", "scrollBoxProps", "status"];
|
12
|
+
var _excluded = ["defaultSelectedKeys", "direction", "disabledKeys", "containerProps", "hasAutoFocus", "hasNoSelectAll", "hasNoStatusIndicator", "helperText", "inputProps", "isDisabled", "isNotFlippable", "isReadOnly", "isRequired", "items", "label", "loadingState", "mode", "onBlur", "onFocus", "onInputChange", "onKeyDown", "onKeyUp", "onLoadMore", "onLoadPrev", "onOpenChange", "onSelectionChange", "placeholder", "selectedKeys", "selectedOptionText", "scrollBoxProps", "status"];
|
13
13
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
14
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
15
15
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
@@ -30,6 +30,7 @@ import PropTypes from 'prop-types';
|
|
30
30
|
import { Box, Button, Icon, PopoverContainer, ScrollBox, Text, TextField } from '../..';
|
31
31
|
import { MultivaluesContext } from '../../context/MultivaluesContext';
|
32
32
|
import { usePropWarning } from '../../hooks';
|
33
|
+
import loadingStates from '../../utils/devUtils/constants/loadingStates';
|
33
34
|
import { getPendoID } from '../../utils/devUtils/constants/pendoID';
|
34
35
|
import { isIterableProp } from '../../utils/devUtils/props/isIterable';
|
35
36
|
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
@@ -55,12 +56,15 @@ var CondensedMultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
55
56
|
isRequired = props.isRequired,
|
56
57
|
items = props.items,
|
57
58
|
label = props.label,
|
59
|
+
loadingState = props.loadingState,
|
58
60
|
mode = props.mode,
|
59
61
|
_onBlur = props.onBlur,
|
60
62
|
_onFocus = props.onFocus,
|
61
63
|
onInputChange = props.onInputChange,
|
62
64
|
onKeyDown = props.onKeyDown,
|
63
65
|
_onKeyUp = props.onKeyUp,
|
66
|
+
onLoadMore = props.onLoadMore,
|
67
|
+
onLoadPrev = props.onLoadPrev,
|
64
68
|
onOpenChange = props.onOpenChange,
|
65
69
|
onSelectionChange = props.onSelectionChange,
|
66
70
|
placeholder = props.placeholder,
|
@@ -280,6 +284,10 @@ var CondensedMultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
280
284
|
hasAutoFocus: hasAutoFocus,
|
281
285
|
hasNoEmptySelection: true,
|
282
286
|
state: state,
|
287
|
+
onLoadMore: onLoadMore,
|
288
|
+
onLoadPrev: onLoadPrev,
|
289
|
+
loadingState: loadingState,
|
290
|
+
isLoading: loadingState === loadingStates.LOADING_MORE,
|
283
291
|
"aria-label": "List of options",
|
284
292
|
isCondensed: mode === 'condensed'
|
285
293
|
}, overlayProps))), ___EmotionJSX(DismissButton, {
|
@@ -17,14 +17,14 @@ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerat
|
|
17
17
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
18
18
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
19
19
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
20
|
-
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 _context13; _forEachInstanceProperty(_context13 = ["next", "throw", "return"]).call(_context13, 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 _context14; 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(_context14 = this.tryEntries).call(_context14, 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; }
|
20
|
+
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 _context19; _forEachInstanceProperty(_context19 = ["next", "throw", "return"]).call(_context19, 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 _context20; 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(_context20 = this.tryEntries).call(_context20, 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; }
|
21
21
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
22
22
|
import _fillInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/fill";
|
23
23
|
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
24
24
|
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
25
25
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
26
26
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
27
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
27
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context17, _context18; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context17 = ownKeys(Object(source), !0)).call(_context17, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context18 = ownKeys(Object(source))).call(_context18, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
28
28
|
import React, { useState } from 'react';
|
29
29
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
30
30
|
import { Box, Icon, Item, MultivaluesField, OverlayProvider, Section } from '../../index';
|
@@ -650,11 +650,98 @@ export var Condensed = function Condensed(args) {
|
|
650
650
|
}, item.name);
|
651
651
|
}));
|
652
652
|
};
|
653
|
-
export var
|
654
|
-
var
|
653
|
+
export var CondensedAsyncLoading = function CondensedAsyncLoading(args) {
|
654
|
+
var _context, _context2;
|
655
|
+
var direction = args.direction;
|
656
|
+
var initialItems = _mapInstanceProperty(_context = _fillInstanceProperty(_context2 = new Array(10)).call(_context2, {
|
657
|
+
key: 'string',
|
658
|
+
name: 'string'
|
659
|
+
})).call(_context, function (_, index) {
|
660
|
+
return {
|
661
|
+
name: "name: ".concat(index),
|
662
|
+
key: "name: ".concat(index),
|
663
|
+
id: index
|
664
|
+
};
|
665
|
+
});
|
666
|
+
var _useState25 = useState(10),
|
655
667
|
_useState26 = _slicedToArray(_useState25, 2),
|
656
|
-
|
657
|
-
|
668
|
+
maxNum = _useState26[0],
|
669
|
+
setMaxNum = _useState26[1];
|
670
|
+
var _useState27 = useState(initialItems),
|
671
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
672
|
+
listItems = _useState28[0],
|
673
|
+
setListItems = _useState28[1];
|
674
|
+
var _useState29 = useState(false),
|
675
|
+
_useState30 = _slicedToArray(_useState29, 2),
|
676
|
+
isOpen = _useState30[0],
|
677
|
+
setIsOpen = _useState30[1];
|
678
|
+
var _useState31 = useState(loadingStates.IDLE),
|
679
|
+
_useState32 = _slicedToArray(_useState31, 2),
|
680
|
+
loadingState = _useState32[0],
|
681
|
+
setLoadingState = _useState32[1];
|
682
|
+
var onOpenChange = function onOpenChange() {
|
683
|
+
setIsOpen(true);
|
684
|
+
};
|
685
|
+
var onLoadMore = /*#__PURE__*/function () {
|
686
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
687
|
+
var _context3, _context4, _context5;
|
688
|
+
var newItems;
|
689
|
+
return _regeneratorRuntime().wrap(function _callee$(_context6) {
|
690
|
+
while (1) switch (_context6.prev = _context6.next) {
|
691
|
+
case 0:
|
692
|
+
setLoadingState(loadingStates.LOADING_MORE);
|
693
|
+
_context6.next = 3;
|
694
|
+
return new _Promise(function (resolve) {
|
695
|
+
return _setTimeout(resolve, 3000);
|
696
|
+
});
|
697
|
+
case 3:
|
698
|
+
newItems = _mapInstanceProperty(_context3 = _fillInstanceProperty(_context4 = new Array(10)).call(_context4, {
|
699
|
+
key: 'string',
|
700
|
+
name: 'string'
|
701
|
+
})).call(_context3, function (_, index) {
|
702
|
+
return {
|
703
|
+
name: "name: ".concat(maxNum + index),
|
704
|
+
key: "name: ".concat(maxNum + index),
|
705
|
+
id: maxNum + index
|
706
|
+
};
|
707
|
+
});
|
708
|
+
setMaxNum(maxNum + 10);
|
709
|
+
setListItems(_concatInstanceProperty(_context5 = []).call(_context5, listItems, newItems));
|
710
|
+
setLoadingState(loadingStates.IDLE);
|
711
|
+
case 7:
|
712
|
+
case "end":
|
713
|
+
return _context6.stop();
|
714
|
+
}
|
715
|
+
}, _callee);
|
716
|
+
}));
|
717
|
+
return function onLoadMore() {
|
718
|
+
return _ref.apply(this, arguments);
|
719
|
+
};
|
720
|
+
}();
|
721
|
+
return ___EmotionJSX(OverlayProvider
|
722
|
+
// note: spacing for demo purpose only so that the select list renders in the right place
|
723
|
+
, {
|
724
|
+
style: setOverlayStyle(direction, isOpen, '25%', '25%', '75%')
|
725
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
726
|
+
items: listItems
|
727
|
+
}, args, {
|
728
|
+
mode: "condensed",
|
729
|
+
onOpenChange: onOpenChange,
|
730
|
+
loadingState: loadingState,
|
731
|
+
onLoadMore: onLoadMore
|
732
|
+
}), function (item) {
|
733
|
+
return ___EmotionJSX(Item, {
|
734
|
+
key: item.key,
|
735
|
+
"data-id": item.name,
|
736
|
+
"aria-label": item.name
|
737
|
+
}, item.name);
|
738
|
+
}));
|
739
|
+
};
|
740
|
+
export var CondensedWithSection = function CondensedWithSection(args) {
|
741
|
+
var _useState33 = useState(false),
|
742
|
+
_useState34 = _slicedToArray(_useState33, 2),
|
743
|
+
isOpen = _useState34[0],
|
744
|
+
setIsOpen = _useState34[1];
|
658
745
|
var direction = args.direction;
|
659
746
|
var onOpenChange = function onOpenChange() {
|
660
747
|
setIsOpen(true);
|
@@ -681,14 +768,14 @@ export var CondensedWithSection = function CondensedWithSection(args) {
|
|
681
768
|
}));
|
682
769
|
};
|
683
770
|
export var CondensedWithCustomText = function CondensedWithCustomText(args) {
|
684
|
-
var
|
685
|
-
|
686
|
-
isOpen =
|
687
|
-
setIsOpen =
|
688
|
-
var
|
689
|
-
|
690
|
-
selectedKeys =
|
691
|
-
setSelectedKeys =
|
771
|
+
var _useState35 = useState(false),
|
772
|
+
_useState36 = _slicedToArray(_useState35, 2),
|
773
|
+
isOpen = _useState36[0],
|
774
|
+
setIsOpen = _useState36[1];
|
775
|
+
var _useState37 = useState([]),
|
776
|
+
_useState38 = _slicedToArray(_useState37, 2),
|
777
|
+
selectedKeys = _useState38[0],
|
778
|
+
setSelectedKeys = _useState38[1];
|
692
779
|
var direction = args.direction;
|
693
780
|
var onOpenChange = function onOpenChange() {
|
694
781
|
setIsOpen(true);
|
@@ -719,57 +806,57 @@ export var CondensedWithCustomText = function CondensedWithCustomText(args) {
|
|
719
806
|
}));
|
720
807
|
};
|
721
808
|
export var OnLoadPrev = function OnLoadPrev() {
|
722
|
-
var
|
723
|
-
var initialItems = _mapInstanceProperty(
|
809
|
+
var _context7, _context8;
|
810
|
+
var initialItems = _mapInstanceProperty(_context7 = _fillInstanceProperty(_context8 = new Array(10)).call(_context8, {
|
724
811
|
key: 'string',
|
725
812
|
name: 'string'
|
726
|
-
})).call(
|
813
|
+
})).call(_context7, function (_, index) {
|
727
814
|
return {
|
728
815
|
name: "name: ".concat(index),
|
729
816
|
key: "name: ".concat(index),
|
730
817
|
id: index
|
731
818
|
};
|
732
819
|
});
|
733
|
-
var
|
734
|
-
_useState32 = _slicedToArray(_useState31, 2),
|
735
|
-
minNum = _useState32[0],
|
736
|
-
setMinNum = _useState32[1];
|
737
|
-
var _useState33 = useState(10),
|
738
|
-
_useState34 = _slicedToArray(_useState33, 2),
|
739
|
-
maxNum = _useState34[0],
|
740
|
-
setMaxNum = _useState34[1];
|
741
|
-
var _useState35 = useState(initialItems),
|
742
|
-
_useState36 = _slicedToArray(_useState35, 2),
|
743
|
-
listItems = _useState36[0],
|
744
|
-
setListItems = _useState36[1];
|
745
|
-
var _useState37 = useState(false),
|
746
|
-
_useState38 = _slicedToArray(_useState37, 2),
|
747
|
-
isOpen = _useState38[0],
|
748
|
-
setIsOpen = _useState38[1];
|
749
|
-
var _useState39 = useState(loadingStates.IDLE),
|
820
|
+
var _useState39 = useState(0),
|
750
821
|
_useState40 = _slicedToArray(_useState39, 2),
|
751
|
-
|
752
|
-
|
822
|
+
minNum = _useState40[0],
|
823
|
+
setMinNum = _useState40[1];
|
824
|
+
var _useState41 = useState(10),
|
825
|
+
_useState42 = _slicedToArray(_useState41, 2),
|
826
|
+
maxNum = _useState42[0],
|
827
|
+
setMaxNum = _useState42[1];
|
828
|
+
var _useState43 = useState(initialItems),
|
829
|
+
_useState44 = _slicedToArray(_useState43, 2),
|
830
|
+
listItems = _useState44[0],
|
831
|
+
setListItems = _useState44[1];
|
832
|
+
var _useState45 = useState(false),
|
833
|
+
_useState46 = _slicedToArray(_useState45, 2),
|
834
|
+
isOpen = _useState46[0],
|
835
|
+
setIsOpen = _useState46[1];
|
836
|
+
var _useState47 = useState(loadingStates.IDLE),
|
837
|
+
_useState48 = _slicedToArray(_useState47, 2),
|
838
|
+
loadingState = _useState48[0],
|
839
|
+
setLoadingState = _useState48[1];
|
753
840
|
var onOpenChange = function onOpenChange() {
|
754
841
|
setIsOpen(true);
|
755
842
|
};
|
756
843
|
var onLoadMore = /*#__PURE__*/function () {
|
757
|
-
var
|
758
|
-
var
|
844
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
845
|
+
var _context9, _context10, _context11;
|
759
846
|
var newItems;
|
760
|
-
return _regeneratorRuntime().wrap(function
|
761
|
-
while (1) switch (
|
847
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context12) {
|
848
|
+
while (1) switch (_context12.prev = _context12.next) {
|
762
849
|
case 0:
|
763
850
|
setLoadingState(loadingStates.LOADING_MORE);
|
764
|
-
|
851
|
+
_context12.next = 3;
|
765
852
|
return new _Promise(function (resolve) {
|
766
853
|
return _setTimeout(resolve, 3000);
|
767
854
|
});
|
768
855
|
case 3:
|
769
|
-
newItems = _mapInstanceProperty(
|
856
|
+
newItems = _mapInstanceProperty(_context9 = _fillInstanceProperty(_context10 = new Array(10)).call(_context10, {
|
770
857
|
key: 'string',
|
771
858
|
name: 'string'
|
772
|
-
})).call(
|
859
|
+
})).call(_context9, function (_, index) {
|
773
860
|
return {
|
774
861
|
name: "name: ".concat(maxNum + index),
|
775
862
|
key: "name: ".concat(maxNum + index),
|
@@ -777,35 +864,35 @@ export var OnLoadPrev = function OnLoadPrev() {
|
|
777
864
|
};
|
778
865
|
});
|
779
866
|
setMaxNum(maxNum + 10);
|
780
|
-
setListItems(_concatInstanceProperty(
|
867
|
+
setListItems(_concatInstanceProperty(_context11 = []).call(_context11, listItems, newItems));
|
781
868
|
setLoadingState(loadingStates.IDLE);
|
782
869
|
case 7:
|
783
870
|
case "end":
|
784
|
-
return
|
871
|
+
return _context12.stop();
|
785
872
|
}
|
786
|
-
},
|
873
|
+
}, _callee2);
|
787
874
|
}));
|
788
875
|
return function onLoadMore() {
|
789
|
-
return
|
876
|
+
return _ref2.apply(this, arguments);
|
790
877
|
};
|
791
878
|
}();
|
792
879
|
var onLoadPrev = /*#__PURE__*/function () {
|
793
|
-
var
|
794
|
-
var
|
880
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
881
|
+
var _context13, _context14, _context15;
|
795
882
|
var newItems;
|
796
|
-
return _regeneratorRuntime().wrap(function
|
797
|
-
while (1) switch (
|
883
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context16) {
|
884
|
+
while (1) switch (_context16.prev = _context16.next) {
|
798
885
|
case 0:
|
799
886
|
setLoadingState(loadingStates.LOADING_MORE_PREPEND);
|
800
|
-
|
887
|
+
_context16.next = 3;
|
801
888
|
return new _Promise(function (resolve) {
|
802
889
|
return _setTimeout(resolve, 3000);
|
803
890
|
});
|
804
891
|
case 3:
|
805
|
-
newItems = _mapInstanceProperty(
|
892
|
+
newItems = _mapInstanceProperty(_context13 = _fillInstanceProperty(_context14 = new Array(10)).call(_context14, {
|
806
893
|
key: 'string',
|
807
894
|
name: 'string'
|
808
|
-
})).call(
|
895
|
+
})).call(_context13, function (_, index) {
|
809
896
|
return {
|
810
897
|
name: "name: ".concat(minNum - (index + 1)),
|
811
898
|
key: "name: ".concat(minNum - (index + 1)),
|
@@ -813,16 +900,16 @@ export var OnLoadPrev = function OnLoadPrev() {
|
|
813
900
|
};
|
814
901
|
});
|
815
902
|
setMinNum(minNum - 10);
|
816
|
-
setListItems(_concatInstanceProperty(
|
903
|
+
setListItems(_concatInstanceProperty(_context15 = []).call(_context15, newItems, listItems));
|
817
904
|
setLoadingState(loadingStates.IDLE);
|
818
905
|
case 7:
|
819
906
|
case "end":
|
820
|
-
return
|
907
|
+
return _context16.stop();
|
821
908
|
}
|
822
|
-
},
|
909
|
+
}, _callee3);
|
823
910
|
}));
|
824
911
|
return function onLoadPrev() {
|
825
|
-
return
|
912
|
+
return _ref3.apply(this, arguments);
|
826
913
|
};
|
827
914
|
}();
|
828
915
|
return ___EmotionJSX(OverlayProvider
|
@@ -129,7 +129,7 @@ var getSectionsComponent = function getSectionsComponent() {
|
|
129
129
|
});
|
130
130
|
})));
|
131
131
|
};
|
132
|
-
var ComponentOnPrevLoad = function ComponentOnPrevLoad() {
|
132
|
+
var ComponentOnPrevLoad = function ComponentOnPrevLoad(props) {
|
133
133
|
var _context, _context2;
|
134
134
|
var initialItems = _mapInstanceProperty(_context = _fillInstanceProperty(_context2 = new Array(10)).call(_context2, {
|
135
135
|
key: 'string',
|
@@ -178,12 +178,12 @@ var ComponentOnPrevLoad = function ComponentOnPrevLoad() {
|
|
178
178
|
return _ref5.apply(this, arguments);
|
179
179
|
};
|
180
180
|
}();
|
181
|
-
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(MultivaluesField, {
|
181
|
+
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(MultivaluesField, _extends({
|
182
182
|
items: listItems,
|
183
183
|
label: "Field Label",
|
184
184
|
onLoadMore: onLoadMore,
|
185
185
|
onLoadPrev: onLoadPrev
|
186
|
-
}, function (item) {
|
186
|
+
}, props), function (item) {
|
187
187
|
return ___EmotionJSX(Item, {
|
188
188
|
key: item.key,
|
189
189
|
"data-id": item.name,
|
@@ -922,6 +922,25 @@ test('in non-restrictive mode the partial string values should be accepted', fun
|
|
922
922
|
expect(input).not.toHaveValue('');
|
923
923
|
expect(input).toHaveValue(value);
|
924
924
|
});
|
925
|
+
test('in condensed mode, onLoadMore and onLoadPrev callbacks are called', function () {
|
926
|
+
render(___EmotionJSX(ComponentOnPrevLoad, {
|
927
|
+
mode: "condensed"
|
928
|
+
}));
|
929
|
+
userEvent.tab();
|
930
|
+
var listBox = screen.getAllByRole('listbox');
|
931
|
+
fireEvent.scroll(listBox[0], {
|
932
|
+
target: {
|
933
|
+
scrollY: 450
|
934
|
+
}
|
935
|
+
});
|
936
|
+
expect(onLoadMoreFunc).toHaveBeenCalled();
|
937
|
+
fireEvent.scroll(listBox[0], {
|
938
|
+
target: {
|
939
|
+
scrollY: 0
|
940
|
+
}
|
941
|
+
});
|
942
|
+
expect(onLoadPrevFunc).toHaveBeenCalled();
|
943
|
+
});
|
925
944
|
test('in condensed mode, hasNoSelectAll hides the select all button', function () {
|
926
945
|
getComponent({
|
927
946
|
mode: 'condensed',
|
@@ -1208,7 +1227,7 @@ test('renders with error without key on item groups ', function () {
|
|
1208
1227
|
}
|
1209
1228
|
expect(errorMessage).toMatch(/No key found for item/);
|
1210
1229
|
});
|
1211
|
-
test('
|
1230
|
+
test('onLoadMore and onLoadPrev callbacks are called', function () {
|
1212
1231
|
render(___EmotionJSX(ComponentOnPrevLoad, null));
|
1213
1232
|
userEvent.tab();
|
1214
1233
|
var listBox = screen.getAllByRole('listbox');
|
package/lib/index.js
CHANGED
@@ -63,6 +63,7 @@ export { default as Checkbox } from './components/Checkbox';
|
|
63
63
|
export * from './components/Checkbox';
|
64
64
|
export { default as CheckboxField } from './components/CheckboxField';
|
65
65
|
export * from './components/CheckboxField';
|
66
|
+
export { default as CodeEditor } from './components/CodeEditor';
|
66
67
|
export { default as CodeView } from './components/CodeView';
|
67
68
|
export { default as CollapsiblePanel } from './components/CollapsiblePanel';
|
68
69
|
export * from './components/CollapsiblePanel';
|
@@ -17,6 +17,7 @@ import breadcrumb from '../../components/Breadcrumbs/Breadcrumb.styles';
|
|
17
17
|
import buttonBar from '../../components/ButtonBar/ButtonBar.styles';
|
18
18
|
import calendar from '../../components/Calendar/Calendar.styles';
|
19
19
|
import callout from '../../components/Callout/Callout.styles';
|
20
|
+
import codeEditor from '../../components/CodeEditor/CodeEditor.styles';
|
20
21
|
import codeView from '../../components/CodeView/CodeView.styles';
|
21
22
|
import collapsiblePanel from '../../components/CollapsiblePanel/CollapsiblePanel.styles';
|
22
23
|
import copyText from '../../components/CopyText/CopyText.styles';
|
@@ -66,6 +67,7 @@ export default _objectSpread({
|
|
66
67
|
calendar: calendar,
|
67
68
|
rangeCalendar: rangeCalendar,
|
68
69
|
callout: callout,
|
70
|
+
codeEditor: codeEditor,
|
69
71
|
codeView: codeView,
|
70
72
|
collapsiblePanel: collapsiblePanel,
|
71
73
|
copyText: copyText,
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
package/lib/types/index.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pingux/astro",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.122.0-alpha.0",
|
4
4
|
"description": "React component library for Ping Identity's design system",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -49,6 +49,7 @@
|
|
49
49
|
"@internationalized/date": "^3.5.3",
|
50
50
|
"@internationalized/number": "^3.6.0",
|
51
51
|
"@mdx-js/react": "^1.6.22",
|
52
|
+
"@monaco-editor/react": "4.4.0",
|
52
53
|
"@pingux/mdi-react": "^1.2.0",
|
53
54
|
"@react-aria/accordion": "~3.0.0-alpha.11",
|
54
55
|
"@react-aria/breadcrumbs": "^3.1.4",
|
@@ -116,6 +117,7 @@
|
|
116
117
|
"lodash": "^4.17.21",
|
117
118
|
"markdown-to-jsx": "^7.7.4",
|
118
119
|
"moment": "^2.29.4",
|
120
|
+
"monaco-editor": "0.34.1",
|
119
121
|
"pluralize": "^8.0.0",
|
120
122
|
"prism-react-renderer": "1.2.1",
|
121
123
|
"prismjs": "^1.27.0",
|