@rpg-engine/long-bow 0.6.7 → 0.6.8

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.
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  interface IStep {
3
3
  component: React.ReactNode;
4
4
  id: number;
5
+ validate?: () => boolean | Promise<boolean>;
6
+ errorMessage?: string;
5
7
  }
6
8
  interface IStepperProps {
7
9
  steps: IStep[];
@@ -9,6 +11,7 @@ interface IStepperProps {
9
11
  label: string;
10
12
  onClick: (() => void) | (() => Promise<void>) | ((e: any) => Promise<void>);
11
13
  };
14
+ onError?: (message: string) => void;
12
15
  }
13
16
  export declare const Stepper: React.FC<IStepperProps>;
14
17
  export {};
@@ -144,6 +144,337 @@ var DropdownOptions = /*#__PURE__*/styled__default.ul.withConfig({
144
144
  return props.opensUp ? 'auto' : '100%';
145
145
  });
146
146
 
147
+ function _regeneratorRuntime() {
148
+ _regeneratorRuntime = function () {
149
+ return exports;
150
+ };
151
+ var exports = {},
152
+ Op = Object.prototype,
153
+ hasOwn = Op.hasOwnProperty,
154
+ defineProperty = Object.defineProperty || function (obj, key, desc) {
155
+ obj[key] = desc.value;
156
+ },
157
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
158
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
159
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
160
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
161
+ function define(obj, key, value) {
162
+ return Object.defineProperty(obj, key, {
163
+ value: value,
164
+ enumerable: !0,
165
+ configurable: !0,
166
+ writable: !0
167
+ }), obj[key];
168
+ }
169
+ try {
170
+ define({}, "");
171
+ } catch (err) {
172
+ define = function (obj, key, value) {
173
+ return obj[key] = value;
174
+ };
175
+ }
176
+ function wrap(innerFn, outerFn, self, tryLocsList) {
177
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
178
+ generator = Object.create(protoGenerator.prototype),
179
+ context = new Context(tryLocsList || []);
180
+ return defineProperty(generator, "_invoke", {
181
+ value: makeInvokeMethod(innerFn, self, context)
182
+ }), generator;
183
+ }
184
+ function tryCatch(fn, obj, arg) {
185
+ try {
186
+ return {
187
+ type: "normal",
188
+ arg: fn.call(obj, arg)
189
+ };
190
+ } catch (err) {
191
+ return {
192
+ type: "throw",
193
+ arg: err
194
+ };
195
+ }
196
+ }
197
+ exports.wrap = wrap;
198
+ var ContinueSentinel = {};
199
+ function Generator() {}
200
+ function GeneratorFunction() {}
201
+ function GeneratorFunctionPrototype() {}
202
+ var IteratorPrototype = {};
203
+ define(IteratorPrototype, iteratorSymbol, function () {
204
+ return this;
205
+ });
206
+ var getProto = Object.getPrototypeOf,
207
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
208
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
209
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
210
+ function defineIteratorMethods(prototype) {
211
+ ["next", "throw", "return"].forEach(function (method) {
212
+ define(prototype, method, function (arg) {
213
+ return this._invoke(method, arg);
214
+ });
215
+ });
216
+ }
217
+ function AsyncIterator(generator, PromiseImpl) {
218
+ function invoke(method, arg, resolve, reject) {
219
+ var record = tryCatch(generator[method], generator, arg);
220
+ if ("throw" !== record.type) {
221
+ var result = record.arg,
222
+ value = result.value;
223
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
224
+ invoke("next", value, resolve, reject);
225
+ }, function (err) {
226
+ invoke("throw", err, resolve, reject);
227
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
228
+ result.value = unwrapped, resolve(result);
229
+ }, function (error) {
230
+ return invoke("throw", error, resolve, reject);
231
+ });
232
+ }
233
+ reject(record.arg);
234
+ }
235
+ var previousPromise;
236
+ defineProperty(this, "_invoke", {
237
+ value: function (method, arg) {
238
+ function callInvokeWithMethodAndArg() {
239
+ return new PromiseImpl(function (resolve, reject) {
240
+ invoke(method, arg, resolve, reject);
241
+ });
242
+ }
243
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
244
+ }
245
+ });
246
+ }
247
+ function makeInvokeMethod(innerFn, self, context) {
248
+ var state = "suspendedStart";
249
+ return function (method, arg) {
250
+ if ("executing" === state) throw new Error("Generator is already running");
251
+ if ("completed" === state) {
252
+ if ("throw" === method) throw arg;
253
+ return doneResult();
254
+ }
255
+ for (context.method = method, context.arg = arg;;) {
256
+ var delegate = context.delegate;
257
+ if (delegate) {
258
+ var delegateResult = maybeInvokeDelegate(delegate, context);
259
+ if (delegateResult) {
260
+ if (delegateResult === ContinueSentinel) continue;
261
+ return delegateResult;
262
+ }
263
+ }
264
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
265
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
266
+ context.dispatchException(context.arg);
267
+ } else "return" === context.method && context.abrupt("return", context.arg);
268
+ state = "executing";
269
+ var record = tryCatch(innerFn, self, context);
270
+ if ("normal" === record.type) {
271
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
272
+ return {
273
+ value: record.arg,
274
+ done: context.done
275
+ };
276
+ }
277
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
278
+ }
279
+ };
280
+ }
281
+ function maybeInvokeDelegate(delegate, context) {
282
+ var methodName = context.method,
283
+ method = delegate.iterator[methodName];
284
+ 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;
285
+ var record = tryCatch(method, delegate.iterator, context.arg);
286
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
287
+ var info = record.arg;
288
+ 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);
289
+ }
290
+ function pushTryEntry(locs) {
291
+ var entry = {
292
+ tryLoc: locs[0]
293
+ };
294
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
295
+ }
296
+ function resetTryEntry(entry) {
297
+ var record = entry.completion || {};
298
+ record.type = "normal", delete record.arg, entry.completion = record;
299
+ }
300
+ function Context(tryLocsList) {
301
+ this.tryEntries = [{
302
+ tryLoc: "root"
303
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
304
+ }
305
+ function values(iterable) {
306
+ if (iterable) {
307
+ var iteratorMethod = iterable[iteratorSymbol];
308
+ if (iteratorMethod) return iteratorMethod.call(iterable);
309
+ if ("function" == typeof iterable.next) return iterable;
310
+ if (!isNaN(iterable.length)) {
311
+ var i = -1,
312
+ next = function next() {
313
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
314
+ return next.value = undefined, next.done = !0, next;
315
+ };
316
+ return next.next = next;
317
+ }
318
+ }
319
+ return {
320
+ next: doneResult
321
+ };
322
+ }
323
+ function doneResult() {
324
+ return {
325
+ value: undefined,
326
+ done: !0
327
+ };
328
+ }
329
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
330
+ value: GeneratorFunctionPrototype,
331
+ configurable: !0
332
+ }), defineProperty(GeneratorFunctionPrototype, "constructor", {
333
+ value: GeneratorFunction,
334
+ configurable: !0
335
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
336
+ var ctor = "function" == typeof genFun && genFun.constructor;
337
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
338
+ }, exports.mark = function (genFun) {
339
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
340
+ }, exports.awrap = function (arg) {
341
+ return {
342
+ __await: arg
343
+ };
344
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
345
+ return this;
346
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
347
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
348
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
349
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
350
+ return result.done ? result.value : iter.next();
351
+ });
352
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
353
+ return this;
354
+ }), define(Gp, "toString", function () {
355
+ return "[object Generator]";
356
+ }), exports.keys = function (val) {
357
+ var object = Object(val),
358
+ keys = [];
359
+ for (var key in object) keys.push(key);
360
+ return keys.reverse(), function next() {
361
+ for (; keys.length;) {
362
+ var key = keys.pop();
363
+ if (key in object) return next.value = key, next.done = !1, next;
364
+ }
365
+ return next.done = !0, next;
366
+ };
367
+ }, exports.values = values, Context.prototype = {
368
+ constructor: Context,
369
+ reset: function (skipTempReset) {
370
+ 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);
371
+ },
372
+ stop: function () {
373
+ this.done = !0;
374
+ var rootRecord = this.tryEntries[0].completion;
375
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
376
+ return this.rval;
377
+ },
378
+ dispatchException: function (exception) {
379
+ if (this.done) throw exception;
380
+ var context = this;
381
+ function handle(loc, caught) {
382
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
383
+ }
384
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
385
+ var entry = this.tryEntries[i],
386
+ record = entry.completion;
387
+ if ("root" === entry.tryLoc) return handle("end");
388
+ if (entry.tryLoc <= this.prev) {
389
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
390
+ hasFinally = hasOwn.call(entry, "finallyLoc");
391
+ if (hasCatch && hasFinally) {
392
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
393
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
394
+ } else if (hasCatch) {
395
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
396
+ } else {
397
+ if (!hasFinally) throw new Error("try statement without catch or finally");
398
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
399
+ }
400
+ }
401
+ }
402
+ },
403
+ abrupt: function (type, arg) {
404
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
405
+ var entry = this.tryEntries[i];
406
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
407
+ var finallyEntry = entry;
408
+ break;
409
+ }
410
+ }
411
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
412
+ var record = finallyEntry ? finallyEntry.completion : {};
413
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
414
+ },
415
+ complete: function (record, afterLoc) {
416
+ if ("throw" === record.type) throw record.arg;
417
+ 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;
418
+ },
419
+ finish: function (finallyLoc) {
420
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
421
+ var entry = this.tryEntries[i];
422
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
423
+ }
424
+ },
425
+ catch: function (tryLoc) {
426
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
427
+ var entry = this.tryEntries[i];
428
+ if (entry.tryLoc === tryLoc) {
429
+ var record = entry.completion;
430
+ if ("throw" === record.type) {
431
+ var thrown = record.arg;
432
+ resetTryEntry(entry);
433
+ }
434
+ return thrown;
435
+ }
436
+ }
437
+ throw new Error("illegal catch attempt");
438
+ },
439
+ delegateYield: function (iterable, resultName, nextLoc) {
440
+ return this.delegate = {
441
+ iterator: values(iterable),
442
+ resultName: resultName,
443
+ nextLoc: nextLoc
444
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
445
+ }
446
+ }, exports;
447
+ }
448
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
449
+ try {
450
+ var info = gen[key](arg);
451
+ var value = info.value;
452
+ } catch (error) {
453
+ reject(error);
454
+ return;
455
+ }
456
+ if (info.done) {
457
+ resolve(value);
458
+ } else {
459
+ Promise.resolve(value).then(_next, _throw);
460
+ }
461
+ }
462
+ function _asyncToGenerator(fn) {
463
+ return function () {
464
+ var self = this,
465
+ args = arguments;
466
+ return new Promise(function (resolve, reject) {
467
+ var gen = fn.apply(self, args);
468
+ function _next(value) {
469
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
470
+ }
471
+ function _throw(err) {
472
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
473
+ }
474
+ _next(undefined);
475
+ });
476
+ };
477
+ }
147
478
  function _extends() {
148
479
  _extends = Object.assign ? Object.assign.bind() : function (target) {
149
480
  for (var i = 1; i < arguments.length; i++) {
@@ -19120,15 +19451,61 @@ var SpellList = /*#__PURE__*/styled__default.div.withConfig({
19120
19451
  var Stepper = function Stepper(_ref) {
19121
19452
  var _steps$currentStep;
19122
19453
  var steps = _ref.steps,
19123
- finalCTAButton = _ref.finalCTAButton;
19454
+ finalCTAButton = _ref.finalCTAButton,
19455
+ onError = _ref.onError;
19124
19456
  var _useState = React.useState(0),
19125
19457
  currentStep = _useState[0],
19126
19458
  setCurrentStep = _useState[1];
19127
19459
  var currentComponent = (_steps$currentStep = steps[currentStep]) == null ? void 0 : _steps$currentStep.component;
19128
19460
  var totalSteps = steps.length;
19129
- var onStepChange = function onStepChange(step) {
19130
- setCurrentStep(step);
19131
- };
19461
+ var onStepChange = /*#__PURE__*/function () {
19462
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(step) {
19463
+ var _steps$currentStep2;
19464
+ var isValid;
19465
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
19466
+ while (1) switch (_context.prev = _context.next) {
19467
+ case 0:
19468
+ if (!((_steps$currentStep2 = steps[currentStep]) != null && _steps$currentStep2.validate)) {
19469
+ _context.next = 14;
19470
+ break;
19471
+ }
19472
+ _context.prev = 1;
19473
+ _context.next = 4;
19474
+ return steps[currentStep].validate();
19475
+ case 4:
19476
+ isValid = _context.sent;
19477
+ if (isValid) {
19478
+ _context.next = 8;
19479
+ break;
19480
+ }
19481
+ // If the current step is not valid, prevent navigation and trigger onError
19482
+ if (onError) {
19483
+ onError(steps[currentStep].errorMessage || "Validation failed on step " + (currentStep + 1));
19484
+ }
19485
+ return _context.abrupt("return");
19486
+ case 8:
19487
+ _context.next = 14;
19488
+ break;
19489
+ case 10:
19490
+ _context.prev = 10;
19491
+ _context.t0 = _context["catch"](1);
19492
+ // Handle unexpected validation errors
19493
+ if (onError) {
19494
+ onError("An error occurred during validation on step " + (currentStep + 1));
19495
+ }
19496
+ return _context.abrupt("return");
19497
+ case 14:
19498
+ setCurrentStep(step);
19499
+ case 15:
19500
+ case "end":
19501
+ return _context.stop();
19502
+ }
19503
+ }, _callee, null, [[1, 10]]);
19504
+ }));
19505
+ return function onStepChange(_x) {
19506
+ return _ref2.apply(this, arguments);
19507
+ };
19508
+ }();
19132
19509
  return React__default.createElement(StepperContainer, {
19133
19510
  className: "stepper-container"
19134
19511
  }, React__default.createElement(StepperTop, null, Array.from({
@@ -19153,7 +19530,7 @@ var Stepper = function Stepper(_ref) {
19153
19530
  }
19154
19531
  }), currentStep === totalSteps - 1 && finalCTAButton && React__default.createElement(Button, {
19155
19532
  buttonType: exports.ButtonTypes.RPGUIButton,
19156
- onPointerDown: finalCTAButton.onClick
19533
+ onClick: finalCTAButton.onClick
19157
19534
  }, finalCTAButton.label)));
19158
19535
  };
19159
19536
  var StepperContainer = /*#__PURE__*/styled__default.div.withConfig({
@@ -19175,11 +19552,11 @@ var StepperFooter = /*#__PURE__*/styled__default.div.withConfig({
19175
19552
  var ProgressIndicator = /*#__PURE__*/styled__default.div.withConfig({
19176
19553
  displayName: "Stepper__ProgressIndicator",
19177
19554
  componentId: "sc-13obf1-4"
19178
- })(["width:20px;height:20px;border-radius:50%;background-color:", ";margin:0 5px;transition:background-color 0.3s;opacity:", ";border:1px solid ", ";cursor:pointer;"], function (_ref2) {
19179
- var isActive = _ref2.isActive;
19180
- return isActive ? uiColors.orange : uiColors.lightGray;
19181
- }, function (_ref3) {
19555
+ })(["width:20px;height:20px;border-radius:50%;background-color:", ";margin:0 5px;transition:background-color 0.3s;opacity:", ";border:1px solid ", ";cursor:pointer;"], function (_ref3) {
19182
19556
  var isActive = _ref3.isActive;
19557
+ return isActive ? uiColors.orange : uiColors.lightGray;
19558
+ }, function (_ref4) {
19559
+ var isActive = _ref4.isActive;
19183
19560
  return isActive ? 1 : 0.25;
19184
19561
  }, uiColors.raisinBlack);
19185
19562