asma-ui-core 3.80.2 → 3.81.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 +32 -0
- package/dist/asma-ui-core.css +1 -1
- package/dist/components/inputs/dynamic-select/components/DynamicSelectAutocomplete.js +2 -2
- package/dist/components/inputs/phone-field/CountryCodeOptions.js +39 -0
- package/dist/components/inputs/phone-field/CountryCodeSelect.js +145 -0
- package/dist/components/inputs/phone-field/StyledCountryFlag.js +25 -0
- package/dist/components/inputs/phone-field/StyledPhoneField.js +74 -0
- package/dist/components/inputs/phone-field/useCountryPicker.js +55 -0
- package/dist/components/inputs/search-field/StyledSearchField.js +28 -24
- package/dist/components/inputs/select/StyledSelect.js +24 -24
- package/dist/components/inputs/select-autocomplete/StyledSelectAutocomplete.js +35 -35
- package/dist/index.js +117 -113
- package/dist/src/components/inputs/phone-field/CountryCodeOptions.d.ts +20 -0
- package/dist/src/components/inputs/phone-field/CountryCodeSelect.d.ts +30 -0
- package/dist/src/components/inputs/phone-field/StyledCountryFlag.d.ts +34 -0
- package/dist/src/components/inputs/phone-field/StyledPhoneField.d.ts +81 -0
- package/dist/src/components/inputs/phone-field/index.d.ts +3 -0
- package/dist/src/components/inputs/phone-field/types.d.ts +24 -0
- package/dist/src/components/inputs/phone-field/useCountryPicker.d.ts +30 -0
- package/dist/src/components/inputs/phone-field/useCountryPicker.test.d.ts +1 -0
- package/dist/src/components/inputs/select/StyledSelectItem.d.ts +2 -1
- package/dist/src/index.d.ts +1 -0
- package/package.json +1 -1
package/Readme.md
CHANGED
|
@@ -193,6 +193,7 @@ Every component is exported from the package root. Browse them interactively wit
|
|
|
193
193
|
| --- | --- |
|
|
194
194
|
| **Buttons & actions** | `StyledButton`, `StyledLink`, `CopyButton`, `CopyWrapper` |
|
|
195
195
|
| **Text inputs** | `StyledInputField`, `StyledTextarea`, `StyledSearchField`, `StyledLabel` |
|
|
196
|
+
| **Phone** | `StyledPhoneField` (country selector + national number), `StyledCountryFlag` |
|
|
196
197
|
| **Selects** | `StyledSelect` + `StyledSelectItem` (single), `StyledSelectAutocomplete` (combobox), `StyledDynamicSelect` (chip multi-select), `Listbox` (headless) |
|
|
197
198
|
| **Toggles** | `StyledCheckbox`, `StyledRadio` / `StyledRadioGroup`, `StyledSwitch`, `StyledSlider` |
|
|
198
199
|
| **Form scaffolding** | `StyledFormControl`, `StyledFormControlLabel`, `StyledFormGroup`, `StyledFormLabel`, `StyledFormHelperText`, `StyledInputLabel` |
|
|
@@ -206,6 +207,37 @@ Every component is exported from the package root. Browse them interactively wit
|
|
|
206
207
|
| **Primitives** | `Paper`, `Stack`, `Container`, `Avatar`, `Skeleton`, `Fade`, `Popper`, `ClickAwayListener` |
|
|
207
208
|
| **Hooks & utils** | `usePopupState` (+ `bindTrigger` / `bindPopover` / `bindPopper`), `useSnackbar`, `cn`, `omit`, `prepareForSlot` |
|
|
208
209
|
|
|
210
|
+
### Phone field
|
|
211
|
+
|
|
212
|
+
`StyledPhoneField` is a country selector paired with the national part of the number. It is
|
|
213
|
+
presentational on purpose and owns **no** phone data: the country list, the formatter and the
|
|
214
|
+
`tel:` href are injected by the consumer, which is normally `asma-core-helpers/phone`.
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
import { StyledPhoneField, StyledCountryFlag } from 'asma-ui-core'
|
|
218
|
+
import { listPhoneCountries, formatNationalAsYouType } from 'asma-core-helpers/phone'
|
|
219
|
+
|
|
220
|
+
<StyledPhoneField
|
|
221
|
+
label='Phone'
|
|
222
|
+
countries={listPhoneCountries(locale)}
|
|
223
|
+
country={country}
|
|
224
|
+
onCountryChange={setCountry}
|
|
225
|
+
value={nationalNumber}
|
|
226
|
+
onChange={setNationalNumber}
|
|
227
|
+
formatNationalNumber={formatNationalAsYouType}
|
|
228
|
+
renderFlag={renderCountryFlag}
|
|
229
|
+
selectCountryLabel='Select country code'
|
|
230
|
+
searchPlaceholder='Search country or code'
|
|
231
|
+
/>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
The split is deliberate. Declaring the country structurally instead of importing the union keeps
|
|
235
|
+
roughly 20 KB gz of country metadata out of the shared bundle, so an app that never renders a phone
|
|
236
|
+
field does not pay for one. `onChange` reports digits only — the country travels separately.
|
|
237
|
+
|
|
238
|
+
The picker has two shapes: below 744 px it is a full-screen sheet with its own search box, above it
|
|
239
|
+
the trigger itself is the combobox. Both are keyboard-operable and share one listbox.
|
|
240
|
+
|
|
209
241
|
### Icons
|
|
210
242
|
|
|
211
243
|
Around 180 icons ship on a dedicated subpath so you only pay for the ones you use — each is its own
|