@12-apps/ui 1.0.0 → 1.3.1
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/components-catalog.md +14 -0
- package/package.json +42 -27
- package/src/__tests__/data-grid.test.tsx +125 -0
- package/src/__tests__/package-wiring.test.ts +12 -8
- package/src/__tests__/social-login-button.test.tsx +5 -5
- package/src/__tests__/viewport.test.ts +50 -0
- package/src/charts/index.ts +8 -0
- package/src/components/data-display/Alert/Alert.md +1 -1
- package/src/components/data-display/Alert/Alert.stories.tsx +5 -7
- package/src/components/data-display/Alert/Alert.styles.tsx +255 -0
- package/src/components/data-display/Alert/Alert.test.stories.tsx +11 -13
- package/src/components/data-display/Alert/Alert.tsx +135 -328
- package/src/components/data-display/AlertDialog/AlertDialog.stories.tsx +3 -1
- package/src/components/data-display/AlertDialog/AlertDialog.tsx +191 -78
- package/src/components/data-display/AlertDialog/AlertDialog.types.ts +8 -1
- package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.test.stories.tsx +5 -5
- package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.tsx +44 -35
- package/src/components/data-display/Avatar/Avatar.stories.tsx +4 -1
- package/src/components/data-display/Avatar/Avatar.test.stories.tsx +5 -3
- package/src/components/data-display/Avatar/Avatar.tsx +154 -450
- package/src/components/data-display/Avatar/Avatar.view.tsx +396 -0
- package/src/components/data-display/Badge/Badge.animations.ts +67 -0
- package/src/components/data-display/Badge/Badge.helpers.ts +74 -0
- package/src/components/data-display/Badge/Badge.stories.tsx +14 -16
- package/src/components/data-display/Badge/Badge.styles.ts +261 -0
- package/src/components/data-display/Badge/Badge.test.stories.tsx +32 -31
- package/src/components/data-display/Badge/Badge.tsx +151 -557
- package/src/components/data-display/Badge/Badge.variants.ts +106 -0
- package/src/components/data-display/Badge/BadgeContent.tsx +107 -0
- package/src/components/data-display/Banner/Banner.stories.tsx +5 -1
- package/src/components/data-display/Banner/Banner.styles.ts +120 -0
- package/src/components/data-display/Banner/Banner.tsx +179 -224
- package/src/components/data-display/Chart/Chart.md +48 -1
- package/src/components/data-display/Chart/Chart.tsx +82 -500
- package/src/components/data-display/Chart/Chart.types.ts +2 -0
- package/src/components/data-display/Chart/ChartComposables.tsx +121 -0
- package/src/components/data-display/Chart/ChartSpec.types.ts +70 -0
- package/src/components/data-display/Chart/SpecChart.stories.tsx +150 -0
- package/src/components/data-display/Chart/SpecChart.test.stories.tsx +56 -0
- package/src/components/data-display/Chart/SpecChart.tsx +53 -0
- package/src/components/data-display/Chart/__tests__/SpecChart.test.tsx +60 -0
- package/src/components/data-display/Chart/__tests__/chart-format.test.ts +43 -0
- package/src/components/data-display/Chart/__tests__/chart-spec.test.ts +119 -0
- package/src/components/data-display/Chart/chart-format.ts +26 -0
- package/src/components/data-display/Chart/chart-internals.ts +148 -0
- package/src/components/data-display/Chart/chart-renderers.tsx +338 -0
- package/src/components/data-display/Chart/chart-spec-registry.ts +74 -0
- package/src/components/data-display/Chart/chart-spec.ts +171 -0
- package/src/components/data-display/Chart/index.ts +30 -0
- package/src/components/data-display/Chip/Chip.helpers.tsx +131 -0
- package/src/components/data-display/Chip/Chip.stories.tsx +2 -1
- package/src/components/data-display/Chip/Chip.test.stories.tsx +11 -8
- package/src/components/data-display/Chip/Chip.tsx +31 -94
- package/src/components/data-display/DataGrid/DataGrid.body.tsx +141 -0
- package/src/components/data-display/DataGrid/DataGrid.cells.tsx +238 -0
- package/src/components/data-display/DataGrid/DataGrid.model.ts +315 -0
- package/src/components/data-display/DataGrid/DataGrid.rows.ts +112 -0
- package/src/components/data-display/DataGrid/DataGrid.states.tsx +102 -0
- package/src/components/data-display/DataGrid/DataGrid.test.stories.tsx +6 -12
- package/src/components/data-display/DataGrid/DataGrid.tsx +129 -725
- package/src/components/data-display/DataViews/DataViewsGrid.tsx +187 -0
- package/src/components/data-display/DataViews/DataViewsTableBase.tsx +400 -0
- package/src/components/data-display/DataViews/ManageViewsDialog.tsx +140 -0
- package/src/components/data-display/DataViews/SaveViewModal.tsx +289 -0
- package/src/components/data-display/DataViews/__tests__/DataViewsGrid.test.tsx +271 -0
- package/src/components/data-display/DataViews/__tests__/DataViewsTableBase.test.tsx +134 -0
- package/src/components/data-display/DataViews/__tests__/SaveViewModal.test.tsx +83 -0
- package/src/components/data-display/DataViews/__tests__/data-views-filter.test.ts +115 -0
- package/src/components/data-display/DataViews/__tests__/data-views-preview.test.ts +53 -0
- package/src/components/data-display/DataViews/__tests__/range-pill.test.tsx +114 -0
- package/src/components/data-display/DataViews/base-card.stories.tsx +136 -0
- package/src/components/data-display/DataViews/base-card.tsx +278 -0
- package/src/components/data-display/DataViews/data-views-filter-panel.tsx +184 -0
- package/src/components/data-display/DataViews/data-views-filter.ts +138 -0
- package/src/components/data-display/DataViews/data-views-grid-helpers.tsx +248 -0
- package/src/components/data-display/DataViews/data-views-grid-parts.tsx +400 -0
- package/src/components/data-display/DataViews/data-views-inline-bar.tsx +257 -0
- package/src/components/data-display/DataViews/data-views-layout-context.tsx +176 -0
- package/src/components/data-display/DataViews/data-views-pagination.tsx +31 -0
- package/src/components/data-display/DataViews/data-views-preview.ts +53 -0
- package/src/components/data-display/DataViews/data-views-range-pill.tsx +277 -0
- package/src/components/data-display/DataViews/data-views-table-parts.tsx +150 -0
- package/src/components/data-display/DataViews/data-views-toolbar.tsx +149 -0
- package/src/components/data-display/DataViews/data-views-types.ts +312 -0
- package/src/components/data-display/DataViews/data-views-view-mutations.ts +68 -0
- package/src/components/data-display/DataViews/index.ts +33 -0
- package/src/components/data-display/DataViews/use-data-views-state.ts +349 -0
- package/src/components/data-display/DateTimeDisplay/DateTimeDisplay.hooks.ts +104 -0
- package/src/components/data-display/DateTimeDisplay/DateTimeDisplay.tsx +68 -118
- package/src/components/data-display/DescriptionItem/DescriptionItem.stories.tsx +1 -1
- package/src/components/data-display/DescriptionItem/DescriptionItem.tsx +52 -34
- package/src/components/data-display/EmptyState/EmptyState.test.stories.tsx +6 -6
- package/src/components/data-display/EmptyState/EmptyState.tsx +218 -135
- package/src/components/data-display/ErrorState/ErrorState.test.stories.tsx +2 -2
- package/src/components/data-display/ErrorState/ErrorState.tsx +83 -55
- package/src/components/data-display/HoverCard/HoverCard.stories.tsx +3 -1
- package/src/components/data-display/HoverCard/HoverCard.test.stories.tsx +5 -5
- package/src/components/data-display/InteractiveTooltip/InteractiveTooltip.hooks.ts +99 -0
- package/src/components/data-display/InteractiveTooltip/InteractiveTooltip.styles.ts +87 -0
- package/src/components/data-display/InteractiveTooltip/InteractiveTooltip.tsx +28 -155
- package/src/components/data-display/LazyImage/LazyImage.hooks.ts +203 -0
- package/src/components/data-display/LazyImage/LazyImage.md +1 -1
- package/src/components/data-display/LazyImage/LazyImage.stories.tsx +3 -3
- package/src/components/data-display/LazyImage/LazyImage.tsx +144 -243
- package/src/components/data-display/Lightbox/Lightbox.constants.ts +53 -0
- package/src/components/data-display/Lightbox/Lightbox.helpers.ts +39 -0
- package/src/components/data-display/Lightbox/Lightbox.hooks.ts +259 -0
- package/src/components/data-display/Lightbox/Lightbox.test.stories.tsx +28 -35
- package/src/components/data-display/Lightbox/Lightbox.tsx +98 -658
- package/src/components/data-display/Lightbox/LightboxControls.tsx +152 -0
- package/src/components/data-display/Lightbox/LightboxCurrentMedia.tsx +50 -0
- package/src/components/data-display/Lightbox/LightboxMedia.tsx +76 -0
- package/src/components/data-display/Lightbox/LightboxOverlay.tsx +83 -0
- package/src/components/data-display/Lightbox/LightboxStage.tsx +97 -0
- package/src/components/data-display/Lightbox/LightboxThumbnails.tsx +83 -0
- package/src/components/data-display/Lightbox/useLightbox.ts +80 -0
- package/src/components/data-display/LoadingState/LoadingState.helpers.ts +52 -0
- package/src/components/data-display/LoadingState/LoadingState.tsx +117 -87
- package/src/components/data-display/MapPreview/MapControlBar.tsx +116 -0
- package/src/components/data-display/MapPreview/MapDecorations.tsx +155 -0
- package/src/components/data-display/MapPreview/MapLayers.tsx +70 -0
- package/src/components/data-display/MapPreview/MapMarkers.tsx +84 -0
- package/src/components/data-display/MapPreview/MapOverlays.tsx +68 -0
- package/src/components/data-display/MapPreview/MapPreview.constants.ts +19 -0
- package/src/components/data-display/MapPreview/MapPreview.helpers.ts +63 -0
- package/src/components/data-display/MapPreview/MapPreview.hooks.ts +265 -0
- package/src/components/data-display/MapPreview/MapPreview.test.stories.tsx +14 -10
- package/src/components/data-display/MapPreview/MapPreview.tsx +52 -882
- package/src/components/data-display/MapPreview/MapPreview.types.ts +8 -1
- package/src/components/data-display/MapPreview/MapSearchBar.tsx +64 -0
- package/src/components/data-display/MapPreview/MapTiles.tsx +70 -0
- package/src/components/data-display/MapPreview/StaticMapView.tsx +63 -0
- package/src/components/data-display/MapPreview/mapProjection.ts +52 -0
- package/src/components/data-display/MapPreview/mapSurface.ts +37 -0
- package/src/components/data-display/MapPreview/useMapPreview.ts +62 -0
- package/src/components/data-display/Popover/Popover.test.stories.tsx +13 -19
- package/src/components/data-display/Progress/Progress.helpers.ts +37 -0
- package/src/components/data-display/Progress/Progress.styles.ts +101 -0
- package/src/components/data-display/Progress/Progress.tsx +185 -213
- package/src/components/data-display/SectionOnboarding/SectionOnboarding.stories.tsx +1 -1
- package/src/components/data-display/SectionOnboarding/SectionOnboarding.tsx +1 -1
- package/src/components/data-display/StatCard/StatCard.md +117 -0
- package/src/components/data-display/StatCard/StatCard.stories.tsx +167 -0
- package/src/components/data-display/StatCard/StatCard.test.stories.tsx +240 -0
- package/src/components/data-display/StatCard/StatCard.tsx +236 -0
- package/src/components/data-display/StatCard/StatCard.types.ts +62 -0
- package/src/components/data-display/StatCard/index.ts +7 -0
- package/src/components/data-display/Stepper/Stepper.test.stories.tsx +12 -19
- package/src/components/data-display/Stepper/Stepper.tsx +1 -1
- package/src/components/data-display/Table/Table.helpers.ts +31 -0
- package/src/components/data-display/Table/Table.hooks.ts +161 -0
- package/src/components/data-display/Table/Table.stories.tsx +3 -1
- package/src/components/data-display/Table/Table.styles.ts +223 -0
- package/src/components/data-display/Table/Table.test.stories.tsx +4 -4
- package/src/components/data-display/Table/Table.tsx +291 -748
- package/src/components/data-display/Table/TableParts.hooks.tsx +112 -0
- package/src/components/data-display/Table/TableParts.tsx +298 -0
- package/src/components/data-display/Table/TableStates.tsx +21 -0
- package/src/components/data-display/Timeline/Timeline.stories.tsx +10 -12
- package/src/components/data-display/Timeline/Timeline.test.stories.tsx +30 -44
- package/src/components/data-display/Timeline/Timeline.tsx +23 -284
- package/src/components/data-display/Timeline/TimelineRow.tsx +346 -0
- package/src/components/data-display/TimingDiagram/TimingDiagram.tsx +38 -311
- package/src/components/data-display/TimingDiagram/TimingDiagram.views.tsx +346 -0
- package/src/components/data-display/Tooltip/Tooltip.stories.tsx +4 -1
- package/src/components/data-display/Tooltip/Tooltip.test.stories.tsx +44 -58
- package/src/components/data-display/Tooltip/Tooltip.tsx +67 -62
- package/src/components/data-display/index.ts +1 -0
- package/src/components/feedback/ConfirmAction/ConfirmAction.hooks.ts +96 -0
- package/src/components/feedback/ConfirmAction/ConfirmAction.md +140 -0
- package/src/components/feedback/ConfirmAction/ConfirmAction.parts.tsx +154 -0
- package/src/components/feedback/ConfirmAction/ConfirmAction.stories.tsx +146 -0
- package/src/components/feedback/ConfirmAction/ConfirmAction.test.stories.tsx +114 -0
- package/src/components/feedback/ConfirmAction/ConfirmAction.tsx +46 -0
- package/src/components/feedback/ConfirmAction/ConfirmAction.types.ts +111 -0
- package/src/components/feedback/ConfirmAction/ConfirmButton.tsx +18 -0
- package/src/components/feedback/ConfirmAction/__tests__/confirm-action.test.tsx +288 -0
- package/src/components/feedback/ConfirmAction/index.ts +16 -0
- package/src/components/feedback/ConfirmAction/with-confirmation.tsx +112 -0
- package/src/components/feedback/Dialog/Dialog.styles.ts +4 -2
- package/src/components/feedback/Dialog/Dialog.tsx +26 -1
- package/src/components/feedback/Dialog/__tests__/dialog-content-spacing.test.tsx +66 -0
- package/src/components/feedback/Modal/Modal.md +1 -1
- package/src/components/feedback/Modal/Modal.stories.tsx +2 -2
- package/src/components/feedback/Sonner/Sonner.tsx +104 -288
- package/src/components/feedback/Sonner/Sonner.types.ts +7 -0
- package/src/components/feedback/Sonner/SonnerToast.tsx +216 -0
- package/src/components/feedback/StackedModal/StackedModal.hooks.ts +226 -0
- package/src/components/feedback/StackedModal/StackedModal.parts.tsx +311 -0
- package/src/components/feedback/StackedModal/StackedModal.stories.tsx +13 -15
- package/src/components/feedback/StackedModal/StackedModal.styles.ts +193 -0
- package/src/components/feedback/StackedModal/StackedModal.tsx +100 -619
- package/src/components/feedback/StackedModal/StackedModal.types.ts +17 -3
- package/src/components/feedback/StackedModal/__tests__/stacked-modal-viewport.test.tsx +104 -0
- package/src/components/feedback/StackedModal/modal-stack.tsx +119 -0
- package/src/components/feedback/Toast/Toast.tsx +92 -81
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.geometry.ts +65 -0
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.hooks.ts +185 -0
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.test.stories.tsx +2 -2
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.tsx +156 -414
- package/src/components/feedback/TutorialOverlay/TutorialStepBody.tsx +255 -0
- package/src/components/feedback/index.ts +1 -0
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.helpers.ts +58 -0
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.hooks.ts +93 -0
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.mapper.ts +57 -0
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.stories.tsx +4 -2
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.test.stories.tsx +20 -16
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.tsx +26 -829
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.types.ts +11 -0
- package/src/components/form/AddressAutocomplete/AddressAutocompleteField.tsx +86 -0
- package/src/components/form/AddressAutocomplete/AddressFallbackField.tsx +64 -0
- package/src/components/form/AddressAutocomplete/AddressInputField.tsx +80 -0
- package/src/components/form/AddressAutocomplete/AddressOption.tsx +83 -0
- package/src/components/form/AddressAutocomplete/AddressSuggestionsPaper.tsx +24 -0
- package/src/components/form/AddressAutocomplete/AddressTextField.tsx +43 -0
- package/src/components/form/AddressAutocomplete/mockPlaces.ts +208 -0
- package/src/components/form/AddressAutocomplete/useAddressPredictions.ts +136 -0
- package/src/components/form/AddressAutocomplete/useAddressSelection.ts +113 -0
- package/src/components/form/AddressAutocomplete/useCurrentLocation.ts +116 -0
- package/src/components/form/AddressAutocomplete/useGoogleMapsAPI.ts +75 -0
- package/src/components/form/Button/Button.helpers.ts +36 -0
- package/src/components/form/Button/Button.stories.tsx +4 -1
- package/src/components/form/Button/Button.styles.ts +225 -0
- package/src/components/form/Button/Button.test.stories.tsx +25 -21
- package/src/components/form/Button/Button.tsx +45 -252
- package/src/components/form/Calendar/Calendar.dates.ts +100 -0
- package/src/components/form/Calendar/Calendar.helpers.ts +32 -0
- package/src/components/form/Calendar/Calendar.hooks.ts +278 -0
- package/src/components/form/Calendar/Calendar.keyboard.ts +32 -0
- package/src/components/form/Calendar/Calendar.selection.ts +156 -0
- package/src/components/form/Calendar/Calendar.test.stories.tsx +33 -34
- package/src/components/form/Calendar/Calendar.tsx +63 -551
- package/src/components/form/Calendar/Calendar.types.ts +16 -0
- package/src/components/form/Calendar/CalendarDay.tsx +127 -0
- package/src/components/form/Calendar/CalendarDayCell.tsx +52 -0
- package/src/components/form/Calendar/CalendarMonth.tsx +128 -0
- package/src/components/form/CepField/CepField.md +138 -0
- package/src/components/form/CepField/CepField.stories.tsx +138 -0
- package/src/components/form/CepField/CepField.test.stories.tsx +281 -0
- package/src/components/form/CepField/CepField.tsx +211 -0
- package/src/components/form/CepField/CepField.types.ts +73 -0
- package/src/components/form/CepField/index.ts +2 -0
- package/src/components/form/Checkbox/Checkbox.helpers.ts +28 -0
- package/src/components/form/Checkbox/Checkbox.tsx +19 -16
- package/src/components/form/CodeEditor/CodeEditor.helpers.ts +45 -0
- package/src/components/form/CodeEditor/CodeEditor.hooks.ts +104 -0
- package/src/components/form/CodeEditor/CodeEditor.monaco.ts +109 -0
- package/src/components/form/CodeEditor/CodeEditor.test.stories.tsx +17 -18
- package/src/components/form/CodeEditor/CodeEditor.tsx +81 -330
- package/src/components/form/CodeEditor/CodeEditorToolbar.tsx +168 -0
- package/src/components/form/Command/Command.hooks.ts +207 -0
- package/src/components/form/Command/Command.parts.tsx +58 -0
- package/src/components/form/Command/Command.styles.ts +83 -0
- package/src/components/form/Command/Command.tsx +61 -270
- package/src/components/form/CreatableSelect/CreatableSelect.md +1 -1
- package/src/components/form/CreatableSelect/CreatableSelect.test.stories.tsx +1 -1
- package/src/components/form/CreatableSelect/CreatableSelect.tsx +152 -71
- package/src/components/form/CreatableSelect/CreatableSelect.types.ts +13 -0
- package/src/components/form/HeaderButton/HeaderButton.tsx +80 -0
- package/src/components/form/HeaderButton/index.ts +2 -0
- package/src/components/form/Input/Input.stories.tsx +5 -1
- package/src/components/form/Input/Input.styles.ts +176 -0
- package/src/components/form/Input/Input.test.stories.tsx +30 -23
- package/src/components/form/Input/Input.tsx +71 -211
- package/src/components/form/Input/Input.types.ts +11 -0
- package/src/components/form/InputOTP/InputOTP.test.stories.tsx +9 -17
- package/src/components/form/Menubar/Menubar.test.stories.tsx +4 -8
- package/src/components/form/PasswordStrength/PasswordStrength.helpers.tsx +117 -0
- package/src/components/form/PasswordStrength/PasswordStrength.test.stories.tsx +3 -3
- package/src/components/form/PasswordStrength/PasswordStrength.tsx +202 -255
- package/src/components/form/PhoneInput/PhoneInput.hooks.ts +134 -0
- package/src/components/form/PhoneInput/PhoneInput.test.stories.tsx +4 -4
- package/src/components/form/PhoneInput/PhoneInput.tsx +279 -292
- package/src/components/form/PhoneInput/countries.ts +54 -0
- package/src/components/form/PhoneInput/phone.ts +47 -0
- package/src/components/form/RadioGroup/RadioGroup.test.stories.tsx +9 -9
- package/src/components/form/RichTextEditor/RichTextEditor.dom.ts +124 -0
- package/src/components/form/RichTextEditor/RichTextEditor.format.ts +61 -0
- package/src/components/form/RichTextEditor/RichTextEditor.hooks.ts +142 -0
- package/src/components/form/RichTextEditor/RichTextEditor.test.stories.tsx +5 -12
- package/src/components/form/RichTextEditor/RichTextEditor.tsx +98 -410
- package/src/components/form/RichTextEditor/RichTextEditorToolbar.tsx +187 -0
- package/src/components/form/SearchPalette/SearchPalette.parts.tsx +22 -0
- package/src/components/form/SearchPalette/SearchPalette.tsx +13 -9
- package/src/components/form/Select/Select.test.stories.tsx +35 -27
- package/src/components/form/Slider/Slider.test.stories.tsx +9 -11
- package/src/components/form/Switch/Switch.md +2 -1
- package/src/components/form/Switch/Switch.test.stories.tsx +6 -6
- package/src/components/form/Textarea/Textarea.styles.ts +143 -0
- package/src/components/form/Textarea/Textarea.test.stories.tsx +20 -26
- package/src/components/form/Textarea/Textarea.tsx +114 -535
- package/src/components/form/Textarea/TextareaRichEditor.tsx +377 -0
- package/src/components/form/Toggle/Toggle.styles.ts +211 -0
- package/src/components/form/Toggle/Toggle.test.stories.tsx +19 -27
- package/src/components/form/Toggle/Toggle.tsx +10 -185
- package/src/components/form/UploadButton/UploadButton.hooks.ts +323 -0
- package/src/components/form/UploadButton/UploadButton.parts.tsx +210 -0
- package/src/components/form/UploadButton/UploadButton.stories.tsx +2 -1
- package/src/components/form/UploadButton/UploadButton.test.stories.tsx +123 -4
- package/src/components/form/UploadButton/UploadButton.tsx +76 -305
- package/src/components/form/UploadButton/UploadButton.types.ts +16 -0
- package/src/components/form/index.ts +1 -0
- package/src/components/form/total-form/Fields/CepField.tsx +143 -0
- package/src/components/form/total-form/Fields/ToggleField.tsx +61 -0
- package/src/components/form/total-form/Fields/index.ts +4 -0
- package/src/components/form/total-form/FormContainer.tsx +3 -3
- package/src/components/form/total-form/SubmitButton.tsx +25 -2
- package/src/components/form/total-form/total-form.test.tsx +118 -1
- package/src/components/layout/Accordion/Accordion.md +1 -1
- package/src/components/layout/Accordion/Accordion.stories.tsx +5 -1
- package/src/components/layout/Accordion/Accordion.styles.ts +80 -0
- package/src/components/layout/Accordion/Accordion.test.stories.tsx +32 -50
- package/src/components/layout/Accordion/Accordion.tsx +2 -75
- package/src/components/layout/Card/Card.helpers.ts +30 -0
- package/src/components/layout/Card/Card.stories.tsx +9 -11
- package/src/components/layout/Card/Card.styles.ts +182 -0
- package/src/components/layout/Card/Card.test.stories.tsx +46 -46
- package/src/components/layout/Card/Card.tsx +24 -241
- package/src/components/layout/CardGrid/CardGrid.md +96 -0
- package/src/components/layout/CardGrid/CardGrid.tsx +140 -0
- package/src/components/layout/CardGrid/__tests__/CardGrid.test.tsx +92 -0
- package/src/components/layout/CardGrid/index.ts +2 -0
- package/src/components/layout/Collapsible/Collapsible.helpers.ts +83 -0
- package/src/components/layout/Collapsible/Collapsible.test.stories.tsx +7 -3
- package/src/components/layout/Collapsible/Collapsible.tsx +111 -107
- package/src/components/layout/Container/Container.test.stories.tsx +11 -16
- package/src/components/layout/ContentToolbar/ColumnsMenu.tsx +1 -1
- package/src/components/layout/ContentToolbar/ContentToolbar.tsx +120 -44
- package/src/components/layout/ContentToolbar/ContentToolbar.types.ts +9 -0
- package/src/components/layout/ContentToolbar/FilterTrigger.tsx +1 -1
- package/src/components/layout/ContentToolbar/MultiSelectDropdown.tsx +58 -43
- package/src/components/layout/ContentToolbar/MultiSelectTriggers.tsx +139 -0
- package/src/components/layout/ContentToolbar/SavedViewsMenu.tsx +10 -3
- package/src/components/layout/ContentToolbar/SortByDropdown.tsx +35 -11
- package/src/components/layout/ContentToolbar/ViewSelector.tsx +5 -6
- package/src/components/layout/ContentToolbar/__tests__/MultiSelectDropdown.test.tsx +21 -0
- package/src/components/layout/Dashboard/Dashboard.test.stories.tsx +27 -1
- package/src/components/layout/Dashboard/Dashboard.tsx +27 -8
- package/src/components/layout/Dashboard/DashboardParts.tsx +12 -19
- package/src/components/layout/Dashboard/index.ts +2 -1
- package/src/components/layout/Drawer/Drawer.stories.tsx +8 -10
- package/src/components/layout/Drawer/Drawer.test.stories.tsx +18 -14
- package/src/components/layout/Drawer/Drawer.tsx +67 -53
- package/src/components/layout/Resizable/Resizable.helpers.ts +133 -0
- package/src/components/layout/Resizable/Resizable.hooks.ts +68 -0
- package/src/components/layout/Resizable/Resizable.tsx +38 -153
- package/src/components/layout/ScrollArea/ScrollArea.helpers.ts +51 -0
- package/src/components/layout/ScrollArea/ScrollArea.styles.ts +248 -0
- package/src/components/layout/ScrollArea/ScrollArea.tsx +183 -374
- package/src/components/layout/ScrollArea/ScrollAreaContent.tsx +70 -0
- package/src/components/layout/ScrollArea/ScrollViewport.tsx +90 -0
- package/src/components/layout/Separator/Separator.styles.ts +128 -0
- package/src/components/layout/Separator/Separator.test.stories.tsx +3 -12
- package/src/components/layout/Separator/Separator.tsx +6 -132
- package/src/components/layout/SettingsLayout/SettingsLayout.parts.tsx +2 -1
- package/src/components/layout/SettingsLayout/SettingsLayout.stories.tsx +6 -8
- package/src/components/layout/Sidebar/Sidebar.stories.tsx +10 -12
- package/src/components/layout/Sidebar/Sidebar.test.stories.tsx +35 -37
- package/src/components/layout/Skeleton/Skeleton.helpers.ts +33 -0
- package/src/components/layout/Skeleton/Skeleton.styles.ts +114 -0
- package/src/components/layout/Skeleton/Skeleton.test.stories.tsx +3 -3
- package/src/components/layout/Skeleton/Skeleton.tsx +67 -155
- package/src/components/layout/TableFilter/TableFilter.tsx +2 -1
- package/src/components/navigation/Breadcrumbs/BreadcrumbEntry.tsx +305 -0
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.md +2 -1
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.stories.tsx +12 -14
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.styles.tsx +212 -0
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.test.stories.tsx +62 -61
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.tsx +116 -429
- package/src/components/navigation/CommandPalette/CommandPalette.helpers.ts +82 -0
- package/src/components/navigation/CommandPalette/CommandPalette.hooks.ts +202 -0
- package/src/components/navigation/CommandPalette/CommandPalette.stories.tsx +3 -1
- package/src/components/navigation/CommandPalette/CommandPalette.test.stories.tsx +3 -5
- package/src/components/navigation/CommandPalette/CommandPalette.tsx +108 -341
- package/src/components/navigation/CommandPalette/CommandPaletteResults.tsx +182 -0
- package/src/components/navigation/CommandPalette/ShortcutChip.tsx +18 -0
- package/src/components/navigation/ContextMenu/ContextMenu.md +3 -1
- package/src/components/navigation/ContextMenu/ContextMenu.stories.tsx +4 -1
- package/src/components/navigation/ContextMenu/ContextMenu.test.stories.tsx +19 -24
- package/src/components/navigation/ContextMenu/ContextMenu.tsx +70 -54
- package/src/components/navigation/DropdownMenu/DropdownMenu.md +3 -1
- package/src/components/navigation/DropdownMenu/DropdownMenu.stories.tsx +17 -19
- package/src/components/navigation/DropdownMenu/DropdownMenu.test.stories.tsx +26 -26
- package/src/components/navigation/DropdownMenu/DropdownMenu.tsx +189 -111
- package/src/components/navigation/NavigationMenu/NavigationMegaSection.tsx +66 -0
- package/src/components/navigation/NavigationMenu/NavigationMenu.md +7 -2
- package/src/components/navigation/NavigationMenu/NavigationMenu.shell.tsx +218 -0
- package/src/components/navigation/NavigationMenu/NavigationMenu.styles.ts +223 -0
- package/src/components/navigation/NavigationMenu/NavigationMenu.tsx +119 -808
- package/src/components/navigation/NavigationMenu/NavigationMenuItem.hooks.ts +126 -0
- package/src/components/navigation/NavigationMenu/NavigationMenuItem.tsx +352 -0
- package/src/components/navigation/NavigationMenu/NavigationStandardBody.tsx +148 -0
- package/src/components/navigation/NavigationMenu/stories/NavigationMenu.stories.tsx +15 -17
- package/src/components/navigation/NavigationMenu/stories/NavigationMenu.test.stories.tsx +27 -23
- package/src/components/navigation/NavigationMenu/stories/NavigationMenuHorizontal.stories.tsx +11 -13
- package/src/components/navigation/NavigationMenu/stories/NavigationMenuVertical.stories.tsx +9 -11
- package/src/components/navigation/Pagination/Pagination.helpers.tsx +85 -0
- package/src/components/navigation/Pagination/Pagination.md +2 -1
- package/src/components/navigation/Pagination/Pagination.stories.tsx +4 -6
- package/src/components/navigation/Pagination/Pagination.styles.ts +135 -0
- package/src/components/navigation/Pagination/Pagination.tsx +178 -313
- package/src/components/navigation/Pagination/PaginationParts.tsx +81 -0
- package/src/components/navigation/Tabs/Tabs.md +3 -1
- package/src/components/navigation/Tabs/Tabs.stories.tsx +21 -23
- package/src/components/navigation/Tabs/Tabs.styles.ts +163 -0
- package/src/components/navigation/Tabs/Tabs.test.stories.tsx +37 -37
- package/src/components/navigation/Tabs/Tabs.tsx +192 -361
- package/src/components/navigation/Tabs/TabsPanel.tsx +100 -0
- package/src/components/typography/Blockquote/Blockquote.tsx +1 -1
- package/src/components/typography/Code/Code.test.stories.tsx +5 -5
- package/src/components/typography/Code/Code.tsx +74 -49
- package/src/components/typography/Heading/Heading.test.stories.tsx +8 -8
- package/src/components/typography/Paragraph/Paragraph.test.stories.tsx +5 -12
- package/src/components/typography/Text/Text.tsx +84 -77
- package/src/components/utility/AnimatedIcon/AnimatedIcon.md +4 -4
- package/src/components/utility/AnimatedIcon/AnimatedIcon.stories.tsx +19 -21
- package/src/components/utility/AnimatedIcon/AnimatedIcon.test.stories.tsx +19 -12
- package/src/components/utility/AspectRatio/AspectRatio.test.stories.tsx +9 -9
- package/src/components/utility/InfiniteScroll/InfiniteScroll.hooks.ts +118 -0
- package/src/components/utility/InfiniteScroll/InfiniteScroll.parts.tsx +54 -0
- package/src/components/utility/InfiniteScroll/InfiniteScroll.test.stories.tsx +12 -9
- package/src/components/utility/InfiniteScroll/InfiniteScroll.tsx +29 -148
- package/src/components/utility/InstallPrompt/InstallPrompt.helpers.ts +124 -0
- package/src/components/utility/InstallPrompt/InstallPrompt.md +113 -0
- package/src/components/utility/InstallPrompt/InstallPrompt.stories.tsx +118 -0
- package/src/components/utility/InstallPrompt/InstallPrompt.styles.ts +50 -0
- package/src/components/utility/InstallPrompt/InstallPrompt.test.stories.tsx +83 -0
- package/src/components/utility/InstallPrompt/InstallPrompt.tsx +192 -0
- package/src/components/utility/InstallPrompt/InstallPrompt.types.ts +78 -0
- package/src/components/utility/InstallPrompt/__tests__/InstallPrompt.ios.test.tsx +65 -0
- package/src/components/utility/InstallPrompt/__tests__/usePwaInstall.test.tsx +271 -0
- package/src/components/utility/InstallPrompt/index.ts +10 -0
- package/src/components/utility/InstallPrompt/usePwaInstall.ts +171 -0
- package/src/components/utility/Transition/Transition.helpers.ts +40 -0
- package/src/components/utility/Transition/Transition.tsx +17 -68
- package/src/components/utility/VirtualList/VirtualList.hooks.ts +319 -0
- package/src/components/utility/VirtualList/VirtualList.test.stories.tsx +49 -38
- package/src/components/utility/VirtualList/VirtualList.tsx +110 -315
- package/src/components/utility/WorkflowStep/WorkflowStep.helpers.ts +151 -0
- package/src/components/utility/WorkflowStep/WorkflowStep.parts.tsx +371 -0
- package/src/components/utility/WorkflowStep/WorkflowStep.stories.tsx +9 -11
- package/src/components/utility/WorkflowStep/WorkflowStep.test.stories.tsx +7 -7
- package/src/components/utility/WorkflowStep/WorkflowStep.tsx +51 -449
- package/src/components/utility/WorkflowStep/WorkflowStepRow.tsx +96 -0
- package/src/components/utility/index.ts +1 -0
- package/src/mui/Link.ts +2 -0
- package/src/utils/index.ts +2 -1
- package/src/utils/viewport.ts +65 -0
|
@@ -1,836 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
place_id: string;
|
|
23
|
-
description: string;
|
|
24
|
-
structured_formatting: {
|
|
25
|
-
main_text: string;
|
|
26
|
-
secondary_text: string;
|
|
27
|
-
};
|
|
28
|
-
matched_substrings?: google.maps.places.PredictionSubstring[];
|
|
29
|
-
terms?: google.maps.places.PredictionTerm[];
|
|
30
|
-
types?: string[];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const MOCK_ADDRESSES: MockPrediction[] = [
|
|
34
|
-
{
|
|
35
|
-
place_id: 'mock_1',
|
|
36
|
-
description: '123 Main Street, San Francisco, CA 94105, USA',
|
|
37
|
-
structured_formatting: {
|
|
38
|
-
main_text: '123 Main Street',
|
|
39
|
-
secondary_text: 'San Francisco, CA 94105, USA',
|
|
40
|
-
},
|
|
41
|
-
matched_substrings: [],
|
|
42
|
-
terms: [],
|
|
43
|
-
types: ['street_address'],
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
place_id: 'mock_2',
|
|
47
|
-
description: '456 Oak Avenue, New York, NY 10001, USA',
|
|
48
|
-
structured_formatting: {
|
|
49
|
-
main_text: '456 Oak Avenue',
|
|
50
|
-
secondary_text: 'New York, NY 10001, USA',
|
|
51
|
-
},
|
|
52
|
-
matched_substrings: [],
|
|
53
|
-
terms: [],
|
|
54
|
-
types: ['street_address'],
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
place_id: 'mock_3',
|
|
58
|
-
description: '789 Pine Boulevard, Los Angeles, CA 90001, USA',
|
|
59
|
-
structured_formatting: {
|
|
60
|
-
main_text: '789 Pine Boulevard',
|
|
61
|
-
secondary_text: 'Los Angeles, CA 90001, USA',
|
|
62
|
-
},
|
|
63
|
-
matched_substrings: [],
|
|
64
|
-
terms: [],
|
|
65
|
-
types: ['street_address'],
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
place_id: 'mock_4',
|
|
69
|
-
description: '321 Elm Street, Chicago, IL 60601, USA',
|
|
70
|
-
structured_formatting: {
|
|
71
|
-
main_text: '321 Elm Street',
|
|
72
|
-
secondary_text: 'Chicago, IL 60601, USA',
|
|
73
|
-
},
|
|
74
|
-
matched_substrings: [],
|
|
75
|
-
terms: [],
|
|
76
|
-
types: ['street_address'],
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
place_id: 'mock_5',
|
|
80
|
-
description: '654 Maple Drive, Austin, TX 78701, USA',
|
|
81
|
-
structured_formatting: {
|
|
82
|
-
main_text: '654 Maple Drive',
|
|
83
|
-
secondary_text: 'Austin, TX 78701, USA',
|
|
84
|
-
},
|
|
85
|
-
matched_substrings: [],
|
|
86
|
-
terms: [],
|
|
87
|
-
types: ['street_address'],
|
|
88
|
-
},
|
|
89
|
-
];
|
|
90
|
-
|
|
91
|
-
interface MockPlaceDetails {
|
|
92
|
-
formatted_address: string;
|
|
93
|
-
address_components: Array<{
|
|
94
|
-
long_name: string;
|
|
95
|
-
types: string[];
|
|
96
|
-
}>;
|
|
97
|
-
geometry: {
|
|
98
|
-
location: {
|
|
99
|
-
lat: () => number;
|
|
100
|
-
lng: () => number;
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const MOCK_PLACE_DETAILS: Record<string, MockPlaceDetails> = {
|
|
106
|
-
mock_1: {
|
|
107
|
-
formatted_address: '123 Main Street, San Francisco, CA 94105, USA',
|
|
108
|
-
address_components: [
|
|
109
|
-
{ long_name: '123', types: ['street_number'] },
|
|
110
|
-
{ long_name: 'Main Street', types: ['route'] },
|
|
111
|
-
{ long_name: 'San Francisco', types: ['locality'] },
|
|
112
|
-
{ long_name: 'California', types: ['administrative_area_level_1'] },
|
|
113
|
-
{ long_name: 'United States', types: ['country'] },
|
|
114
|
-
{ long_name: '94105', types: ['postal_code'] },
|
|
115
|
-
],
|
|
116
|
-
geometry: { location: { lat: () => 37.7749, lng: () => -122.4194 } },
|
|
117
|
-
},
|
|
118
|
-
mock_2: {
|
|
119
|
-
formatted_address: '456 Oak Avenue, New York, NY 10001, USA',
|
|
120
|
-
address_components: [
|
|
121
|
-
{ long_name: '456', types: ['street_number'] },
|
|
122
|
-
{ long_name: 'Oak Avenue', types: ['route'] },
|
|
123
|
-
{ long_name: 'New York', types: ['locality'] },
|
|
124
|
-
{ long_name: 'New York', types: ['administrative_area_level_1'] },
|
|
125
|
-
{ long_name: 'United States', types: ['country'] },
|
|
126
|
-
{ long_name: '10001', types: ['postal_code'] },
|
|
127
|
-
],
|
|
128
|
-
geometry: { location: { lat: () => 40.7128, lng: () => -74.0060 } },
|
|
129
|
-
},
|
|
130
|
-
mock_3: {
|
|
131
|
-
formatted_address: '789 Pine Boulevard, Los Angeles, CA 90001, USA',
|
|
132
|
-
address_components: [
|
|
133
|
-
{ long_name: '789', types: ['street_number'] },
|
|
134
|
-
{ long_name: 'Pine Boulevard', types: ['route'] },
|
|
135
|
-
{ long_name: 'Los Angeles', types: ['locality'] },
|
|
136
|
-
{ long_name: 'California', types: ['administrative_area_level_1'] },
|
|
137
|
-
{ long_name: 'United States', types: ['country'] },
|
|
138
|
-
{ long_name: '90001', types: ['postal_code'] },
|
|
139
|
-
],
|
|
140
|
-
geometry: { location: { lat: () => 34.0522, lng: () => -118.2437 } },
|
|
141
|
-
},
|
|
142
|
-
mock_4: {
|
|
143
|
-
formatted_address: '321 Elm Street, Chicago, IL 60601, USA',
|
|
144
|
-
address_components: [
|
|
145
|
-
{ long_name: '321', types: ['street_number'] },
|
|
146
|
-
{ long_name: 'Elm Street', types: ['route'] },
|
|
147
|
-
{ long_name: 'Chicago', types: ['locality'] },
|
|
148
|
-
{ long_name: 'Illinois', types: ['administrative_area_level_1'] },
|
|
149
|
-
{ long_name: 'United States', types: ['country'] },
|
|
150
|
-
{ long_name: '60601', types: ['postal_code'] },
|
|
151
|
-
],
|
|
152
|
-
geometry: { location: { lat: () => 41.8781, lng: () => -87.6298 } },
|
|
153
|
-
},
|
|
154
|
-
mock_5: {
|
|
155
|
-
formatted_address: '654 Maple Drive, Austin, TX 78701, USA',
|
|
156
|
-
address_components: [
|
|
157
|
-
{ long_name: '654', types: ['street_number'] },
|
|
158
|
-
{ long_name: 'Maple Drive', types: ['route'] },
|
|
159
|
-
{ long_name: 'Austin', types: ['locality'] },
|
|
160
|
-
{ long_name: 'Texas', types: ['administrative_area_level_1'] },
|
|
161
|
-
{ long_name: 'United States', types: ['country'] },
|
|
162
|
-
{ long_name: '78701', types: ['postal_code'] },
|
|
163
|
-
],
|
|
164
|
-
geometry: { location: { lat: () => 30.2672, lng: () => -97.7431 } },
|
|
165
|
-
},
|
|
166
|
-
mock_6: {
|
|
167
|
-
formatted_address: '1000 Broadway, New York, NY 10001, USA',
|
|
168
|
-
address_components: [
|
|
169
|
-
{ long_name: '1000', types: ['street_number'] },
|
|
170
|
-
{ long_name: 'Broadway', types: ['route'] },
|
|
171
|
-
{ long_name: 'New York', types: ['locality'] },
|
|
172
|
-
{ long_name: 'New York', types: ['administrative_area_level_1'] },
|
|
173
|
-
{ long_name: 'United States', types: ['country'] },
|
|
174
|
-
{ long_name: '10001', types: ['postal_code'] },
|
|
175
|
-
],
|
|
176
|
-
geometry: { location: { lat: () => 40.7589, lng: () => -73.9851 } },
|
|
177
|
-
},
|
|
178
|
-
mock_7: {
|
|
179
|
-
formatted_address: '250 Market Street, San Francisco, CA 94102, USA',
|
|
180
|
-
address_components: [
|
|
181
|
-
{ long_name: '250', types: ['street_number'] },
|
|
182
|
-
{ long_name: 'Market Street', types: ['route'] },
|
|
183
|
-
{ long_name: 'San Francisco', types: ['locality'] },
|
|
184
|
-
{ long_name: 'California', types: ['administrative_area_level_1'] },
|
|
185
|
-
{ long_name: 'United States', types: ['country'] },
|
|
186
|
-
{ long_name: '94102', types: ['postal_code'] },
|
|
187
|
-
],
|
|
188
|
-
geometry: { location: { lat: () => 37.7879, lng: () => -122.4075 } },
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
// Styled components
|
|
193
|
-
const GlassTextField = styled(TextField)(({ theme }) => ({
|
|
194
|
-
'& .MuiOutlinedInput-root': {
|
|
195
|
-
background: `linear-gradient(135deg, ${alpha(theme.palette.background.paper, 0.8)} 0%, ${alpha(theme.palette.background.paper, 0.6)} 100%)`,
|
|
196
|
-
backdropFilter: 'blur(10px)',
|
|
197
|
-
WebkitBackdropFilter: 'blur(10px)',
|
|
198
|
-
border: `1px solid ${alpha(theme.palette.divider, 0.18)}`,
|
|
199
|
-
transition: theme.transitions.create(['border-color', 'box-shadow', 'background']),
|
|
200
|
-
'&:hover': {
|
|
201
|
-
background: `linear-gradient(135deg, ${alpha(theme.palette.background.paper, 0.9)} 0%, ${alpha(theme.palette.background.paper, 0.7)} 100%)`,
|
|
202
|
-
borderColor: theme.palette.primary.main,
|
|
203
|
-
},
|
|
204
|
-
'&.Mui-focused': {
|
|
205
|
-
background: theme.palette.background.paper,
|
|
206
|
-
boxShadow: `0 0 0 2px ${alpha(theme.palette.primary.main, 0.25)}`,
|
|
207
|
-
},
|
|
208
|
-
'& fieldset': {
|
|
209
|
-
border: 'none',
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
}));
|
|
213
|
-
|
|
214
|
-
const SuggestionItem = styled(Box)(({ theme }) => ({
|
|
215
|
-
padding: theme.spacing(1.5),
|
|
216
|
-
display: 'flex',
|
|
217
|
-
alignItems: 'flex-start',
|
|
218
|
-
gap: theme.spacing(1.5),
|
|
219
|
-
cursor: 'pointer',
|
|
220
|
-
transition: theme.transitions.create(['background-color']),
|
|
221
|
-
'&:hover': {
|
|
222
|
-
backgroundColor: alpha(theme.palette.primary.main, 0.08),
|
|
223
|
-
},
|
|
224
|
-
}));
|
|
225
|
-
|
|
226
|
-
const LocationIconWrapper = styled(Box)(({ theme }) => ({
|
|
227
|
-
marginTop: theme.spacing(0.5),
|
|
228
|
-
color: theme.palette.text.secondary,
|
|
229
|
-
}));
|
|
230
|
-
|
|
231
|
-
const AddressText = styled(Box)(({ theme }) => ({
|
|
232
|
-
flex: 1,
|
|
233
|
-
'& .primary': {
|
|
234
|
-
fontSize: '0.9rem',
|
|
235
|
-
fontWeight: 500,
|
|
236
|
-
color: theme.palette.text.primary,
|
|
237
|
-
marginBottom: theme.spacing(0.25),
|
|
238
|
-
},
|
|
239
|
-
'& .secondary': {
|
|
240
|
-
fontSize: '0.8rem',
|
|
241
|
-
color: theme.palette.text.secondary,
|
|
242
|
-
},
|
|
243
|
-
}));
|
|
244
|
-
|
|
245
|
-
// Google Maps API service interface
|
|
246
|
-
interface GoogleMapsService {
|
|
247
|
-
autocompleteService: google.maps.places.AutocompleteService | null;
|
|
248
|
-
placesService: google.maps.places.PlacesService | null;
|
|
249
|
-
geocoder: google.maps.Geocoder | null;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// Hook for Google Maps API initialization
|
|
253
|
-
const useGoogleMapsAPI = (apiKey: string) => {
|
|
254
|
-
const [isLoaded, setIsLoaded] = useState(false);
|
|
255
|
-
const [error, setError] = useState<string | null>(null);
|
|
256
|
-
const [useMockData, setUseMockData] = useState(false);
|
|
257
|
-
const serviceRef = useRef<GoogleMapsService>({
|
|
258
|
-
autocompleteService: null,
|
|
259
|
-
placesService: null,
|
|
260
|
-
geocoder: null,
|
|
1
|
+
import LocationIcon from '@mui/icons-material/LocationOn';
|
|
2
|
+
import type { FC } from 'react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { resolveAddressProps } from './AddressAutocomplete.helpers';
|
|
6
|
+
import { useAddressAutocomplete } from './AddressAutocomplete.hooks';
|
|
7
|
+
import type { AddressAutocompleteProps } from './AddressAutocomplete.types';
|
|
8
|
+
import { AddressAutocompleteField } from './AddressAutocompleteField';
|
|
9
|
+
import { AddressFallbackField } from './AddressFallbackField';
|
|
10
|
+
|
|
11
|
+
export const AddressAutocomplete: FC<AddressAutocompleteProps> = (componentProps) => {
|
|
12
|
+
const resolved = resolveAddressProps(componentProps);
|
|
13
|
+
const { defaultValue, googleMapsApiKey, restrictions, onSelect, icon = <LocationIcon /> } =
|
|
14
|
+
resolved;
|
|
15
|
+
const fieldProps = { ...resolved, icon };
|
|
16
|
+
|
|
17
|
+
const state = useAddressAutocomplete({
|
|
18
|
+
defaultValue,
|
|
19
|
+
googleMapsApiKey,
|
|
20
|
+
restrictions,
|
|
21
|
+
onSelect,
|
|
261
22
|
});
|
|
262
23
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
setIsLoaded(true);
|
|
268
|
-
setError(null);
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// Check if Google Maps is already loaded
|
|
273
|
-
if (window.google && window.google.maps && window.google.maps.places) {
|
|
274
|
-
initializeServices();
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// Load Google Maps API
|
|
279
|
-
const script = document.createElement('script');
|
|
280
|
-
script.src = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places`;
|
|
281
|
-
script.async = true;
|
|
282
|
-
script.defer = true;
|
|
283
|
-
|
|
284
|
-
script.onload = () => {
|
|
285
|
-
initializeServices();
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
script.onerror = () => {
|
|
289
|
-
setError('Failed to load Google Maps API');
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
document.head.appendChild(script);
|
|
293
|
-
|
|
294
|
-
return () => {
|
|
295
|
-
// Cleanup script if component unmounts
|
|
296
|
-
if (document.head.contains(script)) {
|
|
297
|
-
document.head.removeChild(script);
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
}, [apiKey]);
|
|
301
|
-
|
|
302
|
-
const initializeServices = () => {
|
|
303
|
-
try {
|
|
304
|
-
if (window.google && window.google.maps && window.google.maps.places) {
|
|
305
|
-
serviceRef.current = {
|
|
306
|
-
autocompleteService: new window.google.maps.places.AutocompleteService(),
|
|
307
|
-
placesService: new window.google.maps.places.PlacesService(document.createElement('div')),
|
|
308
|
-
geocoder: new window.google.maps.Geocoder(),
|
|
309
|
-
};
|
|
310
|
-
setIsLoaded(true);
|
|
311
|
-
setError(null);
|
|
312
|
-
}
|
|
313
|
-
} catch {
|
|
314
|
-
setError('Failed to initialize Google Maps services');
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
return { isLoaded, error, services: serviceRef.current, useMockData };
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
// Main component with proper Google Maps integration
|
|
322
|
-
export const AddressAutocomplete: FC<AddressAutocompleteProps> = ({
|
|
323
|
-
variant = 'outlined',
|
|
324
|
-
label = 'Address',
|
|
325
|
-
placeholder = 'Enter an address',
|
|
326
|
-
icon = <LocationIcon />,
|
|
327
|
-
onSelect,
|
|
328
|
-
googleMapsApiKey,
|
|
329
|
-
floating = false,
|
|
330
|
-
restrictions,
|
|
331
|
-
error = false,
|
|
332
|
-
helperText,
|
|
333
|
-
disabled = false,
|
|
334
|
-
required = false,
|
|
335
|
-
fullWidth = true,
|
|
336
|
-
defaultValue = '',
|
|
337
|
-
getCurrentLocation = false,
|
|
338
|
-
}) => {
|
|
339
|
-
const theme = useTheme();
|
|
340
|
-
const [inputValue, setInputValue] = useState(defaultValue);
|
|
341
|
-
const [options, setOptions] = useState<(string | google.maps.places.AutocompletePrediction | MockPrediction)[]>([]);
|
|
342
|
-
const [loading, setLoading] = useState(false);
|
|
343
|
-
const [apiError, setApiError] = useState<string | null>(null);
|
|
344
|
-
const debounceTimeoutRef = useRef<number | undefined>(undefined);
|
|
345
|
-
|
|
346
|
-
const { isLoaded, error: mapsError, services, useMockData } = useGoogleMapsAPI(googleMapsApiKey);
|
|
347
|
-
|
|
348
|
-
// Debounced autocomplete function
|
|
349
|
-
const debouncedAutocomplete = useCallback(
|
|
350
|
-
(input: string) => {
|
|
351
|
-
if (debounceTimeoutRef.current) {
|
|
352
|
-
clearTimeout(debounceTimeoutRef.current);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
debounceTimeoutRef.current = window.setTimeout(() => {
|
|
356
|
-
if (!input.trim() || !isLoaded) {
|
|
357
|
-
setOptions([]);
|
|
358
|
-
setLoading(false);
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
// Use mock data if API is not available
|
|
363
|
-
if (useMockData) {
|
|
364
|
-
// Simulate realistic but fast API delay for testing
|
|
365
|
-
setTimeout(() => {
|
|
366
|
-
setLoading(false);
|
|
367
|
-
const searchTerm = input.toLowerCase().trim();
|
|
368
|
-
|
|
369
|
-
// More sophisticated search logic that matches Google Maps behavior
|
|
370
|
-
const filtered = MOCK_ADDRESSES.filter(addr => {
|
|
371
|
-
const description = addr.description.toLowerCase();
|
|
372
|
-
const mainText = addr.structured_formatting.main_text.toLowerCase();
|
|
373
|
-
const secondaryText = addr.structured_formatting.secondary_text?.toLowerCase() || '';
|
|
374
|
-
|
|
375
|
-
// Match against street number, street name, city, or state
|
|
376
|
-
const searchWords = searchTerm.split(' ');
|
|
377
|
-
return searchWords.every(word =>
|
|
378
|
-
description.includes(word) ||
|
|
379
|
-
mainText.includes(word) ||
|
|
380
|
-
secondaryText.includes(word)
|
|
381
|
-
);
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
// Sort by relevance (exact matches first, then partial matches)
|
|
385
|
-
const sorted = filtered.sort((a, b) => {
|
|
386
|
-
const aMain = a.structured_formatting.main_text.toLowerCase();
|
|
387
|
-
const bMain = b.structured_formatting.main_text.toLowerCase();
|
|
388
|
-
|
|
389
|
-
if (aMain.startsWith(searchTerm) && !bMain.startsWith(searchTerm)) return -1;
|
|
390
|
-
if (!aMain.startsWith(searchTerm) && bMain.startsWith(searchTerm)) return 1;
|
|
391
|
-
return aMain.localeCompare(bMain);
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
setOptions(sorted.length > 0 ? sorted : []);
|
|
395
|
-
setApiError(null);
|
|
396
|
-
}, 100); // Optimized for testing while still realistic
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
if (!services.autocompleteService) {
|
|
401
|
-
setOptions([]);
|
|
402
|
-
setLoading(false);
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
const request: google.maps.places.AutocompletionRequest = {
|
|
407
|
-
input: input.trim(),
|
|
408
|
-
componentRestrictions: restrictions?.country ? { country: restrictions.country } : undefined,
|
|
409
|
-
types: restrictions?.types || [],
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
services.autocompleteService.getPlacePredictions(
|
|
413
|
-
request,
|
|
414
|
-
(predictions, status) => {
|
|
415
|
-
setLoading(false);
|
|
416
|
-
|
|
417
|
-
if (status === google.maps.places.PlacesServiceStatus.OK && predictions) {
|
|
418
|
-
setOptions(predictions);
|
|
419
|
-
setApiError(null);
|
|
420
|
-
} else if (status === google.maps.places.PlacesServiceStatus.ZERO_RESULTS) {
|
|
421
|
-
setOptions([]);
|
|
422
|
-
setApiError(null);
|
|
423
|
-
} else {
|
|
424
|
-
setOptions([]);
|
|
425
|
-
setApiError('Failed to fetch address suggestions');
|
|
426
|
-
}
|
|
427
|
-
},
|
|
428
|
-
);
|
|
429
|
-
}, 300);
|
|
430
|
-
},
|
|
431
|
-
[services, isLoaded, restrictions, useMockData],
|
|
432
|
-
);
|
|
433
|
-
|
|
434
|
-
const handleInputChange = (event: React.SyntheticEvent, value: string) => {
|
|
435
|
-
setInputValue(value);
|
|
436
|
-
setApiError(null);
|
|
437
|
-
|
|
438
|
-
if (value.length > 2) {
|
|
439
|
-
setLoading(true);
|
|
440
|
-
debouncedAutocomplete(value);
|
|
441
|
-
} else {
|
|
442
|
-
setOptions([]);
|
|
443
|
-
setLoading(false);
|
|
444
|
-
}
|
|
445
|
-
};
|
|
446
|
-
|
|
447
|
-
const handleSelect = useCallback(
|
|
448
|
-
(event: React.SyntheticEvent, value: string | google.maps.places.AutocompletePrediction | MockPrediction | null) => {
|
|
449
|
-
// Handle string values (freeSolo mode)
|
|
450
|
-
if (typeof value === 'string') {
|
|
451
|
-
const addressDetails: AddressDetails = {
|
|
452
|
-
formatted: value,
|
|
453
|
-
street: '',
|
|
454
|
-
city: '',
|
|
455
|
-
state: '',
|
|
456
|
-
country: '',
|
|
457
|
-
postalCode: '',
|
|
458
|
-
coordinates: { lat: 0, lng: 0 },
|
|
459
|
-
};
|
|
460
|
-
onSelect(addressDetails);
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
if (!value) return;
|
|
465
|
-
|
|
466
|
-
setLoading(true);
|
|
467
|
-
|
|
468
|
-
// Use mock data if API is not available
|
|
469
|
-
if (useMockData && 'place_id' in value) {
|
|
470
|
-
setTimeout(() => {
|
|
471
|
-
setLoading(false);
|
|
472
|
-
const place = MOCK_PLACE_DETAILS[value.place_id];
|
|
473
|
-
if (place) {
|
|
474
|
-
const addressComponents = place.address_components || [];
|
|
475
|
-
|
|
476
|
-
const getComponent = (type: string) => {
|
|
477
|
-
const component = addressComponents.find((c) => c.types.includes(type));
|
|
478
|
-
return component?.long_name || '';
|
|
479
|
-
};
|
|
480
|
-
|
|
481
|
-
const street = `${getComponent('street_number')} ${getComponent('route')}`.trim();
|
|
482
|
-
|
|
483
|
-
const addressDetails: AddressDetails = {
|
|
484
|
-
formatted: place.formatted_address || value.description,
|
|
485
|
-
street: street || getComponent('route'),
|
|
486
|
-
city: getComponent('locality') || getComponent('administrative_area_level_2'),
|
|
487
|
-
state: getComponent('administrative_area_level_1'),
|
|
488
|
-
country: getComponent('country'),
|
|
489
|
-
postalCode: getComponent('postal_code'),
|
|
490
|
-
coordinates: {
|
|
491
|
-
lat: place.geometry?.location?.lat() || 0,
|
|
492
|
-
lng: place.geometry?.location?.lng() || 0,
|
|
493
|
-
},
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
onSelect(addressDetails);
|
|
497
|
-
setInputValue(addressDetails.formatted);
|
|
498
|
-
} else {
|
|
499
|
-
setApiError('Address details not found');
|
|
500
|
-
}
|
|
501
|
-
}, 50); // Optimized for testing
|
|
502
|
-
return;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
if (!services.placesService) {
|
|
506
|
-
setLoading(false);
|
|
507
|
-
return;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
// Get place details from real API
|
|
511
|
-
const request: google.maps.places.PlaceDetailsRequest = {
|
|
512
|
-
placeId: value.place_id,
|
|
513
|
-
fields: ['formatted_address', 'address_components', 'geometry'],
|
|
514
|
-
};
|
|
515
|
-
|
|
516
|
-
services.placesService.getDetails(request, (place, status) => {
|
|
517
|
-
setLoading(false);
|
|
518
|
-
|
|
519
|
-
if (status === google.maps.places.PlacesServiceStatus.OK && place) {
|
|
520
|
-
const addressComponents = place.address_components || [];
|
|
521
|
-
|
|
522
|
-
const getComponent = (type: string) => {
|
|
523
|
-
const component = addressComponents.find(c => c.types.includes(type));
|
|
524
|
-
return component?.long_name || '';
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
const street = `${getComponent('street_number')} ${getComponent('route')}`.trim();
|
|
528
|
-
|
|
529
|
-
const addressDetails: AddressDetails = {
|
|
530
|
-
formatted: place.formatted_address || value.description,
|
|
531
|
-
street: street || getComponent('route'),
|
|
532
|
-
city: getComponent('locality') || getComponent('administrative_area_level_2'),
|
|
533
|
-
state: getComponent('administrative_area_level_1'),
|
|
534
|
-
country: getComponent('country'),
|
|
535
|
-
postalCode: getComponent('postal_code'),
|
|
536
|
-
coordinates: {
|
|
537
|
-
lat: place.geometry?.location?.lat() || 0,
|
|
538
|
-
lng: place.geometry?.location?.lng() || 0,
|
|
539
|
-
},
|
|
540
|
-
};
|
|
541
|
-
|
|
542
|
-
onSelect(addressDetails);
|
|
543
|
-
setInputValue(addressDetails.formatted);
|
|
544
|
-
} else {
|
|
545
|
-
setApiError('Failed to get address details');
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
},
|
|
549
|
-
[services, onSelect, useMockData],
|
|
550
|
-
);
|
|
551
|
-
|
|
552
|
-
const handleGetCurrentLocation = useCallback(() => {
|
|
553
|
-
if (!navigator.geolocation) {
|
|
554
|
-
setApiError('Geolocation is not supported by this browser');
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
// Use mock location if in mock mode
|
|
559
|
-
if (useMockData) {
|
|
560
|
-
setLoading(true);
|
|
561
|
-
setTimeout(() => {
|
|
562
|
-
setLoading(false);
|
|
563
|
-
const mockLocation = MOCK_ADDRESSES[0];
|
|
564
|
-
if (!mockLocation) {
|
|
565
|
-
setApiError('No mock location available');
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
568
|
-
const mockDetails = MOCK_PLACE_DETAILS[mockLocation.place_id];
|
|
569
|
-
if (!mockDetails) {
|
|
570
|
-
setApiError('Mock location details not found');
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
const addressComponents = mockDetails.address_components || [];
|
|
575
|
-
const getComponent = (type: string) => {
|
|
576
|
-
const component = addressComponents.find((c) => c.types.includes(type));
|
|
577
|
-
return component?.long_name || '';
|
|
578
|
-
};
|
|
579
|
-
|
|
580
|
-
const street = `${getComponent('street_number')} ${getComponent('route')}`.trim();
|
|
581
|
-
|
|
582
|
-
const addressDetails: AddressDetails = {
|
|
583
|
-
formatted: mockDetails.formatted_address,
|
|
584
|
-
street: street || getComponent('route'),
|
|
585
|
-
city: getComponent('locality') || getComponent('administrative_area_level_2'),
|
|
586
|
-
state: getComponent('administrative_area_level_1'),
|
|
587
|
-
country: getComponent('country'),
|
|
588
|
-
postalCode: getComponent('postal_code'),
|
|
589
|
-
coordinates: {
|
|
590
|
-
lat: mockDetails.geometry.location.lat(),
|
|
591
|
-
lng: mockDetails.geometry.location.lng()
|
|
592
|
-
},
|
|
593
|
-
};
|
|
594
|
-
|
|
595
|
-
onSelect(addressDetails);
|
|
596
|
-
setInputValue(addressDetails.formatted);
|
|
597
|
-
}, 500); // Simulate geolocation delay
|
|
598
|
-
return;
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
if (!services.geocoder) {
|
|
602
|
-
setApiError('Geocoding service not available');
|
|
603
|
-
return;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
setLoading(true);
|
|
607
|
-
navigator.geolocation.getCurrentPosition(
|
|
608
|
-
(position) => {
|
|
609
|
-
const { latitude, longitude } = position.coords;
|
|
610
|
-
const latLng = new google.maps.LatLng(latitude, longitude);
|
|
611
|
-
|
|
612
|
-
services.geocoder!.geocode({ location: latLng }, (results, status) => {
|
|
613
|
-
setLoading(false);
|
|
614
|
-
|
|
615
|
-
if (status === 'OK' && results && results[0]) {
|
|
616
|
-
const place = results[0];
|
|
617
|
-
const addressComponents = place.address_components || [];
|
|
618
|
-
|
|
619
|
-
const getComponent = (type: string) => {
|
|
620
|
-
const component = addressComponents.find(c => c.types.includes(type));
|
|
621
|
-
return component?.long_name || '';
|
|
622
|
-
};
|
|
623
|
-
|
|
624
|
-
const street = `${getComponent('street_number')} ${getComponent('route')}`.trim();
|
|
625
|
-
|
|
626
|
-
const addressDetails: AddressDetails = {
|
|
627
|
-
formatted: place.formatted_address,
|
|
628
|
-
street: street || getComponent('route'),
|
|
629
|
-
city: getComponent('locality') || getComponent('administrative_area_level_2'),
|
|
630
|
-
state: getComponent('administrative_area_level_1'),
|
|
631
|
-
country: getComponent('country'),
|
|
632
|
-
postalCode: getComponent('postal_code'),
|
|
633
|
-
coordinates: { lat: latitude, lng: longitude },
|
|
634
|
-
};
|
|
635
|
-
|
|
636
|
-
onSelect(addressDetails);
|
|
637
|
-
setInputValue(addressDetails.formatted);
|
|
638
|
-
} else {
|
|
639
|
-
setApiError('Unable to retrieve address for current location');
|
|
640
|
-
}
|
|
641
|
-
});
|
|
642
|
-
},
|
|
643
|
-
() => {
|
|
644
|
-
setLoading(false);
|
|
645
|
-
setApiError('Unable to retrieve your location');
|
|
646
|
-
},
|
|
647
|
-
{
|
|
648
|
-
enableHighAccuracy: true,
|
|
649
|
-
timeout: 10000,
|
|
650
|
-
maximumAge: 600000, // 10 minutes
|
|
651
|
-
}
|
|
652
|
-
);
|
|
653
|
-
}, [services, onSelect, useMockData]);
|
|
654
|
-
|
|
655
|
-
// Cleanup debounce on unmount
|
|
656
|
-
useEffect(() => () => {
|
|
657
|
-
if (debounceTimeoutRef.current) {
|
|
658
|
-
clearTimeout(debounceTimeoutRef.current);
|
|
659
|
-
}
|
|
660
|
-
}, []);
|
|
661
|
-
|
|
662
|
-
const TextFieldComponent = variant === 'glass' ? GlassTextField : TextField;
|
|
663
|
-
const displayError = error || !!mapsError || !!apiError;
|
|
664
|
-
const displayHelperText = apiError || mapsError || helperText;
|
|
665
|
-
|
|
666
|
-
// Show loading state if API is not ready
|
|
667
|
-
if (!isLoaded && !mapsError) {
|
|
668
|
-
return (
|
|
669
|
-
<TextFieldComponent
|
|
670
|
-
variant={variant === 'glass' ? 'outlined' : variant}
|
|
671
|
-
label={floating ? undefined : label}
|
|
672
|
-
placeholder="Loading Google Maps..."
|
|
673
|
-
disabled
|
|
674
|
-
fullWidth={fullWidth}
|
|
675
|
-
InputProps={{
|
|
676
|
-
startAdornment: icon && <InputAdornment position="start">{icon}</InputAdornment>,
|
|
677
|
-
endAdornment: <CircularProgress color="inherit" size={20} />,
|
|
678
|
-
}}
|
|
679
|
-
/>
|
|
680
|
-
);
|
|
24
|
+
// Until the API answers there is nothing to autocomplete against, so the field
|
|
25
|
+
// stands in disabled — spinning, or explaining why it never loaded.
|
|
26
|
+
if (!state.isLoaded || state.mapsError) {
|
|
27
|
+
return <AddressFallbackField {...fieldProps} mapsError={state.mapsError} />;
|
|
681
28
|
}
|
|
682
29
|
|
|
683
|
-
|
|
684
|
-
if (mapsError) {
|
|
685
|
-
return (
|
|
686
|
-
<Box>
|
|
687
|
-
<TextFieldComponent
|
|
688
|
-
variant={variant === 'glass' ? 'outlined' : variant}
|
|
689
|
-
label={floating ? undefined : label}
|
|
690
|
-
placeholder={placeholder}
|
|
691
|
-
error
|
|
692
|
-
disabled
|
|
693
|
-
fullWidth={fullWidth}
|
|
694
|
-
helperText={mapsError}
|
|
695
|
-
InputProps={{
|
|
696
|
-
startAdornment: icon && <InputAdornment position="start">{icon}</InputAdornment>,
|
|
697
|
-
}}
|
|
698
|
-
/>
|
|
699
|
-
<Alert severity="error" sx={{ mt: 1 }}>
|
|
700
|
-
Google Maps API failed to load. Please check your API key and internet connection.
|
|
701
|
-
</Alert>
|
|
702
|
-
</Box>
|
|
703
|
-
);
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
return (
|
|
707
|
-
<Box data-testid="address-autocomplete-container">
|
|
708
|
-
<Autocomplete
|
|
709
|
-
freeSolo
|
|
710
|
-
options={options}
|
|
711
|
-
inputValue={inputValue}
|
|
712
|
-
onInputChange={handleInputChange}
|
|
713
|
-
onChange={handleSelect}
|
|
714
|
-
loading={loading}
|
|
715
|
-
disabled={disabled || !isLoaded}
|
|
716
|
-
fullWidth={fullWidth}
|
|
717
|
-
getOptionLabel={(option) => {
|
|
718
|
-
if (typeof option === 'string') return option;
|
|
719
|
-
return option.description || '';
|
|
720
|
-
}}
|
|
721
|
-
isOptionEqualToValue={(option, value) => {
|
|
722
|
-
if (typeof option === 'string' && typeof value === 'string') {
|
|
723
|
-
return option === value;
|
|
724
|
-
}
|
|
725
|
-
if (typeof option === 'object' && typeof value === 'object' && option && value) {
|
|
726
|
-
return option.place_id === value.place_id;
|
|
727
|
-
}
|
|
728
|
-
return false;
|
|
729
|
-
}}
|
|
730
|
-
renderInput={(params) => (
|
|
731
|
-
<TextFieldComponent
|
|
732
|
-
{...params}
|
|
733
|
-
variant={variant === 'glass' ? 'outlined' : variant}
|
|
734
|
-
label={floating ? undefined : label}
|
|
735
|
-
placeholder={placeholder}
|
|
736
|
-
error={displayError}
|
|
737
|
-
helperText={displayHelperText}
|
|
738
|
-
required={required}
|
|
739
|
-
InputProps={{
|
|
740
|
-
...params.InputProps,
|
|
741
|
-
startAdornment: icon && <InputAdornment position="start">{icon}</InputAdornment>,
|
|
742
|
-
endAdornment: (
|
|
743
|
-
<>
|
|
744
|
-
{loading && <CircularProgress color="inherit" size={20} data-testid="address-loading" />}
|
|
745
|
-
{getCurrentLocation && !loading && isLoaded && (
|
|
746
|
-
<InputAdornment position="end">
|
|
747
|
-
<IconButton
|
|
748
|
-
edge="end"
|
|
749
|
-
onClick={handleGetCurrentLocation}
|
|
750
|
-
size="small"
|
|
751
|
-
title="Use current location"
|
|
752
|
-
disabled={disabled}
|
|
753
|
-
data-testid="address-current-location-button"
|
|
754
|
-
>
|
|
755
|
-
<CurrentLocationIcon />
|
|
756
|
-
</IconButton>
|
|
757
|
-
</InputAdornment>
|
|
758
|
-
)}
|
|
759
|
-
{params.InputProps.endAdornment}
|
|
760
|
-
</>
|
|
761
|
-
),
|
|
762
|
-
}}
|
|
763
|
-
inputProps={{
|
|
764
|
-
...params.inputProps,
|
|
765
|
-
'data-testid': 'address-input',
|
|
766
|
-
}}
|
|
767
|
-
/>
|
|
768
|
-
)}
|
|
769
|
-
renderOption={(props, option, state) => {
|
|
770
|
-
const { key, ...optionProps } = props;
|
|
771
|
-
|
|
772
|
-
// Handle string options
|
|
773
|
-
if (typeof option === 'string') {
|
|
774
|
-
return (
|
|
775
|
-
<li key={key} {...optionProps} data-testid={`address-suggestion-${state.index}`}>
|
|
776
|
-
<SuggestionItem>
|
|
777
|
-
<LocationIconWrapper>
|
|
778
|
-
<LocationIcon fontSize="small" />
|
|
779
|
-
</LocationIconWrapper>
|
|
780
|
-
<AddressText data-testid="address-suggestion-text">
|
|
781
|
-
<div className="primary">{option.split(',')[0]}</div>
|
|
782
|
-
<div className="secondary">{option.split(',').slice(1).join(',')}</div>
|
|
783
|
-
</AddressText>
|
|
784
|
-
</SuggestionItem>
|
|
785
|
-
</li>
|
|
786
|
-
);
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
// Handle Google Places AutocompletePrediction or MockPrediction objects
|
|
790
|
-
const prediction = option as google.maps.places.AutocompletePrediction | MockPrediction;
|
|
791
|
-
return (
|
|
792
|
-
<li key={key} {...optionProps} data-testid={`address-suggestion-${state.index}`}>
|
|
793
|
-
<SuggestionItem>
|
|
794
|
-
<LocationIconWrapper>
|
|
795
|
-
<LocationIcon fontSize="small" />
|
|
796
|
-
</LocationIconWrapper>
|
|
797
|
-
<AddressText data-testid="address-prediction-text">
|
|
798
|
-
<div className="primary">
|
|
799
|
-
{prediction.structured_formatting?.main_text || prediction.description?.split(',')[0]}
|
|
800
|
-
</div>
|
|
801
|
-
<div className="secondary">
|
|
802
|
-
{prediction.structured_formatting?.secondary_text ||
|
|
803
|
-
prediction.description?.split(',').slice(1).join(',')}
|
|
804
|
-
</div>
|
|
805
|
-
</AddressText>
|
|
806
|
-
</SuggestionItem>
|
|
807
|
-
</li>
|
|
808
|
-
);
|
|
809
|
-
}}
|
|
810
|
-
PaperComponent={(props) => (
|
|
811
|
-
<Paper
|
|
812
|
-
{...props}
|
|
813
|
-
elevation={8}
|
|
814
|
-
data-testid="address-suggestions-dropdown"
|
|
815
|
-
sx={{
|
|
816
|
-
mt: 1,
|
|
817
|
-
background: `linear-gradient(135deg, ${alpha(theme.palette.background.paper, 0.98)} 0%, ${alpha(theme.palette.background.paper, 0.95)} 100%)`,
|
|
818
|
-
backdropFilter: 'blur(20px)',
|
|
819
|
-
WebkitBackdropFilter: 'blur(20px)',
|
|
820
|
-
border: `1px solid ${alpha(theme.palette.divider, 0.18)}`,
|
|
821
|
-
}}
|
|
822
|
-
/>
|
|
823
|
-
)}
|
|
824
|
-
noOptionsText={inputValue.length <= 2 ? 'Type at least 3 characters' : 'No addresses found'}
|
|
825
|
-
/>
|
|
826
|
-
{apiError && (
|
|
827
|
-
<Alert severity="warning" sx={{ mt: 1 }}>
|
|
828
|
-
{apiError}
|
|
829
|
-
</Alert>
|
|
830
|
-
)}
|
|
831
|
-
</Box>
|
|
832
|
-
);
|
|
30
|
+
return <AddressAutocompleteField {...fieldProps} {...state} />;
|
|
833
31
|
};
|
|
834
32
|
|
|
835
|
-
// Export default
|
|
836
33
|
export default AddressAutocomplete;
|