@veritone-ce/design-system 1.12.46 → 1.12.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/cjs/assets/theme.js +7 -5
  2. package/dist/cjs/components/Button/index.js +17 -15
  3. package/dist/cjs/components/FileUploader/index.js +166 -156
  4. package/dist/cjs/components/IconButton/index.js +27 -0
  5. package/dist/cjs/components/MenuFlyout/index.js +2 -0
  6. package/dist/cjs/components/Table/AutoTable/common.js +143 -0
  7. package/dist/cjs/components/Table/AutoTable/controlled.js +120 -0
  8. package/dist/cjs/components/Table/AutoTable/index.js +118 -0
  9. package/dist/cjs/components/Table/AutoTable/types.js +5 -0
  10. package/dist/cjs/components/Table/AutoTable/virtual.js +154 -0
  11. package/dist/cjs/components/Table/index.js +83 -35
  12. package/dist/cjs/index.js +117 -68
  13. package/dist/esm/assets/theme.js +7 -5
  14. package/dist/esm/components/Button/index.js +17 -15
  15. package/dist/esm/components/FileUploader/index.js +163 -153
  16. package/dist/esm/components/IconButton/index.js +17 -0
  17. package/dist/esm/components/MenuFlyout/index.js +2 -0
  18. package/dist/esm/components/Table/AutoTable/common.js +133 -0
  19. package/dist/esm/components/Table/AutoTable/controlled.js +115 -0
  20. package/dist/esm/components/Table/AutoTable/index.js +107 -0
  21. package/dist/esm/components/Table/AutoTable/types.js +1 -0
  22. package/dist/esm/components/Table/AutoTable/virtual.js +149 -0
  23. package/dist/esm/components/Table/index.js +80 -33
  24. package/dist/esm/index.js +6 -2
  25. package/dist/types/components/Button/index.d.ts +2 -0
  26. package/dist/types/components/FileUploader/index.d.ts +18 -14
  27. package/dist/types/components/IconButton/index.d.ts +16 -0
  28. package/dist/types/components/MenuFlyout/index.d.ts +4 -4
  29. package/dist/types/components/Table/AutoTable/common.d.ts +25 -0
  30. package/dist/types/components/Table/AutoTable/controlled.d.ts +13 -0
  31. package/dist/types/components/Table/AutoTable/index.d.ts +44 -0
  32. package/dist/types/components/Table/AutoTable/types.d.ts +106 -0
  33. package/dist/types/components/Table/AutoTable/virtual.d.ts +19 -0
  34. package/dist/types/components/Table/index.d.ts +45 -8
  35. package/dist/types/index.d.ts +13 -4
  36. package/package.json +4 -1
@@ -1,23 +1,20 @@
1
1
  'use client';
2
2
 
3
3
  /* eslint-disable @typescript-eslint/no-explicit-any */
