neogestify-ui-components 2.1.0 → 2.2.2

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.
Files changed (36) hide show
  1. package/README.md +46 -1
  2. package/dist/components/ElementLibraryBuilder/index.d.mts +5 -0
  3. package/dist/components/ElementLibraryBuilder/index.d.ts +5 -0
  4. package/dist/components/ElementLibraryBuilder/index.js +689 -0
  5. package/dist/components/ElementLibraryBuilder/index.js.map +1 -0
  6. package/dist/components/ElementLibraryBuilder/index.mjs +687 -0
  7. package/dist/components/ElementLibraryBuilder/index.mjs.map +1 -0
  8. package/dist/components/VenueMapEditor/index.d.mts +18 -2
  9. package/dist/components/VenueMapEditor/index.d.ts +18 -2
  10. package/dist/components/VenueMapEditor/index.js +75 -3
  11. package/dist/components/VenueMapEditor/index.js.map +1 -1
  12. package/dist/components/VenueMapEditor/index.mjs +75 -4
  13. package/dist/components/VenueMapEditor/index.mjs.map +1 -1
  14. package/dist/components/html/index.d.mts +37 -4
  15. package/dist/components/html/index.d.ts +37 -4
  16. package/dist/components/html/index.js +135 -12
  17. package/dist/components/html/index.js.map +1 -1
  18. package/dist/components/html/index.mjs +135 -12
  19. package/dist/components/html/index.mjs.map +1 -1
  20. package/dist/index.d.mts +2 -1
  21. package/dist/index.d.ts +2 -1
  22. package/dist/index.js +603 -15
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +602 -16
  25. package/dist/index.mjs.map +1 -1
  26. package/package.json +1 -1
  27. package/src/components/ElementLibraryBuilder/builder.tsx +400 -0
  28. package/src/components/ElementLibraryBuilder/index.ts +1 -0
  29. package/src/components/VenueMapEditor/components/ElementNode.tsx +22 -0
  30. package/src/components/VenueMapEditor/components/PropertiesPanel.tsx +17 -4
  31. package/src/components/VenueMapEditor/components/Toolbar.tsx +14 -4
  32. package/src/components/VenueMapEditor/index.ts +2 -0
  33. package/src/components/VenueMapEditor/types.ts +11 -1
  34. package/src/components/VenueMapEditor/utils/svgParser.ts +33 -0
  35. package/src/components/html/Table.tsx +205 -38
  36. package/src/index.ts +1 -0
package/dist/index.mjs CHANGED
@@ -647,24 +647,147 @@ var Select = ({
647
647
  helperText && /* @__PURE__ */ jsx("p", { className: `text-sm ${error ? "text-red-600 dark:text-red-400" : "text-gray-500 dark:text-gray-400"}`, children: helperText })
648
648
  ] });
649
649
  };
