@pingux/astro 2.117.0 → 2.118.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.
- package/lib/cjs/components/ComboBoxField/ComboBoxField.js +0 -1
- package/lib/cjs/components/ComboBoxField/ComboBoxField.stories.js +24 -16
- package/lib/cjs/components/ComboBoxField/ComboBoxField.test.js +74 -32
- package/lib/cjs/components/SliderField/Slider.styles.d.ts +138 -0
- package/lib/cjs/components/SliderField/Slider.styles.js +163 -0
- package/lib/cjs/components/SliderField/SliderActiveTrack.d.ts +4 -0
- package/lib/cjs/components/SliderField/SliderActiveTrack.js +49 -0
- package/lib/cjs/components/SliderField/SliderField.d.ts +4 -0
- package/lib/cjs/components/SliderField/SliderField.js +58 -0
- package/lib/cjs/components/SliderField/SliderField.mdx +127 -0
- package/lib/cjs/components/SliderField/SliderField.stories.d.ts +11 -0
- package/lib/cjs/components/SliderField/SliderField.stories.js +151 -0
- package/lib/cjs/components/SliderField/SliderField.test.d.ts +1 -0
- package/lib/cjs/components/SliderField/SliderField.test.js +357 -0
- package/lib/cjs/components/SliderField/SliderLabelContainer.d.ts +4 -0
- package/lib/cjs/components/SliderField/SliderLabelContainer.js +43 -0
- package/lib/cjs/components/SliderField/SliderThumb.d.ts +4 -0
- package/lib/cjs/components/SliderField/SliderThumb.js +82 -0
- package/lib/cjs/components/SliderField/index.d.ts +1 -0
- package/lib/cjs/components/SliderField/index.js +14 -0
- package/lib/cjs/hooks/index.d.ts +1 -0
- package/lib/cjs/hooks/index.js +7 -0
- package/lib/cjs/hooks/useSliderField/index.d.ts +1 -0
- package/lib/cjs/hooks/useSliderField/index.js +14 -0
- package/lib/cjs/hooks/useSliderField/useSliderField.d.ts +4290 -0
- package/lib/cjs/hooks/useSliderField/useSliderField.js +230 -0
- package/lib/cjs/hooks/useSliderField/useSliderField.test.d.ts +1 -0
- package/lib/cjs/hooks/useSliderField/useSliderField.test.js +109 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +8 -0
- package/lib/cjs/styles/colors.d.ts +6 -0
- package/lib/cjs/styles/colors.js +5 -1
- package/lib/cjs/styles/variants/variants.js +2 -0
- package/lib/cjs/types/sliderField.d.ts +79 -0
- package/lib/cjs/types/sliderField.js +6 -0
- package/lib/cjs/utils/testUtils/universalFormSubmitTest.js +17 -0
- package/lib/components/ComboBoxField/ComboBoxField.js +0 -1
- package/lib/components/ComboBoxField/ComboBoxField.stories.js +24 -16
- package/lib/components/ComboBoxField/ComboBoxField.test.js +74 -32
- package/lib/components/SliderField/Slider.styles.js +155 -0
- package/lib/components/SliderField/SliderActiveTrack.js +37 -0
- package/lib/components/SliderField/SliderField.js +46 -0
- package/lib/components/SliderField/SliderField.mdx +127 -0
- package/lib/components/SliderField/SliderField.stories.js +131 -0
- package/lib/components/SliderField/SliderField.test.js +354 -0
- package/lib/components/SliderField/SliderLabelContainer.js +29 -0
- package/lib/components/SliderField/SliderThumb.js +68 -0
- package/lib/components/SliderField/index.js +1 -0
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/useSliderField/index.js +1 -0
- package/lib/hooks/useSliderField/useSliderField.js +220 -0
- package/lib/hooks/useSliderField/useSliderField.test.js +102 -0
- package/lib/index.js +1 -0
- package/lib/styles/colors.js +5 -1
- package/lib/styles/variants/variants.js +2 -0
- package/lib/types/sliderField.js +1 -0
- package/lib/utils/testUtils/universalFormSubmitTest.js +17 -0
- package/package.json +3 -1
@@ -17,13 +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
|
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; }
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
21
|
-
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 _context6; _forEachInstanceProperty(_context6 = ["next", "throw", "return"]).call(_context6, 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 _context7; 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(_context7 = this.tryEntries).call(_context7, 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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context10, _context11; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context10 = ownKeys(Object(source), !0)).call(_context10, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context11 = ownKeys(Object(source))).call(_context11, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
21
|
+
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 _context8; _forEachInstanceProperty(_context8 = ["next", "throw", "return"]).call(_context8, 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 _context9; 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(_context9 = this.tryEntries).call(_context9, 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; }
|
22
22
|
import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
|
23
23
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
24
24
|
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
25
25
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
26
26
|
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
27
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
27
28
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
28
29
|
import React, { useState } from 'react';
|
29
30
|
import { useFilter } from '@react-aria/i18n';
|
@@ -325,6 +326,47 @@ test('should be able to open and navigate through the listbox by click', functio
|
|
325
326
|
userEvent.click(button);
|
326
327
|
expect(options[0]).toHaveClass('is-focused');
|
327
328
|
});
|
329
|
+
test('should be able to hover list item and filter on input box', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
330
|
+
var button, input, options;
|
331
|
+
return _regeneratorRuntime().wrap(function _callee$(_context3) {
|
332
|
+
while (1) switch (_context3.prev = _context3.next) {
|
333
|
+
case 0:
|
334
|
+
getComponentWithSections({
|
335
|
+
defaultFilter: function defaultFilter(option, inputValue) {
|
336
|
+
var _context2;
|
337
|
+
return _includesInstanceProperty(_context2 = option.name.toLowerCase()).call(_context2, inputValue.toLowerCase());
|
338
|
+
}
|
339
|
+
});
|
340
|
+
button = screen.queryByRole('button');
|
341
|
+
input = screen.queryByRole('combobox');
|
342
|
+
expect(screen.queryByRole('combobox')).toHaveValue('');
|
343
|
+
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
344
|
+
|
345
|
+
// Open the list by clicking on the button and ensure first option is not active
|
346
|
+
userEvent.click(button);
|
347
|
+
options = screen.queryAllByRole('option');
|
348
|
+
expect(screen.queryByRole('listbox')).toBeInTheDocument();
|
349
|
+
// Both dismiss buttons should be available, but the dropdown button should be inaccessible
|
350
|
+
expect(screen.queryAllByRole('button')).toHaveLength(2);
|
351
|
+
expect(options).toHaveLength(9);
|
352
|
+
expect(input).not.toHaveAttribute('aria-activedescendant', options[0].id);
|
353
|
+
_forEachInstanceProperty(options).call(options, function (opt) {
|
354
|
+
return expect(opt).not.toHaveClass('is-focused');
|
355
|
+
});
|
356
|
+
|
357
|
+
// Ensure active styles are applied
|
358
|
+
userEvent.hover(options[0]);
|
359
|
+
expect(input).toHaveAttribute('aria-activedescendant', options[0].id);
|
360
|
+
expect(options[0]).toHaveClass('is-focused');
|
361
|
+
userEvent.type(input, 'k');
|
362
|
+
expect(screen.queryByRole('listbox')).toBeInTheDocument();
|
363
|
+
expect(input).toHaveValue('k');
|
364
|
+
case 18:
|
365
|
+
case "end":
|
366
|
+
return _context3.stop();
|
367
|
+
}
|
368
|
+
}, _callee);
|
369
|
+
})));
|
328
370
|
test('should be able to open the listbox by keyboard', function () {
|
329
371
|
getComponent();
|
330
372
|
var input = screen.getByRole('combobox');
|
@@ -513,37 +555,37 @@ test('should use default contains filtering', function () {
|
|
513
555
|
userEvent.type(input, 'z');
|
514
556
|
expect(screen.queryByRole('option')).not.toBeInTheDocument();
|
515
557
|
});
|
516
|
-
test('should be able to use controlled filtering', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
558
|
+
test('should be able to use controlled filtering', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
517
559
|
var options, input;
|
518
|
-
return _regeneratorRuntime().wrap(function
|
519
|
-
while (1) switch (
|
560
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context4) {
|
561
|
+
while (1) switch (_context4.prev = _context4.next) {
|
520
562
|
case 0:
|
521
563
|
render(___EmotionJSX(ComboBoxWithCustomFilter, null));
|
522
564
|
input = screen.queryByRole('combobox'); // Should list all without filterable input
|
523
565
|
userEvent.type(input, '{arrowdown}');
|
524
|
-
|
566
|
+
_context4.next = 5;
|
525
567
|
return screen.findAllByRole('option');
|
526
568
|
case 5:
|
527
|
-
options =
|
569
|
+
options = _context4.sent;
|
528
570
|
expect(options).toHaveLength(items.length);
|
529
571
|
|
530
572
|
// Should only list the second option
|
531
573
|
userEvent.type(input, 'k');
|
532
|
-
|
574
|
+
_context4.next = 10;
|
533
575
|
return screen.findAllByRole('option');
|
534
576
|
case 10:
|
535
|
-
options =
|
577
|
+
options = _context4.sent;
|
536
578
|
expect(options[0]).toHaveTextContent(items[1].name);
|
537
579
|
case 12:
|
538
580
|
case "end":
|
539
|
-
return
|
581
|
+
return _context4.stop();
|
540
582
|
}
|
541
|
-
},
|
583
|
+
}, _callee2);
|
542
584
|
})));
|
543
|
-
test('should be able to use custom default filtering', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
585
|
+
test('should be able to use custom default filtering', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
544
586
|
var options, defaultFilter, input;
|
545
|
-
return _regeneratorRuntime().wrap(function
|
546
|
-
while (1) switch (
|
587
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context5) {
|
588
|
+
while (1) switch (_context5.prev = _context5.next) {
|
547
589
|
case 0:
|
548
590
|
defaultFilter = function defaultFilter(option, inputValue) {
|
549
591
|
return _startsWithInstanceProperty(option).call(option, inputValue);
|
@@ -553,29 +595,29 @@ test('should be able to use custom default filtering', /*#__PURE__*/_asyncToGene
|
|
553
595
|
});
|
554
596
|
input = screen.queryByRole('combobox'); // Should list all without filterable input
|
555
597
|
userEvent.type(input, '{arrowdown}');
|
556
|
-
|
598
|
+
_context5.next = 6;
|
557
599
|
return screen.findAllByRole('option');
|
558
600
|
case 6:
|
559
|
-
options =
|
601
|
+
options = _context5.sent;
|
560
602
|
expect(options).toHaveLength(items.length);
|
561
603
|
|
562
604
|
// Should only list the second option
|
563
605
|
userEvent.type(input, 'K');
|
564
|
-
|
606
|
+
_context5.next = 11;
|
565
607
|
return screen.findAllByRole('option');
|
566
608
|
case 11:
|
567
|
-
options =
|
609
|
+
options = _context5.sent;
|
568
610
|
expect(options[0]).toHaveTextContent(items[1].name);
|
569
611
|
case 13:
|
570
612
|
case "end":
|
571
|
-
return
|
613
|
+
return _context5.stop();
|
572
614
|
}
|
573
|
-
},
|
615
|
+
}, _callee3);
|
574
616
|
})));
|
575
|
-
test('should show in input "textValue" if provided', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
617
|
+
test('should show in input "textValue" if provided', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
576
618
|
var newItems, input, options;
|
577
|
-
return _regeneratorRuntime().wrap(function
|
578
|
-
while (1) switch (
|
619
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context6) {
|
620
|
+
while (1) switch (_context6.prev = _context6.next) {
|
579
621
|
case 0:
|
580
622
|
newItems = _mapInstanceProperty(items).call(items, function (item) {
|
581
623
|
return _objectSpread(_objectSpread({}, item), {}, {
|
@@ -587,10 +629,10 @@ test('should show in input "textValue" if provided', /*#__PURE__*/_asyncToGenera
|
|
587
629
|
});
|
588
630
|
input = screen.queryByRole('combobox');
|
589
631
|
userEvent.click(input);
|
590
|
-
|
632
|
+
_context6.next = 6;
|
591
633
|
return screen.findAllByRole('option');
|
592
634
|
case 6:
|
593
|
-
options =
|
635
|
+
options = _context6.sent;
|
594
636
|
userEvent.click(options[0]);
|
595
637
|
expect(input).toHaveValue(newItems[0].textValue);
|
596
638
|
|
@@ -599,14 +641,14 @@ test('should show in input "textValue" if provided', /*#__PURE__*/_asyncToGenera
|
|
599
641
|
expect(input).toHaveValue(newItems[0].textValue);
|
600
642
|
case 11:
|
601
643
|
case "end":
|
602
|
-
return
|
644
|
+
return _context6.stop();
|
603
645
|
}
|
604
|
-
},
|
646
|
+
}, _callee4);
|
605
647
|
})));
|
606
|
-
test('option list should be opened on scroll input value', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
648
|
+
test('option list should be opened on scroll input value', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
607
649
|
var options, otherItems, input;
|
608
|
-
return _regeneratorRuntime().wrap(function
|
609
|
-
while (1) switch (
|
650
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context7) {
|
651
|
+
while (1) switch (_context7.prev = _context7.next) {
|
610
652
|
case 0:
|
611
653
|
otherItems = [{
|
612
654
|
name: 'Short item name one',
|
@@ -646,9 +688,9 @@ test('option list should be opened on scroll input value', /*#__PURE__*/_asyncTo
|
|
646
688
|
expect(options.length).toBe(0);
|
647
689
|
case 14:
|
648
690
|
case "end":
|
649
|
-
return
|
691
|
+
return _context7.stop();
|
650
692
|
}
|
651
|
-
},
|
693
|
+
}, _callee5);
|
652
694
|
})));
|
653
695
|
describe('loadingState', function () {
|
654
696
|
it('combobox should not render a loader if menu is not open', function () {
|
@@ -0,0 +1,155 @@
|
|
1
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
4
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
5
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
6
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
|
+
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; }
|
11
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
12
|
+
import { defaultFocus } from '../Button/Buttons.styles';
|
13
|
+
var test = {
|
14
|
+
bg: 'active'
|
15
|
+
};
|
16
|
+
var slider = {
|
17
|
+
display: 'flex',
|
18
|
+
'&.is-horizontal': {
|
19
|
+
flexDirection: 'column'
|
20
|
+
}
|
21
|
+
};
|
22
|
+
var track = {
|
23
|
+
backgroundColor: 'slider.track',
|
24
|
+
cursor: 'pointer',
|
25
|
+
mb: 'sm',
|
26
|
+
position: 'relative',
|
27
|
+
'&.is-disabled': {
|
28
|
+
opacity: 0.4
|
29
|
+
},
|
30
|
+
'&.is-horizontal': {
|
31
|
+
height: '10px',
|
32
|
+
borderRadius: '11px',
|
33
|
+
width: '100%'
|
34
|
+
},
|
35
|
+
'&:before': {
|
36
|
+
content: 'attr(x)',
|
37
|
+
display: 'block',
|
38
|
+
position: 'absolute',
|
39
|
+
height: '3px',
|
40
|
+
width: '100%',
|
41
|
+
top: '50%',
|
42
|
+
transform: 'translateY(-50%)'
|
43
|
+
},
|
44
|
+
'&.is-vertical': {
|
45
|
+
width: '10px',
|
46
|
+
borderRadius: '11px',
|
47
|
+
height: '100%',
|
48
|
+
'&:before': {
|
49
|
+
content: 'attr(x)',
|
50
|
+
display: 'block',
|
51
|
+
position: 'absolute',
|
52
|
+
width: '3px',
|
53
|
+
height: '100%',
|
54
|
+
left: '50%',
|
55
|
+
transform: 'translateX(-50%)'
|
56
|
+
}
|
57
|
+
}
|
58
|
+
};
|
59
|
+
var hiddenTrack = {
|
60
|
+
cursor: 'pointer',
|
61
|
+
'&.is-horizontal': {
|
62
|
+
height: '10px',
|
63
|
+
borderRadius: '11px',
|
64
|
+
width: 'calc(100% - 9px)',
|
65
|
+
ml: '4.5px',
|
66
|
+
mr: '4.5px'
|
67
|
+
},
|
68
|
+
'&.is-vertical': {
|
69
|
+
width: '10px',
|
70
|
+
borderRadius: '11px',
|
71
|
+
height: 'calc(100% - 9px)',
|
72
|
+
mt: '4.5px',
|
73
|
+
mb: '4.5px'
|
74
|
+
}
|
75
|
+
};
|
76
|
+
var thumb = {
|
77
|
+
width: '21px',
|
78
|
+
height: '21px',
|
79
|
+
borderRadius: '50%',
|
80
|
+
bg: 'active',
|
81
|
+
cursor: 'pointer',
|
82
|
+
'&.is-focused': _objectSpread({}, defaultFocus),
|
83
|
+
'&.is-horizontal': {
|
84
|
+
top: '50%'
|
85
|
+
},
|
86
|
+
'&.is-vertical': {
|
87
|
+
left: '50%'
|
88
|
+
},
|
89
|
+
'&.is-hovered': {
|
90
|
+
backgroundColor: 'accent.40'
|
91
|
+
},
|
92
|
+
'&.is-pressed': {
|
93
|
+
backgroundColor: 'accent.20'
|
94
|
+
}
|
95
|
+
};
|
96
|
+
var activeTrack = {
|
97
|
+
bg: 'active',
|
98
|
+
position: 'absolute',
|
99
|
+
'&.is-horizontal': {
|
100
|
+
borderRadius: '11px 0px 0px 11px',
|
101
|
+
height: '100%',
|
102
|
+
'&.is-single-track': {
|
103
|
+
left: '0%'
|
104
|
+
}
|
105
|
+
},
|
106
|
+
'&.is-vertical': {
|
107
|
+
borderRadius: '11px 11px 11px 11px',
|
108
|
+
width: '100%',
|
109
|
+
bottom: '0%'
|
110
|
+
}
|
111
|
+
};
|
112
|
+
var trackWrapper = {
|
113
|
+
'&.is-vertical': {
|
114
|
+
py: '9px'
|
115
|
+
},
|
116
|
+
'&.is-horizontal': {
|
117
|
+
px: '9px'
|
118
|
+
}
|
119
|
+
};
|
120
|
+
var labelContainer = {
|
121
|
+
'&.is-horizontal': {
|
122
|
+
mb: 'xs'
|
123
|
+
},
|
124
|
+
'&.is-vertical': {
|
125
|
+
mt: 'xs',
|
126
|
+
gap: 'xs'
|
127
|
+
}
|
128
|
+
};
|
129
|
+
var wrapper = {
|
130
|
+
'&.is-horizontal': {
|
131
|
+
width: '100%'
|
132
|
+
},
|
133
|
+
'&.is-vertical': {
|
134
|
+
height: '100%',
|
135
|
+
ml: 'xs'
|
136
|
+
}
|
137
|
+
};
|
138
|
+
var outputContainer = {
|
139
|
+
'&.is-horizontal': {
|
140
|
+
marginLeft: 'auto',
|
141
|
+
mt: '-3px'
|
142
|
+
}
|
143
|
+
};
|
144
|
+
export default {
|
145
|
+
test: test,
|
146
|
+
slider: slider,
|
147
|
+
activeTrack: activeTrack,
|
148
|
+
thumb: thumb,
|
149
|
+
track: track,
|
150
|
+
hiddenTrack: hiddenTrack,
|
151
|
+
trackWrapper: trackWrapper,
|
152
|
+
labelContainer: labelContainer,
|
153
|
+
outputContainer: outputContainer,
|
154
|
+
wrapper: wrapper
|
155
|
+
};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
3
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
4
|
+
var _excluded = ["className", "isHorizontal", "isMultiThumb", "state", "sx"];
|
5
|
+
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; }
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
7
|
+
import _valuesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/values";
|
8
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
9
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
10
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
11
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
12
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
13
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
14
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
15
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
16
|
+
import React, { forwardRef } from 'react';
|
17
|
+
import { Box } from '../../index';
|
18
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
19
|
+
var SliderActiveTrack = /*#__PURE__*/forwardRef(function (props, ref) {
|
20
|
+
var className = props.className,
|
21
|
+
isHorizontal = props.isHorizontal,
|
22
|
+
isMultiThumb = props.isMultiThumb,
|
23
|
+
state = props.state,
|
24
|
+
sx = props.sx,
|
25
|
+
others = _objectWithoutProperties(props, _excluded);
|
26
|
+
var length = isMultiThumb ? "".concat(_valuesInstanceProperty(state)[1] - _valuesInstanceProperty(state)[0], "%") : "".concat(_valuesInstanceProperty(state)[0], "%");
|
27
|
+
var trackStart = "".concat(_valuesInstanceProperty(state)[0], "%");
|
28
|
+
var cssLenProp = isHorizontal ? 'width' : 'height';
|
29
|
+
var cssStartProp = isHorizontal ? 'left' : 'top';
|
30
|
+
return ___EmotionJSX(Box, _extends({
|
31
|
+
ref: ref,
|
32
|
+
className: className,
|
33
|
+
sx: _objectSpread(_objectSpread(_defineProperty({}, cssLenProp, length), isMultiThumb && _defineProperty({}, cssStartProp, trackStart)), sx),
|
34
|
+
variant: "slider.activeTrack"
|
35
|
+
}, others));
|
36
|
+
});
|
37
|
+
export default SliderActiveTrack;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
4
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
5
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
6
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
10
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
|
+
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; }
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
13
|
+
import React, { forwardRef } from 'react';
|
14
|
+
import { useSliderField } from '../../hooks';
|
15
|
+
import { Box, FieldHelperText } from '../../index';
|
16
|
+
import SliderActiveTrack from './SliderActiveTrack';
|
17
|
+
import SliderLabelContainer from './SliderLabelContainer';
|
18
|
+
import SliderThumb from './SliderThumb';
|
19
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
20
|
+
var SliderField = /*#__PURE__*/forwardRef(function (props, ref) {
|
21
|
+
var helperText = props.helperText,
|
22
|
+
_props$isMultiThumb = props.isMultiThumb,
|
23
|
+
isMultiThumb = _props$isMultiThumb === void 0 ? false : _props$isMultiThumb;
|
24
|
+
var trackRef = React.useRef(null);
|
25
|
+
var _useSliderField = useSliderField(_objectSpread(_objectSpread({}, props), {}, {
|
26
|
+
trackRef: trackRef
|
27
|
+
})),
|
28
|
+
containerProps = _useSliderField.containerProps,
|
29
|
+
labelContainerProps = _useSliderField.labelContainerProps,
|
30
|
+
sliderActiveTrackProps = _useSliderField.sliderActiveTrackProps,
|
31
|
+
hiddenTrackProps = _useSliderField.hiddenTrackProps,
|
32
|
+
helperTextProps = _useSliderField.helperTextProps,
|
33
|
+
thumbPropsSpread = _useSliderField.thumbPropsSpread,
|
34
|
+
visibleTrackProps = _useSliderField.visibleTrackProps,
|
35
|
+
wrapperProps = _useSliderField.wrapperProps;
|
36
|
+
return ___EmotionJSX(Box, _extends({}, containerProps, {
|
37
|
+
ref: ref
|
38
|
+
}), ___EmotionJSX(Box, wrapperProps, labelContainerProps.isHorizontal && ___EmotionJSX(SliderLabelContainer, labelContainerProps), ___EmotionJSX(Box, visibleTrackProps, ___EmotionJSX(SliderActiveTrack, sliderActiveTrackProps), ___EmotionJSX(Box, _extends({}, hiddenTrackProps, {
|
39
|
+
ref: trackRef
|
40
|
+
}), ___EmotionJSX(SliderThumb, _extends({}, thumbPropsSpread, {
|
41
|
+
index: 0
|
42
|
+
})), isMultiThumb && ___EmotionJSX(SliderThumb, _extends({}, thumbPropsSpread, {
|
43
|
+
index: 1
|
44
|
+
}))))), labelContainerProps.isVertical && ___EmotionJSX(SliderLabelContainer, labelContainerProps), helperText && ___EmotionJSX(FieldHelperText, helperTextProps, helperText));
|
45
|
+
});
|
46
|
+
export default SliderField;
|
@@ -0,0 +1,127 @@
|
|
1
|
+
import { Meta } from '@storybook/addon-docs';
|
2
|
+
|
3
|
+
<Meta title="Components/SliderField" />
|
4
|
+
|
5
|
+
# SliderField
|
6
|
+
|
7
|
+
The `SliderField` component is used to allow users to select a value from a range by dragging a thumb along a track. It supports both horizontal and vertical orientations, multi-thumb sliders, and provides a customizable display value.
|
8
|
+
|
9
|
+
### Recommended Use
|
10
|
+
|
11
|
+
- Use the `SliderField` component for selecting numeric values within a defined range.
|
12
|
+
- Display the current value dynamically as the user interacts with the slider.
|
13
|
+
- Use multi-thumb sliders for selecting a range of values.
|
14
|
+
|
15
|
+
### Features
|
16
|
+
|
17
|
+
- **Horizontal and Vertical Orientations**: Supports both orientations for flexible UI design.
|
18
|
+
- **Multi-Thumb Sliders**: Allows selecting a range of values.
|
19
|
+
- **Customizable Display Value**: Allows dynamic display of the current value.
|
20
|
+
- **Keyboard Accessibility**: Fully accessible with keyboard navigation.
|
21
|
+
- **Customizable Tracks and Thumbs**: Add custom class names or styles to `trackProps` and `activeTrackProps`.
|
22
|
+
|
23
|
+
### Props
|
24
|
+
|
25
|
+
| Prop | Type | Description |
|
26
|
+
| --------------------- | -------------------- | --------------------------------------------------------------------------- |
|
27
|
+
| `activeTrackProps` | `object` | Props passed to the active track element. |
|
28
|
+
| `autoFocus` | `boolean` | Automatically focuses the slider when it is rendered. |
|
29
|
+
| `className` | `string` | Additional class names for custom styling. |
|
30
|
+
| `defaultValue` | `number` `[number, number]` | The default value of the slider. |
|
31
|
+
| `displayValue` | `string` | Custom display value for the slider. |
|
32
|
+
| `formatOptions` | `Intl.NumberFormatOptions` | Options for formatting the display value. |
|
33
|
+
| `helperText` | `string` | Text displayed below the slider for additional context. |
|
34
|
+
| `helperTextProps` | `object` | Props passed to the helper text element. |
|
35
|
+
| `isDisabled` | `boolean` | Disables the slider. |
|
36
|
+
| `isDisplayValueHidden`| `boolean` | Hides the display value if set to `true`. |
|
37
|
+
| `isMultiThumb` | `boolean` | Enables multi-thumb slider functionality. |
|
38
|
+
| `label` | `string` `ReactNode` | Label for the slider. |
|
39
|
+
| `maxValue` | `number` | Maximum value of the slider. |
|
40
|
+
| `minValue` | `number` | Minimum value of the slider. |
|
41
|
+
| `name` | `string` | Name of the slider input. |
|
42
|
+
| `onBlur` | `function` | Callback triggered when the slider loses focus. |
|
43
|
+
| `onChange` | `function` | Callback triggered when the slider value changes. |
|
44
|
+
| `onChangeEnd` | `function` | Callback triggered when the slider interaction ends. |
|
45
|
+
| `onFocus` | `function` | Callback triggered when the slider gains focus. |
|
46
|
+
| `onFocusChange` | `function` | Callback triggered when the focus state changes. |
|
47
|
+
| `onKeyDown` | `function` | Callback triggered on key down events. |
|
48
|
+
| `onKeyUp` | `function` | Callback triggered on key up events. |
|
49
|
+
| `orientation` | `'horizontal' 'vertical'` | Orientation of the slider. |
|
50
|
+
| `step` | `number` | Step size for the slider. |
|
51
|
+
| `thumbProps` | `object` | Props passed to the slider thumb. |
|
52
|
+
| `trackProps` | `object` | Props passed to the track element. |
|
53
|
+
| `value` | `number` `[number, number]` | Controlled value of the slider. |
|
54
|
+
|
55
|
+
### Accessibility
|
56
|
+
|
57
|
+
This component adheres to accessibility guidelines to ensure a better user experience for all users.
|
58
|
+
|
59
|
+
#### Keyboard Navigation
|
60
|
+
|
61
|
+
| Keys | Function |
|
62
|
+
| ------------ | ----------------------------------------------------------------------- |
|
63
|
+
| Tab | Moves focus to the slider. |
|
64
|
+
| Arrow Keys | Adjusts the slider value incrementally. |
|
65
|
+
| Home | Moves the slider to the minimum value. |
|
66
|
+
| End | Moves the slider to the maximum value. |
|
67
|
+
|
68
|
+
#### Screen Readers
|
69
|
+
|
70
|
+
- **`aria-valuenow`**: Announces the current value of the slider.
|
71
|
+
- **`aria-valuemin` and `aria-valuemax`**: Define the minimum and maximum values of the slider.
|
72
|
+
- **`aria-orientation`**: Indicates whether the slider is horizontal or vertical.
|
73
|
+
|
74
|
+
### Example Usage
|
75
|
+
|
76
|
+
#### Single Thumb Slider
|
77
|
+
|
78
|
+
```jsx
|
79
|
+
<SliderField
|
80
|
+
label="Volume"
|
81
|
+
defaultValue={50}
|
82
|
+
minValue={0}
|
83
|
+
maxValue={100}
|
84
|
+
step={1}
|
85
|
+
onChange={(value) => console.log('Value:', value)}
|
86
|
+
/>
|
87
|
+
```
|
88
|
+
|
89
|
+
#### Multi-Thumb Slider
|
90
|
+
|
91
|
+
```jsx
|
92
|
+
<SliderField
|
93
|
+
label="Range"
|
94
|
+
isMultiThumb
|
95
|
+
defaultValue={[20, 80]}
|
96
|
+
minValue={0}
|
97
|
+
maxValue={100}
|
98
|
+
step={5}
|
99
|
+
onChange={(value) => console.log('Range:', value)}
|
100
|
+
/>
|
101
|
+
```
|
102
|
+
|
103
|
+
#### Custom Tracks and Thumbs
|
104
|
+
|
105
|
+
```jsx
|
106
|
+
<SliderField
|
107
|
+
label="Custom Slider"
|
108
|
+
trackProps={{ className: 'custom-track' }}
|
109
|
+
activeTrackProps={{ className: 'custom-active-track' }}
|
110
|
+
thumbProps={{ className: 'custom-thumb' }}
|
111
|
+
defaultValue={50}
|
112
|
+
minValue={0}
|
113
|
+
maxValue={100}
|
114
|
+
/>
|
115
|
+
```
|
116
|
+
|
117
|
+
#### Vertical Slider
|
118
|
+
|
119
|
+
```jsx
|
120
|
+
<SliderField
|
121
|
+
label="Vertical Slider"
|
122
|
+
orientation="vertical"
|
123
|
+
defaultValue={50}
|
124
|
+
minValue={0}
|
125
|
+
maxValue={100}
|
126
|
+
/>
|
127
|
+
```
|