@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/README.md CHANGED
@@ -20,6 +20,8 @@ Runtime deps: `class-variance-authority`, `clsx`, `tailwind-merge`.
20
20
  In your app's global stylesheet, import the design tokens (Tailwind v4 `@theme`) and the small runtime stylesheet that ships keyframes + the slider thumb:
21
21
 
22
22
  ```css
23
+ @import "tailwindcss";
24
+ @source "../node_modules/@kjaniec-dev/ui";
23
25
  @import "@kjaniec-dev/design/tailwind.css";
24
26
  @import "@kjaniec-dev/ui/ui.css";
25
27
  ```
package/dist/index.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  'use strict';
2
3
 
3
4
  var clsx = require('clsx');
@@ -1177,7 +1178,7 @@ var BottomNavigation = React52__namespace.forwardRef(
1177
1178
  );
1178
1179
  BottomNavigation.displayName = "BottomNavigation";
1179
1180
  var TableWrap = React52__namespace.forwardRef(
1180
- ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("border border-border rounded-kj-lg overflow-x-auto w-full", className), ...props })
1181
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("w-full max-w-full overflow-x-auto border border-border rounded-kj-lg", className), ...props })
1181
1182
  );
1182
1183
  TableWrap.displayName = "TableWrap";
1183
1184
  var Table = React52__namespace.forwardRef(
@@ -1332,7 +1333,7 @@ function Modal({ open, onClose, children, width = 440, className, showClose = tr
1332
1333
  tabIndex: -1,
1333
1334
  style: { maxWidth: width },
1334
1335
  className: cn(
1335
- "relative w-full p-7 rounded-kj-2xl bg-surface border border-border shadow-kj-lg transition-transform duration-200 outline-none",
1336
+ "relative w-full p-7 rounded-kj-2xl bg-surface text-foreground border border-border shadow-kj-lg transition-transform duration-200 outline-none",
1336
1337
  open ? "scale-100 translate-y-0" : "scale-95 translate-y-2",
1337
1338
  className
1338
1339
  ),
@@ -1356,7 +1357,7 @@ function Modal({ open, onClose, children, width = 440, className, showClose = tr
1356
1357
  }
1357
1358
  function ModalTitle({ className, id, children, ...props }) {
1358
1359
  const ctx = React52__namespace.useContext(ModalContext);
1359
- return /* @__PURE__ */ jsxRuntime.jsx("h3", { id: id ?? ctx?.titleId, className: cn("m-0 mb-2 text-[1.15rem] font-bold tracking-[-0.01em]", className), ...props, children });
1360
+ return /* @__PURE__ */ jsxRuntime.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 });
1360
1361
  }
1361
1362
  function ModalDescription({ className, id, ...props }) {
1362
1363
  const ctx = React52__namespace.useContext(ModalContext);
@@ -1647,7 +1648,7 @@ function DataTable({
1647
1648
  };
1648
1649
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col gap-4 w-full", className), children: [
1649
1650
  toolbar && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3", children: toolbar }),
1650
- /* @__PURE__ */ jsxRuntime.jsxs(TableWrap, { className: "relative overflow-hidden", ...props, children: [
1651
+ /* @__PURE__ */ jsxRuntime.jsxs(TableWrap, { className: "relative overflow-x-auto overflow-y-hidden [scroll-behavior:smooth] [-webkit-overflow-scrolling:touch]", ...props, children: [
1651
1652
  /* @__PURE__ */ jsxRuntime.jsxs(Table, { children: [
1652
1653
  /* @__PURE__ */ jsxRuntime.jsx(TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { children: [
1653
1654
  isSelectionActive && /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "w-12 px-4 text-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -3495,7 +3496,7 @@ function isBetweenExclusive(d, lo, hi) {
3495
3496
  return t > startOfDay(lo).getTime() && t < startOfDay(hi).getTime();
3496
3497
  }
3497
3498
  var RangeCalendar = React52__namespace.forwardRef(
3498
- function RangeCalendar2({ value, defaultValue, onChange, month, defaultMonth, onMonthChange, min, max, disabledDates, className }, ref) {
3499
+ function RangeCalendar2({ value, defaultValue, onChange, month, defaultMonth, onMonthChange, min, max, disabledDates, singleMonth, className }, ref) {
3499
3500
  const controlled = value !== void 0;
3500
3501
  const [internalValue, setInternalValue] = React52__namespace.useState(defaultValue ?? {});
3501
3502
  const range2 = controlled ? value : internalValue;
@@ -3583,12 +3584,13 @@ var RangeCalendar = React52__namespace.forwardRef(
3583
3584
  children: /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx("path", { d: "m15 18-6-6 6-6" }) : /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m9 18 6-6-6-6" }) })
3584
3585
  }
3585
3586
  );
3586
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: cn("flex gap-6 select-none", className), children: [
3587
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-[280px]", children: [
3587
+ const showSingleMonth = singleMonth;
3588
+ return /* @__PURE__ */ jsxRuntime.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: [
3589
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full sm:w-[280px]", children: [
3588
3590
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
3589
3591
  navButton("prev"),
3590
3592
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-foreground", children: monthLabelFormat.format(leftMonth) }),
3591
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-[26px]", "aria-hidden": "true" })
3593
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: showSingleMonth ? "" : "sm:hidden", children: navButton("next") })
3592
3594
  ] }),
3593
3595
  /* @__PURE__ */ jsxRuntime.jsx(
3594
3596
  CalendarGrid,
@@ -3602,7 +3604,7 @@ var RangeCalendar = React52__namespace.forwardRef(
3602
3604
  }
3603
3605
  )
3604
3606
  ] }),
3605
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-[280px]", children: [
3607
+ !showSingleMonth && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "hidden sm:block w-[280px]", children: [
3606
3608
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
3607
3609
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-[26px]", "aria-hidden": "true" }),
3608
3610
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-foreground", children: monthLabelFormat.format(rightMonth) }),
@@ -3749,7 +3751,7 @@ var DateRangePicker = React52__namespace.forwardRef(
3749
3751
  "div",
3750
3752
  {
3751
3753
  onKeyDown: onPanelKeyDown,
3752
- 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]",
3754
+ 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]",
3753
3755
  children: /* @__PURE__ */ jsxRuntime.jsx(RangeCalendar, { value: selected, onChange: handleRangeChange, min, max, disabledDates })
3754
3756
  }
3755
3757
  )
@@ -4232,7 +4234,7 @@ function useStepper({ initialStep = 0, stepsCount }) {
4232
4234
  var StepperContext = React52__namespace.createContext(null);
4233
4235
  var StepperItemContext = React52__namespace.createContext(null);
4234
4236
  var Stepper = React52__namespace.forwardRef(
4235
- ({ value, defaultValue, onValueChange, orientation = "horizontal", linear = true, children, className, ...props }, ref) => {
4237
+ ({ value, defaultValue, onValueChange, orientation = "horizontal", responsive = true, linear = true, children, className, ...props }, ref) => {
4236
4238
  const [localValue, setLocalValue] = React52__namespace.useState(defaultValue ?? 0);
4237
4239
  const isControlled = value !== void 0;
4238
4240
  const activeStep = isControlled ? value : localValue;
@@ -4264,6 +4266,7 @@ var Stepper = React52__namespace.forwardRef(
4264
4266
  () => ({
4265
4267
  activeStep,
4266
4268
  orientation,
4269
+ responsive,
4267
4270
  linear,
4268
4271
  setStep,
4269
4272
  completedSteps,
@@ -4271,7 +4274,7 @@ var Stepper = React52__namespace.forwardRef(
4271
4274
  unregisterStep,
4272
4275
  steps
4273
4276
  }),
4274
- [activeStep, orientation, linear, setStep, completedSteps, registerStep, unregisterStep, steps]
4277
+ [activeStep, orientation, responsive, linear, setStep, completedSteps, registerStep, unregisterStep, steps]
4275
4278
  );
4276
4279
  return /* @__PURE__ */ jsxRuntime.jsx(StepperContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(
4277
4280
  "div",
@@ -4313,16 +4316,15 @@ var StepperList = React52__namespace.forwardRef(
4313
4316
  ({ className, children, ...props }, ref) => {
4314
4317
  const ctx = React52__namespace.useContext(StepperContext);
4315
4318
  if (!ctx) throw new Error("StepperList must be used within a Stepper");
4319
+ const isResponsiveHorizontal = ctx.orientation === "horizontal" && (ctx.responsive ?? true);
4320
+ 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";
4316
4321
  return /* @__PURE__ */ jsxRuntime.jsx(
4317
4322
  "div",
4318
4323
  {
4319
4324
  ref,
4320
4325
  role: "tablist",
4321
4326
  "aria-orientation": ctx.orientation,
4322
- className: cn(
4323
- ctx.orientation === "horizontal" ? "flex items-center justify-between w-full relative gap-4" : "flex flex-col items-start gap-6 relative w-full",
4324
- className
4325
- ),
4327
+ className: cn(orientationClass, className),
4326
4328
  ...props,
4327
4329
  children
4328
4330
  }
@@ -4340,13 +4342,14 @@ var StepperItem = React52__namespace.forwardRef(
4340
4342
  return () => unregisterStep(value);
4341
4343
  }, [value, registerStep, unregisterStep]);
4342
4344
  const isLast = ctx.steps[ctx.steps.length - 1] === value;
4345
+ const isResponsiveHorizontal = ctx.orientation === "horizontal" && (ctx.responsive ?? true);
4343
4346
  return /* @__PURE__ */ jsxRuntime.jsx(StepperItemContext.Provider, { value: { value, disabled, isLast }, children: /* @__PURE__ */ jsxRuntime.jsx(
4344
4347
  "div",
4345
4348
  {
4346
4349
  ref,
4347
4350
  className: cn(
4348
4351
  "group relative flex items-center gap-3 z-10",
4349
- ctx.orientation === "vertical" ? "flex items-start w-full" : "",
4352
+ ctx.orientation === "vertical" ? "flex items-start w-full" : isResponsiveHorizontal ? "w-full sm:w-auto items-start sm:items-center" : "",
4350
4353
  className
4351
4354
  ),
4352
4355
  ...props,
@@ -4360,12 +4363,13 @@ var StepperSeparator = React52__namespace.forwardRef(
4360
4363
  ({ className, ...props }, ref) => {
4361
4364
  const ctx = React52__namespace.useContext(StepperContext);
4362
4365
  if (!ctx) throw new Error("StepperSeparator must be used within a Stepper");
4366
+ const isResponsiveHorizontal = ctx.orientation === "horizontal" && (ctx.responsive ?? true);
4363
4367
  return /* @__PURE__ */ jsxRuntime.jsx(
4364
4368
  "div",
4365
4369
  {
4366
4370
  ref,
4367
4371
  className: cn(
4368
- 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",
4372
+ 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",
4369
4373
  className
4370
4374
  ),
4371
4375
  ...props
@@ -4548,6 +4552,16 @@ var AppShellHeader = React52__namespace.forwardRef(
4548
4552
  window.addEventListener("keydown", handleKeyDown);
4549
4553
  return () => window.removeEventListener("keydown", handleKeyDown);
4550
4554
  }, [mobileOpen]);
4555
+ React52__namespace.useEffect(() => {
4556
+ if (mobileOpen) {
4557
+ document.body.style.overflow = "hidden";
4558
+ } else {
4559
+ document.body.style.overflow = "";
4560
+ }
4561
+ return () => {
4562
+ document.body.style.overflow = "";
4563
+ };
4564
+ }, [mobileOpen]);
4551
4565
  const positionClass = {
4552
4566
  sticky: "sticky top-0 z-40",
4553
4567
  fixed: "fixed top-0 left-0 right-0 z-40",
@@ -4641,7 +4655,7 @@ var AppShellMain = React52__namespace.forwardRef(
4641
4655
  "main",
4642
4656
  {
4643
4657
  ref,
4644
- className: cn("flex-1", padded && "px-4 sm:px-6 lg:px-8 py-8 md:py-12", widthClass, className),
4658
+ className: cn("flex-1", padded && "px-4 sm:px-6 lg:px-8 py-4 sm:py-6 md:py-12", widthClass, className),
4645
4659
  ...props,
4646
4660
  children
4647
4661
  }
@@ -4679,6 +4693,7 @@ var AppShell = React52__namespace.forwardRef(
4679
4693
  headerVariant = "glass",
4680
4694
  paddedContent = true,
4681
4695
  mobileNav,
4696
+ bottomNav,
4682
4697
  ...props
4683
4698
  }, ref) => {
4684
4699
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -4691,7 +4706,8 @@ var AppShell = React52__namespace.forwardRef(
4691
4706
  banner && /* @__PURE__ */ jsxRuntime.jsx(AppShellBanner, { children: banner }),
4692
4707
  header && /* @__PURE__ */ jsxRuntime.jsx(AppShellHeader, { variant: headerVariant, position: headerPosition, mobileNav, children: header }),
4693
4708
  /* @__PURE__ */ jsxRuntime.jsx(AppShellMain, { width: contentWidth, padded: paddedContent, children }),
4694
- footer && /* @__PURE__ */ jsxRuntime.jsx(AppShellFooter, { children: footer })
4709
+ footer && /* @__PURE__ */ jsxRuntime.jsx(AppShellFooter, { children: footer }),
4710
+ bottomNav && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "md:hidden sticky bottom-0 z-30 w-full bg-surface border-t border-border", children: bottomNav })
4695
4711
  ]
4696
4712
  }
4697
4713
  );
@@ -5534,6 +5550,7 @@ function InboxContent({
5534
5550
  viewAllHref,
5535
5551
  viewAllLabel = "View all notifications",
5536
5552
  emptyState,
5553
+ align = "auto",
5537
5554
  width = 360,
5538
5555
  maxHeight = 320,
5539
5556
  className
@@ -5553,6 +5570,11 @@ function InboxContent({
5553
5570
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-foreground", children: "All caught up" }),
5554
5571
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mt-0.5", children: "No new notifications" })
5555
5572
  ] });
5573
+ const alignClass = {
5574
+ start: "left-0 top-[calc(100%+6px)]",
5575
+ end: "right-0 top-[calc(100%+6px)]",
5576
+ auto: "right-0 sm:right-0 left-auto top-[calc(100%+6px)] max-sm:left-1/2 max-sm:-translate-x-1/2"
5577
+ }[align ?? "auto"];
5556
5578
  return /* @__PURE__ */ jsxRuntime.jsxs(
5557
5579
  "div",
5558
5580
  {
@@ -5560,11 +5582,12 @@ function InboxContent({
5560
5582
  role: "dialog",
5561
5583
  "aria-label": "Notifications",
5562
5584
  tabIndex: -1,
5563
- style: { width },
5585
+ style: { width: typeof width === "number" ? `${width}px` : width },
5564
5586
  className: cn(
5565
- "absolute right-0 top-[calc(100%+6px)] z-40",
5587
+ "absolute z-40 max-w-[calc(100vw-1.5rem)]",
5566
5588
  "bg-surface border border-border rounded-kj-md shadow-kj-lg outline-none",
5567
5589
  "animate-[kjpop_.12s_ease]",
5590
+ alignClass,
5568
5591
  className
5569
5592
  ),
5570
5593
  children: [
@@ -6080,6 +6103,385 @@ function ImageGallery({
6080
6103
  )
6081
6104
  ] });
6082
6105
  }
6106
+ var OFFICIAL_SCRIPT_URL = "https://geowidget.easypack24.net/js/sdk-for-javascript.js";
6107
+ var OFFICIAL_CSS_URL = "https://geowidget.easypack24.net/css/easypack.css";
6108
+ var scriptPromise = null;
6109
+ function useInPostScript(options = {}) {
6110
+ const [isLoaded, setIsLoaded] = React52.useState(() => {
6111
+ if (typeof window === "undefined") return false;
6112
+ return !!(window.customElements?.get("inpost-geowidget") || window.easyPack);
6113
+ });
6114
+ const [error, setError] = React52.useState(null);
6115
+ const scriptUrl = options.customScriptUrl || OFFICIAL_SCRIPT_URL;
6116
+ const cssUrl = options.customCssUrl || OFFICIAL_CSS_URL;
6117
+ React52.useEffect(() => {
6118
+ if (typeof window === "undefined") return;
6119
+ if (window.customElements?.get("inpost-geowidget") || window.easyPack) {
6120
+ return;
6121
+ }
6122
+ let linkTag = document.querySelector(`link[href="${cssUrl}"]`);
6123
+ if (!linkTag) {
6124
+ linkTag = document.createElement("link");
6125
+ linkTag.rel = "stylesheet";
6126
+ linkTag.href = cssUrl;
6127
+ linkTag.type = "text/css";
6128
+ document.head.appendChild(linkTag);
6129
+ }
6130
+ if (!scriptPromise) {
6131
+ scriptPromise = new Promise((resolve, reject) => {
6132
+ let scriptTag = document.querySelector(`script[src="${scriptUrl}"]`);
6133
+ if (!scriptTag) {
6134
+ scriptTag = document.createElement("script");
6135
+ scriptTag.src = scriptUrl;
6136
+ scriptTag.async = true;
6137
+ document.head.appendChild(scriptTag);
6138
+ }
6139
+ scriptTag.addEventListener("load", () => resolve());
6140
+ scriptTag.addEventListener(
6141
+ "error",
6142
+ (err) => reject(err instanceof Error ? err : new Error("Failed to load InPost GeoWidget SDK script"))
6143
+ );
6144
+ });
6145
+ }
6146
+ scriptPromise.then(async () => {
6147
+ if (typeof window !== "undefined" && window.customElements?.whenDefined) {
6148
+ try {
6149
+ await Promise.race([
6150
+ window.customElements.whenDefined("inpost-geowidget"),
6151
+ new Promise((r) => setTimeout(r, 100))
6152
+ ]);
6153
+ } catch {
6154
+ }
6155
+ }
6156
+ setIsLoaded(true);
6157
+ }).catch((err) => {
6158
+ setError(err instanceof Error ? err : new Error(String(err)));
6159
+ });
6160
+ }, [scriptUrl, cssUrl]);
6161
+ return { isLoaded, error };
6162
+ }
6163
+ var MOCK_POINTS = [
6164
+ {
6165
+ name: "WAW01M",
6166
+ address: { line1: "ul. Towarowa 5", line2: "00-838 Warszawa" },
6167
+ address_details: { city: "Warszawa", street: "Towarowa", building_number: "5", post_code: "00-838" },
6168
+ location: { latitude: 52.2297, longitude: 21.0122 },
6169
+ type: ["parcel_locker"],
6170
+ status: "Operating",
6171
+ location_description: "Przy stacji benzynowej BP"
6172
+ },
6173
+ {
6174
+ name: "KRA02N",
6175
+ address: { line1: "ul. Floria\u0144ska 12", line2: "31-021 Krak\xF3w" },
6176
+ address_details: { city: "Krak\xF3w", street: "Floria\u0144ska", building_number: "12", post_code: "31-021" },
6177
+ location: { latitude: 50.0647, longitude: 19.945 },
6178
+ type: ["parcel_locker"],
6179
+ status: "Operating",
6180
+ location_description: "Obok wej\u015Bcia do sklepu"
6181
+ },
6182
+ {
6183
+ name: "GDA03P",
6184
+ address: { line1: "ul. D\u0142uga 8", line2: "80-827 Gda\u0144sk" },
6185
+ address_details: { city: "Gda\u0144sk", street: "D\u0142uga", building_number: "8", post_code: "80-827" },
6186
+ location: { latitude: 54.352, longitude: 18.6466 },
6187
+ type: ["parcel_locker"],
6188
+ status: "Operating",
6189
+ location_description: "R\xF3g ulicy D\u0142ugiej i Tkackiej"
6190
+ },
6191
+ {
6192
+ name: "POZ04S",
6193
+ address: { line1: "ul. P\xF3\u0142wiejska 42", line2: "61-888 Pozna\u0144" },
6194
+ address_details: { city: "Pozna\u0144", street: "P\xF3\u0142wiejska", building_number: "42", post_code: "61-888" },
6195
+ location: { latitude: 52.4064, longitude: 16.9252 },
6196
+ type: ["parcel_locker"],
6197
+ status: "Operating",
6198
+ location_description: "Przy centrum handlowym Stary Browar"
6199
+ }
6200
+ ];
6201
+ var InPostGeowidget = ({
6202
+ token,
6203
+ language = "pl",
6204
+ config = "parcelCollect",
6205
+ sandbox = false,
6206
+ onPointSelect,
6207
+ onReady,
6208
+ onError,
6209
+ className,
6210
+ style,
6211
+ customScriptUrl,
6212
+ customCssUrl
6213
+ }) => {
6214
+ const { isLoaded, error } = useInPostScript({
6215
+ customScriptUrl,
6216
+ customCssUrl
6217
+ });
6218
+ const [searchQuery, setSearchQuery] = React52.useState("");
6219
+ const [selectedMock, setSelectedMock] = React52.useState(null);
6220
+ const widgetRef = React52.useRef(null);
6221
+ const callbackNameRef = React52.useRef(`inpost_cb_${Math.random().toString(36).substring(2, 9)}`);
6222
+ React52.useEffect(() => {
6223
+ if (error && onError) {
6224
+ onError(error);
6225
+ }
6226
+ }, [error, onError]);
6227
+ React52.useEffect(() => {
6228
+ if (isLoaded && onReady) {
6229
+ onReady();
6230
+ }
6231
+ }, [isLoaded, onReady]);
6232
+ React52.useEffect(() => {
6233
+ if (!token) return;
6234
+ const cbName = callbackNameRef.current;
6235
+ window[cbName] = (point) => {
6236
+ if (onPointSelect) {
6237
+ onPointSelect(point);
6238
+ }
6239
+ };
6240
+ const el = widgetRef.current;
6241
+ const handlePointSelect = (event) => {
6242
+ const customEv = event;
6243
+ const point = customEv.detail || customEv.point;
6244
+ if (point && onPointSelect) {
6245
+ onPointSelect(point);
6246
+ }
6247
+ };
6248
+ if (el) {
6249
+ el.addEventListener("inpostgeowidget", handlePointSelect);
6250
+ el.addEventListener("onpointselect", handlePointSelect);
6251
+ }
6252
+ document.addEventListener("onpointselect", handlePointSelect);
6253
+ return () => {
6254
+ delete window[cbName];
6255
+ if (el) {
6256
+ el.removeEventListener("inpostgeowidget", handlePointSelect);
6257
+ el.removeEventListener("onpointselect", handlePointSelect);
6258
+ }
6259
+ document.removeEventListener("onpointselect", handlePointSelect);
6260
+ };
6261
+ }, [onPointSelect, isLoaded, token]);
6262
+ if (error) {
6263
+ return /* @__PURE__ */ jsxRuntime.jsxs(
6264
+ "div",
6265
+ {
6266
+ 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 || ""}`,
6267
+ style,
6268
+ children: [
6269
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-base font-extrabold text-danger mb-1", children: "B\u0142\u0105d \u0142adowania Geowidget InPost" }),
6270
+ /* @__PURE__ */ jsxRuntime.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." })
6271
+ ]
6272
+ }
6273
+ );
6274
+ }
6275
+ if (!token) {
6276
+ const filteredPoints = MOCK_POINTS.filter(
6277
+ (p) => p.name.toLowerCase().includes(searchQuery.toLowerCase()) || p.address.line1.toLowerCase().includes(searchQuery.toLowerCase()) || p.address_details.city.toLowerCase().includes(searchQuery.toLowerCase())
6278
+ );
6279
+ return /* @__PURE__ */ jsxRuntime.jsxs(
6280
+ "div",
6281
+ {
6282
+ className: `flex flex-col h-full min-h-[500px] bg-surface border-2 border-border rounded-xl p-4 font-sans text-foreground ${className || ""}`,
6283
+ style,
6284
+ children: [
6285
+ /* @__PURE__ */ jsxRuntime.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: [
6286
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
6287
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
6288
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-2.5 h-2.5 rounded-full bg-slate-950 animate-pulse" }),
6289
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-black text-sm tracking-tight uppercase", children: "InPost Paczkomat\xAE" })
6290
+ ] }),
6291
+ /* @__PURE__ */ jsxRuntime.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" })
6292
+ ] }),
6293
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-slate-950 font-bold leading-relaxed opacity-95", children: [
6294
+ "Wybierz punkt z listy poni\u017Cej. Do za\u0142adowania produkcyjnej mapy przeka\u017C prop ",
6295
+ /* @__PURE__ */ jsxRuntime.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"' }),
6296
+ "."
6297
+ ] })
6298
+ ] }),
6299
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-3.5 relative", children: /* @__PURE__ */ jsxRuntime.jsx(
6300
+ "input",
6301
+ {
6302
+ type: "text",
6303
+ placeholder: "Szukaj Paczkomatu (np. Warszawa, WAW01M, Towarowa)...",
6304
+ value: searchQuery,
6305
+ onChange: (e) => setSearchQuery(e.target.value),
6306
+ 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"
6307
+ }
6308
+ ) }),
6309
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-y-auto space-y-3 pr-1 max-h-[420px]", children: filteredPoints.map((p) => {
6310
+ const isSelected = selectedMock?.name === p.name;
6311
+ return /* @__PURE__ */ jsxRuntime.jsxs(
6312
+ "div",
6313
+ {
6314
+ onClick: () => {
6315
+ setSelectedMock(p);
6316
+ if (onPointSelect) {
6317
+ onPointSelect(p);
6318
+ }
6319
+ },
6320
+ 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"}`,
6321
+ children: [
6322
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 min-w-0", children: [
6323
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "font-black text-base flex items-center gap-2", children: [
6324
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: isSelected ? "text-primary-foreground font-black" : "text-foreground font-black", children: [
6325
+ "Paczkomat\xAE ",
6326
+ p.name
6327
+ ] }),
6328
+ p.location_description && /* @__PURE__ */ jsxRuntime.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 })
6329
+ ] }),
6330
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `text-xs font-bold ${isSelected ? "text-primary-foreground/90" : "text-muted-foreground"}`, children: [
6331
+ p.address.line1,
6332
+ ", ",
6333
+ p.address.line2
6334
+ ] })
6335
+ ] }),
6336
+ /* @__PURE__ */ jsxRuntime.jsx(
6337
+ "button",
6338
+ {
6339
+ type: "button",
6340
+ 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"}`,
6341
+ children: isSelected ? "Wybrano \u2713" : "Wybierz"
6342
+ }
6343
+ )
6344
+ ]
6345
+ },
6346
+ p.name
6347
+ );
6348
+ }) })
6349
+ ]
6350
+ }
6351
+ );
6352
+ }
6353
+ if (!isLoaded) {
6354
+ return /* @__PURE__ */ jsxRuntime.jsx(
6355
+ "div",
6356
+ {
6357
+ className: `flex items-center justify-center min-h-[450px] bg-surface border-2 border-border rounded-xl p-6 ${className || ""}`,
6358
+ style,
6359
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3 text-muted-foreground", children: [
6360
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-9 h-9 border-4 border-primary border-t-transparent rounded-full animate-spin" }),
6361
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-extrabold text-foreground", children: "\u0141adowanie mapy InPost GeoWidget..." })
6362
+ ] })
6363
+ }
6364
+ );
6365
+ }
6366
+ const widgetProps = {
6367
+ language,
6368
+ config: String(config).toLowerCase(),
6369
+ // eslint-disable-next-line react-hooks/refs
6370
+ onpointselect: callbackNameRef.current
6371
+ };
6372
+ if (token) {
6373
+ widgetProps.token = token;
6374
+ }
6375
+ if (sandbox) {
6376
+ widgetProps.sandbox = "true";
6377
+ }
6378
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `w-full h-full min-h-[450px] relative ${className || ""}`, style, children: React52__namespace.default.createElement("inpost-geowidget", {
6379
+ ref: widgetRef,
6380
+ ...widgetProps,
6381
+ style: { width: "100%", height: "100%", display: "block", minHeight: "450px" }
6382
+ }) });
6383
+ };
6384
+ var InPostGeowidgetModal = ({
6385
+ value,
6386
+ onSelect,
6387
+ triggerText = "Wybierz Paczkomat\xAE",
6388
+ modalTitle = "Wybierz punkt odbioru InPost",
6389
+ disabled = false,
6390
+ open: controlledOpen,
6391
+ onOpenChange,
6392
+ showSelectedBadge = true,
6393
+ className = "",
6394
+ buttonVariant = "outline",
6395
+ buttonSize = "md",
6396
+ token,
6397
+ language,
6398
+ config,
6399
+ sandbox,
6400
+ customScriptUrl,
6401
+ customCssUrl
6402
+ }) => {
6403
+ const [internalOpen, setInternalOpen] = React52.useState(false);
6404
+ const [selectedPoint, setSelectedPoint] = React52.useState(
6405
+ typeof value === "object" && value ? value : null
6406
+ );
6407
+ const isControlled = controlledOpen !== void 0;
6408
+ const isOpen = isControlled ? controlledOpen : internalOpen;
6409
+ const handleOpenToggle = (newOpen) => {
6410
+ if (!isControlled) {
6411
+ setInternalOpen(newOpen);
6412
+ }
6413
+ if (onOpenChange) {
6414
+ onOpenChange(newOpen);
6415
+ }
6416
+ };
6417
+ const handlePointSelect = (point) => {
6418
+ setSelectedPoint(point);
6419
+ if (onSelect) {
6420
+ onSelect(point);
6421
+ }
6422
+ handleOpenToggle(false);
6423
+ };
6424
+ const selectedCode = selectedPoint?.name || (typeof value === "string" ? value : null);
6425
+ const selectedAddress = selectedPoint ? `${selectedPoint.address?.line1 || ""}, ${selectedPoint.address?.line2 || ""}` : null;
6426
+ const isOutline = buttonVariant === "outline";
6427
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `inline-flex flex-col gap-3 min-w-[280px] ${className}`, children: [
6428
+ /* @__PURE__ */ jsxRuntime.jsxs(
6429
+ Button,
6430
+ {
6431
+ type: "button",
6432
+ variant: buttonVariant,
6433
+ size: buttonSize,
6434
+ disabled,
6435
+ onClick: () => handleOpenToggle(true),
6436
+ 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"}`,
6437
+ children: [
6438
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2.5 min-w-0", children: [
6439
+ /* @__PURE__ */ jsxRuntime.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" }),
6440
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `truncate font-bold text-sm ${isOutline ? "text-foreground group-hover:text-primary" : ""}`, children: selectedCode ? `Paczkomat\xAE ${selectedCode}` : triggerText })
6441
+ ] }),
6442
+ /* @__PURE__ */ jsxRuntime.jsx(
6443
+ "span",
6444
+ {
6445
+ 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"}`,
6446
+ children: selectedCode ? "Zmie\u0144" : "Wybierz"
6447
+ }
6448
+ )
6449
+ ]
6450
+ }
6451
+ ),
6452
+ showSelectedBadge && selectedCode && /* @__PURE__ */ jsxRuntime.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: [
6453
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "font-bold flex items-center justify-between gap-2", children: [
6454
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2 text-foreground", children: [
6455
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-2.5 h-2.5 rounded-full bg-primary shadow-sm animate-pulse" }),
6456
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-black text-sm text-primary", children: [
6457
+ "Paczkomat\xAE ",
6458
+ selectedCode
6459
+ ] })
6460
+ ] }),
6461
+ /* @__PURE__ */ jsxRuntime.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" })
6462
+ ] }),
6463
+ selectedAddress && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground text-[0.78rem] font-medium pl-4 border-l-2 border-border", children: selectedAddress })
6464
+ ] }),
6465
+ /* @__PURE__ */ jsxRuntime.jsxs(Modal, { open: isOpen, onClose: () => handleOpenToggle(false), width: 850, children: [
6466
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 pb-3.5 border-b border-border", children: [
6467
+ /* @__PURE__ */ jsxRuntime.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" }),
6468
+ /* @__PURE__ */ jsxRuntime.jsx(ModalTitle, { className: "m-0 text-xl font-black text-primary tracking-tight", children: modalTitle })
6469
+ ] }),
6470
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-[600px] min-h-[500px] mt-3.5 rounded-xl overflow-hidden", children: isOpen && /* @__PURE__ */ jsxRuntime.jsx(
6471
+ InPostGeowidget,
6472
+ {
6473
+ token,
6474
+ language,
6475
+ config,
6476
+ sandbox,
6477
+ customScriptUrl,
6478
+ customCssUrl,
6479
+ onPointSelect: handlePointSelect
6480
+ }
6481
+ ) })
6482
+ ] })
6483
+ ] });
6484
+ };
6083
6485
 
6084
6486
  exports.Accordion = Accordion;
6085
6487
  exports.AccordionContent = AccordionContent;
@@ -6147,6 +6549,8 @@ exports.FileUploadField = FileUploadField;
6147
6549
  exports.FormField = FormField;
6148
6550
  exports.Hint = Hint;
6149
6551
  exports.ImageGallery = ImageGallery;
6552
+ exports.InPostGeowidget = InPostGeowidget;
6553
+ exports.InPostGeowidgetModal = InPostGeowidgetModal;
6150
6554
  exports.InboxContent = InboxContent;
6151
6555
  exports.InboxPopover = InboxPopover;
6152
6556
  exports.InboxTrigger = InboxTrigger;
@@ -6229,6 +6633,7 @@ exports.hslToHex = hslToHex;
6229
6633
  exports.isValidHex = isValidHex;
6230
6634
  exports.normalizeHex = normalizeHex;
6231
6635
  exports.sliderThumbCSS = sliderThumbCSS;
6636
+ exports.useInPostScript = useInPostScript;
6232
6637
  exports.useInboxState = useInboxState;
6233
6638
  exports.useStepper = useStepper;
6234
6639
  exports.useToast = useToast;