@undefine-ui/design-system 3.6.1 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -62,6 +62,7 @@ const ThemeSwitcher = () => {
62
62
  ```tsx
63
63
  import {
64
64
  CopyButton,
65
+ CustomFormLabel,
65
66
  Field,
66
67
  Form,
67
68
  Icon,
@@ -600,6 +601,158 @@ const sortOptions: SortOption[] = [
600
601
  - `open` - Whether the button is in open/active state
601
602
  - All standard MUI ButtonBase props
602
603
 
604
+ ### Google Places Autocomplete
605
+
606
+ 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.
607
+
608
+ **Setup:**
609
+
610
+ ```tsx
611
+ import { GooglePlacesProvider } from '@undefine-ui/design-system';
612
+
613
+ // Wrap your app with GooglePlacesProvider
614
+ function App() {
615
+ return (
616
+ <GooglePlacesProvider apiKey={process.env.GOOGLE_MAPS_API_KEY}>
617
+ {/* Your app content */}
618
+ </GooglePlacesProvider>
619
+ );
620
+ }
621
+ ```
622
+
623
+ **Usage:**
624
+
625
+ ```tsx
626
+ import {
627
+ GooglePlacesAutocomplete,
628
+ Field,
629
+ type PlaceType,
630
+ type PlaceDetails
631
+ } from '@undefine-ui/design-system';
632
+
633
+ // Basic usage
634
+ const [value, setValue] = useState<PlaceType | null>(null);
635
+
636
+ <GooglePlacesAutocomplete
637
+ label="Search for a location"
638
+ placeholder="Start typing..."
639
+ onChange={setValue}
640
+ />
641
+
642
+ // With place details (includes parsed address and coordinates)
643
+ <GooglePlacesAutocomplete
644
+ label="Search address"
645
+ fetchPlaceDetails
646
+ onPlaceDetailsChange={(details) => {
647
+ console.log(details?.parsedAddress?.city); // "Lagos"
648
+ console.log(details?.parsedAddress?.country); // "Nigeria"
649
+ console.log(details?.coordinates?.latitude); // 6.5245
650
+ }}
651
+ />
652
+
653
+ // With country restriction
654
+ <GooglePlacesAutocomplete
655
+ label="US addresses only"
656
+ componentRestrictions={{ country: 'us' }}
657
+ onChange={setValue}
658
+ />
659
+ ```
660
+
661
+ **React Hook Form Integration:**
662
+
663
+ ```tsx
664
+ import { Form, Field } from '@undefine-ui/design-system';
665
+ import { useForm } from 'react-hook-form';
666
+
667
+ const MyForm = () => {
668
+ const methods = useForm({
669
+ defaultValues: {
670
+ location: null,
671
+ address: ''
672
+ }
673
+ });
674
+
675
+ return (
676
+ <Form methods={methods} onSubmit={(data) => console.log(data)}>
677
+ {/* Store full PlaceType object */}
678
+ <Field.GooglePlacesAutocomplete name="location" label="Location" valueType="full" />
679
+
680
+ {/* Store only description string */}
681
+ <Field.GooglePlacesAutocomplete name="address" label="Address" valueType="description" />
682
+
683
+ {/* Store PlaceDetails with parsed address */}
684
+ <Field.GooglePlacesAutocomplete
685
+ name="fullAddress"
686
+ label="Full Address"
687
+ valueType="details"
688
+ fetchPlaceDetails
689
+ />
690
+ </Form>
691
+ );
692
+ };
693
+ ```
694
+
695
+ **GooglePlacesAutocomplete Props:**
696
+
697
+ - `label` - Input label
698
+ - `placeholder` - Input placeholder
699
+ - `value` - Selected place (controlled)
700
+ - `onChange` - Callback when selection changes `(place: PlaceType | null) => void`
701
+ - `fetchPlaceDetails` - Fetch full place details on selection (default: `false`)
702
+ - `onPlaceDetailsChange` - Callback with place details `(details: PlaceDetails | null) => void`
703
+ - `componentRestrictions` - Country restrictions `{ country: string | string[] }`
704
+ - `types` - Place types to search for (e.g., `['address']`, `['establishment']`)
705
+ - `debounceMs` - Debounce delay in milliseconds (default: `300`)
706
+ - `error` / `errorMessage` / `helperText` - Error and helper text display
707
+ - All standard MUI TextField props
708
+
709
+ **Field.GooglePlacesAutocomplete Props:**
710
+
711
+ - `name` - Form field name (required)
712
+ - `valueType` - What to store in form: `'full'` (PlaceType), `'description'` (string), or `'details'` (PlaceDetails)
713
+ - `onValueChange` - Callback when value changes (raw PlaceType)
714
+ - `onPlaceDetailsChange` - Callback when place details are fetched
715
+ - All `GooglePlacesAutocomplete` props except `value`, `onChange`, `error`, `errorMessage`
716
+
717
+ **PlaceDetails Structure:**
718
+
719
+ ```typescript
720
+ interface PlaceDetails {
721
+ placeId: string;
722
+ description: string;
723
+ formattedAddress?: string;
724
+ lat?: number;
725
+ lng?: number;
726
+
727
+ // Structured parsed address
728
+ parsedAddress?: {
729
+ streetNumber?: string;
730
+ street?: string;
731
+ address?: string; // Full formatted address
732
+ neighborhood?: string;
733
+ city?: string;
734
+ state?: string;
735
+ stateCode?: string;
736
+ country?: string;
737
+ countryCode?: string;
738
+ postalCode?: string;
739
+ county?: string;
740
+ };
741
+
742
+ // Coordinates
743
+ coordinates?: {
744
+ latitude: number;
745
+ longitude: number;
746
+ };
747
+ }
748
+ ```
749
+
750
+ **Exported Utilities:**
751
+
752
+ - `GooglePlacesProvider` - Context provider for API key
753
+ - `useGooglePlacesAutocomplete` - Hook for custom implementations
754
+ - `parseAddressComponents` - Parse raw Google address components into structured format
755
+
603
756
  ### OTP Input
604
757
 
605
758
  A one-time password input component with keyboard navigation, paste support, and validation. Perfect for email/SMS verification, PIN codes, and security codes.
@@ -661,6 +814,65 @@ import { OTPInput, Field } from '@undefine-ui/design-system';
661
814
 
662
815
  The `Field.OTP` component automatically integrates with React Hook Form, providing validation and error handling out of the box.
663
816
 
817
+ ### FormLabel
818
+
819
+ A custom form label component with support for optional text, tooltips, and custom icons. Perfect for creating consistent form field labels across your application.
820
+
821
+ **Usage:**
822
+
823
+ ```tsx
824
+ import { CustomFormLabel } from '@undefine-ui/design-system';
825
+
826
+ // Basic label
827
+ <CustomFormLabel label="Email Address" />
828
+
829
+ // Optional field label
830
+ <CustomFormLabel label="Phone Number" optional />
831
+
832
+ // With tooltip
833
+ <CustomFormLabel
834
+ label="API Key"
835
+ tooltip="Your API key can be found in the developer settings."
836
+ />
837
+
838
+ // Optional with tooltip
839
+ <CustomFormLabel
840
+ label="Company Name"
841
+ optional
842
+ tooltip="Enter your company name if applicable."
843
+ />
844
+
845
+ // With custom icon
846
+ <CustomFormLabel
847
+ label="Password"
848
+ tooltip="Password must be at least 8 characters long."
849
+ icon={<Icon icon="HelpCircle" sx={{ width: 16, height: 16, color: 'primary.main' }} />}
850
+ />
851
+
852
+ // Complete form example
853
+ <Box>
854
+ <CustomFormLabel label="Full Name" />
855
+ <TextField fullWidth placeholder="Enter your full name" size="small" />
856
+ </Box>
857
+ ```
858
+
859
+ **Props:**
860
+
861
+ - `label` - Label text to display (required)
862
+ - `optional` - Show "(Optional)" text after label (default: `false`)
863
+ - `tooltip` - Tooltip text shown on hover of info icon
864
+ - `icon` - Custom icon for tooltip (default: `InfoCircle` icon)
865
+ - `sx` - MUI sx prop for styling
866
+ - All MUI `FormLabelProps` are supported (except `children`)
867
+
868
+ **Features:**
869
+
870
+ - **Optional indicator:** Shows "(Optional)" text for non-required fields
871
+ - **Tooltip support:** Info icon with tooltip for additional context
872
+ - **Custom icons:** Replace default info icon with custom icons
873
+ - **Flexible styling:** Supports all MUI FormLabel props and sx styling
874
+ - **Theme integration:** Uses theme variables for consistent styling
875
+
664
876
  ### Dialog
665
877
 
666
878
  Custom dialog components with close button and feedback variations. Includes a base `CustomDialog` with a close button positioned on the right, and a `FeedbackDialog` for success, error, and confirmation states.