@dominevo/ui-library 0.1.6 → 0.1.7

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.cjs CHANGED
@@ -11471,6 +11471,112 @@ function sanitizeInfoHtml(html) {
11471
11471
  return root.innerHTML;
11472
11472
  }
11473
11473
  //#endregion
11474
+ //#region src/lib/form-grid.ts
11475
+ /**
11476
+ * form-grid — the ONE place a form's column grid and field spans are decided.
11477
+ *
11478
+ * Both schema renderers (ui-library `ConfigFormBuilder` and admin-ui
11479
+ * `FormBuilder`) and every span site in `config-form-field.tsx` call this
11480
+ * module, so a change to the tiers lands everywhere at once.
11481
+ *
11482
+ * The grid follows the width of its own container (`@container` on each
11483
+ * section), never the viewport: the same schema is drawn in a full page, a
11484
+ * split device pane and a dialog. A section's `columns` is a MAXIMUM; unset
11485
+ * means "as many tracks as the width earns":
11486
+ *
11487
+ * container width <480 480-879 880-1319 >=1320
11488
+ * unset 1 2 3 4
11489
+ * columns: 2 1 2 2 2
11490
+ * columns: 3 1 2 3 3
11491
+ * columns: 4 1 2 2 (to 1139) 4 from 1140
11492
+ * columns: 1 1 1 1 1 (capped at max-w-3xl)
11493
+ *
11494
+ * Class strings stay LITERAL in this file: the Tailwind scan
11495
+ * (`@source "../../ui-library/src"`) only emits classes it can read.
11496
+ */
11497
+ /** Container widths (px) where an automatic grid gains a track. */
11498
+ var FORM_GRID_TIERS = [
11499
+ 480,
11500
+ 880,
11501
+ 1320
11502
+ ];
11503
+ /** Gap between fields — shared so both renderers agree. */
11504
+ var FORM_GRID_GAP = "gap-x-3 gap-y-2.5";
11505
+ /** Vertical rhythm between the sections of one form. */
11506
+ var FORM_SECTIONS_GAP = "space-y-4";
11507
+ /** Section/field helper text: a readable measure, never the full line. */
11508
+ var FORM_DESCRIPTION_MEASURE = "max-w-prose";
11509
+ /**
11510
+ * Tracks the grid has at a container width. Mirrors {@link formGridClass}
11511
+ * exactly; the spec parses the classes and checks both agree.
11512
+ */
11513
+ function formTracks(columns, containerWidth) {
11514
+ if (columns === 1 || containerWidth < 480) return 1;
11515
+ if (columns === 2) return 2;
11516
+ if (columns === 3) return containerWidth >= 880 ? 3 : 2;
11517
+ if (columns === 4) return containerWidth >= 1140 ? 4 : 2;
11518
+ if (containerWidth >= 1320) return 4;
11519
+ return containerWidth >= 880 ? 3 : 2;
11520
+ }
11521
+ /**
11522
+ * The section grid's column classes. A one-column grid also gets
11523
+ * `max-w-3xl` so a lone column never stretches inputs across a wide page.
11524
+ */
11525
+ function formGridClass(columns) {
11526
+ if (columns === 1) return "grid-cols-1 max-w-3xl";
11527
+ if (columns === 2) return "grid-cols-1 @[480px]:grid-cols-2";
11528
+ if (columns === 3) return "grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3";
11529
+ if (columns === 4) return "grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4";
11530
+ return "grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3 @[1320px]:grid-cols-4";
11531
+ }
11532
+ /** Grid + gap, the full className of a section's field grid. */
11533
+ function formGridClassWithGap(columns) {
11534
+ return `grid ${formGridClass(columns)} ${FORM_GRID_GAP}`;
11535
+ }
11536
+ /**
11537
+ * A field's column span, clamped to the tracks its grid really has at each
11538
+ * tier. Below 480px the grid is one column and every span is `col-span-1`: a
11539
+ * raw `col-span-2` there forces an implicit auto-sized column that siblings
11540
+ * collapse into. `span >= 4` means "the whole row" at every tier.
11541
+ */
11542
+ function formSpanClass(span, columns) {
11543
+ if (span === void 0 || span <= 1 || columns === 1) return "col-span-1";
11544
+ if (span >= 4) return "col-span-full";
11545
+ if (columns === 2) return "col-span-1 @[480px]:col-span-2";
11546
+ if (columns === 3) return span === 2 ? "col-span-1 @[480px]:col-span-2" : "col-span-1 @[480px]:col-span-2 @[880px]:col-span-3";
11547
+ if (columns === 4) return span === 2 ? "col-span-1 @[480px]:col-span-2" : "col-span-1 @[480px]:col-span-2 @[1140px]:col-span-3";
11548
+ return span === 2 ? "col-span-1 @[480px]:col-span-2" : "col-span-1 @[480px]:col-span-2 @[880px]:col-span-3";
11549
+ }
11550
+ /** Field kinds that need the whole row (content is wide or self-framed). */
11551
+ var FULL_ROW_TYPES = new Set([
11552
+ "textarea",
11553
+ "tags",
11554
+ "multiselect",
11555
+ "device-multiselect",
11556
+ "node-multiselect",
11557
+ "notification-target-multiselect",
11558
+ "time-window",
11559
+ "widget",
11560
+ "group",
11561
+ "sub-tabs"
11562
+ ]);
11563
+ /**
11564
+ * The span a field gets: its own `span` when set (an explicit `1` on a
11565
+ * textarea wins), else the whole row for a full-row kind, else one track.
11566
+ */
11567
+ function fieldSpan(field) {
11568
+ if (field.span !== void 0) return field.span;
11569
+ return FULL_ROW_TYPES.has(field.type) ? 4 : void 0;
11570
+ }
11571
+ /**
11572
+ * The enclosing section's `columns`, so a field's span is clamped to its own
11573
+ * grid. Provided by each renderer around the section grid.
11574
+ */
11575
+ var FormColumnsContext = (0, react$1.createContext)(void 0);
11576
+ function useFormColumns() {
11577
+ return (0, react$1.useContext)(FormColumnsContext);
11578
+ }
11579
+ //#endregion
11474
11580
  //#region ../../node_modules/class-variance-authority/dist/index.mjs
