@betterinternship/components 3.0.4 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +45 -45
  2. package/dist/components/accordion.js.map +1 -1
  3. package/dist/components/animated-count.js.map +1 -1
  4. package/dist/components/animated-shiny-text.js +12 -0
  5. package/dist/components/animated-shiny-text.js.map +1 -0
  6. package/dist/components/app-header.js.map +1 -1
  7. package/dist/components/autocomplete.js +335 -0
  8. package/dist/components/autocomplete.js.map +1 -0
  9. package/dist/components/avatar.js.map +1 -1
  10. package/dist/components/badge.js.map +1 -1
  11. package/dist/components/banner.js.map +1 -1
  12. package/dist/components/button.js.map +1 -1
  13. package/dist/components/calendar.js.map +1 -1
  14. package/dist/components/card.js.map +1 -1
  15. package/dist/components/carousel.js +126 -0
  16. package/dist/components/carousel.js.map +1 -0
  17. package/dist/components/checkbox.js.map +1 -1
  18. package/dist/components/chip-select.js +22 -0
  19. package/dist/components/chip-select.js.map +1 -0
  20. package/dist/components/collapsible.js +45 -0
  21. package/dist/components/collapsible.js.map +1 -0
  22. package/dist/components/context-menu.js +37 -0
  23. package/dist/components/context-menu.js.map +1 -0
  24. package/dist/components/dialog.js +10 -10
  25. package/dist/components/dialog.js.map +1 -1
  26. package/dist/components/divider.js.map +1 -1
  27. package/dist/components/dot-matrix.js +163 -0
  28. package/dist/components/dot-matrix.js.map +1 -0
  29. package/dist/components/dropdown-menu.js.map +1 -1
  30. package/dist/components/dropdown.js +262 -0
  31. package/dist/components/dropdown.js.map +1 -0
  32. package/dist/components/error.js +19 -0
  33. package/dist/components/error.js.map +1 -0
  34. package/dist/components/fab.js +9 -0
  35. package/dist/components/fab.js.map +1 -0
  36. package/dist/components/file-upload.js.map +1 -1
  37. package/dist/components/filter-chip.js.map +1 -1
  38. package/dist/components/form-checkbox-group.js.map +1 -1
  39. package/dist/components/form-checkbox.js.map +1 -1
  40. package/dist/components/form-date-picker.js.map +1 -1
  41. package/dist/components/form-field.js.map +1 -1
  42. package/dist/components/form-input.js.map +1 -1
  43. package/dist/components/form-month-picker.js.map +1 -1
  44. package/dist/components/form-radio.js.map +1 -1
  45. package/dist/components/form-textarea.js.map +1 -1
  46. package/dist/components/form.js +71 -0
  47. package/dist/components/form.js.map +1 -0
  48. package/dist/components/hover-card.js +13 -0
  49. package/dist/components/hover-card.js.map +1 -0
  50. package/dist/components/input-otp.js +24 -0
  51. package/dist/components/input-otp.js.map +1 -0
  52. package/dist/components/input.js.map +1 -1
  53. package/dist/components/label.js.map +1 -1
  54. package/dist/components/loader.js.map +1 -1
  55. package/dist/components/magnetic-button.js +32 -0
  56. package/dist/components/magnetic-button.js.map +1 -0
  57. package/dist/components/messages.js +9 -0
  58. package/dist/components/messages.js.map +1 -0
  59. package/dist/components/mobile-sheet-portal.js +17 -0
  60. package/dist/components/mobile-sheet-portal.js.map +1 -0
  61. package/dist/components/page-header.js.map +1 -1
  62. package/dist/components/paginator.js +44 -0
  63. package/dist/components/paginator.js.map +1 -0
  64. package/dist/components/popover.js.map +1 -1
  65. package/dist/components/progress.js +11 -0
  66. package/dist/components/progress.js.map +1 -0
  67. package/dist/components/radio-group.js.map +1 -1
  68. package/dist/components/select.js.map +1 -1
  69. package/dist/components/sheet.d.ts +1 -1
  70. package/dist/components/sheet.js +40 -0
  71. package/dist/components/sheet.js.map +1 -0
  72. package/dist/components/skeleton.js.map +1 -1
  73. package/dist/components/slider.js +11 -0
  74. package/dist/components/slider.js.map +1 -0
  75. package/dist/components/sonner-toast.js +78 -0
  76. package/dist/components/sonner-toast.js.map +1 -0
  77. package/dist/components/stepper.js.map +1 -1
  78. package/dist/components/switch.js.map +1 -1
  79. package/dist/components/table.js.map +1 -1
  80. package/dist/components/tabs.js.map +1 -1
  81. package/dist/components/textarea.js.map +1 -1
  82. package/dist/components/time-input-native.js.map +1 -1
  83. package/dist/components/timeline.js +16 -0
  84. package/dist/components/timeline.js.map +1 -0
  85. package/dist/components/toggle.js +15 -0
  86. package/dist/components/toggle.js.map +1 -0
  87. package/dist/components/tooltip.js.map +1 -1
  88. package/dist/hooks/use-detect-click-outside.js +29 -0
  89. package/dist/hooks/use-detect-click-outside.js.map +1 -0
  90. package/dist/hooks/use-field-focus.js.map +1 -1
  91. package/dist/hooks/use-mobile-sheet-viewport.js.map +1 -1
  92. package/dist/hooks/use-mobile.js.map +1 -1
  93. package/dist/hooks/use-resource-table.js.map +1 -1
  94. package/dist/hooks/useMQJob.js.map +1 -1
  95. package/dist/index.d.ts +34 -3
  96. package/dist/index.js +30 -0
  97. package/dist/index.js.map +1 -1
  98. package/dist/lib/interaction-styles.js.map +1 -1
  99. package/dist/node_modules/embla-carousel/esm/embla-carousel.esm.js +1670 -0
  100. package/dist/node_modules/embla-carousel/esm/embla-carousel.esm.js.map +1 -0
  101. package/dist/node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js +38 -0
  102. package/dist/node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js.map +1 -0
  103. package/dist/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js +39 -0
  104. package/dist/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js.map +1 -0
  105. package/dist/node_modules/input-otp/dist/index.js +25 -0
  106. package/dist/node_modules/input-otp/dist/index.js.map +1 -0
  107. package/dist/node_modules/react-hook-form/dist/index.esm.js +706 -0
  108. package/dist/node_modules/react-hook-form/dist/index.esm.js.map +1 -0
  109. package/dist/utils.js.map +1 -1
  110. package/package.json +326 -291
  111. package/theme.css +355 -355
  112. package/theme.legacy.css +84 -84