650
+ function isColumnDef(col) {
651
+ return typeof col === "object" && col !== null && "header" in col;
652
+ }
653
+ function resolveColumn(col) {
654
+ if (isColumnDef(col)) return col;
655
+ return { header: col };
656
+ }
657
+ var ALIGN_CLASS = {
658
+ left: "text-left",
659
+ center: "text-center",
660
+ right: "text-right"
661
+ };
662
+ var SIZE_TH = {
663
+ sm: "px-2 py-1.5 text-xs",
664
+ md: "px-3 py-2.5 text-xs",
665
+ lg: "px-4 py-3.5 text-sm"
666
+ };
667
+ var SIZE_TD = {
668
+ sm: "px-2 py-1.5 text-xs",
669
+ md: "px-3 py-2.5 text-sm",
670
+ lg: "px-4 py-3.5 text-sm"
671
+ };
672
+ var VARIANT_TABLE = {
673
+ default: "w-full min-w-full table-auto",
674
+ striped: "w-full min-w-full table-auto",
675
+ bordered: "w-full min-w-full table-auto border border-gray-300 dark:border-gray-600",
676
+ minimal: "w-full min-w-full table-auto",
677
+ custom: "w-full min-w-full table-auto"
678
+ };
679
+ var VARIANT_THEAD = {
680
+ default: "bg-gray-100 dark:bg-gray-700",
681
+ striped: "bg-gray-100 dark:bg-gray-700",
682
+ bordered: "bg-gray-100 dark:bg-gray-700",
683
+ minimal: "",
684
+ custom: ""
685
+ };
686
+ var VARIANT_TH = {
687
+ default: "font-semibold uppercase tracking-wider text-gray-600 dark:text-gray-300",
688
+ striped: "font-semibold uppercase tracking-wider text-gray-600 dark:text-gray-300",
689
+ bordered: "font-semibold uppercase tracking-wider text-gray-600 dark:text-gray-300 border border-gray-300 dark:border-gray-600",
690
+ minimal: "font-semibold text-gray-500 dark:text-gray-400 border-b border-gray-200 dark:border-gray-700",
691
+ custom: ""
692
+ };
693
+ var VARIANT_TR = {
694
+ default: () => "bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700/60 transition-colors",
695
+ striped: (i) => `${i % 2 === 0 ? "bg-white dark:bg-gray-800" : "bg-gray-50 dark:bg-gray-700/40"} hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-colors`,
696
+ bordered: () => "bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700/60 transition-colors",
697
+ minimal: () => "hover:bg-gray-50 dark:hover:bg-gray-800/60 transition-colors",
698
+ custom: () => ""
699
+ };
700
+ var VARIANT_TD = {
701
+ default: "text-gray-700 dark:text-gray-300",
702
+ striped: "text-gray-700 dark:text-gray-300",
703
+ bordered: "text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-gray-700",
704
+ minimal: "text-gray-700 dark:text-gray-300 border-b border-gray-100 dark:border-gray-800",
705
+ custom: ""
706
+ };
707
+ var VARIANT_TBODY_DIVIDER = {
708
+ default: "divide-y divide-gray-200 dark:divide-gray-700",
709
+ striped: "",
710
+ bordered: "",
711
+ minimal: "",
712
+ custom: ""
713
+ };
650
714
  function Table({
651
- headers,
715
+ columns,
652
716
  rows,
653
717
  variant = "default",
718
+ size = "md",
654
719
  className = "",
720
+ tableClassName = "",
655
721
  thClassName = "",
656
- tdClassName = ""
722
+ tdClassName = "",
723
+ trClassName,
724
+ emptyState,
725
+ onRowClick,
726
+ hideHeader = false,
727
+ style
657
728
  }) {
658
- const baseTableClass = variant === "default" ? "w-full table-auto border-collapse border border-gray-300 dark:border-gray-600 min-w-full" : "";
659
- const baseThClass = variant === "default" ? "border border-gray-300 dark:border-gray-600 px-4 py-2 text-left text-gray-900 dark:text-white" : "";
660
- const baseTdClass = variant === "default" ? "border border-gray-300 dark:border-gray-600 px-4 py-2 text-gray-900 dark:text-white" : "";
661
- const tableClass = `${baseTableClass} ${className}`.trim();
662
- const thClass = `${baseThClass} ${thClassName}`.trim();
663
- const tdClass = `${baseTdClass} ${tdClassName}`.trim();
664
- return /* @__PURE__ */ jsx("div", { className: "overflow-x-auto w-full", children: /* @__PURE__ */ jsxs("table", { className: tableClass, children: [
665
- /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { className: variant === "default" ? "bg-gray-100 dark:bg-gray-700" : "", children: headers.map((header, index) => /* @__PURE__ */ jsx("th", { className: thClass, children: header }, index)) }) }),
666
- /* @__PURE__ */ jsx("tbody", { children: rows.map((row, rowIndex) => /* @__PURE__ */ jsx("tr", { className: variant === "default" ? "hover:bg-gray-50 dark:hover:bg-gray-600" : "", children: row.map((cell, cellIndex) => /* @__PURE__ */ jsx("td", { className: tdClass, children: cell }, cellIndex)) }, rowIndex)) })
667
- ] }) });
729
+ const cols = columns.map(resolveColumn);
730
+ const resolvedTrClass = (i) => {
731
+ const variantCls = VARIANT_TR[variant](i);
732
+ const clickCls = onRowClick ? "cursor-pointer" : "";
733
+ const customCls = typeof trClassName === "function" ? trClassName(i) : trClassName ?? "";
734
+ return `${variantCls} ${clickCls} ${customCls}`.trim();
735
+ };
736
+ return /* @__PURE__ */ jsx("div", { className: `overflow-x-auto w-full ${className}`.trim(), children: /* @__PURE__ */ jsxs(
737
+ "table",
738
+ {
739
+ className: `${VARIANT_TABLE[variant]} ${tableClassName}`.trim(),
740
+ style,
741
+ children: [
742
+ !hideHeader && /* @__PURE__ */ jsx("thead", { className: VARIANT_THEAD[variant], children: /* @__PURE__ */ jsx("tr", { children: cols.map((col, i) => /* @__PURE__ */ jsx(
743
+ "th",
744
+ {
745
+ className: [
746
+ SIZE_TH[size],
747
+ VARIANT_TH[variant],
748
+ ALIGN_CLASS[col.align ?? "left"],
749
+ col.className ?? "",
750
+ thClassName
751
+ ].filter(Boolean).join(" "),
752
+ children: col.header
753
+ },
754
+ i
755
+ )) }) }),
756
+ /* @__PURE__ */ jsx("tbody", { className: VARIANT_TBODY_DIVIDER[variant], children: rows.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
757
+ "td",
758
+ {
759
+ colSpan: cols.length,
760
+ className: `${SIZE_TD[size]} text-center text-gray-400 dark:text-gray-500 py-8`,
761
+ children: emptyState ?? "Sin datos"
762
+ }
763
+ ) }) : rows.map((row, rowIndex) => /* @__PURE__ */ jsx(
764
+ "tr",
765
+ {
766
+ className: resolvedTrClass(rowIndex),
767
+ onClick: onRowClick ? () => onRowClick(rowIndex) : void 0,
768
+ children: row.map((cell, cellIndex) => {
769
+ const col = cols[cellIndex];
770
+ return /* @__PURE__ */ jsx(
771
+ "td",
772
+ {
773
+ className: [
774
+ SIZE_TD[size],
775
+ VARIANT_TD[variant],
776
+ ALIGN_CLASS[col?.align ?? "left"],
777
+ col?.className ?? "",
778
+ tdClassName
779
+ ].filter(Boolean).join(" "),
780
+ children: cell
781
+ },
782
+ cellIndex
783
+ );
784
+ })
785
+ },
786
+ rowIndex
787
+ )) })
788
+ ]
789
+ }
790
+ ) });
668
791
  }
