@next-degree/pickle-shared-js 0.3.27 → 0.4.31
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/app/layout.css +59 -2
- package/dist/app/layout.css.map +1 -1
- package/dist/app/page.cjs +464 -114
- package/dist/app/page.cjs.map +1 -1
- package/dist/app/page.js +442 -92
- package/dist/app/page.js.map +1 -1
- package/dist/components/demos/ComboboxDemo.cjs +91 -52
- package/dist/components/demos/ComboboxDemo.cjs.map +1 -1
- package/dist/components/demos/ComboboxDemo.js +84 -45
- package/dist/components/demos/ComboboxDemo.js.map +1 -1
- package/dist/components/demos/CounterDemo.cjs +270 -0
- package/dist/components/demos/CounterDemo.cjs.map +1 -0
- package/dist/components/demos/CounterDemo.d.cts +5 -0
- package/dist/components/demos/CounterDemo.d.ts +5 -0
- package/dist/components/demos/CounterDemo.js +238 -0
- package/dist/components/demos/CounterDemo.js.map +1 -0
- package/dist/components/demos/InputDemo.cjs +74 -35
- package/dist/components/demos/InputDemo.cjs.map +1 -1
- package/dist/components/demos/InputDemo.js +59 -30
- package/dist/components/demos/InputDemo.js.map +1 -1
- package/dist/components/demos/PlacesQueryInputDemo.cjs +341 -0
- package/dist/components/demos/PlacesQueryInputDemo.cjs.map +1 -0
- package/dist/components/demos/PlacesQueryInputDemo.d.cts +5 -0
- package/dist/components/demos/PlacesQueryInputDemo.d.ts +5 -0
- package/dist/components/demos/PlacesQueryInputDemo.js +309 -0
- package/dist/components/demos/PlacesQueryInputDemo.js.map +1 -0
- package/dist/components/demos/SelectDemo.cjs +83 -53
- package/dist/components/demos/SelectDemo.cjs.map +1 -1
- package/dist/components/demos/SelectDemo.js +73 -43
- package/dist/components/demos/SelectDemo.js.map +1 -1
- package/dist/components/demos/index.cjs +462 -112
- package/dist/components/demos/index.cjs.map +1 -1
- package/dist/components/demos/index.js +440 -90
- package/dist/components/demos/index.js.map +1 -1
- package/dist/components/primitives/command.d.cts +1 -1
- package/dist/components/primitives/command.d.ts +1 -1
- package/dist/components/primitives/tooltip.cjs +75 -0
- package/dist/components/primitives/tooltip.cjs.map +1 -0
- package/dist/components/primitives/tooltip.d.cts +9 -0
- package/dist/components/primitives/tooltip.d.ts +9 -0
- package/dist/components/primitives/tooltip.js +38 -0
- package/dist/components/primitives/tooltip.js.map +1 -0
- package/dist/components/ui/Combobox.cjs +78 -40
- package/dist/components/ui/Combobox.cjs.map +1 -1
- package/dist/components/ui/Combobox.d.cts +5 -2
- package/dist/components/ui/Combobox.d.ts +5 -2
- package/dist/components/ui/Combobox.js +71 -33
- package/dist/components/ui/Combobox.js.map +1 -1
- package/dist/components/ui/Counter.cjs +248 -0
- package/dist/components/ui/Counter.cjs.map +1 -0
- package/dist/components/ui/Counter.d.cts +28 -0
- package/dist/components/ui/Counter.d.ts +28 -0
- package/dist/components/ui/Counter.js +214 -0
- package/dist/components/ui/Counter.js.map +1 -0
- package/dist/components/ui/Input.cjs +67 -28
- package/dist/components/ui/Input.cjs.map +1 -1
- package/dist/components/ui/Input.d.cts +2 -1
- package/dist/components/ui/Input.d.ts +2 -1
- package/dist/components/ui/Input.js +54 -25
- package/dist/components/ui/Input.js.map +1 -1
- package/dist/components/ui/Label.cjs +54 -16
- package/dist/components/ui/Label.cjs.map +1 -1
- package/dist/components/ui/Label.d.cts +2 -1
- package/dist/components/ui/Label.d.ts +2 -1
- package/dist/components/ui/Label.js +44 -16
- package/dist/components/ui/Label.js.map +1 -1
- package/dist/components/ui/PlacesQueryInput.cjs +321 -0
- package/dist/components/ui/PlacesQueryInput.cjs.map +1 -0
- package/dist/components/ui/PlacesQueryInput.d.cts +18 -0
- package/dist/components/ui/PlacesQueryInput.d.ts +18 -0
- package/dist/components/ui/PlacesQueryInput.js +289 -0
- package/dist/components/ui/PlacesQueryInput.js.map +1 -0
- package/dist/components/ui/Select.cjs +75 -46
- package/dist/components/ui/Select.cjs.map +1 -1
- package/dist/components/ui/Select.d.cts +3 -2
- package/dist/components/ui/Select.d.ts +3 -2
- package/dist/components/ui/Select.js +67 -38
- package/dist/components/ui/Select.js.map +1 -1
- package/dist/index.cjs +536 -230
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +510 -206
- package/dist/index.js.map +1 -1
- package/dist/lib/google.cjs +43 -0
- package/dist/lib/google.cjs.map +1 -0
- package/dist/lib/google.d.cts +5 -0
- package/dist/lib/google.d.ts +5 -0
- package/dist/lib/google.js +19 -0
- package/dist/lib/google.js.map +1 -0
- package/dist/styles/globals.css +59 -2
- package/dist/styles/globals.css.map +1 -1
- package/package.json +22 -21
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useState as useState2 } from "react";
|
|
3
3
|
|
|
4
4
|
// src/components/ui/Combobox.tsx
|
|
5
|
-
import { forwardRef as
|
|
5
|
+
import { forwardRef as forwardRef7, useEffect, useState } from "react";
|
|
6
6
|
import { ChevronDownIcon, CircleX, icons as icons2 } from "lucide-react";
|
|
7
7
|
import { cva as cva2 } from "cva";
|
|
8
8
|
|
|
@@ -342,30 +342,58 @@ function Badge({ className, variant, ...props }) {
|
|
|
342
342
|
return /* @__PURE__ */ jsx7("div", { className: cn(badgeVariants({ variant }), className), ...props });
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
+
// src/components/primitives/tooltip.tsx
|
|
346
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
347
|
+
import * as React5 from "react";
|
|
348
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
349
|
+
var TooltipProvider = TooltipPrimitive.Provider;
|
|
350
|
+
var Tooltip = TooltipPrimitive.Root;
|
|
351
|
+
var TooltipTrigger = TooltipPrimitive.Trigger;
|
|
352
|
+
var TooltipContent = React5.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx8(
|
|
353
|
+
TooltipPrimitive.Content,
|
|
354
|
+
{
|
|
355
|
+
ref,
|
|
356
|
+
sideOffset,
|
|
357
|
+
className: cn(
|
|
358
|
+
"z-50 overflow-hidden rounded-md border border-neutral-200 bg-white px-3 py-1.5 text-sm text-neutral-950 shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",
|
|
359
|
+
className
|
|
360
|
+
),
|
|
361
|
+
...props
|
|
362
|
+
}
|
|
363
|
+
));
|
|
364
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
365
|
+
|
|
345
366
|
// src/components/ui/Label.tsx
|
|
346
|
-
import {
|
|
347
|
-
|
|
367
|
+
import { InfoIcon } from "lucide-react";
|
|
368
|
+
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
369
|
+
function Label({ text, required, description, className, ...props }) {
|
|
348
370
|
if (!text) return null;
|
|
349
|
-
return /* @__PURE__ */ jsxs5(
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
371
|
+
return /* @__PURE__ */ jsxs5("div", { className: "flex w-full flex-row gap-1", children: [
|
|
372
|
+
/* @__PURE__ */ jsxs5(
|
|
373
|
+
"label",
|
|
374
|
+
{
|
|
375
|
+
className: cn(
|
|
376
|
+
"text-xs text-grey-80 peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
377
|
+
className
|
|
378
|
+
),
|
|
379
|
+
...props,
|
|
380
|
+
children: [
|
|
381
|
+
text,
|
|
382
|
+
required && /* @__PURE__ */ jsx9("span", { className: "text-red-600", children: "\xA0*" })
|
|
383
|
+
]
|
|
384
|
+
}
|
|
385
|
+
),
|
|
386
|
+
!!description && /* @__PURE__ */ jsx9(TooltipProvider, { children: /* @__PURE__ */ jsxs5(Tooltip, { children: [
|
|
387
|
+
/* @__PURE__ */ jsx9(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx9(InfoIcon, { className: "h-4 w-4" }) }),
|
|
388
|
+
/* @__PURE__ */ jsx9(TooltipContent, { className: "max-w-48", children: description })
|
|
389
|
+
] }) })
|
|
390
|
+
] });
|
|
363
391
|
}
|
|
364
392
|
var Label_default = Label;
|
|
365
393
|
|
|
366
394
|
// src/components/ui/Combobox.tsx
|
|
367
|
-
import { jsx as
|
|
368
|
-
var Combobox =
|
|
395
|
+
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
396
|
+
var Combobox = forwardRef7((props, ref) => {
|
|
369
397
|
const {
|
|
370
398
|
id,
|
|
371
399
|
name,
|
|
@@ -373,6 +401,7 @@ var Combobox = forwardRef6((props, ref) => {
|
|
|
373
401
|
label,
|
|
374
402
|
options,
|
|
375
403
|
required,
|
|
404
|
+
description,
|
|
376
405
|
classNames,
|
|
377
406
|
multiselect,
|
|
378
407
|
placeholder,
|
|
@@ -421,10 +450,19 @@ var Combobox = forwardRef6((props, ref) => {
|
|
|
421
450
|
return isDefault ? defaultLabel : label;
|
|
422
451
|
};
|
|
423
452
|
return /* @__PURE__ */ jsxs6("div", { className: cn("flex flex-col gap-1", className), children: [
|
|
424
|
-
isDefault && /* @__PURE__ */
|
|
453
|
+
isDefault && /* @__PURE__ */ jsx10(
|
|
454
|
+
Label_default,
|
|
455
|
+
{
|
|
456
|
+
text: label,
|
|
457
|
+
htmlFor: name,
|
|
458
|
+
required,
|
|
459
|
+
description,
|
|
460
|
+
className: classNames?.label
|
|
461
|
+
}
|
|
462
|
+
),
|
|
425
463
|
/* @__PURE__ */ jsxs6("div", { className: "relative flex", children: [
|
|
426
464
|
/* @__PURE__ */ jsxs6(Popover, { open, onOpenChange: setOpen, children: [
|
|
427
|
-
/* @__PURE__ */
|
|
465
|
+
/* @__PURE__ */ jsx10(
|
|
428
466
|
PopoverTrigger,
|
|
429
467
|
{
|
|
430
468
|
asChild: true,
|
|
@@ -441,9 +479,9 @@ var Combobox = forwardRef6((props, ref) => {
|
|
|
441
479
|
),
|
|
442
480
|
"aria-expanded": open,
|
|
443
481
|
children: [
|
|
444
|
-
isDefault && IconComponent && /* @__PURE__ */
|
|
445
|
-
isChip && !isEmpty && /* @__PURE__ */
|
|
446
|
-
/* @__PURE__ */
|
|
482
|
+
isDefault && IconComponent && /* @__PURE__ */ jsx10(IconComponent, { className: "h-4 w-4 shrink-0" }),
|
|
483
|
+
isChip && !isEmpty && /* @__PURE__ */ jsx10(Badge, { variant: "purple", children: selected.length }),
|
|
484
|
+
/* @__PURE__ */ jsx10(
|
|
447
485
|
"span",
|
|
448
486
|
{
|
|
449
487
|
className: cn(
|
|
@@ -453,7 +491,7 @@ var Combobox = forwardRef6((props, ref) => {
|
|
|
453
491
|
children: handleDisplayValue()
|
|
454
492
|
}
|
|
455
493
|
),
|
|
456
|
-
showChevron && /* @__PURE__ */
|
|
494
|
+
showChevron && /* @__PURE__ */ jsx10(
|
|
457
495
|
ChevronDownIcon,
|
|
458
496
|
{
|
|
459
497
|
className: "shrink-0 transform group-data-[state=open]:rotate-180",
|
|
@@ -465,7 +503,7 @@ var Combobox = forwardRef6((props, ref) => {
|
|
|
465
503
|
)
|
|
466
504
|
}
|
|
467
505
|
),
|
|
468
|
-
/* @__PURE__ */
|
|
506
|
+
/* @__PURE__ */ jsx10(
|
|
469
507
|
PopoverContent,
|
|
470
508
|
{
|
|
471
509
|
className: cn(
|
|
@@ -477,15 +515,15 @@ var Combobox = forwardRef6((props, ref) => {
|
|
|
477
515
|
sideOffset: 4,
|
|
478
516
|
align: "start",
|
|
479
517
|
children: /* @__PURE__ */ jsxs6(Command, { children: [
|
|
480
|
-
!hideSearchBox && /* @__PURE__ */
|
|
518
|
+
!hideSearchBox && /* @__PURE__ */ jsx10(CommandInput, { placeholder: "Search..." }),
|
|
481
519
|
/* @__PURE__ */ jsxs6(CommandList, { children: [
|
|
482
|
-
/* @__PURE__ */
|
|
483
|
-
/* @__PURE__ */
|
|
520
|
+
/* @__PURE__ */ jsx10(CommandEmpty, { children: "No results" }),
|
|
521
|
+
/* @__PURE__ */ jsx10(CommandGroup, { children: options.map(({ id: id2, ...option }) => /* @__PURE__ */ jsx10(
|
|
484
522
|
CommandItem,
|
|
485
523
|
{
|
|
486
524
|
value: option.title,
|
|
487
525
|
onSelect: () => handleSelect(option.value),
|
|
488
|
-
children: /* @__PURE__ */
|
|
526
|
+
children: /* @__PURE__ */ jsx10(
|
|
489
527
|
ListItem_default,
|
|
490
528
|
{
|
|
491
529
|
className: cn(classNames?.items, "truncate py-1"),
|
|
@@ -498,19 +536,19 @@ var Combobox = forwardRef6((props, ref) => {
|
|
|
498
536
|
id2
|
|
499
537
|
)) })
|
|
500
538
|
] }),
|
|
501
|
-
!!footer && /* @__PURE__ */
|
|
539
|
+
!!footer && /* @__PURE__ */ jsx10(Separator, {}),
|
|
502
540
|
footer && footer({ close })
|
|
503
541
|
] })
|
|
504
542
|
}
|
|
505
543
|
)
|
|
506
544
|
] }),
|
|
507
|
-
isDefault && !isEmpty && /* @__PURE__ */
|
|
545
|
+
isDefault && !isEmpty && /* @__PURE__ */ jsx10(
|
|
508
546
|
"button",
|
|
509
547
|
{
|
|
510
548
|
type: "button",
|
|
511
549
|
className: "absolute inset-y-0 right-1 my-auto flex h-8 w-8 cursor-pointer items-center justify-center rounded-full hover:bg-pickle-20",
|
|
512
550
|
onClick: handleClear,
|
|
513
|
-
children: /* @__PURE__ */
|
|
551
|
+
children: /* @__PURE__ */ jsx10(CircleX, { className: "h-4 w-4 text-green-100" })
|
|
514
552
|
}
|
|
515
553
|
)
|
|
516
554
|
] })
|
|
@@ -546,12 +584,12 @@ var triggerVariants = cva2(
|
|
|
546
584
|
// src/components/ui/Button.tsx
|
|
547
585
|
import { Slot } from "@radix-ui/react-slot";
|
|
548
586
|
import { cva as cva3 } from "cva";
|
|
549
|
-
import { forwardRef as
|
|
550
|
-
import { jsx as
|
|
551
|
-
var Button =
|
|
587
|
+
import { forwardRef as forwardRef8 } from "react";
|
|
588
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
589
|
+
var Button = forwardRef8(
|
|
552
590
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
553
591
|
const Component = asChild ? Slot : "button";
|
|
554
|
-
return /* @__PURE__ */
|
|
592
|
+
return /* @__PURE__ */ jsx11(
|
|
555
593
|
Component,
|
|
556
594
|
{
|
|
557
595
|
className: cn(buttonVariants({ variant, size, className })),
|
|
@@ -653,7 +691,7 @@ var buttonVariants = cva3(
|
|
|
653
691
|
);
|
|
654
692
|
|
|
655
693
|
// src/components/demos/ComboboxDemo.tsx
|
|
656
|
-
import { jsx as
|
|
694
|
+
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
657
695
|
function ComboboxDemo() {
|
|
658
696
|
const [selectedBands, setSelectedBands] = useState2([]);
|
|
659
697
|
const [selectedFruit, setSelectedFruit] = useState2("");
|
|
@@ -694,7 +732,7 @@ function ComboboxDemo() {
|
|
|
694
732
|
{ title: "Grape", value: "Grape", id: "2", icon: "Grape" }
|
|
695
733
|
];
|
|
696
734
|
return /* @__PURE__ */ jsxs7("div", { className: "flex max-w-sm flex-col flex-wrap gap-4 p-4", children: [
|
|
697
|
-
/* @__PURE__ */
|
|
735
|
+
/* @__PURE__ */ jsx12(
|
|
698
736
|
Combobox,
|
|
699
737
|
{
|
|
700
738
|
required: true,
|
|
@@ -704,11 +742,12 @@ function ComboboxDemo() {
|
|
|
704
742
|
options: bands,
|
|
705
743
|
id: "bands",
|
|
706
744
|
multiselect: true,
|
|
745
|
+
description: "This is a tooltip",
|
|
707
746
|
onChange: setSelectedBands,
|
|
708
747
|
value: selectedBands
|
|
709
748
|
}
|
|
710
749
|
),
|
|
711
|
-
/* @__PURE__ */
|
|
750
|
+
/* @__PURE__ */ jsx12(
|
|
712
751
|
Combobox,
|
|
713
752
|
{
|
|
714
753
|
label: "US bands from the 90's",
|
|
@@ -720,7 +759,7 @@ function ComboboxDemo() {
|
|
|
720
759
|
value: selectedBands
|
|
721
760
|
}
|
|
722
761
|
),
|
|
723
|
-
/* @__PURE__ */
|
|
762
|
+
/* @__PURE__ */ jsx12(
|
|
724
763
|
Combobox,
|
|
725
764
|
{
|
|
726
765
|
label: "Fruit label",
|
|
@@ -729,13 +768,13 @@ function ComboboxDemo() {
|
|
|
729
768
|
value: selectedFruit,
|
|
730
769
|
onChange: setSelectedFruit,
|
|
731
770
|
children: ({ close }) => /* @__PURE__ */ jsxs7("div", { className: "flex flex-row items-center justify-between bg-white p-2 pl-4", children: [
|
|
732
|
-
/* @__PURE__ */
|
|
733
|
-
/* @__PURE__ */
|
|
771
|
+
/* @__PURE__ */ jsx12(Button, { variant: "link", tabIndex: -1, onClick: close, children: "Clear" }),
|
|
772
|
+
/* @__PURE__ */ jsx12(Button, { variant: "primary", size: "small", tabIndex: -1, children: "Apply" })
|
|
734
773
|
] })
|
|
735
774
|
}
|
|
736
775
|
),
|
|
737
|
-
selectedBands.map((band) => /* @__PURE__ */
|
|
738
|
-
/* @__PURE__ */
|
|
776
|
+
selectedBands.map((band) => /* @__PURE__ */ jsx12("span", { className: "text-green-80", children: band }, band)),
|
|
777
|
+
/* @__PURE__ */ jsx12("span", { className: "text-purple-100", children: selectedFruit })
|
|
739
778
|
] });
|
|
740
779
|
}
|
|
741
780
|
var ComboboxDemo_default = ComboboxDemo;
|
|
@@ -744,25 +783,25 @@ var ComboboxDemo_default = ComboboxDemo;
|
|
|
744
783
|
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
745
784
|
import { CheckIcon as CheckIcon2, ChevronDownIcon as ChevronDownIcon2, X as X2 } from "lucide-react";
|
|
746
785
|
import {
|
|
747
|
-
forwardRef as
|
|
786
|
+
forwardRef as forwardRef9,
|
|
748
787
|
useEffect as useEffect2,
|
|
749
788
|
useRef,
|
|
750
789
|
useState as useState3
|
|
751
790
|
} from "react";
|
|
752
791
|
|
|
753
792
|
// src/components/ui/ErrorMessage.tsx
|
|
754
|
-
import { jsx as
|
|
793
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
755
794
|
function ErrorMessage({ message, className, ...props }) {
|
|
756
795
|
if (!message) return null;
|
|
757
|
-
return /* @__PURE__ */
|
|
796
|
+
return /* @__PURE__ */ jsx13("p", { className: cn("px-1 text-xs text-red-600", className), ...props, children: message });
|
|
758
797
|
}
|
|
759
798
|
var ErrorMessage_default = ErrorMessage;
|
|
760
799
|
|
|
761
800
|
// src/components/ui/Chip.tsx
|
|
762
801
|
import { cva as cva4 } from "cva";
|
|
763
802
|
import { twMerge as twMerge2 } from "tailwind-merge";
|
|
764
|
-
import { jsx as
|
|
765
|
-
var Chip = ({ className, variant, size, ...props }) => /* @__PURE__ */
|
|
803
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
804
|
+
var Chip = ({ className, variant, size, ...props }) => /* @__PURE__ */ jsx14("div", { className: twMerge2(chipVariants({ variant, size, className })), ...props });
|
|
766
805
|
var chipVariants = cva4(["flex", "items-center", "rounded-3xl", "border", "w-fit"], {
|
|
767
806
|
variants: {
|
|
768
807
|
variant: {
|
|
@@ -785,9 +824,9 @@ var chipVariants = cva4(["flex", "items-center", "rounded-3xl", "border", "w-fit
|
|
|
785
824
|
var Chip_default = Chip;
|
|
786
825
|
|
|
787
826
|
// src/components/ui/Select.tsx
|
|
788
|
-
import { jsx as
|
|
789
|
-
var Select =
|
|
790
|
-
({ label, options, placeholder, multiselect, classNames, error, id, ...props }, ref) => {
|
|
827
|
+
import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
828
|
+
var Select = forwardRef9(
|
|
829
|
+
({ label, options, placeholder, multiselect, description, classNames, error, id, ...props }, ref) => {
|
|
791
830
|
const { value, defaultValue, dir, className, onChange, ...rest } = props;
|
|
792
831
|
const [selected, setSelected] = useState3([]);
|
|
793
832
|
const [open, setOpen] = useState3(false);
|
|
@@ -820,16 +859,17 @@ var Select = forwardRef8(
|
|
|
820
859
|
return /* @__PURE__ */ jsxs8(
|
|
821
860
|
"div",
|
|
822
861
|
{
|
|
823
|
-
className: cn("flex flex-col gap-1", className),
|
|
862
|
+
className: cn("flex w-full flex-col gap-1", className),
|
|
824
863
|
ref: containerRef,
|
|
825
864
|
"data-testid": `${(label ?? id)?.toLowerCase()}-select-element`,
|
|
826
865
|
children: [
|
|
827
|
-
/* @__PURE__ */
|
|
866
|
+
/* @__PURE__ */ jsx15(
|
|
828
867
|
Label_default,
|
|
829
868
|
{
|
|
830
869
|
text: label,
|
|
831
870
|
htmlFor: props.name,
|
|
832
871
|
required: props.required,
|
|
872
|
+
description,
|
|
833
873
|
className: classNames?.label
|
|
834
874
|
}
|
|
835
875
|
),
|
|
@@ -849,11 +889,11 @@ var Select = forwardRef8(
|
|
|
849
889
|
{
|
|
850
890
|
ref,
|
|
851
891
|
className: cn(
|
|
852
|
-
"group flex h-11
|
|
892
|
+
"group flex h-11 w-full flex-row items-center justify-between gap-3 rounded-lg border px-4 py-3 text-sm font-normal focus:outline-purple-100 disabled:bg-grey-5 data-[placeholder]:text-grey-50 data-[placeholder]:disabled:text-grey-40",
|
|
853
893
|
classNames?.trigger
|
|
854
894
|
),
|
|
855
895
|
children: [
|
|
856
|
-
/* @__PURE__ */
|
|
896
|
+
/* @__PURE__ */ jsx15("span", { className: "truncate", children: /* @__PURE__ */ jsx15(
|
|
857
897
|
SelectPrimitive.Value,
|
|
858
898
|
{
|
|
859
899
|
placeholder: placeholder ?? "Select an option",
|
|
@@ -861,7 +901,7 @@ var Select = forwardRef8(
|
|
|
861
901
|
children: handleLabels()
|
|
862
902
|
}
|
|
863
903
|
) }),
|
|
864
|
-
/* @__PURE__ */
|
|
904
|
+
/* @__PURE__ */ jsx15(
|
|
865
905
|
ChevronDownIcon2,
|
|
866
906
|
{
|
|
867
907
|
className: "transform text-black group-data-[state=open]:rotate-180",
|
|
@@ -871,7 +911,7 @@ var Select = forwardRef8(
|
|
|
871
911
|
]
|
|
872
912
|
}
|
|
873
913
|
),
|
|
874
|
-
/* @__PURE__ */
|
|
914
|
+
/* @__PURE__ */ jsx15(SelectPrimitive.Portal, { container: containerRef.current, children: /* @__PURE__ */ jsx15(
|
|
875
915
|
SelectPrimitive.Content,
|
|
876
916
|
{
|
|
877
917
|
hideWhenDetached: true,
|
|
@@ -881,15 +921,15 @@ var Select = forwardRef8(
|
|
|
881
921
|
onPointerDownOutside: toggleOpen,
|
|
882
922
|
onKeyDown: closeOnEscape,
|
|
883
923
|
children: /* @__PURE__ */ jsxs8(SelectPrimitive.Viewport, { children: [
|
|
884
|
-
multiselect && !!chipLabels?.length && /* @__PURE__ */
|
|
924
|
+
multiselect && !!chipLabels?.length && /* @__PURE__ */ jsx15(
|
|
885
925
|
SelectPrimitive.Group,
|
|
886
926
|
{
|
|
887
927
|
className: "mb-2 flex flex-row flex-wrap gap-1 px-2",
|
|
888
928
|
"data-testid": "selected-labels",
|
|
889
929
|
children: chipLabels?.map(
|
|
890
930
|
(chip) => chip && /* @__PURE__ */ jsxs8(Chip_default, { size: "small", variant: "primary", children: [
|
|
891
|
-
/* @__PURE__ */
|
|
892
|
-
/* @__PURE__ */
|
|
931
|
+
/* @__PURE__ */ jsx15("span", { children: chip.title }),
|
|
932
|
+
/* @__PURE__ */ jsx15(
|
|
893
933
|
X2,
|
|
894
934
|
{
|
|
895
935
|
size: 18,
|
|
@@ -902,7 +942,7 @@ var Select = forwardRef8(
|
|
|
902
942
|
)
|
|
903
943
|
}
|
|
904
944
|
),
|
|
905
|
-
/* @__PURE__ */
|
|
945
|
+
/* @__PURE__ */ jsx15(Separator, {}),
|
|
906
946
|
options?.map(({ id: id2, title, value: value2 }) => /* @__PURE__ */ jsxs8(
|
|
907
947
|
SelectPrimitive.Item,
|
|
908
948
|
{
|
|
@@ -912,8 +952,8 @@ var Select = forwardRef8(
|
|
|
912
952
|
onKeyDown: (e) => setValueOnEnter(e, value2),
|
|
913
953
|
onClick: () => handleChange(value2),
|
|
914
954
|
children: [
|
|
915
|
-
/* @__PURE__ */
|
|
916
|
-
/* @__PURE__ */
|
|
955
|
+
/* @__PURE__ */ jsx15(SelectPrimitive.ItemText, { children: title }),
|
|
956
|
+
/* @__PURE__ */ jsx15(
|
|
917
957
|
CheckIcon2,
|
|
918
958
|
{
|
|
919
959
|
className: "absolute inset-y-0 right-3 my-auto hidden w-6 text-purple-100 group-data-[state=checked]:block",
|
|
@@ -930,7 +970,7 @@ var Select = forwardRef8(
|
|
|
930
970
|
]
|
|
931
971
|
}
|
|
932
972
|
),
|
|
933
|
-
/* @__PURE__ */
|
|
973
|
+
/* @__PURE__ */ jsx15(ErrorMessage_default, { message: error })
|
|
934
974
|
]
|
|
935
975
|
}
|
|
936
976
|
);
|
|
@@ -940,12 +980,12 @@ Select.displayName = "Select";
|
|
|
940
980
|
var Select_default = Select;
|
|
941
981
|
|
|
942
982
|
// src/components/demos/SelectDemo.tsx
|
|
943
|
-
import { jsx as
|
|
983
|
+
import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
944
984
|
function SelectDemo() {
|
|
945
985
|
return /* @__PURE__ */ jsxs9("div", { className: "m-4", children: [
|
|
946
|
-
/* @__PURE__ */
|
|
986
|
+
/* @__PURE__ */ jsx16("h3", { children: "Select" }),
|
|
947
987
|
/* @__PURE__ */ jsxs9("div", { className: "mt-2 flex max-w-sm flex-col gap-4", children: [
|
|
948
|
-
/* @__PURE__ */
|
|
988
|
+
/* @__PURE__ */ jsx16(
|
|
949
989
|
Select_default,
|
|
950
990
|
{
|
|
951
991
|
required: true,
|
|
@@ -958,12 +998,13 @@ function SelectDemo() {
|
|
|
958
998
|
]
|
|
959
999
|
}
|
|
960
1000
|
),
|
|
961
|
-
/* @__PURE__ */
|
|
1001
|
+
/* @__PURE__ */ jsx16(
|
|
962
1002
|
Select_default,
|
|
963
1003
|
{
|
|
964
1004
|
multiselect: true,
|
|
965
1005
|
label: "Label - Multiselect",
|
|
966
1006
|
placeholder: "Select an option",
|
|
1007
|
+
description: "This is a tooltip",
|
|
967
1008
|
options: [
|
|
968
1009
|
{ id: "1", value: "1", title: "Option 1" },
|
|
969
1010
|
{ id: "2", value: "2", title: "Option 2" },
|
|
@@ -978,7 +1019,7 @@ function SelectDemo() {
|
|
|
978
1019
|
]
|
|
979
1020
|
}
|
|
980
1021
|
),
|
|
981
|
-
/* @__PURE__ */
|
|
1022
|
+
/* @__PURE__ */ jsx16(
|
|
982
1023
|
Select_default,
|
|
983
1024
|
{
|
|
984
1025
|
disabled: true,
|
|
@@ -999,10 +1040,10 @@ var SelectDemo_default = SelectDemo;
|
|
|
999
1040
|
// src/components/ui/Input.tsx
|
|
1000
1041
|
import { cva as cva5 } from "cva";
|
|
1001
1042
|
import { icons as icons3, X as X3 } from "lucide-react";
|
|
1002
|
-
import { forwardRef as
|
|
1003
|
-
import { jsx as
|
|
1004
|
-
var Input =
|
|
1005
|
-
({ label, error, theme, icon, onClear, value, onChange, classNames, ...props }, ref) => {
|
|
1043
|
+
import { forwardRef as forwardRef10 } from "react";
|
|
1044
|
+
import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1045
|
+
var Input = forwardRef10(
|
|
1046
|
+
({ label, error, description, theme, icon, onClear, value, onChange, classNames, ...props }, ref) => {
|
|
1006
1047
|
const handleClear = () => {
|
|
1007
1048
|
onChange?.({ target: { value: "" } });
|
|
1008
1049
|
onClear?.();
|
|
@@ -1012,23 +1053,24 @@ var Input = forwardRef9(
|
|
|
1012
1053
|
const hasIcon = !!icon;
|
|
1013
1054
|
const iconColor = theme === "dark" ? "text-white" : "text-grey-80";
|
|
1014
1055
|
return /* @__PURE__ */ jsxs10("div", { className: "group flex w-full flex-col gap-1", "data-testid": `input-wrapper-${props.id}`, children: [
|
|
1015
|
-
label && /* @__PURE__ */
|
|
1056
|
+
label && /* @__PURE__ */ jsx17(
|
|
1016
1057
|
Label_default,
|
|
1017
1058
|
{
|
|
1018
1059
|
text: label,
|
|
1019
1060
|
htmlFor: props.name,
|
|
1020
1061
|
required: props.required,
|
|
1062
|
+
description,
|
|
1021
1063
|
className: classNames?.label
|
|
1022
1064
|
}
|
|
1023
1065
|
),
|
|
1024
1066
|
/* @__PURE__ */ jsxs10("div", { className: "relative flex flex-row items-center", children: [
|
|
1025
|
-
IconComponent && /* @__PURE__ */
|
|
1067
|
+
IconComponent && /* @__PURE__ */ jsx17(
|
|
1026
1068
|
IconComponent,
|
|
1027
1069
|
{
|
|
1028
1070
|
className: `absolute left-3 h-4 w-4 ${iconColor} opacity-50 group-hover:opacity-100`
|
|
1029
1071
|
}
|
|
1030
1072
|
),
|
|
1031
|
-
/* @__PURE__ */
|
|
1073
|
+
/* @__PURE__ */ jsx17(
|
|
1032
1074
|
"input",
|
|
1033
1075
|
{
|
|
1034
1076
|
className: cn(inputVariants({ theme, hasIcon })),
|
|
@@ -1040,7 +1082,7 @@ var Input = forwardRef9(
|
|
|
1040
1082
|
...props
|
|
1041
1083
|
}
|
|
1042
1084
|
),
|
|
1043
|
-
hasIcon && value && /* @__PURE__ */
|
|
1085
|
+
hasIcon && value && /* @__PURE__ */ jsx17(
|
|
1044
1086
|
X3,
|
|
1045
1087
|
{
|
|
1046
1088
|
className: `absolute right-3 h-4 w-4 cursor-pointer ${iconColor}`,
|
|
@@ -1049,7 +1091,7 @@ var Input = forwardRef9(
|
|
|
1049
1091
|
}
|
|
1050
1092
|
)
|
|
1051
1093
|
] }),
|
|
1052
|
-
/* @__PURE__ */
|
|
1094
|
+
/* @__PURE__ */ jsx17(ErrorMessage_default, { message: error })
|
|
1053
1095
|
] });
|
|
1054
1096
|
}
|
|
1055
1097
|
);
|
|
@@ -1105,26 +1147,334 @@ var inputVariants = cva5(
|
|
|
1105
1147
|
var Input_default = Input;
|
|
1106
1148
|
|
|
1107
1149
|
// src/components/demos/InputDemo.tsx
|
|
1108
|
-
import { jsx as
|
|
1150
|
+
import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1109
1151
|
function InputDemo() {
|
|
1110
1152
|
return /* @__PURE__ */ jsxs11("div", { className: "m-4", children: [
|
|
1111
|
-
/* @__PURE__ */
|
|
1153
|
+
/* @__PURE__ */ jsx18("h3", { children: "Input" }),
|
|
1112
1154
|
/* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-2 md:flex-row", children: [
|
|
1113
|
-
/* @__PURE__ */
|
|
1114
|
-
/* @__PURE__ */
|
|
1115
|
-
/* @__PURE__ */
|
|
1155
|
+
/* @__PURE__ */ jsx18("div", { className: "bg-green-80 p-2", children: /* @__PURE__ */ jsx18(Input_default, { theme: "dark", icon: "Search" }) }),
|
|
1156
|
+
/* @__PURE__ */ jsx18("div", { className: "p-2", children: /* @__PURE__ */ jsx18(Input_default, { label: "Required input", required: true, description: "This is a tooltip" }) }),
|
|
1157
|
+
/* @__PURE__ */ jsx18("div", { className: "p-2", children: /* @__PURE__ */ jsx18(Input_default, { icon: "MapPin" }) })
|
|
1116
1158
|
] })
|
|
1117
1159
|
] });
|
|
1118
1160
|
}
|
|
1119
1161
|
var InputDemo_default = InputDemo;
|
|
1120
1162
|
|
|
1163
|
+
// src/components/ui/Counter.tsx
|
|
1164
|
+
import { cva as cva6 } from "cva";
|
|
1165
|
+
import { Minus as Minus2, Plus } from "lucide-react";
|
|
1166
|
+
import { forwardRef as forwardRef11, useEffect as useEffect3, useState as useState4 } from "react";
|
|
1167
|
+
import { jsx as jsx19, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1168
|
+
var Counter = forwardRef11(
|
|
1169
|
+
({ label, error, min, max, step = 1, description, theme, value, classNames, onChange, ...props }, ref) => {
|
|
1170
|
+
const [count, setCount] = useState4(0);
|
|
1171
|
+
useEffect3(() => {
|
|
1172
|
+
setCount(value ?? 0);
|
|
1173
|
+
}, [value]);
|
|
1174
|
+
const handleChange = (e) => {
|
|
1175
|
+
const newValue = parseInt(e.target.value.replace(/\D/g, ""), 10);
|
|
1176
|
+
if (isNaN(newValue)) return;
|
|
1177
|
+
if (min && newValue < min) {
|
|
1178
|
+
onChange?.(min);
|
|
1179
|
+
setCount(min);
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
if (max && newValue > max) {
|
|
1183
|
+
onChange?.(max);
|
|
1184
|
+
setCount(max);
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
onChange?.(newValue);
|
|
1188
|
+
setCount(newValue);
|
|
1189
|
+
};
|
|
1190
|
+
const decrement = () => {
|
|
1191
|
+
const proposedValue = count - step;
|
|
1192
|
+
const newValue = Math.max(min ?? -Infinity, proposedValue);
|
|
1193
|
+
onChange?.(newValue);
|
|
1194
|
+
setCount(newValue);
|
|
1195
|
+
};
|
|
1196
|
+
const increment = () => {
|
|
1197
|
+
const proposedValue = count + step;
|
|
1198
|
+
const newValue = Math.min(max ?? Infinity, proposedValue);
|
|
1199
|
+
onChange?.(newValue);
|
|
1200
|
+
setCount(newValue);
|
|
1201
|
+
};
|
|
1202
|
+
return /* @__PURE__ */ jsxs12(
|
|
1203
|
+
"div",
|
|
1204
|
+
{
|
|
1205
|
+
className: cn("flex w-auto flex-col gap-1", classNames?.root),
|
|
1206
|
+
"data-testid": `counter-wrapper-${props.id}`,
|
|
1207
|
+
children: [
|
|
1208
|
+
label && /* @__PURE__ */ jsx19(
|
|
1209
|
+
Label_default,
|
|
1210
|
+
{
|
|
1211
|
+
text: label,
|
|
1212
|
+
htmlFor: props.name,
|
|
1213
|
+
required: props.required,
|
|
1214
|
+
description,
|
|
1215
|
+
className: classNames?.label
|
|
1216
|
+
}
|
|
1217
|
+
),
|
|
1218
|
+
/* @__PURE__ */ jsxs12("div", { className: "relative flex w-[122px] flex-row items-center", children: [
|
|
1219
|
+
/* @__PURE__ */ jsx19(
|
|
1220
|
+
"button",
|
|
1221
|
+
{
|
|
1222
|
+
type: "button",
|
|
1223
|
+
className: "absolute inset-y-0 left-1 my-auto flex h-8 w-8 cursor-pointer items-center justify-center rounded-full hover:bg-pickle-20",
|
|
1224
|
+
onClick: decrement,
|
|
1225
|
+
children: /* @__PURE__ */ jsx19(Minus2, { className: "h-4 w-4 text-green-100" })
|
|
1226
|
+
}
|
|
1227
|
+
),
|
|
1228
|
+
/* @__PURE__ */ jsx19(
|
|
1229
|
+
"input",
|
|
1230
|
+
{
|
|
1231
|
+
className: cn(counterVariants({ theme }), classNames?.input),
|
|
1232
|
+
ref,
|
|
1233
|
+
value: count,
|
|
1234
|
+
onChange: handleChange,
|
|
1235
|
+
"data-testid": `counter-element-${props.id}`,
|
|
1236
|
+
...props
|
|
1237
|
+
}
|
|
1238
|
+
),
|
|
1239
|
+
/* @__PURE__ */ jsx19(
|
|
1240
|
+
"button",
|
|
1241
|
+
{
|
|
1242
|
+
type: "button",
|
|
1243
|
+
className: "absolute inset-y-0 right-1 my-auto flex h-8 w-8 cursor-pointer items-center justify-center rounded-full hover:bg-pickle-20",
|
|
1244
|
+
onClick: increment,
|
|
1245
|
+
children: /* @__PURE__ */ jsx19(Plus, { className: "h-4 w-4 text-green-100" })
|
|
1246
|
+
}
|
|
1247
|
+
)
|
|
1248
|
+
] }),
|
|
1249
|
+
/* @__PURE__ */ jsx19(ErrorMessage_default, { message: error })
|
|
1250
|
+
]
|
|
1251
|
+
}
|
|
1252
|
+
);
|
|
1253
|
+
}
|
|
1254
|
+
);
|
|
1255
|
+
Counter.displayName = "Counter";
|
|
1256
|
+
var counterVariants = cva6(
|
|
1257
|
+
[
|
|
1258
|
+
"border-input",
|
|
1259
|
+
"placeholder:text-muted-foreground",
|
|
1260
|
+
"focus-visible:ring-ring",
|
|
1261
|
+
"inline-flex",
|
|
1262
|
+
"w-[122px]",
|
|
1263
|
+
"h-11",
|
|
1264
|
+
"items-center",
|
|
1265
|
+
"justify-start",
|
|
1266
|
+
"gap-3",
|
|
1267
|
+
"rounded-lg",
|
|
1268
|
+
"bg-transparent",
|
|
1269
|
+
"px-3",
|
|
1270
|
+
"pt-0.5",
|
|
1271
|
+
"text-sm",
|
|
1272
|
+
"text-center",
|
|
1273
|
+
"shadow-sm",
|
|
1274
|
+
"ring-grey-50",
|
|
1275
|
+
"transition-colors",
|
|
1276
|
+
"focus-visible:outline-none",
|
|
1277
|
+
"focus-visible:ring-1",
|
|
1278
|
+
"disabled:cursor-not-allowed",
|
|
1279
|
+
"disabled:opacity-50",
|
|
1280
|
+
"appearance-none",
|
|
1281
|
+
"[&::-webkit-search-cancel-button]:appearance-none",
|
|
1282
|
+
"[&::-webkit-search-decoration]:appearance-none",
|
|
1283
|
+
"[&::-webkit-search-results-button]:appearance-none",
|
|
1284
|
+
"[&::-webkit-search-results-decoration]:appearance-none",
|
|
1285
|
+
"[&::-ms-clear]:display-none",
|
|
1286
|
+
"[&::-ms-reveal]:display-none"
|
|
1287
|
+
],
|
|
1288
|
+
{
|
|
1289
|
+
variants: {
|
|
1290
|
+
theme: {
|
|
1291
|
+
light: "text-grey-80 border",
|
|
1292
|
+
dark: "text-white"
|
|
1293
|
+
},
|
|
1294
|
+
hasIcon: {
|
|
1295
|
+
false: "pl-3",
|
|
1296
|
+
true: "pl-8"
|
|
1297
|
+
}
|
|
1298
|
+
},
|
|
1299
|
+
defaultVariants: {
|
|
1300
|
+
theme: "light",
|
|
1301
|
+
hasIcon: false
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
);
|
|
1305
|
+
|
|
1306
|
+
// src/components/demos/CounterDemo.tsx
|
|
1307
|
+
import { useState as useState5 } from "react";
|
|
1308
|
+
import { jsx as jsx20, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1309
|
+
function CounterDemo() {
|
|
1310
|
+
const [count, setCount] = useState5(0);
|
|
1311
|
+
return /* @__PURE__ */ jsxs13("div", { className: "m-4", children: [
|
|
1312
|
+
/* @__PURE__ */ jsx20("h3", { children: "Counter" }),
|
|
1313
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-2 md:flex-row", children: [
|
|
1314
|
+
/* @__PURE__ */ jsx20("div", { className: "p-2", children: /* @__PURE__ */ jsx20(
|
|
1315
|
+
Counter,
|
|
1316
|
+
{
|
|
1317
|
+
label: "Required Counter",
|
|
1318
|
+
required: true,
|
|
1319
|
+
value: count,
|
|
1320
|
+
onChange: setCount,
|
|
1321
|
+
description: "This is a tooltip"
|
|
1322
|
+
}
|
|
1323
|
+
) }),
|
|
1324
|
+
/* @__PURE__ */ jsx20("div", { className: "p-2", children: /* @__PURE__ */ jsx20(Counter, { min: 0, max: 10, step: 2 }) })
|
|
1325
|
+
] })
|
|
1326
|
+
] });
|
|
1327
|
+
}
|
|
1328
|
+
var CounterDemo_default = CounterDemo;
|
|
1329
|
+
|
|
1330
|
+
// src/lib/google.ts
|
|
1331
|
+
import { Client, PlaceAutocompleteType } from "@googlemaps/google-maps-services-js";
|
|
1332
|
+
var client = new Client();
|
|
1333
|
+
var autocomplete = async (input, key) => {
|
|
1334
|
+
try {
|
|
1335
|
+
const response = await client.placeAutocomplete({
|
|
1336
|
+
params: { input, key, types: PlaceAutocompleteType.address }
|
|
1337
|
+
});
|
|
1338
|
+
return response.data.predictions;
|
|
1339
|
+
} catch (error) {
|
|
1340
|
+
console.error(error);
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
|
|
1344
|
+
// src/components/ui/PlacesQueryInput.tsx
|
|
1345
|
+
import { CircleX as CircleX2, LoaderCircle } from "lucide-react";
|
|
1346
|
+
import { useState as useState6, useCallback, useRef as useRef2, useEffect as useEffect4 } from "react";
|
|
1347
|
+
import { jsx as jsx21, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1348
|
+
function PlacesQueryInput({
|
|
1349
|
+
apiKey,
|
|
1350
|
+
selected,
|
|
1351
|
+
onSelect,
|
|
1352
|
+
className
|
|
1353
|
+
}) {
|
|
1354
|
+
const [predictions, setPredictions] = useState6(null);
|
|
1355
|
+
const [input, setInput] = useState6(selected?.description ?? "");
|
|
1356
|
+
const [isLoadingPredictions, setIsLoadingPredictions] = useState6(false);
|
|
1357
|
+
const [shouldOpenUpward, setShouldOpenUpward] = useState6(false);
|
|
1358
|
+
const timeoutRef = useRef2(null);
|
|
1359
|
+
const inputRef = useRef2(null);
|
|
1360
|
+
const debouncedAutocomplete = useCallback((value) => {
|
|
1361
|
+
if (timeoutRef.current) {
|
|
1362
|
+
clearTimeout(timeoutRef.current);
|
|
1363
|
+
}
|
|
1364
|
+
timeoutRef.current = setTimeout(async () => {
|
|
1365
|
+
if (value.length > 2) {
|
|
1366
|
+
setIsLoadingPredictions(true);
|
|
1367
|
+
const fetchedPredictions = await autocomplete(value, apiKey);
|
|
1368
|
+
fetchedPredictions && setIsLoadingPredictions(false);
|
|
1369
|
+
setPredictions(fetchedPredictions ?? []);
|
|
1370
|
+
} else {
|
|
1371
|
+
setPredictions(null);
|
|
1372
|
+
}
|
|
1373
|
+
}, 300);
|
|
1374
|
+
}, []);
|
|
1375
|
+
const handleInputChange = (value) => {
|
|
1376
|
+
setInput(value);
|
|
1377
|
+
debouncedAutocomplete(value);
|
|
1378
|
+
};
|
|
1379
|
+
const handleSelect = (prediction) => {
|
|
1380
|
+
onSelect(prediction);
|
|
1381
|
+
setPredictions(null);
|
|
1382
|
+
setInput(prediction.description);
|
|
1383
|
+
};
|
|
1384
|
+
const handleClear = () => {
|
|
1385
|
+
onSelect();
|
|
1386
|
+
setPredictions(null);
|
|
1387
|
+
setInput("");
|
|
1388
|
+
};
|
|
1389
|
+
const handleBlur = () => setTimeout(() => setPredictions(null), 200);
|
|
1390
|
+
useEffect4(() => {
|
|
1391
|
+
const checkDropdownPosition = () => {
|
|
1392
|
+
if (inputRef.current) {
|
|
1393
|
+
const rect = inputRef.current.getBoundingClientRect();
|
|
1394
|
+
const windowHeight = window.innerHeight;
|
|
1395
|
+
setShouldOpenUpward(rect.bottom + 200 > windowHeight);
|
|
1396
|
+
}
|
|
1397
|
+
};
|
|
1398
|
+
checkDropdownPosition();
|
|
1399
|
+
window.addEventListener("resize", checkDropdownPosition);
|
|
1400
|
+
return () => window.removeEventListener("resize", checkDropdownPosition);
|
|
1401
|
+
}, []);
|
|
1402
|
+
return /* @__PURE__ */ jsx21("div", { className: cn("relative w-full", className), ref: inputRef, onBlur: handleBlur, children: /* @__PURE__ */ jsxs14(Command, { children: [
|
|
1403
|
+
/* @__PURE__ */ jsxs14("div", { className: "relative w-full", children: [
|
|
1404
|
+
/* @__PURE__ */ jsx21(
|
|
1405
|
+
CommandInput,
|
|
1406
|
+
{
|
|
1407
|
+
placeholder: "Type an address to search...",
|
|
1408
|
+
value: input,
|
|
1409
|
+
onValueChange: handleInputChange,
|
|
1410
|
+
className: "truncate pr-8"
|
|
1411
|
+
}
|
|
1412
|
+
),
|
|
1413
|
+
isLoadingPredictions && /* @__PURE__ */ jsx21(LoaderCircle, { className: "absolute inset-y-0 right-2 my-auto flex h-8 w-8 animate-spin items-center justify-center rounded-full text-green-100" }),
|
|
1414
|
+
input && /* @__PURE__ */ jsx21(
|
|
1415
|
+
"button",
|
|
1416
|
+
{
|
|
1417
|
+
type: "button",
|
|
1418
|
+
className: "absolute inset-y-0 right-2 my-auto flex h-8 w-8 cursor-pointer items-center justify-center rounded-full hover:bg-pickle-20",
|
|
1419
|
+
onClick: handleClear,
|
|
1420
|
+
children: /* @__PURE__ */ jsx21(CircleX2, { className: "h-4 w-4 text-green-100" })
|
|
1421
|
+
}
|
|
1422
|
+
)
|
|
1423
|
+
] }),
|
|
1424
|
+
predictions && /* @__PURE__ */ jsxs14(
|
|
1425
|
+
CommandList,
|
|
1426
|
+
{
|
|
1427
|
+
className: cn(
|
|
1428
|
+
"absolute z-50 w-full rounded-md border bg-white shadow-lg",
|
|
1429
|
+
shouldOpenUpward ? "bottom-full" : "top-full"
|
|
1430
|
+
),
|
|
1431
|
+
children: [
|
|
1432
|
+
/* @__PURE__ */ jsx21(CommandEmpty, { children: "No results" }),
|
|
1433
|
+
/* @__PURE__ */ jsx21(CommandGroup, { children: predictions.map((prediction) => /* @__PURE__ */ jsx21(
|
|
1434
|
+
CommandItem,
|
|
1435
|
+
{
|
|
1436
|
+
onSelect: () => handleSelect(prediction),
|
|
1437
|
+
className: "truncate",
|
|
1438
|
+
children: prediction.description
|
|
1439
|
+
},
|
|
1440
|
+
prediction.place_id
|
|
1441
|
+
)) })
|
|
1442
|
+
]
|
|
1443
|
+
}
|
|
1444
|
+
)
|
|
1445
|
+
] }) });
|
|
1446
|
+
}
|
|
1447
|
+
var PlacesQueryInput_default = PlacesQueryInput;
|
|
1448
|
+
|
|
1449
|
+
// src/components/demos/PlacesQueryInputDemo.tsx
|
|
1450
|
+
import { useState as useState7 } from "react";
|
|
1451
|
+
import { jsx as jsx22, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1452
|
+
function PlacesQueryInputDemo() {
|
|
1453
|
+
const [selected, setSelected] = useState7();
|
|
1454
|
+
return /* @__PURE__ */ jsxs15("div", { className: "flex h-24 flex-col p-4", children: [
|
|
1455
|
+
/* @__PURE__ */ jsx22(
|
|
1456
|
+
PlacesQueryInput_default,
|
|
1457
|
+
{
|
|
1458
|
+
className: "max-w-96",
|
|
1459
|
+
apiKey: process.env.NEXT_PUBLIC_GOOGLE_API_KEY ?? "",
|
|
1460
|
+
selected,
|
|
1461
|
+
onSelect: setSelected
|
|
1462
|
+
}
|
|
1463
|
+
),
|
|
1464
|
+
/* @__PURE__ */ jsx22("h3", { className: "px-3", children: selected?.description })
|
|
1465
|
+
] });
|
|
1466
|
+
}
|
|
1467
|
+
var PlacesQueryInputDemo_default = PlacesQueryInputDemo;
|
|
1468
|
+
|
|
1121
1469
|
// src/components/demos/index.tsx
|
|
1122
|
-
import { jsx as
|
|
1470
|
+
import { jsx as jsx23, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1123
1471
|
function Demos() {
|
|
1124
|
-
return /* @__PURE__ */
|
|
1125
|
-
/* @__PURE__ */
|
|
1126
|
-
/* @__PURE__ */
|
|
1127
|
-
/* @__PURE__ */
|
|
1472
|
+
return /* @__PURE__ */ jsxs16("div", { children: [
|
|
1473
|
+
/* @__PURE__ */ jsx23(ComboboxDemo_default, {}),
|
|
1474
|
+
/* @__PURE__ */ jsx23(SelectDemo_default, {}),
|
|
1475
|
+
/* @__PURE__ */ jsx23(InputDemo_default, {}),
|
|
1476
|
+
/* @__PURE__ */ jsx23(CounterDemo_default, {}),
|
|
1477
|
+
/* @__PURE__ */ jsx23(PlacesQueryInputDemo_default, {})
|
|
1128
1478
|
] });
|
|
1129
1479
|
}
|
|
1130
1480
|
var demos_default = Demos;
|