@mrshmllw/smores-react 9.18.1 → 9.19.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.
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { FocusEvent, FormEvent } from 'react';
|
1
|
+
import React, { FocusEvent, FormEvent, HTMLInputAutoCompleteAttribute } from 'react';
|
2
2
|
import { CommonFieldProps } from '../fields/commonFieldTypes';
|
3
3
|
interface Props extends CommonFieldProps {
|
4
4
|
type?: 'text' | 'email' | 'password' | 'time' | 'date' | 'tel';
|
@@ -6,8 +6,12 @@ interface Props extends CommonFieldProps {
|
|
6
6
|
name?: string;
|
7
7
|
value: string;
|
8
8
|
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
9
|
+
/**
|
10
|
+
* Triggers after animation end (animation duration is 2s),
|
11
|
+
* the animation starts when a user selects or hovers over an autofill option
|
12
|
+
*/
|
13
|
+
onAutoFill?: () => void;
|
9
14
|
}
|
10
|
-
type AutoComplete = 'off' | 'bday-day' | 'bday-month' | 'bday-year';
|
11
15
|
type InputMode = 'text' | 'email' | 'numeric';
|
12
16
|
/** on change or on input required */
|
13
17
|
type InputProps = ({
|
@@ -19,9 +23,17 @@ type InputProps = ({
|
|
19
23
|
onChange?: (e: string) => void;
|
20
24
|
onInputChange: (e: FormEvent<HTMLInputElement>) => void;
|
21
25
|
}) & {
|
22
|
-
autoCompleteAttr?:
|
26
|
+
autoCompleteAttr?: HTMLInputAutoCompleteAttribute;
|
23
27
|
inputModeAttr?: InputMode;
|
24
28
|
};
|
25
29
|
export type TextInputProps = Props & InputProps;
|
30
|
+
/**
|
31
|
+
* A reusable TextInput component that supports various input types, custom styling, icons,
|
32
|
+
* and autofill detection.
|
33
|
+
*
|
34
|
+
* ### Caveats:
|
35
|
+
* - `onAutoFill` triggers after animation end (animation duration is 2s),
|
36
|
+
* the animation starts when a user selects or hovers over an autofill option
|
37
|
+
*/
|
26
38
|
export declare const TextInput: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<HTMLInputElement>>;
|
27
39
|
export {};
|
@@ -1,14 +1,27 @@
|
|
1
|
-
import React, { forwardRef } from 'react';
|
1
|
+
import React, { forwardRef, } from 'react';
|
2
2
|
import { Box } from '../Box';
|
3
3
|
import { Field } from '../fields/Field';
|
4
4
|
import { Input, StyledFrontIcon, StyledTrailingIcon, } from '../fields/components/CommonInput';
|
5
5
|
import { useUniqueId } from '../utils/id';
|
6
|
-
|
6
|
+
/**
|
7
|
+
* A reusable TextInput component that supports various input types, custom styling, icons,
|
8
|
+
* and autofill detection.
|
9
|
+
*
|
10
|
+
* ### Caveats:
|
11
|
+
* - `onAutoFill` triggers after animation end (animation duration is 2s),
|
12
|
+
* the animation starts when a user selects or hovers over an autofill option
|
13
|
+
*/
|
14
|
+
export const TextInput = forwardRef(function TextInput({ id: idProp, type = 'text', placeholder, name, value, error = false, onBlur, onChange, onInputChange, onAutoFill, disabled = false, frontIcon, trailingIcon, fallbackStyle, autoCompleteAttr = 'off', inputModeAttr, ...fieldProps }, ref) {
|
7
15
|
const id = useUniqueId(idProp);
|
16
|
+
const handleAnimationEnd = (e) => {
|
17
|
+
if (e.animationName === 'onAutoFillStart' && onAutoFill && !!value) {
|
18
|
+
onAutoFill();
|
19
|
+
}
|
20
|
+
};
|
8
21
|
return (React.createElement(Field, { ...fieldProps, htmlFor: id, error: error },
|
9
22
|
React.createElement(Box, { flex: true, alignItems: "center", justifyContent: "flex-start" },
|
10
23
|
frontIcon && (React.createElement(StyledFrontIcon, { "$disabled": disabled, render: frontIcon, color: "sesame" })),
|
11
|
-
React.createElement(Input, { disabled: disabled, type: type, id: id, name: name, ref: ref, placeholder: placeholder, value: value, "$error": error, "$frontIcon": frontIcon, "$fallbackStyle": fallbackStyle, autoComplete: autoCompleteAttr, onChange: (e) => {
|
24
|
+
React.createElement(Input, { disabled: disabled, type: type, id: id, name: name, ref: ref, onAnimationEnd: handleAnimationEnd, placeholder: placeholder, value: value, "$error": error, "$frontIcon": frontIcon, "$fallbackStyle": fallbackStyle, autoComplete: autoCompleteAttr, onChange: (e) => {
|
12
25
|
onChange && onChange(e.currentTarget.value);
|
13
26
|
onInputChange && onInputChange(e);
|
14
27
|
}, onBlur: onBlur, inputMode: inputModeAttr }),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../src/TextInput/TextInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../src/TextInput/TextInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAIZ,UAAU,GAEX,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAEvC,OAAO,EACL,KAAK,EACL,eAAe,EACf,kBAAkB,GACnB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAoCzC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,SAAS,CACpD,EACE,EAAE,EAAE,MAAM,EACV,IAAI,GAAG,MAAM,EACb,WAAW,EACX,IAAI,EACJ,KAAK,EACL,KAAK,GAAG,KAAK,EACb,MAAM,EACN,QAAQ,EACR,aAAa,EACb,UAAU,EACV,QAAQ,GAAG,KAAK,EAChB,SAAS,EACT,YAAY,EACZ,aAAa,EACb,gBAAgB,GAAG,KAAK,EACxB,aAAa,EACb,GAAG,UAAU,EACE,EACjB,GAAmC;IAEnC,MAAM,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IAE9B,MAAM,kBAAkB,GAAG,CAAC,CAAyC,EAAE,EAAE;QACvE,IAAI,CAAC,CAAC,aAAa,KAAK,iBAAiB,IAAI,UAAU,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;YACnE,UAAU,EAAE,CAAA;QACd,CAAC;IACH,CAAC,CAAA;IAED,OAAO,CACL,oBAAC,KAAK,OAAK,UAAU,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK;QAC9C,oBAAC,GAAG,IAAC,IAAI,QAAC,UAAU,EAAC,QAAQ,EAAC,cAAc,EAAC,YAAY;YACtD,SAAS,IAAI,CACZ,oBAAC,eAAe,iBACH,QAAQ,EACnB,MAAM,EAAE,SAAS,EACjB,KAAK,EAAC,QAAQ,GACd,CACH;YACD,oBAAC,KAAK,IACJ,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,GAAG,EACR,cAAc,EAAE,kBAAkB,EAClC,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,YACJ,KAAK,gBACD,SAAS,oBACL,aAAa,EAC7B,YAAY,EAAE,gBAAgB,EAC9B,QAAQ,EAAE,CAAC,CAA8B,EAAE,EAAE;oBAC3C,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;oBAC3C,aAAa,IAAI,aAAa,CAAC,CAAC,CAAC,CAAA;gBACnC,CAAC,EACD,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,aAAa,GACxB;YACD,YAAY,IAAI,CACf,oBAAC,kBAAkB,iBACN,QAAQ,EACnB,MAAM,EAAE,YAAY,EACpB,KAAK,EAAC,QAAQ,GACd,CACH,CACG,CACA,CACT,CAAA;AACH,CAAC,CAAC,CAAA"}
|
@@ -48,6 +48,20 @@ export const Input = styled.input `
|
|
48
48
|
&::placeholder {
|
49
49
|
color: ${theme.colors.sesame};
|
50
50
|
}
|
51
|
+
|
52
|
+
&:-webkit-autofill {
|
53
|
+
animation-name: onAutoFillStart;
|
54
|
+
animation-duration: 2s;
|
55
|
+
}
|
56
|
+
|
57
|
+
@keyframes onAutoFillStart {
|
58
|
+
from {
|
59
|
+
background-color: inherit;
|
60
|
+
}
|
61
|
+
to {
|
62
|
+
background-color: inherit;
|
63
|
+
}
|
64
|
+
}
|
51
65
|
`;
|
52
66
|
export const StyledFrontIcon = styled(Icon) `
|
53
67
|
position: relative;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CommonInput.js","sourceRoot":"","sources":["../../../src/fields/components/CommonInput.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAiBnC,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAQ;;WAE9B,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CACtB,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;;;;YAI9C,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC;aACvD,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;;sBAEjC,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE,CACzC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK;;MAExD,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;;IAE3E,CAAC,EAAE,QAAQ,EAAE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CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;;IAE3E,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,CACzB,CAAC,QAAQ;IACT,CAAC,MAAM;IACP,GAAG,CAAA;;;wBAGiB,KAAK,CAAC,MAAM,CAAC,QAAQ;;KAExC;;;;;IAKD,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CACnB,UAAU;IACV;;KAEC;;IAED,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CACtB,aAAa;IACb;;KAEC;;;;;;;;;;;;aAYQ,KAAK,CAAC,MAAM,CAAC,MAAM;;;;;;;;;;;;;;;;CAgB/B,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,CAAO;;;;;aAKrC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;WAC9C,KAAK,CAAC,MAAM,CAAC,SAAS;CAChC,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAO;;;;aAIxC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;WAC9C,KAAK,CAAC,MAAM,CAAC,SAAS;CAChC,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@mrshmllw/smores-react",
|
3
|
-
"version": "9.
|
3
|
+
"version": "9.19.0",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"description": "Collection of React components used by Marshmallow Technology",
|
6
6
|
"keywords": [
|
@@ -39,11 +39,11 @@
|
|
39
39
|
"@babel/preset-env": "^7.25.4",
|
40
40
|
"@babel/preset-react": "^7.18.6",
|
41
41
|
"@babel/preset-typescript": "^7.18.6",
|
42
|
-
"@commitlint/cli": "^19.4.
|
42
|
+
"@commitlint/cli": "^19.4.1",
|
43
43
|
"@commitlint/types": "^19.0.3",
|
44
44
|
"@semantic-release/changelog": "^6.0.3",
|
45
45
|
"@semantic-release/git": "^10.0.1",
|
46
|
-
"@semantic-release/github": "^10.
|
46
|
+
"@semantic-release/github": "^10.3.3",
|
47
47
|
"@semantic-release/npm": "^12.0.0",
|
48
48
|
"@snyk/protect": "^1.1293.0",
|
49
49
|
"@storybook/addon-a11y": "^8.2.9",
|
@@ -55,10 +55,10 @@
|
|
55
55
|
"@storybook/react-vite": "^8.2.9",
|
56
56
|
"@storybook/test": "^8.2.1",
|
57
57
|
"@storybook/test-runner": "^0.19.1",
|
58
|
-
"@testing-library/react": "^16.0.
|
58
|
+
"@testing-library/react": "^16.0.1",
|
59
59
|
"@types/body-scroll-lock": "^3.1.0",
|
60
60
|
"@types/dompurify": "^3.0.5",
|
61
|
-
"@types/node": "^22.5.
|
61
|
+
"@types/node": "^22.5.4",
|
62
62
|
"@types/react": "^18.0.24",
|
63
63
|
"@types/react-dom": "^18.0.8",
|
64
64
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
@@ -67,20 +67,20 @@
|
|
67
67
|
"conventional-changelog-conventionalcommits": "^8.0.0",
|
68
68
|
"eslint": "^8.57.0",
|
69
69
|
"eslint-config-prettier": "^9.0.0",
|
70
|
-
"eslint-plugin-react": "^7.35.
|
70
|
+
"eslint-plugin-react": "^7.35.2",
|
71
71
|
"eslint-plugin-react-hooks": "^4.1.2",
|
72
72
|
"husky": "^9.1.5",
|
73
73
|
"jsdom": "^24.1.1",
|
74
|
-
"lint-staged": "^15.2.
|
74
|
+
"lint-staged": "^15.2.10",
|
75
75
|
"prettier": "^3.3.3",
|
76
76
|
"react": "^18.2.0",
|
77
77
|
"react-dom": "^18.2.0",
|
78
78
|
"rimraf": "^6.0.1",
|
79
79
|
"semantic-release": "^24.1.0",
|
80
80
|
"storybook": "^8.0.4",
|
81
|
-
"styled-components": "^6.1.
|
81
|
+
"styled-components": "^6.1.13",
|
82
82
|
"typescript": "^5.5.4",
|
83
|
-
"vite": "^5.4.
|
83
|
+
"vite": "^5.4.3",
|
84
84
|
"vitest": "^2.0.5"
|
85
85
|
},
|
86
86
|
"dependencies": {
|