@valbuild/ui 0.46.0 → 0.47.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.
@@ -72891,86 +72891,88 @@ function ImageField({
72891
72891
  }
72892
72892
  }, [hotspot, defaultValue]);
72893
72893
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(FieldContainer, { children: [
72894
- /* @__PURE__ */ jsxRuntimeExports.jsx(
72895
- "div",
72896
- {
72897
- className: "flex flex-col max-w-4xl p-2 border border-b-0 rounded-sm rounded-b-none gap-y-4 bg-background text-foreground border-input",
72898
- children: data || url ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [
72899
- hotspot && /* @__PURE__ */ jsxRuntimeExports.jsx(
72900
- "div",
72901
- {
72902
- className: "rounded-full h-[12px] w-[12px] bg-background mix-blend-difference border-accent border-2 absolute pointer-events-none",
72903
- style: {
72904
- top: `${hotspot.y * 100}%`,
72905
- left: `${hotspot.x * 100}%`
72906
- }
72907
- }
72908
- ),
72909
- /* @__PURE__ */ jsxRuntimeExports.jsx(
72910
- "img",
72911
- {
72912
- src: (data == null ? void 0 : data.src) || url,
72913
- draggable: false,
72914
- className: "w-full",
72915
- style: {
72916
- cursor: "crosshair"
72917
- },
72918
- onClick: (ev) => {
72919
- const { width, height, left, top } = ev.currentTarget.getBoundingClientRect();
72920
- const hotspotX = (ev.clientX - 6 - left) / width;
72921
- const hotspotY = (ev.clientY - 6 - top) / height;
72922
- setHotspot({
72923
- x: hotspotX,
72924
- y: hotspotY,
72925
- width: 1,
72926
- height: 1
72927
- });
72928
- }
72929
- }
72930
- )
72931
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Select image below" })
72932
- },
72933
- path
72934
- ),
72935
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full p-4 border border-t-0 rounded-b-sm bg-background border-input", children: [
72894
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-fit", children: [
72936
72895
  /* @__PURE__ */ jsxRuntimeExports.jsx(
72937
- "label",
72896
+ "div",
72938
72897
  {
72939
- htmlFor: `img_input:${path}`,
72940
- className: "block w-full px-1 py-2 text-sm text-center rounded-md cursor-pointer bg-primary text-background",
72941
- children: "Update"
72942
- }
72898
+ className: "flex flex-col justify-start p-2 border border-b-0 rounded-sm rounded-b-none gap-y-4 bg-background text-foreground border-input",
72899
+ children: data || url ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [
72900
+ hotspot && /* @__PURE__ */ jsxRuntimeExports.jsx(
72901
+ "div",
72902
+ {
72903
+ className: "rounded-full h-[12px] w-[12px] bg-background mix-blend-difference border-accent border-2 absolute pointer-events-none",
72904
+ style: {
72905
+ top: `${hotspot.y * 100}%`,
72906
+ left: `${hotspot.x * 100}%`
72907
+ }
72908
+ }
72909
+ ),
72910
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
72911
+ "img",
72912
+ {
72913
+ src: (data == null ? void 0 : data.src) || url,
72914
+ draggable: false,
72915
+ className: "object-contain w-full max-h-[500px]",
72916
+ style: {
72917
+ cursor: "crosshair"
72918
+ },
72919
+ onClick: (ev) => {
72920
+ const { width, height, left, top } = ev.currentTarget.getBoundingClientRect();
72921
+ const hotspotX = (ev.clientX - 6 - left) / width;
72922
+ const hotspotY = (ev.clientY - 6 - top) / height;
72923
+ setHotspot({
72924
+ x: hotspotX,
72925
+ y: hotspotY,
72926
+ width: 1,
72927
+ height: 1
72928
+ });
72929
+ }
72930
+ }
72931
+ )
72932
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Select image below" })
72933
+ },
72934
+ path
72943
72935
  ),
72944
- /* @__PURE__ */ jsxRuntimeExports.jsx(
72945
- "input",
72946
- {
72947
- hidden: true,
72948
- id: `img_input:${path}`,
72949
- type: "file",
72950
- onChange: (ev) => {
72951
- readImage(ev).then((res) => {
72952
- setData({ src: res.src, filename: res.filename });
72953
- if (res.width && res.height && res.mimeType) {
72954
- setMetadata({
72955
- sha256: res.sha256,
72956
- width: res.width,
72957
- height: res.height,
72958
- mimeType: res.mimeType,
72959
- hotspot
72960
- });
72961
- } else {
72962
- setMetadata(void 0);
72936
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 border border-t-0 rounded-b-sm bg-background border-input", children: [
72937
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
72938
+ "label",
72939
+ {
72940
+ htmlFor: `img_input:${path}`,
72941
+ className: "block px-1 py-2 text-sm text-center rounded-md cursor-pointer bg-primary text-background",
72942
+ children: "Update"
72943
+ }
72944
+ ),
72945
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
72946
+ "input",
72947
+ {
72948
+ hidden: true,
72949
+ id: `img_input:${path}`,
72950
+ type: "file",
72951
+ onChange: (ev) => {
72952
+ readImage(ev).then((res) => {
72953
+ setData({ src: res.src, filename: res.filename });
72954
+ if (res.width && res.height && res.mimeType) {
72955
+ setMetadata({
72956
+ sha256: res.sha256,
72957
+ width: res.width,
72958
+ height: res.height,
72959
+ mimeType: res.mimeType,
72960
+ hotspot
72961
+ });
72962
+ } else {
72963
+ setMetadata(void 0);
72964
+ setHotspot(void 0);
72965
+ }
72966
+ }).catch((err2) => {
72967
+ console.error(err2.message);
72968
+ setData(null);
72963
72969
  setHotspot(void 0);
72964
- }
72965
- }).catch((err2) => {
72966
- console.error(err2.message);
72967
- setData(null);
72968
- setHotspot(void 0);
72969
- setMetadata(void 0);
72970
- });
72970
+ setMetadata(void 0);
72971
+ });
72972
+ }
72971
72973
  }
72972
- }
72973
- )
72974
+ )
72975
+ ] })
72974
72976
  ] }),
