@arkyn/components 3.0.1-beta.143 → 3.0.1-beta.144
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/dist/components/alert/alertContainer/index.d.ts +27 -43
- package/dist/components/alert/alertContainer/index.d.ts.map +1 -1
- package/dist/components/alert/alertContainer/index.js +20 -40
- package/dist/components/alert/alertContent/index.d.ts +11 -36
- package/dist/components/alert/alertContent/index.d.ts.map +1 -1
- package/dist/components/alert/alertContent/index.js +11 -31
- package/dist/components/alert/alertDescription/index.d.ts +10 -38
- package/dist/components/alert/alertDescription/index.d.ts.map +1 -1
- package/dist/components/alert/alertDescription/index.js +10 -33
- package/dist/components/alert/alertIcon/index.d.ts +14 -38
- package/dist/components/alert/alertIcon/index.d.ts.map +1 -1
- package/dist/components/alert/alertIcon/index.js +14 -32
- package/dist/components/alert/alertTitle/index.d.ts +12 -35
- package/dist/components/alert/alertTitle/index.d.ts.map +1 -1
- package/dist/components/alert/alertTitle/index.js +12 -27
- package/dist/components/audioPlayer/index.d.ts +24 -32
- package/dist/components/audioPlayer/index.d.ts.map +1 -1
- package/dist/components/audioPlayer/index.js +15 -18
- package/dist/components/audioUpload/index.d.ts +37 -48
- package/dist/components/audioUpload/index.d.ts.map +1 -1
- package/dist/components/audioUpload/index.js +23 -48
- package/dist/components/badge/index.d.ts +31 -22
- package/dist/components/badge/index.d.ts.map +1 -1
- package/dist/components/badge/index.js +14 -22
- package/dist/components/button/index.d.ts +38 -28
- package/dist/components/button/index.d.ts.map +1 -1
- package/dist/components/button/index.js +18 -28
- package/dist/components/cardTab/cardTabButton/index.d.ts +14 -52
- package/dist/components/cardTab/cardTabButton/index.d.ts.map +1 -1
- package/dist/components/cardTab/cardTabButton/index.js +12 -52
- package/dist/components/cardTab/cardTabContainer/index.d.ts +16 -58
- package/dist/components/cardTab/cardTabContainer/index.d.ts.map +1 -1
- package/dist/components/cardTab/cardTabContainer/index.js +12 -58
- package/dist/components/checkbox/index.d.ts +38 -37
- package/dist/components/checkbox/index.d.ts.map +1 -1
- package/dist/components/checkbox/index.js +21 -37
- package/dist/components/clientOnly.d.ts +13 -66
- package/dist/components/clientOnly.d.ts.map +1 -1
- package/dist/components/clientOnly.js +11 -66
- package/dist/components/currencyInput/index.d.ts +67 -50
- package/dist/components/currencyInput/index.d.ts.map +1 -1
- package/dist/components/currencyInput/index.js +28 -50
- package/dist/components/divider/index.d.ts +12 -25
- package/dist/components/divider/index.d.ts.map +1 -1
- package/dist/components/divider/index.js +8 -25
- package/dist/components/drawer/drawerContainer/index.d.ts +16 -50
- package/dist/components/drawer/drawerContainer/index.d.ts.map +1 -1
- package/dist/components/drawer/drawerContainer/index.js +13 -50
- package/dist/components/drawer/drawerHeader/index.d.ts +9 -33
- package/dist/components/drawer/drawerHeader/index.d.ts.map +1 -1
- package/dist/components/drawer/drawerHeader/index.js +8 -33
- package/dist/components/facebookPixel/index.d.ts +47 -0
- package/dist/components/facebookPixel/index.d.ts.map +1 -1
- package/dist/components/facebookPixel/index.js +35 -0
- package/dist/components/fieldError/index.d.ts +4 -11
- package/dist/components/fieldError/index.d.ts.map +1 -1
- package/dist/components/fieldError/index.js +4 -11
- package/dist/components/fieldLabel/index.d.ts +6 -21
- package/dist/components/fieldLabel/index.d.ts.map +1 -1
- package/dist/components/fieldLabel/index.js +5 -21
- package/dist/components/fieldWrapper/index.d.ts +12 -22
- package/dist/components/fieldWrapper/index.d.ts.map +1 -1
- package/dist/components/fieldWrapper/index.js +7 -22
- package/dist/components/fileUpload/index.d.ts +36 -61
- package/dist/components/fileUpload/index.d.ts.map +1 -1
- package/dist/components/fileUpload/index.js +23 -61
- package/dist/components/googleAnalytics/index.d.ts +11 -7
- package/dist/components/googleAnalytics/index.d.ts.map +1 -1
- package/dist/components/googleAnalytics/index.js +9 -7
- package/dist/components/googleTagManager/index.d.ts +27 -21
- package/dist/components/googleTagManager/index.d.ts.map +1 -1
- package/dist/components/googleTagManager/index.js +20 -21
- package/dist/components/iconButton/index.d.ts +31 -15
- package/dist/components/iconButton/index.d.ts.map +1 -1
- package/dist/components/iconButton/index.js +12 -15
- package/dist/components/imageUpload/index.d.ts +47 -75
- package/dist/components/imageUpload/index.d.ts.map +1 -1
- package/dist/components/imageUpload/index.js +27 -75
- package/dist/components/input/index.d.ts +51 -44
- package/dist/components/input/index.d.ts.map +1 -1
- package/dist/components/input/index.js +24 -44
- package/dist/components/mapView/index.d.ts +44 -0
- package/dist/components/mapView/index.d.ts.map +1 -1
- package/dist/components/mapView/index.js +35 -0
- package/dist/components/maskedInput/index.d.ts +66 -51
- package/dist/components/maskedInput/index.d.ts.map +1 -1
- package/dist/components/maskedInput/index.js +28 -51
- package/dist/components/modal/modalContainer/index.d.ts +17 -57
- package/dist/components/modal/modalContainer/index.d.ts.map +1 -1
- package/dist/components/modal/modalContainer/index.js +15 -57
- package/dist/components/modal/modalFooter/index.d.ts +17 -50
- package/dist/components/modal/modalFooter/index.d.ts.map +1 -1
- package/dist/components/modal/modalFooter/index.js +10 -50
- package/dist/components/modal/modalHeader/index.d.ts +13 -47
- package/dist/components/modal/modalHeader/index.d.ts.map +1 -1
- package/dist/components/modal/modalHeader/index.js +12 -47
- package/dist/components/multiSelect/index.d.ts +67 -62
- package/dist/components/multiSelect/index.d.ts.map +1 -1
- package/dist/components/multiSelect/index.js +28 -62
- package/dist/components/pagination/index.d.ts +18 -9
- package/dist/components/pagination/index.d.ts.map +1 -1
- package/dist/components/pagination/index.js +18 -9
- package/dist/components/phoneInput/index.d.ts +65 -30
- package/dist/components/phoneInput/index.d.ts.map +1 -1
- package/dist/components/phoneInput/index.js +35 -30
- package/dist/components/popover/index.d.ts +34 -114
- package/dist/components/popover/index.d.ts.map +1 -1
- package/dist/components/popover/index.js +25 -114
- package/dist/components/radio/radioBox/index.d.ts +17 -65
- package/dist/components/radio/radioBox/index.d.ts.map +1 -1
- package/dist/components/radio/radioBox/index.js +14 -65
- package/dist/components/radio/radioGroup/index.d.ts +36 -67
- package/dist/components/radio/radioGroup/index.d.ts.map +1 -1
- package/dist/components/radio/radioGroup/index.js +25 -67
- package/dist/components/richText/index.d.ts +33 -47
- package/dist/components/richText/index.d.ts.map +1 -1
- package/dist/components/richText/index.js +30 -44
- package/dist/components/searchPlaces.d.ts +52 -50
- package/dist/components/searchPlaces.d.ts.map +1 -1
- package/dist/components/searchPlaces.js +23 -30
- package/dist/components/select/index.d.ts +68 -63
- package/dist/components/select/index.d.ts.map +1 -1
- package/dist/components/select/index.js +29 -63
- package/dist/components/slider/index.d.ts +20 -34
- package/dist/components/slider/index.d.ts.map +1 -1
- package/dist/components/slider/index.js +15 -33
- package/dist/components/switch/index.d.ts +42 -58
- package/dist/components/switch/index.d.ts.map +1 -1
- package/dist/components/switch/index.js +24 -58
- package/dist/components/tab/tabButton/index.d.ts +14 -52
- package/dist/components/tab/tabButton/index.d.ts.map +1 -1
- package/dist/components/tab/tabButton/index.js +12 -52
- package/dist/components/tab/tabContainer/index.d.ts +16 -58
- package/dist/components/tab/tabContainer/index.d.ts.map +1 -1
- package/dist/components/tab/tabContainer/index.js +12 -58
- package/dist/components/table/tableBody/index.d.ts +13 -47
- package/dist/components/table/tableBody/index.d.ts.map +1 -1
- package/dist/components/table/tableBody/index.js +12 -47
- package/dist/components/table/tableCaption/index.d.ts +6 -46
- package/dist/components/table/tableCaption/index.d.ts.map +1 -1
- package/dist/components/table/tableCaption/index.js +6 -46
- package/dist/components/table/tableContainer/index.d.ts +12 -41
- package/dist/components/table/tableContainer/index.d.ts.map +1 -1
- package/dist/components/table/tableContainer/index.js +12 -41
- package/dist/components/table/tableFooter/index.d.ts +5 -29
- package/dist/components/table/tableFooter/index.d.ts.map +1 -1
- package/dist/components/table/tableFooter/index.js +5 -29
- package/dist/components/table/tableHeader/index.d.ts +4 -25
- package/dist/components/table/tableHeader/index.d.ts.map +1 -1
- package/dist/components/table/tableHeader/index.js +4 -25
- package/dist/components/textarea/index.d.ts +32 -64
- package/dist/components/textarea/index.d.ts.map +1 -1
- package/dist/components/textarea/index.js +16 -64
- package/dist/components/tooltip/index.d.ts +27 -55
- package/dist/components/tooltip/index.d.ts.map +1 -1
- package/dist/components/tooltip/index.js +16 -55
- package/dist/hooks/useAutomation.d.ts +18 -26
- package/dist/hooks/useAutomation.d.ts.map +1 -1
- package/dist/hooks/useAutomation.js +18 -26
- package/dist/hooks/useDrawer.d.ts +19 -64
- package/dist/hooks/useDrawer.d.ts.map +1 -1
- package/dist/hooks/useForm.d.ts +12 -29
- package/dist/hooks/useForm.d.ts.map +1 -1
- package/dist/hooks/useForm.js +12 -29
- package/dist/hooks/useHydrated.d.ts +8 -63
- package/dist/hooks/useHydrated.d.ts.map +1 -1
- package/dist/hooks/useHydrated.js +8 -63
- package/dist/hooks/useModal.d.ts +19 -59
- package/dist/hooks/useModal.d.ts.map +1 -1
- package/dist/hooks/useScopedParams.d.ts +17 -69
- package/dist/hooks/useScopedParams.d.ts.map +1 -1
- package/dist/hooks/useScopedParams.js +17 -69
- package/dist/hooks/useScrollLock.d.ts +11 -27
- package/dist/hooks/useScrollLock.d.ts.map +1 -1
- package/dist/hooks/useScrollLock.js +11 -33
- package/dist/hooks/useSearchAutomation.d.ts +16 -34
- package/dist/hooks/useSearchAutomation.d.ts.map +1 -1
- package/dist/hooks/useSearchAutomation.js +16 -34
- package/dist/hooks/useSlider.d.ts +5 -19
- package/dist/hooks/useSlider.d.ts.map +1 -1
- package/dist/hooks/useSlider.js +5 -19
- package/dist/hooks/useToast.d.ts +8 -52
- package/dist/hooks/useToast.d.ts.map +1 -1
- package/dist/hooks/useToast.js +8 -52
- package/dist/providers/drawerProvider.d.ts +15 -81
- package/dist/providers/drawerProvider.d.ts.map +1 -1
- package/dist/providers/drawerProvider.js +15 -81
- package/dist/providers/formProvider.d.ts +17 -53
- package/dist/providers/formProvider.d.ts.map +1 -1
- package/dist/providers/formProvider.js +17 -53
- package/dist/providers/modalProvider.d.ts +16 -77
- package/dist/providers/modalProvider.d.ts.map +1 -1
- package/dist/providers/modalProvider.js +16 -77
- package/dist/providers/placesProvider.d.ts +16 -11
- package/dist/providers/placesProvider.d.ts.map +1 -1
- package/dist/providers/placesProvider.js +16 -11
- package/dist/providers/toastProvider.d.ts +10 -21
- package/dist/providers/toastProvider.d.ts.map +1 -1
- package/dist/providers/toastProvider.js +10 -21
- package/dist/services/toHtml.d.ts +11 -10
- package/dist/services/toHtml.d.ts.map +1 -1
- package/dist/services/toHtml.js +11 -10
- package/dist/services/toRichTextValue.d.ts +11 -17
- package/dist/services/toRichTextValue.d.ts.map +1 -1
- package/dist/services/toRichTextValue.js +11 -17
- package/package.json +1 -1
|
@@ -19,67 +19,53 @@ import { toggleMark } from "../../services/toggleMark";
|
|
|
19
19
|
import { hotKeys, initialValue } from "../../templates/richTextTemplates";
|
|
20
20
|
import "./styles.css";
|
|
21
21
|
/**
|
|
22
|
-
* RichText
|
|
23
|
-
* including bold, italic, underline, code, headings, block quotes, alignment, and image insertion.
|
|
22
|
+
* RichText — WYSIWYG rich-text editor built on Slate.js with a configurable toolbar.
|
|
24
23
|
*
|
|
25
|
-
*
|
|
26
|
-
* character limits, form integration, and error handling.
|
|
24
|
+
* **Toolbar features:** bold, italic, underline, code, H1/H2, block quote, alignment (left/center/right/justify), image and video insertion.
|
|
27
25
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @param props.hiddenButtons - Array of button keys to hide from the toolbar
|
|
31
|
-
* @param props.imageConfig - Configuration object for image insertion functionality
|
|
32
|
-
* @param props.defaultValue - Initial JSON string value for the editor content (default: "[]")
|
|
33
|
-
* @param props.enforceCharacterLimit - Whether to enforce the character limit strictly (default: false)
|
|
34
|
-
* @param props.onChangeCharactersCount - Callback function triggered when character count changes
|
|
35
|
-
* @param props.baseErrorMessage - Custom error message to display
|
|
36
|
-
* @param props.maxLimit - Maximum number of characters allowed (default: 10000)
|
|
37
|
-
* @param props.onChange - Callback function triggered when editor content changes
|
|
38
|
-
* @param props.isError - Whether the component should display in error state
|
|
39
|
-
* @param props.id - Custom ID for the editor element
|
|
40
|
-
* @param props.unShowFieldTemplate - When true, skips `FieldTemplate` structure (wrapper, label and error text) and renders only the checkbox button content.
|
|
41
|
-
* @param props.orientation - Layout direction forwarded to `FieldTemplate`/`FieldWrapper` (`horizontal`, `vertical`, `horizontalReverse`). Default: "horizontalReverse"
|
|
26
|
+
* Editor content is stored as a Slate JSON string in a hidden `<input>` for form submission.
|
|
27
|
+
* Integrates with `useForm` to display validation errors by field name.
|
|
42
28
|
*
|
|
43
|
-
* @
|
|
29
|
+
* @param props.name - Field name for form submission. Required.
|
|
30
|
+
* @param props.label - Label text displayed above the editor.
|
|
31
|
+
* @param props.hiddenButtons - Toolbar button keys to hide (e.g. `["image", "code"]`).
|
|
32
|
+
* @param props.imageConfig - Enables image insertion; contains the upload endpoint and modal labels.
|
|
33
|
+
* @param props.defaultValue - Initial editor content as a Slate JSON string. Default: "[]"
|
|
34
|
+
* @param props.maxLimit - Maximum character count. Default: 10000
|
|
35
|
+
* @param props.enforceCharacterLimit - Prevents typing past `maxLimit`. Default: false
|
|
36
|
+
* @param props.onChangeCharactersCount - Callback fired on every keystroke — receives the current character count.
|
|
37
|
+
* @param props.onChange - Callback fired when editor content changes — receives the Slate `Descendant[]`.
|
|
38
|
+
* @param props.baseErrorMessage - Custom error message (overrides `useForm` context error).
|
|
39
|
+
* @param props.isError - Forces the error visual state.
|
|
40
|
+
* @param props.id - Custom id for the editable area element.
|
|
41
|
+
* @param props.showAsterisk - Appends `*` to the label.
|
|
42
|
+
* @param props.orientation - Layout direction. Default: "horizontal"
|
|
43
|
+
* @param props.unShowFieldTemplate - Skips wrapper, label, and error rendering. Default: false
|
|
44
|
+
*
|
|
45
|
+
* @returns RichText JSX element wrapped in `FieldTemplate`.
|
|
44
46
|
*
|
|
45
47
|
* @example
|
|
46
48
|
* ```tsx
|
|
47
|
-
* // Basic
|
|
49
|
+
* // Basic
|
|
48
50
|
* <RichText name="content" />
|
|
49
51
|
*
|
|
50
|
-
* // With character limit and
|
|
52
|
+
* // With character limit and hidden toolbar buttons
|
|
51
53
|
* <RichText
|
|
52
54
|
* name="description"
|
|
55
|
+
* label="Description"
|
|
53
56
|
* maxLimit={500}
|
|
54
|
-
* enforceCharacterLimit
|
|
55
|
-
* hiddenButtons={["image", "code"]}
|
|
56
|
-
* onChangeCharactersCount={(
|
|
57
|
+
* enforceCharacterLimit
|
|
58
|
+
* hiddenButtons={["image", "video", "code"]}
|
|
59
|
+
* onChangeCharactersCount={(n) => setCharCount(n)}
|
|
57
60
|
* />
|
|
58
61
|
*
|
|
59
|
-
* // With image upload
|
|
62
|
+
* // With image upload support
|
|
60
63
|
* <RichText
|
|
61
64
|
* name="article"
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* modalTitle: "Insert Image",
|
|
65
|
-
* modalInputUrlLabel: "Image URL",
|
|
66
|
-
* modalInputImageLabel: "Upload Image"
|
|
67
|
-
* }}
|
|
65
|
+
* label="Article Body"
|
|
66
|
+
* imageConfig={{ action: "/api/upload" }}
|
|
68
67
|
* />
|
|
69
68
|
* ```
|
|
70
|
-
*
|
|
71
|
-
* @description
|
|
72
|
-
* The component includes:
|
|
73
|
-
* - **Formatting**: Bold, italic, underline, code, headings (H1, H2), block quotes
|
|
74
|
-
* - **Alignment**: Left, center, right, justify
|
|
75
|
-
* - **Image Support**: Upload and URL insertion (when imageConfig is provided)
|
|
76
|
-
* - **Character Limits**: Configurable limits with visual feedback
|
|
77
|
-
* - **Form Integration**: Works with form providers and validation
|
|
78
|
-
* - **Keyboard Shortcuts**: Standard shortcuts for formatting (Ctrl+B, Ctrl+I, etc.)
|
|
79
|
-
* - **Error Handling**: Visual error states and validation messages
|
|
80
|
-
*
|
|
81
|
-
* The editor outputs JSON data representing the document structure, which can be
|
|
82
|
-
* converted to HTML using the provided utility functions.
|
|
83
69
|
*/
|
|
84
70
|
function RichText(props) {
|
|
85
71
|
const { name, hiddenButtons, imageConfig, videoConfig, className: wrapperClassName = "", defaultValue = "[]", enforceCharacterLimit = false, onChangeCharactersCount, baseErrorMessage, maxLimit = 10000, onChange, isError: baseIsError, label, showAsterisk, id, orientation = "horizontal", unShowFieldTemplate = false, } = props;
|
|
@@ -1,70 +1,72 @@
|
|
|
1
1
|
import type { StandaloneSearchBoxProps } from "@react-google-maps/api";
|
|
2
2
|
import { JSX } from "react";
|
|
3
3
|
import { InputProps } from "./input";
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
4
|
+
/** Structured address data extracted from a Google Places result. */
|
|
5
|
+
type PlaceData = {
|
|
6
|
+
/** Street name (e.g. `"Rua Exemplo"`). */
|
|
7
|
+
street: string;
|
|
8
|
+
/** City name (e.g. `"São Paulo"`). */
|
|
9
|
+
city: string;
|
|
10
|
+
/** Full state name (e.g. `"São Paulo"`). */
|
|
11
|
+
state: string;
|
|
12
|
+
/** Neighborhood / district name. */
|
|
13
|
+
neighborhood: string;
|
|
14
|
+
/** Postal / ZIP code. */
|
|
15
|
+
postalCode: string;
|
|
16
|
+
/** State abbreviation (e.g. `"SP"`). */
|
|
17
|
+
stateShortName: string;
|
|
18
|
+
/** Street number (e.g. `"123"`). */
|
|
19
|
+
streetNumber: string;
|
|
20
|
+
/** Geographic coordinates of the place. */
|
|
21
|
+
coordinates: {
|
|
22
|
+
lat: number;
|
|
23
|
+
lng: number;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
11
26
|
type SearchPlacesProps = {
|
|
27
|
+
/** Google Maps `StandaloneSearchBox` options (e.g. `componentRestrictions`, `bounds`). */
|
|
12
28
|
options?: StandaloneSearchBoxProps["options"];
|
|
29
|
+
/** Callback fired every time the input text changes. Receives the current string value. */
|
|
13
30
|
onChange?: (e: string) => void;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
postalCode: string;
|
|
20
|
-
stateShortName: string;
|
|
21
|
-
streetNumber: string;
|
|
22
|
-
coordinates: {
|
|
23
|
-
lat: number;
|
|
24
|
-
lng: number;
|
|
25
|
-
};
|
|
26
|
-
}) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Callback fired when the user selects a place from the autocomplete suggestions.
|
|
33
|
+
* Receives a structured {@link PlaceData} object.
|
|
34
|
+
*/
|
|
35
|
+
onPlaceChanged?: (e: PlaceData) => void;
|
|
27
36
|
} & Omit<InputProps, "onLoad" | "onChange" | "type">;
|
|
28
37
|
/**
|
|
29
|
-
* SearchPlaces
|
|
38
|
+
* SearchPlaces — text input with Google Places autocomplete that returns structured address data.
|
|
39
|
+
*
|
|
40
|
+
* Requires the Google Maps JavaScript API with the Places library to be loaded.
|
|
41
|
+
* Built on `@react-google-maps/api`'s `StandaloneSearchBox`.
|
|
42
|
+
*
|
|
43
|
+
* @param props.options - Google Maps search box options (e.g. restrict by country).
|
|
44
|
+
* @param props.onChange - Fires on every keystroke — receives the current text value.
|
|
45
|
+
* @param props.onPlaceChanged - Fires when the user selects a suggestion — receives structured address data.
|
|
30
46
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
47
|
+
* **...Other valid `Input` properties (except `onLoad`, `onChange`, `type`)**
|
|
48
|
+
*
|
|
49
|
+
* @returns SearchPlaces JSX element (an `Input` wrapped in `StandaloneSearchBox`).
|
|
34
50
|
*
|
|
35
|
-
* @component
|
|
36
51
|
* @example
|
|
37
52
|
* ```tsx
|
|
38
53
|
* <SearchPlaces
|
|
39
|
-
*
|
|
40
|
-
*
|
|
54
|
+
* name="address"
|
|
55
|
+
* label="Address"
|
|
56
|
+
* placeholder="Start typing an address…"
|
|
57
|
+
* options={{ componentRestrictions: { country: "br" } }}
|
|
58
|
+
* onChange={(v) => setRawAddress(v)}
|
|
41
59
|
* onPlaceChanged={(place) => {
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* // stateShortName: "SP",
|
|
50
|
-
* // streetNumber: "123",
|
|
51
|
-
* // coordinates: { lat: -23.5505, lng: -46.6333 }
|
|
52
|
-
* // }
|
|
53
|
-
* }}
|
|
54
|
-
* options={{
|
|
55
|
-
* componentRestrictions: { country: "br" }
|
|
60
|
+
* setAddress({
|
|
61
|
+
* street: place.street,
|
|
62
|
+
* city: place.city,
|
|
63
|
+
* state: place.state,
|
|
64
|
+
* postalCode: place.postalCode,
|
|
65
|
+
* coordinates: place.coordinates,
|
|
66
|
+
* });
|
|
56
67
|
* }}
|
|
57
68
|
* />
|
|
58
69
|
* ```
|
|
59
|
-
*
|
|
60
|
-
* @param {SearchPlacesProps} props - Component props
|
|
61
|
-
* @param {StandaloneSearchBoxProps["options"]} [props.options] - Google Maps API options for filtering/customizing search results
|
|
62
|
-
* @param {(value: string) => void} [props.onChange] - Handler called when the input text changes
|
|
63
|
-
* @param {(place: PlaceData) => void} [props.onPlaceChanged] - Handler called when a place is selected, receives structured address data
|
|
64
|
-
* @returns {JSX.Element} An input field with Google Places autocomplete functionality
|
|
65
|
-
*
|
|
66
|
-
* @requires Google Maps JavaScript API with Places library loaded
|
|
67
|
-
* @requires @react-google-maps/api package
|
|
68
70
|
*/
|
|
69
71
|
declare function SearchPlaces(props: SearchPlacesProps): JSX.Element;
|
|
70
72
|
export { SearchPlaces };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchPlaces.d.ts","sourceRoot":"","sources":["../../src/components/searchPlaces.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAE,GAAG,EAAY,MAAM,OAAO,CAAC;AACtC,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"searchPlaces.d.ts","sourceRoot":"","sources":["../../src/components/searchPlaces.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAE,GAAG,EAAY,MAAM,OAAO,CAAC;AACtC,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAQ5C,qEAAqE;AACrE,KAAK,SAAS,GAAG;IACf,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,yBAAyB;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,oCAAoC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAC;IAC9C,2FAA2F;IAC3F,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;CACzC,GAAG,IAAI,CAAC,UAAU,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,iBAAS,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAmF3D;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -3,45 +3,38 @@ import { StandaloneSearchBox } from "@react-google-maps/api";
|
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { Input } from "./input";
|
|
5
5
|
/**
|
|
6
|
-
* SearchPlaces
|
|
6
|
+
* SearchPlaces — text input with Google Places autocomplete that returns structured address data.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Requires the Google Maps JavaScript API with the Places library to be loaded.
|
|
9
|
+
* Built on `@react-google-maps/api`'s `StandaloneSearchBox`.
|
|
10
|
+
*
|
|
11
|
+
* @param props.options - Google Maps search box options (e.g. restrict by country).
|
|
12
|
+
* @param props.onChange - Fires on every keystroke — receives the current text value.
|
|
13
|
+
* @param props.onPlaceChanged - Fires when the user selects a suggestion — receives structured address data.
|
|
14
|
+
*
|
|
15
|
+
* **...Other valid `Input` properties (except `onLoad`, `onChange`, `type`)**
|
|
16
|
+
*
|
|
17
|
+
* @returns SearchPlaces JSX element (an `Input` wrapped in `StandaloneSearchBox`).
|
|
11
18
|
*
|
|
12
|
-
* @component
|
|
13
19
|
* @example
|
|
14
20
|
* ```tsx
|
|
15
21
|
* <SearchPlaces
|
|
16
|
-
*
|
|
17
|
-
*
|
|
22
|
+
* name="address"
|
|
23
|
+
* label="Address"
|
|
24
|
+
* placeholder="Start typing an address…"
|
|
25
|
+
* options={{ componentRestrictions: { country: "br" } }}
|
|
26
|
+
* onChange={(v) => setRawAddress(v)}
|
|
18
27
|
* onPlaceChanged={(place) => {
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* // stateShortName: "SP",
|
|
27
|
-
* // streetNumber: "123",
|
|
28
|
-
* // coordinates: { lat: -23.5505, lng: -46.6333 }
|
|
29
|
-
* // }
|
|
30
|
-
* }}
|
|
31
|
-
* options={{
|
|
32
|
-
* componentRestrictions: { country: "br" }
|
|
28
|
+
* setAddress({
|
|
29
|
+
* street: place.street,
|
|
30
|
+
* city: place.city,
|
|
31
|
+
* state: place.state,
|
|
32
|
+
* postalCode: place.postalCode,
|
|
33
|
+
* coordinates: place.coordinates,
|
|
34
|
+
* });
|
|
33
35
|
* }}
|
|
34
36
|
* />
|
|
35
37
|
* ```
|
|
36
|
-
*
|
|
37
|
-
* @param {SearchPlacesProps} props - Component props
|
|
38
|
-
* @param {StandaloneSearchBoxProps["options"]} [props.options] - Google Maps API options for filtering/customizing search results
|
|
39
|
-
* @param {(value: string) => void} [props.onChange] - Handler called when the input text changes
|
|
40
|
-
* @param {(place: PlaceData) => void} [props.onPlaceChanged] - Handler called when a place is selected, receives structured address data
|
|
41
|
-
* @returns {JSX.Element} An input field with Google Places autocomplete functionality
|
|
42
|
-
*
|
|
43
|
-
* @requires Google Maps JavaScript API with Places library loaded
|
|
44
|
-
* @requires @react-google-maps/api package
|
|
45
38
|
*/
|
|
46
39
|
function SearchPlaces(props) {
|
|
47
40
|
const { onChange, onPlaceChanged, options, ...rest } = props;
|
|
@@ -1,127 +1,132 @@
|
|
|
1
1
|
import { LucideIcon } from "lucide-react";
|
|
2
2
|
import { FocusEvent } from "react";
|
|
3
3
|
type SelectProps = {
|
|
4
|
+
/** Field name for form submission. Required. */
|
|
4
5
|
name: string;
|
|
6
|
+
/** Array of selectable options. Required. */
|
|
5
7
|
options: {
|
|
6
8
|
label: string;
|
|
7
9
|
value: string;
|
|
8
10
|
}[];
|
|
11
|
+
/** Optional HTML id for the underlying hidden input. */
|
|
9
12
|
id?: string;
|
|
13
|
+
/** Controlled selected value. */
|
|
10
14
|
value?: string;
|
|
15
|
+
/** Uncontrolled default selected value. @default "" */
|
|
11
16
|
defaultValue?: string;
|
|
17
|
+
/** Displays an asterisk on the label to signal a required field. */
|
|
12
18
|
showAsterisk?: boolean;
|
|
19
|
+
/** Optional label text displayed above the select. */
|
|
13
20
|
label?: string;
|
|
21
|
+
/** Validation error message displayed below the select. */
|
|
14
22
|
errorMessage?: string;
|
|
23
|
+
/** Placeholder text shown when no option is selected. @default "Selecione..." */
|
|
15
24
|
placeholder?: string;
|
|
25
|
+
/** Text shown when no options match the search query. @default "Sem opções disponíveis" */
|
|
16
26
|
notFoundText?: string;
|
|
27
|
+
/** Additional CSS class applied to the wrapper element. */
|
|
17
28
|
className?: string;
|
|
29
|
+
/** Disables all interactions. @default false */
|
|
18
30
|
disabled?: boolean;
|
|
31
|
+
/** Prevents value changes while keeping the current value visible. @default false */
|
|
19
32
|
readOnly?: boolean;
|
|
33
|
+
/** Shows a loading spinner and disables interactions. @default false */
|
|
20
34
|
isLoading?: boolean;
|
|
35
|
+
/** Enables search/filter within the dropdown. @default false */
|
|
21
36
|
isSearchable?: boolean;
|
|
37
|
+
/** Closes the dropdown after an option is selected. @default true */
|
|
22
38
|
closeOnSelect?: boolean;
|
|
39
|
+
/** Callback fired when the search query changes. Use for async option loading. */
|
|
23
40
|
onSearch?: (value: string) => void;
|
|
41
|
+
/** Callback fired when the selected value changes. */
|
|
24
42
|
onChange?: (value: string) => void;
|
|
43
|
+
/** Callback fired when the select gains focus. */
|
|
25
44
|
onFocus?: () => void;
|
|
45
|
+
/** Callback fired when the select loses focus. */
|
|
26
46
|
onBlur?: (e: FocusEvent<HTMLDivElement>) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Select size.
|
|
49
|
+
* @default "md"
|
|
50
|
+
*/
|
|
27
51
|
size?: "md" | "lg";
|
|
52
|
+
/**
|
|
53
|
+
* Visual style variant.
|
|
54
|
+
* - `solid`: filled background.
|
|
55
|
+
* - `outline`: bordered, transparent background.
|
|
56
|
+
* - `underline`: bottom border only.
|
|
57
|
+
* @default "solid"
|
|
58
|
+
*/
|
|
28
59
|
variant?: "solid" | "outline" | "underline";
|
|
60
|
+
/** Text or icon rendered at the far left, outside the select area. */
|
|
29
61
|
prefix?: string | LucideIcon;
|
|
62
|
+
/** Lucide icon rendered inside the select on the left. */
|
|
30
63
|
leftIcon?: LucideIcon;
|
|
64
|
+
/** Maximum height (in px) of the options dropdown. */
|
|
31
65
|
optionMaxHeight?: number;
|
|
66
|
+
/** When true, skips `FieldTemplate` wrapper (label and error text). @default false */
|
|
32
67
|
unShowFieldTemplate?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Layout direction forwarded to `FieldTemplate`.
|
|
70
|
+
* @default "horizontal"
|
|
71
|
+
*/
|
|
33
72
|
orientation?: "horizontal" | "vertical" | "horizontalReverse";
|
|
34
73
|
};
|
|
35
74
|
/**
|
|
36
|
-
* Select
|
|
75
|
+
* Select — single-option dropdown with optional search, label, validation, and form integration.
|
|
37
76
|
*
|
|
38
|
-
*
|
|
39
|
-
* @param props.name - Required field name for form handling
|
|
40
|
-
* @param props.options - Array of options with label and value properties
|
|
41
|
-
* @param props.id - Optional unique identifier for the component
|
|
42
|
-
* @param props.value - Controlled value of selected option
|
|
43
|
-
* @param props.defaultValue - Default selected value. Default: ""
|
|
44
|
-
* @param props.showAsterisk - Whether to show asterisk on label for required fields
|
|
45
|
-
* @param props.label - Optional label text to display above the select
|
|
46
|
-
* @param props.errorMessage - Error message to display below the select
|
|
47
|
-
* @param props.placeholder - Placeholder text when no options are selected. Default: "Selecione..."
|
|
48
|
-
* @param props.notFoundText - Text to display when no options match search. Default: "Sem opções disponíveis"
|
|
49
|
-
* @param props.className - Additional CSS classes to apply
|
|
50
|
-
* @param props.disabled - Whether the select is disabled. Default: false
|
|
51
|
-
* @param props.readOnly - Whether the select is read-only. Default: false
|
|
52
|
-
* @param props.isLoading - Controls loading state with spinner. Default: false
|
|
53
|
-
* @param props.isSearchable - Whether the select supports search functionality. Default: false
|
|
54
|
-
* @param props.closeOnSelect - Whether to close dropdown after selecting an option. Default: true
|
|
55
|
-
* @param props.onSearch - Callback function called when search value changes
|
|
56
|
-
* @param props.onChange - Callback function called when selected value changes
|
|
57
|
-
* @param props.onFocus - Callback function called when select gains focus
|
|
58
|
-
* @param props.onBlur - Callback function called when select loses focus
|
|
59
|
-
* @param props.size - Select size. Default: "md"
|
|
60
|
-
* @param props.variant - Visual variant of the select. Default: "solid"
|
|
61
|
-
* @param props.prefix - Text or icon to display at the beginning of the select
|
|
62
|
-
* @param props.leftIcon - Optional icon to display on the left side
|
|
63
|
-
* @param props.optionMaxHeight - Maximum height for the options dropdown
|
|
64
|
-
* @param props.unShowFieldTemplate - When true, skips `FieldTemplate` structure (wrapper, label and error text) and renders only the checkbox button content.
|
|
65
|
-
* @param props.orientation - Layout direction forwarded to `FieldTemplate`/`FieldWrapper` (`horizontal`, `vertical`, `horizontalReverse`). Default: "horizontalReverse"
|
|
77
|
+
* Integrates with `useForm` to display validation errors by field name.
|
|
66
78
|
*
|
|
67
|
-
* @
|
|
79
|
+
* @param props.name - Field name for form submission. Required.
|
|
80
|
+
* @param props.options - Array of selectable options (`{ label, value }`). Required.
|
|
81
|
+
* @param props.value - Controlled selected value.
|
|
82
|
+
* @param props.defaultValue - Uncontrolled default value. Default: ""
|
|
83
|
+
* @param props.label - Label text displayed above the select.
|
|
84
|
+
* @param props.placeholder - Placeholder shown when nothing is selected. Default: "Selecione..."
|
|
85
|
+
* @param props.errorMessage - Validation error message.
|
|
86
|
+
* @param props.isSearchable - Enables search/filter within the dropdown. Default: false
|
|
87
|
+
* @param props.isLoading - Shows a loading spinner and disables interactions. Default: false
|
|
88
|
+
* @param props.closeOnSelect - Closes the dropdown after selecting. Default: true
|
|
89
|
+
* @param props.onChange - Callback fired when the selected value changes.
|
|
90
|
+
* @param props.onSearch - Callback fired when the search query changes.
|
|
91
|
+
* @param props.size - Select size (`md` | `lg`). Default: "md"
|
|
92
|
+
* @param props.variant - Visual style variant. Default: "solid"
|
|
93
|
+
* @param props.orientation - Layout direction. Default: "horizontal"
|
|
94
|
+
* @param props.unShowFieldTemplate - Skips wrapper, label, and error rendering. Default: false
|
|
95
|
+
*
|
|
96
|
+
* @returns Select JSX element wrapped in `FieldTemplate`.
|
|
68
97
|
*
|
|
69
98
|
* @example
|
|
70
99
|
* ```tsx
|
|
71
|
-
* // Basic
|
|
100
|
+
* // Basic
|
|
72
101
|
* <Select
|
|
73
|
-
* name="category
|
|
102
|
+
* name="category"
|
|
74
103
|
* options={[
|
|
75
104
|
* { label: "Technology", value: "tech" },
|
|
76
105
|
* { label: "Design", value: "design" },
|
|
77
|
-
* { label: "Marketing", value: "marketing" }
|
|
78
106
|
* ]}
|
|
79
107
|
* />
|
|
80
108
|
*
|
|
81
|
-
* //
|
|
82
|
-
* <Select
|
|
83
|
-
* name="skill"
|
|
84
|
-
* label="Select your skill:"
|
|
85
|
-
* showAsterisk
|
|
86
|
-
* errorMessage="Please select at least one skill"
|
|
87
|
-
* options={skillOptions}
|
|
88
|
-
* placeholder="Choose your skills..."
|
|
89
|
-
* />
|
|
90
|
-
*
|
|
91
|
-
* // Searchable select with custom styling
|
|
109
|
+
* // With label, validation, and searchable
|
|
92
110
|
* <Select
|
|
93
111
|
* name="country"
|
|
94
|
-
* label="Country
|
|
112
|
+
* label="Country"
|
|
113
|
+
* showAsterisk
|
|
95
114
|
* isSearchable
|
|
96
|
-
* variant="outline"
|
|
97
|
-
* size="lg"
|
|
98
|
-
* leftIcon={GlobeIcon}
|
|
99
115
|
* options={countryOptions}
|
|
116
|
+
* errorMessage={errors.country}
|
|
100
117
|
* notFoundText="No countries found"
|
|
101
118
|
* />
|
|
102
119
|
*
|
|
103
|
-
* // Controlled
|
|
120
|
+
* // Controlled with async search
|
|
104
121
|
* <Select
|
|
105
122
|
* name="tag"
|
|
106
|
-
* label="Tag
|
|
123
|
+
* label="Tag"
|
|
107
124
|
* value={selectedTag}
|
|
108
125
|
* onChange={setSelectedTag}
|
|
109
|
-
* onSearch={
|
|
110
|
-
* closeOnSelect={false}
|
|
126
|
+
* onSearch={fetchTagOptions}
|
|
111
127
|
* isLoading={isLoadingTags}
|
|
112
128
|
* options={tagOptions}
|
|
113
129
|
* />
|
|
114
|
-
*
|
|
115
|
-
* // Select with prefix and custom behavior
|
|
116
|
-
* <Select
|
|
117
|
-
* name="department"
|
|
118
|
-
* label="Department:"
|
|
119
|
-
* prefix="Dept:"
|
|
120
|
-
* closeOnSelect={true}
|
|
121
|
-
* variant="underline"
|
|
122
|
-
* defaultValue="hr"
|
|
123
|
-
* options={departmentOptions}
|
|
124
|
-
* />
|
|
125
130
|
* ```
|
|
126
131
|
*/
|
|
127
132
|
declare function Select(props: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/select/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAA2B,MAAM,OAAO,CAAC;AAc5D,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/select/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAA2B,MAAM,OAAO,CAAC;AAc5D,KAAK,WAAW,GAAG;IACjB,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5C,wDAAwD;IACxD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qFAAqF;IACrF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wEAAwE;IACxE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gEAAgE;IAChE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,qEAAqE;IACrE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,sDAAsD;IACtD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,kDAAkD;IAClD,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IACjD;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;IAC5C,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,sDAAsD;IACtD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sFAAsF;IACtF,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,mBAAmB,CAAC;CAC/D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,2CAuKjC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -11,95 +11,61 @@ import { SelectOptionsContainer } from "./selectOptionsContainer";
|
|
|
11
11
|
import { SelectOverlay } from "./selectOverlay";
|
|
12
12
|
import { SelectSpinner } from "./selectSpinner";
|
|
13
13
|
/**
|
|
14
|
-
* Select
|
|
14
|
+
* Select — single-option dropdown with optional search, label, validation, and form integration.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
* @param props.name - Required field name for form handling
|
|
18
|
-
* @param props.options - Array of options with label and value properties
|
|
19
|
-
* @param props.id - Optional unique identifier for the component
|
|
20
|
-
* @param props.value - Controlled value of selected option
|
|
21
|
-
* @param props.defaultValue - Default selected value. Default: ""
|
|
22
|
-
* @param props.showAsterisk - Whether to show asterisk on label for required fields
|
|
23
|
-
* @param props.label - Optional label text to display above the select
|
|
24
|
-
* @param props.errorMessage - Error message to display below the select
|
|
25
|
-
* @param props.placeholder - Placeholder text when no options are selected. Default: "Selecione..."
|
|
26
|
-
* @param props.notFoundText - Text to display when no options match search. Default: "Sem opções disponíveis"
|
|
27
|
-
* @param props.className - Additional CSS classes to apply
|
|
28
|
-
* @param props.disabled - Whether the select is disabled. Default: false
|
|
29
|
-
* @param props.readOnly - Whether the select is read-only. Default: false
|
|
30
|
-
* @param props.isLoading - Controls loading state with spinner. Default: false
|
|
31
|
-
* @param props.isSearchable - Whether the select supports search functionality. Default: false
|
|
32
|
-
* @param props.closeOnSelect - Whether to close dropdown after selecting an option. Default: true
|
|
33
|
-
* @param props.onSearch - Callback function called when search value changes
|
|
34
|
-
* @param props.onChange - Callback function called when selected value changes
|
|
35
|
-
* @param props.onFocus - Callback function called when select gains focus
|
|
36
|
-
* @param props.onBlur - Callback function called when select loses focus
|
|
37
|
-
* @param props.size - Select size. Default: "md"
|
|
38
|
-
* @param props.variant - Visual variant of the select. Default: "solid"
|
|
39
|
-
* @param props.prefix - Text or icon to display at the beginning of the select
|
|
40
|
-
* @param props.leftIcon - Optional icon to display on the left side
|
|
41
|
-
* @param props.optionMaxHeight - Maximum height for the options dropdown
|
|
42
|
-
* @param props.unShowFieldTemplate - When true, skips `FieldTemplate` structure (wrapper, label and error text) and renders only the checkbox button content.
|
|
43
|
-
* @param props.orientation - Layout direction forwarded to `FieldTemplate`/`FieldWrapper` (`horizontal`, `vertical`, `horizontalReverse`). Default: "horizontalReverse"
|
|
16
|
+
* Integrates with `useForm` to display validation errors by field name.
|
|
44
17
|
*
|
|
45
|
-
* @
|
|
18
|
+
* @param props.name - Field name for form submission. Required.
|
|
19
|
+
* @param props.options - Array of selectable options (`{ label, value }`). Required.
|
|
20
|
+
* @param props.value - Controlled selected value.
|
|
21
|
+
* @param props.defaultValue - Uncontrolled default value. Default: ""
|
|
22
|
+
* @param props.label - Label text displayed above the select.
|
|
23
|
+
* @param props.placeholder - Placeholder shown when nothing is selected. Default: "Selecione..."
|
|
24
|
+
* @param props.errorMessage - Validation error message.
|
|
25
|
+
* @param props.isSearchable - Enables search/filter within the dropdown. Default: false
|
|
26
|
+
* @param props.isLoading - Shows a loading spinner and disables interactions. Default: false
|
|
27
|
+
* @param props.closeOnSelect - Closes the dropdown after selecting. Default: true
|
|
28
|
+
* @param props.onChange - Callback fired when the selected value changes.
|
|
29
|
+
* @param props.onSearch - Callback fired when the search query changes.
|
|
30
|
+
* @param props.size - Select size (`md` | `lg`). Default: "md"
|
|
31
|
+
* @param props.variant - Visual style variant. Default: "solid"
|
|
32
|
+
* @param props.orientation - Layout direction. Default: "horizontal"
|
|
33
|
+
* @param props.unShowFieldTemplate - Skips wrapper, label, and error rendering. Default: false
|
|
34
|
+
*
|
|
35
|
+
* @returns Select JSX element wrapped in `FieldTemplate`.
|
|
46
36
|
*
|
|
47
37
|
* @example
|
|
48
38
|
* ```tsx
|
|
49
|
-
* // Basic
|
|
39
|
+
* // Basic
|
|
50
40
|
* <Select
|
|
51
|
-
* name="category
|
|
41
|
+
* name="category"
|
|
52
42
|
* options={[
|
|
53
43
|
* { label: "Technology", value: "tech" },
|
|
54
44
|
* { label: "Design", value: "design" },
|
|
55
|
-
* { label: "Marketing", value: "marketing" }
|
|
56
45
|
* ]}
|
|
57
46
|
* />
|
|
58
47
|
*
|
|
59
|
-
* //
|
|
60
|
-
* <Select
|
|
61
|
-
* name="skill"
|
|
62
|
-
* label="Select your skill:"
|
|
63
|
-
* showAsterisk
|
|
64
|
-
* errorMessage="Please select at least one skill"
|
|
65
|
-
* options={skillOptions}
|
|
66
|
-
* placeholder="Choose your skills..."
|
|
67
|
-
* />
|
|
68
|
-
*
|
|
69
|
-
* // Searchable select with custom styling
|
|
48
|
+
* // With label, validation, and searchable
|
|
70
49
|
* <Select
|
|
71
50
|
* name="country"
|
|
72
|
-
* label="Country
|
|
51
|
+
* label="Country"
|
|
52
|
+
* showAsterisk
|
|
73
53
|
* isSearchable
|
|
74
|
-
* variant="outline"
|
|
75
|
-
* size="lg"
|
|
76
|
-
* leftIcon={GlobeIcon}
|
|
77
54
|
* options={countryOptions}
|
|
55
|
+
* errorMessage={errors.country}
|
|
78
56
|
* notFoundText="No countries found"
|
|
79
57
|
* />
|
|
80
58
|
*
|
|
81
|
-
* // Controlled
|
|
59
|
+
* // Controlled with async search
|
|
82
60
|
* <Select
|
|
83
61
|
* name="tag"
|
|
84
|
-
* label="Tag
|
|
62
|
+
* label="Tag"
|
|
85
63
|
* value={selectedTag}
|
|
86
64
|
* onChange={setSelectedTag}
|
|
87
|
-
* onSearch={
|
|
88
|
-
* closeOnSelect={false}
|
|
65
|
+
* onSearch={fetchTagOptions}
|
|
89
66
|
* isLoading={isLoadingTags}
|
|
90
67
|
* options={tagOptions}
|
|
91
68
|
* />
|
|
92
|
-
*
|
|
93
|
-
* // Select with prefix and custom behavior
|
|
94
|
-
* <Select
|
|
95
|
-
* name="department"
|
|
96
|
-
* label="Department:"
|
|
97
|
-
* prefix="Dept:"
|
|
98
|
-
* closeOnSelect={true}
|
|
99
|
-
* variant="underline"
|
|
100
|
-
* defaultValue="hr"
|
|
101
|
-
* options={departmentOptions}
|
|
102
|
-
* />
|
|
103
69
|
* ```
|
|
104
70
|
*/
|
|
105
71
|
function Select(props) {
|