@middag-io/react 0.45.0 → 0.45.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/public/schemas/ai-contract-manifest.json +1820 -0
- package/docs/public/schemas/blocks.json +445 -0
- package/docs/public/schemas/components.json +166 -0
- package/docs/public/schemas/connectors.json +97 -0
- package/docs/public/schemas/fragment.json +2329 -0
- package/docs/public/schemas/manifest.json +119 -0
- package/docs/public/schemas/navigation.json +72 -0
- package/docs/public/schemas/page-contract.json +2329 -0
- package/docs/public/schemas/shared-props.json +118 -0
- package/docs/public/schemas/theme-defaults.json +253 -0
- package/docs/public/schemas/theme.json +401 -0
- package/package.json +109 -3
- package/src/assets/lottie/calendar/schedule-1.json +1 -0
- package/src/assets/lottie/calendar/schedule-2.json +1 -0
- package/src/assets/lottie/celebration/confetti-1.json +1 -0
- package/src/assets/lottie/celebration/confetti-2.json +1 -0
- package/src/assets/lottie/celebration/confetti-3.json +1 -0
- package/src/assets/lottie/cloud/cloud-1.json +1 -0
- package/src/assets/lottie/cloud/cloud-2.json +1 -0
- package/src/assets/lottie/connection/network-1.json +1 -0
- package/src/assets/lottie/connection/network-2.json +1 -0
- package/src/assets/lottie/connection/network-3.json +1 -0
- package/src/assets/lottie/dashboard/analytics-1.json +1 -0
- package/src/assets/lottie/dashboard/analytics-2.json +1 -0
- package/src/assets/lottie/dashboard/analytics-3.json +1 -0
- package/src/assets/lottie/email/mail-1.json +1 -0
- package/src/assets/lottie/email/mail-2.json +1 -0
- package/src/assets/lottie/email/mail-3.json +1 -0
- package/src/assets/lottie/empty-state/empty-1.json +1 -0
- package/src/assets/lottie/empty-state/empty-2.json +1 -0
- package/src/assets/lottie/empty-state/empty-3.json +1 -0
- package/src/assets/lottie/error/warning-1.json +1 -0
- package/src/assets/lottie/error/warning-2.json +1 -0
- package/src/assets/lottie/error/warning-3.json +1 -0
- package/src/assets/lottie/index.ts +49 -0
- package/src/assets/lottie/loading/spinner-1.json +1 -0
- package/src/assets/lottie/loading/spinner-2.json +1 -0
- package/src/assets/lottie/loading/spinner-3.json +1 -0
- package/src/assets/lottie/maintenance/construction-1.json +1 -0
- package/src/assets/lottie/maintenance/construction-2.json +1 -0
- package/src/assets/lottie/maintenance/construction-3.json +1 -0
- package/src/assets/lottie/not-found/404-1.json +1 -0
- package/src/assets/lottie/not-found/404-2.json +1 -0
- package/src/assets/lottie/not-found/404-3.json +1 -0
- package/src/assets/lottie/notification/bell-1.json +1 -0
- package/src/assets/lottie/notification/bell-2.json +1 -0
- package/src/assets/lottie/notification/bell-3.json +1 -0
- package/src/assets/lottie/onboarding/welcome-1.json +1 -0
- package/src/assets/lottie/onboarding/welcome-2.json +1 -0
- package/src/assets/lottie/onboarding/welcome-3.json +1 -0
- package/src/assets/lottie/payment/wallet-1.json +1 -0
- package/src/assets/lottie/payment/wallet-2.json +1 -0
- package/src/assets/lottie/payment/wallet-3.json +1 -0
- package/src/assets/lottie/search/search-1.json +1 -0
- package/src/assets/lottie/search/search-2.json +1 -0
- package/src/assets/lottie/search/search-3.json +1 -0
- package/src/assets/lottie/security/lock-1.json +1 -0
- package/src/assets/lottie/security/lock-2.json +1 -0
- package/src/assets/lottie/security/lock-3.json +1 -0
- package/src/assets/lottie/settings/gear-1.json +1 -0
- package/src/assets/lottie/settings/gear-2.json +1 -0
- package/src/assets/lottie/settings/gear-3.json +1 -0
- package/src/assets/lottie/success/check-1.json +1 -0
- package/src/assets/lottie/success/check-2.json +1 -0
- package/src/assets/lottie/success/check-3.json +1 -0
- package/src/assets/lottie/upload/upload-1.json +1 -0
- package/src/assets/lottie/upload/upload-2.json +1 -0
- package/src/assets/lottie/upload/upload-3.json +1 -0
- package/src/assets/lottie/user/profile-1.json +1 -0
- package/src/assets/lottie/user/profile-2.json +1 -0
- package/src/assets/lottie/user/profile-3.json +1 -0
- package/src/base/blocks/ActionGridBlock.tsx +151 -0
- package/src/base/blocks/ActivityTimelineBlock.tsx +180 -0
- package/src/base/blocks/CardGridBlock.tsx +384 -0
- package/src/base/blocks/ChartBlock.tsx +81 -0
- package/src/base/blocks/DenseTableBlock.tsx +403 -0
- package/src/base/blocks/DetailPanelBlock.tsx +189 -0
- package/src/base/blocks/EmptyStateBlock.tsx +46 -0
- package/src/base/blocks/FormPanelBlock.lazy.tsx +38 -0
- package/src/base/blocks/FormPanelBlock.tsx +480 -0
- package/src/base/blocks/LinkListBlock.tsx +94 -0
- package/src/base/blocks/MarkdownPanelBlock.tsx +60 -0
- package/src/base/blocks/MetricCardBlock.tsx +128 -0
- package/src/base/blocks/StatusStripBlock.tsx +43 -0
- package/src/base/blocks/TabsBlock.tsx +94 -0
- package/src/base/form/FormField.tsx +607 -0
- package/src/base/form/fields/CheckboxField.tsx +56 -0
- package/src/base/form/fields/ColorField.tsx +76 -0
- package/src/base/form/fields/CurrencyField.tsx +126 -0
- package/src/base/form/fields/DateField.tsx +168 -0
- package/src/base/form/fields/DateRangeField.tsx +66 -0
- package/src/base/form/fields/DocumentField.tsx +222 -0
- package/src/base/form/fields/EntityPickerField.tsx +244 -0
- package/src/base/form/fields/FileUploadField.tsx +253 -0
- package/src/base/form/fields/MultiSelectField.tsx +286 -0
- package/src/base/form/fields/NativeSelectField.tsx +67 -0
- package/src/base/form/fields/NumberField.tsx +67 -0
- package/src/base/form/fields/OtpField.tsx +88 -0
- package/src/base/form/fields/PasswordField.tsx +69 -0
- package/src/base/form/fields/PhoneField.tsx +64 -0
- package/src/base/form/fields/RadioField.tsx +66 -0
- package/src/base/form/fields/RatingField.tsx +52 -0
- package/src/base/form/fields/SelectField.tsx +76 -0
- package/src/base/form/fields/SliderField.tsx +77 -0
- package/src/base/form/fields/SlugField.tsx +114 -0
- package/src/base/form/fields/StaticField.tsx +25 -0
- package/src/base/form/fields/SwitchField.tsx +56 -0
- package/src/base/form/fields/TagsField.tsx +128 -0
- package/src/base/form/fields/TextField.tsx +55 -0
- package/src/base/form/fields/TextareaField.tsx +55 -0
- package/src/base/form/fields/document-validation.ts +126 -0
- package/src/base/form/fields/field-registry.ts +53 -0
- package/src/base/form/fields/register-default-fields.ts +86 -0
- package/src/base/form/form-schema-builder.ts +192 -0
- package/src/base/form/form-utils.ts +71 -0
- package/src/base/hooks/useIsDark.ts +50 -0
- package/src/base/hooks/useLazyTabs.ts +98 -0
- package/src/base/hooks/usePolling.ts +43 -0
- package/src/base/hooks/useRemember.ts +58 -0
- package/src/base/hooks/useToast.ts +27 -0
- package/src/base/layout/BlockRegion.tsx +39 -0
- package/src/base/layout/DashboardLayout.tsx +110 -0
- package/src/base/layout/SidebarLayout.tsx +38 -0
- package/src/base/layout/StackLayout.tsx +32 -0
- package/src/base/layout/WizardLayout.tsx +49 -0
- package/src/base/partials/ActionBar/index.tsx +115 -0
- package/src/base/partials/ConfirmationDialog/index.tsx +128 -0
- package/src/base/partials/DataTable/cell-registry.ts +50 -0
- package/src/base/partials/DataTable/cell-renderers.tsx +372 -0
- package/src/base/partials/DataTable/index.tsx +1282 -0
- package/src/base/partials/DataTable/register-default-cells.ts +37 -0
- package/src/base/partials/DataTable/sanitize-html.ts +45 -0
- package/src/base/partials/DataTable/types.ts +229 -0
- package/src/base/partials/DetailSection/index.tsx +316 -0
- package/src/base/partials/EmptyPlaceholder/index.tsx +162 -0
- package/src/base/partials/EntityItem/index.tsx +154 -0
- package/src/base/partials/FilterBar/index.tsx +256 -0
- package/src/base/partials/FormSection/index.tsx +87 -0
- package/src/base/partials/LogViewer/JsonBlock.tsx +39 -0
- package/src/base/partials/LogViewer/LogEntry.tsx +68 -0
- package/src/base/partials/LogViewer/LogViewerToolbar.tsx +71 -0
- package/src/base/partials/LogViewer/index.tsx +110 -0
- package/src/base/partials/LogViewer/types.ts +28 -0
- package/src/base/partials/MarkdownContent/index.tsx +307 -0
- package/src/base/partials/MenuBar/index.tsx +80 -0
- package/src/base/partials/QuickRecordSheet/index.tsx +59 -0
- package/src/base/partials/ResizableSidebar/index.tsx +70 -0
- package/src/base/partials/StatRow/index.tsx +28 -0
- package/src/base/partials/StatusBar/index.tsx +126 -0
- package/src/base/partials/StatusIndicator/index.tsx +61 -0
- package/src/base/partials/StepIndicator/index.tsx +63 -0
- package/src/base/partials/TableOfContents/index.tsx +78 -0
- package/src/base/partials/TimelineList/index.tsx +273 -0
- package/src/base/partials/ToggleGroupControl/index.tsx +100 -0
- package/src/base/partials/TreeView/index.tsx +75 -0
- package/src/base/partials/index.ts +23 -0
- package/src/base/shell/AuthShell.tsx +54 -0
- package/src/base/shell/BasicShell.tsx +286 -0
- package/src/base/shell/ImmersiveShell.tsx +85 -0
- package/src/base/shell/partials/EditablePanelContext.tsx +82 -0
- package/src/base/shell/partials/EditablePanelProvider.tsx +122 -0
- package/src/base/shell/partials/InlineEditablePanel.tsx +239 -0
- package/src/base/shell/partials/InspectorContext.tsx +173 -0
- package/src/base/shell/partials/InspectorPanel.tsx +65 -0
- package/src/base/shell/partials/NavErrorBoundary.tsx +82 -0
- package/src/base/shell/partials/OverlayScreen.tsx +67 -0
- package/src/base/shell/partials/PageActionButton.tsx +203 -0
- package/src/base/theme/appearance.ts +133 -0
- package/src/base/theme/host-layout-detector.ts +119 -0
- package/src/base/theme/host-theme-detector.ts +146 -0
- package/src/base/theme/sidebar-safelist.txt +20 -0
- package/src/base/theme/tailwind-theme.css +136 -0
- package/src/base/theme/theme-bridge.css +164 -0
- package/src/base/theme/theme-context.tsx +142 -0
- package/src/base/theme/themes/classic.css +174 -0
- package/src/base/theme/tokens.css +290 -0
- package/src/base/theme/useHostTheme.ts +95 -0
- package/src/base/utils/clipboard.ts +39 -0
- package/src/base/utils/conditions.ts +27 -0
- package/src/base/utils/icon-registry.ts +78 -0
- package/src/base/utils/icons.ts +31 -0
- package/src/base/utils/interpolate.ts +9 -0
- package/src/base/utils/register-default-icons.ts +163 -0
- package/src/base/utils/storage.ts +65 -0
- package/src/base/utils/time.ts +139 -0
- package/src/contracts/block-data/actions.ts +73 -0
- package/src/contracts/block-data/data-display.ts +343 -0
- package/src/contracts/block-data/form.ts +164 -0
- package/src/contracts/block-data/index.ts +15 -0
- package/src/contracts/block-data/interactive.ts +34 -0
- package/src/contracts/block-data/shared.ts +44 -0
- package/src/contracts/connectors.ts +60 -0
- package/src/contracts/generated/contract-schema.ts +1237 -0
- package/src/contracts/generated/contract-types.ts +675 -0
- package/src/contracts/generated/index.ts +15 -0
- package/src/contracts/navigation.ts +59 -0
- package/src/contracts/page-contract-schema.ts +40 -0
- package/src/contracts/page-contract.ts +79 -0
- package/src/contracts/shared-props.ts +92 -0
- package/src/engine/ContractPage.tsx +178 -0
- package/src/engine/EntityRoutes.tsx +72 -0
- package/src/engine/HostSlot.tsx +126 -0
- package/src/engine/LazyBlock.tsx +92 -0
- package/src/engine/bootstrap.tsx +20 -0
- package/src/engine/providers/auth.tsx +87 -0
- package/src/engine/providers/error-reporter.tsx +89 -0
- package/src/engine/providers/flash.tsx +44 -0
- package/src/engine/providers/index.ts +18 -0
- package/src/engine/providers/inertia-error-reporter.tsx +61 -0
- package/src/engine/providers/progress.tsx +56 -0
- package/src/engine/providers/scope.tsx +51 -0
- package/src/engine/register-defaults.ts +88 -0
- package/src/engine/registries.ts +96 -0
- package/src/i18n/I18nProvider.tsx +53 -0
- package/src/i18n/MANIFEST.md +101 -0
- package/src/i18n/host-resolver.ts +18 -0
- package/src/i18n/instance.ts +69 -0
- package/src/i18n/locales/en/ui.json +277 -0
- package/src/i18n/locales/en/validators.json +13 -0
- package/src/i18n/locales/pt-BR/ui.json +277 -0
- package/src/i18n/locales/pt-BR/validators.json +13 -0
- package/src/i18n/register-strings.ts +10 -0
- package/src/i18n/render-label.ts +33 -0
- package/src/i18n/resolve-field-error.ts +29 -0
- package/src/i18n/useHostString.ts +50 -0
- package/src/i18n/useTranslation.ts +83 -0
- package/src/lib/actions/resolve-action-target.ts +151 -0
- package/src/lib/hooks/use-copy-to-clipboard.ts +37 -0
- package/src/lib/hooks/use-file-upload.ts +406 -0
- package/src/lib/hooks/use-mobile.ts +21 -0
- package/src/lib/host-pending.ts +76 -0
- package/src/lib/portal-container.ts +16 -0
- package/src/lib/test-ids.ts +40 -0
- package/src/lib/utils.ts +6 -0
- package/src/primitives/reui/MANIFEST.md +97 -0
- package/src/primitives/reui/accordion.tsx +64 -0
- package/src/primitives/reui/alert-dialog.tsx +196 -0
- package/src/primitives/reui/alert.tsx +92 -0
- package/src/primitives/reui/aspect-ratio.tsx +9 -0
- package/src/primitives/reui/autocomplete.tsx +343 -0
- package/src/primitives/reui/avatar.tsx +109 -0
- package/src/primitives/reui/badge.tsx +94 -0
- package/src/primitives/reui/breadcrumb.tsx +109 -0
- package/src/primitives/reui/button-group.tsx +83 -0
- package/src/primitives/reui/button.tsx +64 -0
- package/src/primitives/reui/calendar.tsx +220 -0
- package/src/primitives/reui/card.tsx +92 -0
- package/src/primitives/reui/carousel.tsx +239 -0
- package/src/primitives/reui/chart.tsx +388 -0
- package/src/primitives/reui/checkbox.tsx +30 -0
- package/src/primitives/reui/collapsible.tsx +31 -0
- package/src/primitives/reui/combobox.tsx +308 -0
- package/src/primitives/reui/command.tsx +182 -0
- package/src/primitives/reui/context-menu.tsx +250 -0
- package/src/primitives/reui/data-grid/data-grid-column-filter.tsx +172 -0
- package/src/primitives/reui/data-grid/data-grid-column-header.tsx +420 -0
- package/src/primitives/reui/data-grid/data-grid-column-visibility.tsx +51 -0
- package/src/primitives/reui/data-grid/data-grid-pagination.tsx +235 -0
- package/src/primitives/reui/data-grid/data-grid-scroll-area.tsx +427 -0
- package/src/primitives/reui/data-grid/data-grid-table-dnd-rows.tsx +308 -0
- package/src/primitives/reui/data-grid/data-grid-table-dnd.tsx +318 -0
- package/src/primitives/reui/data-grid/data-grid-table-virtual.tsx +491 -0
- package/src/primitives/reui/data-grid/data-grid-table.tsx +1430 -0
- package/src/primitives/reui/data-grid/data-grid.tsx +269 -0
- package/src/primitives/reui/data-grid-pagination.tsx +235 -0
- package/src/primitives/reui/date-selector.tsx +1353 -0
- package/src/primitives/reui/dialog.tsx +158 -0
- package/src/primitives/reui/drawer.tsx +133 -0
- package/src/primitives/reui/dropdown-menu.tsx +257 -0
- package/src/primitives/reui/empty.tsx +104 -0
- package/src/primitives/reui/field.tsx +246 -0
- package/src/primitives/reui/filters.tsx +1891 -0
- package/src/primitives/reui/frame.tsx +170 -0
- package/src/primitives/reui/hover-card.tsx +42 -0
- package/src/primitives/reui/icon-placeholder.tsx +39 -0
- package/src/primitives/reui/index.ts +98 -0
- package/src/primitives/reui/input-group.tsx +170 -0
- package/src/primitives/reui/input-otp.tsx +75 -0
- package/src/primitives/reui/input.tsx +21 -0
- package/src/primitives/reui/item.tsx +193 -0
- package/src/primitives/reui/kanban.tsx +743 -0
- package/src/primitives/reui/kbd.tsx +28 -0
- package/src/primitives/reui/label.tsx +22 -0
- package/src/primitives/reui/menubar.tsx +274 -0
- package/src/primitives/reui/native-select.tsx +62 -0
- package/src/primitives/reui/navigation-menu.tsx +168 -0
- package/src/primitives/reui/number-field.tsx +250 -0
- package/src/primitives/reui/pagination.tsx +127 -0
- package/src/primitives/reui/phone-input.tsx +231 -0
- package/src/primitives/reui/popover.tsx +87 -0
- package/src/primitives/reui/progress.tsx +31 -0
- package/src/primitives/reui/radio-group.tsx +43 -0
- package/src/primitives/reui/rating.tsx +177 -0
- package/src/primitives/reui/resizable.tsx +51 -0
- package/src/primitives/reui/scroll-area.tsx +58 -0
- package/src/primitives/reui/scrollspy.tsx +240 -0
- package/src/primitives/reui/select.tsx +188 -0
- package/src/primitives/reui/separator.tsx +28 -0
- package/src/primitives/reui/sheet.tsx +141 -0
- package/src/primitives/reui/sidebar.tsx +732 -0
- package/src/primitives/reui/skeleton.tsx +13 -0
- package/src/primitives/reui/slider.tsx +61 -0
- package/src/primitives/reui/sonner.tsx +47 -0
- package/src/primitives/reui/sortable.tsx +414 -0
- package/src/primitives/reui/spinner.tsx +16 -0
- package/src/primitives/reui/stepper.tsx +484 -0
- package/src/primitives/reui/svgs/claudeAiIcon.tsx +12 -0
- package/src/primitives/reui/svgs/gemini.tsx +171 -0
- package/src/primitives/reui/svgs/openai.tsx +9 -0
- package/src/primitives/reui/svgs/openaiDark.tsx +12 -0
- package/src/primitives/reui/switch.tsx +33 -0
- package/src/primitives/reui/table.tsx +114 -0
- package/src/primitives/reui/tabs.tsx +91 -0
- package/src/primitives/reui/textarea.tsx +18 -0
- package/src/primitives/reui/timeline.tsx +219 -0
- package/src/primitives/reui/toggle-group.tsx +83 -0
- package/src/primitives/reui/toggle.tsx +45 -0
- package/src/primitives/reui/tooltip.tsx +55 -0
- package/src/primitives/reui/tree.tsx +247 -0
- package/src/theme.css +71 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { createContext, ReactNode, useContext, useId } from "react";
|
|
2
|
+
import { NumberField as NumberFieldPrimitive } from "@base-ui/react/number-field";
|
|
3
|
+
import { cva, VariantProps } from "class-variance-authority";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
import { Label } from "@/primitives/reui/label";
|
|
7
|
+
import { HugeiconsIcon } from "@hugeicons/react";
|
|
8
|
+
import { MinusSignIcon, PlusSignIcon } from "@hugeicons/core-free-icons";
|
|
9
|
+
|
|
10
|
+
const NumberFieldContext = createContext<{
|
|
11
|
+
fieldId: string;
|
|
12
|
+
size: "sm" | "default" | "lg";
|
|
13
|
+
} | null>(null);
|
|
14
|
+
|
|
15
|
+
const numberFieldGroupVariants = cva(
|
|
16
|
+
"relative flex w-full justify-between border border-input data-disabled:pointer-events-none data-disabled:opacity-50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive focus-within:has-aria-invalid:border-destructive focus-within:has-aria-invalid:ring-destructive/20 dark:focus-within:has-aria-invalid:ring-destructive/40 rounded-4xl bg-input/30 transition-colors focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]",
|
|
17
|
+
{
|
|
18
|
+
variants: {
|
|
19
|
+
size: {
|
|
20
|
+
sm: "h-8 text-sm",
|
|
21
|
+
default: "h-9 text-sm",
|
|
22
|
+
lg: "h-10 text-sm",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: {
|
|
26
|
+
size: "default",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const numberFieldButtonVariants = cva(
|
|
32
|
+
"relative flex shrink-0 cursor-pointer items-center justify-center transition-colors pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:bg-accent",
|
|
33
|
+
{
|
|
34
|
+
variants: {
|
|
35
|
+
size: {
|
|
36
|
+
sm: "px-2 [&_svg:not([class*='size-'])]:size-3.5",
|
|
37
|
+
default: "px-2.5 [&_svg:not([class*='size-'])]:size-4",
|
|
38
|
+
lg: "px-3 [&_svg:not([class*='size-'])]:size-4",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
defaultVariants: {
|
|
42
|
+
size: "default",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const numberFieldInputVariants = cva(
|
|
48
|
+
"w-full min-w-0 flex-1 bg-transparent text-center tabular-nums outline-none",
|
|
49
|
+
{
|
|
50
|
+
variants: {
|
|
51
|
+
size: {
|
|
52
|
+
sm: "px-2.5 py-1",
|
|
53
|
+
default: "px-3 py-1.5",
|
|
54
|
+
lg: "px-3.5 py-2",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
defaultVariants: {
|
|
58
|
+
size: "default",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
function NumberField({
|
|
64
|
+
id,
|
|
65
|
+
className,
|
|
66
|
+
size = "default",
|
|
67
|
+
...props
|
|
68
|
+
}: NumberFieldPrimitive.Root.Props &
|
|
69
|
+
VariantProps<typeof numberFieldGroupVariants>) {
|
|
70
|
+
const generatedId = useId();
|
|
71
|
+
const fieldId = id ?? generatedId;
|
|
72
|
+
const sizeValue = size ?? "default";
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<NumberFieldContext.Provider value={{ fieldId, size: sizeValue }}>
|
|
76
|
+
<NumberFieldPrimitive.Root
|
|
77
|
+
className={cn("flex w-full flex-col items-start gap-2", className)}
|
|
78
|
+
data-size={sizeValue}
|
|
79
|
+
data-slot="number-field"
|
|
80
|
+
id={fieldId}
|
|
81
|
+
{...props}
|
|
82
|
+
/>
|
|
83
|
+
</NumberFieldContext.Provider>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function NumberFieldGroup({
|
|
88
|
+
className,
|
|
89
|
+
size: sizeProp,
|
|
90
|
+
...props
|
|
91
|
+
}: NumberFieldPrimitive.Group.Props &
|
|
92
|
+
Partial<VariantProps<typeof numberFieldGroupVariants>>) {
|
|
93
|
+
const context = useContext(NumberFieldContext);
|
|
94
|
+
if (!context) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
"NumberFieldGroup must be used within a NumberField component.",
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
const size = sizeProp ?? context.size;
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<NumberFieldPrimitive.Group
|
|
103
|
+
className={cn(numberFieldGroupVariants({ size }), className)}
|
|
104
|
+
data-slot="number-field-group"
|
|
105
|
+
{...props}
|
|
106
|
+
/>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function NumberFieldDecrement({
|
|
111
|
+
className,
|
|
112
|
+
size: sizeProp,
|
|
113
|
+
children,
|
|
114
|
+
...props
|
|
115
|
+
}: NumberFieldPrimitive.Decrement.Props &
|
|
116
|
+
Partial<VariantProps<typeof numberFieldButtonVariants>> & {
|
|
117
|
+
children?: React.ReactNode;
|
|
118
|
+
}) {
|
|
119
|
+
const context = useContext(NumberFieldContext);
|
|
120
|
+
if (!context) {
|
|
121
|
+
throw new Error(
|
|
122
|
+
"NumberFieldDecrement must be used within a NumberField component.",
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
const size = sizeProp ?? context.size;
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<NumberFieldPrimitive.Decrement
|
|
129
|
+
className={cn(
|
|
130
|
+
numberFieldButtonVariants({ size }),
|
|
131
|
+
"rounded-s-4xl border-e-0",
|
|
132
|
+
className,
|
|
133
|
+
)}
|
|
134
|
+
data-slot="number-field-decrement"
|
|
135
|
+
{...props}
|
|
136
|
+
>
|
|
137
|
+
{children ?? <HugeiconsIcon icon={MinusSignIcon} strokeWidth={2} />}
|
|
138
|
+
</NumberFieldPrimitive.Decrement>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function NumberFieldIncrement({
|
|
143
|
+
className,
|
|
144
|
+
size: sizeProp,
|
|
145
|
+
children,
|
|
146
|
+
...props
|
|
147
|
+
}: NumberFieldPrimitive.Increment.Props &
|
|
148
|
+
Partial<VariantProps<typeof numberFieldButtonVariants>> & {
|
|
149
|
+
children?: ReactNode;
|
|
150
|
+
}) {
|
|
151
|
+
const context = useContext(NumberFieldContext);
|
|
152
|
+
if (!context) {
|
|
153
|
+
throw new Error(
|
|
154
|
+
"NumberFieldIncrement must be used within a NumberField component.",
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
const size = sizeProp ?? context.size;
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<NumberFieldPrimitive.Increment
|
|
161
|
+
className={cn(
|
|
162
|
+
numberFieldButtonVariants({ size }),
|
|
163
|
+
"rounded-e-4xl border-s-0",
|
|
164
|
+
className,
|
|
165
|
+
)}
|
|
166
|
+
data-slot="number-field-increment"
|
|
167
|
+
{...props}
|
|
168
|
+
>
|
|
169
|
+
{children ?? <HugeiconsIcon icon={PlusSignIcon} strokeWidth={2} />}
|
|
170
|
+
</NumberFieldPrimitive.Increment>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function NumberFieldInput({
|
|
175
|
+
className,
|
|
176
|
+
size: sizeProp,
|
|
177
|
+
...props
|
|
178
|
+
}: NumberFieldPrimitive.Input.Props &
|
|
179
|
+
Partial<VariantProps<typeof numberFieldInputVariants>>) {
|
|
180
|
+
const context = useContext(NumberFieldContext);
|
|
181
|
+
if (!context) {
|
|
182
|
+
throw new Error(
|
|
183
|
+
"NumberFieldInput must be used within a NumberField component.",
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
const size = sizeProp ?? context.size;
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<NumberFieldPrimitive.Input
|
|
190
|
+
className={cn(numberFieldInputVariants({ size }), className)}
|
|
191
|
+
data-slot="number-field-input"
|
|
192
|
+
{...props}
|
|
193
|
+
/>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function NumberFieldScrubArea({
|
|
198
|
+
className,
|
|
199
|
+
label,
|
|
200
|
+
...props
|
|
201
|
+
}: NumberFieldPrimitive.ScrubArea.Props & {
|
|
202
|
+
label: string;
|
|
203
|
+
}) {
|
|
204
|
+
const context = useContext(NumberFieldContext);
|
|
205
|
+
if (!context) {
|
|
206
|
+
throw new Error(
|
|
207
|
+
"NumberFieldScrubArea must be used within a NumberField component for accessibility.",
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<NumberFieldPrimitive.ScrubArea
|
|
213
|
+
className={cn("flex cursor-ew-resize", className)}
|
|
214
|
+
data-slot="number-field-scrub-area"
|
|
215
|
+
{...props}
|
|
216
|
+
>
|
|
217
|
+
<Label className="cursor-ew-resize" htmlFor={context.fieldId}>
|
|
218
|
+
{label}
|
|
219
|
+
</Label>
|
|
220
|
+
<NumberFieldPrimitive.ScrubAreaCursor className="drop-shadow-[0_1px_1px_#0008] filter">
|
|
221
|
+
<CursorGrowIcon />
|
|
222
|
+
</NumberFieldPrimitive.ScrubAreaCursor>
|
|
223
|
+
</NumberFieldPrimitive.ScrubArea>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function CursorGrowIcon(props: React.ComponentProps<"svg">) {
|
|
228
|
+
return (
|
|
229
|
+
<svg
|
|
230
|
+
fill="black"
|
|
231
|
+
height="14"
|
|
232
|
+
stroke="white"
|
|
233
|
+
viewBox="0 0 24 14"
|
|
234
|
+
width="26"
|
|
235
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
236
|
+
{...props}
|
|
237
|
+
>
|
|
238
|
+
<path d="M19.5 5.5L6.49737 5.51844V2L1 6.9999L6.5 12L6.49737 8.5L19.5 8.5V12L25 6.9999L19.5 2V5.5Z" />
|
|
239
|
+
</svg>
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export {
|
|
244
|
+
NumberField,
|
|
245
|
+
NumberFieldScrubArea,
|
|
246
|
+
NumberFieldDecrement,
|
|
247
|
+
NumberFieldIncrement,
|
|
248
|
+
NumberFieldGroup,
|
|
249
|
+
NumberFieldInput,
|
|
250
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
ChevronLeftIcon,
|
|
4
|
+
ChevronRightIcon,
|
|
5
|
+
MoreHorizontalIcon,
|
|
6
|
+
} from "lucide-react";
|
|
7
|
+
|
|
8
|
+
import { cn } from "@/lib/utils";
|
|
9
|
+
import { buttonVariants, type Button } from "@/primitives/reui/button";
|
|
10
|
+
|
|
11
|
+
function Pagination({ className, ...props }: React.ComponentProps<"nav">) {
|
|
12
|
+
return (
|
|
13
|
+
<nav
|
|
14
|
+
role="navigation"
|
|
15
|
+
aria-label="pagination"
|
|
16
|
+
data-slot="pagination"
|
|
17
|
+
className={cn("mx-auto flex w-full justify-center", className)}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function PaginationContent({
|
|
24
|
+
className,
|
|
25
|
+
...props
|
|
26
|
+
}: React.ComponentProps<"ul">) {
|
|
27
|
+
return (
|
|
28
|
+
<ul
|
|
29
|
+
data-slot="pagination-content"
|
|
30
|
+
className={cn("flex flex-row items-center gap-1", className)}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function PaginationItem({ ...props }: React.ComponentProps<"li">) {
|
|
37
|
+
return <li data-slot="pagination-item" {...props} />;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type PaginationLinkProps = {
|
|
41
|
+
isActive?: boolean;
|
|
42
|
+
} & Pick<React.ComponentProps<typeof Button>, "size"> &
|
|
43
|
+
React.ComponentProps<"a">;
|
|
44
|
+
|
|
45
|
+
function PaginationLink({
|
|
46
|
+
className,
|
|
47
|
+
isActive,
|
|
48
|
+
size = "icon",
|
|
49
|
+
...props
|
|
50
|
+
}: PaginationLinkProps) {
|
|
51
|
+
return (
|
|
52
|
+
<a
|
|
53
|
+
aria-current={isActive ? "page" : undefined}
|
|
54
|
+
data-slot="pagination-link"
|
|
55
|
+
data-active={isActive}
|
|
56
|
+
className={cn(
|
|
57
|
+
buttonVariants({
|
|
58
|
+
variant: isActive ? "outline" : "ghost",
|
|
59
|
+
size,
|
|
60
|
+
}),
|
|
61
|
+
className,
|
|
62
|
+
)}
|
|
63
|
+
{...props}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function PaginationPrevious({
|
|
69
|
+
className,
|
|
70
|
+
...props
|
|
71
|
+
}: React.ComponentProps<typeof PaginationLink>) {
|
|
72
|
+
return (
|
|
73
|
+
<PaginationLink
|
|
74
|
+
aria-label="Go to previous page"
|
|
75
|
+
size="default"
|
|
76
|
+
className={cn("gap-1 px-2.5 sm:pl-2.5", className)}
|
|
77
|
+
{...props}
|
|
78
|
+
>
|
|
79
|
+
<ChevronLeftIcon />
|
|
80
|
+
<span className="hidden sm:block">Previous</span>
|
|
81
|
+
</PaginationLink>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function PaginationNext({
|
|
86
|
+
className,
|
|
87
|
+
...props
|
|
88
|
+
}: React.ComponentProps<typeof PaginationLink>) {
|
|
89
|
+
return (
|
|
90
|
+
<PaginationLink
|
|
91
|
+
aria-label="Go to next page"
|
|
92
|
+
size="default"
|
|
93
|
+
className={cn("gap-1 px-2.5 sm:pr-2.5", className)}
|
|
94
|
+
{...props}
|
|
95
|
+
>
|
|
96
|
+
<span className="hidden sm:block">Next</span>
|
|
97
|
+
<ChevronRightIcon />
|
|
98
|
+
</PaginationLink>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function PaginationEllipsis({
|
|
103
|
+
className,
|
|
104
|
+
...props
|
|
105
|
+
}: React.ComponentProps<"span">) {
|
|
106
|
+
return (
|
|
107
|
+
<span
|
|
108
|
+
aria-hidden
|
|
109
|
+
data-slot="pagination-ellipsis"
|
|
110
|
+
className={cn("flex size-9 items-center justify-center", className)}
|
|
111
|
+
{...props}
|
|
112
|
+
>
|
|
113
|
+
<MoreHorizontalIcon className="size-4" />
|
|
114
|
+
<span className="sr-only">More pages</span>
|
|
115
|
+
</span>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
Pagination,
|
|
121
|
+
PaginationContent,
|
|
122
|
+
PaginationLink,
|
|
123
|
+
PaginationItem,
|
|
124
|
+
PaginationPrevious,
|
|
125
|
+
PaginationNext,
|
|
126
|
+
PaginationEllipsis,
|
|
127
|
+
};
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ComponentProps,
|
|
5
|
+
createContext,
|
|
6
|
+
useContext,
|
|
7
|
+
useMemo,
|
|
8
|
+
useState,
|
|
9
|
+
} from "react";
|
|
10
|
+
import * as BasePhoneInput from "react-phone-number-input";
|
|
11
|
+
import flags from "react-phone-number-input/flags";
|
|
12
|
+
|
|
13
|
+
import { cn } from "@/lib/utils";
|
|
14
|
+
import { Button } from "@/primitives/reui/button";
|
|
15
|
+
import {
|
|
16
|
+
Combobox,
|
|
17
|
+
ComboboxContent,
|
|
18
|
+
ComboboxEmpty,
|
|
19
|
+
ComboboxInput,
|
|
20
|
+
ComboboxItem,
|
|
21
|
+
ComboboxList,
|
|
22
|
+
ComboboxSeparator,
|
|
23
|
+
ComboboxTrigger,
|
|
24
|
+
ComboboxValue,
|
|
25
|
+
} from "@/primitives/reui/combobox";
|
|
26
|
+
import { Input } from "@/primitives/reui/input";
|
|
27
|
+
import { ScrollArea } from "@/primitives/reui/scroll-area";
|
|
28
|
+
import { HugeiconsIcon } from "@hugeicons/react";
|
|
29
|
+
import { Globe02Icon } from "@hugeicons/core-free-icons";
|
|
30
|
+
|
|
31
|
+
type PhoneInputSize = "sm" | "default" | "lg";
|
|
32
|
+
|
|
33
|
+
const PhoneInputContext = createContext<{
|
|
34
|
+
variant: PhoneInputSize;
|
|
35
|
+
popupClassName?: string;
|
|
36
|
+
scrollAreaClassName?: string;
|
|
37
|
+
}>({
|
|
38
|
+
variant: "default",
|
|
39
|
+
popupClassName: undefined,
|
|
40
|
+
scrollAreaClassName: undefined,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
type PhoneInputProps = Omit<
|
|
44
|
+
ComponentProps<"input">,
|
|
45
|
+
"onChange" | "value" | "ref"
|
|
46
|
+
> &
|
|
47
|
+
Omit<
|
|
48
|
+
BasePhoneInput.Props<typeof BasePhoneInput.default>,
|
|
49
|
+
"onChange" | "variant" | "popupClassName" | "scrollAreaClassName"
|
|
50
|
+
> & {
|
|
51
|
+
onChange?: (value: BasePhoneInput.Value) => void;
|
|
52
|
+
variant?: PhoneInputSize;
|
|
53
|
+
popupClassName?: string;
|
|
54
|
+
scrollAreaClassName?: string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
function PhoneInput({
|
|
58
|
+
className,
|
|
59
|
+
variant,
|
|
60
|
+
popupClassName,
|
|
61
|
+
scrollAreaClassName,
|
|
62
|
+
onChange,
|
|
63
|
+
value,
|
|
64
|
+
...props
|
|
65
|
+
}: PhoneInputProps) {
|
|
66
|
+
const phoneInputSize = variant || "default";
|
|
67
|
+
return (
|
|
68
|
+
<PhoneInputContext.Provider
|
|
69
|
+
value={{ variant: phoneInputSize, popupClassName, scrollAreaClassName }}
|
|
70
|
+
>
|
|
71
|
+
<BasePhoneInput.default
|
|
72
|
+
className={cn(
|
|
73
|
+
"flex",
|
|
74
|
+
props["aria-invalid"] &&
|
|
75
|
+
"[&_*[data-slot=combobox-trigger]]:border-destructive [&_*[data-slot=combobox-trigger]]:ring-destructive/50",
|
|
76
|
+
className,
|
|
77
|
+
)}
|
|
78
|
+
flagComponent={FlagComponent}
|
|
79
|
+
countrySelectComponent={CountrySelect}
|
|
80
|
+
inputComponent={InputComponent}
|
|
81
|
+
smartCaret={false}
|
|
82
|
+
value={value || undefined}
|
|
83
|
+
onChange={(value) => onChange?.(value || ("" as BasePhoneInput.Value))}
|
|
84
|
+
{...props}
|
|
85
|
+
/>
|
|
86
|
+
</PhoneInputContext.Provider>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function InputComponent({ className, ...props }: ComponentProps<typeof Input>) {
|
|
91
|
+
const { variant } = useContext(PhoneInputContext);
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<Input
|
|
95
|
+
className={cn(
|
|
96
|
+
"rounded-s-none focus:z-1",
|
|
97
|
+
variant === "sm" && "h-8",
|
|
98
|
+
variant === "lg" && "h-10",
|
|
99
|
+
className,
|
|
100
|
+
)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
type CountryEntry = {
|
|
107
|
+
label: string;
|
|
108
|
+
value: BasePhoneInput.Country | undefined;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
type CountrySelectProps = {
|
|
112
|
+
disabled?: boolean;
|
|
113
|
+
value: BasePhoneInput.Country;
|
|
114
|
+
options: CountryEntry[];
|
|
115
|
+
onChange: (country: BasePhoneInput.Country) => void;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
function CountrySelect({
|
|
119
|
+
disabled,
|
|
120
|
+
value: selectedCountry,
|
|
121
|
+
options: countryList,
|
|
122
|
+
onChange,
|
|
123
|
+
}: CountrySelectProps) {
|
|
124
|
+
const { variant, popupClassName } = useContext(PhoneInputContext);
|
|
125
|
+
const [searchValue, setSearchValue] = useState("");
|
|
126
|
+
|
|
127
|
+
const filteredCountries = useMemo(() => {
|
|
128
|
+
if (!searchValue) return countryList;
|
|
129
|
+
return countryList.filter(({ label }) =>
|
|
130
|
+
label.toLowerCase().includes(searchValue.toLowerCase()),
|
|
131
|
+
);
|
|
132
|
+
}, [countryList, searchValue]);
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<Combobox
|
|
136
|
+
items={filteredCountries}
|
|
137
|
+
value={selectedCountry || ""}
|
|
138
|
+
onValueChange={(country: BasePhoneInput.Country | null) => {
|
|
139
|
+
if (country) {
|
|
140
|
+
onChange(country);
|
|
141
|
+
}
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
144
|
+
<ComboboxTrigger
|
|
145
|
+
render={
|
|
146
|
+
<Button
|
|
147
|
+
variant="outline"
|
|
148
|
+
size={variant}
|
|
149
|
+
className={cn(
|
|
150
|
+
"rounded-s-4xl rounded-e-none flex gap-1 border-e-0 px-2.5 py-0 leading-none hover:bg-transparent focus:z-10 data-pressed:bg-transparent",
|
|
151
|
+
disabled && "opacity-50",
|
|
152
|
+
)}
|
|
153
|
+
disabled={disabled}
|
|
154
|
+
>
|
|
155
|
+
<span className="sr-only">
|
|
156
|
+
<ComboboxValue />
|
|
157
|
+
</span>
|
|
158
|
+
<FlagComponent
|
|
159
|
+
country={selectedCountry}
|
|
160
|
+
countryName={selectedCountry}
|
|
161
|
+
/>
|
|
162
|
+
</Button>
|
|
163
|
+
}
|
|
164
|
+
/>
|
|
165
|
+
<ComboboxContent
|
|
166
|
+
className={cn(
|
|
167
|
+
"w-xs *:data-[slot=input-group]:bg-transparent",
|
|
168
|
+
popupClassName,
|
|
169
|
+
)}
|
|
170
|
+
>
|
|
171
|
+
<ComboboxInput
|
|
172
|
+
placeholder="e.g. United States"
|
|
173
|
+
value={searchValue}
|
|
174
|
+
onChange={(e) => setSearchValue(e.target.value)}
|
|
175
|
+
showTrigger={false}
|
|
176
|
+
className="border-input focus-visible:border-border rounded-none border-0 px-0 py-2.5 shadow-none ring-0! outline-none! focus-visible:ring-0 focus-visible:ring-offset-0"
|
|
177
|
+
/>
|
|
178
|
+
<ComboboxSeparator />
|
|
179
|
+
<ComboboxEmpty className="px-4 py-2.5 text-sm">
|
|
180
|
+
No country found.
|
|
181
|
+
</ComboboxEmpty>
|
|
182
|
+
<ComboboxList>
|
|
183
|
+
<div className="relative flex max-h-full">
|
|
184
|
+
<div className="flex max-h-[min(var(--available-height),24rem)] w-full scroll-pt-2 scroll-pb-2 flex-col overscroll-contain">
|
|
185
|
+
<ScrollArea className="size-full min-h-0 **:data-[slot=scroll-area-scrollbar]:m-0 [&_[data-slot=scroll-area-viewport]]:h-full [&_[data-slot=scroll-area-viewport]]:overscroll-contain">
|
|
186
|
+
{filteredCountries.map((item: CountryEntry) =>
|
|
187
|
+
item.value ? (
|
|
188
|
+
<ComboboxItem
|
|
189
|
+
key={item.value}
|
|
190
|
+
value={item.value}
|
|
191
|
+
className="flex items-center gap-2"
|
|
192
|
+
>
|
|
193
|
+
<FlagComponent
|
|
194
|
+
country={item.value}
|
|
195
|
+
countryName={item.label}
|
|
196
|
+
/>
|
|
197
|
+
<span className="flex-1 text-sm">{item.label}</span>
|
|
198
|
+
<span className="text-foreground/50 text-sm">
|
|
199
|
+
{`+${BasePhoneInput.getCountryCallingCode(item.value)}`}
|
|
200
|
+
</span>
|
|
201
|
+
</ComboboxItem>
|
|
202
|
+
) : null,
|
|
203
|
+
)}
|
|
204
|
+
</ScrollArea>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
</ComboboxList>
|
|
208
|
+
</ComboboxContent>
|
|
209
|
+
</Combobox>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function FlagComponent({ country, countryName }: BasePhoneInput.FlagProps) {
|
|
214
|
+
const Flag = flags[country];
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<span className="flex h-4 w-4 items-center justify-center [&_svg:not([class*='size-'])]:size-full! [&_svg:not([class*='size-'])]:rounded-[5px]">
|
|
218
|
+
{Flag ? (
|
|
219
|
+
<Flag title={countryName} />
|
|
220
|
+
) : (
|
|
221
|
+
<HugeiconsIcon
|
|
222
|
+
icon={Globe02Icon}
|
|
223
|
+
strokeWidth={2}
|
|
224
|
+
className="size-4 opacity-60"
|
|
225
|
+
/>
|
|
226
|
+
)}
|
|
227
|
+
</span>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export { PhoneInput };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Popover as PopoverPrimitive } from "radix-ui";
|
|
3
|
+
|
|
4
|
+
import { cn } from "@/lib/utils";
|
|
5
|
+
|
|
6
|
+
function Popover({
|
|
7
|
+
...props
|
|
8
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
|
|
9
|
+
return <PopoverPrimitive.Root data-slot="popover" {...props} />;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function PopoverTrigger({
|
|
13
|
+
...props
|
|
14
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
|
|
15
|
+
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function PopoverContent({
|
|
19
|
+
className,
|
|
20
|
+
align = "center",
|
|
21
|
+
sideOffset = 4,
|
|
22
|
+
...props
|
|
23
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
|
|
24
|
+
return (
|
|
25
|
+
<PopoverPrimitive.Portal>
|
|
26
|
+
<PopoverPrimitive.Content
|
|
27
|
+
data-slot="popover-content"
|
|
28
|
+
align={align}
|
|
29
|
+
sideOffset={sideOffset}
|
|
30
|
+
className={cn(
|
|
31
|
+
"z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden 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 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
32
|
+
className,
|
|
33
|
+
)}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
</PopoverPrimitive.Portal>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function PopoverAnchor({
|
|
41
|
+
...props
|
|
42
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
|
|
43
|
+
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function PopoverHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
47
|
+
return (
|
|
48
|
+
<div
|
|
49
|
+
data-slot="popover-header"
|
|
50
|
+
className={cn("flex flex-col gap-1 text-sm", className)}
|
|
51
|
+
{...props}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function PopoverTitle({ className, ...props }: React.ComponentProps<"h2">) {
|
|
57
|
+
return (
|
|
58
|
+
<div
|
|
59
|
+
data-slot="popover-title"
|
|
60
|
+
className={cn("font-medium", className)}
|
|
61
|
+
{...props}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function PopoverDescription({
|
|
67
|
+
className,
|
|
68
|
+
...props
|
|
69
|
+
}: React.ComponentProps<"p">) {
|
|
70
|
+
return (
|
|
71
|
+
<p
|
|
72
|
+
data-slot="popover-description"
|
|
73
|
+
className={cn("text-muted-foreground", className)}
|
|
74
|
+
{...props}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
Popover,
|
|
81
|
+
PopoverTrigger,
|
|
82
|
+
PopoverContent,
|
|
83
|
+
PopoverAnchor,
|
|
84
|
+
PopoverHeader,
|
|
85
|
+
PopoverTitle,
|
|
86
|
+
PopoverDescription,
|
|
87
|
+
};
|