@undefine-ui/design-system 3.6.0 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +153 -0
- package/dist/index.cjs +568 -452
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -4
- package/dist/index.d.ts +52 -4
- package/dist/index.js +568 -452
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -90,6 +90,7 @@ The package includes a comprehensive icon library with 45+ SVG icons organized b
|
|
|
90
90
|
- **Date & Time:** Calendar, Clock
|
|
91
91
|
- **Data:** SortUp, SortDown, StatUp, StatDown
|
|
92
92
|
- **Toast:** InfoToast, SuccessToast, WarningToast, ErrorToast
|
|
93
|
+
- **Location:** MapPinXMark
|
|
93
94
|
- **System:** KeyCommand
|
|
94
95
|
|
|
95
96
|
**Usage:**
|
|
@@ -599,6 +600,158 @@ const sortOptions: SortOption[] = [
|
|
|
599
600
|
- `open` - Whether the button is in open/active state
|
|
600
601
|
- All standard MUI ButtonBase props
|
|
601
602
|
|
|
603
|
+
### Google Places Autocomplete
|
|
604
|
+
|
|
605
|
+
A Google Places address autocomplete component with structured address parsing, coordinates extraction, and React Hook Form integration. Perfect for address lookup, location selection, and form-based address capture.
|
|
606
|
+
|
|
607
|
+
**Setup:**
|
|
608
|
+
|
|
609
|
+
```tsx
|
|
610
|
+
import { GooglePlacesProvider } from '@undefine-ui/design-system';
|
|
611
|
+
|
|
612
|
+
// Wrap your app with GooglePlacesProvider
|
|
613
|
+
function App() {
|
|
614
|
+
return (
|
|
615
|
+
<GooglePlacesProvider apiKey={process.env.GOOGLE_MAPS_API_KEY}>
|
|
616
|
+
{/* Your app content */}
|
|
617
|
+
</GooglePlacesProvider>
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
**Usage:**
|
|
623
|
+
|
|
624
|
+
```tsx
|
|
625
|
+
import {
|
|
626
|
+
GooglePlacesAutocomplete,
|
|
627
|
+
Field,
|
|
628
|
+
type PlaceType,
|
|
629
|
+
type PlaceDetails
|
|
630
|
+
} from '@undefine-ui/design-system';
|
|
631
|
+
|
|
632
|
+
// Basic usage
|
|
633
|
+
const [value, setValue] = useState<PlaceType | null>(null);
|
|
634
|
+
|
|
635
|
+
<GooglePlacesAutocomplete
|
|
636
|
+
label="Search for a location"
|
|
637
|
+
placeholder="Start typing..."
|
|
638
|
+
onChange={setValue}
|
|
639
|
+
/>
|
|
640
|
+
|
|
641
|
+
// With place details (includes parsed address and coordinates)
|
|
642
|
+
<GooglePlacesAutocomplete
|
|
643
|
+
label="Search address"
|
|
644
|
+
fetchPlaceDetails
|
|
645
|
+
onPlaceDetailsChange={(details) => {
|
|
646
|
+
console.log(details?.parsedAddress?.city); // "Lagos"
|
|
647
|
+
console.log(details?.parsedAddress?.country); // "Nigeria"
|
|
648
|
+
console.log(details?.coordinates?.latitude); // 6.5245
|
|
649
|
+
}}
|
|
650
|
+
/>
|
|
651
|
+
|
|
652
|
+
// With country restriction
|
|
653
|
+
<GooglePlacesAutocomplete
|
|
654
|
+
label="US addresses only"
|
|
655
|
+
componentRestrictions={{ country: 'us' }}
|
|
656
|
+
onChange={setValue}
|
|
657
|
+
/>
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
**React Hook Form Integration:**
|
|
661
|
+
|
|
662
|
+
```tsx
|
|
663
|
+
import { Form, Field } from '@undefine-ui/design-system';
|
|
664
|
+
import { useForm } from 'react-hook-form';
|
|
665
|
+
|
|
666
|
+
const MyForm = () => {
|
|
667
|
+
const methods = useForm({
|
|
668
|
+
defaultValues: {
|
|
669
|
+
location: null,
|
|
670
|
+
address: ''
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
return (
|
|
675
|
+
<Form methods={methods} onSubmit={(data) => console.log(data)}>
|
|
676
|
+
{/* Store full PlaceType object */}
|
|
677
|
+
<Field.GooglePlacesAutocomplete name="location" label="Location" valueType="full" />
|
|
678
|
+
|
|
679
|
+
{/* Store only description string */}
|
|
680
|
+
<Field.GooglePlacesAutocomplete name="address" label="Address" valueType="description" />
|
|
681
|
+
|
|
682
|
+
{/* Store PlaceDetails with parsed address */}
|
|
683
|
+
<Field.GooglePlacesAutocomplete
|
|
684
|
+
name="fullAddress"
|
|
685
|
+
label="Full Address"
|
|
686
|
+
valueType="details"
|
|
687
|
+
fetchPlaceDetails
|
|
688
|
+
/>
|
|
689
|
+
</Form>
|
|
690
|
+
);
|
|
691
|
+
};
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
**GooglePlacesAutocomplete Props:**
|
|
695
|
+
|
|
696
|
+
- `label` - Input label
|
|
697
|
+
- `placeholder` - Input placeholder
|
|
698
|
+
- `value` - Selected place (controlled)
|
|
699
|
+
- `onChange` - Callback when selection changes `(place: PlaceType | null) => void`
|
|
700
|
+
- `fetchPlaceDetails` - Fetch full place details on selection (default: `false`)
|
|
701
|
+
- `onPlaceDetailsChange` - Callback with place details `(details: PlaceDetails | null) => void`
|
|
702
|
+
- `componentRestrictions` - Country restrictions `{ country: string | string[] }`
|
|
703
|
+
- `types` - Place types to search for (e.g., `['address']`, `['establishment']`)
|
|
704
|
+
- `debounceMs` - Debounce delay in milliseconds (default: `300`)
|
|
705
|
+
- `error` / `errorMessage` / `helperText` - Error and helper text display
|
|
706
|
+
- All standard MUI TextField props
|
|
707
|
+
|
|
708
|
+
**Field.GooglePlacesAutocomplete Props:**
|
|
709
|
+
|
|
710
|
+
- `name` - Form field name (required)
|
|
711
|
+
- `valueType` - What to store in form: `'full'` (PlaceType), `'description'` (string), or `'details'` (PlaceDetails)
|
|
712
|
+
- `onValueChange` - Callback when value changes (raw PlaceType)
|
|
713
|
+
- `onPlaceDetailsChange` - Callback when place details are fetched
|
|
714
|
+
- All `GooglePlacesAutocomplete` props except `value`, `onChange`, `error`, `errorMessage`
|
|
715
|
+
|
|
716
|
+
**PlaceDetails Structure:**
|
|
717
|
+
|
|
718
|
+
```typescript
|
|
719
|
+
interface PlaceDetails {
|
|
720
|
+
placeId: string;
|
|
721
|
+
description: string;
|
|
722
|
+
formattedAddress?: string;
|
|
723
|
+
lat?: number;
|
|
724
|
+
lng?: number;
|
|
725
|
+
|
|
726
|
+
// Structured parsed address
|
|
727
|
+
parsedAddress?: {
|
|
728
|
+
streetNumber?: string;
|
|
729
|
+
street?: string;
|
|
730
|
+
address?: string; // Full formatted address
|
|
731
|
+
neighborhood?: string;
|
|
732
|
+
city?: string;
|
|
733
|
+
state?: string;
|
|
734
|
+
stateCode?: string;
|
|
735
|
+
country?: string;
|
|
736
|
+
countryCode?: string;
|
|
737
|
+
postalCode?: string;
|
|
738
|
+
county?: string;
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
// Coordinates
|
|
742
|
+
coordinates?: {
|
|
743
|
+
latitude: number;
|
|
744
|
+
longitude: number;
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
**Exported Utilities:**
|
|
750
|
+
|
|
751
|
+
- `GooglePlacesProvider` - Context provider for API key
|
|
752
|
+
- `useGooglePlacesAutocomplete` - Hook for custom implementations
|
|
753
|
+
- `parseAddressComponents` - Parse raw Google address components into structured format
|
|
754
|
+
|
|
602
755
|
### OTP Input
|
|
603
756
|
|
|
604
757
|
A one-time password input component with keyboard navigation, paste support, and validation. Perfect for email/SMS verification, PIN codes, and security codes.
|