@simplybusiness/mobius 5.13.0 → 5.14.1
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/CHANGELOG.md +17 -0
- package/dist/cjs/components/NumberField/NumberField.js +17 -91
- package/dist/cjs/components/NumberField/NumberField.js.map +1 -1
- package/dist/cjs/components/TextField/TextField.js +2 -3
- package/dist/cjs/components/TextField/TextField.js.map +1 -1
- package/dist/cjs/hooks/useTextField/useTextField.js +1 -0
- package/dist/cjs/hooks/useTextField/useTextField.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/components/NumberField/NumberField.js +19 -93
- package/dist/esm/components/NumberField/NumberField.js.map +1 -1
- package/dist/esm/components/TextField/TextField.js +2 -3
- package/dist/esm/components/TextField/TextField.js.map +1 -1
- package/dist/esm/hooks/useTextField/types.js.map +1 -1
- package/dist/esm/hooks/useTextField/useTextField.js +1 -0
- package/dist/esm/hooks/useTextField/useTextField.js.map +1 -1
- package/dist/types/components/NumberField/NumberField.d.ts +5 -24
- package/dist/types/components/NumberField/NumberField.stories.d.ts +1 -0
- package/dist/types/hooks/useTextField/types.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/NumberField/NumberField.stories.tsx +12 -0
- package/src/components/NumberField/NumberField.test.tsx +23 -37
- package/src/components/NumberField/NumberField.tsx +31 -158
- package/src/components/TextField/TextField.tsx +0 -2
- package/src/hooks/useTextField/types.tsx +5 -0
- package/src/hooks/useTextField/useTextField.tsx +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.14.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [d7b97da]
|
|
8
|
+
- @simplybusiness/icons@4.18.0
|
|
9
|
+
|
|
10
|
+
## 5.14.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- bf49853: Add min/max/step props to `TextFieldProps`
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- bf49853: Make `NumberField` inherit from `TextField` so we can use prefixes and suffixes
|
|
19
|
+
|
|
3
20
|
## 5.13.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
|
@@ -12,108 +12,34 @@ Object.defineProperty(exports, "NumberField", {
|
|
|
12
12
|
const _jsxruntime = require("react/jsx-runtime");
|
|
13
13
|
const _dedupe = /*#__PURE__*/ _interop_require_default(require("classnames/dedupe"));
|
|
14
14
|
const _react = require("react");
|
|
15
|
-
const
|
|
16
|
-
const _spaceDelimitedList = require("../../utils/spaceDelimitedList");
|
|
17
|
-
const _ErrorMessage = require("../ErrorMessage");
|
|
18
|
-
const _Label = require("../Label");
|
|
19
|
-
const _Stack = require("../Stack");
|
|
15
|
+
const _TextField = require("../TextField");
|
|
20
16
|
function _interop_require_default(obj) {
|
|
21
17
|
return obj && obj.__esModule ? obj : {
|
|
22
18
|
default: obj
|
|
23
19
|
};
|
|
24
20
|
}
|
|
25
21
|
const NumberField = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
|
|
26
|
-
const {
|
|
27
|
-
const
|
|
28
|
-
const [value, setValue] = (0, _react.useState)(defaultValue);
|
|
29
|
-
const valueWithoutLeadingZero = value.toString().replace(/^0+/, "");
|
|
30
|
-
const optional = typeof isRequired === "boolean" && !isRequired;
|
|
31
|
-
const required = typeof isRequired === "boolean" && isRequired;
|
|
32
|
-
const { labelProps, fieldProps } = (0, _hooks.useLabel)({
|
|
33
|
-
id,
|
|
34
|
-
label,
|
|
35
|
-
"aria-label": ariaLabel,
|
|
36
|
-
"aria-labelledby": ariaLabelledBy
|
|
37
|
-
});
|
|
38
|
-
const containerClasses = (0, _dedupe.default)("mobius-number-field", className, {
|
|
39
|
-
"--is-optional": optional
|
|
40
|
-
});
|
|
41
|
-
const validationClasses = (0, _hooks.useValidationClasses)({
|
|
42
|
-
validationState,
|
|
43
|
-
isInvalid
|
|
44
|
-
});
|
|
45
|
-
const inputClasses = (0, _dedupe.default)("mobius-number-field__input", className, {
|
|
46
|
-
"--is-required": required,
|
|
47
|
-
"--is-optional": optional,
|
|
48
|
-
"--is-disabled": isDisabled
|
|
49
|
-
}, validationClasses);
|
|
50
|
-
const labelClasses = (0, _dedupe.default)("mobius-number-field__label", {
|
|
51
|
-
"--is-disabled": isDisabled
|
|
52
|
-
}, validationClasses);
|
|
53
|
-
const errorMessageId = (0, _react.useId)();
|
|
54
|
-
const shouldErrorMessageShow = errorMessage ? errorMessageId : undefined;
|
|
55
|
-
const describedBy = (0, _spaceDelimitedList.spaceDelimitedList)([
|
|
56
|
-
shouldErrorMessageShow,
|
|
57
|
-
ariaDescribedBy
|
|
58
|
-
]);
|
|
59
|
-
const handleChange = (event)=>{
|
|
60
|
-
// Only allow change between min and max values
|
|
61
|
-
const enteredValue = Number(event.target.value);
|
|
62
|
-
if (minValue && enteredValue < minValue || maxValue && enteredValue > maxValue) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
setValue(enteredValue);
|
|
66
|
-
if (onChange) {
|
|
67
|
-
onChange(event);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
// Only allow numeric input
|
|
22
|
+
const { minValue, maxValue, step, defaultValue, className, ...otherProps } = props;
|
|
23
|
+
const containerClasses = (0, _dedupe.default)("mobius-number-field", className);
|
|
71
24
|
const handleBeforeInput = (event)=>{
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
25
|
+
const { data } = event.nativeEvent;
|
|
26
|
+
if (step != null && Number.isInteger(step) && data === ".") {
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
}
|
|
29
|
+
if (minValue != null && minValue >= 0 && data === "-") {
|
|
74
30
|
event.preventDefault();
|
|
75
|
-
event.stopPropagation();
|
|
76
31
|
}
|
|
77
32
|
};
|
|
78
|
-
return /*#__PURE__*/ (0, _jsxruntime.
|
|
79
|
-
|
|
33
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TextField.TextField, {
|
|
34
|
+
...otherProps,
|
|
80
35
|
className: containerClasses,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
className: "mobius-number-field__input-wrapper",
|
|
89
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
|
|
90
|
-
...fieldProps,
|
|
91
|
-
ref: inputRef || ref,
|
|
92
|
-
className: inputClasses,
|
|
93
|
-
type: "number",
|
|
94
|
-
onChange: handleChange,
|
|
95
|
-
onBeforeInput: handleBeforeInput,
|
|
96
|
-
max: maxValue,
|
|
97
|
-
min: minValue,
|
|
98
|
-
step: step,
|
|
99
|
-
value: valueWithoutLeadingZero,
|
|
100
|
-
placeholder: placeholder,
|
|
101
|
-
required: required,
|
|
102
|
-
"aria-describedby": describedBy,
|
|
103
|
-
"aria-errormessage": shouldErrorMessageShow,
|
|
104
|
-
"aria-invalid": isInvalid,
|
|
105
|
-
readOnly: isReadOnly,
|
|
106
|
-
disabled: isDisabled,
|
|
107
|
-
autoComplete: "off",
|
|
108
|
-
autoCorrect: "off",
|
|
109
|
-
spellCheck: "false"
|
|
110
|
-
})
|
|
111
|
-
}),
|
|
112
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_ErrorMessage.ErrorMessage, {
|
|
113
|
-
id: errorMessageId,
|
|
114
|
-
errorMessage: errorMessage
|
|
115
|
-
})
|
|
116
|
-
]
|
|
36
|
+
onBeforeInput: handleBeforeInput,
|
|
37
|
+
type: "number",
|
|
38
|
+
min: minValue !== null && minValue !== void 0 ? minValue : undefined,
|
|
39
|
+
max: maxValue !== null && maxValue !== void 0 ? maxValue : undefined,
|
|
40
|
+
step: step,
|
|
41
|
+
ref: ref,
|
|
42
|
+
defaultValue: defaultValue != null ? defaultValue.toString() : defaultValue
|
|
117
43
|
});
|
|
118
44
|
});
|
|
119
45
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/NumberField/NumberField.tsx"],"sourcesContent":["\"use client\";\n\nimport classNames from \"classnames/dedupe\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/NumberField/NumberField.tsx"],"sourcesContent":["\"use client\";\n\nimport classNames from \"classnames/dedupe\";\nimport { type Ref, type RefAttributes, forwardRef } from \"react\";\nimport { ForwardedRefComponent } from \"../../types/components\";\nimport {\n TextField,\n type TextFieldElementType,\n type TextFieldProps,\n} from \"../TextField\";\n\nexport type NumberFieldElementType = TextFieldElementType;\n\nexport interface NumberFieldProps\n extends Omit<TextFieldProps, \"type\" | \"defaultValue\" | \"inputElementType\">,\n RefAttributes<NumberFieldElementType> {\n /** The smallest value allowed for the input. */\n minValue?: number;\n /** The largest value allowed for the input. */\n maxValue?: number;\n /** The amount that the input value changes with each increment or decrement \"tick\". */\n step?: number; // ??\n /** The default value for the input. */\n defaultValue?: number;\n}\n\nexport type NumberFieldRef = Ref<NumberFieldElementType>;\n\nexport const NumberField: ForwardedRefComponent<\n NumberFieldProps,\n NumberFieldElementType\n> = forwardRef((props: NumberFieldProps, ref: NumberFieldRef) => {\n const { minValue, maxValue, step, defaultValue, className, ...otherProps } =\n props;\n\n const containerClasses = classNames(\"mobius-number-field\", className);\n\n const handleBeforeInput = (\n event: React.FormEvent<NumberFieldElementType>,\n ) => {\n const { data } = event.nativeEvent as InputEvent;\n if (step != null && Number.isInteger(step) && data === \".\") {\n event.preventDefault();\n }\n if (minValue != null && minValue >= 0 && data === \"-\") {\n event.preventDefault();\n }\n };\n\n return (\n <TextField\n {...otherProps}\n className={containerClasses}\n onBeforeInput={handleBeforeInput}\n type=\"number\"\n min={minValue ?? undefined}\n max={maxValue ?? undefined}\n step={step}\n ref={ref}\n defaultValue={\n defaultValue != null ? defaultValue.toString() : defaultValue\n }\n />\n );\n});\n"],"names":["NumberField","forwardRef","props","ref","minValue","maxValue","step","defaultValue","className","otherProps","containerClasses","classNames","handleBeforeInput","event","data","nativeEvent","Number","isInteger","preventDefault","TextField","onBeforeInput","type","min","undefined","max","toString"],"mappings":"AAAA;;;;;+BA4BaA;;;eAAAA;;;;+DA1BU;uBACkC;2BAMlD;;;;;;AAmBA,MAAMA,4BAGTC,IAAAA,iBAAU,EAAC,CAACC,OAAyBC;IACvC,MAAM,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,YAAY,EAAEC,SAAS,EAAE,GAAGC,YAAY,GACxEP;IAEF,MAAMQ,mBAAmBC,IAAAA,eAAU,EAAC,uBAAuBH;IAE3D,MAAMI,oBAAoB,CACxBC;QAEA,MAAM,EAAEC,IAAI,EAAE,GAAGD,MAAME,WAAW;QAClC,IAAIT,QAAQ,QAAQU,OAAOC,SAAS,CAACX,SAASQ,SAAS,KAAK;YAC1DD,MAAMK,cAAc;QACtB;QACA,IAAId,YAAY,QAAQA,YAAY,KAAKU,SAAS,KAAK;YACrDD,MAAMK,cAAc;QACtB;IACF;IAEA,qBACE,qBAACC,oBAAS;QACP,GAAGV,UAAU;QACdD,WAAWE;QACXU,eAAeR;QACfS,MAAK;QACLC,KAAKlB,qBAAAA,sBAAAA,WAAYmB;QACjBC,KAAKnB,qBAAAA,sBAAAA,WAAYkB;QACjBjB,MAAMA;QACNH,KAAKA;QACLI,cACEA,gBAAgB,OAAOA,aAAakB,QAAQ,KAAKlB;;AAIzD"}
|
|
@@ -23,7 +23,7 @@ function _interop_require_default(obj) {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
const TextField = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
|
|
26
|
-
const { isDisabled,
|
|
26
|
+
const { isDisabled, type = "text", validationState, isInvalid, className, label, errorMessage, children, isRequired, prefixInside, prefixOutside, suffixInside, suffixOutside, ...otherProps } = props;
|
|
27
27
|
const { inputProps, labelProps, errorMessageProps } = (0, _hooks.useTextField)({
|
|
28
28
|
...props,
|
|
29
29
|
"aria-errormessage": errorMessage
|
|
@@ -69,8 +69,7 @@ const TextField = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
|
|
|
69
69
|
...inputProps,
|
|
70
70
|
ref: ref,
|
|
71
71
|
type: type,
|
|
72
|
-
className: inputClasses
|
|
73
|
-
readOnly: isReadOnly
|
|
72
|
+
className: inputClasses
|
|
74
73
|
}),
|
|
75
74
|
(0, _adornmentWithClassName.adornmentWithClassName)(suffixInside, labelClasses, "mobius-text-field__suffix-inside")
|
|
76
75
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/TextField/TextField.tsx"],"sourcesContent":["\"use client\";\n\nimport classNames from \"classnames/dedupe\";\nimport {\n HTMLInputTypeAttribute,\n ReactElement,\n ReactNode,\n Ref,\n RefAttributes,\n forwardRef,\n} from \"react\";\nimport {\n UseTextFieldProps,\n useTextField,\n useValidationClasses,\n} from \"../../hooks\";\nimport { DOMProps, FocusEvents } from \"../../types\";\nimport { ForwardedRefComponent } from \"../../types/components\";\nimport { ErrorMessage } from \"../ErrorMessage\";\nimport { Label } from \"../Label\";\nimport { Stack } from \"../Stack\";\nimport { adornmentWithClassName } from \"./adornmentWithClassName\";\n\nexport type TextFieldElementType = HTMLInputElement;\nexport interface TextFieldProps\n extends DOMProps,\n FocusEvents,\n UseTextFieldProps,\n RefAttributes<TextFieldElementType> {\n className?: string;\n errorMessage?: string;\n children?: ReactNode;\n label?: string;\n type?: Exclude<\n HTMLInputTypeAttribute,\n | \"button\"\n | \"checkbox\"\n | \"color\"\n | \"date\"\n | \"datetime-local\"\n | \"file\"\n | \"image\"\n | \"month\"\n | \"radio\"\n | \"range\"\n | \"reset\"\n | \"submit\"\n | \"week\"\n >;\n prefixInside?: ReactElement;\n prefixOutside?: ReactElement;\n suffixInside?: ReactElement;\n suffixOutside?: ReactElement;\n}\n\nexport type TextFieldRef = Ref<TextFieldElementType>;\n\nconst TextField: ForwardedRefComponent<TextFieldProps, TextFieldElementType> =\n forwardRef((props: TextFieldProps, ref: TextFieldRef) => {\n const {\n isDisabled,\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/TextField/TextField.tsx"],"sourcesContent":["\"use client\";\n\nimport classNames from \"classnames/dedupe\";\nimport {\n HTMLInputTypeAttribute,\n ReactElement,\n ReactNode,\n Ref,\n RefAttributes,\n forwardRef,\n} from \"react\";\nimport {\n UseTextFieldProps,\n useTextField,\n useValidationClasses,\n} from \"../../hooks\";\nimport { DOMProps, FocusEvents } from \"../../types\";\nimport { ForwardedRefComponent } from \"../../types/components\";\nimport { ErrorMessage } from \"../ErrorMessage\";\nimport { Label } from \"../Label\";\nimport { Stack } from \"../Stack\";\nimport { adornmentWithClassName } from \"./adornmentWithClassName\";\n\nexport type TextFieldElementType = HTMLInputElement;\nexport interface TextFieldProps\n extends DOMProps,\n FocusEvents,\n UseTextFieldProps,\n RefAttributes<TextFieldElementType> {\n className?: string;\n errorMessage?: string;\n children?: ReactNode;\n label?: string;\n type?: Exclude<\n HTMLInputTypeAttribute,\n | \"button\"\n | \"checkbox\"\n | \"color\"\n | \"date\"\n | \"datetime-local\"\n | \"file\"\n | \"image\"\n | \"month\"\n | \"radio\"\n | \"range\"\n | \"reset\"\n | \"submit\"\n | \"week\"\n >;\n prefixInside?: ReactElement;\n prefixOutside?: ReactElement;\n suffixInside?: ReactElement;\n suffixOutside?: ReactElement;\n}\n\nexport type TextFieldRef = Ref<TextFieldElementType>;\n\nconst TextField: ForwardedRefComponent<TextFieldProps, TextFieldElementType> =\n forwardRef((props: TextFieldProps, ref: TextFieldRef) => {\n const {\n isDisabled,\n type = \"text\",\n validationState,\n isInvalid,\n className,\n label,\n errorMessage,\n children,\n isRequired,\n prefixInside,\n prefixOutside,\n suffixInside,\n suffixOutside,\n ...otherProps\n } = props;\n\n const { inputProps, labelProps, errorMessageProps } = useTextField({\n ...props,\n \"aria-errormessage\": errorMessage,\n });\n\n const hidden = type === \"hidden\";\n\n const validationClasses = useValidationClasses({\n validationState,\n isInvalid,\n });\n\n const textfieldClasses = {\n \"--is-disabled\": isDisabled,\n \"--is-required\": typeof isRequired === \"boolean\" && isRequired,\n \"--is-optional\": typeof isRequired === \"boolean\" && !isRequired,\n \"--is-hidden\": hidden,\n [className || \"\"]: true,\n };\n\n const sharedClasses = classNames(validationClasses, textfieldClasses);\n\n const labelClasses = classNames(\n {\n \"--is-disabled\": isDisabled,\n },\n validationClasses,\n );\n\n const containerClasses = classNames(\n \"mobius\",\n \"mobius-text-field\",\n sharedClasses,\n );\n\n const inputClasses = classNames(\n \"mobius\",\n \"mobius-text-field__input\",\n sharedClasses,\n );\n\n const inputWrapperClasses = classNames(\n \"mobius-text-field__input-wrapper\",\n sharedClasses,\n );\n\n return (\n <Stack gap=\"xs\" className={containerClasses}>\n {label && !hidden && (\n <Label {...labelProps} className={labelClasses}>\n {label}\n </Label>\n )}\n <div className=\"mobius-text-field__inner-container\">\n {adornmentWithClassName(\n prefixOutside,\n labelClasses,\n \"mobius-text-field__prefix-outside\",\n )}\n <div className={inputWrapperClasses}>\n {adornmentWithClassName(\n prefixInside,\n labelClasses,\n \"mobius-text-field__prefix-inside\",\n )}\n <input\n {...otherProps}\n {...inputProps}\n ref={ref}\n type={type}\n className={inputClasses}\n />\n {adornmentWithClassName(\n suffixInside,\n labelClasses,\n \"mobius-text-field__suffix-inside\",\n )}\n </div>\n {adornmentWithClassName(\n suffixOutside,\n labelClasses,\n \"mobius-text-field__suffix-outside\",\n )}\n </div>\n {children && (\n <div className=\"mobius-text-field__children\">{children}</div>\n )}\n\n <ErrorMessage {...errorMessageProps} errorMessage={errorMessage} />\n </Stack>\n );\n });\n\nTextField.displayName = \"TextField\";\nexport { TextField };\n"],"names":["TextField","forwardRef","props","ref","isDisabled","type","validationState","isInvalid","className","label","errorMessage","children","isRequired","prefixInside","prefixOutside","suffixInside","suffixOutside","otherProps","inputProps","labelProps","errorMessageProps","useTextField","hidden","validationClasses","useValidationClasses","textfieldClasses","sharedClasses","classNames","labelClasses","containerClasses","inputClasses","inputWrapperClasses","Stack","gap","Label","div","adornmentWithClassName","input","ErrorMessage","displayName"],"mappings":"AAAA;;;;;+BA0KSA;;;eAAAA;;;;+DAxKc;uBAQhB;uBAKA;8BAGsB;uBACP;uBACA;wCACiB;;;;;;AAoCvC,MAAMA,0BACJC,IAAAA,iBAAU,EAAC,CAACC,OAAuBC;IACjC,MAAM,EACJC,UAAU,EACVC,OAAO,MAAM,EACbC,eAAe,EACfC,SAAS,EACTC,SAAS,EACTC,KAAK,EACLC,YAAY,EACZC,QAAQ,EACRC,UAAU,EACVC,YAAY,EACZC,aAAa,EACbC,YAAY,EACZC,aAAa,EACb,GAAGC,YACJ,GAAGf;IAEJ,MAAM,EAAEgB,UAAU,EAAEC,UAAU,EAAEC,iBAAiB,EAAE,GAAGC,IAAAA,mBAAY,EAAC;QACjE,GAAGnB,KAAK;QACR,qBAAqBQ;IACvB;IAEA,MAAMY,SAASjB,SAAS;IAExB,MAAMkB,oBAAoBC,IAAAA,2BAAoB,EAAC;QAC7ClB;QACAC;IACF;IAEA,MAAMkB,mBAAmB;QACvB,iBAAiBrB;QACjB,iBAAiB,OAAOQ,eAAe,aAAaA;QACpD,iBAAiB,OAAOA,eAAe,aAAa,CAACA;QACrD,eAAeU;QACf,CAACd,aAAa,GAAG,EAAE;IACrB;IAEA,MAAMkB,gBAAgBC,IAAAA,eAAU,EAACJ,mBAAmBE;IAEpD,MAAMG,eAAeD,IAAAA,eAAU,EAC7B;QACE,iBAAiBvB;IACnB,GACAmB;IAGF,MAAMM,mBAAmBF,IAAAA,eAAU,EACjC,UACA,qBACAD;IAGF,MAAMI,eAAeH,IAAAA,eAAU,EAC7B,UACA,4BACAD;IAGF,MAAMK,sBAAsBJ,IAAAA,eAAU,EACpC,oCACAD;IAGF,qBACE,sBAACM,YAAK;QAACC,KAAI;QAAKzB,WAAWqB;;YACxBpB,SAAS,CAACa,wBACT,qBAACY,YAAK;gBAAE,GAAGf,UAAU;gBAAEX,WAAWoB;0BAC/BnB;;0BAGL,sBAAC0B;gBAAI3B,WAAU;;oBACZ4B,IAAAA,8CAAsB,EACrBtB,eACAc,cACA;kCAEF,sBAACO;wBAAI3B,WAAWuB;;4BACbK,IAAAA,8CAAsB,EACrBvB,cACAe,cACA;0CAEF,qBAACS;gCACE,GAAGpB,UAAU;gCACb,GAAGC,UAAU;gCACdf,KAAKA;gCACLE,MAAMA;gCACNG,WAAWsB;;4BAEZM,IAAAA,8CAAsB,EACrBrB,cACAa,cACA;;;oBAGHQ,IAAAA,8CAAsB,EACrBpB,eACAY,cACA;;;YAGHjB,0BACC,qBAACwB;gBAAI3B,WAAU;0BAA+BG;;0BAGhD,qBAAC2B,0BAAY;gBAAE,GAAGlB,iBAAiB;gBAAEV,cAAcA;;;;AAGzD;AAEFV,UAAUuC,WAAW,GAAG"}
|
|
@@ -37,6 +37,7 @@ function useTextField(props) {
|
|
|
37
37
|
onChange: props.onChange,
|
|
38
38
|
disabled: isDisabled,
|
|
39
39
|
readOnly: isReadOnly,
|
|
40
|
+
required: isRequired,
|
|
40
41
|
"aria-required": isRequired === true ? true : undefined,
|
|
41
42
|
"aria-invalid": props.isInvalid,
|
|
42
43
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/hooks/useTextField/useTextField.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport { spaceDelimitedList } from \"../../utils/spaceDelimitedList\";\nimport { useLabel } from \"../useLabel/useLabel\";\nimport { UseTextFieldProps, UseTextFieldReturn } from \"./types\";\n\nexport function useTextField(props: UseTextFieldProps): UseTextFieldReturn {\n const {\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n inputElementType = \"input\",\n } = props;\n const { labelProps, fieldProps } = useLabel(props);\n\n const descriptionId = useId();\n const descriptionProps = { id: descriptionId };\n\n const errorMessageId = useId();\n const errorMessageProps = { id: errorMessageId };\n\n const ariaDescribedBy = spaceDelimitedList([\n props.description && descriptionId,\n props.errorMessage && errorMessageId,\n props[\"aria-describedby\"],\n ]);\n\n return {\n descriptionProps,\n errorMessageProps,\n labelProps,\n inputProps: {\n defaultValue: props.defaultValue,\n value: props.value,\n onChange: props.onChange,\n disabled: isDisabled,\n readOnly: isReadOnly,\n \"aria-required\": isRequired === true ? true : undefined,\n \"aria-invalid\": props.isInvalid,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": props[\"aria-errormessage\"],\n role: props.role,\n\n type: inputElementType === \"input\" ? props.type : undefined,\n pattern: inputElementType === \"input\" ? props.pattern : undefined,\n\n autoComplete: props.autoComplete,\n maxLength: props.maxLength,\n minLength: props.minLength,\n name: props.name,\n placeholder: props.placeholder,\n inputMode: props.inputMode,\n\n // Clipboard events\n onCopy: props.onCopy,\n onCut: props.onCut,\n onPaste: props.onPaste,\n\n // Composition events\n onCompositionEnd: props.onCompositionEnd,\n onCompositionStart: props.onCompositionStart,\n onCompositionUpdate: props.onCompositionUpdate,\n\n // Selection events\n onSelect: props.onSelect,\n\n // Input events\n onBeforeInput: props.onBeforeInput,\n onInput: props.onInput,\n\n // Focus events\n onFocus: props.onFocus,\n onBlur: props.onBlur,\n\n ...fieldProps,\n },\n };\n}\n"],"names":["useTextField","props","isDisabled","isReadOnly","isRequired","inputElementType","labelProps","fieldProps","useLabel","descriptionId","useId","descriptionProps","id","errorMessageId","errorMessageProps","ariaDescribedBy","spaceDelimitedList","description","errorMessage","inputProps","defaultValue","value","onChange","disabled","readOnly","undefined","isInvalid","role","type","pattern","autoComplete","maxLength","minLength","name","placeholder","inputMode","onCopy","onCut","onPaste","onCompositionEnd","onCompositionStart","onCompositionUpdate","onSelect","onBeforeInput","onInput","onFocus","onBlur"],"mappings":";;;;+BAKgBA;;;eAAAA;;;uBALM;oCACa;0BACV;AAGlB,SAASA,aAAaC,KAAwB;IACnD,MAAM,EACJC,aAAa,KAAK,EAClBC,aAAa,KAAK,EAClBC,aAAa,KAAK,EAClBC,mBAAmB,OAAO,EAC3B,GAAGJ;IACJ,MAAM,EAAEK,UAAU,EAAEC,UAAU,EAAE,GAAGC,IAAAA,kBAAQ,EAACP;IAE5C,MAAMQ,gBAAgBC,IAAAA,YAAK;IAC3B,MAAMC,mBAAmB;QAAEC,IAAIH;IAAc;IAE7C,MAAMI,iBAAiBH,IAAAA,YAAK;IAC5B,MAAMI,oBAAoB;QAAEF,IAAIC;IAAe;IAE/C,MAAME,kBAAkBC,IAAAA,sCAAkB,EAAC;QACzCf,MAAMgB,WAAW,IAAIR;QACrBR,MAAMiB,YAAY,IAAIL;QACtBZ,KAAK,CAAC,mBAAmB;KAC1B;IAED,OAAO;QACLU;QACAG;QACAR;QACAa,YAAY;YACVC,cAAcnB,MAAMmB,YAAY;YAChCC,OAAOpB,MAAMoB,KAAK;YAClBC,UAAUrB,MAAMqB,QAAQ;YACxBC,UAAUrB;YACVsB,UAAUrB;YACV,
|
|
1
|
+
{"version":3,"sources":["../../../../src/hooks/useTextField/useTextField.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport { spaceDelimitedList } from \"../../utils/spaceDelimitedList\";\nimport { useLabel } from \"../useLabel/useLabel\";\nimport { UseTextFieldProps, UseTextFieldReturn } from \"./types\";\n\nexport function useTextField(props: UseTextFieldProps): UseTextFieldReturn {\n const {\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n inputElementType = \"input\",\n } = props;\n const { labelProps, fieldProps } = useLabel(props);\n\n const descriptionId = useId();\n const descriptionProps = { id: descriptionId };\n\n const errorMessageId = useId();\n const errorMessageProps = { id: errorMessageId };\n\n const ariaDescribedBy = spaceDelimitedList([\n props.description && descriptionId,\n props.errorMessage && errorMessageId,\n props[\"aria-describedby\"],\n ]);\n\n return {\n descriptionProps,\n errorMessageProps,\n labelProps,\n inputProps: {\n defaultValue: props.defaultValue,\n value: props.value,\n onChange: props.onChange,\n disabled: isDisabled,\n readOnly: isReadOnly,\n required: isRequired,\n \"aria-required\": isRequired === true ? true : undefined,\n \"aria-invalid\": props.isInvalid,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": props[\"aria-errormessage\"],\n role: props.role,\n\n type: inputElementType === \"input\" ? props.type : undefined,\n pattern: inputElementType === \"input\" ? props.pattern : undefined,\n\n autoComplete: props.autoComplete,\n maxLength: props.maxLength,\n minLength: props.minLength,\n name: props.name,\n placeholder: props.placeholder,\n inputMode: props.inputMode,\n\n // Clipboard events\n onCopy: props.onCopy,\n onCut: props.onCut,\n onPaste: props.onPaste,\n\n // Composition events\n onCompositionEnd: props.onCompositionEnd,\n onCompositionStart: props.onCompositionStart,\n onCompositionUpdate: props.onCompositionUpdate,\n\n // Selection events\n onSelect: props.onSelect,\n\n // Input events\n onBeforeInput: props.onBeforeInput,\n onInput: props.onInput,\n\n // Focus events\n onFocus: props.onFocus,\n onBlur: props.onBlur,\n\n ...fieldProps,\n },\n };\n}\n"],"names":["useTextField","props","isDisabled","isReadOnly","isRequired","inputElementType","labelProps","fieldProps","useLabel","descriptionId","useId","descriptionProps","id","errorMessageId","errorMessageProps","ariaDescribedBy","spaceDelimitedList","description","errorMessage","inputProps","defaultValue","value","onChange","disabled","readOnly","required","undefined","isInvalid","role","type","pattern","autoComplete","maxLength","minLength","name","placeholder","inputMode","onCopy","onCut","onPaste","onCompositionEnd","onCompositionStart","onCompositionUpdate","onSelect","onBeforeInput","onInput","onFocus","onBlur"],"mappings":";;;;+BAKgBA;;;eAAAA;;;uBALM;oCACa;0BACV;AAGlB,SAASA,aAAaC,KAAwB;IACnD,MAAM,EACJC,aAAa,KAAK,EAClBC,aAAa,KAAK,EAClBC,aAAa,KAAK,EAClBC,mBAAmB,OAAO,EAC3B,GAAGJ;IACJ,MAAM,EAAEK,UAAU,EAAEC,UAAU,EAAE,GAAGC,IAAAA,kBAAQ,EAACP;IAE5C,MAAMQ,gBAAgBC,IAAAA,YAAK;IAC3B,MAAMC,mBAAmB;QAAEC,IAAIH;IAAc;IAE7C,MAAMI,iBAAiBH,IAAAA,YAAK;IAC5B,MAAMI,oBAAoB;QAAEF,IAAIC;IAAe;IAE/C,MAAME,kBAAkBC,IAAAA,sCAAkB,EAAC;QACzCf,MAAMgB,WAAW,IAAIR;QACrBR,MAAMiB,YAAY,IAAIL;QACtBZ,KAAK,CAAC,mBAAmB;KAC1B;IAED,OAAO;QACLU;QACAG;QACAR;QACAa,YAAY;YACVC,cAAcnB,MAAMmB,YAAY;YAChCC,OAAOpB,MAAMoB,KAAK;YAClBC,UAAUrB,MAAMqB,QAAQ;YACxBC,UAAUrB;YACVsB,UAAUrB;YACVsB,UAAUrB;YACV,iBAAiBA,eAAe,OAAO,OAAOsB;YAC9C,gBAAgBzB,MAAM0B,SAAS;YAC/B,oBAAoBZ;YACpB,qBAAqBd,KAAK,CAAC,oBAAoB;YAC/C2B,MAAM3B,MAAM2B,IAAI;YAEhBC,MAAMxB,qBAAqB,UAAUJ,MAAM4B,IAAI,GAAGH;YAClDI,SAASzB,qBAAqB,UAAUJ,MAAM6B,OAAO,GAAGJ;YAExDK,cAAc9B,MAAM8B,YAAY;YAChCC,WAAW/B,MAAM+B,SAAS;YAC1BC,WAAWhC,MAAMgC,SAAS;YAC1BC,MAAMjC,MAAMiC,IAAI;YAChBC,aAAalC,MAAMkC,WAAW;YAC9BC,WAAWnC,MAAMmC,SAAS;YAE1B,mBAAmB;YACnBC,QAAQpC,MAAMoC,MAAM;YACpBC,OAAOrC,MAAMqC,KAAK;YAClBC,SAAStC,MAAMsC,OAAO;YAEtB,qBAAqB;YACrBC,kBAAkBvC,MAAMuC,gBAAgB;YACxCC,oBAAoBxC,MAAMwC,kBAAkB;YAC5CC,qBAAqBzC,MAAMyC,mBAAmB;YAE9C,mBAAmB;YACnBC,UAAU1C,MAAM0C,QAAQ;YAExB,eAAe;YACfC,eAAe3C,MAAM2C,aAAa;YAClCC,SAAS5C,MAAM4C,OAAO;YAEtB,eAAe;YACfC,SAAS7C,MAAM6C,OAAO;YACtBC,QAAQ9C,MAAM8C,MAAM;YAEpB,GAAGxC,UAAU;QACf;IACF;AACF"}
|