@valbuild/ui 0.46.0 → 0.46.1

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]",
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,7 @@ 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("div", { className: "truncate max-w-[300px]", title: path, dir: "rtl", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path }) }),
77394
77408
  /* @__PURE__ */ jsxRuntimeExports.jsx(
77395
77409
  ValList,
77396
77410
  {
@@ -77417,7 +77431,7 @@ function AnyVal({
77417
77431
  ] });
77418
77432
  }
77419
77433
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
77420
- field ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-left", children: field }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path }),
77434
+ field ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-left", children: field }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "truncate max-w-[300px]", title: path, dir: "rtl", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path }) }),
77421
77435
  /* @__PURE__ */ jsxRuntimeExports.jsx(
77422
77436
  ValRecord,
77423
77437
  {
@@ -77433,6 +77447,7 @@ function AnyVal({
77433
77447
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
77434
77448
  ValTaggedUnion,
77435
77449
  {
77450
+ field,
77436
77451
  tag: schema.key,
77437
77452
  source,
77438
77453
  path,
@@ -77447,7 +77462,7 @@ function AnyVal({
77447
77462
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
77448
77463
  }
77449
77464
  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 }),
77465
+ field ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-left", children: field }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "truncate max-w-[300px]", title: path, dir: "rtl", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path }) }),
77451
77466
  /* @__PURE__ */ jsxRuntimeExports.jsx(
77452
77467
  ValFormField,
77453
77468
  {
@@ -77462,6 +77477,7 @@ function AnyVal({
77462
77477
  }
77463
77478
  function ValTaggedUnion({
77464
77479
  tag,
77480
+ field,
77465
77481
  path,
77466
77482
  source,
77467
77483
  schema,
@@ -77499,6 +77515,8 @@ function ValTaggedUnion({
77499
77515
  });
77500
77516
  if (sourceKey && typeof sourceKey === "string" && unionSchema) {
77501
77517
  setCurrent({ source, schema: unionSchema });
77518
+ } else if (unionSchema) {
77519
+ setCurrent({ schema: unionSchema });
77502
77520
  } else {
77503
77521
  console.error(
77504
77522
  "Could not find source or schema of key",
@@ -77509,22 +77527,24 @@ function ValTaggedUnion({
77509
77527
  setCurrent(null);
77510
77528
  }
77511
77529
  }
77512
- }, [currentKey, source, schema, keys]);
77530
+ }, [currentKey, source, tag, schema, keys]);
77513
77531
  if (keys.length !== schema.items.length) {
77514
77532
  console.warn("Not all items have tag:", tag);
77515
77533
  }
77516
77534
  const loading = false;
77535
+ const onSubmit = initOnSubmit(path);
77517
77536
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
77518
- "div",
77537
+ FieldContainer,
77519
77538
  {
77520
- className: classNames("flex flex-col gap-y-8", {
77539
+ className: classNames("flex flex-col gap-y-4", {
77521
77540
  "border-l-2 border-border pl-6": !top
77522
77541
  }),
77523
77542
  children: [
77543
+ field ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-left", children: field }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "truncate max-w-[300px]", title: path, dir: "rtl", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path }) }),
77524
77544
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
77525
77545
  Select,
77526
77546
  {
77527
- defaultValue: currentKey ?? void 0,
77547
+ value: currentKey ?? void 0,
77528
77548
  disabled: loading,
77529
77549
  onValueChange: (key) => {
77530
77550
  setCurrentKey(key);
@@ -77535,11 +77555,19 @@ function ValTaggedUnion({
77535
77555
  ]
77536
77556
  }
77537
77557
  ),
77558
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
77559
+ SubmitButton,
77560
+ {
77561
+ loading,
77562
+ enabled: false,
77563
+ onClick: () => onSubmit(async () => [])
77564
+ }
77565
+ ),
77538
77566
  current && /* @__PURE__ */ jsxRuntimeExports.jsx(
77539
77567
  AnyVal,
77540
77568
  {
77541
77569
  path,
77542
- source: current.source,
77570
+ source: current.source ?? null,
77543
77571
  schema: current.schema,
77544
77572
  setSelectedPath,
77545
77573
  initOnSubmit,
@@ -77562,7 +77590,7 @@ function ValObject({
77562
77590
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
77563
77591
  "div",
77564
77592
  {
77565
- className: classNames("flex flex-col gap-y-8", {
77593
+ className: classNames("flex flex-col gap-y-1", {
77566
77594
  "border-l-2 border-border pl-6": !top
77567
77595
  }),
77568
77596
  children: Object.entries(schema.items).map(([key, property]) => {
@@ -77655,7 +77683,7 @@ function ValList({
77655
77683
  setSelectedPath
77656
77684
  }) {
77657
77685
  const navigate = useNavigate();
77658
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-4 p-2", children: source.map((item, index2) => {
77686
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-4 p-2 pb-8", children: source.map((item, index2) => {
77659
77687
  const subPath = createValPathOfItem(path, index2);
77660
77688
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
77661
77689
  "button",
@@ -77894,9 +77922,10 @@ function ValOptional({
77894
77922
  field
77895
77923
  }) {
77896
77924
  const [enable, setEnable] = reactExports.useState(source !== null);
77925
+ const { editMode } = useValOverlayContext();
77897
77926
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-y-2", children: [
77898
77927
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-start gap-x-4", children: [
77899
- /* @__PURE__ */ jsxRuntimeExports.jsx(
77928
+ editMode === "full" && /* @__PURE__ */ jsxRuntimeExports.jsx(
77900
77929
  Switch,
77901
77930
  {
77902
77931
  checked: enable,
@@ -77905,7 +77934,7 @@ function ValOptional({
77905
77934
  }
77906
77935
  }
77907
77936
  ),
77908
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: field ? field : /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path }) })
77937
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "truncate max-w-[300px]", title: path, dir: "rtl", children: field ? field : /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: path }) })
77909
77938
  ] }),
77910
77939
  enable && /* @__PURE__ */ jsxRuntimeExports.jsx(
77911
77940
  ValDefaultOf,
@@ -78004,7 +78033,7 @@ function PathTree({
78004
78033
  const selectedModuleId = selectedPath && Internal.splitModuleIdAndModulePath(selectedPath)[0];
78005
78034
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col w-full py-2 text-xs", children: Object.entries(tree).map(([dir, files]) => {
78006
78035
  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 }) }),
78036
+ dir && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-bold truncate max-w-[300px]", title: dir, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Path, { children: dir }) }),
78008
78037
  /* @__PURE__ */ jsxRuntimeExports.jsx(
78009
78038
  "div",
78010
78039
  {