669
792
  var Modal = forwardRef(({
670
793
  onClose,
@@ -929,6 +1052,26 @@ function useLibraryStorage(storageKey) {
929
1052
  );
930
1053
  return [libs, setAndPersist];
931
1054
  }
1055
+
1056
+ // src/components/VenueMapEditor/utils/svgParser.ts
1057
+ var DANGEROUS_TAGS = /\b(script|iframe|object|embed|link|style|meta)\b/gi;
1058
+ var DANGEROUS_ATTRS = /\bon\w+\s*=/gi;
1059
+ var DANGEROUS_HREF = /\bhref\s*=\s*["']?\s*javascript:/gi;
1060
+ var DANGEROUS_XLINK = /\bxlink:href\s*=\s*["']?\s*javascript:/gi;
1061
+ function sanitize(html) {
1062
+ return html.replace(DANGEROUS_TAGS, "").replace(DANGEROUS_ATTRS, "").replace(DANGEROUS_HREF, "").replace(DANGEROUS_XLINK, "");
1063
+ }
1064
+ var VIEWBOX_RE = /viewBox\s*=\s*"([^"]+)"/i;
1065
+ var SVG_OPEN_END_RE = /<svg[^>]*>/i;
1066
+ function parseSvgMarkup(markup) {
1067
+ const viewBoxMatch = markup.match(VIEWBOX_RE);
1068
+ const viewBox = viewBoxMatch?.[1] ?? "0 0 100 100";
1069
+ const svgOpenMatch = markup.match(SVG_OPEN_END_RE);
1070
+ const afterOpen = svgOpenMatch ? markup.slice(svgOpenMatch.index + svgOpenMatch[0].length) : markup;
1071
+ const closeIdx = afterOpen.lastIndexOf("</svg>");
1072
+ const inner = closeIdx >= 0 ? afterOpen.slice(0, closeIdx) : afterOpen;
1073
+ return { viewBox, innerHtml: sanitize(inner) };
1074
+ }
932
1075
  function ToolButton({ active, disabled, title, onClick, children }) {
933
1076
  return /* @__PURE__ */ jsx(
934
1077
  "button",
@@ -958,7 +1101,15 @@ function TypeChip({ typeDef, active, onClick }) {
958
1101
  active ? "border-blue-400 bg-blue-50 text-blue-700 font-medium" : "border-slate-200 bg-white text-slate-600 hover:border-slate-300 hover:bg-slate-50"
959
1102
  ].join(" "),
960
1103
  children: [
961
- /* @__PURE__ */ jsx(
1104
+ typeDef.shape === "svg" && typeDef.svgMarkup ? /* @__PURE__ */ jsx(
1105
+ "svg",
1106
+ {
1107
+ viewBox: parseSvgMarkup(typeDef.svgMarkup).viewBox,
1108
+ className: "w-2.5 h-2.5 shrink-0",
1109
+ style: { color: typeDef.strokeColor },
1110
+ dangerouslySetInnerHTML: { __html: parseSvgMarkup(typeDef.svgMarkup).innerHtml }
1111
+ }
1112
+ ) : /* @__PURE__ */ jsx(
962
1113
  "span",
963
1114
  {
964
1115
  className: "w-2.5 h-2.5 rounded-sm shrink-0",
@@ -2027,6 +2178,28 @@ function ElementNode({
2027
2178
  onClick: handleBodyClick
2028
2179
  }
2029
2180
  ) }),
2181
+ typeDef.shape === "svg" && typeDef.svgMarkup && (() => {
2182
+ const parsed = parseSvgMarkup(typeDef.svgMarkup);
2183
+ const parts = parsed.viewBox.split(/[\s,]+/).map(Number);
2184
+ const vw = parts[2] ?? 100;
2185
+ const vh = parts[3] ?? 100;
2186
+ const sx = vw > 0 ? w / vw : 1;
2187
+ const sy = vh > 0 ? h / vh : 1;
2188
+ const avgScale = Math.sqrt(Math.abs(sx * sy)) || 1;
2189
+ return /* @__PURE__ */ jsx(
2190
+ "g",
2191
+ {
2192
+ transform: `translate(${x}, ${y}) scale(${sx}, ${sy})`,
2193
+ fill: fillColor,
2194
+ stroke: isSelected ? "#3b82f6" : typeDef.strokeColor,
2195
+ strokeWidth: isSelected ? sw / avgScale * 1.5 : sw / avgScale,
2196
+ style: { cursor: bodyCursor },
2197
+ onMouseDown: tool === "SELECT" && !onViewerClick ? handleBodyDown : void 0,
2198
+ onClick: handleBodyClick,
2199
+ dangerouslySetInnerHTML: { __html: parsed.innerHtml }
2200
+ }
2201
+ );
2202
+ })(),
2030
2203
  (element.label ?? typeDef.label) && /* @__PURE__ */ jsx(
2031
2204
  "text",
2032
2205
  {
@@ -2525,14 +2698,35 @@ function PropertiesPanel({
2525
2698
  /* @__PURE__ */ jsx("div", { className: "px-3 py-2 border-b border-slate-100 text-xs font-semibold text-slate-500 uppercase tracking-wide", children: "Propiedades" }),
2526
2699
  /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col gap-4 p-3", children: [
2527
2700
  typeDef && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
2528
- /* @__PURE__ */ jsx(
2701
+ typeDef.shape === "svg" ? /* @__PURE__ */ jsx(
2702
+ "svg",
2703
+ {
2704
+ viewBox: (() => {
2705
+ try {
2706
+ return typeDef.svgMarkup ? parseSvgMarkup(typeDef.svgMarkup).viewBox : "0 0 100 100";
2707
+ } catch {
2708
+ return "0 0 100 100";
2709
+ }
2710
+ })(),
2711
+ className: "w-3.5 h-3.5 shrink-0 border border-slate-300 rounded-sm",
2712
+ style: { color: typeDef.strokeColor },
2713
+ dangerouslySetInnerHTML: { __html: (() => {
2714
+ try {
2715
+ return typeDef.svgMarkup ? parseSvgMarkup(typeDef.svgMarkup).innerHtml : "";
2716
+ } catch {
2717
+ return "";
2718
+ }
2719
+ })() }
2720
+ }
2721
+ ) : /* @__PURE__ */ jsx(
2529
2722
  "span",
2530
2723
  {
2531
2724
  className: "w-3.5 h-3.5 rounded-sm shrink-0 border",
2532
2725
  style: { background: typeDef.color, borderColor: typeDef.strokeColor }
2533
2726
  }
2534
2727
  ),
2535
- /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-slate-700 truncate", children: typeDef.label })
2728
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-slate-700 truncate", children: typeDef.label }),
2729
+ typeDef.shape === "svg" && /* @__PURE__ */ jsx("span", { className: "text-[9px] uppercase tracking-wide text-slate-400 font-medium ml-auto", children: "SVG" })
2536
2730
  ] }),
2537
2731
  /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-0.5", children: [
2538
2732
  /* @__PURE__ */ jsx("span", { className: "text-[10px] font-medium text-slate-400 uppercase tracking-wide", children: "Etiqueta" }),
@@ -3600,7 +3794,399 @@ function VenueMapViewer({ elementStatus, onElementClick, ...rest }) {
3600
3794
  }
3601
3795
  );
3602
3796
  }
3797
+ var DEFAULT_ELEMENT = {
3798
+ id: "",
3799
+ label: "",
3800
+ shape: "rect",
3801
+ defaultWidth: 100,
3802
+ defaultHeight: 100,
3803
+ color: "#cccccc",
3804
+ strokeColor: "#000000"
3805
+ };
3806
+ var SHAPE_OPTIONS = [
3807
+ { value: "rect", label: "Rectangle" },
3808
+ { value: "circle", label: "Circle" },
3809
+ { value: "arrow", label: "Arrow" },
3810
+ { value: "path", label: "Path" },
3811
+ { value: "svg", label: "SVG Markup" }
3812
+ ];
3813
+ var ElementLibraryBuilder = () => {
3814
+ const [groups, setGroups] = useState([
3815
+ { internalId: crypto.randomUUID(), name: "defaultGroup", objects: [] }
3816
+ ]);
3817
+ const [activeGroupId, setActiveGroupId] = useState(groups[0].internalId);
3818
+ const [editingGroupId, setEditingGroupId] = useState(null);
3819
+ const [activeElementIndex, setActiveElementIndex] = useState(null);
3820
+ const [currentElement, setCurrentElement] = useState({ ...DEFAULT_ELEMENT, id: "rect_1", label: "New Rect" });
3821
+ const [downloadFileName, setDownloadFileName] = useState("libraries");
3822
+ const handleAddGroup = () => {
3823
+ const newGroupId = crypto.randomUUID();
3824
+ const newName = `group_${groups.length + 1}`;
3825
+ setGroups([...groups, { internalId: newGroupId, name: newName, objects: [] }]);
3826
+ setActiveGroupId(newGroupId);
3827
+ setActiveElementIndex(null);
3828
+ };
3829
+ const handleRemoveGroup = (id) => {
3830
+ const newGroups = groups.filter((g) => g.internalId !== id);
3831
+ setGroups(newGroups);
3832
+ if (activeGroupId === id) {
3833
+ if (newGroups.length > 0) {
3834
+ setActiveGroupId(newGroups[0].internalId);
3835
+ } else {
3836
+ setActiveGroupId("");
3837
+ }
3838
+ setActiveElementIndex(null);
3839
+ }
3840
+ };
3841
+ const activeGroup = groups.find((g) => g.internalId === activeGroupId);
3842
+ const handleSelectGroup = (gId) => {
3843
+ setActiveGroupId(gId);
3844
+ setActiveElementIndex(null);
3845
+ };
3846
+ const handleAddElement = () => {
3847
+ if (!activeGroup) return;
3848
+ const newEl = { ...DEFAULT_ELEMENT, id: `shape_${activeGroup.objects.length + 1}`, label: `Shape ${activeGroup.objects.length + 1}` };
3849
+ const updatedGroups = groups.map((g) => {
3850
+ if (g.internalId === activeGroupId) {
3851
+ return { ...g, objects: [...g.objects, newEl] };
3852
+ }
3853
+ return g;
3854
+ });
3855
+ setGroups(updatedGroups);
3856
+ setActiveElementIndex(activeGroup.objects.length);
3857
+ setCurrentElement(newEl);
3858
+ };
3859
+ const handleSelectElement = (idx) => {
3860
+ if (!activeGroup) return;
3861
+ setActiveElementIndex(idx);
3862
+ setCurrentElement(activeGroup.objects[idx]);
3863
+ };
3864
+ const handleRemoveElement = (idx) => {
3865
+ if (!activeGroup) return;
3866
+ const updatedGroups = groups.map((g) => {
3867
+ if (g.internalId === activeGroupId) {
3868
+ const newObjs = [...g.objects];
3869
+ newObjs.splice(idx, 1);
3870
+ return { ...g, objects: newObjs };
3871
+ }
3872
+ return g;
3873
+ });
3874
+ setGroups(updatedGroups);
3875
+ if (activeElementIndex === idx) {
3876
+ setActiveElementIndex(null);
3877
+ } else if (activeElementIndex !== null && activeElementIndex > idx) {
3878
+ setActiveElementIndex(activeElementIndex - 1);
3879
+ }
3880
+ };
3881
+ const handleSaveElement = () => {
3882
+ if (!activeGroup || activeElementIndex === null) return;
3883
+ const updatedGroups = groups.map((g) => {
3884
+ if (g.internalId === activeGroupId) {
3885
+ const newObjs = [...g.objects];
3886
+ newObjs[activeElementIndex] = { ...currentElement };
3887
+ return { ...g, objects: newObjs };
3888
+ }
3889
+ return g;
3890
+ });
3891
+ setGroups(updatedGroups);
3892
+ };
3893
+ const handleFieldChange = (field, value) => {
3894
+ setCurrentElement((prev) => ({ ...prev, [field]: value }));
3895
+ };
3896
+ const handleSvgMarkupChange = (value) => {
3897
+ handleFieldChange("svgMarkup", value);
3898
+ };
3899
+ const generatedLib = useMemo(() => {
3900
+ const lib = {};
3901
+ groups.forEach((g) => {
3902
+ lib[g.name] = {
3903
+ name: g.name,
3904
+ objects: g.objects
3905
+ };
3906
+ });
3907
+ return JSON.stringify(lib, null, 2);
3908
+ }, [groups]);
3909
+ const handleDownload = () => {
3910
+ const blob = new Blob([generatedLib], { type: "application/json" });
3911
+ const url = URL.createObjectURL(blob);
3912
+ const a = document.createElement("a");
3913
+ a.href = url;
3914
+ a.download = `${downloadFileName}.json`;
3915
+ document.body.appendChild(a);
3916
+ a.click();
3917
+ document.body.removeChild(a);
3918
+ URL.revokeObjectURL(url);
3919
+ };
3920
+ return /* @__PURE__ */ jsxs("div", { className: "flex gap-4 p-4 h-full min-h-[600px] text-sm text-gray-900 dark:text-gray-100 bg-white dark:bg-gray-900", children: [
3921
+ /* @__PURE__ */ jsxs("div", { className: "w-1/4 flex flex-col gap-4 border-r dark:border-gray-700 pr-4", children: [
3922
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
3923
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
3924
+ /* @__PURE__ */ jsx("h3", { className: "font-bold", children: "Libraries (Groups)" }),
3925
+ /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: handleAddGroup, children: "+ Group" })
3926
+ ] }),
3927
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1 max-h-48 overflow-y-auto pr-1", children: groups.map((group) => /* @__PURE__ */ jsxs(
3928
+ "div",
3929
+ {
3930
+ className: `flex items-center justify-between p-2 rounded cursor-pointer ${activeGroupId === group.internalId ? "bg-indigo-100 text-indigo-900 dark:bg-indigo-900/50 dark:text-indigo-100 font-semibold" : "hover:bg-gray-100 dark:hover:bg-gray-800"}`,
3931
+ onClick: () => handleSelectGroup(group.internalId),
3932
+ children: [
3933
+ editingGroupId === group.internalId ? /* @__PURE__ */ jsx(
3934
+ Input,
3935
+ {
3936
+ autoFocus: true,
3937
+ value: group.name,
3938
+ onChange: (e) => {
3939
+ setGroups(groups.map((g) => g.internalId === group.internalId ? { ...g, name: e.target.value } : g));
3940
+ },
3941
+ onBlur: () => setEditingGroupId(null),
3942
+ onKeyDown: (e) => e.key === "Enter" && setEditingGroupId(null)
3943
+ }
3944
+ ) : /* @__PURE__ */ jsx("span", { onDoubleClick: () => setEditingGroupId(group.internalId), children: group.name }),
3945
+ groups.length > 1 && /* @__PURE__ */ jsx("button", { onClick: (e) => {
3946
+ e.stopPropagation();
3947
+ handleRemoveGroup(group.internalId);
3948
+ }, className: "text-red-500 text-xs", children: "x" })
3949
+ ]
3950
+ },
3951
+ group.internalId
3952
+ )) })
3953
+ ] }),
3954
+ /* @__PURE__ */ jsx("hr", { className: "dark:border-gray-700" }),
3955
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 flex-grow overflow-hidden", children: [
3956
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
3957
+ /* @__PURE__ */ jsxs("h3", { className: "font-bold", children: [
3958
+ "Elements in ",
3959
+ activeGroup?.name || "?"
3960
+ ] }),
3961
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: handleAddElement, disabled: !activeGroup, children: "+ Element" })
3962
+ ] }),
3963
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 overflow-y-auto flex-grow pr-1", children: [
3964
+ activeGroup?.objects.map((el, i) => /* @__PURE__ */ jsxs(
3965
+ "div",
3966
+ {
3967
+ className: `flex items-center justify-between p-2 rounded cursor-pointer ${activeElementIndex === i ? "bg-indigo-100 text-indigo-900 dark:bg-indigo-900/50 dark:text-indigo-100 font-semibold" : "hover:bg-gray-100 dark:hover:bg-gray-800"}`,
3968
+ onClick: () => handleSelectElement(i),
3969
+ children: [
3970
+ /* @__PURE__ */ jsxs("span", { children: [
3971
+ el.id,
3972
+ " (",
3973
+ el.shape,
3974
+ ")"
3975
+ ] }),
3976
+ /* @__PURE__ */ jsx("button", { onClick: (e) => {
3977
+ e.stopPropagation();
3978
+ handleRemoveElement(i);
3979
+ }, className: "text-red-500 text-xs", children: "x" })
3980
+ ]
3981
+ },
3982
+ i
3983
+ )),
3984
+ (!activeGroup || activeGroup.objects.length === 0) && /* @__PURE__ */ jsx("span", { className: "text-gray-400 dark:text-gray-500 italic text-xs", children: "No elements yet" })
3985
+ ] })
3986
+ ] })
3987
+ ] }),
3988
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col gap-4 px-2 overflow-y-auto", children: [
3989
+ /* @__PURE__ */ jsx("h3", { className: "font-bold text-lg", children: "Element Editor" }),
3990
+ activeElementIndex !== null ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 w-full max-w-2xl", children: [
3991
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
3992
+ /* @__PURE__ */ jsx(
3993
+ Input,
3994
+ {
3995
+ label: "Element ID (unique)",
3996
+ value: currentElement.id,
3997
+ onChange: (e) => handleFieldChange("id", e.target.value)
3998
+ }
3999
+ ),
4000
+ /* @__PURE__ */ jsx(
4001
+ Input,
4002
+ {
4003
+ label: "Label (display name)",
4004
+ value: currentElement.label,
4005
+ onChange: (e) => handleFieldChange("label", e.target.value)
4006
+ }
4007
+ )
4008
+ ] }),
4009
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
4010
+ /* @__PURE__ */ jsx(
4011
+ Select,
4012
+ {
4013
+ label: "Shape",
4014
+ options: SHAPE_OPTIONS,
4015
+ value: currentElement.shape,
4016
+ onChange: (e) => handleFieldChange("shape", e.target.value)
4017
+ }
4018
+ ),
4019
+ /* @__PURE__ */ jsx(
4020
+ Input,
4021
+ {
4022
+ label: "Icon (emoji or class)",
4023
+ value: currentElement.icon || "",
4024
+ onChange: (e) => handleFieldChange("icon", e.target.value)
4025
+ }
4026
+ )
4027
+ ] }),
4028
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
4029
+ /* @__PURE__ */ jsx(
4030
+ Input,
4031
+ {
4032
+ type: "number",
4033
+ label: "Default Width",
4034
+ value: currentElement.defaultWidth,
4035
+ onChange: (e) => handleFieldChange("defaultWidth", parseFloat(e.target.value) || 0)
4036
+ }
4037
+ ),
4038
+ /* @__PURE__ */ jsx(
4039
+ Input,
4040
+ {
4041
+ type: "number",
4042
+ label: "Default Height",
4043
+ value: currentElement.defaultHeight,
4044
+ onChange: (e) => handleFieldChange("defaultHeight", parseFloat(e.target.value) || 0)
4045
+ }
4046
+ )
4047
+ ] }),
4048
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
4049
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
4050
+ /* @__PURE__ */ jsx("label", { className: "text-xs font-semibold text-gray-700", children: "Fill Color" }),
4051
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
4052
+ /* @__PURE__ */ jsx(
4053
+ "input",
4054
+ {
4055
+ type: "color",
4056
+ className: "w-8 h-8 cursor-pointer rounded",
4057
+ value: currentElement.color,
4058
+ onChange: (e) => handleFieldChange("color", e.target.value)
4059
+ }
4060
+ ),
4061
+ /* @__PURE__ */ jsx(
4062
+ Input,
4063
+ {
4064
+ value: currentElement.color,
4065
+ onChange: (e) => handleFieldChange("color", e.target.value)
4066
+ }
4067
+ )
4068
+ ] })
4069
+ ] }),
4070
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
4071
+ /* @__PURE__ */ jsx("label", { className: "text-xs font-semibold text-gray-700", children: "Stroke Color" }),
4072
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
4073
+ /* @__PURE__ */ jsx(
4074
+ "input",
4075
+ {
4076
+ type: "color",
4077
+ className: "w-8 h-8 cursor-pointer rounded",
4078
+ value: currentElement.strokeColor,
4079
+ onChange: (e) => handleFieldChange("strokeColor", e.target.value)
4080
+ }
4081
+ ),
4082
+ /* @__PURE__ */ jsx(
4083
+ Input,
4084
+ {
4085
+ value: currentElement.strokeColor,
4086
+ onChange: (e) => handleFieldChange("strokeColor", e.target.value)
4087
+ }
4088
+ )
4089
+ ] })
4090
+ ] })
4091
+ ] }),
4092
+ currentElement.shape === "path" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 border dark:border-gray-700 p-4 rounded bg-gray-50 dark:bg-gray-800/50", children: [
4093
+ /* @__PURE__ */ jsx("h4", { className: "font-semibold text-sm", children: "Path Config" }),
4094
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
4095
+ /* @__PURE__ */ jsx(
4096
+ Input,
4097
+ {
4098
+ label: "ViewBox",
4099
+ placeholder: "0 0 100 100",
4100
+ value: currentElement.viewBox || "",
4101
+ onChange: (e) => handleFieldChange("viewBox", e.target.value)
4102
+ }
4103
+ ),
4104
+ /* @__PURE__ */ jsx(
4105
+ Select,
4106
+ {
4107
+ label: "Fill Rule",
4108
+ options: [
4109
+ { value: "nonzero", label: "nonzero" },
4110
+ { value: "evenodd", label: "evenodd" }
4111
+ ],
4112
+ value: currentElement.fillRule || "nonzero",
4113
+ onChange: (e) => handleFieldChange("fillRule", e.target.value)
4114
+ }
4115
+ )
4116
+ ] }),
4117
+ /* @__PURE__ */ jsx(
4118
+ TextArea,
4119
+ {
4120
+ label: "SVG Path (d attribute)",
4121
+ placeholder: "M10 10 H 90 V 90 H 10 Z",
4122
+ value: currentElement.svgPath || "",
4123
+ onChange: (e) => handleFieldChange("svgPath", e.target.value),
4124
+ rows: 4
4125
+ }
4126
+ )
4127
+ ] }),
4128
+ currentElement.shape === "svg" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 border dark:border-amber-700/50 p-4 rounded bg-amber-50 dark:bg-amber-900/10", children: [
4129
+ /* @__PURE__ */ jsx("h4", { className: "font-semibold text-sm", children: "SVG Markup (Autosanitized)" }),
4130
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-amber-800 dark:text-amber-400", children: "Paste your raw SVG here. Double quotes will be converted to single quotes automatically to safely embed the string in JSON." }),
4131
+ /* @__PURE__ */ jsx(
4132
+ TextArea,
4133
+ {
4134
+ label: "raw <svg>...</svg>",
4135
+ value: currentElement.svgMarkup || "",
4136
+ onChange: (e) => handleSvgMarkupChange(e.target.value),
4137
+ rows: 6,
4138
+ placeholder: "<svg viewBox='0 0 100 100'><circle cx='50' cy='50' r='50'/></svg>"
4139
+ }
4140
+ )
4141
+ ] }),
4142
+ /* @__PURE__ */ jsx("div", { className: "flex justify-end gap-2 mt-4 pt-4 border-t dark:border-gray-700", children: /* @__PURE__ */ jsx(Button, { onClick: handleSaveElement, children: "Save Changes to Element" }) })
4143
+ ] }) : /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-full text-gray-400", children: "Select an element to edit or add a new one." })
4144
+ ] }),
4145
+ /* @__PURE__ */ jsxs("div", { className: "w-1/3 flex flex-col gap-2 border-l dark:border-gray-700 pl-4 h-full max-h-full", children: [
4146
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between shrink-0", children: [
4147
+ /* @__PURE__ */ jsx("h3", { className: "font-bold", children: "Output JSON" }),
4148
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
4149
+ /* @__PURE__ */ jsx(
4150
+ Input,
4151
+ {
4152
+ value: downloadFileName,
4153
+ onChange: (e) => setDownloadFileName(e.target.value),
4154
+ placeholder: "filename",
4155
+ title: "Filename without extension"
4156
+ }
4157
+ ),
4158
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-gray-500", children: ".json" }),
4159
+ /* @__PURE__ */ jsx(
4160
+ Button,
4161
+ {
4162
+ variant: "secondary",
4163
+ onClick: handleDownload,
4164
+ title: "Download JSON file",
4165
+ children: "Descargar"
4166
+ }
4167
+ ),
4168
+ /* @__PURE__ */ jsx(
4169
+ Button,
4170
+ {
4171
+ variant: "secondary",
4172
+ onClick: () => navigator.clipboard.writeText(generatedLib),
4173
+ children: "Copy"
4174
+ }
4175
+ )
4176
+ ] })
4177
+ ] }),
4178
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden h-full pb-4", children: /* @__PURE__ */ jsx(
4179
+ TextArea,
4180
+ {
4181
+ readOnly: true,
4182
+ className: "h-full resize-none font-mono text-xs text-green-600 dark:text-green-400 bg-gray-50 dark:bg-gray-900 border-gray-200 dark:border-gray-800",
4183
+ value: generatedLib
4184
+ }
4185
+ ) })
4186
+ ] })
4187
+ ] });
4188
+ };
3603
4189
 