4
- var _excluded = ["accept", "multiple", "uploadFile", "onComplete", "onError"];
5
4
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
6
5
  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) { ["next", "throw", "return"].forEach(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" }], tryLocsList.forEach(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 keys.reverse(), 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) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(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; }
6
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
7
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
7
8
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
9
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
10
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
10
11
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
11
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
12
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
13
12
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
13
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
14
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
15
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
16
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
18
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
20
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
21
18
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
22
19
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
20
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -33,9 +30,17 @@ import { useDropzone } from 'react-dropzone';
33
30
  import LinearProgress from '../LinearProgress/index.js';
34
31
  import { jsx as _jsx } from "react/jsx-runtime";
35
32
  import { jsxs as _jsxs } from "react/jsx-runtime";
36
- export var FileUploaderView = function FileUploaderView(props) {
33
+ export default function FileUploader(props) {
37
34
  var _useTheme = useTheme(),
38
35
  palette = _useTheme.palette;
36
+ var _useDropzone = useDropzone({
37
+ disabled: props.uploading || props.uploaded,
38
+ multiple: props.multiple,
39
+ accept: props.accept,
40
+ onDrop: props.onDrop
41
+ }),
42
+ getRootProps = _useDropzone.getRootProps,
43
+ getInputProps = _useDropzone.getInputProps;
39
44
  return /*#__PURE__*/_jsxs(Box, {
40
45
  "data-testid": props['data-testid'],
41
46
  sx: props.sx,
@@ -59,13 +64,13 @@ export var FileUploaderView = function FileUploaderView(props) {
59
64
  cursor: 'pointer',
60
65
  outline: "1px solid ".concat(palette.neutral.main)
61
66
  }
62
- }, props.rootProps), {}, {
67
+ }, getRootProps()), {}, {
63
68
  children: [/*#__PURE__*/_jsx("input", _objectSpread({
64
69
  type: 'file',
65
70
  style: {
66
71
  display: 'none'
67
72
  }
68
- }, props.inputProps)), /*#__PURE__*/_jsx(Box, {
73
+ }, getInputProps())), /*#__PURE__*/_jsx(Box, {
69
74
  sx: {
70
75
  display: 'flex',
71
76
  alignItems: 'center',
@@ -108,7 +113,7 @@ export var FileUploaderView = function FileUploaderView(props) {
108
113
  lineHeight: '16px',
109
114
  color: palette.neutral.main
110
115
  },
111
- children: ["Supported File Formats: ", props.extensions.join(', ')]
116
+ children: ["Supported File Formats:", ' ', Object.values(props.accept).flat().join(', ')]
112
117
  })]
113
118
  })]
114
119
  })), props.filesState.map(function (file, index) {
@@ -130,7 +135,7 @@ export var FileUploaderView = function FileUploaderView(props) {
130
135
  isError: file.withError,
131
136
  feedbackText: file.feedbackText,
132
137
  isUploaded: file.isUploaded
133
- }), /*#__PURE__*/_jsx(IconButton, {
138
+ }), !props.uploading && !props.uploaded && /*#__PURE__*/_jsx(IconButton, {
134
139
  "data-testid": "file-item-delete-button",
135
140
  "aria-label": "delete",
136
141
  sx: {
@@ -150,23 +155,24 @@ export var FileUploaderView = function FileUploaderView(props) {
150
155
  }, index);
151
156
  })]
152
157
  });
153
- };
158
+ }
154
159
 
155
160
  // this returns a generator to provide incremental progress updates. See storybook for example
156
161
 
