@kjaniec-dev/ui 0.9.0 → 0.9.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.
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
+ "use client";
1
2
  import { clsx } from 'clsx';
2
3
  import { twMerge } from 'tailwind-merge';
3
4
  import * as React52 from 'react';
5
+ import React52__default, { useState, useEffect, useRef } from 'react';
4
6
  import { cva } from 'class-variance-authority';
5
7
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
6
8
 
@@ -1155,7 +1157,7 @@ var BottomNavigation = React52.forwardRef(
1155
1157
  );
1156
1158
  BottomNavigation.displayName = "BottomNavigation";
1157
1159
  var TableWrap = React52.forwardRef(
1158
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("border border-border rounded-kj-lg overflow-x-auto w-full", className), ...props })
1160
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("w-full max-w-full overflow-x-auto border border-border rounded-kj-lg", className), ...props })
1159
1161
  );
1160
1162
  TableWrap.displayName = "TableWrap";
1161
1163
  var Table = React52.forwardRef(
@@ -1310,7 +1312,7 @@ function Modal({ open, onClose, children, width = 440, className, showClose = tr
1310
1312
  tabIndex: -1,
1311
1313
  style: { maxWidth: width },
1312
1314
  className: cn(
1313
- "relative w-full p-7 rounded-kj-2xl bg-surface border border-border shadow-kj-lg transition-transform duration-200 outline-none",
1315
+ "relative w-full p-7 rounded-kj-2xl bg-surface text-foreground border border-border shadow-kj-lg transition-transform duration-200 outline-none",
1314
1316
  open ? "scale-100 translate-y-0" : "scale-95 translate-y-2",
1315
1317
  className
1316
1318
  ),
@@ -1334,7 +1336,7 @@ function Modal({ open, onClose, children, width = 440, className, showClose = tr
1334
1336
  }
1335
1337
  function ModalTitle({ className, id, children, ...props }) {
1336
1338
  const ctx = React52.useContext(ModalContext);
1337
- return /* @__PURE__ */ jsx("h3", { id: id ?? ctx?.titleId, className: cn("m-0 mb-2 text-[1.15rem] font-bold tracking-[-0.01em]", className), ...props, children });
1339
+ return /* @__PURE__ */ jsx("h3", { id: id ?? ctx?.titleId, className: cn("m-0 mb-2 text-[1.15rem] font-bold tracking-[-0.01em] text-foreground", className), ...props, children });
1338
1340
  }
1339
1341
  function ModalDescription({ className, id, ...props }) {
1340
1342
  const ctx = React52.useContext(ModalContext);
@@ -1625,7 +1627,7 @@ function DataTable({
1625
1627
  };
1626
1628
  return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-4 w-full", className), children: [
1627
1629
  toolbar && /* @__PURE__ */ jsx("div", { className: "flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3", children: toolbar }),
1628
- /* @__PURE__ */ jsxs(TableWrap, { className: "relative overflow-hidden", ...props, children: [
1630
+ /* @__PURE__ */ jsxs(TableWrap, { className: "relative overflow-x-auto overflow-y-hidden [scroll-behavior:smooth] [-webkit-overflow-scrolling:touch]", ...props, children: [
1629
1631
  /* @__PURE__ */ jsxs(Table, { children: [
1630
1632
  /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
1631
1633
  isSelectionActive && /* @__PURE__ */ jsx(TableHead, { className: "w-12 px-4 text-center", children: /* @__PURE__ */ jsx("div", { className: "inline-flex items-center justify-center", children: /* @__PURE__ */ jsx(
@@ -3473,7 +3475,7 @@ function isBetweenExclusive(d, lo, hi) {
3473
3475
  return t > startOfDay(lo).getTime() && t < startOfDay(hi).getTime();
3474
3476
  }
3475
3477
  var RangeCalendar = React52.forwardRef(
3476
- function RangeCalendar2({ value, defaultValue, onChange, month, defaultMonth, onMonthChange, min, max, disabledDates, className }, ref) {
3478
+ function RangeCalendar2({ value, defaultValue, onChange, month, defaultMonth, onMonthChange, min, max, disabledDates, singleMonth, className }, ref) {
3477
3479
  const controlled = value !== void 0;
3478
3480
  const [internalValue, setInternalValue] = React52.useState(defaultValue ?? {});
3479
3481
  const range2 = controlled ? value : internalValue;
@@ -3561,12 +3563,13 @@ var RangeCalendar = React52.forwardRef(
3561
3563
  children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", className: "h-4 w-4", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: direction === "prev" ? /* @__PURE__ */ jsx("path", { d: "m15 18-6-6 6-6" }) : /* @__PURE__ */ jsx("path", { d: "m9 18 6-6-6-6" }) })
3562
3564
  }
3563
3565
  );
3564
- return /* @__PURE__ */ jsxs("div", { ref, className: cn("flex gap-6 select-none", className), children: [
3565
- /* @__PURE__ */ jsxs("div", { className: "w-[280px]", children: [
3566
+ const showSingleMonth = singleMonth;
3567
+ return /* @__PURE__ */ jsxs("div", { ref, className: cn("flex flex-col sm:flex-row gap-4 sm:gap-6 select-none max-w-full overflow-hidden", className), children: [
3568
+ /* @__PURE__ */ jsxs("div", { className: "w-full sm:w-[280px]", children: [
3566
3569
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-2", children: [
3567
3570
  navButton("prev"),
3568
3571
  /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-foreground", children: monthLabelFormat.format(leftMonth) }),
3569
- /* @__PURE__ */ jsx("span", { className: "w-[26px]", "aria-hidden": "true" })
3572
+ /* @__PURE__ */ jsx("span", { className: showSingleMonth ? "" : "sm:hidden", children: navButton("next") })
3570
3573
  ] }),
3571
3574
  /* @__PURE__ */ jsx(
3572
3575
  CalendarGrid,
@@ -3580,7 +3583,7 @@ var RangeCalendar = React52.forwardRef(
3580
3583
  }
3581
3584
  )
3582
3585
  ] }),
3583
- /* @__PURE__ */ jsxs("div", { className: "w-[280px]", children: [
3586
+ !showSingleMonth && /* @__PURE__ */ jsxs("div", { className: "hidden sm:block w-[280px]", children: [
3584
3587
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-2", children: [
3585
3588
  /* @__PURE__ */ jsx("span", { className: "w-[26px]", "aria-hidden": "true" }),
3586
3589
  /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-foreground", children: monthLabelFormat.format(rightMonth) }),
@@ -3727,7 +3730,7 @@ var DateRangePicker = React52.forwardRef(
3727
3730
  "div",
3728
3731
  {
3729
3732
  onKeyDown: onPanelKeyDown,
3730
- className: "absolute z-40 top-[calc(100%+6px)] left-0 bg-surface border border-border rounded-kj-md shadow-kj-lg p-3 animate-[kjpop_.12s_ease]",
3733
+ className: "absolute z-40 top-[calc(100%+6px)] left-0 sm:left-auto right-0 sm:right-auto max-w-[calc(100vw-2rem)] bg-surface border border-border rounded-kj-md shadow-kj-lg p-3 animate-[kjpop_.12s_ease]",
3731
3734
  children: /* @__PURE__ */ jsx(RangeCalendar, { value: selected, onChange: handleRangeChange, min, max, disabledDates })
3732
3735
  }
3733
3736
  )
@@ -4210,7 +4213,7 @@ function useStepper({ initialStep = 0, stepsCount }) {
4210
4213
  var StepperContext = React52.createContext(null);
4211
4214
  var StepperItemContext = React52.createContext(null);
4212
4215
  var Stepper = React52.forwardRef(
4213
- ({ value, defaultValue, onValueChange, orientation = "horizontal", linear = true, children, className, ...props }, ref) => {
4216
+ ({ value, defaultValue, onValueChange, orientation = "horizontal", responsive = true, linear = true, children, className, ...props }, ref) => {
4214
4217
  const [localValue, setLocalValue] = React52.useState(defaultValue ?? 0);
4215
4218
  const isControlled = value !== void 0;
4216
4219
  const activeStep = isControlled ? value : localValue;
@@ -4242,6 +4245,7 @@ var Stepper = React52.forwardRef(
4242
4245
  () => ({
4243
4246
  activeStep,
4244
4247
  orientation,
4248
+ responsive,
4245
4249
  linear,
4246
4250
  setStep,
4247
4251
  completedSteps,
@@ -4249,7 +4253,7 @@ var Stepper = React52.forwardRef(
4249
4253
  unregisterStep,
4250
4254
  steps
4251
4255
  }),
4252
- [activeStep, orientation, linear, setStep, completedSteps, registerStep, unregisterStep, steps]
4256
+ [activeStep, orientation, responsive, linear, setStep, completedSteps, registerStep, unregisterStep, steps]
4253
4257
  );
4254
4258
  return /* @__PURE__ */ jsx(StepperContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
4255
4259
  "div",
@@ -4291,16 +4295,15 @@ var StepperList = React52.forwardRef(
4291
4295
  ({ className, children, ...props }, ref) => {
4292
4296
  const ctx = React52.useContext(StepperContext);
4293
4297
  if (!ctx) throw new Error("StepperList must be used within a Stepper");
4298
+ const isResponsiveHorizontal = ctx.orientation === "horizontal" && (ctx.responsive ?? true);
4299
+ const orientationClass = isResponsiveHorizontal ? "flex flex-col sm:flex-row items-start sm:items-center justify-between w-full relative gap-4" : ctx.orientation === "horizontal" ? "flex items-center justify-between w-full relative gap-4" : "flex flex-col items-start gap-6 relative w-full";
4294
4300
  return /* @__PURE__ */ jsx(
4295
4301
  "div",
4296
4302
  {
4297
4303
  ref,
4298
4304
  role: "tablist",
4299
4305
  "aria-orientation": ctx.orientation,
4300
- className: cn(
4301
- ctx.orientation === "horizontal" ? "flex items-center justify-between w-full relative gap-4" : "flex flex-col items-start gap-6 relative w-full",
4302
- className
4303
- ),
4306
+ className: cn(orientationClass, className),
4304
4307
  ...props,
4305
4308
  children
4306
4309
  }
@@ -4318,13 +4321,14 @@ var StepperItem = React52.forwardRef(
4318
4321
  return () => unregisterStep(value);
4319
4322
  }, [value, registerStep, unregisterStep]);
4320
4323
  const isLast = ctx.steps[ctx.steps.length - 1] === value;
4324
+ const isResponsiveHorizontal = ctx.orientation === "horizontal" && (ctx.responsive ?? true);
4321
4325
  return /* @__PURE__ */ jsx(StepperItemContext.Provider, { value: { value, disabled, isLast }, children: /* @__PURE__ */ jsx(
4322
4326
  "div",
4323
4327
  {
4324
4328
  ref,
4325
4329
  className: cn(
4326
4330
  "group relative flex items-center gap-3 z-10",
4327
- ctx.orientation === "vertical" ? "flex items-start w-full" : "",
4331
+ ctx.orientation === "vertical" ? "flex items-start w-full" : isResponsiveHorizontal ? "w-full sm:w-auto items-start sm:items-center" : "",
4328
4332
  className
4329
4333
  ),
4330
4334
  ...props,
@@ -4338,12 +4342,13 @@ var StepperSeparator = React52.forwardRef(
4338
4342
  ({ className, ...props }, ref) => {
4339
4343
  const ctx = React52.useContext(StepperContext);
4340
4344
  if (!ctx) throw new Error("StepperSeparator must be used within a Stepper");
4345
+ const isResponsiveHorizontal = ctx.orientation === "horizontal" && (ctx.responsive ?? true);
4341
4346
  return /* @__PURE__ */ jsx(
4342
4347
  "div",
4343
4348
  {
4344
4349
  ref,
4345
4350
  className: cn(
4346
- ctx.orientation === "horizontal" ? "flex-1 h-[2px] bg-border transition-all duration-300" : "w-[2px] bg-border absolute left-[17px] top-8 bottom-0 -ml-px z-0",
4351
+ isResponsiveHorizontal ? "hidden sm:block flex-1 h-[2px] bg-border transition-all duration-300" : ctx.orientation === "horizontal" ? "flex-1 h-[2px] bg-border transition-all duration-300" : "w-[2px] bg-border absolute left-[17px] top-8 bottom-0 -ml-px z-0",
4347
4352
  className
4348
4353
  ),
4349
4354
  ...props
@@ -4526,6 +4531,16 @@ var AppShellHeader = React52.forwardRef(
4526
4531
  window.addEventListener("keydown", handleKeyDown);
4527
4532
  return () => window.removeEventListener("keydown", handleKeyDown);
4528
4533
  }, [mobileOpen]);
4534
+ React52.useEffect(() => {
4535
+ if (mobileOpen) {
4536
+ document.body.style.overflow = "hidden";
4537
+ } else {
4538
+ document.body.style.overflow = "";
4539
+ }
4540
+ return () => {
4541
+ document.body.style.overflow = "";
4542
+ };
4543
+ }, [mobileOpen]);
4529
4544
  const positionClass = {
4530
4545
  sticky: "sticky top-0 z-40",
4531
4546
  fixed: "fixed top-0 left-0 right-0 z-40",
@@ -4619,7 +4634,7 @@ var AppShellMain = React52.forwardRef(
4619
4634
  "main",
4620
4635
  {
4621
4636
  ref,
4622
- className: cn("flex-1", padded && "px-4 sm:px-6 lg:px-8 py-8 md:py-12", widthClass, className),
4637
+ className: cn("flex-1", padded && "px-4 sm:px-6 lg:px-8 py-4 sm:py-6 md:py-12", widthClass, className),
4623
4638
  ...props,
4624
4639
  children
4625
4640
  }
@@ -4657,6 +4672,7 @@ var AppShell = React52.forwardRef(
4657
4672
  headerVariant = "glass",
4658
4673
  paddedContent = true,
4659
4674
  mobileNav,
4675
+ bottomNav,
4660
4676
  ...props
4661
4677
  }, ref) => {
4662
4678
  return /* @__PURE__ */ jsxs(
@@ -4669,7 +4685,8 @@ var AppShell = React52.forwardRef(
4669
4685
  banner && /* @__PURE__ */ jsx(AppShellBanner, { children: banner }),
4670
4686
  header && /* @__PURE__ */ jsx(AppShellHeader, { variant: headerVariant, position: headerPosition, mobileNav, children: header }),
4671
4687
  /* @__PURE__ */ jsx(AppShellMain, { width: contentWidth, padded: paddedContent, children }),
4672
- footer && /* @__PURE__ */ jsx(AppShellFooter, { children: footer })
4688
+ footer && /* @__PURE__ */ jsx(AppShellFooter, { children: footer }),
4689
+ bottomNav && /* @__PURE__ */ jsx("div", { className: "md:hidden sticky bottom-0 z-30 w-full bg-surface border-t border-border", children: bottomNav })
4673
4690
  ]
4674
4691
  }
4675
4692
  );
@@ -5512,6 +5529,7 @@ function InboxContent({
5512
5529
  viewAllHref,
5513
5530
  viewAllLabel = "View all notifications",
5514
5531
  emptyState,
5532
+ align = "auto",
5515
5533
  width = 360,
5516
5534
  maxHeight = 320,
5517
5535
  className
@@ -5531,6 +5549,11 @@ function InboxContent({
5531
5549
  /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-foreground", children: "All caught up" }),
5532
5550
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-0.5", children: "No new notifications" })
5533
5551
  ] });
5552
+ const alignClass = {
5553
+ start: "left-0 top-[calc(100%+6px)]",
5554
+ end: "right-0 top-[calc(100%+6px)]",
5555
+ auto: "right-0 sm:right-0 left-auto top-[calc(100%+6px)] max-sm:left-1/2 max-sm:-translate-x-1/2"
5556
+ }[align ?? "auto"];
5534
5557
  return /* @__PURE__ */ jsxs(
5535
5558
  "div",
5536
5559
  {
@@ -5538,11 +5561,12 @@ function InboxContent({
5538
5561
  role: "dialog",
5539
5562
  "aria-label": "Notifications",
5540
5563
  tabIndex: -1,
5541
- style: { width },
5564
+ style: { width: typeof width === "number" ? `${width}px` : width },
5542
5565
  className: cn(
5543
- "absolute right-0 top-[calc(100%+6px)] z-40",
5566
+ "absolute z-40 max-w-[calc(100vw-1.5rem)]",
5544
5567
  "bg-surface border border-border rounded-kj-md shadow-kj-lg outline-none",
5545
5568
  "animate-[kjpop_.12s_ease]",
5569
+ alignClass,
5546
5570
  className
5547
5571
  ),
5548
5572
  children: [
@@ -6058,7 +6082,386 @@ function ImageGallery({
6058
6082
  )
6059
6083
  ] });
6060
6084
  }
6085
+ var OFFICIAL_SCRIPT_URL = "https://geowidget.easypack24.net/js/sdk-for-javascript.js";
6086
+ var OFFICIAL_CSS_URL = "https://geowidget.easypack24.net/css/easypack.css";
6087
+ var scriptPromise = null;
6088
+ function useInPostScript(options = {}) {
6089
+ const [isLoaded, setIsLoaded] = useState(() => {
6090
+ if (typeof window === "undefined") return false;
6091
+ return !!(window.customElements?.get("inpost-geowidget") || window.easyPack);
6092
+ });
6093
+ const [error, setError] = useState(null);
6094
+ const scriptUrl = options.customScriptUrl || OFFICIAL_SCRIPT_URL;
6095
+ const cssUrl = options.customCssUrl || OFFICIAL_CSS_URL;
6096
+ useEffect(() => {
6097
+ if (typeof window === "undefined") return;
6098
+ if (window.customElements?.get("inpost-geowidget") || window.easyPack) {
6099
+ return;
6100
+ }
6101
+ let linkTag = document.querySelector(`link[href="${cssUrl}"]`);
6102
+ if (!linkTag) {
6103
+ linkTag = document.createElement("link");
6104
+ linkTag.rel = "stylesheet";
6105
+ linkTag.href = cssUrl;
6106
+ linkTag.type = "text/css";
6107
+ document.head.appendChild(linkTag);
6108
+ }
6109
+ if (!scriptPromise) {
6110
+ scriptPromise = new Promise((resolve, reject) => {
6111
+ let scriptTag = document.querySelector(`script[src="${scriptUrl}"]`);
6112
+ if (!scriptTag) {
6113
+ scriptTag = document.createElement("script");
6114
+ scriptTag.src = scriptUrl;
6115
+ scriptTag.async = true;
6116
+ document.head.appendChild(scriptTag);
6117
+ }
6118
+ scriptTag.addEventListener("load", () => resolve());
6119
+ scriptTag.addEventListener(
6120
+ "error",
6121
+ (err) => reject(err instanceof Error ? err : new Error("Failed to load InPost GeoWidget SDK script"))
6122
+ );
6123
+ });
6124
+ }
6125
+ scriptPromise.then(async () => {
6126
+ if (typeof window !== "undefined" && window.customElements?.whenDefined) {
6127
+ try {
6128
+ await Promise.race([
6129
+ window.customElements.whenDefined("inpost-geowidget"),
6130
+ new Promise((r) => setTimeout(r, 100))
6131
+ ]);
6132
+ } catch {
6133
+ }
6134
+ }
6135
+ setIsLoaded(true);
6136
+ }).catch((err) => {
6137
+ setError(err instanceof Error ? err : new Error(String(err)));
6138
+ });
6139
+ }, [scriptUrl, cssUrl]);
6140
+ return { isLoaded, error };
6141
+ }
6142
+ var MOCK_POINTS = [
6143
+ {
6144
+ name: "WAW01M",
6145
+ address: { line1: "ul. Towarowa 5", line2: "00-838 Warszawa" },
6146
+ address_details: { city: "Warszawa", street: "Towarowa", building_number: "5", post_code: "00-838" },
6147
+ location: { latitude: 52.2297, longitude: 21.0122 },
6148
+ type: ["parcel_locker"],
6149
+ status: "Operating",
6150
+ location_description: "Przy stacji benzynowej BP"
6151
+ },
6152
+ {
6153
+ name: "KRA02N",
6154
+ address: { line1: "ul. Floria\u0144ska 12", line2: "31-021 Krak\xF3w" },
6155
+ address_details: { city: "Krak\xF3w", street: "Floria\u0144ska", building_number: "12", post_code: "31-021" },
6156
+ location: { latitude: 50.0647, longitude: 19.945 },
6157
+ type: ["parcel_locker"],
6158
+ status: "Operating",
6159
+ location_description: "Obok wej\u015Bcia do sklepu"
6160
+ },
6161
+ {
6162
+ name: "GDA03P",
6163
+ address: { line1: "ul. D\u0142uga 8", line2: "80-827 Gda\u0144sk" },
6164
+ address_details: { city: "Gda\u0144sk", street: "D\u0142uga", building_number: "8", post_code: "80-827" },
6165
+ location: { latitude: 54.352, longitude: 18.6466 },
6166
+ type: ["parcel_locker"],
6167
+ status: "Operating",
6168
+ location_description: "R\xF3g ulicy D\u0142ugiej i Tkackiej"
6169
+ },
6170
+ {
6171
+ name: "POZ04S",
6172
+ address: { line1: "ul. P\xF3\u0142wiejska 42", line2: "61-888 Pozna\u0144" },
6173
+ address_details: { city: "Pozna\u0144", street: "P\xF3\u0142wiejska", building_number: "42", post_code: "61-888" },
6174
+ location: { latitude: 52.4064, longitude: 16.9252 },
6175
+ type: ["parcel_locker"],
6176
+ status: "Operating",
6177
+ location_description: "Przy centrum handlowym Stary Browar"
6178
+ }
6179
+ ];
6180
+ var InPostGeowidget = ({
6181
+ token,
6182
+ language = "pl",
6183
+ config = "parcelCollect",
6184
+ sandbox = false,
6185
+ onPointSelect,
6186
+ onReady,
6187
+ onError,
6188
+ className,
6189
+ style,
6190
+ customScriptUrl,
6191
+ customCssUrl
6192
+ }) => {
6193
+ const { isLoaded, error } = useInPostScript({
6194
+ customScriptUrl,
6195
+ customCssUrl
6196
+ });
6197
+ const [searchQuery, setSearchQuery] = useState("");
6198
+ const [selectedMock, setSelectedMock] = useState(null);
6199
+ const widgetRef = useRef(null);
6200
+ const callbackNameRef = useRef(`inpost_cb_${Math.random().toString(36).substring(2, 9)}`);
6201
+ useEffect(() => {
6202
+ if (error && onError) {
6203
+ onError(error);
6204
+ }
6205
+ }, [error, onError]);
6206
+ useEffect(() => {
6207
+ if (isLoaded && onReady) {
6208
+ onReady();
6209
+ }
6210
+ }, [isLoaded, onReady]);
6211
+ useEffect(() => {
6212
+ if (!token) return;
6213
+ const cbName = callbackNameRef.current;
6214
+ window[cbName] = (point) => {
6215
+ if (onPointSelect) {
6216
+ onPointSelect(point);
6217
+ }
6218
+ };
6219
+ const el = widgetRef.current;
6220
+ const handlePointSelect = (event) => {
6221
+ const customEv = event;
6222
+ const point = customEv.detail || customEv.point;
6223
+ if (point && onPointSelect) {
6224
+ onPointSelect(point);
6225
+ }
6226
+ };
6227
+ if (el) {
6228
+ el.addEventListener("inpostgeowidget", handlePointSelect);
6229
+ el.addEventListener("onpointselect", handlePointSelect);
6230
+ }
6231
+ document.addEventListener("onpointselect", handlePointSelect);
6232
+ return () => {
6233
+ delete window[cbName];
6234
+ if (el) {
6235
+ el.removeEventListener("inpostgeowidget", handlePointSelect);
6236
+ el.removeEventListener("onpointselect", handlePointSelect);
6237
+ }
6238
+ document.removeEventListener("onpointselect", handlePointSelect);
6239
+ };
6240
+ }, [onPointSelect, isLoaded, token]);
6241
+ if (error) {
6242
+ return /* @__PURE__ */ jsxs(
6243
+ "div",
6244
+ {
6245
+ className: `flex flex-col items-center justify-center min-h-[450px] bg-danger/10 border-2 border-danger rounded-xl p-6 text-center ${className || ""}`,
6246
+ style,
6247
+ children: [
6248
+ /* @__PURE__ */ jsx("p", { className: "text-base font-extrabold text-danger mb-1", children: "B\u0142\u0105d \u0142adowania Geowidget InPost" }),
6249
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground font-semibold max-w-sm", children: "Nie uda\u0142o si\u0119 pobra\u0107 skryptu mapy z serwera InPost. Sprawd\u017A po\u0142\u0105czenie z sieci\u0105." })
6250
+ ]
6251
+ }
6252
+ );
6253
+ }
6254
+ if (!token) {
6255
+ const filteredPoints = MOCK_POINTS.filter(
6256
+ (p) => p.name.toLowerCase().includes(searchQuery.toLowerCase()) || p.address.line1.toLowerCase().includes(searchQuery.toLowerCase()) || p.address_details.city.toLowerCase().includes(searchQuery.toLowerCase())
6257
+ );
6258
+ return /* @__PURE__ */ jsxs(
6259
+ "div",
6260
+ {
6261
+ className: `flex flex-col h-full min-h-[500px] bg-surface border-2 border-border rounded-xl p-4 font-sans text-foreground ${className || ""}`,
6262
+ style,
6263
+ children: [
6264
+ /* @__PURE__ */ jsxs("div", { className: "bg-gradient-to-r from-amber-400 via-amber-500 to-yellow-500 text-slate-950 rounded-xl p-4 mb-3.5 shadow-sm flex flex-col gap-1 border border-amber-600/30", children: [
6265
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
6266
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
6267
+ /* @__PURE__ */ jsx("span", { className: "w-2.5 h-2.5 rounded-full bg-slate-950 animate-pulse" }),
6268
+ /* @__PURE__ */ jsx("span", { className: "font-black text-sm tracking-tight uppercase", children: "InPost Paczkomat\xAE" })
6269
+ ] }),
6270
+ /* @__PURE__ */ jsx("span", { className: "text-[0.7rem] font-black bg-slate-950 text-amber-400 px-2.5 py-0.5 rounded-md uppercase tracking-wider shadow-sm", children: "Tryb Pokazowy" })
6271
+ ] }),
6272
+ /* @__PURE__ */ jsxs("p", { className: "text-xs text-slate-950 font-bold leading-relaxed opacity-95", children: [
6273
+ "Wybierz punkt z listy poni\u017Cej. Do za\u0142adowania produkcyjnej mapy przeka\u017C prop ",
6274
+ /* @__PURE__ */ jsx("code", { className: "bg-slate-950 text-amber-400 px-1.5 py-0.5 rounded font-mono text-[0.72rem] font-black", children: 'token="TWOJ_TOKEN"' }),
6275
+ "."
6276
+ ] })
6277
+ ] }),
6278
+ /* @__PURE__ */ jsx("div", { className: "mb-3.5 relative", children: /* @__PURE__ */ jsx(
6279
+ "input",
6280
+ {
6281
+ type: "text",
6282
+ placeholder: "Szukaj Paczkomatu (np. Warszawa, WAW01M, Towarowa)...",
6283
+ value: searchQuery,
6284
+ onChange: (e) => setSearchQuery(e.target.value),
6285
+ className: "w-full px-4 py-2.5 text-sm bg-surface border-2 border-border rounded-xl outline-none text-foreground placeholder:text-muted-foreground font-bold focus:border-primary focus:ring-2 focus:ring-primary/20 shadow-sm transition-all"
6286
+ }
6287
+ ) }),
6288
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto space-y-3 pr-1 max-h-[420px]", children: filteredPoints.map((p) => {
6289
+ const isSelected = selectedMock?.name === p.name;
6290
+ return /* @__PURE__ */ jsxs(
6291
+ "div",
6292
+ {
6293
+ onClick: () => {
6294
+ setSelectedMock(p);
6295
+ if (onPointSelect) {
6296
+ onPointSelect(p);
6297
+ }
6298
+ },
6299
+ className: `p-4 rounded-xl border-2 transition-all cursor-pointer flex items-center justify-between gap-3 ${isSelected ? "bg-primary text-primary-foreground border-primary shadow-md" : "bg-surface border-border hover:border-primary hover:shadow-md text-foreground"}`,
6300
+ children: [
6301
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 min-w-0", children: [
6302
+ /* @__PURE__ */ jsxs("div", { className: "font-black text-base flex items-center gap-2", children: [
6303
+ /* @__PURE__ */ jsxs("span", { className: isSelected ? "text-primary-foreground font-black" : "text-foreground font-black", children: [
6304
+ "Paczkomat\xAE ",
6305
+ p.name
6306
+ ] }),
6307
+ p.location_description && /* @__PURE__ */ jsx("span", { className: `text-[0.72rem] px-2.5 py-0.5 rounded-full font-bold ${isSelected ? "bg-primary-hover text-primary-foreground" : "bg-muted text-primary"}`, children: p.location_description })
6308
+ ] }),
6309
+ /* @__PURE__ */ jsxs("div", { className: `text-xs font-bold ${isSelected ? "text-primary-foreground/90" : "text-muted-foreground"}`, children: [
6310
+ p.address.line1,
6311
+ ", ",
6312
+ p.address.line2
6313
+ ] })
6314
+ ] }),
6315
+ /* @__PURE__ */ jsx(
6316
+ "button",
6317
+ {
6318
+ type: "button",
6319
+ className: `px-4 py-2 rounded-lg text-xs font-black shrink-0 transition-all shadow-sm ${isSelected ? "bg-amber-400 text-slate-950 border border-amber-500" : "bg-primary hover:bg-primary-hover text-primary-foreground"}`,
6320
+ children: isSelected ? "Wybrano \u2713" : "Wybierz"
6321
+ }
6322
+ )
6323
+ ]
6324
+ },
6325
+ p.name
6326
+ );
6327
+ }) })
6328
+ ]
6329
+ }
6330
+ );
6331
+ }
6332
+ if (!isLoaded) {
6333
+ return /* @__PURE__ */ jsx(
6334
+ "div",
6335
+ {
6336
+ className: `flex items-center justify-center min-h-[450px] bg-surface border-2 border-border rounded-xl p-6 ${className || ""}`,
6337
+ style,
6338
+ children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3 text-muted-foreground", children: [
6339
+ /* @__PURE__ */ jsx("div", { className: "w-9 h-9 border-4 border-primary border-t-transparent rounded-full animate-spin" }),
6340
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-extrabold text-foreground", children: "\u0141adowanie mapy InPost GeoWidget..." })
6341
+ ] })
6342
+ }
6343
+ );
6344
+ }
6345
+ const widgetProps = {
6346
+ language,
6347
+ config: String(config).toLowerCase(),
6348
+ // eslint-disable-next-line react-hooks/refs
6349
+ onpointselect: callbackNameRef.current
6350
+ };
6351
+ if (token) {
6352
+ widgetProps.token = token;
6353
+ }
6354
+ if (sandbox) {
6355
+ widgetProps.sandbox = "true";
6356
+ }
6357
+ return /* @__PURE__ */ jsx("div", { className: `w-full h-full min-h-[450px] relative ${className || ""}`, style, children: React52__default.createElement("inpost-geowidget", {
6358
+ ref: widgetRef,
6359
+ ...widgetProps,
6360
+ style: { width: "100%", height: "100%", display: "block", minHeight: "450px" }
6361
+ }) });
6362
+ };
6363
+ var InPostGeowidgetModal = ({
6364
+ value,
6365
+ onSelect,
6366
+ triggerText = "Wybierz Paczkomat\xAE",
6367
+ modalTitle = "Wybierz punkt odbioru InPost",
6368
+ disabled = false,
6369
+ open: controlledOpen,
6370
+ onOpenChange,
6371
+ showSelectedBadge = true,
6372
+ className = "",
6373
+ buttonVariant = "outline",
6374
+ buttonSize = "md",
6375
+ token,
6376
+ language,
6377
+ config,
6378
+ sandbox,
6379
+ customScriptUrl,
6380
+ customCssUrl
6381
+ }) => {
6382
+ const [internalOpen, setInternalOpen] = useState(false);
6383
+ const [selectedPoint, setSelectedPoint] = useState(
6384
+ typeof value === "object" && value ? value : null
6385
+ );
6386
+ const isControlled = controlledOpen !== void 0;
6387
+ const isOpen = isControlled ? controlledOpen : internalOpen;
6388
+ const handleOpenToggle = (newOpen) => {
6389
+ if (!isControlled) {
6390
+ setInternalOpen(newOpen);
6391
+ }
6392
+ if (onOpenChange) {
6393
+ onOpenChange(newOpen);
6394
+ }
6395
+ };
6396
+ const handlePointSelect = (point) => {
6397
+ setSelectedPoint(point);
6398
+ if (onSelect) {
6399
+ onSelect(point);
6400
+ }
6401
+ handleOpenToggle(false);
6402
+ };
6403
+ const selectedCode = selectedPoint?.name || (typeof value === "string" ? value : null);
6404
+ const selectedAddress = selectedPoint ? `${selectedPoint.address?.line1 || ""}, ${selectedPoint.address?.line2 || ""}` : null;
6405
+ const isOutline = buttonVariant === "outline";
6406
+ return /* @__PURE__ */ jsxs("div", { className: `inline-flex flex-col gap-3 min-w-[280px] ${className}`, children: [
6407
+ /* @__PURE__ */ jsxs(
6408
+ Button,
6409
+ {
6410
+ type: "button",
6411
+ variant: buttonVariant,
6412
+ size: buttonSize,
6413
+ disabled,
6414
+ onClick: () => handleOpenToggle(true),
6415
+ className: `group w-full justify-between gap-4 text-left font-bold shadow-sm hover:shadow-md transition-all py-2.5 px-3.5 rounded-xl ${isOutline ? "bg-surface hover:bg-muted text-foreground border-2 border-border hover:border-primary" : "border-2 border-transparent"}`,
6416
+ children: [
6417
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2.5 min-w-0", children: [
6418
+ /* @__PURE__ */ jsx("span", { className: "font-black text-[0.7rem] bg-amber-400 text-slate-950 px-2.5 py-1 rounded-md shadow-sm tracking-tight uppercase border border-amber-500/40 shrink-0 group-hover:scale-105 transition-transform", children: "InPost" }),
6419
+ /* @__PURE__ */ jsx("span", { className: `truncate font-bold text-sm ${isOutline ? "text-foreground group-hover:text-primary" : ""}`, children: selectedCode ? `Paczkomat\xAE ${selectedCode}` : triggerText })
6420
+ ] }),
6421
+ /* @__PURE__ */ jsx(
6422
+ "span",
6423
+ {
6424
+ className: `text-xs font-black px-2.5 py-1 rounded-md shrink-0 shadow-sm uppercase tracking-wide transition-all ${isOutline ? "bg-primary text-primary-foreground group-hover:bg-primary-hover" : "bg-amber-400 text-slate-950"}`,
6425
+ children: selectedCode ? "Zmie\u0144" : "Wybierz"
6426
+ }
6427
+ )
6428
+ ]
6429
+ }
6430
+ ),
6431
+ showSelectedBadge && selectedCode && /* @__PURE__ */ jsxs("div", { className: "text-xs bg-surface text-foreground border-2 border-border p-3.5 rounded-xl flex flex-col gap-1.5 shadow-md", children: [
6432
+ /* @__PURE__ */ jsxs("div", { className: "font-bold flex items-center justify-between gap-2", children: [
6433
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 text-foreground", children: [
6434
+ /* @__PURE__ */ jsx("span", { className: "w-2.5 h-2.5 rounded-full bg-primary shadow-sm animate-pulse" }),
6435
+ /* @__PURE__ */ jsxs("span", { className: "font-black text-sm text-primary", children: [
6436
+ "Paczkomat\xAE ",
6437
+ selectedCode
6438
+ ] })
6439
+ ] }),
6440
+ /* @__PURE__ */ jsx("span", { className: "text-[0.65rem] bg-amber-400 text-slate-950 font-black px-2 py-0.5 rounded uppercase tracking-wider", children: "Wybrany" })
6441
+ ] }),
6442
+ selectedAddress && /* @__PURE__ */ jsx("div", { className: "text-muted-foreground text-[0.78rem] font-medium pl-4 border-l-2 border-border", children: selectedAddress })
6443
+ ] }),
6444
+ /* @__PURE__ */ jsxs(Modal, { open: isOpen, onClose: () => handleOpenToggle(false), width: 850, children: [
6445
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 pb-3.5 border-b border-border", children: [
6446
+ /* @__PURE__ */ jsx("span", { className: "font-black text-xs bg-amber-400 text-slate-950 px-2.5 py-1 rounded-md shadow-sm tracking-tight uppercase border border-amber-500/40 shrink-0", children: "InPost" }),
6447
+ /* @__PURE__ */ jsx(ModalTitle, { className: "m-0 text-xl font-black text-primary tracking-tight", children: modalTitle })
6448
+ ] }),
6449
+ /* @__PURE__ */ jsx("div", { className: "w-full h-[600px] min-h-[500px] mt-3.5 rounded-xl overflow-hidden", children: isOpen && /* @__PURE__ */ jsx(
6450
+ InPostGeowidget,
6451
+ {
6452
+ token,
6453
+ language,
6454
+ config,
6455
+ sandbox,
6456
+ customScriptUrl,
6457
+ customCssUrl,
6458
+ onPointSelect: handlePointSelect
6459
+ }
6460
+ ) })
6461
+ ] })
6462
+ ] });
6463
+ };
6061
6464
 
6062
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AppShell, AppShellBanner, AppShellFooter, AppShellHeader, AppShellMain, Avatar, AvatarGroup, Badge, BlogCard, BottomNavigation, BottomSheet, BottomSheetContent, BottomSheetDescription, BottomSheetFooter, BottomSheetHeader, BottomSheetTitle, Breadcrumb, BreadcrumbItem, BreadcrumbSeparator, Button, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CheckboxField, CodeBlock, ColorPicker, ColorPickerField, ColorPickerSwatch, Combobox, ComboboxField, CommandPalette, ConfirmDialog, DEFAULT_COLOR_SWATCHES, DashboardShell, DataTable, DatePicker, DatePickerField, DateRangePicker, DateRangePickerField, DetailPageLayout, Drawer, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, Dropzone, EmptyState, ErrorState, Fab, Field, FileUpload, FileUploadField, FormField, Hint, ImageGallery, InboxContent, InboxPopover, InboxTrigger, Input, Kbd, Label, MetricCard, Modal, ModalActions, ModalDescription, ModalTitle, NotificationItem, PageHeader, Pagination, Popover, PopoverContent, PopoverTrigger, PricingCard, Progress, ProgressRing, ProgressRingField, ProjectCard, Radio, RangeCalendar, Rating, RatingField, RatingSummary, SectionHeader, Segmented, Select, SelectField, Separator, SettingsLayout, SidebarNav, Skeleton, Slider, Spinner, Stat, Stepper, StepperContent, StepperDescription, StepperIndicator, StepperItem, StepperList, StepperSeparator, StepperTitle, StepperTrigger, Switch, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, TableToolbar, TableWrap, Tabs, TabsContent, TabsList, TabsTrigger, TextField, Textarea, Timeline, TimelineConnector, TimelineContent, TimelineDot, TimelineItem, TimelineSeparator, TimelineTime, TimelineTitle, ToastProvider, ToggleGroup, Tooltip, badgeVariants, buttonVariants, cn, formatRelativeTime, hexToHsl, hslToHex, isValidHex, normalizeHex, sliderThumbCSS, useInboxState, useStepper, useToast };
6465
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AppShell, AppShellBanner, AppShellFooter, AppShellHeader, AppShellMain, Avatar, AvatarGroup, Badge, BlogCard, BottomNavigation, BottomSheet, BottomSheetContent, BottomSheetDescription, BottomSheetFooter, BottomSheetHeader, BottomSheetTitle, Breadcrumb, BreadcrumbItem, BreadcrumbSeparator, Button, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CheckboxField, CodeBlock, ColorPicker, ColorPickerField, ColorPickerSwatch, Combobox, ComboboxField, CommandPalette, ConfirmDialog, DEFAULT_COLOR_SWATCHES, DashboardShell, DataTable, DatePicker, DatePickerField, DateRangePicker, DateRangePickerField, DetailPageLayout, Drawer, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, Dropzone, EmptyState, ErrorState, Fab, Field, FileUpload, FileUploadField, FormField, Hint, ImageGallery, InPostGeowidget, InPostGeowidgetModal, InboxContent, InboxPopover, InboxTrigger, Input, Kbd, Label, MetricCard, Modal, ModalActions, ModalDescription, ModalTitle, NotificationItem, PageHeader, Pagination, Popover, PopoverContent, PopoverTrigger, PricingCard, Progress, ProgressRing, ProgressRingField, ProjectCard, Radio, RangeCalendar, Rating, RatingField, RatingSummary, SectionHeader, Segmented, Select, SelectField, Separator, SettingsLayout, SidebarNav, Skeleton, Slider, Spinner, Stat, Stepper, StepperContent, StepperDescription, StepperIndicator, StepperItem, StepperList, StepperSeparator, StepperTitle, StepperTrigger, Switch, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, TableToolbar, TableWrap, Tabs, TabsContent, TabsList, TabsTrigger, TextField, Textarea, Timeline, TimelineConnector, TimelineContent, TimelineDot, TimelineItem, TimelineSeparator, TimelineTime, TimelineTitle, ToastProvider, ToggleGroup, Tooltip, badgeVariants, buttonVariants, cn, formatRelativeTime, hexToHsl, hslToHex, isValidHex, normalizeHex, sliderThumbCSS, useInPostScript, useInboxState, useStepper, useToast };
6063
6466
  //# sourceMappingURL=index.js.map
6064
6467
  //# sourceMappingURL=index.js.map