@homebound/beam 2.380.1 → 2.381.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -16490,6 +16490,9 @@ function BoundDateRangeField(props) {
16490
16490
  ) });
16491
16491
  }
16492
16492
 
16493
+ // src/forms/BoundForm.tsx
16494
+ import { useMemo as useMemo38 } from "react";
16495
+
16493
16496
  // src/forms/BoundIconCardField.tsx
16494
16497
  import { Observer as Observer6 } from "mobx-react";
16495
16498
  import { jsx as jsx138 } from "@emotion/react/jsx-runtime";
@@ -16818,35 +16821,9 @@ function BoundRichTextField(props) {
16818
16821
  ) });
16819
16822
  }
16820
16823
 
16821
- // src/forms/BoundSelectAndTextField.tsx
16822
- import { jsx as jsx146, jsxs as jsxs73 } from "@emotion/react/jsx-runtime";
16823
- function BoundSelectAndTextField(props) {
16824
- const { selectFieldProps, textFieldProps, compact = true } = props;
16825
- const tid = useTestIds(props);
16826
- return /* @__PURE__ */ jsxs73(CompoundField, { children: [
16827
- /* @__PURE__ */ jsx146(
16828
- BoundSelectField,
16829
- {
16830
- ...tid[defaultTestId(selectFieldProps.label ?? selectFieldProps.field.key)],
16831
- ...selectFieldProps,
16832
- sizeToContent: true,
16833
- compact
16834
- }
16835
- ),
16836
- /* @__PURE__ */ jsx146(
16837
- BoundTextField,
16838
- {
16839
- ...tid[defaultTestId(textFieldProps.label ?? textFieldProps.field.key)],
16840
- ...textFieldProps,
16841
- compact
16842
- }
16843
- )
16844
- ] });
16845
- }
16846
-
16847
16824
  // src/forms/BoundSelectField.tsx
16848
16825
  import { Observer as Observer13 } from "mobx-react";
