@getsoren/design-system 4.89.0 → 4.90.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.
@@ -0,0 +1,15 @@
1
+ import { TextFieldProps } from '@mui/material';
2
+ export interface TextFieldPhoneProps extends Omit<TextFieldProps, "type" | "value" | "onChange"> {
3
+ /** Number as displayed, e.g. "06 34 39 39 49" */
4
+ value: string;
5
+ /** Called with the formatted number on each change */
6
+ onChange: (value: string) => void;
7
+ /** Display of the digits left by an edit, e.g. to cap their count (defaults to `phoneNumberAdapter`: French pairs) */
8
+ format?: (digits: string) => string;
9
+ }
10
+ /**
11
+ * A phone number field formatted as it is typed ("06 34 39 39 49"), the caret kept after the digit it followed:
12
+ * reformatting would otherwise send it to the end on each edit in the middle of the number.
13
+ */
14
+ declare const TextFieldPhone: ({ value, onChange, format, inputRef, slotProps, ...props }: TextFieldPhoneProps) => import("@emotion/react/jsx-runtime").JSX.Element;
15
+ export default TextFieldPhone;
@@ -0,0 +1,23 @@
1
+ export declare const toDigits: (value: string) => string;
2
+ export interface NextPhoneParams {
3
+ /** Caret index in `rawValue` */
4
+ caret: number;
5
+ /** `InputEvent.inputType` — empty when the change was not a keystroke (autofill, a test harness) */
6
+ inputType: string;
7
+ /** Display value before the edit */
8
+ previous: string;
9
+ /** Input value as written by the browser, before formatting */
10
+ rawValue: string;
11
+ /** Display value of the digits left by the edit */
12
+ format: (digits: string) => string;
13
+ }
14
+ /**
15
+ * Pure transition of a phone field: previous value + raw input → next display value and caret.
16
+ * Reformatting rewrites the whole value, which would send the browser caret to the end: an edit in
17
+ * the middle of the number would then continue at the end. The caret is put back after the same
18
+ * count of digits it followed (spaces move, digits do not).
19
+ */
20
+ export declare const computeNextPhone: ({ caret, inputType, previous, rawValue, format }: NextPhoneParams) => {
21
+ caret: number;
22
+ formatted: string;
23
+ };
@@ -105,6 +105,8 @@ export * from './components/Inputs/TextFieldGroup/TextFieldGroup';
105
105
  export { default as TextFieldGroup } from './components/Inputs/TextFieldGroup/TextFieldGroup';
106
106
  export * from './components/Inputs/TextFieldPassword/TextFieldPassword';
107
107
  export { default as TextFieldPassword } from './components/Inputs/TextFieldPassword/TextFieldPassword';
108
+ export * from './components/Inputs/TextFieldPhone/TextFieldPhone';
109
+ export { default as TextFieldPhone } from './components/Inputs/TextFieldPhone/TextFieldPhone';
108
110
  export * from './components/Layout/Backoffice/Backoffice';
109
111
  export { default as Backoffice } from './components/Layout/Backoffice/Backoffice';
110
112
  export { default as CollapsingHeader } from './components/Layout/CollapsingHeader/CollapsingHeader';
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@getsoren/design-system",
3
3
  "description": "Design System React library",
4
4
  "sideEffects": false,
5
- "version": "4.89.0",
5
+ "version": "4.90.0",
6
6
  "license": "ISC",
7
7
  "type": "module",
8
8
  "types": "./dist/src/main.d.ts",