@homebound/beam 2.137.7 → 2.138.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,19 +10,14 @@ function Stepper({ steps, currentStep, onChange }) {
10
10
  if (steps.length === 0) {
11
11
  throw new Error("Stepper must be initialized with at least one step");
12
12
  }
13
- const [progressBarStep, setProgressBarStep] = (0, react_1.useState)(0);
14
- (0, react_1.useEffect)(() => {
15
- const currentStepIndex = steps.findIndex((s) => s.value === currentStep) || 0;
16
- if (currentStepIndex > progressBarStep) {
17
- setProgressBarStep(currentStepIndex);
18
- }
19
- }, [currentStep]);
13
+ // calc progress based on last completed step - return -1 when no steps completed
14
+ const lastCompletedStep = steps.map((step) => step.state).lastIndexOf("complete");
20
15
  return ((0, jsx_runtime_1.jsxs)("nav", Object.assign({ "aria-label": "steps", css: Css_1.Css.df.fdc.$ }, { children: [(0, jsx_runtime_1.jsx)("ol", Object.assign({ css: Css_1.Css.listReset.df.$ }, { children: steps.map((step) => {
21
16
  const isCurrent = currentStep === step.value;
22
17
  return ((0, jsx_runtime_1.jsx)("li", Object.assign({ css: Css_1.Css.df.fdc.wPx(200).$, "aria-current": isCurrent }, { children: (0, jsx_runtime_1.jsx)(StepButton, Object.assign({}, step, { onClick: () => onChange(step.value), isCurrent: isCurrent }), void 0) }), step.label));
23
18
  }) }), void 0), (0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.mt1.bgGray300.hPx(4).w(`${steps.length * 200}px`).$ }, { children: (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.bgLightBlue600
24
19
  .add("transition", "width 200ms")
25
- .h100.w(`${((progressBarStep + 1) / steps.length) * 100}%`).$ }, void 0) }), void 0)] }), void 0));
20
+ .h100.w(`${((lastCompletedStep + 1) / steps.length) * 100}%`).$ }, void 0) }), void 0)] }), void 0));
26
21
  }
27
22
  exports.Stepper = Stepper;
28
23
  function StepButton({ label, disabled, state, isCurrent, onClick }) {
@@ -24,7 +24,7 @@ function numericColumn(columnDef) {
24
24
  exports.numericColumn = numericColumn;
25
25
  /** Provides default styling for a GridColumn representing an Action. */
26
26
  function actionColumn(columnDef) {
27
- return { clientSideSort: false, ...columnDef, align: "center", isAction: true };
27
+ return { clientSideSort: false, ...columnDef, align: "center", isAction: true, wrapAction: false };
28
28
  }
29
29
  exports.actionColumn = actionColumn;
30
30
  /**
@@ -27,6 +27,7 @@ exports.condensedStyle = {
27
27
  /** Renders each row as a card. */
28
28
  exports.cardStyle = {
29
29
  ...exports.defaultStyle,
30
+ betweenRowsCss: {},
30
31
  firstNonHeaderRowCss: Css_1.Css.mt2.$,
31
32
  cellCss: Css_1.Css.p2.my1.bt.bb.bGray400.$,
32
33
  firstCellCss: Css_1.Css.bl.add({ borderTopLeftRadius: "4px", borderBottomLeftRadius: "4px" }).$,
@@ -45,9 +45,9 @@ function StepperForm({ formState }) {
45
45
  const onBack = (0, react_1.useCallback)(() => {
46
46
  const currentStepIndex = steps.findIndex((s) => s.value === currentStep);
47
47
  setActiveStep(steps[currentStepIndex === 0 ? 0 : currentStepIndex - 1].value);
48
- }, [currentStep]);
48
+ }, [currentStep, steps]);
49
49
  (0, react_1.useEffect)(() => {
50
- const disposer = (0, mobx_1.reaction)(() => [formState.firstName.valid && formState.lastName.valid, formState.books.valid], ([step1Valid, step2Valid], [wasStep1Valid, wasStep2Valid]) => {
50
+ const disposer = (0, mobx_1.reaction)(() => [formState.firstName.valid && formState.lastName.valid, formState.books.valid, formState.birthday.valid], ([step1Valid, step2Valid, step3Valid], [wasStep1Valid, wasStep2Valid, wasStep3Valid]) => {
51
51
  if (step1Valid && step1Valid !== wasStep1Valid) {
52
52
  setStep("books", { disabled: !step1Valid });
53
53
  return;
@@ -56,10 +56,14 @@ function StepperForm({ formState }) {
56
56
  setStep("misc", { disabled: !step2Valid });
57
57
  return;
58
58
  }
59
+ if (step3Valid && step3Valid !== wasStep3Valid) {
60
+ setStep("misc", { state: "complete" });
61
+ return;
62
+ }
59
63
  });
60
64
  // Return the disposer in order to clean up useEffect.
61
65
  return disposer;
62
- }, [setStep]);
66
+ }, [setStep, formState.birthday.valid, formState.books.valid, formState.firstName.valid, formState.lastName.valid]);
63
67
  return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(Stepper_1.Stepper, { steps: steps, currentStep: currentStep, onChange: setActiveStep }, void 0), (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.mt2.$ }, { children: [currentStep === "author" && (0, jsx_runtime_1.jsx)(AuthorDetails, { formState: formState, onNext: onNext }, void 0), currentStep === "books" && (0, jsx_runtime_1.jsx)(BookList, { formState: formState, onNext: onNext, onBack: onBack }, void 0), currentStep === "misc" && (0, jsx_runtime_1.jsx)(MiscAuthorDetails, { formState: formState, onBack: onBack }, void 0)] }), void 0)] }, void 0));
64
68
  }
65
69
  function AuthorDetails({ formState, onNext }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.137.7",
3
+ "version": "2.138.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",