157
- var FileUploader = function FileUploader(_ref) {
158
- var _ref2;
159
- var accept = _ref.accept,
160
- multiple = _ref.multiple,
161
- uploadFile = _ref.uploadFile,
162
- onComplete = _ref.onComplete,
163
- onError = _ref.onError,
164
- props = _objectWithoutProperties(_ref, _excluded);
162
+ export function useFileUploader(options) {
165
163
  var filesRef = useRef([]);
166
164
  var _useState = useState([]),
167
165
  _useState2 = _slicedToArray(_useState, 2),
168
166
  filesState = _useState2[0],
169
167
  setFilesState = _useState2[1];
168
+ var _useState3 = useState(false),
169
+ _useState4 = _slicedToArray(_useState3, 2),
170
+ uploading = _useState4[0],
171
+ setUploading = _useState4[1];
172
+ var _useState5 = useState(false),
173
+ _useState6 = _slicedToArray(_useState5, 2),
174
+ uploaded = _useState6[0],
175
+ setUploaded = _useState6[1];
170
176
  var updateFileState = function updateFileState(file, update) {
171
177
  setFilesState(function (prevFilesState) {
172
178
  var index = filesRef.current.indexOf(file);
@@ -182,143 +188,147 @@ var FileUploader = function FileUploader(_ref) {
182
188
  });
183
189
  });
184
190
  };
185
- var uploadFiles = /*#__PURE__*/function uploadFiles(_x2) {
186
- return (_ref2 = _ref2 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(acceptedFiles) {
187
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
188
- while (1) switch (_context2.prev = _context2.next) {
189
- case 0:
190
- // add files to processing list
191
- filesRef.current = [].concat(_toConsumableArray(filesRef.current), _toConsumableArray(acceptedFiles));
192
- setFilesState(function (prevFilesState) {
193
- return [].concat(_toConsumableArray(prevFilesState), _toConsumableArray(acceptedFiles.map(function (acceptedFile) {
194
- return {
195
- name: acceptedFile.name,
196
- isUploaded: false,
197
- uploadProgress: 0,
198
- withError: false,
199
- feedbackText: ''
200
- };
201
- })));
202
- });
203
-
204
- // upload
205
- acceptedFiles.forEach(function (acceptedFile) {
206
- _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
207
- var uploadProgress, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, newProgress;
208
- return _regeneratorRuntime().wrap(function _callee$(_context) {
209
- while (1) switch (_context.prev = _context.next) {
210
- case 0:
211
- _context.prev = 0;
212
- _context.next = 3;
213
- return uploadFile(acceptedFile);
214
- case 3:
215
- uploadProgress = _context.sent;
216
- // get progress updates
217
- _iteratorAbruptCompletion = false;
218
- _didIteratorError = false;
219
- _context.prev = 6;
220
- _iterator = _asyncIterator(uploadProgress);
221
- case 8:
222
- _context.next = 10;
223
- return _iterator.next();
224
- case 10:
225
- if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
226
- _context.next = 16;
227
- break;
228
- }
229
- newProgress = _step.value;
230
- updateFileState(acceptedFile, {
231
- uploadProgress: newProgress
232
- });
233
- case 13:
234
- _iteratorAbruptCompletion = false;
235
- _context.next = 8;
236
- break;
237
- case 16:
238
- _context.next = 22;
239
- break;
240
- case 18:
241
- _context.prev = 18;
242
- _context.t0 = _context["catch"](6);
243
- _didIteratorError = true;
244
- _iteratorError = _context.t0;
245
- case 22:
246
- _context.prev = 22;
247
- _context.prev = 23;
248
- if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
249
- _context.next = 27;
250
- break;
251
- }
252
- _context.next = 27;
253
- return _iterator["return"]();
254
- case 27:
255
- _context.prev = 27;
256
- if (!_didIteratorError) {
257
- _context.next = 30;
258
- break;
259
- }
260
- throw _iteratorError;
261
- case 30:
262
- return _context.finish(27);
263
- case 31:
264
- return _context.finish(22);
265
- case 32:
266
- // complete
267
- updateFileState(acceptedFile, {
268
- isUploaded: true,
269
- uploadProgress: 100
270
- });
271
- onComplete === null || onComplete === void 0 ? void 0 : onComplete(acceptedFile);
272
- _context.next = 40;
273
- break;
274
- case 36:
275
- _context.prev = 36;
276
- _context.t1 = _context["catch"](0);
277
- // catch error
278
- updateFileState(acceptedFile, {
279
- withError: true
280
- });
281
- onError === null || onError === void 0 ? void 0 : onError(_context.t1);
282
- case 40:
283
- case "end":
284
- return _context.stop();
285
- }
286
- }, _callee, null, [[0, 36], [6, 18, 22, 32], [23,, 27, 31]]);
287
- }))();
288
- });
289
- case 3:
290
- case "end":
291
- return _context2.stop();
292
- }
293
- }, _callee2);
294
- }))).apply(this, arguments);
295
- };
296
- var _useDropzone = useDropzone({
297
- multiple: multiple,
298
- accept: accept,
299
- onDrop: function onDrop(acceptedFiles) {
300
- uploadFiles(acceptedFiles)["catch"](function (err) {
301
- onError === null || onError === void 0 ? void 0 : onError(err);
302
- });
303
- }
304
- }),
305
- getRootProps = _useDropzone.getRootProps,
306
- getInputProps = _useDropzone.getInputProps;
307
191
  var handleDeleteFile = useCallback(function (fileIndex) {
308
192
  filesRef.current.splice(fileIndex, 1);
309
193
  var nFileList = _toConsumableArray(filesState);
310
194
  nFileList.splice(fileIndex, 1);
311
195
  setFilesState(nFileList);
312
196
  }, [filesState]);