package/README.md CHANGED
@@ -1,45 +1,45 @@
1
- # Package.Components
2
-
3
- Contains common components shared between the different interfaces of the site.
4
-
5
- ## Running the playground
6
-
7
- This package comes with a simple React app that you can use to test components. It runs on `localhost:5173` in your browser.
8
-
9
- Run the playground:
10
-
11
- ```bash
12
- npm run dev:playground
13
- ```
14
-
15
- ## Checking the playground
16
-
17
- Run the documentation audit and review type check:
18
-
19
- ```bash
20
- npm --prefix playground run check:docs
21
- npm --prefix playground run check:review
22
- ```
23
-
24
- ## Updating the package
25
-
26
- 1. Build the package:
27
-
28
- ```bash
29
- npm run build
30
- ```
31
-
32
- 2. Commit the build:
33
-
34
- ```bash
35
- git add .
36
- git commit -m "<follow conventional commits, k thanks>"
37
- git push
38
- ```
39
-
40
- 3. Update the version and publish the package to NPM:
41
-
42
- ```bash
43
- npm version <major|minor|patch>
44
- npm publish
45
- ```
1
+ # Package.Components
2
+
3
+ Contains common components shared between the different interfaces of the site.
4
+
5
+ ## Running the playground
6
+
7
+ This package comes with a simple React app that you can use to test components. It runs on `localhost:5173` in your browser.
8
+
9
+ Run the playground:
10
+
11
+ ```bash
12
+ npm run dev:playground
13
+ ```
14
+
15
+ ## Checking the playground
16
+
17
+ Run the documentation audit and review type check:
18
+
19
+ ```bash
20
+ npm --prefix playground run check:docs
21
+ npm --prefix playground run check:review
22
+ ```
23
+
24
+ ## Updating the package
25
+
26
+ 1. Build the package:
27
+
28
+ ```bash
29
+ npm run build
30
+ ```
31
+
32
+ 2. Commit the build:
33
+
34
+ ```bash
35
+ git add .
36
+ git commit -m "<follow conventional commits, k thanks>"
37
+ git push
38
+ ```
39
+
40
+ 3. Update the version and publish the package to NPM:
41
+
42
+ ```bash
43
+ npm version <major|minor|patch>
44
+ npm publish
45
+ ```
@@ -1 +1 @@
1
- {"version":3,"file":"accordion.js","sources":["../../src/components/accordion.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport * as AccordionPrimitive from '@radix-ui/react-accordion';\r\nimport { ChevronDownIcon } from 'lucide-react';\r\n\r\nimport { cn } from '@/utils';\r\n\r\ntype AccordionProps =\r\n | React.ComponentProps<typeof AccordionPrimitive.Root>\r\n | (Omit<Extract<React.ComponentProps<typeof AccordionPrimitive.Root>, { type: 'multiple' }>, 'type'> & {\r\n /** Multiple sections can be open by default. */\r\n type?: 'multiple';\r\n });\r\n\r\nfunction Accordion(props: AccordionProps) {\r\n if (props.type === 'single') {\r\n return <AccordionPrimitive.Root data-slot=\"accordion\" {...props} />;\r\n }\r\n return <AccordionPrimitive.Root data-slot=\"accordion\" {...props} type=\"multiple\" />;\r\n}\r\n\r\nfunction AccordionItem({\r\n className,\r\n ...props\r\n}: React.ComponentProps<typeof AccordionPrimitive.Item>) {\r\n return (\r\n <AccordionPrimitive.Item\r\n data-slot=\"accordion-item\"\r\n className={cn('border-b border-border last:border-b-0', className)}\r\n {...props}\r\n />\r\n );\r\n}\r\n\r\nfunction AccordionTrigger({\r\n className,\r\n children,\r\n ...props\r\n}: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {\r\n return (\r\n <AccordionPrimitive.Header className=\"flex\">\r\n <AccordionPrimitive.Trigger\r\n data-slot=\"accordion-trigger\"\r\n className={cn(\r\n 'group/accordion focus-visible:outline-ring flex flex-1 cursor-pointer items-start justify-between gap-4 rounded-control-lg py-4 text-left text-sm font-medium transition-colors duration-state ease-out-strong pointer-fine:hover:text-primary-hover focus-visible:outline-3 focus-visible:outline-offset-4 disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none',\r\n className,\r\n )}\r\n {...props}\r\n >\r\n {children}\r\n <ChevronDownIcon className=\"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-[color,transform] duration-state ease-out-strong pointer-fine:group-hover/accordion:text-primary-hover group-data-[state=open]/accordion:rotate-180 motion-safe:pointer-fine:group-data-[state=closed]/accordion:group-hover/accordion:-rotate-45 motion-safe:pointer-fine:group-data-[state=open]/accordion:group-hover/accordion:rotate-[225deg] motion-reduce:transition-none\" />\r\n </AccordionPrimitive.Trigger>\r\n </AccordionPrimitive.Header>\r\n );\r\n}\r\n\r\nfunction AccordionContent({\r\n className,\r\n children,\r\n ...props\r\n}: React.ComponentProps<typeof AccordionPrimitive.Content>) {\r\n return (\r\n <AccordionPrimitive.Content\r\n data-slot=\"accordion-content\"\r\n className=\"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-base\"\r\n {...props}\r\n >\r\n <div className={cn('pt-0 pb-4', className)}>{children}</div>\r\n </AccordionPrimitive.Content>\r\n );\r\n}\r\n\r\nexport { Accordion, AccordionItem, AccordionTrigger, AccordionContent };\r\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;AAaA,SAAS,SAAS,CAAC,KAAqB,EAAA;AACtC,IAAA,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;QAC3B,OAAOA,GAAA,CAAC,kBAAkB,CAAC,IAAI,iBAAW,WAAW,EAAA,GAAK,KAAK,EAAA,CAAI;IACrE;AACA,IAAA,OAAOA,GAAA,CAAC,kBAAkB,CAAC,IAAI,EAAA,EAAA,WAAA,EAAW,WAAW,EAAA,GAAK,KAAK,EAAE,IAAI,EAAC,UAAU,GAAG;AACrF;AAEA,SAAS,aAAa,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EAC6C,EAAA;IACrD,QACEA,IAAC,kBAAkB,CAAC,IAAI,EAAA,EAAA,WAAA,EACZ,gBAAgB,EAC1B,SAAS,EAAE,EAAE,CAAC,wCAAwC,EAAE,SAAS,CAAC,KAC9D,KAAK,EAAA,CACT;AAEN;AAEA,SAAS,gBAAgB,CAAC,EACxB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACgD,EAAA;AACxD,IAAA,QACEA,GAAA,CAAC,kBAAkB,CAAC,MAAM,EAAA,EAAC,SAAS,EAAC,MAAM,EAAA,QAAA,EACzCC,IAAA,CAAC,kBAAkB,CAAC,OAAO,iBACf,mBAAmB,EAC7B,SAAS,EAAE,EAAE,CACX,4XAA4X,EAC5X,SAAS,CACV,KACG,KAAK,EAAA,QAAA,EAAA,CAER,QAAQ,EACTD,GAAA,CAAC,eAAe,EAAA,EAAC,SAAS,EAAC,ucAAuc,GAAG,CAAA,EAAA,CAC1c,EAAA,CACH;AAEhC;AAEA,SAAS,gBAAgB,CAAC,EACxB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACgD,EAAA;AACxD,IAAA,QACEA,GAAA,CAAC,kBAAkB,CAAC,OAAO,EAAA,EAAA,WAAA,EACf,mBAAmB,EAC7B,SAAS,EAAC,6GAA6G,EAAA,GACnH,KAAK,EAAA,QAAA,EAETA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAO,EAAA,CACjC;AAEjC;;;;"}
1
+ {"version":3,"file":"accordion.js","sources":["../../src/components/accordion.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as AccordionPrimitive from '@radix-ui/react-accordion';\nimport { ChevronDownIcon } from 'lucide-react';\n\nimport { cn } from '@/utils';\n\ntype AccordionProps =\n | React.ComponentProps<typeof AccordionPrimitive.Root>\n | (Omit<Extract<React.ComponentProps<typeof AccordionPrimitive.Root>, { type: 'multiple' }>, 'type'> & {\n /** Multiple sections can be open by default. */\n type?: 'multiple';\n });\n\nfunction Accordion(props: AccordionProps) {\n if (props.type === 'single') {\n return <AccordionPrimitive.Root data-slot=\"accordion\" {...props} />;\n }\n return <AccordionPrimitive.Root data-slot=\"accordion\" {...props} type=\"multiple\" />;\n}\n\nfunction AccordionItem({\n className,\n ...props\n}: React.ComponentProps<typeof AccordionPrimitive.Item>) {\n return (\n <AccordionPrimitive.Item\n data-slot=\"accordion-item\"\n className={cn('border-b border-border last:border-b-0', className)}\n {...props}\n />\n );\n}\n\nfunction AccordionTrigger({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {\n return (\n <AccordionPrimitive.Header className=\"flex\">\n <AccordionPrimitive.Trigger\n data-slot=\"accordion-trigger\"\n className={cn(\n 'group/accordion focus-visible:outline-ring flex flex-1 cursor-pointer items-start justify-between gap-4 rounded-control-lg py-4 text-left text-sm font-medium transition-colors duration-state ease-out-strong pointer-fine:hover:text-primary-hover focus-visible:outline-3 focus-visible:outline-offset-4 disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronDownIcon className=\"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-[color,transform] duration-state ease-out-strong pointer-fine:group-hover/accordion:text-primary-hover group-data-[state=open]/accordion:rotate-180 motion-safe:pointer-fine:group-data-[state=closed]/accordion:group-hover/accordion:-rotate-45 motion-safe:pointer-fine:group-data-[state=open]/accordion:group-hover/accordion:rotate-[225deg] motion-reduce:transition-none\" />\n </AccordionPrimitive.Trigger>\n </AccordionPrimitive.Header>\n );\n}\n\nfunction AccordionContent({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof AccordionPrimitive.Content>) {\n return (\n <AccordionPrimitive.Content\n data-slot=\"accordion-content\"\n className=\"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-base\"\n {...props}\n >\n <div className={cn('pt-0 pb-4', className)}>{children}</div>\n </AccordionPrimitive.Content>\n );\n}\n\nexport { Accordion, AccordionItem, AccordionTrigger, AccordionContent };\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;AAaA,SAAS,SAAS,CAAC,KAAqB,EAAA;AACtC,IAAA,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;QAC3B,OAAOA,GAAA,CAAC,kBAAkB,CAAC,IAAI,iBAAW,WAAW,EAAA,GAAK,KAAK,EAAA,CAAI;IACrE;AACA,IAAA,OAAOA,GAAA,CAAC,kBAAkB,CAAC,IAAI,EAAA,EAAA,WAAA,EAAW,WAAW,EAAA,GAAK,KAAK,EAAE,IAAI,EAAC,UAAU,GAAG;AACrF;AAEA,SAAS,aAAa,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EAC6C,EAAA;IACrD,QACEA,IAAC,kBAAkB,CAAC,IAAI,EAAA,EAAA,WAAA,EACZ,gBAAgB,EAC1B,SAAS,EAAE,EAAE,CAAC,wCAAwC,EAAE,SAAS,CAAC,KAC9D,KAAK,EAAA,CACT;AAEN;AAEA,SAAS,gBAAgB,CAAC,EACxB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACgD,EAAA;AACxD,IAAA,QACEA,GAAA,CAAC,kBAAkB,CAAC,MAAM,EAAA,EAAC,SAAS,EAAC,MAAM,EAAA,QAAA,EACzCC,IAAA,CAAC,kBAAkB,CAAC,OAAO,iBACf,mBAAmB,EAC7B,SAAS,EAAE,EAAE,CACX,4XAA4X,EAC5X,SAAS,CACV,KACG,KAAK,EAAA,QAAA,EAAA,CAER,QAAQ,EACTD,GAAA,CAAC,eAAe,EAAA,EAAC,SAAS,EAAC,ucAAuc,GAAG,CAAA,EAAA,CAC1c,EAAA,CACH;AAEhC;AAEA,SAAS,gBAAgB,CAAC,EACxB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACgD,EAAA;AACxD,IAAA,QACEA,GAAA,CAAC,kBAAkB,CAAC,OAAO,EAAA,EAAA,WAAA,EACf,mBAAmB,EAC7B,SAAS,EAAC,6GAA6G,EAAA,GACnH,KAAK,EAAA,QAAA,EAETA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAO,EAAA,CACjC;AAEjC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"animated-count.js","sources":["../../src/components/animated-count.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useEffect, useRef } from 'react';\r\nimport { AnimatePresence, motion, useReducedMotion } from 'framer-motion';\r\n\r\n/** A number that rolls up or down when its value changes. */\r\nexport const AnimatedCount = ({ value }: { value: number }) => {\r\n const reduceMotion = useReducedMotion();\r\n const previous = useRef(value);\r\n const direction = value >= previous.current ? 1 : -1;\r\n\r\n useEffect(() => {\r\n previous.current = value;\r\n }, [value]);\r\n\r\n return (\r\n <span className=\"relative inline-flex justify-center overflow-hidden tabular-nums\">\r\n <span className={reduceMotion ? undefined : 'invisible'}>{value}</span>\r\n {!reduceMotion && (\r\n <span aria-hidden=\"true\">\r\n <AnimatePresence initial={false} custom={direction}>\r\n <motion.span\r\n key={value}\r\n className=\"absolute inset-0 flex items-center justify-center\"\r\n initial={{ y: `${direction * 100}%`, opacity: 0 }}\r\n animate={{ y: '0%', opacity: 1 }}\r\n variants={{ exit: (exitDirection: number) => ({ y: `${exitDirection * -100}%`, opacity: 0 }) }}\r\n exit=\"exit\"\r\n transition={{ duration: 0.18, ease: 'easeOut' }}\r\n >\r\n {value}\r\n </motion.span>\r\n </AnimatePresence>\r\n </span>\r\n )}\r\n </span>\r\n );\r\n};\r\n\r\nexport default AnimatedCount;\r\n"],"names":[],"mappings":";;;;;AAKA;;AAEE;AACA;AACA;;AAGE;AACF;AAEA;AAsBF;;"}
1
+ {"version":3,"file":"animated-count.js","sources":["../../src/components/animated-count.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef } from 'react';\nimport { AnimatePresence, motion, useReducedMotion } from 'framer-motion';\n\n/** A number that rolls up or down when its value changes. */\nexport const AnimatedCount = ({ value }: { value: number }) => {\n const reduceMotion = useReducedMotion();\n const previous = useRef(value);\n const direction = value >= previous.current ? 1 : -1;\n\n useEffect(() => {\n previous.current = value;\n }, [value]);\n\n return (\n <span className=\"relative inline-flex justify-center overflow-hidden tabular-nums\">\n <span className={reduceMotion ? undefined : 'invisible'}>{value}</span>\n {!reduceMotion && (\n <span aria-hidden=\"true\">\n <AnimatePresence initial={false} custom={direction}>\n <motion.span\n key={value}\n className=\"absolute inset-0 flex items-center justify-center\"\n initial={{ y: `${direction * 100}%`, opacity: 0 }}\n animate={{ y: '0%', opacity: 1 }}\n variants={{ exit: (exitDirection: number) => ({ y: `${exitDirection * -100}%`, opacity: 0 }) }}\n exit=\"exit\"\n transition={{ duration: 0.18, ease: 'easeOut' }}\n >\n {value}\n </motion.span>\n </AnimatePresence>\n </span>\n )}\n </span>\n );\n};\n\nexport default AnimatedCount;\n"],"names":[],"mappings":";;;;;AAKA;;AAEE;AACA;AACA;;AAGE;AACF;AAEA;AAsBF;;"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useReducedMotion, motion } from 'framer-motion';
4
+ import { cn } from '../utils.js';
5
+
6
+ function AnimatedShinyText({ children, className, }) {
7
+ const reduceMotion = useReducedMotion();
8
+ return (jsx(motion.span, { className: cn("inline-block bg-[linear-gradient(110deg,rgba(15,23,42,0.9)_0%,rgba(15,23,42,0.9)_42%,rgba(255,255,255,0.75)_50%,rgba(15,23,42,0.9)_58%,rgba(15,23,42,0.9)_100%)] bg-[length:200%_100%] bg-clip-text align-baseline text-transparent motion-reduce:bg-none motion-reduce:text-slate-900", className), initial: false, animate: reduceMotion ? { backgroundPosition: '0% 0%' } : { backgroundPosition: ['200% 0%', '-200% 0%'] }, transition: reduceMotion ? { duration: 0 } : { duration: 4, ease: 'linear', repeat: Infinity }, children: children }));
9
+ }
10
+
11
+ export { AnimatedShinyText };
12
+ //# sourceMappingURL=animated-shiny-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animated-shiny-text.js","sources":["../../src/components/animated-shiny-text.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from \"react\";\nimport { motion, useReducedMotion } from \"framer-motion\";\nimport { cn } from \"@/utils\";\n\nexport function AnimatedShinyText({\n children,\n className,\n}: {\n children: ReactNode;\n className?: string;\n}) {\n const reduceMotion = useReducedMotion();\n\n return (\n <motion.span\n className={cn(\n \"inline-block bg-[linear-gradient(110deg,rgba(15,23,42,0.9)_0%,rgba(15,23,42,0.9)_42%,rgba(255,255,255,0.75)_50%,rgba(15,23,42,0.9)_58%,rgba(15,23,42,0.9)_100%)] bg-[length:200%_100%] bg-clip-text align-baseline text-transparent motion-reduce:bg-none motion-reduce:text-slate-900\",\n className,\n )}\n initial={false}\n animate={reduceMotion ? { backgroundPosition: '0% 0%' } : { backgroundPosition: ['200% 0%', '-200% 0%'] }}\n transition={reduceMotion ? { duration: 0 } : { duration: 4, ease: 'linear', repeat: Infinity }}\n >\n {children}\n </motion.span>\n );\n}\n"],"names":[],"mappings":";;;;;;AAaE;AAEA;AAaF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"app-header.js","sources":["../../src/components/app-header.tsx"],"sourcesContent":["'use client';\r\n\r\nimport Link from 'next/link';\r\nimport Image from 'next/image';\r\nimport { usePathname, useRouter } from 'next/navigation';\r\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\r\nimport {\r\n DropdownMenu,\r\n DropdownMenuTrigger,\r\n DropdownMenuContent,\r\n DropdownMenuItem,\r\n DropdownMenuSeparator,\r\n} from '@/components/dropdown-menu';\r\nimport { Button } from '@/components/button';\r\nimport { Divider } from '@/components/divider';\r\nimport { cn } from '@/utils';\r\nimport {\r\n LogOut,\r\n Menu,\r\n Search,\r\n X,\r\n UserRound,\r\n ChevronDown,\r\n ChevronRight,\r\n Handshake,\r\n Mail,\r\n History,\r\n FileText,\r\n Users,\r\n LayoutDashboard,\r\n FileSignature,\r\n GraduationCap,\r\n Building2,\r\n SearchCheck,\r\n} from 'lucide-react';\r\nimport { useState, useEffect } from 'react';\r\nimport type { ReactNode } from 'react';\r\nimport type { LucideIcon } from 'lucide-react';\r\n\r\nexport interface NavItem {\r\n href: string;\r\n label: string;\r\n badge?: number;\r\n icon?: LucideIcon;\r\n}\r\n\r\ninterface AppHeaderProps {\r\n /** Optional site name. */\r\n siteName?: string;\r\n homeHref: string;\r\n nav: NavItem[];\r\n /** Optional desktop links displayed next to the brand. */\r\n links?: NavItem[];\r\n userPrimary?: string;\r\n userSecondary?: string;\r\n logout: () => Promise<unknown>;\r\n postLogoutPath: string;\r\n profileHref?: string;\r\n userAvatarUrl?: string | null;\r\n accountNav?: NavItem[];\r\n /** Overrides the hardcoded \"Partners\" brand text. */\r\n brand?: string;\r\n /** Overrides the hardcoded \"/betterinternship-logo.png\" logo path. */\r\n logoPath?: string;\r\n /** Extra controls rendered next to the nav (desktop) and inside the drawer (mobile). */\r\n actions?: ReactNode;\r\n /**\r\n * Inline search control rendered in the header's center region on desktop\r\n * (`md` and up only). Purely a layout slot — the consumer owns all search\r\n * state and behavior. For mobile, pair with `onSearchClick`.\r\n */\r\n search?: ReactNode;\r\n /**\r\n * When set, renders a search icon button on mobile immediately left of the\r\n * hamburger. Typically opens a full-screen search overlay owned by the\r\n * consumer.\r\n */\r\n onSearchClick?: () => void;\r\n /**\r\n * Set to false to hide the mobile hamburger button and its side drawer\r\n * entirely — for consumers that provide their own mobile navigation (e.g.\r\n * a bottom tab bar) and don't want the nav/profile/logout items duplicated.\r\n * Defaults to true.\r\n */\r\n showMobileMenu?: boolean;\r\n}\r\n\r\nfunction labelIcon(label: string): LucideIcon {\r\n const map: Record<string, LucideIcon> = {\r\n Partners: Handshake,\r\n Invites: Mail,\r\n Invitations: Mail,\r\n Accounts: Users,\r\n 'Activity Log': History,\r\n 'MOA Templates': FileText,\r\n Universities: GraduationCap,\r\n Companies: Building2,\r\n 'Company Reviews': SearchCheck,\r\n 'Request MOA': FileSignature,\r\n Dashboard: LayoutDashboard,\r\n };\r\n return map[label] ?? Handshake;\r\n}\r\n\r\nexport function AppHeader({\r\n siteName,\r\n homeHref,\r\n nav,\r\n links = [],\r\n userPrimary,\r\n userSecondary,\r\n logout: logoutFn,\r\n postLogoutPath,\r\n profileHref,\r\n userAvatarUrl,\r\n accountNav = [],\r\n brand = 'Partners',\r\n logoPath = '/betterinternship-logo.png',\r\n actions,\r\n search,\r\n onSearchClick,\r\n showMobileMenu = true,\r\n}: AppHeaderProps) {\r\n const pathname = usePathname() ?? '';\r\n const router = useRouter();\r\n const queryClient = useQueryClient();\r\n const [isDrawerOpen, setIsDrawerOpen] = useState(false);\r\n\r\n useEffect(() => {\r\n setIsDrawerOpen(false);\r\n }, [pathname]);\r\n\r\n useEffect(() => {\r\n document.body.style.overflow = isDrawerOpen ? 'hidden' : '';\r\n return () => {\r\n document.body.style.overflow = '';\r\n };\r\n }, [isDrawerOpen]);\r\n\r\n const logout = useMutation({\r\n mutationFn: logoutFn,\r\n onSettled: () => {\r\n queryClient.clear();\r\n router.replace(postLogoutPath);\r\n },\r\n });\r\n\r\n const isActive = (href: string) =>\r\n pathname === href || pathname.startsWith(`${href}/`);\r\n\r\n return (\r\n <header className=\"sticky top-0 z-40 w-full bg-white\">\r\n <div className=\"flex min-h-[76px] w-full items-center gap-7 px-4 md:px-6 max-md:min-h-[72px] max-md:gap-3 max-md:py-3\">\r\n {/* Brand */}\r\n <Link\r\n href={homeHref}\r\n aria-label={brand}\r\n className=\"inline-flex shrink-0 items-center gap-3 text-lg font-[750] leading-[1.5] tracking-[-.0375rem] text-landing-navy focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-landing-blue max-md:gap-1.5 max-md:text-base\"\r\n >\r\n <div className=\"flex items-center gap-3 max-md:gap-1.5\">\r\n <Image\r\n src={logoPath}\r\n alt=\"\"\r\n width={24}\r\n height={24}\r\n className=\"flex-none\"\r\n />\r\n {/* Wordmark hides below md — the logo carries the link, which keeps\r\n its name via the aria-label above. */}\r\n <div className=\"hidden items-center md:flex\">\r\n <span>\r\n {brand}\r\n </span>\r\n {siteName && (\r\n <>\r\n <span className=\"mx-2.5 text-gray-300\" aria-hidden=\"true\">\r\n |\r\n </span>\r\n <span className=\"font-display text-gray-500\">{siteName}</span>\r\n </>\r\n )}\r\n </div>\r\n </div>\r\n </Link>\r\n\r\n {links.length > 0 && (\r\n <nav aria-label=\"Resources\" className=\"hidden shrink-0 items-center gap-4 text-sm font-[550] text-landing-nav md:flex xl:gap-7\">\r\n {links.map((item) => (\r\n <Link\r\n key={item.href}\r\n href={item.href}\r\n aria-current={isActive(item.href) ? 'page' : undefined}\r\n className=\"flex min-h-11 items-center rounded-sm text-landing-nav transition-colors duration-[180ms] hover:text-landing-blue focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-landing-blue aria-[current=page]:text-landing-blue\"\r\n >\r\n {item.label}\r\n </Link>\r\n ))}\r\n </nav>\r\n )}\r\n\r\n {/* Desktop center: inline search slot. The empty div doubles as the\r\n spacer that keeps the right cluster right-aligned when no search\r\n is passed. */}\r\n <div className=\"hidden min-w-0 flex-1 md:flex md:items-center\">\r\n {search}\r\n </div>\r\n\r\n {/* Desktop right side: nav buttons + user */}\r\n <div className=\"ml-auto hidden shrink-0 items-center gap-1 md:flex\">\r\n {nav.map((item) => {\r\n const Icon = item.icon ?? labelIcon(item.label);\r\n return (\r\n <Button\r\n key={item.href}\r\n variant=\"ghost\"\r\n className={cn(\r\n 'relative min-h-12 min-w-0 flex-col items-center justify-center gap-1 rounded-[.33em] px-3 py-1 text-xs font-normal text-gray-600 hover:bg-gray-100 hover:text-landing-blue focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-landing-blue',\r\n isActive(item.href)\r\n ? 'text-landing-blue'\r\n : '',\r\n )}\r\n onClick={() => router.push(item.href)}\r\n >\r\n <Icon className=\"h-6! w-6!\" strokeWidth={1.7} />\r\n <span className=\"text-xs\">{item.label}</span>\r\n {!!item.badge && (\r\n <span className=\"absolute -top-0.5 right-5.5 inline-flex h-4 w-4 items-center justify-center rounded-full bg-amber-400 text-xs font-bold leading-none text-amber-900\">\r\n {item.badge}\r\n </span>\r\n )}\r\n </Button>\r\n );\r\n })}\r\n\r\n {actions}\r\n\r\n {/* User dropdown */}\r\n <DropdownMenu>\r\n <DropdownMenuTrigger asChild>\r\n <Button\r\n variant=\"ghost\"\r\n className={cn(\r\n 'group min-h-12 w-20 flex-col items-center justify-center gap-1 rounded-[.33em] px-2 py-1 text-xs font-normal text-gray-600 hover:bg-gray-100 hover:text-landing-blue focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-landing-blue',\r\n (profileHref && isActive(profileHref)) ||\r\n accountNav.some((item) => isActive(item.href))\r\n ? 'text-landing-blue'\r\n : '',\r\n )}\r\n >\r\n <div className=\"flex h-6 w-6 items-center justify-center overflow-hidden rounded-full bg-gray-100\">\r\n {userAvatarUrl ? (\r\n <img\r\n src={userAvatarUrl}\r\n alt=\"\"\r\n className=\"h-full w-full object-contain\"\r\n />\r\n ) : (\r\n <UserRound className=\"h-5 w-5 text-gray-500\" />\r\n )}\r\n </div>\r\n <div className=\"flex items-center gap-0.5\">\r\n <span className=\"text-xs\">Account</span>\r\n <ChevronDown className=\"h-3! w-3! transition-transform group-data-[state=open]:rotate-180\" />\r\n </div>\r\n </Button>\r\n </DropdownMenuTrigger>\r\n <DropdownMenuContent align=\"end\" className=\"w-max min-w-44\">\r\n {userPrimary && (\r\n <div className=\"px-2 py-1.5\">\r\n <div className=\"text-center text-sm font-medium\">\r\n {userPrimary}\r\n </div>\r\n {userSecondary && (\r\n <div className=\"text-muted-foreground text-center text-xs\">\r\n {userSecondary}\r\n </div>\r\n )}\r\n </div>\r\n )}\r\n <DropdownMenuSeparator />\r\n {profileHref && (\r\n <DropdownMenuItem asChild>\r\n <Link href={profileHref}>\r\n <UserRound className=\"h-4 w-4\" />\r\n Profile\r\n </Link>\r\n </DropdownMenuItem>\r\n )}\r\n {accountNav.map((item) => {\r\n const Icon = item.icon ?? labelIcon(item.label);\r\n return (\r\n <DropdownMenuItem key={item.href} asChild>\r\n <Link href={item.href}>\r\n <Icon className=\"h-4 w-4\" />\r\n {item.label}\r\n </Link>\r\n </DropdownMenuItem>\r\n );\r\n })}\r\n {(profileHref || accountNav.length > 0) && (\r\n <DropdownMenuSeparator />\r\n )}\r\n <DropdownMenuItem\r\n variant=\"destructive\"\r\n disabled={logout.isPending}\r\n onClick={() => logout.mutate()}\r\n >\r\n <LogOut className=\"h-4 w-4\" />\r\n {logout.isPending ? 'Logging out...' : 'Sign Out'}\r\n </DropdownMenuItem>\r\n </DropdownMenuContent>\r\n </DropdownMenu>\r\n </div>\r\n\r\n {/* Mobile: search trigger + hamburger */}\r\n <div className=\"flex items-center gap-1 md:hidden\">\r\n {onSearchClick && (\r\n <button\r\n type=\"button\"\r\n aria-label=\"Search\"\r\n className=\"inline-flex h-10 w-10 items-center justify-center rounded-md border border-border hover:bg-gray-50\"\r\n onClick={onSearchClick}\r\n >\r\n <Search className=\"h-5 w-5\" />\r\n </button>\r\n )}\r\n {showMobileMenu && (\r\n <button\r\n type=\"button\"\r\n aria-label={isDrawerOpen ? 'Close menu' : 'Open menu'}\r\n className=\"inline-flex h-10 w-10 items-center justify-center rounded-md border border-border hover:bg-gray-50\"\r\n onClick={() => setIsDrawerOpen(!isDrawerOpen)}\r\n >\r\n {isDrawerOpen ? (\r\n <X className=\"h-5 w-5\" />\r\n ) : (\r\n <Menu className=\"h-5 w-5\" />\r\n )}\r\n </button>\r\n )}\r\n </div>\r\n </div>\r\n\r\n {/* Mobile right drawer */}\r\n {showMobileMenu && isDrawerOpen && (\r\n <div\r\n className=\"fixed inset-0 z-[30] duration-200 md:hidden\"\r\n onClick={() => setIsDrawerOpen(false)}\r\n />\r\n )}\r\n\r\n {showMobileMenu && (\r\n <div\r\n className={cn(\r\n 'fixed top-0 right-0 z-[31] h-[100svh] w-full max-w-[92%] border-l border-border bg-white shadow-xl sm:max-w-[420px] md:hidden',\r\n 'transition-transform duration-250 ease-out',\r\n isDrawerOpen ? 'translate-x-0' : 'translate-x-full',\r\n )}\r\n role=\"dialog\"\r\n aria-modal=\"true\"\r\n aria-label=\"Mobile menu\"\r\n >\r\n <div className=\"flex h-full flex-col\">\r\n <div className=\"mt-1 flex items-center justify-between border-b px-4 py-3\">\r\n <div className=\"flex items-center gap-2\">\r\n <Image\r\n src={logoPath}\r\n alt=\"\"\r\n width={25}\r\n height={25}\r\n className=\"h-6 w-6 rounded object-contain\"\r\n />\r\n <span className=\"text-sm font-semibold\">{brand}</span>\r\n <span className=\"rounded border border-border bg-gray-50 px-1 py-0 text-xs font-medium text-gray-400 leading-none\">\r\n {siteName}\r\n </span>\r\n </div>\r\n <button\r\n type=\"button\"\r\n aria-label=\"Close menu\"\r\n className=\"inline-flex h-9 w-9 items-center justify-center rounded-md transition-colors hover:bg-gray-100\"\r\n onClick={() => setIsDrawerOpen(false)}\r\n >\r\n <X className=\"h-5 w-5\" />\r\n </button>\r\n </div>\r\n\r\n <div className=\"flex-1 overflow-y-auto p-4\">\r\n {userPrimary && (\r\n <div className=\"flex items-center gap-2 pb-2\">\r\n <UserRound className=\"h-5 w-5 text-gray-500\" />\r\n <span className=\"text-sm font-semibold text-gray-900\">\r\n {userPrimary}\r\n </span>\r\n </div>\r\n )}\r\n\r\n <Divider className=\"my-4\" />\r\n\r\n {actions && <div className=\"mb-2\">{actions}</div>}\r\n\r\n <nav className=\"space-y-1\">\r\n {nav.map((item) => {\r\n const Icon = item.icon ?? labelIcon(item.label);\r\n return (\r\n <Link\r\n key={item.href}\r\n href={item.href}\r\n className=\"block w-full\"\r\n >\r\n <button className=\"flex w-full items-center justify-between rounded-md border border-transparent px-3 py-2 text-sm transition-colors hover:border-border-hover hover:bg-gray-50\">\r\n <div className=\"flex items-center gap-2\">\r\n <Icon className=\"h-4 w-4 text-gray-500\" />\r\n <span>{item.label}</span>\r\n {!!item.badge && (\r\n <span className=\"inline-flex h-4 w-4 items-center justify-center rounded-full bg-amber-400 text-xs font-bold leading-none text-amber-900\">\r\n !\r\n </span>\r\n )}\r\n </div>\r\n <ChevronRight className=\"h-4 w-4 text-gray-300\" />\r\n </button>\r\n </Link>\r\n );\r\n })}\r\n </nav>\r\n </div>\r\n\r\n <div className=\"mt-auto border-t px-4 py-3 space-y-1\">\r\n {profileHref && (\r\n <Link href={profileHref} className=\"block w-full\">\r\n <button className=\"flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm transition-colors hover:bg-gray-50\">\r\n <UserRound className=\"h-4 w-4\" />\r\n Profile\r\n </button>\r\n </Link>\r\n )}\r\n {accountNav.map((item) => {\r\n const Icon = item.icon ?? labelIcon(item.label);\r\n return (\r\n <Link\r\n key={item.href}\r\n href={item.href}\r\n className=\"block w-full\"\r\n >\r\n <button className=\"flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm transition-colors hover:bg-gray-50\">\r\n <Icon className=\"h-4 w-4\" />\r\n {item.label}\r\n </button>\r\n </Link>\r\n );\r\n })}\r\n <button\r\n onClick={() => logout.mutate()}\r\n disabled={logout.isPending}\r\n className=\"flex w-full items-center justify-center gap-2 rounded-md py-2 font-medium text-red-600 transition-colors hover:bg-red-50\"\r\n >\r\n <LogOut className=\"h-4 w-4\" />\r\n {logout.isPending ? 'Logging out...' : 'Sign Out'}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n )}\r\n </header>\r\n );\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;;;;;AAuFA;AACE;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEF;AACF;AAEM;AAmBJ;AACA;AACA;;;;AAKA;;AAGE;AACA;;AAEA;AACF;;AAGE;;;AAGE;;AAEH;AAED;AAGA;AA4DU;AACA;AAOQ;AACA;AAaV;AAYU;AACA;AACA;AA2CJ;AACA;AAQF;AAyGI;AACA;;AAkCF;AACA;;AA2BhB;;"}
1
+ {"version":3,"file":"app-header.js","sources":["../../src/components/app-header.tsx"],"sourcesContent":["'use client';\n\nimport Link from 'next/link';\nimport Image from 'next/image';\nimport { usePathname, useRouter } from 'next/navigation';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport {\n DropdownMenu,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n} from '@/components/dropdown-menu';\nimport { Button } from '@/components/button';\nimport { Divider } from '@/components/divider';\nimport { cn } from '@/utils';\nimport {\n LogOut,\n Menu,\n Search,\n X,\n UserRound,\n ChevronDown,\n ChevronRight,\n Handshake,\n Mail,\n History,\n FileText,\n Users,\n LayoutDashboard,\n FileSignature,\n GraduationCap,\n Building2,\n SearchCheck,\n} from 'lucide-react';\nimport { useState, useEffect } from 'react';\nimport type { ReactNode } from 'react';\nimport type { LucideIcon } from 'lucide-react';\n\nexport interface NavItem {\n href: string;\n label: string;\n badge?: number;\n icon?: LucideIcon;\n}\n\ninterface AppHeaderProps {\n /** Optional site name. */\n siteName?: string;\n homeHref: string;\n nav: NavItem[];\n /** Optional desktop links displayed next to the brand. */\n links?: NavItem[];\n userPrimary?: string;\n userSecondary?: string;\n logout: () => Promise<unknown>;\n postLogoutPath: string;\n profileHref?: string;\n userAvatarUrl?: string | null;\n accountNav?: NavItem[];\n /** Overrides the hardcoded \"Partners\" brand text. */\n brand?: string;\n /** Overrides the hardcoded \"/betterinternship-logo.png\" logo path. */\n logoPath?: string;\n /** Extra controls rendered next to the nav (desktop) and inside the drawer (mobile). */\n actions?: ReactNode;\n /**\n * Inline search control rendered in the header's center region on desktop\n * (`md` and up only). Purely a layout slot — the consumer owns all search\n * state and behavior. For mobile, pair with `onSearchClick`.\n */\n search?: ReactNode;\n /**\n * When set, renders a search icon button on mobile immediately left of the\n * hamburger. Typically opens a full-screen search overlay owned by the\n * consumer.\n */\n onSearchClick?: () => void;\n /**\n * Set to false to hide the mobile hamburger button and its side drawer\n * entirely — for consumers that provide their own mobile navigation (e.g.\n * a bottom tab bar) and don't want the nav/profile/logout items duplicated.\n * Defaults to true.\n */\n showMobileMenu?: boolean;\n}\n\nfunction labelIcon(label: string): LucideIcon {\n const map: Record<string, LucideIcon> = {\n Partners: Handshake,\n Invites: Mail,\n Invitations: Mail,\n Accounts: Users,\n 'Activity Log': History,\n 'MOA Templates': FileText,\n Universities: GraduationCap,\n Companies: Building2,\n 'Company Reviews': SearchCheck,\n 'Request MOA': FileSignature,\n Dashboard: LayoutDashboard,\n };\n return map[label] ?? Handshake;\n}\n\nexport function AppHeader({\n siteName,\n homeHref,\n nav,\n links = [],\n userPrimary,\n userSecondary,\n logout: logoutFn,\n postLogoutPath,\n profileHref,\n userAvatarUrl,\n accountNav = [],\n brand = 'Partners',\n logoPath = '/betterinternship-logo.png',\n actions,\n search,\n onSearchClick,\n showMobileMenu = true,\n}: AppHeaderProps) {\n const pathname = usePathname() ?? '';\n const router = useRouter();\n const queryClient = useQueryClient();\n const [isDrawerOpen, setIsDrawerOpen] = useState(false);\n\n useEffect(() => {\n setIsDrawerOpen(false);\n }, [pathname]);\n\n useEffect(() => {\n document.body.style.overflow = isDrawerOpen ? 'hidden' : '';\n return () => {\n document.body.style.overflow = '';\n };\n }, [isDrawerOpen]);\n\n const logout = useMutation({\n mutationFn: logoutFn,\n onSettled: () => {\n queryClient.clear();\n router.replace(postLogoutPath);\n },\n });\n\n const isActive = (href: string) =>\n pathname === href || pathname.startsWith(`${href}/`);\n\n return (\n <header className=\"sticky top-0 z-40 w-full bg-white\">\n <div className=\"flex min-h-[76px] w-full items-center gap-7 px-4 md:px-6 max-md:min-h-[72px] max-md:gap-3 max-md:py-3\">\n {/* Brand */}\n <Link\n href={homeHref}\n aria-label={brand}\n className=\"inline-flex shrink-0 items-center gap-3 text-lg font-[750] leading-[1.5] tracking-[-.0375rem] text-landing-navy focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-landing-blue max-md:gap-1.5 max-md:text-base\"\n >\n <div className=\"flex items-center gap-3 max-md:gap-1.5\">\n <Image\n src={logoPath}\n alt=\"\"\n width={24}\n height={24}\n className=\"flex-none\"\n />\n {/* Wordmark hides below md — the logo carries the link, which keeps\n its name via the aria-label above. */}\n <div className=\"hidden items-center md:flex\">\n <span>\n {brand}\n </span>\n {siteName && (\n <>\n <span className=\"mx-2.5 text-gray-300\" aria-hidden=\"true\">\n |\n </span>\n <span className=\"font-display text-gray-500\">{siteName}</span>\n </>\n )}\n </div>\n </div>\n </Link>\n\n {links.length > 0 && (\n <nav aria-label=\"Resources\" className=\"hidden shrink-0 items-center gap-4 text-sm font-[550] text-landing-nav md:flex xl:gap-7\">\n {links.map((item) => (\n <Link\n key={item.href}\n href={item.href}\n aria-current={isActive(item.href) ? 'page' : undefined}\n className=\"flex min-h-11 items-center rounded-sm text-landing-nav transition-colors duration-[180ms] hover:text-landing-blue focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-landing-blue aria-[current=page]:text-landing-blue\"\n >\n {item.label}\n </Link>\n ))}\n </nav>\n )}\n\n {/* Desktop center: inline search slot. The empty div doubles as the\n spacer that keeps the right cluster right-aligned when no search\n is passed. */}\n <div className=\"hidden min-w-0 flex-1 md:flex md:items-center\">\n {search}\n </div>\n\n {/* Desktop right side: nav buttons + user */}\n <div className=\"ml-auto hidden shrink-0 items-center gap-1 md:flex\">\n {nav.map((item) => {\n const Icon = item.icon ?? labelIcon(item.label);\n return (\n <Button\n key={item.href}\n variant=\"ghost\"\n className={cn(\n 'relative min-h-12 min-w-0 flex-col items-center justify-center gap-1 rounded-[.33em] px-3 py-1 text-xs font-normal text-gray-600 hover:bg-gray-100 hover:text-landing-blue focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-landing-blue',\n isActive(item.href)\n ? 'text-landing-blue'\n : '',\n )}\n onClick={() => router.push(item.href)}\n >\n <Icon className=\"h-6! w-6!\" strokeWidth={1.7} />\n <span className=\"text-xs\">{item.label}</span>\n {!!item.badge && (\n <span className=\"absolute -top-0.5 right-5.5 inline-flex h-4 w-4 items-center justify-center rounded-full bg-amber-400 text-xs font-bold leading-none text-amber-900\">\n {item.badge}\n </span>\n )}\n </Button>\n );\n })}\n\n {actions}\n\n {/* User dropdown */}\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n variant=\"ghost\"\n className={cn(\n 'group min-h-12 w-20 flex-col items-center justify-center gap-1 rounded-[.33em] px-2 py-1 text-xs font-normal text-gray-600 hover:bg-gray-100 hover:text-landing-blue focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-landing-blue',\n (profileHref && isActive(profileHref)) ||\n accountNav.some((item) => isActive(item.href))\n ? 'text-landing-blue'\n : '',\n )}\n >\n <div className=\"flex h-6 w-6 items-center justify-center overflow-hidden rounded-full bg-gray-100\">\n {userAvatarUrl ? (\n <img\n src={userAvatarUrl}\n alt=\"\"\n className=\"h-full w-full object-contain\"\n />\n ) : (\n <UserRound className=\"h-5 w-5 text-gray-500\" />\n )}\n </div>\n <div className=\"flex items-center gap-0.5\">\n <span className=\"text-xs\">Account</span>\n <ChevronDown className=\"h-3! w-3! transition-transform group-data-[state=open]:rotate-180\" />\n </div>\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"w-max min-w-44\">\n {userPrimary && (\n <div className=\"px-2 py-1.5\">\n <div className=\"text-center text-sm font-medium\">\n {userPrimary}\n </div>\n {userSecondary && (\n <div className=\"text-muted-foreground text-center text-xs\">\n {userSecondary}\n </div>\n )}\n </div>\n )}\n <DropdownMenuSeparator />\n {profileHref && (\n <DropdownMenuItem asChild>\n <Link href={profileHref}>\n <UserRound className=\"h-4 w-4\" />\n Profile\n </Link>\n </DropdownMenuItem>\n )}\n {accountNav.map((item) => {\n const Icon = item.icon ?? labelIcon(item.label);\n return (\n <DropdownMenuItem key={item.href} asChild>\n <Link href={item.href}>\n <Icon className=\"h-4 w-4\" />\n {item.label}\n </Link>\n </DropdownMenuItem>\n );\n })}\n {(profileHref || accountNav.length > 0) && (\n <DropdownMenuSeparator />\n )}\n <DropdownMenuItem\n variant=\"destructive\"\n disabled={logout.isPending}\n onClick={() => logout.mutate()}\n >\n <LogOut className=\"h-4 w-4\" />\n {logout.isPending ? 'Logging out...' : 'Sign Out'}\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n\n {/* Mobile: search trigger + hamburger */}\n <div className=\"flex items-center gap-1 md:hidden\">\n {onSearchClick && (\n <button\n type=\"button\"\n aria-label=\"Search\"\n className=\"inline-flex h-10 w-10 items-center justify-center rounded-md border border-border hover:bg-gray-50\"\n onClick={onSearchClick}\n >\n <Search className=\"h-5 w-5\" />\n </button>\n )}\n {showMobileMenu && (\n <button\n type=\"button\"\n aria-label={isDrawerOpen ? 'Close menu' : 'Open menu'}\n className=\"inline-flex h-10 w-10 items-center justify-center rounded-md border border-border hover:bg-gray-50\"\n onClick={() => setIsDrawerOpen(!isDrawerOpen)}\n >\n {isDrawerOpen ? (\n <X className=\"h-5 w-5\" />\n ) : (\n <Menu className=\"h-5 w-5\" />\n )}\n </button>\n )}\n </div>\n </div>\n\n {/* Mobile right drawer */}\n {showMobileMenu && isDrawerOpen && (\n <div\n className=\"fixed inset-0 z-[30] duration-200 md:hidden\"\n onClick={() => setIsDrawerOpen(false)}\n />\n )}\n\n {showMobileMenu && (\n <div\n className={cn(\n 'fixed top-0 right-0 z-[31] h-[100svh] w-full max-w-[92%] border-l border-border bg-white shadow-xl sm:max-w-[420px] md:hidden',\n 'transition-transform duration-250 ease-out',\n isDrawerOpen ? 'translate-x-0' : 'translate-x-full',\n )}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Mobile menu\"\n >\n <div className=\"flex h-full flex-col\">\n <div className=\"mt-1 flex items-center justify-between border-b px-4 py-3\">\n <div className=\"flex items-center gap-2\">\n <Image\n src={logoPath}\n alt=\"\"\n width={25}\n height={25}\n className=\"h-6 w-6 rounded object-contain\"\n />\n <span className=\"text-sm font-semibold\">{brand}</span>\n <span className=\"rounded border border-border bg-gray-50 px-1 py-0 text-xs font-medium text-gray-400 leading-none\">\n {siteName}\n </span>\n </div>\n <button\n type=\"button\"\n aria-label=\"Close menu\"\n className=\"inline-flex h-9 w-9 items-center justify-center rounded-md transition-colors hover:bg-gray-100\"\n onClick={() => setIsDrawerOpen(false)}\n >\n <X className=\"h-5 w-5\" />\n </button>\n </div>\n\n <div className=\"flex-1 overflow-y-auto p-4\">\n {userPrimary && (\n <div className=\"flex items-center gap-2 pb-2\">\n <UserRound className=\"h-5 w-5 text-gray-500\" />\n <span className=\"text-sm font-semibold text-gray-900\">\n {userPrimary}\n </span>\n </div>\n )}\n\n <Divider className=\"my-4\" />\n\n {actions && <div className=\"mb-2\">{actions}</div>}\n\n <nav className=\"space-y-1\">\n {nav.map((item) => {\n const Icon = item.icon ?? labelIcon(item.label);\n return (\n <Link\n key={item.href}\n href={item.href}\n className=\"block w-full\"\n >\n <button className=\"flex w-full items-center justify-between rounded-md border border-transparent px-3 py-2 text-sm transition-colors hover:border-border-hover hover:bg-gray-50\">\n <div className=\"flex items-center gap-2\">\n <Icon className=\"h-4 w-4 text-gray-500\" />\n <span>{item.label}</span>\n {!!item.badge && (\n <span className=\"inline-flex h-4 w-4 items-center justify-center rounded-full bg-amber-400 text-xs font-bold leading-none text-amber-900\">\n !\n </span>\n )}\n </div>\n <ChevronRight className=\"h-4 w-4 text-gray-300\" />\n </button>\n </Link>\n );\n })}\n </nav>\n </div>\n\n <div className=\"mt-auto border-t px-4 py-3 space-y-1\">\n {profileHref && (\n <Link href={profileHref} className=\"block w-full\">\n <button className=\"flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm transition-colors hover:bg-gray-50\">\n <UserRound className=\"h-4 w-4\" />\n Profile\n </button>\n </Link>\n )}\n {accountNav.map((item) => {\n const Icon = item.icon ?? labelIcon(item.label);\n return (\n <Link\n key={item.href}\n href={item.href}\n className=\"block w-full\"\n >\n <button className=\"flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm transition-colors hover:bg-gray-50\">\n <Icon className=\"h-4 w-4\" />\n {item.label}\n </button>\n </Link>\n );\n })}\n <button\n onClick={() => logout.mutate()}\n disabled={logout.isPending}\n className=\"flex w-full items-center justify-center gap-2 rounded-md py-2 font-medium text-red-600 transition-colors hover:bg-red-50\"\n >\n <LogOut className=\"h-4 w-4\" />\n {logout.isPending ? 'Logging out...' : 'Sign Out'}\n </button>\n </div>\n </div>\n </div>\n )}\n </header>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAuFA;AACE;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEF;AACF;AAEM;AAmBJ;AACA;AACA;;;;AAKA;;AAGE;AACA;;AAEA;AACF;;AAGE;;;AAGE;;AAEH;AAED;AAGA;AA4DU;AACA;AAOQ;AACA;AAaV;AAYU;AACA;AACA;AA2CJ;AACA;AAQF;AAyGI;AACA;;AAkCF;AACA;;AA2BhB;;"}
@@ -0,0 +1,335 @@
1
+ "use client";
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { useState, useRef, useId, useMemo, useEffect, Fragment } from 'react';
4
+ import { Input } from './input.js';
5
+ import { useDetectClickOutside } from '../hooks/use-detect-click-outside.js';
6
+ import { cn } from '../utils.js';
7
+ import { X, ChevronDown, PlusCircleIcon, Search } from 'lucide-react';
8
+ import { Label } from './label.js';
9
+ import { Button } from './button.js';
10
+ import { CheckboxVisual } from './checkbox.js';
11
+ import { Sheet, SheetContent, SheetTitle } from './sheet.js';
12
+ import { useMobile } from '../hooks/use-mobile.js';
13
+ import { useMobileSheetViewport } from '../hooks/use-mobile-sheet-viewport.js';
14
+ import { useFieldFocus, fieldFocusOutlineClassName, fieldInteractionClassName, FieldChromeContext } from '../hooks/use-field-focus.js';
15
+
16
+ /* -------------------------------------------------------
17
+ * Base component (array-based). Single uses length 0..1.
18
+ * -----------------------------------------------------*/
19
+ function AutocompleteBase({ required, options, value = [], setter, placeholder, className, multiple = true, label, labelAddon, allowCustomValue = false, preserveOptionOrder = false, emptyText = "No matching options", mobileDropdownMode = "sheet", inputIcons = false, ...props }) {
20
+ const [query, setQuery] = useState("");
21
+ const [isOpen, setIsOpen] = useState(false);
22
+ const [dropdownMaxHeight, setDropdownMaxHeight] = useState();
23
+ const isMobile = useMobile();
24
+ const clickOutsideRef = useDetectClickOutside({
25
+ onTriggered: () => {
26
+ // Radix owns outside dismissal for the portalled modal sheet.
27
+ if (isMobile && mobileDropdownMode === 'sheet')
28
+ return;
29
+ setIsOpen(false);
30
+ },
31
+ });
32
+ const rootRef = useRef(null);
33
+ const inputRef = useRef(null);
34
+ const sheetInputRef = useRef(null);
35
+ const sheetRef = useRef(null);
36
+ const sheetCloseRef = useRef(null);
37
+ const lastSelectionRef = useRef(0);
38
+ // Show the Button focus outline only for keyboard focus, not clicks.
39
+ const { keyboardFocus, focusProps: fieldFocusProps } = useFieldFocus();
40
+ const inputId = useId();
41
+ const flatOptions = useMemo(() => options.flatMap((option) => option.children?.length ? option.children : [option]), [options]);
42
+ const findExactOption = (value) => {
43
+ const normalizedValue = value.trim().toLowerCase();
44
+ return flatOptions.find((o) => o.name?.trim().toLowerCase() === normalizedValue ||
45
+ o.keywords?.some((k) => k === normalizedValue));
46
+ };
47
+ const resolveQuerySelection = (nextQuery, matchKeywords = true) => {
48
+ const text = nextQuery.trim();
49
+ if (!text)
50
+ return false;
51
+ const exact = matchKeywords
52
+ ? findExactOption(text)
53
+ : flatOptions.find((o) => o.name?.trim().toLowerCase() === text.toLowerCase());
54
+ if (exact) {
55
+ setter([exact.id]);
56
+ setQuery("");
57
+ return true;
58
+ }
59
+ if (allowCustomValue) {
60
+ setter([text]);
61
+ setQuery("");
62
+ return true;
63
+ }
64
+ return false;
65
+ };
66
+ const selectedSet = useMemo(() => new Set(value ?? []), [value]);
67
+ const filtered = useMemo(() => {
68
+ const q = query.trim().toLowerCase();
69
+ const base = q
70
+ ? flatOptions.filter((o) => o.name?.toLowerCase().includes(q) ||
71
+ options.some((group) => group.children?.some((child) => child.id === o.id) && group.name.toLowerCase().includes(q)) ||
72
+ o.keywords?.some((k) => k.includes(q)))
73
+ : flatOptions;
74
+ return preserveOptionOrder || options.some((option) => option.children?.length)
75
+ ? base
76
+ : base.slice().sort((a, b) => a.name.localeCompare(b.name));
77
+ }, [query, flatOptions, options, preserveOptionOrder]);
78
+ const toggle = (id) => {
79
+ lastSelectionRef.current = Date.now();
80
+ if (!multiple) {
81
+ setter([id]); // single-select
82
+ setIsOpen(false);
83
+ setQuery("");
84
+ return;
85
+ }
86
+ const set = new Set(value ?? []);
87
+ if (set.has(id))
88
+ set.delete(id);
89
+ else
90
+ set.add(id);
91
+ setter(Array.from(set));
92
+ };
93
+ const removeAt = (id) => {
94
+ const set = new Set(value ?? []);
95
+ set.delete(id);
96
+ setter(Array.from(set));
97
+ };
98
+ const selectedLabels = useMemo(() => (value ?? [])
99
+ .map((id) => {
100
+ const label = flatOptions.find((o) => o.id === id)?.name;
101
+ return label ?? (allowCustomValue ? String(id) : undefined);
102
+ })
103
+ .filter(Boolean), [value, flatOptions, allowCustomValue]);
104
+ const singleDisplay = !multiple && (selectedLabels[0] ?? "");
105
+ const useMobileSheet = isMobile && mobileDropdownMode === "sheet";
106
+ const sheetViewport = useMobileSheetViewport(isOpen && useMobileSheet);
107
+ const useInlineMobileDropdown = isMobile && mobileDropdownMode === "inline";
108
+ useEffect(() => {
109
+ if (!isOpen || !useInlineMobileDropdown) {
110
+ setDropdownMaxHeight(undefined);
111
+ return;
112
+ }
113
+ const updateDropdownMaxHeight = () => {
114
+ const rootRect = rootRef.current?.getBoundingClientRect();
115
+ if (!rootRect)
116
+ return;
117
+ const viewportHeight = window.visualViewport?.height ?? window.innerHeight;
118
+ const gap = 8;
119
+ const availableHeight = viewportHeight - rootRect.bottom - gap;
120
+ setDropdownMaxHeight(Math.max(0, Math.min(400, availableHeight)));
121
+ };
122
+ updateDropdownMaxHeight();
123
+ window.addEventListener("resize", updateDropdownMaxHeight);
124
+ window.visualViewport?.addEventListener("resize", updateDropdownMaxHeight);
125
+ window.visualViewport?.addEventListener("scroll", updateDropdownMaxHeight);
126
+ return () => {
127
+ window.removeEventListener("resize", updateDropdownMaxHeight);
128
+ window.visualViewport?.removeEventListener("resize", updateDropdownMaxHeight);
129
+ window.visualViewport?.removeEventListener("scroll", updateDropdownMaxHeight);
130
+ };
131
+ }, [isOpen, useInlineMobileDropdown]);
132
+ const suppressMobileKeyboard = isMobile && (useMobileSheet || (mobileDropdownMode === "inline" && !allowCustomValue));
133
+ // --- keyboard helpers for multi
134
+ const onMultiKeyDown = (e) => {
135
+ if (!multiple)
136
+ return;
137
+ if (allowCustomValue && e.key === "Enter" && query.trim().length > 0 && !findExactOption(query)) {
138
+ const text = query.trim();
139
+ const exact = findExactOption(text);
140
+ const nextId = exact ? exact.id : text;
141
+ const set = new Set(value ?? []);
142
+ set.add(nextId);
143
+ setter(Array.from(set));
144
+ setQuery("");
145
+ setIsOpen(true);
146
+ e.preventDefault();
147
+ return;
148
+ }
149
+ if (e.key === "Backspace" &&
150
+ query.length === 0 &&
151
+ (value?.length ?? 0) > 0) {
152
+ const last = value[value.length - 1];
153
+ removeAt(last);
154
+ e.preventDefault();
155
+ }
156
+ if (e.key === "Enter") {
157
+ const first = filtered[0];
158
+ if (first) {
159
+ toggle(first.id);
160
+ setQuery("");
161
+ setIsOpen(true);
162
+ e.preventDefault();
163
+ }
164
+ }
165
+ if (e.key === "ArrowDown")
166
+ setIsOpen(true);
167
+ if (e.key === "Escape")
168
+ setIsOpen(false);
169
+ };
170
+ // Same hover lift and press feedback as the Dropdown trigger.
171
+ const fieldClassName = cn(fieldInteractionClassName, keyboardFocus && fieldFocusOutlineClassName);
172
+ const decorateSingleInput = (input) => inputIcons ? (jsxs("div", { className: cn("relative min-w-0 flex-1", fieldClassName), ...fieldFocusProps, children: [inputIcons !== "search" && inputIcons !== "dropdown" && (jsx(Search, { className: "pointer-events-none absolute left-3 top-1/2 z-20 h-4 w-4 -translate-y-1/2 text-muted-foreground", "aria-hidden": "true" })), jsx(FieldChromeContext, { value: true, children: input }), inputIcons === "search" ? (jsx(Search, { className: "pointer-events-none absolute right-3 top-1/2 z-20 h-4 w-4 -translate-y-1/2 text-muted-foreground", "aria-hidden": "true" })) : (jsx(ChevronDown, { className: cn("pointer-events-none absolute right-3 top-1/2 z-20 h-4 w-4 -translate-y-1/2 text-muted-foreground transition-transform duration-interactive ease-out-strong motion-reduce:transition-none", isOpen && "rotate-180"), "aria-hidden": "true" }))] })) : (jsx("div", { className: cn("relative min-w-0 flex-1", fieldClassName), ...fieldFocusProps, children: jsx(FieldChromeContext, { value: true, children: input }) }));
173
+ const OptionsSurface = useMobileSheet ? SheetContent : 'div';
174
+ const sheetProps = useMobileSheet ? {
175
+ side: 'bottom',
176
+ showCloseButton: false,
177
+ overlayClassName: 'z-[1090] bg-black/25 backdrop-blur-[1px]',
178
+ 'aria-describedby': undefined,
179
+ onOpenAutoFocus: (event) => { event.preventDefault(); sheetCloseRef.current?.focus(); },
180
+ onCloseAutoFocus: (event) => { event.preventDefault(); inputRef.current?.focus(); },
181
+ } : {};
182
+ return (jsxs("div", { className: cn("relative w-full overflow-visible", className), ref: (node) => {
183
+ rootRef.current = node;
184
+ clickOutsideRef.current = node;
185
+ }, children: [label ? (jsx(Label, { label: label, required: required, labelAddon: labelAddon })) : null, multiple ? (
186
+ // ---------- MULTI: chips inline inside the box ----------
187
+ jsxs("div", { className: cn("relative flex min-h-form-control w-full flex-wrap items-center gap-1 rounded-control-lg border border-input bg-background px-[0.75em] pr-10 hover:border-input-hover", fieldClassName), ...fieldFocusProps, onClick: () => {
188
+ setIsOpen(true);
189
+ if (!suppressMobileKeyboard) {
190
+ inputRef.current?.focus();
191
+ }
192
+ }, children: [(value ?? []).map((id) => {
193
+ const label = flatOptions.find((o) => o.id === id)?.name ?? String(id);
194
+ return (jsxs("span", { className: "my-0.5 flex items-center gap-1 rounded-control-sm border border-input bg-muted px-2 text-xs", children: [label, jsx(Button, { type: "button", variant: "ghost", size: "xs", className: "ml-1 h-5 min-h-0 w-5 p-0 hover:bg-muted", onClick: (event) => { event.stopPropagation(); removeAt(id); }, "aria-label": `Remove ${label}`, children: jsx(X, { className: "h-3.5 w-3.5" }) })] }, String(id)));
195
+ }), jsx("input", { id: inputId, ref: inputRef, value: query, onChange: (e) => {
196
+ setQuery(e.target.value);
197
+ setIsOpen(true);
198
+ }, onBlur: () => {
199
+ if (useMobileSheet)
200
+ return;
201
+ // Delay slightly to let dropdown option clicks register first
202
+ setTimeout(() => {
203
+ if (Date.now() - lastSelectionRef.current < 250) {
204
+ return;
205
+ }
206
+ if (allowCustomValue && query.trim().length > 0) {
207
+ const text = query.trim();
208
+ const exact = findExactOption(text);
209
+ const nextId = exact ? exact.id : text;
210
+ setter(Array.from(new Set([...(value ?? []), nextId])));
211
+ setQuery("");
212
+ }
213
+ }, 150);
214
+ }, onKeyDown: onMultiKeyDown, onFocus: () => { if (!useMobileSheet)
215
+ setIsOpen(true); }, readOnly: suppressMobileKeyboard, placeholder: (value?.length ?? 0) === 0 ? placeholder : "", className: cn("h-[calc(var(--spacing-form-control)-2px)] min-w-[8ch] flex-1 border-none bg-transparent p-0 text-base outline-none focus:ring-0", "placeholder:text-muted-foreground/40"), ...props }), jsx(ChevronDown, { className: cn("pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground transition-transform duration-interactive ease-out-strong motion-reduce:transition-none", isOpen && "rotate-180"), "aria-hidden": "true" })] })) : (
216
+ // ---------- SINGLE: regular input ----------
217
+ decorateSingleInput(jsx(Input, { id: inputId, value: singleDisplay || query, className: cn("border-input", inputIcons === "search" || inputIcons === "dropdown" ? "pr-10" : inputIcons && "px-10"), placeholder: placeholder, readOnly: suppressMobileKeyboard, onChange: (e) => {
218
+ const nextQuery = e.target.value;
219
+ if ((value?.length ?? 0) > 0) {
220
+ setter([]);
221
+ }
222
+ const exact = findExactOption(nextQuery);
223
+ // Only auto-fill on an exact NAME match; keyword/acronym matches
224
+ // (e.g. "dlsu") require an explicit Enter, blur, or click.
225
+ if (exact &&
226
+ exact.name.trim().toLowerCase() ===
227
+ nextQuery.trim().toLowerCase()) {
228
+ setter([exact.id]);
229
+ setQuery("");
230
+ }
231
+ else {
232
+ setQuery(nextQuery);
233
+ }
234
+ setIsOpen(true);
235
+ }, onFocus: () => { if (!useMobileSheet)
236
+ setIsOpen(true); }, onClick: (e) => {
237
+ setIsOpen(true);
238
+ if (suppressMobileKeyboard) {
239
+ e.currentTarget.blur();
240
+ }
241
+ }, onKeyDown: (e) => {
242
+ if (e.key === "Enter" && resolveQuerySelection(query, true)) {
243
+ setIsOpen(false);
244
+ e.preventDefault();
245
+ }
246
+ }, onBlur: () => {
247
+ if (useMobileSheet)
248
+ return;
249
+ // slight delay to let dropdown option clicks register first
250
+ setTimeout(() => {
251
+ if (Date.now() - lastSelectionRef.current < 250) {
252
+ return;
253
+ }
254
+ if (!resolveQuerySelection(query, false))
255
+ setQuery("");
256
+ }, 150);
257
+ } }))), isOpen && (jsx(Sheet, { open: useMobileSheet && isOpen, onOpenChange: next => { if (!next) {
258
+ setQuery('');
259
+ setIsOpen(false);
260
+ } }, children: jsxs(OptionsSurface, { ...sheetProps, ref: useMobileSheet ? sheetRef : undefined, role: useMobileSheet ? "dialog" : undefined, "aria-modal": useMobileSheet ? true : undefined, "aria-label": useMobileSheet ? (typeof label === "string" ? label : "Choose options") : undefined, className: cn("bg-background text-sm shadow-card border border-border", useMobileSheet
261
+ ? "fixed left-0 right-0 z-[1100] flex flex-col gap-0 overflow-hidden rounded-t-control-lg border-b-0 p-0"
262
+ : "absolute left-0 right-0 z-50 mt-1 max-h-[400px] overflow-y-auto overscroll-contain rounded-control-lg"), style: useMobileSheet
263
+ ? {
264
+ bottom: sheetViewport?.bottom ?? 0,
265
+ maxHeight: sheetViewport ? Math.min(sheetViewport.height, 640) : "80dvh",
266
+ }
267
+ : undefined, children: [useMobileSheet && (jsxs("div", { className: "shrink-0 px-4 pb-3 pt-4", children: [jsxs("div", { className: "mb-3 flex items-center justify-between gap-4", children: [jsx(SheetTitle, { className: "text-base font-semibold text-foreground", children: label || "Choose options" }), jsx("button", { ref: sheetCloseRef, type: "button", "aria-label": "Close options", className: "-mr-3 flex h-11 w-11 shrink-0 items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted", onClick: () => { setQuery(""); setIsOpen(false); }, children: jsx(X, { className: "h-5 w-5", "aria-hidden": "true" }) })] }), jsx(Input, { ref: sheetInputRef, "aria-label": typeof label === "string" ? `Search ${label}` : "Search options", value: query, placeholder: placeholder ?? "Search", className: "h-10 min-h-10 max-h-none text-base", onChange: (e) => {
268
+ setQuery(e.target.value);
269
+ setIsOpen(true);
270
+ if ((value?.length ?? 0) > 0 && !multiple) {
271
+ setter([]);
272
+ }
273
+ }, onKeyDown: (e) => {
274
+ if (multiple) {
275
+ onMultiKeyDown(e);
276
+ return;
277
+ }
278
+ if (e.key === "Enter" && resolveQuerySelection(query)) {
279
+ setIsOpen(false);
280
+ e.preventDefault();
281
+ }
282
+ if (e.key === "Escape") {
283
+ setIsOpen(false);
284
+ }
285
+ } })] })), jsxs("ul", { className: cn(useMobileSheet && "min-h-0 flex-1 overflow-y-auto overscroll-contain"), children: [allowCustomValue && (jsx("li", { className: "w-full text-left px-4 py-2 text-sm text-muted-foreground bg-muted pointer-events-none", children: "Suggestions" })), filtered.length ? (filtered.map((option, index) => {
286
+ const active = selectedSet.has(option.id);
287
+ const group = options.find((item) => item.children?.some((child) => child.id === option.id));
288
+ const firstInGroup = group && !filtered.slice(0, index).some((item) => group.children?.some((child) => child.id === item.id));
289
+ return (jsxs(Fragment, { children: [firstInGroup && group && (jsx("li", { children: multiple ? (jsxs("button", { type: "button", "aria-pressed": group.children.every((child) => selectedSet.has(child.id)), className: "flex min-h-11 w-full items-center gap-2 px-4 py-2 text-left text-sm font-medium text-foreground hover:bg-muted", onClick: () => {
290
+ const ids = group.children.map((child) => child.id);
291
+ const next = new Set(value ?? []);
292
+ const allSelected = ids.every((id) => next.has(id));
293
+ ids.forEach((id) => allSelected ? next.delete(id) : next.add(id));
294
+ setter(Array.from(next));
295
+ }, children: [jsx(CheckboxVisual, { checked: group.children.every((child) => selectedSet.has(child.id)) ? true : group.children.some((child) => selectedSet.has(child.id)) ? 'indeterminate' : false }), group.name] })) : jsx("div", { className: "px-4 py-2 text-sm font-medium text-foreground", children: group.name }) })), jsx("li", { children: jsxs("button", { type: "button", "aria-pressed": multiple ? active : undefined, onClick: () => {
296
+ toggle(option.id);
297
+ if (multiple) {
298
+ // keep open for rapid multi-pick
299
+ setQuery("");
300
+ if (!useMobileSheet) {
301
+ inputRef.current?.focus();
302
+ }
303
+ }
304
+ else {
305
+ setQuery("");
306
+ setIsOpen(false);
307
+ }
308
+ }, className: cn("w-full text-left px-4 py-2 text-sm text-muted-foreground transition-colors flex items-center gap-2 cursor-pointer hover:bg-muted", useMobileSheet && "min-h-12", group && "pl-8", active && "bg-primary-tint"), children: [multiple ? (jsx(CheckboxVisual, { checked: active })) : null, option.name] }) })] }, String(option.id)));
309
+ })) : (!allowCustomValue || !query.trim() ? (jsx("li", { className: "w-full text-left px-4 py-2 text-sm text-muted-foreground", children: emptyText })) : null), allowCustomValue && query.trim() && !findExactOption(query) && (jsx("li", { children: jsxs("button", { type: "button", className: "flex min-h-11 w-full items-center gap-2 px-4 py-2 text-left text-sm text-primary hover:bg-muted focus-visible:outline-2 focus-visible:outline-primary", onMouseDown: (event) => event.preventDefault(), onClick: () => {
310
+ const text = query.trim();
311
+ if (multiple) {
312
+ setter(Array.from(new Set([...(value ?? []), text])));
313
+ setQuery("");
314
+ }
315
+ else {
316
+ resolveQuerySelection(text);
317
+ setIsOpen(false);
318
+ }
319
+ }, children: [jsx(PlusCircleIcon, { className: "h-4 w-4", "aria-hidden": "true" }), "Add \u201C", query.trim(), "\u201D"] }) }))] }), useMobileSheet && multiple && (jsx("div", { className: "shrink-0 border-t border-border bg-background px-4 pt-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]", children: jsx(Button, { type: "button", variant: "outline", className: "min-h-11 w-full", onClick: () => {
320
+ setQuery("");
321
+ setIsOpen(false);
322
+ }, children: "Done" }) }))] }) }))] }));
323
+ }
324
+ const Autocomplete = (config) => {
325
+ const { required, options, placeholder, className, label, props, allowCustomValue = false, preserveOptionOrder = false, emptyText, mobileDropdownMode, inputIcons } = config;
326
+ return (jsx(AutocompleteBase, { required: required, options: options, multiple: config.multiple === true, value: config.multiple === true ? config.value ?? [] : config.value != null ? [config.value] : [], setter: (arr) => {
327
+ if (config.multiple === true)
328
+ config.setter(arr);
329
+ else
330
+ config.setter(arr[0] ?? null);
331
+ }, placeholder: placeholder, className: className, label: label, allowCustomValue: allowCustomValue, preserveOptionOrder: preserveOptionOrder, emptyText: emptyText, mobileDropdownMode: mobileDropdownMode, inputIcons: inputIcons, ...props }));
332
+ };
333
+
334
+ export { Autocomplete };
335
+ //# sourceMappingURL=autocomplete.js.map