72975
72977
  onSubmit && /* @__PURE__ */ jsxRuntimeExports.jsx(
72976
72978
  SubmitButton,
@@ -73326,10 +73328,13 @@ function StringField({
73326
73328
  ] });
73327
73329
  }
73328
73330
  function InlineValidationErrors({ errors }) {
73329
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-y-1 p-2 rounded-md text-sm text-destructive-foreground bg-destructive", children: errors.map((error, i) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: error.message }, i)) });
73331
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col p-2 text-sm rounded-md gap-y-1 text-destructive-foreground bg-destructive", children: errors.map((error, i) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: error.message }, i)) });
73330
73332
  }
73331
- function FieldContainer({ children }) {
73332
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative p-4", children });
73333
+ function FieldContainer({
73334
+ children,
73335
+ className: className2
73336
+ }) {
73337
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: classNames("relative max-w-lg px-4 pt-4", className2), children });
73333
73338
  }
73334
73339
  function SubmitButton({
73335
73340
  loading,
@@ -73339,9 +73344,10 @@ function SubmitButton({
73339
73344
  }) {
73340
73345
  const { session } = useValOverlayContext();
73341
73346
  const isProxy = session.status === "success" && session.data.mode === "proxy";
73342
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sticky bottom-0 m-4 ml-0", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between w-full gap-2 py-2 text-sm", children: [
73343
- validationErrors ? /* @__PURE__ */ jsxRuntimeExports.jsx(InlineValidationErrors, { errors: validationErrors || [] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", {}),
73344
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { disabled: loading || !enabled, onClick, children: loading ? isProxy ? "Staging..." : "Saving..." : isProxy ? "Stage" : "Save" })
73347
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sticky bottom-0 m-4 mt-2 ml-0", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-start w-full gap-2 text-sm", children: [
73348
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { disabled: loading || !enabled, onClick, children: loading ? isProxy ? "Staging..." : "Saving..." : isProxy ? "Stage" : "Save" }),
73349
+ " ",
73350
+ validationErrors ? /* @__PURE__ */ jsxRuntimeExports.jsx(InlineValidationErrors, { errors: validationErrors || [] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", {})
73345
73351
  ] }) });
73346
73352
  }
73347
73353
  const Logo = ({ className: className2 }) => {
@@ -77267,10 +77273,18 @@ Showing stack trace of: 1. ${fatalErrors[0].message}`;
77267
77273
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronLeft, {})
77268
77274
  }
77269
77275
  ),
77270
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: selectedPath || "/" }) })
77276
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
77277
+ "div",
77278
+ {
77279
+ className: "truncate max-w-[300px] text-left",
77280
+ dir: "rtl",
77281
+ title: selectedPath,
77282
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: selectedPath || "/" })
77283
+ }
77284
+ )
77271
77285
  ] }),
77272
77286
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4", children: [
77273
- error && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 text-lg bg-destructive text-destructive-foreground max-w-xl", children: [
77287
+ error && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "max-w-xl p-4 text-lg bg-destructive text-destructive-foreground", children: [
77274
77288
  "ERROR: ",
77275
77289
  error
77276
77290
  ] }),
@@ -77390,7 +77404,15 @@ function AnyVal({
77390
77404
  ] });
77391
77405
  }
77392
77406
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
77393
- field ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-left", children: field }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path }),
77407
+ field ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-left", children: field }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
77408
+ "div",
77409
+ {
77410
+ className: "truncate max-w-[300px] text-left",
77411
+ title: path,
77412
+ dir: "rtl",
77413
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path })
77414
+ }
77415
+ ),
77394
77416
  /* @__PURE__ */ jsxRuntimeExports.jsx(
77395
77417
  ValList,
77396
77418
  {
@@ -77417,7 +77439,15 @@ function AnyVal({
77417
77439
  ] });
77418
77440
  }
77419
77441
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
77420
- field ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-left", children: field }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path }),
77442
+ field ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-left", children: field }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
77443
+ "div",
77444
+ {
77445
+ className: "truncate max-w-[300px] text-left",
77446
+ title: path,
77447
+ dir: "rtl",
77448
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path })
77449
+ }
77450
+ ),
77421
77451
  /* @__PURE__ */ jsxRuntimeExports.jsx(
77422
77452
  ValRecord,
77423
77453
  {
@@ -77433,6 +77463,7 @@ function AnyVal({
77433
77463
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
77434
77464
  ValTaggedUnion,
77435
77465
  {
77466
+ field,
77436
77467
  tag: schema.key,
77437
77468
  source,
77438
77469
  path,
@@ -77447,7 +77478,15 @@ function AnyVal({
77447
77478
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
77448
77479
  }
77449
77480
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "py-2 gap-y-4", children: [
77450
- field ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-left", children: field }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path }),
77481
+ field ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-left", children: field }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
77482
+ "div",
77483
+ {
77484
+ className: "truncate max-w-[300px] text-left",
77485
+ title: path,
77486
+ dir: "rtl",
77487
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path })
77488
+ }
77489
+ ),
77451
77490
  /* @__PURE__ */ jsxRuntimeExports.jsx(
77452
77491
  ValFormField,
77453
77492
  {
@@ -77462,6 +77501,7 @@ function AnyVal({
77462
77501
  }
77463
77502
  function ValTaggedUnion({
77464
77503
  tag,
77504
+ field,
77465
77505
  path,
77466
77506
  source,
77467
77507
  schema,
@@ -77499,6 +77539,8 @@ function ValTaggedUnion({
77499
77539
  });
77500
77540
  if (sourceKey && typeof sourceKey === "string" && unionSchema) {
77501
77541
  setCurrent({ source, schema: unionSchema });
77542
+ } else if (unionSchema) {
77543
+ setCurrent({ schema: unionSchema });
77502
77544
  } else {
77503
77545
  console.error(
77504
77546
  "Could not find source or schema of key",
@@ -77509,22 +77551,32 @@ function ValTaggedUnion({
77509
77551
  setCurrent(null);
77510
77552
  }
77511
77553
  }
77512
- }, [currentKey, source, schema, keys]);
77554
+ }, [currentKey, source, tag, schema, keys]);
77513
77555
  if (keys.length !== schema.items.length) {
77514
77556
  console.warn("Not all items have tag:", tag);
77515
77557
  }
77516
77558
  const loading = false;
77559
+ const onSubmit = initOnSubmit(path);
77517
77560
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
77518
- "div",
77561
+ FieldContainer,
77519
77562
  {
77520
- className: classNames("flex flex-col gap-y-8", {
77563
+ className: classNames("flex flex-col gap-y-4", {
77521
77564
  "border-l-2 border-border pl-6": !top
77522
77565
  }),
77523
77566
  children: [
77567
+ field ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-left", children: field }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
77568
+ "div",
77569
+ {
77570
+ className: "truncate max-w-[300px] text-left",
77571
+ title: path,
77572
+ dir: "rtl",
77573
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path })
77574
+ }
77575
+ ),
77524
77576
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
77525
77577
  Select,
77526
77578
  {
77527
- defaultValue: currentKey ?? void 0,
77579
+ value: currentKey ?? void 0,
77528
77580
  disabled: loading,
77529
77581
  onValueChange: (key) => {
77530
77582
  setCurrentKey(key);
@@ -77535,11 +77587,19 @@ function ValTaggedUnion({
77535
77587
  ]
77536
77588
  }
77537
77589
  ),
77590
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
77591
+ SubmitButton,
77592
+ {
77593
+ loading,
77594
+ enabled: false,
77595
+ onClick: () => onSubmit(async () => [])
77596
+ }
77597
+ ),
77538
77598
  current && /* @__PURE__ */ jsxRuntimeExports.jsx(
77539
77599
  AnyVal,
77540
77600
  {
77541
77601
  path,
77542
- source: current.source,
77602
+ source: current.source ?? null,
77543
77603
  schema: current.schema,
77544
77604
  setSelectedPath,
77545
77605
  initOnSubmit,
@@ -77562,7 +77622,7 @@ function ValObject({
77562
77622
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
77563
77623
  "div",
77564
77624
  {
77565
- className: classNames("flex flex-col gap-y-8", {
77625
+ className: classNames("flex flex-col gap-y-1", {
77566
77626
  "border-l-2 border-border pl-6": !top
77567
77627
  }),
77568
77628
  children: Object.entries(schema.items).map(([key, property]) => {
@@ -77655,7 +77715,7 @@ function ValList({
77655
77715
  setSelectedPath
77656
77716
  }) {
77657
77717
  const navigate = useNavigate();
77658
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-4 p-2", children: source.map((item, index2) => {
77718
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(FieldContainer, { className: "flex flex-col gap-4 p-2 pb-8", children: source.map((item, index2) => {
77659
77719
  const subPath = createValPathOfItem(path, index2);
77660
77720
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
77661
77721
  "button",
@@ -77894,9 +77954,10 @@ function ValOptional({
77894
77954
  field
77895
77955
  }) {
77896
77956
  const [enable, setEnable] = reactExports.useState(source !== null);
77957
+ const { editMode } = useValOverlayContext();
77897
77958
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-y-2", children: [
77898
77959
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-start gap-x-4", children: [
77899
- /* @__PURE__ */ jsxRuntimeExports.jsx(
77960
+ editMode === "full" && /* @__PURE__ */ jsxRuntimeExports.jsx(
77900
77961
  Switch,
77901
77962
  {
77902
77963
  checked: enable,
@@ -77905,7 +77966,15 @@ function ValOptional({
77905
77966
  }
77906
77967
  }
77907
77968
  ),
77908
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: field ? field : /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path }) })
77969
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
77970
+ "div",
77971
+ {
77972
+ className: "truncate max-w-[300px] text-left",
77973
+ title: path,
77974
+ dir: "rtl",
77975
+ children: field ? field : /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path })
77976
+ }
77977
+ )
77909
77978
  ] }),
77910
77979
  enable && /* @__PURE__ */ jsxRuntimeExports.jsx(
77911
77980
  ValDefaultOf,
@@ -78004,7 +78073,14 @@ function PathTree({
78004
78073
  const selectedModuleId = selectedPath && Internal.splitModuleIdAndModulePath(selectedPath)[0];
78005
78074
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col w-full py-2 text-xs", children: Object.entries(tree).map(([dir, files]) => {
78006
78075
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-4 py-2", children: [
78007
- dir && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-bold", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: dir }) }),
78076
+ dir && /* @__PURE__ */ jsxRuntimeExports.jsx(
78077
+ "div",
78078
+ {
78079
+ className: "font-bold truncate max-w-[300px] text-left",
78080
+ title: dir,
78081
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: dir })
78082
+ }
78083
+ ),
78008
78084
  /* @__PURE__ */ jsxRuntimeExports.jsx(
78009
78085
  "div",
78010
78086
  {