313
- return /*#__PURE__*/_jsx(FileUploaderView, {
314
- "data-testid": props['data-testid'],
315
- extensions: Object.values(accept).flat(),
316
- filesState: filesState,
317
- onDelete: handleDeleteFile,
318
- rootProps: getRootProps(),
319
- inputProps: getInputProps(),
320
- sx: props.sx,
321
- className: props.className
322
- });
323
- };
324
- export default FileUploader;
197
+ return {
198
+ files: filesState,
199
+ onDrop: function onDrop(acceptedFiles) {
200
+ // add files to processing list
201
+ filesRef.current = [].concat(_toConsumableArray(filesRef.current), _toConsumableArray(acceptedFiles));
202
+ setFilesState(function (prevFilesState) {
203
+ return [].concat(_toConsumableArray(prevFilesState), _toConsumableArray(acceptedFiles.map(function (acceptedFile) {
204
+ return {
205
+ name: acceptedFile.name,
206
+ isUploaded: false,
207
+ uploadProgress: 0,
208
+ withError: false,
209
+ feedbackText: 'Pending'
210
+ };
211
+ })));
212
+ });
213
+ },
214
+ removeFile: handleDeleteFile,
215
+ uploading: uploading,
216
+ uploaded: uploaded,
217
+ uploadFiles: function uploadFiles() {
218
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
219
+ var _ref;
220
+ var results;
221
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
222
+ while (1) switch (_context2.prev = _context2.next) {
223
+ case 0:
224
+ if (!(uploading || uploaded)) {
225
+ _context2.next = 2;
226
+ break;
227
+ }
228
+ return _context2.abrupt("return", []);
229
+ case 2:
230
+ setUploading(true);
231
+ _context2.next = 5;
232
+ return Promise.allSettled(filesRef.current.map( /*#__PURE__*/function (_x2) {
233
+ return (_ref = _ref || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(acceptedFile) {
234
+ var _options$onComplete, uploadProgress, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, newProgress, _options$onError;
235
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
236
+ while (1) switch (_context.prev = _context.next) {
237
+ case 0:
238
+ _context.prev = 0;
239
+ updateFileState(acceptedFile, {
240
+ feedbackText: ''
241
+ });
242
+ _context.next = 4;
243
+ return options.uploadFile(acceptedFile);
244
+ case 4:
245
+ uploadProgress = _context.sent;
246
+ // get progress updates
247
+ _iteratorAbruptCompletion = false;
248
+ _didIteratorError = false;
249
+ _context.prev = 7;
250
+ _iterator = _asyncIterator(uploadProgress);
251
+ case 9:
252
+ _context.next = 11;
253
+ return _iterator.next();
254
+ case 11:
255
+ if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
256
+ _context.next = 17;
257
+ break;
258
+ }
259
+ newProgress = _step.value;
260
+ updateFileState(acceptedFile, {
261
+ uploadProgress: newProgress,
262
+ feedbackText: ''
263
+ });
264
+ case 14:
265
+ _iteratorAbruptCompletion = false;
266
+ _context.next = 9;
267
+ break;
268
+ case 17:
269
+ _context.next = 23;
270
+ break;
271
+ case 19:
272
+ _context.prev = 19;
273
+ _context.t0 = _context["catch"](7);
274
+ _didIteratorError = true;
275
+ _iteratorError = _context.t0;
276
+ case 23:
277
+ _context.prev = 23;
278
+ _context.prev = 24;
279
+ if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
280
+ _context.next = 28;
281
+ break;
282
+ }
283
+ _context.next = 28;
284
+ return _iterator["return"]();
285
+ case 28:
286
+ _context.prev = 28;
287
+ if (!_didIteratorError) {
288
+ _context.next = 31;
289
+ break;
290
+ }
291
+ throw _iteratorError;
292
+ case 31:
293
+ return _context.finish(28);
294
+ case 32:
295
+ return _context.finish(23);
296
+ case 33:
297
+ // complete
298
+ updateFileState(acceptedFile, {
299
+ isUploaded: true,
300
+ uploadProgress: 100
301
+ });
302
+ (_options$onComplete = options.onComplete) === null || _options$onComplete === void 0 ? void 0 : _options$onComplete.call(options, acceptedFile);
303
+ _context.next = 42;
304
+ break;
305
+ case 37:
306
+ _context.prev = 37;
307
+ _context.t1 = _context["catch"](0);
308
+ // catch error
309
+ updateFileState(acceptedFile, {
310
+ withError: true
311
+ });
312
+ (_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call(options, _context.t1);
313
+ throw _context.t1;
314
+ case 42:
315
+ case "end":
316
+ return _context.stop();
317
+ }
318
+ }, _callee, null, [[0, 37], [7, 19, 23, 33], [24,, 28, 32]]);
319
+ }))).apply(this, arguments);
320
+ }));
321
+ case 5:
322
+ results = _context2.sent;
323
+ setUploading(false);
324
+ setUploaded(true);
325
+ return _context2.abrupt("return", results);
326
+ case 9:
327
+ case "end":
328
+ return _context2.stop();
329
+ }
330
+ }, _callee2);
331
+ }))();
332
+ }
333
+ };
334
+ }
@@ -0,0 +1,17 @@
1
+ import { IconButton as MuiIconButton } from '@mui/material';
2
+ import * as React from 'react';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ /**
5
+ - Use a button for common user click actions. Several variations available.
6
+ **/
7
+ var IconButton = function IconButton(props) {
8
+ var disabled = props.disabled;
9
+ return /*#__PURE__*/_jsx(MuiIconButton, {
10
+ disabled: disabled,
11
+ onClick: props.onClick,
12
+ sx: props.sx,
13
+ className: props.className,
14
+ children: props.children
15
+ });
16
+ };
17
+ export default IconButton;
@@ -5,12 +5,14 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
5
5
  var MenuFlyout = function MenuFlyout(props) {
6
6
  return /*#__PURE__*/_jsx(MuiMenu, {
7
7
  "data-testid": props['data-testid'],
8
+ anchorEl: props.anchorEl,
8
9
  open: props.open,
9
10
  onClose: props.onClose,
10
11
  sx: props.sx,
11
12
  className: props.className,
12
13
  children: props.menuOptions.map(function (menuItem, index) {
13
14
  return /*#__PURE__*/_jsx(MenuItem, {
15
+ onClick: menuItem.onSelect,
14
16
  children: /*#__PURE__*/_jsxs(Box, {
15
17
  sx: {
16
18
  display: 'flex',
@@ -0,0 +1,133 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ import { useReactTable, getCoreRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
8
+ import React from 'react';
9
+ import { TableCell } from '../index.js';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ export function createColumnHelper() {
12
+ return {
13
+ accessor: function accessor(_accessor, column) {
14
+ return typeof _accessor === 'function' ? _objectSpread(_objectSpread({}, column), {}, {
15
+ accessorFn: _accessor
16
+ }) : _objectSpread(_objectSpread({}, column), {}, {
17
+ accessorKey: _accessor
18
+ });
19
+ },
20
+ display: function display(column) {
21
+ return column;
22
+ }
23
+ // group: column => column
24
+ };
25
+ }
26
+
27
+ export function useAutoTable(options) {
28
+ var columnsProp = options.columns;
29
+ var mappedColumns = React.useMemo(function () {
30
+ return mapColumnDefs(columnsProp);
31
+ }, [columnsProp]);
32
+ return useReactTable({
33
+ data: options.data,
34
+ columns: mappedColumns,
35
+ manualSorting: options.manualSorting,
36
+ manualPagination: options.manualPagination,
37
+ enableSorting: options.enableSorting,
38
+ enableRowSelection: options.enableRowSelection,
39
+ meta: options.meta,
40
+ getRowId: options.getRowId,
41
+ defaultColumn: {
42
+ cell: function cell(info) {
43
+ return /*#__PURE__*/_jsx(TableCell, {
44
+ children: info.renderValue()
45
+ });
46
+ }
47
+ },
48
+ initialState: {
49
+ pagination: {
50
+ pageSize: options.pagination.pageSize
51
+ }
52
+ },
53
+ state: {
54
+ pagination: options.pagination,
55
+ sorting: options.sorting,
56
+ rowSelection: options.rowSelection
57
+ },
58
+ onSortingChange: function onSortingChange(updater) {
59
+ var value = typeof updater === 'function' ? updater(options.sorting) : updater;
60
+ options.onSortingChange(value);
61
+ },
62
+ onRowSelectionChange: function onRowSelectionChange(updater) {
63
+ var value = typeof updater === 'function' ? updater(options.rowSelection) : updater;
64
+ options.onRowSelectionChange(value);
65
+ },
66
+ onPaginationChange: function onPaginationChange() {},
67
+ getCoreRowModel: getCoreRowModel(),
68
+ getSortedRowModel: getSortedRowModel(),
69
+ getPaginationRowModel: getPaginationRowModel()
70
+ });
71
+ }
72
+ export function mapColumnDefs(columnDefs) {
73
+ return columnDefs.map(mapColumnDef);
74
+ }
75
+ export function mapColumnDef(columnDef) {
76
+ // typed column meta
77
+ var meta = {
78
+ noVerticalPadding: columnDef.noVerticalPadding
79
+ };
80
+ var mappedDef = {
81
+ id: columnDef.id,
82
+ accessorFn: columnDef.accessorFn,
83
+ accessorKey: columnDef.accessorKey,
84
+ meta: meta,
85
+ getUniqueValues: columnDef.getUniqueValues,
86
+ header: columnDef.header !== undefined ? makeHeaderMappingComponent(columnDef.header) : undefined,
87
+ cell: columnDef.cell !== undefined ? makeCellMappingComponent(columnDef.cell) : undefined,
88
+ enableMultiSort: columnDef.enableMultiSort,
89
+ enableSorting: columnDef.enableSorting,
90
+ invertSorting: columnDef.invertSorting,
91
+ sortDescFirst: columnDef.sortDescFirst,
92
+ sortingFn: columnDef.sortingFn,
93
+ sortUndefined: columnDef.sortUndefined
94
+ };
95
+
96
+ // remove all fileds that are undefined because react-table is probably using Object.keys in a weird way under the hood
97
+ Object.keys(mappedDef).forEach(function (key) {
98
+ var k = key;
99
+ if (mappedDef[k] === undefined) {
100
+ delete mappedDef[k];
101
+ }
102
+ });
103
+ return mappedDef;
104
+ }
105
+ function makeHeaderMappingComponent(header) {
106
+ if (typeof header === 'string') {
107
+ return header;
108
+ }
109
+ return function (props) {
110
+ return header({
111
+ column: props.column,
112
+ header: props.header,
113
+ table: props.table,
114
+ meta: props.table.options.meta
115
+ });
116
+ };
117
+ }
118
+ function makeCellMappingComponent(cell) {
119
+ if (typeof cell === 'string') {
120
+ return cell;
121
+ }
122
+ return function (props) {
123
+ return cell({
124
+ cell: props.cell,
125
+ column: props.column,
126
+ getValue: props.getValue,
127
+ renderValue: props.renderValue,
128
+ row: props.row,
129
+ table: props.table,
130
+ meta: props.table.options.meta
131
+ });
132
+ };
133
+ }