11475
11581
  /**
11476
11582
  * Copyright 2022 Joe Bell. All rights reserved.
@@ -33576,6 +33682,8 @@ var contentVariants = cva("relative fixed left-1/2 top-1/2 -translate-x-1/2 -tra
33576
33682
  sm: "max-w-sm",
33577
33683
  md: "max-w-md",
33578
33684
  lg: "max-w-lg",
33685
+ /** Form dialogs (ItemFormDialog): wide enough for a two-column form grid (672px). */
33686
+ form: "max-w-2xl",
33579
33687
  /** Wide editors (scripts, long forms). */
33580
33688
  xl: "max-w-4xl",
33581
33689
  /** Full page: the dialog fills the viewport (picker modals over a long list). */
@@ -33626,6 +33734,11 @@ var contentVariants = cva("relative fixed left-1/2 top-1/2 -translate-x-1/2 -tra
33626
33734
  width: "lg",
33627
33735
  class: "md:w-[calc(100vw-2rem)] md:max-w-lg"
33628
33736
  },
33737
+ {
33738
+ placement: "sheet-on-mobile",
33739
+ width: "form",
33740
+ class: "md:w-[calc(100vw-2rem)] md:max-w-2xl"
33741
+ },
33629
33742
  {
33630
33743
  placement: "sheet-on-mobile",
33631
33744
  width: "xl",
@@ -36572,9 +36685,9 @@ function discoveryStatus(t, ready, settled, query, canType = true) {
36572
36685
  //#region src/composites/config-form-field.tsx
36573
36686
  var INPUT_CLASS = "w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none disabled:opacity-50 disabled:cursor-not-allowed";
36574
36687
  var LABEL_CLASS$1 = "block text-[11px] font-medium text-foreground mb-1 break-words";
36575
- var DESC_CLASS = "text-[10px] text-foreground-subtle mt-0.5 break-words";
36688
+ var DESC_CLASS = `text-[10px] text-foreground-subtle mt-0.5 break-words ${FORM_DESCRIPTION_MEASURE}`;
36576
36689
  function FieldWrapper({ label, description, required, span, htmlFor, children, translationFn }) {
36577
- const colSpanClass = span === 2 ? "col-span-1 @[480px]:col-span-2" : span === 3 ? "col-span-1 @[480px]:col-span-2 @[880px]:col-span-3" : span === 4 ? "col-span-1 @[480px]:col-span-2 @[1140px]:col-span-4" : "col-span-1";
36690
+ const colSpanClass = formSpanClass(span, useFormColumns());
36578
36691
  const resolvedLabel = resolveLabel(label, translationFn);
36579
36692
  const resolvedDescription = resolveLabel(description, translationFn);
36580
36693
  const hasLabel = resolvedLabel !== void 0 && resolvedLabel !== "";
@@ -36615,7 +36728,7 @@ function KeychainOr({ field, value, onChange, disabled, translationFn, multiline
36615
36728
  label: "label" in field ? field.label : void 0,
36616
36729
  description: "description" in field ? field.description : void 0,
36617
36730
  required: "required" in field ? field.required : void 0,
36618
- span: "span" in field ? field.span : void 0,
36731
+ span: fieldSpan(field),
36619
36732
  translationFn,
36620
36733
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SecretFieldControl, {
36621
36734
  field,
@@ -36631,7 +36744,7 @@ function TextField({ field, value, onChange, disabled, translationFn }) {
36631
36744
  label: field.label,
36632
36745
  description: field.description,
36633
36746
  required: field.required,
36634
- span: field.span,
36747
+ span: fieldSpan(field),
36635
36748
  translationFn,
36636
36749
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
36637
36750
  type: field.inputType ?? "text",
@@ -36666,7 +36779,7 @@ function NumberField({ field, value, onChange, disabled, translationFn }) {
36666
36779
  label: field.label,
36667
36780
  description: field.description,
36668
36781
  required: field.required,
36669
- span: field.span,
36782
+ span: fieldSpan(field),
36670
36783
  translationFn,
36671
36784
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
36672
36785
  className: "flex items-center gap-1",
@@ -36700,7 +36813,7 @@ function BooleanField({ field, value, onChange, disabled, translationFn }) {
36700
36813
  label: void 0,
36701
36814
  description: field.description,
36702
36815
  required: field.required,
36703
- span: field.span,
36816
+ span: fieldSpan(field),
36704
36817
  translationFn,
36705
36818
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
36706
36819
  className: "flex items-center gap-2 cursor-pointer select-none",
@@ -36726,7 +36839,7 @@ function BooleanField({ field, value, onChange, disabled, translationFn }) {
36726
36839
  label: void 0,
36727
36840
  description: field.description,
36728
36841
  required: field.required,
36729
- span: field.span,
36842
+ span: fieldSpan(field),
36730
36843
  translationFn,
36731
36844
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
36732
36845
  className: "flex items-center justify-between",
@@ -36778,7 +36891,7 @@ function SelectField({ field, values, value, onChange, disabled, translationFn }
36778
36891
  label: field.label,
36779
36892
  description: field.description,
36780
36893
  required: field.required,
36781
- span: field.span,
36894
+ span: fieldSpan(field),
36782
36895
  htmlFor: controlId,
36783
36896
  translationFn,
36784
36897
  children: field.discoverOptions !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConfigDiscoveredSelectControl, {
@@ -36802,7 +36915,7 @@ function InstanceSelectField({ field, value, onChange, disabled, translationFn }
36802
36915
  label: field.label,
36803
36916
  description: field.description,
36804
36917
  required: field.required,
36805
- span: field.span,
36918
+ span: fieldSpan(field),
36806
36919
  translationFn,
36807
36920
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConfigInstanceSelectControl, {
36808
36921
  field,
@@ -36818,7 +36931,7 @@ function TimezoneField({ field, value, onChange, disabled, translationFn }) {
36818
36931
  label: field.label,
36819
36932
  description: field.description,
36820
36933
  required: field.required,
36821
- span: field.span,
36934
+ span: fieldSpan(field),
36822
36935
  translationFn,
36823
36936
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TimezoneSelector, {
36824
36937
  value: typeof value === "string" ? value : "",
@@ -36832,7 +36945,7 @@ function DateTimeField({ field, value, onChange, disabled, translationFn }) {
36832
36945
  label: field.label,
36833
36946
  description: field.description,
36834
36947
  required: field.required,
36835
- span: field.span,
36948
+ span: fieldSpan(field),
36836
36949
  translationFn,
36837
36950
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
36838
36951
  type: "datetime-local",
@@ -36850,7 +36963,7 @@ function DurationField({ field, value, onChange, disabled, translationFn }) {
36850
36963
  label: field.label,
36851
36964
  description: field.description,
36852
36965
  required: field.required,
36853
- span: field.span,
36966
+ span: fieldSpan(field),
36854
36967
  translationFn,
36855
36968
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DurationInput, {
36856
36969
  value: stored,
@@ -36873,7 +36986,7 @@ function TimeWindowField({ field, value, onChange, disabled, translationFn }) {
36873
36986
  label: field.label,
36874
36987
  description: field.description,
36875
36988
  required: field.required,
36876
- span: field.span,
36989
+ span: fieldSpan(field),
36877
36990
  translationFn,
36878
36991
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TimeWindowInput, {
36879
36992
  value: current,
@@ -36898,7 +37011,7 @@ function MultiSelectField({ field, value, onChange, disabled, translationFn }) {
36898
37011
  label: field.label,
36899
37012
  description: field.description,
36900
37013
  required: field.required,
36901
- span: field.span,
37014
+ span: fieldSpan(field),
36902
37015
  translationFn,
36903
37016
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
36904
37017
  className: "flex flex-wrap gap-2",
@@ -36935,7 +37048,7 @@ function PasswordField({ field, value, onChange, disabled, translationFn }) {
36935
37048
  label: field.label,
36936
37049
  description: field.description,
36937
37050
  required: field.required,
36938
- span: field.span,
37051
+ span: fieldSpan(field),
36939
37052
  translationFn,
36940
37053
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PasswordInput, {
36941
37054
  "aria-label": field.label,
@@ -36957,7 +37070,7 @@ function TextAreaField({ field, value, onChange, disabled, translationFn }) {
36957
37070
  label: field.label,
36958
37071
  description: field.description,
36959
37072
  required: field.required,
36960
- span: field.span,
37073
+ span: fieldSpan(field),
36961
37074
  translationFn,
36962
37075
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
36963
37076
  className: "w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none disabled:opacity-50 disabled:cursor-not-allowed resize-y min-h-[60px]",
@@ -36987,7 +37100,7 @@ function SliderField({ field, value, onChange, disabled, translationFn }) {
36987
37100
  label: field.label,
36988
37101
  description: field.description,
36989
37102
  required: field.required,
36990
- span: field.span,
37103
+ span: fieldSpan(field),
36991
37104
  translationFn,
36992
37105
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
36993
37106
  className: "w-full rounded-lg border border-dashed border-border px-3 py-2 text-xs text-foreground-subtle hover:border-primary/40 hover:text-primary transition-colors text-left",
@@ -37008,7 +37121,7 @@ function SliderField({ field, value, onChange, disabled, translationFn }) {
37008
37121
  label: field.label,
37009
37122
  description: field.description,
37010
37123
  required: field.required,
37011
- span: field.span,
37124
+ span: fieldSpan(field),
37012
37125
  translationFn,
37013
37126
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
37014
37127
  className: "flex flex-wrap items-center gap-x-3 gap-y-2",
@@ -37103,7 +37216,7 @@ function TagsField({ field, value, onChange, disabled, translationFn }) {
37103
37216
  label: field.label,
37104
37217
  description: field.description,
37105
37218
  required: field.required,
37106
- span: field.span,
37219
+ span: fieldSpan(field),
37107
37220
  translationFn,
37108
37221
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OptionSelect, {
37109
37222
  mode: "multi",
@@ -37151,7 +37264,7 @@ function NodeSelectBody({ field, value, onChange, disabled, translationFn, lacks
37151
37264
  label: field.label,
37152
37265
  description: field.description,
37153
37266
  required: field.required,
37154
- span: field.span,
37267
+ span: fieldSpan(field),
37155
37268
  translationFn,
37156
37269
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Select, {
37157
37270
  className: "w-full px-3 py-2 text-sm bg-background border border-border rounded-lg text-foreground focus:outline-none focus:border-primary/50 disabled:opacity-50",
@@ -37183,7 +37296,7 @@ function NodeMultiSelectField({ field, value, onChange, disabled, translationFn
37183
37296
  label: field.label,
37184
37297
  description: field.description,
37185
37298
  required: field.required,
37186
- span: field.span,
37299
+ span: fieldSpan(field),
37187
37300
  translationFn,
37188
37301
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
37189
37302
  className: "flex flex-wrap gap-1.5",
@@ -37206,7 +37319,7 @@ function ColorField({ field, value, onChange, disabled, translationFn }) {
37206
37319
  label: field.label,
37207
37320
  description: field.description,
37208
37321
  required: field.required,
37209
- span: field.span,
37322
+ span: fieldSpan(field),
37210
37323
  translationFn,
37211
37324
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
37212
37325
  className: "flex items-center gap-2",
@@ -37243,7 +37356,7 @@ function IconField({ field, value, onChange, disabled, translationFn }) {
37243
37356
  label: field.label,
37244
37357
  description: field.description,
37245
37358
  required: field.required,
37246
- span: field.span,
37359
+ span: fieldSpan(field),
37247
37360
  translationFn,
37248
37361
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConfigIconFieldControl, {
37249
37362
  label: resolveLabel(field.label, translationFn) ?? field.label,
@@ -37293,7 +37406,7 @@ function ProbeField({ field, value, onChange, disabled, translationFn, onTestFie
37293
37406
  label: field.label,
37294
37407
  description: field.description,
37295
37408
  required: field.required,
37296
- span: field.span,
37409
+ span: fieldSpan(field),
37297
37410
  translationFn,
37298
37411
  children: [
37299
37412
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -37342,11 +37455,11 @@ function ProbeField({ field, value, onChange, disabled, translationFn, onTestFie
37342
37455
  function GroupField({ field, values, onChange, onChangeMany, disabled, translationFn, onTestField, onAction }) {
37343
37456
  const [collapsed, setCollapsed] = (0, react$1.useState)(field.defaultCollapsed ?? false);
37344
37457
  const isAccordion = field.style === "accordion";
37458
+ const columns = useFormColumns();
37345
37459
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
37346
- className: `${field.span === 2 ? "col-span-2" : field.span === 3 ? "col-span-3" : field.span === 4 ? "col-span-4" : "col-span-1"} min-w-0`,
37460
+ className: `${formSpanClass(fieldSpan(field), columns)} min-w-0`,
37347
37461
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
37348
37462
  className: "@container rounded-lg border border-border bg-surface/50 overflow-hidden",
37349
- style: { containerType: "inline-size" },
37350
37463
  children: [isAccordion ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
37351
37464
  type: "button",
37352
37465
  "aria-expanded": !collapsed,
@@ -37366,7 +37479,7 @@ function GroupField({ field, values, onChange, onChangeMany, disabled, translati
37366
37479
  children: resolveLabel(field.label, translationFn)
37367
37480
  })
37368
37481
  }), !collapsed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
37369
- className: "px-3 pb-3 grid grid-cols-1 @[480px]:grid-cols-2 gap-x-4 gap-y-3",
37482
+ className: `px-3 pb-3 ${formGridClassWithGap(columns)}`,
37370
37483
  children: field.fields.map((subField) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormField, {
37371
37484
  field: subField,
37372
37485
  values,
@@ -37383,7 +37496,8 @@ function GroupField({ field, values, onChange, onChangeMany, disabled, translati
37383
37496
  }
37384
37497
  function SubTabsField({ field, values, onChange, disabled, translationFn, onTestField, onAction }) {
37385
37498
  const [active, setActive] = (0, react$1.useState)(field.tabs[0]?.id ?? "");
37386
- const colSpanClass = field.span === 2 ? "col-span-2" : field.span === 3 ? "col-span-3" : field.span === 4 ? "col-span-4" : "col-span-1";
37499
+ const columns = useFormColumns();
37500
+ const colSpanClass = formSpanClass(fieldSpan(field), columns);
37387
37501
  if (field.tabs.length === 0) return null;
37388
37502
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
37389
37503
  className: `${colSpanClass} min-w-0`,
@@ -37392,7 +37506,6 @@ function SubTabsField({ field, values, onChange, disabled, translationFn, onTest
37392
37506
  children: resolveLabel(field.label, translationFn)
37393
37507
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
37394
37508
  className: "@container rounded-lg border border-border-subtle bg-surface-hover/40 overflow-hidden",
37395
- style: { containerType: "inline-size" },
37396
37509
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
37397
37510
  className: "flex flex-wrap gap-1 p-1.5 border-b border-border-subtle bg-surface/40",
37398
37511
  role: "tablist",
@@ -37414,7 +37527,7 @@ function SubTabsField({ field, values, onChange, disabled, translationFn, onTest
37414
37527
  if (t.id !== active) return null;
37415
37528
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
37416
37529
  role: "tabpanel",
37417
- className: "px-3 pb-3 pt-2 grid grid-cols-1 @[480px]:grid-cols-2 gap-x-4 gap-y-3",
37530
+ className: `px-3 pb-3 pt-2 ${formGridClassWithGap(columns)}`,
37418
37531
  children: t.fields.map((subField, idx) => {
37419
37532
  const stableKey = "key" in subField && typeof subField.key === "string" ? subField.key : `__${t.id}__${idx}`;
37420
37533
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormField, {
@@ -37434,7 +37547,7 @@ function SubTabsField({ field, values, onChange, disabled, translationFn, onTest
37434
37547
  }
37435
37548
  function SeparatorField({ span }) {
37436
37549
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
37437
- className: span === 2 ? "col-span-2" : span === 3 ? "col-span-3" : span === 4 ? "col-span-4" : "col-span-full",
37550
+ className: span === void 0 ? "col-span-full" : formSpanClass(span, useFormColumns()),
37438
37551
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hr", { className: "border-border" })
37439
37552
  });
37440
37553
  }
@@ -37687,18 +37800,21 @@ function EditableArrayField({ field, value, onChange, disabled, translationFn, o
37687
37800
  }, { count: minRows }) : t("uiLibrary.configFormField.removeRow", "Remove this row"),
37688
37801
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Minus, { className: "h-3 w-3" }), t("uiLibrary.configFormField.remove", "Remove")]
37689
37802
  })]
37690
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
37691
- className: "grid grid-cols-1 @[480px]:grid-cols-2 gap-x-3 gap-y-2 p-3",
37692
- children: field.itemFields.map((sub) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormField, {
37693
- field: sub,
37694
- values: row,
37695
- onChange: (k, v) => updateRow(idx, k, v),
37696
- disabled,
37697
- translationFn,
37698
- onTestField,
37699
- allFields: field.itemFields,
37700
- onAction
37701
- }, sub.key))
37803
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormColumnsContext.Provider, {
37804
+ value: 2,
37805
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
37806
+ className: `${formGridClassWithGap(2)} p-3`,
37807
+ children: field.itemFields.map((sub) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormField, {
37808
+ field: sub,
37809
+ values: row,
37810
+ onChange: (k, v) => updateRow(idx, k, v),
37811
+ disabled,
37812
+ translationFn,
37813
+ onTestField,
37814
+ allFields: field.itemFields,
37815
+ onAction
37816
+ }, sub.key))
37817
+ })
37702
37818
  })]
37703
37819
  }, rowReactKey(row, idx)))
37704
37820
  }),
@@ -37745,7 +37861,7 @@ function ButtonField({ field, disabled, onAction }) {
37745
37861
  label: field.label,
37746
37862
  description: field.description,
37747
37863
  required: field.required,
37748
- span: field.span,
37864
+ span: fieldSpan(field),
37749
37865
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
37750
37866
  onClick: handleClick,
37751
37867
  disabled: disabled || loading,
@@ -37835,7 +37951,7 @@ function AddonActionSelectField({ field, value, values, onChange, disabled, onAc
37835
37951
  label: field.label,
37836
37952
  description: field.description,
37837
37953
  required: field.required,
37838
- span: field.span,
37954
+ span: fieldSpan(field),
37839
37955
  children: missingParam ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
37840
37956
  className: "text-[11px] text-foreground-subtle italic",
37841
37957
  children: field.emptyParamsMessage ?? t("uiLibrary.configFormField.fillPrerequisites", "Fill the prerequisite fields above first.")
@@ -37947,7 +38063,7 @@ function AddonActionButtonField({ field, values, disabled, onAction, onChange, o
37947
38063
  label: field.label,
37948
38064
  description: field.description,
37949
38065
  required: field.required,
37950
- span: field.span,
38066
+ span: fieldSpan(field),
37951
38067
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
37952
38068
  className: "flex flex-col gap-1.5",
37953
38069
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
@@ -38008,7 +38124,7 @@ function DeviceActionButtonField({ field, values, disabled, onAction }) {
38008
38124
  label: field.label,
38009
38125
  description: field.description,
38010
38126
  required: field.required,
38011
- span: field.span,
38127
+ span: fieldSpan(field),
38012
38128
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
38013
38129
  className: "flex flex-col gap-1.5",
38014
38130
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
@@ -38028,7 +38144,7 @@ function WidgetField({ field }) {
38028
38144
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FieldWrapper, {
38029
38145
  label: void 0,
38030
38146
  description: void 0,
38031
- span: field.span,
38147
+ span: fieldSpan(field),
38032
38148
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WidgetSlot, {
38033
38149
  widgetId: field.widgetId,
38034
38150
  host: "device-tab",
@@ -38184,7 +38300,7 @@ function MultipleFieldWrapper({ field, values, onChange, disabled, translationFn
38184
38300
  label: field.label,
38185
38301
  description: field.description,
38186
38302
  required: min > 0 ? field.required : false,
38187
- span: field.span,
38303
+ span: fieldSpan(field),
38188
38304
  translationFn,
38189
38305
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
38190
38306
  className: "space-y-2",
@@ -38576,23 +38692,6 @@ function resolveLabel(value, t) {
38576
38692
  return value;
38577
38693
  }
38578
38694
  /**
38579
- * Container-query driven responsive grid. Each section is its own
38580
- * `@container` so the column count adapts to the SECTION's width
38581
- * (not the viewport) — important inside narrow hosts like the
38582
- * device-detail right column / ItemFormDialog. Behavior:
38583
- * columns=1 → always 1 col
38584
- * columns=2 (default) → 1 col below 480px container, 2 cols above
38585
- * columns=3 → 1 → 2 → 3 col at 480px / 880px
38586
- * columns=4 → 1 → 2 → 4 col at 480px / 1140px
38587
- */
38588
- function sectionGridClass(columns) {
38589
- const cols = columns ?? 2;
38590
- if (cols === 1) return "grid-cols-1";
38591
- if (cols === 3) return "grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3";
38592
- if (cols === 4) return "grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4";
38593
- return "grid-cols-1 @[480px]:grid-cols-2";
38594
- }
38595
- /**
38596
38695
  * The sections worth drawing for these values: a section whose every field is hidden by its
38597
38696
  * `showWhen` (a provider's section while another provider is selected) would be a bare header, so
38598
38697
  * it is left out. A section declared with no fields at all is the author's choice and stays.
@@ -38603,10 +38702,9 @@ function visibleSections(allFields, schema, values) {
38603
38702
  function SectionCard$1({ section, allFields, values, onChange, disabled, translationFn, onTestField, probeResults, onAction, onChangeMany }) {
38604
38703
  const [collapsed, setCollapsed] = (0, react$1.useState)(section.defaultCollapsed ?? false);
38605
38704
  const isAccordion = section.style === "accordion";
38606
- const gridClass = sectionGridClass(section.columns);
38705
+ const gridClass = formGridClassWithGap(section.columns);
38607
38706
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
38608
38707
  className: "@container rounded-lg border border-border bg-surface p-3",
38609
- style: { containerType: "inline-size" },
38610
38708
  children: [isAccordion ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
38611
38709
  type: "button",
38612
38710
  "aria-expanded": !collapsed,
@@ -38616,7 +38714,7 @@ function SectionCard$1({ section, allFields, values, onChange, disabled, transla
38616
38714
  className: "text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",
38617
38715
  children: resolveLabel(section.title, translationFn)
38618
38716
  }), section.description && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
38619
- className: "text-[10px] text-foreground-subtle mt-0.5",
38717
+ className: `text-[10px] text-foreground-subtle mt-0.5 max-w-prose`,
38620
38718
  children: resolveLabel(section.description, translationFn)
38621
38719
  })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DisclosureChevron, {
38622
38720
  expanded: !collapsed,
@@ -38628,23 +38726,26 @@ function SectionCard$1({ section, allFields, values, onChange, disabled, transla
38628
38726
  className: "text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",
38629
38727
  children: resolveLabel(section.title, translationFn)
38630
38728
  }), section.description && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
38631
- className: "text-[10px] text-foreground-subtle mt-0.5",
38729
+ className: `text-[10px] text-foreground-subtle mt-0.5 max-w-prose`,
38632
38730
  children: resolveLabel(section.description, translationFn)
38633
38731
  })] })
38634
- }), !collapsed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
38635
- className: `grid ${gridClass} gap-x-3 gap-y-2.5`,
38636
- children: section.fields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormField, {
38637
- field,
38638
- allFields,
38639
- values,
38640
- onChange,
38641
- disabled,
38642
- translationFn,
38643
- onTestField,
38644
- externalProbe: probeResults?.[field.key],
38645
- onAction,
38646
- onChangeMany
38647
- }, field.key))
38732
+ }), !collapsed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormColumnsContext.Provider, {
38733
+ value: section.columns,
38734
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
38735
+ className: gridClass,
38736
+ children: section.fields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormField, {
38737
+ field,
38738
+ allFields,
38739
+ values,
38740
+ onChange,
38741
+ disabled,
38742
+ translationFn,
38743
+ onTestField,
38744
+ externalProbe: probeResults?.[field.key],
38745
+ onAction,
38746
+ onChangeMany
38747
+ }, field.key))
38748
+ })
38648
38749
  })]
38649
38750
  });
38650
38751
  }
@@ -38667,29 +38768,31 @@ function ConfigFormBuilder({ schema, values, onChange, disabled, translationFn,
38667
38768
  };
38668
38769
  const allFields = schema.sections.flatMap((section) => section.fields);
38669
38770
  if (bare) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
38670
- className: "space-y-4",
38771
+ className: FORM_SECTIONS_GAP,
38671
38772
  children: visibleSections(allFields, schema, values).map((section) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
38672
38773
  className: "@container",
38673
- style: { containerType: "inline-size" },
38674
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
38675
- className: `grid ${sectionGridClass(section.columns)} gap-x-3 gap-y-2.5`,
38676
- children: section.fields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormField, {
38677
- field,
38678
- allFields,
38679
- values,
38680
- onChange: handleFieldChange,
38681
- disabled,
38682
- translationFn,
38683
- onTestField,
38684
- externalProbe: probeResults?.[field.key],
38685
- onAction,
38686
- onChangeMany: handleChangeMany
38687
- }, field.key))
38774
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormColumnsContext.Provider, {
38775
+ value: section.columns,
38776
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
38777
+ className: formGridClassWithGap(section.columns),
38778
+ children: section.fields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormField, {
38779
+ field,
38780
+ allFields,
38781
+ values,
38782
+ onChange: handleFieldChange,
38783
+ disabled,
38784
+ translationFn,
38785
+ onTestField,
38786
+ externalProbe: probeResults?.[field.key],
38787
+ onAction,
38788
+ onChangeMany: handleChangeMany
38789
+ }, field.key))
38790
+ })
38688
38791
  })
38689
38792
  }, section.id))
38690
38793
  });
38691
38794
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
38692
- className: "space-y-4",
38795
+ className: FORM_SECTIONS_GAP,
38693
38796
  children: visibleSections(allFields, schema, values).map((section) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SectionCard$1, {
38694
38797
  section,
38695
38798
  allFields,
@@ -45742,6 +45845,27 @@ function SettingRow({ label, children, actions, elements = "plain", className, v
45742
45845
  })]
45743
45846
  });
45744
45847
  }
45848
+ /**
45849
+ * A group of independent `SettingRow`s that uses the width it is given.
45850
+ *
45851
+ * One column in a narrow card; from an 880px container the rows flow into two
45852
+ * label/value columns, so a settings card on a wide window is not a narrow
45853
+ * column hugging the left edge. The track count follows the CONTAINER, not the
45854
+ * viewport, like the schema form grid (`lib/form-grid.ts`).
45855
+ *
45856
+ * Only group rows that do not depend on each other: a chain (source -> sensor
45857
+ * -> thresholds) reads top to bottom and stays a plain stack. A row that must
45858
+ * take the whole line passes `className="@[880px]:col-span-2"`.
45859
+ */
45860
+ function SettingRows({ children, className }) {
45861
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
45862
+ className: "@container",
45863
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
45864
+ className: cn("grid grid-cols-1 gap-x-10 @[880px]:grid-cols-2", className),
45865
+ children
45866
+ })
45867
+ });
45868
+ }
45745
45869
  //#endregion
45746
45870
  //#region src/composites/key-value-list.tsx
45747
45871
  /**
@@ -97161,7 +97285,7 @@ function SectionToolbar({ start, end, className, testId }) {
97161
97285
  }
97162
97286
  //#endregion
97163
97287
  //#region src/composites/item-form-dialog.tsx
97164
- function ItemFormDialog({ open, onClose, title, icon: Icon, error, width = "lg", children, beforeBody, footer, testId, fill = false }) {
97288
+ function ItemFormDialog({ open, onClose, title, icon: Icon, error, width = "form", children, beforeBody, footer, testId, fill = false }) {
97165
97289
  if (!open) return null;
97166
97290
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Dialog, {
97167
97291
  open: true,
@@ -104914,7 +105038,7 @@ function TaggedDataTable({ section, rows, columns, getTags, searchText, searchLa
104914
105038
  }
104915
105039
  //#endregion
104916
105040
  //#region src/ui-library-version.ts
104917
- var uiLibraryVersion = "0.1.6";
105041
+ var uiLibraryVersion = "0.1.7";
104918
105042
  //#endregion
104919
105043
  //#region src/hooks/use-account-unit-preferences.ts
104920
105044
  /**
@@ -106378,7 +106502,11 @@ exports.FILL = FILL;
106378
106502
  exports.FLEET_LIST_GC_TIME_MS = FLEET_LIST_GC_TIME_MS;
106379
106503
  exports.FLEET_LIST_QUERY_KEY = FLEET_LIST_QUERY_KEY;
106380
106504
  exports.FLEET_LIST_STALE_TIME_MS = FLEET_LIST_STALE_TIME_MS;
106505
+ exports.FORM_DESCRIPTION_MEASURE = FORM_DESCRIPTION_MEASURE;
106506
+ exports.FORM_GRID_GAP = FORM_GRID_GAP;
106507
+ exports.FORM_GRID_TIERS = FORM_GRID_TIERS;
106381
106508
  exports.FORM_OPEN_ROUTER_STATE = FORM_OPEN_ROUTER_STATE;
106509
+ exports.FORM_SECTIONS_GAP = FORM_SECTIONS_GAP;
106382
106510
  exports.FOUNTAIN_LOW_PERCENT = FOUNTAIN_LOW_PERCENT;
106383
106511
  exports.Fan = Fan;
106384
106512
  exports.FanCard = FanCard;
@@ -106396,6 +106524,7 @@ exports.FloatingEventStream = FloatingEventStream;
106396
106524
  exports.FloatingLogStream = FloatingLogStream;
106397
106525
  exports.FloatingPanel = FloatingPanel;
106398
106526
  exports.Footprints = Footprints;
106527
+ exports.FormColumnsContext = FormColumnsContext;
106399
106528
  exports.FormField = FormField$1;
106400
106529
  exports.FormSaveBar = FormSaveBar;
106401
106530
  exports.Funnel = Funnel;
@@ -106771,6 +106900,7 @@ exports.SensorValueAtom = SensorValueAtom;
106771
106900
  exports.Separator = Separator;
106772
106901
  exports.Server = Server;
106773
106902
  exports.SettingRow = SettingRow;
106903
+ exports.SettingRows = SettingRows;
106774
106904
  exports.Settings = Settings;
106775
106905
  exports.Settings2 = Settings2;
106776
106906
  exports.Share2 = Share2;
@@ -107159,6 +107289,7 @@ exports.fanPresetChoice = fanPresetChoice;
107159
107289
  exports.fanPresetFailure = fanPresetFailure;
107160
107290
  exports.fanSliceModel = fanSliceModel;
107161
107291
  exports.fieldAccepts = fieldAccepts;
107292
+ exports.fieldSpan = fieldSpan;
107162
107293
  exports.filterByTags = filterByTags;
107163
107294
  exports.filterDataTableRows = filterDataTableRows;
107164
107295
  exports.filterDeviceOptions = filterDeviceOptions;
@@ -107174,6 +107305,10 @@ exports.flattenPickerRows = flattenPickerRows;
107174
107305
  exports.fleetViewOf = fleetViewOf;
107175
107306
  exports.foldDeviceName = foldDeviceName;
107176
107307
  exports.followTagRename = followTagRename;
107308
+ exports.formGridClass = formGridClass;
107309
+ exports.formGridClassWithGap = formGridClassWithGap;
107310
+ exports.formSpanClass = formSpanClass;
107311
+ exports.formTracks = formTracks;
107177
107312
  exports.formatChartBytes = formatChartBytes;
107178
107313
  exports.formatChartNumber = formatChartNumber;
107179
107314
  exports.formatChartValue = formatChartValue;
@@ -108156,6 +108291,7 @@ exports.useFanPresetsGetPresets = useFanPresetsGetPresets;
108156
108291
  exports.useFanPresetsSetPresets = useFanPresetsSetPresets;
108157
108292
  exports.useFeatureProbeGetStatus = useFeatureProbeGetStatus;
108158
108293
  exports.useFloodGetStatus = useFloodGetStatus;
108294
+ exports.useFormColumns = useFormColumns;
108159
108295
  exports.useGasGetStatus = useGasGetStatus;
108160
108296
  exports.useGroupActiveGetStatus = useGroupActiveGetStatus;
108161
108297
  exports.useGroupCommandsGetStatus = useGroupCommandsGetStatus;