3604
- export { AddIcon, Alerta, AlertaAdvertencia, AlertaConfirmacion, AlertaError, AlertaExito, AlertaInfo, AlertaToast, AnimateSpin, ArchiveIcon, ArrowIcon, ArrowLeftIcon, ArrowRightIcon, BackIcon, BarsChartsIcon, BoxIcon, BuildingIcon, Button, CajasIcon, CalendarIcon, CamaraIcon, CancelIcon, CashIcon, CategorieIcon, ChartIcon, CheckCircleIcon, CheckIcon, ClockIcon, CloseIcon, CloudIcon, CopyIcon, DeleteIcon, DocumentIcon, EditIcon, FacturacionIcon, FilterIcon, FolderIcon, Form, GearIcon, HomeIcon, IconCursor, IconDownload, IconDuplicate, IconErase, IconGrid, IconHand, IconLayers, IconPlace, IconPolygon, IconRedo, IconReset, IconUndo, IconUpload, IconWall, IconZoomIn, IconZoomOut, InfoAlert, InfoIcon, Input, LifeGuardIcon, LightingIcon, Loading, LocationIcon, LogoutIcon, MenuIcon, MinusIcon, Modal, MoneyIcon, MonitorIcon, MoonIcon, NetworkIcon, NotFoundIcon, PasteIcon, PercentIcon, PrinterIcon, QuestionIcon, RestaurantMenuIcon, SaveIcon, SearchIcon, Select, ShieldIcon, SpinnerIcon, StackIcon, SunIcon, Table, TestIcon, TextArea, ThemeContext, ThemeProvider, ThemeToggle, TrashIcon, TruckIcon, UsersIcon, VenueMapEditor, VenueMapViewer, WhatsAppIcon, findNearestNode, genId, snapPoint, snapToGrid, useLibraryStorage, usePanZoom, useTheme };
4190
+ export { AddIcon, Alerta, AlertaAdvertencia, AlertaConfirmacion, AlertaError, AlertaExito, AlertaInfo, AlertaToast, AnimateSpin, ArchiveIcon, ArrowIcon, ArrowLeftIcon, ArrowRightIcon, BackIcon, BarsChartsIcon, BoxIcon, BuildingIcon, Button, CajasIcon, CalendarIcon, CamaraIcon, CancelIcon, CashIcon, CategorieIcon, ChartIcon, CheckCircleIcon, CheckIcon, ClockIcon, CloseIcon, CloudIcon, CopyIcon, DeleteIcon, DocumentIcon, EditIcon, ElementLibraryBuilder, FacturacionIcon, FilterIcon, FolderIcon, Form, GearIcon, HomeIcon, IconCursor, IconDownload, IconDuplicate, IconErase, IconGrid, IconHand, IconLayers, IconPlace, IconPolygon, IconRedo, IconReset, IconUndo, IconUpload, IconWall, IconZoomIn, IconZoomOut, InfoAlert, InfoIcon, Input, LifeGuardIcon, LightingIcon, Loading, LocationIcon, LogoutIcon, MenuIcon, MinusIcon, Modal, MoneyIcon, MonitorIcon, MoonIcon, NetworkIcon, NotFoundIcon, PasteIcon, PercentIcon, PrinterIcon, QuestionIcon, RestaurantMenuIcon, SaveIcon, SearchIcon, Select, ShieldIcon, SpinnerIcon, StackIcon, SunIcon, Table, TestIcon, TextArea, ThemeContext, ThemeProvider, ThemeToggle, TrashIcon, TruckIcon, UsersIcon, VenueMapEditor, VenueMapViewer, WhatsAppIcon, findNearestNode, genId, parseSvgMarkup, snapPoint, snapToGrid, useLibraryStorage, usePanZoom, useTheme };
3605
4191
  //# sourceMappingURL=index.mjs.map
3606
4192
  //# sourceMappingURL=index.mjs.map