16849
- import { jsx as jsx147 } from "@emotion/react/jsx-runtime";
16826
+ import { jsx as jsx146 } from "@emotion/react/jsx-runtime";
16850
16827
  function BoundSelectField(props) {
16851
16828
  const {
16852
16829
  field,
@@ -16861,7 +16838,7 @@ function BoundSelectField(props) {
16861
16838
  ...others
16862
16839
  } = props;
16863
16840
  const testId = useTestIds(props, field.key);
16864
- return /* @__PURE__ */ jsx147(Observer13, { children: () => /* @__PURE__ */ jsx147(
16841
+ return /* @__PURE__ */ jsx146(Observer13, { children: () => /* @__PURE__ */ jsx146(
16865
16842
  SelectField,
16866
16843
  {
16867
16844
  label,
@@ -16892,7 +16869,7 @@ function BoundSelectField(props) {
16892
16869
 
16893
16870
  // src/forms/BoundSwitchField.tsx
16894
16871
  import { Observer as Observer14 } from "mobx-react";
16895
- import { jsx as jsx148 } from "@emotion/react/jsx-runtime";
16872
+ import { jsx as jsx147 } from "@emotion/react/jsx-runtime";
16896
16873
  function BoundSwitchField(props) {
16897
16874
  const {
16898
16875
  field,
@@ -16903,7 +16880,7 @@ function BoundSwitchField(props) {
16903
16880
  ...others
16904
16881
  } = props;
16905
16882
  const testId = useTestIds(props, field.key);
16906
- return /* @__PURE__ */ jsx148(Observer14, { children: () => /* @__PURE__ */ jsx148(
16883
+ return /* @__PURE__ */ jsx147(Observer14, { children: () => /* @__PURE__ */ jsx147(
16907
16884
  Switch,
16908
16885
  {
16909
16886
  label,
@@ -16922,7 +16899,7 @@ function BoundSwitchField(props) {
16922
16899
 
16923
16900
  // src/forms/BoundTextAreaField.tsx
16924
16901
  import { Observer as Observer15 } from "mobx-react";
16925
- import { jsx as jsx149 } from "@emotion/react/jsx-runtime";
16902
+ import { jsx as jsx148 } from "@emotion/react/jsx-runtime";
16926
16903
  function BoundTextAreaField(props) {
16927
16904
  const {
16928
16905
  field,
@@ -16935,7 +16912,7 @@ function BoundTextAreaField(props) {
16935
16912
  ...others
16936
16913
  } = props;
16937
16914
  const testId = useTestIds(props, field.key);
16938
- return /* @__PURE__ */ jsx149(Observer15, { children: () => /* @__PURE__ */ jsx149(
16915
+ return /* @__PURE__ */ jsx148(Observer15, { children: () => /* @__PURE__ */ jsx148(
16939
16916
  TextAreaField,
16940
16917
  {
16941
16918
  label,
@@ -16964,7 +16941,7 @@ function BoundTextAreaField(props) {
16964
16941
 
16965
16942
  // src/forms/BoundTextField.tsx
16966
16943
  import { Observer as Observer16 } from "mobx-react";
16967
- import { jsx as jsx150 } from "@emotion/react/jsx-runtime";
16944
+ import { jsx as jsx149 } from "@emotion/react/jsx-runtime";
16968
16945
  function BoundTextField(props) {
16969
16946
  const {
16970
16947
  field,
@@ -16977,7 +16954,7 @@ function BoundTextField(props) {
16977
16954
  ...others
16978
16955
  } = props;
16979
16956
  const testId = useTestIds(props, field.key);
16980
- return /* @__PURE__ */ jsx150(Observer16, { children: () => /* @__PURE__ */ jsx150(
16957
+ return /* @__PURE__ */ jsx149(Observer16, { children: () => /* @__PURE__ */ jsx149(
16981
16958
  TextField,
16982
16959
  {
16983
16960
  label,
@@ -17006,16 +16983,16 @@ function BoundTextField(props) {
17006
16983
 
17007
16984
  // src/forms/BoundToggleChipGroupField.tsx
17008
16985
  import { Observer as Observer17 } from "mobx-react";
17009
- import { jsx as jsx151 } from "@emotion/react/jsx-runtime";
16986
+ import { jsx as jsx150 } from "@emotion/react/jsx-runtime";
17010
16987
  function BoundToggleChipGroupField(props) {
17011
16988
  const { field, onChange = (value) => field.set(value), label = defaultLabel(field.key), ...others } = props;
17012
16989
  const testId = useTestIds(props, field.key);
17013
- return /* @__PURE__ */ jsx151(Observer17, { children: () => /* @__PURE__ */ jsx151(ToggleChipGroup, { label, values: field.value || [], onChange, ...testId, ...others }) });
16990
+ return /* @__PURE__ */ jsx150(Observer17, { children: () => /* @__PURE__ */ jsx150(ToggleChipGroup, { label, values: field.value || [], onChange, ...testId, ...others }) });
17014
16991
  }
17015
16992
 
17016
16993
  // src/forms/BoundTreeSelectField.tsx
17017
16994
  import { Observer as Observer18 } from "mobx-react";
17018
- import { jsx as jsx152 } from "@emotion/react/jsx-runtime";
16995
+ import { jsx as jsx151 } from "@emotion/react/jsx-runtime";
17019
16996
  function BoundTreeSelectField(props) {
17020
16997
  const {
17021
16998
  field,
@@ -17032,7 +17009,7 @@ function BoundTreeSelectField(props) {
17032
17009
  ...others
17033
17010
  } = props;
17034
17011
  const testId = useTestIds(props, field.key);
17035
- return /* @__PURE__ */ jsx152(Observer18, { children: () => /* @__PURE__ */ jsx152(
17012
+ return /* @__PURE__ */ jsx151(Observer18, { children: () => /* @__PURE__ */ jsx151(
17036
17013
  TreeSelectField,
17037
17014
  {
17038
17015
  label,
@@ -17061,29 +17038,9 @@ function BoundTreeSelectField(props) {
17061
17038
  ) });
17062
17039
  }
17063
17040
 
17064
- // src/forms/FormHeading.tsx
17065
- import { jsx as jsx153 } from "@emotion/react/jsx-runtime";
17066
- function FormHeading(props) {
17067
- const { title, xss, isFirst = false, ...others } = props;
17068
- return /* @__PURE__ */ jsx153(
17069
- "h3",
17070
- {
17071
- css: {
17072
- ...Css.baseMd.$,
17073
- // Add space before the heading, but only if it's not first.
17074
- ...!isFirst && Css.mt4.$,
17075
- ...xss
17076
- },
17077
- ...others,
17078
- children: title
17079
- }
17080
- );
17081
- }
17082
- FormHeading.isFormHeading = true;
17083
-
17084
17041
  // src/forms/FormLines.tsx
17085
17042
  import { Children, cloneElement as cloneElement3 } from "react";
17086
- import { jsx as jsx154 } from "@emotion/react/jsx-runtime";
17043
+ import { jsx as jsx152 } from "@emotion/react/jsx-runtime";
17087
17044
  function FormLines(props) {
17088
17045
  const { inModal } = useModal();
17089
17046
  const {
@@ -17103,7 +17060,7 @@ function FormLines(props) {
17103
17060
  ..."labelLeftFieldWidth" in props ? { labelLeftFieldWidth } : {},
17104
17061
  ...width === "full" ? { fullWidth: true } : {}
17105
17062
  };
17106
- return /* @__PURE__ */ jsx154(PresentationProvider, { fieldProps: newFieldProps, children: /* @__PURE__ */ jsx154(
17063
+ return /* @__PURE__ */ jsx152(PresentationProvider, { fieldProps: newFieldProps, children: /* @__PURE__ */ jsx152(
17107
17064
  "div",
17108
17065
  {
17109
17066
  css: {
@@ -17125,7 +17082,7 @@ function FormLines(props) {
17125
17082
  ) });
17126
17083
  }
17127
17084
  function FormDivider() {
17128
- return /* @__PURE__ */ jsx154("div", { css: Css.hPx(1).my2.bgGray200.$ });
17085
+ return /* @__PURE__ */ jsx152("div", { css: Css.hPx(1).my2.bgGray200.$ });
17129
17086
  }
17130
17087
  function FieldGroup(props) {
17131
17088
  const { title, children, widths: widths2 = [] } = props;
@@ -17133,7 +17090,7 @@ function FieldGroup(props) {
17133
17090
  const width = widths2[i] || 1;
17134
17091
  return typeof width === `number` ? `${width}fr` : width;
17135
17092
  }).join(" ");
17136
- return /* @__PURE__ */ jsx154("div", { css: Css.dg.gap2.gtc(gtc).$, children });
17093
+ return /* @__PURE__ */ jsx152("div", { css: Css.dg.gap2.gtc(gtc).$, children });
17137
17094
  }
17138
17095
  var sizes = {
17139
17096
  full: "100%",
@@ -17142,29 +17099,206 @@ var sizes = {
17142
17099
  sm: "320px"
17143
17100
  };
17144
17101
 
17102
+ // src/forms/BoundForm.tsx
17103
+ import { jsx as jsx153 } from "@emotion/react/jsx-runtime";
17104
+ var reactNodePrefix = "reactNode";
17105
+ function BoundForm(props) {
17106
+ const { rows, formState } = props;
17107
+ const tid = useTestIds({}, "boundForm");
17108
+ return /* @__PURE__ */ jsx153("div", { ...tid, children: /* @__PURE__ */ jsx153(FormLines, { labelSuffix: { required: "*" }, width: "full", gap: 4, children: rows.map((row) => /* @__PURE__ */ jsx153(FormRow, { row, formState }, `fieldGroup-${Object.keys(row).join("-")}`)) }) });
17109
+ }
17110
+ function FormRow({ row, formState }) {
17111
+ const tid = useTestIds({}, "boundFormRow");
17112
+ const componentsWithConfig = useMemo38(() => {
17113
+ return safeEntries(row).map(([key, fieldFnOrCustomNode]) => {
17114
+ if (typeof fieldFnOrCustomNode === "function" && !isCustomReactNodeKey(key)) {
17115
+ const field = formState[key] ?? fail(`Field ${key.toString()} not found in formState`);
17116
+ const fieldFn = fieldFnOrCustomNode ?? fail(`Field function not defined for key ${key.toLocaleString()}`);
17117
+ const { component, minWidth } = fieldFn(field);
17118
+ return { component, key, minWidth };
17119
+ }
17120
+ return { component: fieldFnOrCustomNode, key };
17121
+ });
17122
+ }, [row, formState]);
17123
+ const isLoading = useComputed(() => formState.loading, [formState]);
17124
+ const itemFlexBasis = 100 / componentsWithConfig.length - 3;
17125
+ return /* @__PURE__ */ jsx153("div", { css: Css.df.fww.gap2.$, ...tid, children: componentsWithConfig.map(({ component, key, minWidth }) => /* @__PURE__ */ jsx153("div", { css: Css.mw(minWidth).fb(`${itemFlexBasis}%`).fg1.$, children: isLoading ? /* @__PURE__ */ jsx153(LoadingSkeleton, { size: "lg" }) : component }, key.toString())) });
17126
+ }
17127
+ function isCustomReactNodeKey(key) {
17128
+ return key.toString().startsWith(reactNodePrefix);
17129
+ }
17130
+ function boundSelectField(props) {
17131
+ return (field) => ({
17132
+ component: /* @__PURE__ */ jsx153(BoundSelectField, { field, ...props }),
17133
+ minWidth: "200px"
17134
+ });
17135
+ }
17136
+ function boundMultiSelectField(props) {
17137
+ return (field) => ({
17138
+ component: /* @__PURE__ */ jsx153(BoundMultiSelectField, { field, ...props }),
17139
+ minWidth: "200px"
17140
+ });
17141
+ }
17142
+ function boundMultilineSelectField(props) {
17143
+ return (field) => ({
17144
+ component: /* @__PURE__ */ jsx153(BoundMultiLineSelectField, { field, ...props }),
17145
+ minWidth: "200px"
17146
+ });
17147
+ }
17148
+ function boundTextField(props) {
17149
+ return (field) => ({
17150
+ component: /* @__PURE__ */ jsx153(BoundTextField, { field, ...props }),
17151
+ minWidth: "150px"
17152
+ });
17153
+ }
17154
+ function boundTextAreaField(props) {
17155
+ return (field) => ({
17156
+ component: /* @__PURE__ */ jsx153(BoundTextAreaField, { field, ...props }),
17157
+ minWidth: "200px"
17158
+ });
17159
+ }
17160
+ function boundNumberField(props) {
17161
+ return (field) => ({
17162
+ component: /* @__PURE__ */ jsx153(BoundNumberField, { field, ...props }),
17163
+ minWidth: "150px"
17164
+ });
17165
+ }
17166
+ function boundDateField(props) {
17167
+ return (field) => ({
17168
+ component: /* @__PURE__ */ jsx153(BoundDateField, { field, ...props }),
17169
+ minWidth: "150px"
17170
+ });
17171
+ }
17172
+ function boundDateRangeField(props) {
17173
+ return (field) => ({
17174
+ component: /* @__PURE__ */ jsx153(BoundDateRangeField, { field, ...props }),
17175
+ minWidth: "150px"
17176
+ });
17177
+ }
17178
+ function boundCheckboxField(props) {
17179
+ return (field) => ({
17180
+ component: /* @__PURE__ */ jsx153(BoundCheckboxField, { field, ...props }),
17181
+ minWidth: "min-content"
17182
+ });
17183
+ }
17184
+ function boundCheckboxGroupField(props) {
17185
+ return (field) => ({
17186
+ component: /* @__PURE__ */ jsx153(BoundCheckboxGroupField, { field, ...props }),
17187
+ minWidth: "200px"
17188
+ });
17189
+ }
17190
+ function boundIconCardField(props) {
17191
+ return (field) => ({
17192
+ component: /* @__PURE__ */ jsx153(BoundIconCardField, { field, ...props }),
17193
+ minWidth: "150px"
17194
+ });
17195
+ }
17196
+ function boundIconCardGroupField(props) {
17197
+ return (field) => ({
17198
+ component: /* @__PURE__ */ jsx153(BoundIconCardGroupField, { field, ...props }),
17199
+ minWidth: "100%"
17200
+ });
17201
+ }
17202
+ function boundRadioGroupField(props) {
17203
+ return (field) => ({
17204
+ component: /* @__PURE__ */ jsx153(BoundRadioGroupField, { field, ...props }),
17205
+ minWidth: "200px"
17206
+ });
17207
+ }
17208
+ function boundRichTextField(props) {
17209
+ return (field) => ({
17210
+ component: /* @__PURE__ */ jsx153(BoundRichTextField, { field, ...props }),
17211
+ minWidth: "200px"
17212
+ });
17213
+ }
17214
+ function boundSwitchField(props) {
17215
+ return (field) => ({
17216
+ component: /* @__PURE__ */ jsx153(BoundSwitchField, { field, labelStyle: "inline", ...props }),
17217
+ minWidth: "min-content"
17218
+ });
17219
+ }
17220
+ function boundToggleChipGroupField(props) {
17221
+ return (field) => ({
17222
+ component: /* @__PURE__ */ jsx153(BoundToggleChipGroupField, { field, ...props }),
17223
+ minWidth: "100%"
17224
+ });
17225
+ }
17226
+ function boundTreeSelectField(props) {
17227
+ return (field) => ({
17228
+ component: /* @__PURE__ */ jsx153(BoundTreeSelectField, { field, ...props }),
17229
+ minWidth: "200px"
17230
+ });
17231
+ }
17232
+
17233
+ // src/forms/BoundSelectAndTextField.tsx
17234
+ import { jsx as jsx154, jsxs as jsxs73 } from "@emotion/react/jsx-runtime";
17235
+ function BoundSelectAndTextField(props) {
17236
+ const { selectFieldProps, textFieldProps, compact = true } = props;
17237
+ const tid = useTestIds(props);
17238
+ return /* @__PURE__ */ jsxs73(CompoundField, { children: [
17239
+ /* @__PURE__ */ jsx154(
17240
+ BoundSelectField,
17241
+ {
17242
+ ...tid[defaultTestId(selectFieldProps.label ?? selectFieldProps.field.key)],
17243
+ ...selectFieldProps,
17244
+ sizeToContent: true,
17245
+ compact
17246
+ }
17247
+ ),
17248
+ /* @__PURE__ */ jsx154(
17249
+ BoundTextField,
17250
+ {
17251
+ ...tid[defaultTestId(textFieldProps.label ?? textFieldProps.field.key)],
17252
+ ...textFieldProps,
17253
+ compact
17254
+ }
17255
+ )
17256
+ ] });
17257
+ }
17258
+
17259
+ // src/forms/FormHeading.tsx
17260
+ import { jsx as jsx155 } from "@emotion/react/jsx-runtime";
17261
+ function FormHeading(props) {
17262
+ const { title, xss, isFirst = false, ...others } = props;
17263
+ return /* @__PURE__ */ jsx155(
17264
+ "h3",
17265
+ {
17266
+ css: {
17267
+ ...Css.baseMd.$,
17268
+ // Add space before the heading, but only if it's not first.
17269
+ ...!isFirst && Css.mt4.$,
17270
+ ...xss
17271
+ },
17272
+ ...others,
17273
+ children: title
17274
+ }
17275
+ );
17276
+ }
17277
+ FormHeading.isFormHeading = true;
17278
+
17145
17279
  // src/forms/StaticField.tsx
17146
17280
  import { useId as useId2 } from "@react-aria/utils";
17147
- import { jsx as jsx155, jsxs as jsxs74 } from "@emotion/react/jsx-runtime";
17281
+ import { jsx as jsx156, jsxs as jsxs74 } from "@emotion/react/jsx-runtime";
17148
17282
  function StaticField(props) {
17149
17283
  const { fieldProps } = usePresentationContext();
17150
17284
  const { label, labelStyle = fieldProps?.labelStyle ?? "above", value, children } = props;
17151
17285
  const tid = useTestIds(props, typeof label === "string" ? defaultTestId(label) : "staticField");
17152
17286
  const id = useId2();
17153
17287
  return /* @__PURE__ */ jsxs74("div", { css: Css.if(labelStyle === "left").df.jcsb.maxw100.$, ...tid.container, children: [
17154
- /* @__PURE__ */ jsx155("label", { css: Css.db.sm.gray700.mbPx(4).$, htmlFor: id, ...tid.label, children: label }),
17155
- /* @__PURE__ */ jsx155("div", { id, css: Css.smMd.gray900.df.aic.if(labelStyle === "left").w50.$, ...tid, children: value || children })
17288
+ /* @__PURE__ */ jsx156("label", { css: Css.db.sm.gray700.mbPx(4).$, htmlFor: id, ...tid.label, children: label }),
17289
+ /* @__PURE__ */ jsx156("div", { id, css: Css.smMd.gray900.df.aic.if(labelStyle === "left").w50.$, ...tid, children: value || children })
17156
17290
  ] });
17157
17291
  }
17158
17292
 
17159
17293
  // src/forms/SubmitButton.tsx
17160
- import { jsx as jsx156 } from "@emotion/react/jsx-runtime";
17294
+ import { jsx as jsx157 } from "@emotion/react/jsx-runtime";
17161
17295
  function SubmitButton(props) {
17162
17296
  const { form, disabled, onClick, label = "Submit", ...others } = props;
17163
17297
  if (typeof onClick === "string") {
17164
17298
  throw new Error("SubmitButton.onClick doesn't support strings yet");
17165
17299
  }
17166
17300
  const dirty = useComputed(() => form.dirty, [form]);
17167
- return /* @__PURE__ */ jsx156(
17301
+ return /* @__PURE__ */ jsx157(
17168
17302
  Button,
17169
17303
  {
17170
17304
  label,
@@ -17198,6 +17332,7 @@ export {
17198
17332
  BoundChipSelectField,
17199
17333
  BoundDateField,
17200
17334
  BoundDateRangeField,
17335
+ BoundForm,
17201
17336
  BoundIconCardField,
17202
17337
  BoundIconCardGroupField,
17203
17338
  BoundMultiLineSelectField,
@@ -17316,6 +17451,23 @@ export {
17316
17451
  applyRowFn,
17317
17452
  assignDefaultColumnIds,
17318
17453
  booleanFilter,
17454
+ boundCheckboxField,
17455
+ boundCheckboxGroupField,
17456
+ boundDateField,
17457
+ boundDateRangeField,
17458
+ boundIconCardField,
17459
+ boundIconCardGroupField,
17460
+ boundMultiSelectField,
17461
+ boundMultilineSelectField,
17462
+ boundNumberField,
17463
+ boundRadioGroupField,
17464
+ boundRichTextField,
17465
+ boundSelectField,
17466
+ boundSwitchField,
17467
+ boundTextAreaField,
17468
+ boundTextField,
17469
+ boundToggleChipGroupField,
17470
+ boundTreeSelectField,
17319
17471
  calcColumnSizes,
17320
17472
  cardStyle,
17321
17473
  checkboxFilter,