@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,7 +1,18 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
+
import type { MockPrediction } from './mockPlaces';
|
|
4
|
+
|
|
3
5
|
/// <reference types="@types/google.maps" />
|
|
4
6
|
|
|
7
|
+
// What the Autocomplete holds: a live prediction, a canned one, or — in freeSolo
|
|
8
|
+
// mode — the raw text.
|
|
9
|
+
export type AddressOptionValue =
|
|
10
|
+
| string
|
|
11
|
+
| google.maps.places.AutocompletePrediction
|
|
12
|
+
| MockPrediction;
|
|
13
|
+
|
|
14
|
+
export type AddressPrediction = google.maps.places.AutocompletePrediction | MockPrediction;
|
|
15
|
+
|
|
5
16
|
export interface AddressDetails {
|
|
6
17
|
formatted: string;
|
|
7
18
|
street: string;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Alert, Autocomplete, Box } from '@mui/material';
|
|
2
|
+
import type { FC } from 'react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
addressOptionLabel,
|
|
7
|
+
isSameAddressOption,
|
|
8
|
+
MIN_QUERY_LENGTH,
|
|
9
|
+
type ResolvedAddressProps,
|
|
10
|
+
} from './AddressAutocomplete.helpers';
|
|
11
|
+
import type { AddressAutocompleteState } from './AddressAutocomplete.hooks';
|
|
12
|
+
import { AddressInputField } from './AddressInputField';
|
|
13
|
+
import { AddressOption } from './AddressOption';
|
|
14
|
+
import { AddressSuggestionsPaper } from './AddressSuggestionsPaper';
|
|
15
|
+
|
|
16
|
+
export type AddressAutocompleteFieldProps = ResolvedAddressProps & AddressAutocompleteState;
|
|
17
|
+
|
|
18
|
+
// The live field, rendered once Google Maps (or the mock stand-in) is ready.
|
|
19
|
+
export const AddressAutocompleteField: FC<AddressAutocompleteFieldProps> = ({
|
|
20
|
+
variant,
|
|
21
|
+
label,
|
|
22
|
+
placeholder,
|
|
23
|
+
icon,
|
|
24
|
+
floating,
|
|
25
|
+
error,
|
|
26
|
+
helperText,
|
|
27
|
+
disabled,
|
|
28
|
+
required,
|
|
29
|
+
fullWidth,
|
|
30
|
+
getCurrentLocation,
|
|
31
|
+
inputValue,
|
|
32
|
+
options,
|
|
33
|
+
loading,
|
|
34
|
+
apiError,
|
|
35
|
+
handleInputChange,
|
|
36
|
+
handleSelect,
|
|
37
|
+
handleGetCurrentLocation,
|
|
38
|
+
}) => (
|
|
39
|
+
<Box data-testid="address-autocomplete-container">
|
|
40
|
+
<Autocomplete
|
|
41
|
+
freeSolo
|
|
42
|
+
options={options}
|
|
43
|
+
inputValue={inputValue}
|
|
44
|
+
onInputChange={handleInputChange}
|
|
45
|
+
onChange={handleSelect}
|
|
46
|
+
loading={loading}
|
|
47
|
+
disabled={disabled}
|
|
48
|
+
fullWidth={fullWidth}
|
|
49
|
+
getOptionLabel={addressOptionLabel}
|
|
50
|
+
isOptionEqualToValue={isSameAddressOption}
|
|
51
|
+
PaperComponent={AddressSuggestionsPaper}
|
|
52
|
+
noOptionsText={
|
|
53
|
+
inputValue.length <= MIN_QUERY_LENGTH ? 'Type at least 3 characters' : 'No addresses found'
|
|
54
|
+
}
|
|
55
|
+
renderOption={({ key, ...optionProps }, option, state) => (
|
|
56
|
+
<AddressOption
|
|
57
|
+
key={key}
|
|
58
|
+
optionProps={optionProps}
|
|
59
|
+
option={option}
|
|
60
|
+
index={state.index}
|
|
61
|
+
/>
|
|
62
|
+
)}
|
|
63
|
+
renderInput={(params) => (
|
|
64
|
+
<AddressInputField
|
|
65
|
+
params={params}
|
|
66
|
+
addressVariant={variant}
|
|
67
|
+
label={floating ? undefined : label}
|
|
68
|
+
placeholder={placeholder}
|
|
69
|
+
icon={icon}
|
|
70
|
+
error={error || !!apiError}
|
|
71
|
+
helperText={apiError || helperText}
|
|
72
|
+
required={required}
|
|
73
|
+
disabled={disabled}
|
|
74
|
+
loading={loading}
|
|
75
|
+
showCurrentLocation={getCurrentLocation && !loading}
|
|
76
|
+
onGetCurrentLocation={handleGetCurrentLocation}
|
|
77
|
+
/>
|
|
78
|
+
)}
|
|
79
|
+
/>
|
|
80
|
+
{apiError && (
|
|
81
|
+
<Alert severity="warning" sx={{ mt: 1 }}>
|
|
82
|
+
{apiError}
|
|
83
|
+
</Alert>
|
|
84
|
+
)}
|
|
85
|
+
</Box>
|
|
86
|
+
);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Alert, Box, CircularProgress, InputAdornment } from '@mui/material';
|
|
2
|
+
import type { FC, ReactNode } from 'react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import type { AddressAutocompleteProps } from './AddressAutocomplete.types';
|
|
6
|
+
import { AddressTextField } from './AddressTextField';
|
|
7
|
+
|
|
8
|
+
export interface AddressFallbackFieldProps {
|
|
9
|
+
variant: AddressAutocompleteProps['variant'];
|
|
10
|
+
label?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
icon?: ReactNode;
|
|
13
|
+
floating: boolean;
|
|
14
|
+
fullWidth: boolean;
|
|
15
|
+
mapsError: string | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Stands in for the Autocomplete before Google Maps is usable: a disabled field
|
|
19
|
+
// that either spins or explains why it never loaded.
|
|
20
|
+
export const AddressFallbackField: FC<AddressFallbackFieldProps> = ({
|
|
21
|
+
variant,
|
|
22
|
+
label,
|
|
23
|
+
placeholder,
|
|
24
|
+
icon,
|
|
25
|
+
floating,
|
|
26
|
+
fullWidth,
|
|
27
|
+
mapsError,
|
|
28
|
+
}) => {
|
|
29
|
+
const startAdornment = icon ? <InputAdornment position="start">{icon}</InputAdornment> : undefined;
|
|
30
|
+
|
|
31
|
+
if (!mapsError) {
|
|
32
|
+
return (
|
|
33
|
+
<AddressTextField
|
|
34
|
+
addressVariant={variant}
|
|
35
|
+
label={floating ? undefined : label}
|
|
36
|
+
placeholder="Loading Google Maps..."
|
|
37
|
+
disabled
|
|
38
|
+
fullWidth={fullWidth}
|
|
39
|
+
InputProps={{
|
|
40
|
+
startAdornment,
|
|
41
|
+
endAdornment: <CircularProgress color="inherit" size={20} />,
|
|
42
|
+
}}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Box>
|
|
49
|
+
<AddressTextField
|
|
50
|
+
addressVariant={variant}
|
|
51
|
+
label={floating ? undefined : label}
|
|
52
|
+
placeholder={placeholder}
|
|
53
|
+
error
|
|
54
|
+
disabled
|
|
55
|
+
fullWidth={fullWidth}
|
|
56
|
+
helperText={mapsError}
|
|
57
|
+
InputProps={{ startAdornment }}
|
|
58
|
+
/>
|
|
59
|
+
<Alert severity="error" sx={{ mt: 1 }}>
|
|
60
|
+
Google Maps API failed to load. Please check your API key and internet connection.
|
|
61
|
+
</Alert>
|
|
62
|
+
</Box>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import CurrentLocationIcon from '@mui/icons-material/MyLocation';
|
|
2
|
+
import type { AutocompleteRenderInputParams } from '@mui/material';
|
|
3
|
+
import { CircularProgress, IconButton, InputAdornment } from '@mui/material';
|
|
4
|
+
import type { FC, ReactNode } from 'react';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import type { AddressAutocompleteProps } from './AddressAutocomplete.types';
|
|
8
|
+
import { AddressTextField } from './AddressTextField';
|
|
9
|
+
|
|
10
|
+
const CurrentLocationButton: FC<{ disabled: boolean; onClick: () => void }> = ({
|
|
11
|
+
disabled,
|
|
12
|
+
onClick,
|
|
13
|
+
}) => (
|
|
14
|
+
<InputAdornment position="end">
|
|
15
|
+
<IconButton
|
|
16
|
+
edge="end"
|
|
17
|
+
onClick={onClick}
|
|
18
|
+
size="small"
|
|
19
|
+
title="Use current location"
|
|
20
|
+
disabled={disabled}
|
|
21
|
+
data-testid="address-current-location-button"
|
|
22
|
+
>
|
|
23
|
+
<CurrentLocationIcon />
|
|
24
|
+
</IconButton>
|
|
25
|
+
</InputAdornment>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export interface AddressInputFieldProps {
|
|
29
|
+
params: AutocompleteRenderInputParams;
|
|
30
|
+
addressVariant: AddressAutocompleteProps['variant'];
|
|
31
|
+
label?: string;
|
|
32
|
+
placeholder?: string;
|
|
33
|
+
icon?: ReactNode;
|
|
34
|
+
error: boolean;
|
|
35
|
+
helperText?: string;
|
|
36
|
+
required: boolean;
|
|
37
|
+
disabled: boolean;
|
|
38
|
+
loading: boolean;
|
|
39
|
+
showCurrentLocation: boolean;
|
|
40
|
+
onGetCurrentLocation: () => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const AddressInputField: FC<AddressInputFieldProps> = ({
|
|
44
|
+
params,
|
|
45
|
+
addressVariant,
|
|
46
|
+
label,
|
|
47
|
+
placeholder,
|
|
48
|
+
icon,
|
|
49
|
+
error,
|
|
50
|
+
helperText,
|
|
51
|
+
required,
|
|
52
|
+
disabled,
|
|
53
|
+
loading,
|
|
54
|
+
showCurrentLocation,
|
|
55
|
+
onGetCurrentLocation,
|
|
56
|
+
}) => (
|
|
57
|
+
<AddressTextField
|
|
58
|
+
{...params}
|
|
59
|
+
addressVariant={addressVariant}
|
|
60
|
+
label={label}
|
|
61
|
+
placeholder={placeholder}
|
|
62
|
+
error={error}
|
|
63
|
+
helperText={helperText}
|
|
64
|
+
required={required}
|
|
65
|
+
InputProps={{
|
|
66
|
+
...params.InputProps,
|
|
67
|
+
startAdornment: icon && <InputAdornment position="start">{icon}</InputAdornment>,
|
|
68
|
+
endAdornment: (
|
|
69
|
+
<>
|
|
70
|
+
{loading && <CircularProgress color="inherit" size={20} data-testid="address-loading" />}
|
|
71
|
+
{showCurrentLocation && (
|
|
72
|
+
<CurrentLocationButton disabled={disabled} onClick={onGetCurrentLocation} />
|
|
73
|
+
)}
|
|
74
|
+
{params.InputProps.endAdornment}
|
|
75
|
+
</>
|
|
76
|
+
),
|
|
77
|
+
}}
|
|
78
|
+
inputProps={{ ...params.inputProps, 'data-testid': 'address-input' }}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import LocationIcon from '@mui/icons-material/LocationOn';
|
|
2
|
+
import { alpha, Box, styled } from '@mui/material';
|
|
3
|
+
import type { FC, HTMLAttributes } from 'react';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import type { AddressOptionValue } from './AddressAutocomplete.types';
|
|
7
|
+
|
|
8
|
+
// Module-local: styled() components cannot be exported across a module boundary
|
|
9
|
+
// here without tripping TS2742.
|
|
10
|
+
const SuggestionItem = styled(Box)(({ theme }) => ({
|
|
11
|
+
padding: theme.spacing(1.5),
|
|
12
|
+
display: 'flex',
|
|
13
|
+
alignItems: 'flex-start',
|
|
14
|
+
gap: theme.spacing(1.5),
|
|
15
|
+
cursor: 'pointer',
|
|
16
|
+
transition: theme.transitions.create(['background-color']),
|
|
17
|
+
'&:hover': {
|
|
18
|
+
backgroundColor: alpha(theme.palette.primary.main, 0.08),
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
const LocationIconWrapper = styled(Box)(({ theme }) => ({
|
|
23
|
+
marginTop: theme.spacing(0.5),
|
|
24
|
+
color: theme.palette.text.secondary,
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
const AddressText = styled(Box)(({ theme }) => ({
|
|
28
|
+
flex: 1,
|
|
29
|
+
'& .primary': {
|
|
30
|
+
fontSize: '0.9rem',
|
|
31
|
+
fontWeight: 500,
|
|
32
|
+
color: theme.palette.text.primary,
|
|
33
|
+
marginBottom: theme.spacing(0.25),
|
|
34
|
+
},
|
|
35
|
+
'& .secondary': {
|
|
36
|
+
fontSize: '0.8rem',
|
|
37
|
+
color: theme.palette.text.secondary,
|
|
38
|
+
},
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
// Predictions carry the street line and the rest already split; freeSolo text has
|
|
42
|
+
// to be split on the first comma to get the same two lines.
|
|
43
|
+
const optionText = (option: AddressOptionValue) => {
|
|
44
|
+
if (typeof option === 'string') {
|
|
45
|
+
return {
|
|
46
|
+
testId: 'address-suggestion-text',
|
|
47
|
+
primary: option.split(',')[0],
|
|
48
|
+
secondary: option.split(',').slice(1).join(','),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
testId: 'address-prediction-text',
|
|
54
|
+
primary: option.structured_formatting?.main_text || option.description?.split(',')[0],
|
|
55
|
+
secondary:
|
|
56
|
+
option.structured_formatting?.secondary_text ||
|
|
57
|
+
option.description?.split(',').slice(1).join(','),
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export interface AddressOptionProps {
|
|
62
|
+
optionProps: HTMLAttributes<HTMLLIElement>;
|
|
63
|
+
option: AddressOptionValue;
|
|
64
|
+
index: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const AddressOption: FC<AddressOptionProps> = ({ optionProps, option, index }) => {
|
|
68
|
+
const { testId, primary, secondary } = optionText(option);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<li {...optionProps} data-testid={`address-suggestion-${index}`}>
|
|
72
|
+
<SuggestionItem>
|
|
73
|
+
<LocationIconWrapper>
|
|
74
|
+
<LocationIcon fontSize="small" />
|
|
75
|
+
</LocationIconWrapper>
|
|
76
|
+
<AddressText data-testid={testId}>
|
|
77
|
+
<div className="primary">{primary}</div>
|
|
78
|
+
<div className="secondary">{secondary}</div>
|
|
79
|
+
</AddressText>
|
|
80
|
+
</SuggestionItem>
|
|
81
|
+
</li>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PaperProps } from '@mui/material';
|
|
2
|
+
import { alpha, Paper, useTheme } from '@mui/material';
|
|
3
|
+
import type { FC } from 'react';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
// The dropdown surface, frosted to match the glass field.
|
|
7
|
+
export const AddressSuggestionsPaper: FC<PaperProps> = (props) => {
|
|
8
|
+
const theme = useTheme();
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<Paper
|
|
12
|
+
{...props}
|
|
13
|
+
elevation={8}
|
|
14
|
+
data-testid="address-suggestions-dropdown"
|
|
15
|
+
sx={{
|
|
16
|
+
mt: 1,
|
|
17
|
+
background: `linear-gradient(135deg, ${alpha(theme.palette.background.paper, 0.98)} 0%, ${alpha(theme.palette.background.paper, 0.95)} 100%)`,
|
|
18
|
+
backdropFilter: 'blur(20px)',
|
|
19
|
+
WebkitBackdropFilter: 'blur(20px)',
|
|
20
|
+
border: `1px solid ${alpha(theme.palette.divider, 0.18)}`,
|
|
21
|
+
}}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TextFieldProps } from '@mui/material';
|
|
2
|
+
import { alpha, styled, TextField } from '@mui/material';
|
|
3
|
+
import type { FC } from 'react';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import type { AddressAutocompleteProps } from './AddressAutocomplete.types';
|
|
7
|
+
|
|
8
|
+
// Kept module-local on purpose: the inferred type of a styled() component cannot
|
|
9
|
+
// be named across a module boundary here (TS2742), so the plain component below
|
|
10
|
+
// is what the rest of the folder imports.
|
|
11
|
+
const GlassTextField = styled(TextField)(({ theme }) => ({
|
|
12
|
+
'& .MuiOutlinedInput-root': {
|
|
13
|
+
background: `linear-gradient(135deg, ${alpha(theme.palette.background.paper, 0.8)} 0%, ${alpha(theme.palette.background.paper, 0.6)} 100%)`,
|
|
14
|
+
backdropFilter: 'blur(10px)',
|
|
15
|
+
WebkitBackdropFilter: 'blur(10px)',
|
|
16
|
+
border: `1px solid ${alpha(theme.palette.divider, 0.18)}`,
|
|
17
|
+
transition: theme.transitions.create(['border-color', 'box-shadow', 'background']),
|
|
18
|
+
'&:hover': {
|
|
19
|
+
background: `linear-gradient(135deg, ${alpha(theme.palette.background.paper, 0.9)} 0%, ${alpha(theme.palette.background.paper, 0.7)} 100%)`,
|
|
20
|
+
borderColor: theme.palette.primary.main,
|
|
21
|
+
},
|
|
22
|
+
'&.Mui-focused': {
|
|
23
|
+
background: theme.palette.background.paper,
|
|
24
|
+
boxShadow: `0 0 0 2px ${alpha(theme.palette.primary.main, 0.25)}`,
|
|
25
|
+
},
|
|
26
|
+
'& fieldset': {
|
|
27
|
+
border: 'none',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
export type AddressTextFieldProps = Omit<TextFieldProps, 'variant'> & {
|
|
33
|
+
addressVariant: AddressAutocompleteProps['variant'];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// 'glass' is not a MUI variant: it renders the outlined field with the frosted
|
|
37
|
+
// treatment on top.
|
|
38
|
+
export const AddressTextField: FC<AddressTextFieldProps> = ({ addressVariant, ...props }) =>
|
|
39
|
+
addressVariant === 'glass' ? (
|
|
40
|
+
<GlassTextField variant="outlined" {...props} />
|
|
41
|
+
) : (
|
|
42
|
+
<TextField variant={addressVariant} {...props} />
|
|
43
|
+
);
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
export interface MockPrediction {
|
|
2
|
+
place_id: string;
|
|
3
|
+
description: string;
|
|
4
|
+
structured_formatting: {
|
|
5
|
+
main_text: string;
|
|
6
|
+
secondary_text: string;
|
|
7
|
+
};
|
|
8
|
+
matched_substrings?: google.maps.places.PredictionSubstring[];
|
|
9
|
+
terms?: google.maps.places.PredictionTerm[];
|
|
10
|
+
types?: string[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Canned Places data so the component renders and is testable without a Google
|
|
14
|
+
// Maps key.
|
|
15
|
+
export const MOCK_ADDRESSES: MockPrediction[] = [
|
|
16
|
+
{
|
|
17
|
+
place_id: 'mock_1',
|
|
18
|
+
description: '123 Main Street, San Francisco, CA 94105, USA',
|
|
19
|
+
structured_formatting: {
|
|
20
|
+
main_text: '123 Main Street',
|
|
21
|
+
secondary_text: 'San Francisco, CA 94105, USA',
|
|
22
|
+
},
|
|
23
|
+
matched_substrings: [],
|
|
24
|
+
terms: [],
|
|
25
|
+
types: ['street_address'],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
place_id: 'mock_2',
|
|
29
|
+
description: '456 Oak Avenue, New York, NY 10001, USA',
|
|
30
|
+
structured_formatting: {
|
|
31
|
+
main_text: '456 Oak Avenue',
|
|
32
|
+
secondary_text: 'New York, NY 10001, USA',
|
|
33
|
+
},
|
|
34
|
+
matched_substrings: [],
|
|
35
|
+
terms: [],
|
|
36
|
+
types: ['street_address'],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
place_id: 'mock_3',
|
|
40
|
+
description: '789 Pine Boulevard, Los Angeles, CA 90001, USA',
|
|
41
|
+
structured_formatting: {
|
|
42
|
+
main_text: '789 Pine Boulevard',
|
|
43
|
+
secondary_text: 'Los Angeles, CA 90001, USA',
|
|
44
|
+
},
|
|
45
|
+
matched_substrings: [],
|
|
46
|
+
terms: [],
|
|
47
|
+
types: ['street_address'],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
place_id: 'mock_4',
|
|
51
|
+
description: '321 Elm Street, Chicago, IL 60601, USA',
|
|
52
|
+
structured_formatting: {
|
|
53
|
+
main_text: '321 Elm Street',
|
|
54
|
+
secondary_text: 'Chicago, IL 60601, USA',
|
|
55
|
+
},
|
|
56
|
+
matched_substrings: [],
|
|
57
|
+
terms: [],
|
|
58
|
+
types: ['street_address'],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
place_id: 'mock_5',
|
|
62
|
+
description: '654 Maple Drive, Austin, TX 78701, USA',
|
|
63
|
+
structured_formatting: {
|
|
64
|
+
main_text: '654 Maple Drive',
|
|
65
|
+
secondary_text: 'Austin, TX 78701, USA',
|
|
66
|
+
},
|
|
67
|
+
matched_substrings: [],
|
|
68
|
+
terms: [],
|
|
69
|
+
types: ['street_address'],
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
interface MockPlaceDetails {
|
|
74
|
+
formatted_address: string;
|
|
75
|
+
address_components: Array<{
|
|
76
|
+
long_name: string;
|
|
77
|
+
types: string[];
|
|
78
|
+
}>;
|
|
79
|
+
geometry: {
|
|
80
|
+
location: {
|
|
81
|
+
lat: () => number;
|
|
82
|
+
lng: () => number;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const MOCK_PLACE_DETAILS: Record<string, MockPlaceDetails> = {
|
|
88
|
+
mock_1: {
|
|
89
|
+
formatted_address: '123 Main Street, San Francisco, CA 94105, USA',
|
|
90
|
+
address_components: [
|
|
91
|
+
{ long_name: '123', types: ['street_number'] },
|
|
92
|
+
{ long_name: 'Main Street', types: ['route'] },
|
|
93
|
+
{ long_name: 'San Francisco', types: ['locality'] },
|
|
94
|
+
{ long_name: 'California', types: ['administrative_area_level_1'] },
|
|
95
|
+
{ long_name: 'United States', types: ['country'] },
|
|
96
|
+
{ long_name: '94105', types: ['postal_code'] },
|
|
97
|
+
],
|
|
98
|
+
geometry: { location: { lat: () => 37.7749, lng: () => -122.4194 } },
|
|
99
|
+
},
|
|
100
|
+
mock_2: {
|
|
101
|
+
formatted_address: '456 Oak Avenue, New York, NY 10001, USA',
|
|
102
|
+
address_components: [
|
|
103
|
+
{ long_name: '456', types: ['street_number'] },
|
|
104
|
+
{ long_name: 'Oak Avenue', types: ['route'] },
|
|
105
|
+
{ long_name: 'New York', types: ['locality'] },
|
|
106
|
+
{ long_name: 'New York', types: ['administrative_area_level_1'] },
|
|
107
|
+
{ long_name: 'United States', types: ['country'] },
|
|
108
|
+
{ long_name: '10001', types: ['postal_code'] },
|
|
109
|
+
],
|
|
110
|
+
geometry: { location: { lat: () => 40.7128, lng: () => -74.0060 } },
|
|
111
|
+
},
|
|
112
|
+
mock_3: {
|
|
113
|
+
formatted_address: '789 Pine Boulevard, Los Angeles, CA 90001, USA',
|
|
114
|
+
address_components: [
|
|
115
|
+
{ long_name: '789', types: ['street_number'] },
|
|
116
|
+
{ long_name: 'Pine Boulevard', types: ['route'] },
|
|
117
|
+
{ long_name: 'Los Angeles', types: ['locality'] },
|
|
118
|
+
{ long_name: 'California', types: ['administrative_area_level_1'] },
|
|
119
|
+
{ long_name: 'United States', types: ['country'] },
|
|
120
|
+
{ long_name: '90001', types: ['postal_code'] },
|
|
121
|
+
],
|
|
122
|
+
geometry: { location: { lat: () => 34.0522, lng: () => -118.2437 } },
|
|
123
|
+
},
|
|
124
|
+
mock_4: {
|
|
125
|
+
formatted_address: '321 Elm Street, Chicago, IL 60601, USA',
|
|
126
|
+
address_components: [
|
|
127
|
+
{ long_name: '321', types: ['street_number'] },
|
|
128
|
+
{ long_name: 'Elm Street', types: ['route'] },
|
|
129
|
+
{ long_name: 'Chicago', types: ['locality'] },
|
|
130
|
+
{ long_name: 'Illinois', types: ['administrative_area_level_1'] },
|
|
131
|
+
{ long_name: 'United States', types: ['country'] },
|
|
132
|
+
{ long_name: '60601', types: ['postal_code'] },
|
|
133
|
+
],
|
|
134
|
+
geometry: { location: { lat: () => 41.8781, lng: () => -87.6298 } },
|
|
135
|
+
},
|
|
136
|
+
mock_5: {
|
|
137
|
+
formatted_address: '654 Maple Drive, Austin, TX 78701, USA',
|
|
138
|
+
address_components: [
|
|
139
|
+
{ long_name: '654', types: ['street_number'] },
|
|
140
|
+
{ long_name: 'Maple Drive', types: ['route'] },
|
|
141
|
+
{ long_name: 'Austin', types: ['locality'] },
|
|
142
|
+
{ long_name: 'Texas', types: ['administrative_area_level_1'] },
|
|
143
|
+
{ long_name: 'United States', types: ['country'] },
|
|
144
|
+
{ long_name: '78701', types: ['postal_code'] },
|
|
145
|
+
],
|
|
146
|
+
geometry: { location: { lat: () => 30.2672, lng: () => -97.7431 } },
|
|
147
|
+
},
|
|
148
|
+
mock_6: {
|
|
149
|
+
formatted_address: '1000 Broadway, New York, NY 10001, USA',
|
|
150
|
+
address_components: [
|
|
151
|
+
{ long_name: '1000', types: ['street_number'] },
|
|
152
|
+
{ long_name: 'Broadway', types: ['route'] },
|
|
153
|
+
{ long_name: 'New York', types: ['locality'] },
|
|
154
|
+
{ long_name: 'New York', types: ['administrative_area_level_1'] },
|
|
155
|
+
{ long_name: 'United States', types: ['country'] },
|
|
156
|
+
{ long_name: '10001', types: ['postal_code'] },
|
|
157
|
+
],
|
|
158
|
+
geometry: { location: { lat: () => 40.7589, lng: () => -73.9851 } },
|
|
159
|
+
},
|
|
160
|
+
mock_7: {
|
|
161
|
+
formatted_address: '250 Market Street, San Francisco, CA 94102, USA',
|
|
162
|
+
address_components: [
|
|
163
|
+
{ long_name: '250', types: ['street_number'] },
|
|
164
|
+
{ long_name: 'Market Street', types: ['route'] },
|
|
165
|
+
{ long_name: 'San Francisco', types: ['locality'] },
|
|
166
|
+
{ long_name: 'California', types: ['administrative_area_level_1'] },
|
|
167
|
+
{ long_name: 'United States', types: ['country'] },
|
|
168
|
+
{ long_name: '94102', types: ['postal_code'] },
|
|
169
|
+
],
|
|
170
|
+
geometry: { location: { lat: () => 37.7879, lng: () => -122.4075 } },
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// Every word has to appear somewhere in the address, which is roughly how Google
|
|
175
|
+
// treats a multi-word query.
|
|
176
|
+
const matchesAllWords = (address: MockPrediction, searchTerm: string): boolean => {
|
|
177
|
+
const description = address.description.toLowerCase();
|
|
178
|
+
const mainText = address.structured_formatting.main_text.toLowerCase();
|
|
179
|
+
const secondaryText = address.structured_formatting.secondary_text?.toLowerCase() || '';
|
|
180
|
+
|
|
181
|
+
return searchTerm
|
|
182
|
+
.split(' ')
|
|
183
|
+
.every(
|
|
184
|
+
(word) =>
|
|
185
|
+
description.includes(word) || mainText.includes(word) || secondaryText.includes(word),
|
|
186
|
+
);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// Addresses whose street line starts with the query come first; the rest sort
|
|
190
|
+
// alphabetically.
|
|
191
|
+
const byRelevance =
|
|
192
|
+
(searchTerm: string) =>
|
|
193
|
+
(a: MockPrediction, b: MockPrediction): number => {
|
|
194
|
+
const aMain = a.structured_formatting.main_text.toLowerCase();
|
|
195
|
+
const bMain = b.structured_formatting.main_text.toLowerCase();
|
|
196
|
+
|
|
197
|
+
if (aMain.startsWith(searchTerm) && !bMain.startsWith(searchTerm)) return -1;
|
|
198
|
+
if (!aMain.startsWith(searchTerm) && bMain.startsWith(searchTerm)) return 1;
|
|
199
|
+
return aMain.localeCompare(bMain);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export const searchMockAddresses = (input: string): MockPrediction[] => {
|
|
203
|
+
const searchTerm = input.toLowerCase().trim();
|
|
204
|
+
|
|
205
|
+
return MOCK_ADDRESSES.filter((address) => matchesAllWords(address, searchTerm)).sort(
|
|
206
|
+
byRelevance(searchTerm),
|
|
207
|
+
);
|
|
208
|
+
};
|