najm-kit 0.0.7 → 0.0.8

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/json.mjs CHANGED
@@ -13,6 +13,7 @@ import { Slot } from '@radix-ui/react-slot';
13
13
  import * as LucideIcons from 'lucide-react';
14
14
  import { LoaderCircleIcon, Loader2, AlertCircle, ClipboardPaste, Copy, RotateCcw } from 'lucide-react';
15
15
  import { cva } from 'class-variance-authority';
16
+ import { OverlayScrollbarsComponent } from 'overlayscrollbars-react';
16
17
 
17
18
  // src/json/JsonViewer.tsx
18
19
  function cn(...inputs) {
@@ -197,7 +198,7 @@ var NIcon = ({
197
198
  };
198
199
  if (React3__default.isValidElement(icon)) {
199
200
  return React3__default.cloneElement(icon, {
200
- className: cn(icon.props.className, className),
201
+ className: cn(className, icon.props.className),
201
202
  onClick,
202
203
  ...rest
203
204
  });
@@ -330,6 +331,7 @@ var Button = React3.forwardRef(
330
331
  loaderPosition = "left",
331
332
  leftIcon,
332
333
  rightIcon,
334
+ bordered = false,
333
335
  disabled,
334
336
  children,
335
337
  onClick,
@@ -371,7 +373,11 @@ var Button = React3.forwardRef(
371
373
  "aria-busy": isLoading || void 0,
372
374
  "aria-disabled": asChild && isDisabled ? true : void 0,
373
375
  disabled: !asChild ? isDisabled : void 0,
374
- className: cn(buttonVariants({ variant, size, rounded, fullWidth, className })),
376
+ className: cn(
377
+ buttonVariants({ variant, size, rounded, fullWidth }),
378
+ bordered && "border border-muted-foreground",
379
+ className
380
+ ),
375
381
  onClick: handleClick,
376
382
  ...props,
377
383
  children: showCenteredLoader ? /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -734,7 +740,7 @@ function JsonEditor({
734
740
  statusAddon && /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: statusAddon })
735
741
  ] }),
736
742
  headerMiddle && /* @__PURE__ */ jsx("div", { className: "hidden shrink-0 items-center gap-1.5 md:flex", children: headerMiddle }),
737
- showActions && /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1.5 overflow-x-auto", children: [
743
+ showActions && /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1.5 najm-overlay-scroll-x", children: [
738
744
  onSmartPaste && /* @__PURE__ */ jsxs(Button, { variant: "secondary", disabled: saving || loading, onClick: onSmartPaste, title: "Paste & merge JSON from clipboard", className: "gap-1.5 whitespace-nowrap px-2 sm:px-3", children: [
739
745
  /* @__PURE__ */ jsx(ClipboardPaste, { className: "h-3.5 w-3.5 mr-1" }),
740
746
  /* @__PURE__ */ jsx("span", { children: smartPasteLabel ?? "Paste" })
@@ -820,6 +826,66 @@ var handler = {
820
826
  }
821
827
  };
822
828
  useTableStore.use = new Proxy({}, handler);
829
+ function assignRef(ref, node) {
830
+ if (!ref) return;
831
+ if (typeof ref === "function") ref(node);
832
+ else ref.current = node;
833
+ }
834
+ function applyViewportLayout(node, axis) {
835
+ node.style.width = "100%";
836
+ node.style.height = "100%";
837
+ node.style.minWidth = "0";
838
+ node.style.minHeight = "0";
839
+ node.style.overflowX = axis === "x" || axis === "both" ? "auto" : "hidden";
840
+ node.style.overflowY = axis === "y" || axis === "both" ? "auto" : "hidden";
841
+ }
842
+ function NajmScroll({ className, axis = "y", autoHide = "never", viewportRef, events, options, element, children, style, ...props }) {
843
+ return /* @__PURE__ */ jsx(
844
+ OverlayScrollbarsComponent,
845
+ {
846
+ className: cn(className),
847
+ style: {
848
+ ...style,
849
+ display: "flex",
850
+ alignItems: "stretch",
851
+ flexDirection: "row",
852
+ flexWrap: "nowrap",
853
+ overflow: "hidden",
854
+ minHeight: 0,
855
+ minWidth: 0
856
+ },
857
+ element,
858
+ defer: true,
859
+ options: {
860
+ scrollbars: { theme: "os-theme-najm", autoHide, autoHideDelay: 500, clickScroll: true },
861
+ overflow: {
862
+ x: axis === "x" || axis === "both" ? "scroll" : "hidden",
863
+ y: axis === "y" || axis === "both" ? "scroll" : "hidden"
864
+ },
865
+ ...options
866
+ },
867
+ events: {
868
+ ...events,
869
+ initialized: (instance, ...rest) => {
870
+ const viewport = instance.elements().viewport;
871
+ applyViewportLayout(viewport, axis);
872
+ assignRef(viewportRef, viewport);
873
+ events?.initialized?.(instance, ...rest);
874
+ },
875
+ updated: (instance, ...rest) => {
876
+ applyViewportLayout(instance.elements().viewport, axis);
877
+ events?.updated?.(instance, ...rest);
878
+ },
879
+ destroyed: (instance, ...rest) => {
880
+ assignRef(viewportRef, null);
881
+ events?.destroyed?.(instance, ...rest);
882
+ }
883
+ },
884
+ ...props,
885
+ children
886
+ }
887
+ );
888
+ }
823
889
  function formatJsonValue(value) {
824
890
  if (typeof value === "string") return value;
825
891
  try {
@@ -833,7 +899,7 @@ function NTableJson() {
833
899
  const renderJson = useTableStore.use.renderJson();
834
900
  const jsonValue = useTableStore.use.jsonValue();
835
901
  if (viewMode !== "json") return null;
836
- return /* @__PURE__ */ jsx("div", { className: "flex-1 flex flex-col min-h-0 overflow-hidden", children: renderJson?.() ?? /* @__PURE__ */ jsx("pre", { className: "h-full min-h-0 overflow-auto rounded-md border border-border bg-muted/40 p-4 font-mono text-xs leading-relaxed text-foreground", children: formatJsonValue(jsonValue) }) });
902
+ return /* @__PURE__ */ jsx("div", { className: "flex-1 flex flex-col min-h-0 overflow-hidden", children: renderJson?.() ?? /* @__PURE__ */ jsx(NajmScroll, { axis: "both", className: "h-full min-h-0 rounded-md border border-border bg-muted/40", children: /* @__PURE__ */ jsx("pre", { className: "p-4 font-mono text-xs leading-relaxed text-foreground", children: formatJsonValue(jsonValue) }) }) });
837
903
  }
838
904
 
839
905
  export { JsonEditor, JsonViewer, NTableJson };