@tamagui/input 2.7.7 → 3.0.0-beta.1091.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/dist/cjs/Input.cjs +72 -163
- package/dist/cjs/Input.native.cjs +208 -0
- package/dist/cjs/Input.native.js +186 -283
- package/dist/cjs/Input.native.js.map +1 -1
- package/dist/cjs/InputNativeProps.cjs +9 -11
- package/dist/cjs/InputNativeProps.native.cjs +18 -0
- package/dist/cjs/InputNativeProps.native.js +9 -10
- package/dist/cjs/InputNativeProps.native.js.map +1 -1
- package/dist/cjs/TextArea.cjs +23 -39
- package/dist/cjs/TextArea.native.cjs +38 -0
- package/dist/cjs/TextArea.native.js +23 -38
- package/dist/cjs/TextArea.native.js.map +1 -1
- package/dist/cjs/index.cjs +15 -17
- package/dist/cjs/index.native.cjs +32 -0
- package/dist/cjs/index.native.js +15 -16
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/shared.cjs +74 -124
- package/dist/cjs/shared.native.cjs +101 -0
- package/dist/cjs/shared.native.js +80 -129
- package/dist/cjs/shared.native.js.map +1 -1
- package/dist/cjs/types.cjs +9 -11
- package/dist/cjs/types.native.cjs +18 -0
- package/dist/cjs/types.native.js +9 -10
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/Input.mjs +59 -139
- package/dist/esm/Input.mjs.map +1 -1
- package/dist/esm/Input.native.js +174 -261
- package/dist/esm/Input.native.js.map +1 -1
- package/dist/esm/InputNativeProps.mjs +0 -2
- package/dist/esm/InputNativeProps.native.js +0 -2
- package/dist/esm/TextArea.mjs +12 -22
- package/dist/esm/TextArea.mjs.map +1 -1
- package/dist/esm/TextArea.native.js +12 -22
- package/dist/esm/TextArea.native.js.map +1 -1
- package/dist/esm/index.js +6 -4
- package/dist/esm/index.mjs +6 -4
- package/dist/esm/index.native.js +6 -4
- package/dist/esm/shared.mjs +59 -107
- package/dist/esm/shared.mjs.map +1 -1
- package/dist/esm/shared.native.js +64 -112
- package/dist/esm/shared.native.js.map +1 -1
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/types.native.js +0 -2
- package/dist/jsx/Input.mjs +59 -139
- package/dist/jsx/Input.mjs.map +1 -1
- package/dist/jsx/Input.native.cjs +208 -0
- package/dist/jsx/Input.native.js +186 -283
- package/dist/jsx/Input.native.js.map +1 -1
- package/dist/jsx/InputNativeProps.mjs +0 -2
- package/dist/jsx/InputNativeProps.native.cjs +18 -0
- package/dist/jsx/InputNativeProps.native.js +9 -10
- package/dist/jsx/InputNativeProps.native.js.map +1 -1
- package/dist/jsx/TextArea.mjs +12 -22
- package/dist/jsx/TextArea.mjs.map +1 -1
- package/dist/jsx/TextArea.native.cjs +38 -0
- package/dist/jsx/TextArea.native.js +23 -38
- package/dist/jsx/TextArea.native.js.map +1 -1
- package/dist/jsx/index.js +6 -4
- package/dist/jsx/index.mjs +6 -4
- package/dist/jsx/index.native.cjs +32 -0
- package/dist/jsx/index.native.js +15 -16
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/shared.mjs +59 -107
- package/dist/jsx/shared.mjs.map +1 -1
- package/dist/jsx/shared.native.cjs +101 -0
- package/dist/jsx/shared.native.js +80 -129
- package/dist/jsx/shared.native.js.map +1 -1
- package/dist/jsx/types.mjs +0 -2
- package/dist/jsx/types.native.cjs +18 -0
- package/dist/jsx/types.native.js +9 -10
- package/dist/jsx/types.native.js.map +1 -1
- package/package.json +17 -17
- package/src/Input.native.tsx +267 -242
- package/src/Input.tsx +150 -154
- package/src/TextArea.tsx +9 -18
- package/src/shared.tsx +56 -109
- package/src/types.ts +2 -2
- package/types/Input.d.ts +32 -50
- package/types/Input.d.ts.map +1 -1
- package/types/Input.native.d.ts +32 -50
- package/types/Input.native.d.ts.map +1 -1
- package/types/TextArea.d.ts +16 -34
- package/types/TextArea.d.ts.map +1 -1
- package/types/shared.d.ts +38 -109
- package/types/shared.d.ts.map +1 -1
- package/types/types.d.ts +2 -2
- package/types/types.d.ts.map +1 -1
- package/dist/cjs/inputTypes.test-d.cjs +0 -128
- package/dist/cjs/inputTypes.test-d.native.js +0 -131
- package/dist/cjs/inputTypes.test-d.native.js.map +0 -1
- package/dist/cjs/v1/Input.cjs +0 -200
- package/dist/cjs/v1/Input.native.js +0 -183
- package/dist/cjs/v1/Input.native.js.map +0 -1
- package/dist/cjs/v1/TextArea.cjs +0 -52
- package/dist/cjs/v1/TextArea.native.js +0 -55
- package/dist/cjs/v1/TextArea.native.js.map +0 -1
- package/dist/cjs/v1/index.cjs +0 -21
- package/dist/cjs/v1/index.native.js +0 -24
- package/dist/cjs/v1/index.native.js.map +0 -1
- package/dist/cjs/v1/types.cjs +0 -18
- package/dist/cjs/v1/types.native.js +0 -21
- package/dist/cjs/v1/types.native.js.map +0 -1
- package/dist/esm/InputNativeProps.mjs.map +0 -1
- package/dist/esm/InputNativeProps.native.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/inputTypes.test-d.mjs +0 -129
- package/dist/esm/inputTypes.test-d.mjs.map +0 -1
- package/dist/esm/inputTypes.test-d.native.js +0 -129
- package/dist/esm/inputTypes.test-d.native.js.map +0 -1
- package/dist/esm/types.mjs.map +0 -1
- package/dist/esm/types.native.js.map +0 -1
- package/dist/esm/v1/Input.mjs +0 -164
- package/dist/esm/v1/Input.mjs.map +0 -1
- package/dist/esm/v1/Input.native.js +0 -144
- package/dist/esm/v1/Input.native.js.map +0 -1
- package/dist/esm/v1/TextArea.mjs +0 -27
- package/dist/esm/v1/TextArea.mjs.map +0 -1
- package/dist/esm/v1/TextArea.native.js +0 -27
- package/dist/esm/v1/TextArea.native.js.map +0 -1
- package/dist/esm/v1/index.mjs +0 -3
- package/dist/esm/v1/index.mjs.map +0 -1
- package/dist/esm/v1/index.native.js +0 -3
- package/dist/esm/v1/index.native.js.map +0 -1
- package/dist/esm/v1/types.mjs +0 -2
- package/dist/esm/v1/types.mjs.map +0 -1
- package/dist/esm/v1/types.native.js +0 -2
- package/dist/esm/v1/types.native.js.map +0 -1
- package/dist/jsx/InputNativeProps.mjs.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
- package/dist/jsx/inputTypes.test-d.mjs +0 -129
- package/dist/jsx/inputTypes.test-d.mjs.map +0 -1
- package/dist/jsx/inputTypes.test-d.native.js +0 -131
- package/dist/jsx/inputTypes.test-d.native.js.map +0 -1
- package/dist/jsx/types.mjs.map +0 -1
- package/dist/jsx/v1/Input.mjs +0 -164
- package/dist/jsx/v1/Input.mjs.map +0 -1
- package/dist/jsx/v1/Input.native.js +0 -183
- package/dist/jsx/v1/Input.native.js.map +0 -1
- package/dist/jsx/v1/TextArea.mjs +0 -27
- package/dist/jsx/v1/TextArea.mjs.map +0 -1
- package/dist/jsx/v1/TextArea.native.js +0 -55
- package/dist/jsx/v1/TextArea.native.js.map +0 -1
- package/dist/jsx/v1/index.mjs +0 -3
- package/dist/jsx/v1/index.mjs.map +0 -1
- package/dist/jsx/v1/index.native.js +0 -24
- package/dist/jsx/v1/index.native.js.map +0 -1
- package/dist/jsx/v1/types.mjs +0 -2
- package/dist/jsx/v1/types.mjs.map +0 -1
- package/dist/jsx/v1/types.native.js +0 -21
- package/dist/jsx/v1/types.native.js.map +0 -1
- package/src/inputTypes.test-d.ts +0 -245
- package/src/v1/Input.native.tsx +0 -153
- package/src/v1/Input.tsx +0 -190
- package/src/v1/TextArea.tsx +0 -35
- package/src/v1/index.ts +0 -3
- package/src/v1/types.ts +0 -65
- package/types/v1/Input.d.ts +0 -64
- package/types/v1/Input.d.ts.map +0 -1
- package/types/v1/Input.native.d.ts +0 -63
- package/types/v1/Input.native.d.ts.map +0 -1
- package/types/v1/TextArea.d.ts +0 -41
- package/types/v1/TextArea.d.ts.map +0 -1
- package/types/v1/index.d.ts +0 -4
- package/types/v1/index.d.ts.map +0 -1
- package/types/v1/types.d.ts +0 -39
- package/types/v1/types.d.ts.map +0 -1
package/dist/esm/shared.mjs
CHANGED
|
@@ -1,115 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getVariableValue, isWeb } from "@tamagui/core";
|
|
3
|
-
import { getButtonSized } from "@tamagui/get-button-sized";
|
|
1
|
+
import { getVariableValue, isWeb, resolveSize, styled } from "@tamagui/core";
|
|
4
2
|
import { getFontSized } from "@tamagui/get-font-sized";
|
|
5
|
-
|
|
3
|
+
|
|
6
4
|
const defaultStyles = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
color: "$color",
|
|
12
|
-
...(isWeb ? {
|
|
13
|
-
tabIndex: 0
|
|
14
|
-
} : {
|
|
15
|
-
focusable: true
|
|
16
|
-
}),
|
|
17
|
-
borderColor: "$borderColor",
|
|
18
|
-
backgroundColor: "$background",
|
|
19
|
-
// this fixes a flex bug where it overflows container
|
|
20
|
-
minWidth: 0,
|
|
21
|
-
hoverStyle: {
|
|
22
|
-
borderColor: "$borderColorHover"
|
|
23
|
-
},
|
|
24
|
-
focusStyle: {
|
|
25
|
-
borderColor: "$borderColorFocus"
|
|
26
|
-
},
|
|
27
|
-
focusVisibleStyle: {
|
|
28
|
-
outlineColor: "$outlineColor",
|
|
29
|
-
outlineWidth: 2,
|
|
30
|
-
outlineStyle: "solid"
|
|
31
|
-
}
|
|
5
|
+
size: true,
|
|
6
|
+
outlineWidth: 0,
|
|
7
|
+
tabIndex: 0,
|
|
8
|
+
minWidth: 0
|
|
32
9
|
};
|
|
33
|
-
const inputSizeVariant = (val =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
10
|
+
const inputSizeVariant = styled.dynamic((val = true, env) => {
|
|
11
|
+
const { frame } = resolveSize(val, env);
|
|
12
|
+
const fontStyle = getFontSized(val, env);
|
|
13
|
+
return {
|
|
14
|
+
color: fontStyle?.color,
|
|
15
|
+
fontFamily: fontStyle?.fontFamily,
|
|
16
|
+
fontSize: fontStyle?.fontSize,
|
|
17
|
+
fontStyle: fontStyle?.fontStyle,
|
|
18
|
+
fontWeight: fontStyle?.fontWeight,
|
|
19
|
+
letterSpacing: fontStyle?.letterSpacing,
|
|
20
|
+
lineHeight: isWeb ? fontStyle?.lineHeight : void 0,
|
|
21
|
+
textTransform: fontStyle?.textTransform,
|
|
22
|
+
...frame
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
const textAreaSizeVariant = styled.dynamic((val = true, env) => {
|
|
26
|
+
return {
|
|
27
|
+
...inputSizeVariant(val, env),
|
|
28
|
+
height: "auto"
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
const resolveTextAreaSize = (props, env) => {
|
|
32
|
+
const sized = textAreaSizeVariant(props.size ?? true, env);
|
|
33
|
+
const fontStyle = getFontSized(props.size ?? true, env);
|
|
34
|
+
const lines = props.rows ?? props.numberOfLines;
|
|
35
|
+
const height = typeof lines === "number" ? lines * getVariableValue(fontStyle?.lineHeight) : sized?.height;
|
|
36
|
+
return {
|
|
37
|
+
borderRadius: sized?.borderRadius,
|
|
38
|
+
color: sized?.color,
|
|
39
|
+
fontFamily: sized?.fontFamily,
|
|
40
|
+
fontSize: sized?.fontSize,
|
|
41
|
+
fontStyle: sized?.fontStyle,
|
|
42
|
+
fontWeight: sized?.fontWeight,
|
|
43
|
+
letterSpacing: sized?.letterSpacing,
|
|
44
|
+
lineHeight: sized?.lineHeight,
|
|
45
|
+
textTransform: sized?.textTransform,
|
|
46
|
+
paddingVertical: sized?.paddingVertical,
|
|
47
|
+
paddingHorizontal: sized?.paddingHorizontal,
|
|
48
|
+
height
|
|
49
|
+
};
|
|
51
50
|
};
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
} = extras;
|
|
56
|
-
const buttonStyles = getButtonSized(val, extras);
|
|
57
|
-
const fontStyle = getFontSized(val, extras);
|
|
58
|
-
const lines = props.rows ?? props.numberOfLines;
|
|
59
|
-
const height = typeof lines === "number" ? lines * getVariableValue(fontStyle.lineHeight) : "auto";
|
|
60
|
-
if (!isWeb && fontStyle) {
|
|
61
|
-
delete fontStyle["lineHeight"];
|
|
62
|
-
}
|
|
63
|
-
const paddingVertical = getSpace(val, {
|
|
64
|
-
shift: -2,
|
|
65
|
-
bounds: [2]
|
|
66
|
-
});
|
|
67
|
-
const paddingHorizontal = getSpace(val, {
|
|
68
|
-
shift: -1,
|
|
69
|
-
bounds: [2]
|
|
70
|
-
});
|
|
71
|
-
return {
|
|
72
|
-
...buttonStyles,
|
|
73
|
-
...fontStyle,
|
|
74
|
-
paddingVertical,
|
|
75
|
-
paddingHorizontal,
|
|
76
|
-
height
|
|
77
|
-
};
|
|
51
|
+
const resolveMultilineInputSize = (props, env) => {
|
|
52
|
+
if (!(props.rows > 1 || props.multiline || props.numberOfLines > 1)) return;
|
|
53
|
+
return resolveTextAreaSize(props, env);
|
|
78
54
|
};
|
|
79
55
|
const INPUT_NAME = "Input";
|
|
80
56
|
const styledBody = [{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
false: defaultStyles
|
|
92
|
-
},
|
|
93
|
-
size: {
|
|
94
|
-
"...size": inputSizeVariant
|
|
95
|
-
},
|
|
96
|
-
disabled: {
|
|
97
|
-
true: {}
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
defaultVariants: {
|
|
101
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
102
|
-
}
|
|
103
|
-
}, {
|
|
104
|
-
isInput: true,
|
|
105
|
-
accept: {
|
|
106
|
-
placeholderTextColor: "color",
|
|
107
|
-
selectionColor: "color",
|
|
108
|
-
cursorColor: "color",
|
|
109
|
-
selectionHandleColor: "color",
|
|
110
|
-
underlineColorAndroid: "color"
|
|
111
|
-
},
|
|
112
|
-
validStyles: Text.staticConfig.validStyles
|
|
113
|
-
}];
|
|
114
|
-
export { INPUT_NAME, defaultStyles, inputSizeVariant, styledBody, textAreaSizeVariant };
|
|
57
|
+
name: INPUT_NAME,
|
|
58
|
+
render: "input",
|
|
59
|
+
...defaultStyles,
|
|
60
|
+
variants: {
|
|
61
|
+
size: inputSizeVariant,
|
|
62
|
+
disabled: { true: {} }
|
|
63
|
+
}
|
|
64
|
+
}, { isInput: true }];
|
|
65
|
+
|
|
66
|
+
export { INPUT_NAME, defaultStyles, inputSizeVariant, resolveMultilineInputSize, resolveTextAreaSize, styledBody, textAreaSizeVariant };
|
|
115
67
|
//# sourceMappingURL=shared.mjs.map
|
package/dist/esm/shared.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"shared.js","names":[],"sources":["esm/shared.js"],"sourcesContent":["import { getVariableValue, isWeb, resolveSize, styled } from \"@tamagui/core\";\nimport { getFontSized } from \"@tamagui/get-font-sized\";\nconst defaultStyles = {\n size: true,\n outlineWidth: 0,\n tabIndex: 0,\n // this fixes a flex bug where it overflows container\n minWidth: 0\n};\nconst inputSizeVariant = styled.dynamic((val = true, env) => {\n const { frame } = resolveSize(val, env);\n const fontStyle = getFontSized(val, env);\n return {\n color: fontStyle?.color,\n fontFamily: fontStyle?.fontFamily,\n fontSize: fontStyle?.fontSize,\n fontStyle: fontStyle?.fontStyle,\n fontWeight: fontStyle?.fontWeight,\n letterSpacing: fontStyle?.letterSpacing,\n lineHeight: isWeb ? fontStyle?.lineHeight : void 0,\n textTransform: fontStyle?.textTransform,\n ...frame\n };\n});\nconst textAreaSizeVariant = styled.dynamic((val = true, env) => {\n return {\n ...inputSizeVariant(val, env),\n height: \"auto\"\n };\n});\nconst resolveTextAreaSize = (props, env) => {\n const sized = textAreaSizeVariant(props.size ?? true, env);\n const fontStyle = getFontSized(props.size ?? true, env);\n const lines = props.rows ?? props.numberOfLines;\n const height = typeof lines === \"number\" ? lines * getVariableValue(fontStyle?.lineHeight) : sized?.height;\n return {\n borderRadius: sized?.borderRadius,\n color: sized?.color,\n fontFamily: sized?.fontFamily,\n fontSize: sized?.fontSize,\n fontStyle: sized?.fontStyle,\n fontWeight: sized?.fontWeight,\n letterSpacing: sized?.letterSpacing,\n lineHeight: sized?.lineHeight,\n textTransform: sized?.textTransform,\n paddingVertical: sized?.paddingVertical,\n paddingHorizontal: sized?.paddingHorizontal,\n height\n };\n};\nconst resolveMultilineInputSize = (props, env) => {\n if (!(props.rows > 1 || props.multiline || props.numberOfLines > 1)) return;\n return resolveTextAreaSize(props, env);\n};\nconst INPUT_NAME = \"Input\";\nconst styledBody = [\n {\n name: INPUT_NAME,\n render: \"input\",\n ...defaultStyles,\n variants: {\n size: inputSizeVariant,\n disabled: {\n true: {}\n }\n }\n },\n {\n isInput: true\n }\n];\nexport {\n INPUT_NAME,\n defaultStyles,\n inputSizeVariant,\n resolveMultilineInputSize,\n resolveTextAreaSize,\n styledBody,\n textAreaSizeVariant\n};\n//# sourceMappingURL=shared.js.map\n"],"mappings":";;;;AAEA,MAAM,gBAAgB;CACpB,MAAM;CACN,cAAc;CACd,UAAU;CAEV,UAAU;AACZ;AACA,MAAM,mBAAmB,OAAO,SAAS,MAAM,MAAM,QAAQ;CAC3D,MAAM,EAAE,UAAU,YAAY,KAAK,GAAG;CACtC,MAAM,YAAY,aAAa,KAAK,GAAG;CACvC,OAAO;EACL,OAAO,WAAW;EAClB,YAAY,WAAW;EACvB,UAAU,WAAW;EACrB,WAAW,WAAW;EACtB,YAAY,WAAW;EACvB,eAAe,WAAW;EAC1B,YAAY,QAAQ,WAAW,aAAa,KAAK;EACjD,eAAe,WAAW;EAC1B,GAAG;CACL;AACF,CAAC;AACD,MAAM,sBAAsB,OAAO,SAAS,MAAM,MAAM,QAAQ;CAC9D,OAAO;EACL,GAAG,iBAAiB,KAAK,GAAG;EAC5B,QAAQ;CACV;AACF,CAAC;AACD,MAAM,uBAAuB,OAAO,QAAQ;CAC1C,MAAM,QAAQ,oBAAoB,MAAM,QAAQ,MAAM,GAAG;CACzD,MAAM,YAAY,aAAa,MAAM,QAAQ,MAAM,GAAG;CACtD,MAAM,QAAQ,MAAM,QAAQ,MAAM;CAClC,MAAM,SAAS,OAAO,UAAU,WAAW,QAAQ,iBAAiB,WAAW,UAAU,IAAI,OAAO;CACpG,OAAO;EACL,cAAc,OAAO;EACrB,OAAO,OAAO;EACd,YAAY,OAAO;EACnB,UAAU,OAAO;EACjB,WAAW,OAAO;EAClB,YAAY,OAAO;EACnB,eAAe,OAAO;EACtB,YAAY,OAAO;EACnB,eAAe,OAAO;EACtB,iBAAiB,OAAO;EACxB,mBAAmB,OAAO;EAC1B;CACF;AACF;AACA,MAAM,6BAA6B,OAAO,QAAQ;CAChD,IAAI,EAAE,MAAM,OAAO,KAAK,MAAM,aAAa,MAAM,gBAAgB,IAAI;CACrE,OAAO,oBAAoB,OAAO,GAAG;AACvC;AACA,MAAM,aAAa;AACnB,MAAM,aAAa,CACjB;CACE,MAAM;CACN,QAAQ;CACR,GAAG;CACH,UAAU;EACR,MAAM;EACN,UAAU,EACR,MAAM,CAAC,EACT;CACF;AACF,GACA,EACE,SAAS,KACX,CACF"}
|
|
@@ -1,120 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getVariableValue, isWeb } from "@tamagui/core";
|
|
3
|
-
import { getButtonSized } from "@tamagui/get-button-sized";
|
|
1
|
+
import { getVariableValue, isWeb, resolveSize, styled } from "@tamagui/core";
|
|
4
2
|
import { getFontSized } from "@tamagui/get-font-sized";
|
|
5
|
-
|
|
3
|
+
|
|
6
4
|
var defaultStyles = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
color: "$color",
|
|
12
|
-
...(isWeb ? {
|
|
13
|
-
tabIndex: 0
|
|
14
|
-
} : {
|
|
15
|
-
focusable: true
|
|
16
|
-
}),
|
|
17
|
-
borderColor: "$borderColor",
|
|
18
|
-
backgroundColor: "$background",
|
|
19
|
-
// this fixes a flex bug where it overflows container
|
|
20
|
-
minWidth: 0,
|
|
21
|
-
hoverStyle: {
|
|
22
|
-
borderColor: "$borderColorHover"
|
|
23
|
-
},
|
|
24
|
-
focusStyle: {
|
|
25
|
-
borderColor: "$borderColorFocus"
|
|
26
|
-
},
|
|
27
|
-
focusVisibleStyle: {
|
|
28
|
-
outlineColor: "$outlineColor",
|
|
29
|
-
outlineWidth: 2,
|
|
30
|
-
outlineStyle: "solid"
|
|
31
|
-
}
|
|
5
|
+
size: true,
|
|
6
|
+
outlineWidth: 0,
|
|
7
|
+
tabIndex: 0,
|
|
8
|
+
minWidth: 0
|
|
32
9
|
};
|
|
33
|
-
var inputSizeVariant = function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
10
|
+
var inputSizeVariant = styled.dynamic(function() {
|
|
11
|
+
var val = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true, env = arguments.length > 1 ? arguments[1] : void 0;
|
|
12
|
+
var { frame } = resolveSize(val, env);
|
|
13
|
+
var fontStyle = getFontSized(val, env);
|
|
14
|
+
return {
|
|
15
|
+
color: fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.color,
|
|
16
|
+
fontFamily: fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.fontFamily,
|
|
17
|
+
fontSize: fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.fontSize,
|
|
18
|
+
fontStyle: fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.fontStyle,
|
|
19
|
+
fontWeight: fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.fontWeight,
|
|
20
|
+
letterSpacing: fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.letterSpacing,
|
|
21
|
+
lineHeight: isWeb ? fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.lineHeight : void 0,
|
|
22
|
+
textTransform: fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.textTransform,
|
|
23
|
+
...frame
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
var textAreaSizeVariant = styled.dynamic(function() {
|
|
27
|
+
var val = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true, env = arguments.length > 1 ? arguments[1] : void 0;
|
|
28
|
+
return {
|
|
29
|
+
...inputSizeVariant(val, env),
|
|
30
|
+
height: "auto"
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
var resolveTextAreaSize = function(props, env) {
|
|
34
|
+
var _props_size;
|
|
35
|
+
var sized = textAreaSizeVariant((_props_size = props.size) !== null && _props_size !== void 0 ? _props_size : true, env);
|
|
36
|
+
var _props_size1;
|
|
37
|
+
var fontStyle = getFontSized((_props_size1 = props.size) !== null && _props_size1 !== void 0 ? _props_size1 : true, env);
|
|
38
|
+
var _props_rows;
|
|
39
|
+
var lines = (_props_rows = props.rows) !== null && _props_rows !== void 0 ? _props_rows : props.numberOfLines;
|
|
40
|
+
var height = typeof lines === "number" ? lines * getVariableValue(fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.lineHeight) : sized === null || sized === void 0 ? void 0 : sized.height;
|
|
41
|
+
return {
|
|
42
|
+
borderRadius: sized === null || sized === void 0 ? void 0 : sized.borderRadius,
|
|
43
|
+
color: sized === null || sized === void 0 ? void 0 : sized.color,
|
|
44
|
+
fontFamily: sized === null || sized === void 0 ? void 0 : sized.fontFamily,
|
|
45
|
+
fontSize: sized === null || sized === void 0 ? void 0 : sized.fontSize,
|
|
46
|
+
fontStyle: sized === null || sized === void 0 ? void 0 : sized.fontStyle,
|
|
47
|
+
fontWeight: sized === null || sized === void 0 ? void 0 : sized.fontWeight,
|
|
48
|
+
letterSpacing: sized === null || sized === void 0 ? void 0 : sized.letterSpacing,
|
|
49
|
+
lineHeight: sized === null || sized === void 0 ? void 0 : sized.lineHeight,
|
|
50
|
+
textTransform: sized === null || sized === void 0 ? void 0 : sized.textTransform,
|
|
51
|
+
paddingVertical: sized === null || sized === void 0 ? void 0 : sized.paddingVertical,
|
|
52
|
+
paddingHorizontal: sized === null || sized === void 0 ? void 0 : sized.paddingHorizontal,
|
|
53
|
+
height
|
|
54
|
+
};
|
|
53
55
|
};
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var {
|
|
58
|
-
props
|
|
59
|
-
} = extras;
|
|
60
|
-
var buttonStyles = getButtonSized(val, extras);
|
|
61
|
-
var fontStyle = getFontSized(val, extras);
|
|
62
|
-
var _props_rows;
|
|
63
|
-
var lines = (_props_rows = props.rows) !== null && _props_rows !== void 0 ? _props_rows : props.numberOfLines;
|
|
64
|
-
var height = typeof lines === "number" ? lines * getVariableValue(fontStyle.lineHeight) : "auto";
|
|
65
|
-
if (!isWeb && fontStyle) {
|
|
66
|
-
delete fontStyle["lineHeight"];
|
|
67
|
-
}
|
|
68
|
-
var paddingVertical = getSpace(val, {
|
|
69
|
-
shift: -2,
|
|
70
|
-
bounds: [2]
|
|
71
|
-
});
|
|
72
|
-
var paddingHorizontal = getSpace(val, {
|
|
73
|
-
shift: -1,
|
|
74
|
-
bounds: [2]
|
|
75
|
-
});
|
|
76
|
-
return {
|
|
77
|
-
...buttonStyles,
|
|
78
|
-
...fontStyle,
|
|
79
|
-
paddingVertical,
|
|
80
|
-
paddingHorizontal,
|
|
81
|
-
height
|
|
82
|
-
};
|
|
56
|
+
var resolveMultilineInputSize = function(props, env) {
|
|
57
|
+
if (!(props.rows > 1 || props.multiline || props.numberOfLines > 1)) return;
|
|
58
|
+
return resolveTextAreaSize(props, env);
|
|
83
59
|
};
|
|
84
60
|
var INPUT_NAME = "Input";
|
|
85
61
|
var styledBody = [{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
false: defaultStyles
|
|
97
|
-
},
|
|
98
|
-
size: {
|
|
99
|
-
"...size": inputSizeVariant
|
|
100
|
-
},
|
|
101
|
-
disabled: {
|
|
102
|
-
true: {}
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
defaultVariants: {
|
|
106
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
107
|
-
}
|
|
108
|
-
}, {
|
|
109
|
-
isInput: true,
|
|
110
|
-
accept: {
|
|
111
|
-
placeholderTextColor: "color",
|
|
112
|
-
selectionColor: "color",
|
|
113
|
-
cursorColor: "color",
|
|
114
|
-
selectionHandleColor: "color",
|
|
115
|
-
underlineColorAndroid: "color"
|
|
116
|
-
},
|
|
117
|
-
validStyles: Text.staticConfig.validStyles
|
|
118
|
-
}];
|
|
119
|
-
export { INPUT_NAME, defaultStyles, inputSizeVariant, styledBody, textAreaSizeVariant };
|
|
62
|
+
name: INPUT_NAME,
|
|
63
|
+
render: "input",
|
|
64
|
+
...defaultStyles,
|
|
65
|
+
variants: {
|
|
66
|
+
size: inputSizeVariant,
|
|
67
|
+
disabled: { true: {} }
|
|
68
|
+
}
|
|
69
|
+
}, { isInput: true }];
|
|
70
|
+
|
|
71
|
+
export { INPUT_NAME, defaultStyles, inputSizeVariant, resolveMultilineInputSize, resolveTextAreaSize, styledBody, textAreaSizeVariant };
|
|
120
72
|
//# sourceMappingURL=shared.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"shared.native.js","names":[],"sources":["esm/shared.native.js"],"sourcesContent":["import { getVariableValue, isWeb, resolveSize, styled } from \"@tamagui/core\";\nimport { getFontSized } from \"@tamagui/get-font-sized\";\nvar defaultStyles = {\n size: true,\n outlineWidth: 0,\n tabIndex: 0,\n // this fixes a flex bug where it overflows container\n minWidth: 0\n};\nvar inputSizeVariant = styled.dynamic(function() {\n var val = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true, env = arguments.length > 1 ? arguments[1] : void 0;\n var { frame } = resolveSize(val, env);\n var fontStyle = getFontSized(val, env);\n return {\n color: fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.color,\n fontFamily: fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.fontFamily,\n fontSize: fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.fontSize,\n fontStyle: fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.fontStyle,\n fontWeight: fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.fontWeight,\n letterSpacing: fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.letterSpacing,\n lineHeight: isWeb ? fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.lineHeight : void 0,\n textTransform: fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.textTransform,\n ...frame\n };\n});\nvar textAreaSizeVariant = styled.dynamic(function() {\n var val = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true, env = arguments.length > 1 ? arguments[1] : void 0;\n return {\n ...inputSizeVariant(val, env),\n height: \"auto\"\n };\n});\nvar resolveTextAreaSize = function(props, env) {\n var _props_size;\n var sized = textAreaSizeVariant((_props_size = props.size) !== null && _props_size !== void 0 ? _props_size : true, env);\n var _props_size1;\n var fontStyle = getFontSized((_props_size1 = props.size) !== null && _props_size1 !== void 0 ? _props_size1 : true, env);\n var _props_rows;\n var lines = (_props_rows = props.rows) !== null && _props_rows !== void 0 ? _props_rows : props.numberOfLines;\n var height = typeof lines === \"number\" ? lines * getVariableValue(fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.lineHeight) : sized === null || sized === void 0 ? void 0 : sized.height;\n return {\n borderRadius: sized === null || sized === void 0 ? void 0 : sized.borderRadius,\n color: sized === null || sized === void 0 ? void 0 : sized.color,\n fontFamily: sized === null || sized === void 0 ? void 0 : sized.fontFamily,\n fontSize: sized === null || sized === void 0 ? void 0 : sized.fontSize,\n fontStyle: sized === null || sized === void 0 ? void 0 : sized.fontStyle,\n fontWeight: sized === null || sized === void 0 ? void 0 : sized.fontWeight,\n letterSpacing: sized === null || sized === void 0 ? void 0 : sized.letterSpacing,\n lineHeight: sized === null || sized === void 0 ? void 0 : sized.lineHeight,\n textTransform: sized === null || sized === void 0 ? void 0 : sized.textTransform,\n paddingVertical: sized === null || sized === void 0 ? void 0 : sized.paddingVertical,\n paddingHorizontal: sized === null || sized === void 0 ? void 0 : sized.paddingHorizontal,\n height\n };\n};\nvar resolveMultilineInputSize = function(props, env) {\n if (!(props.rows > 1 || props.multiline || props.numberOfLines > 1)) return;\n return resolveTextAreaSize(props, env);\n};\nvar INPUT_NAME = \"Input\";\nvar styledBody = [\n {\n name: INPUT_NAME,\n render: \"input\",\n ...defaultStyles,\n variants: {\n size: inputSizeVariant,\n disabled: {\n true: {}\n }\n }\n },\n {\n isInput: true\n }\n];\nexport {\n INPUT_NAME,\n defaultStyles,\n inputSizeVariant,\n resolveMultilineInputSize,\n resolveTextAreaSize,\n styledBody,\n textAreaSizeVariant\n};\n//# sourceMappingURL=shared.js.map\n"],"mappings":";;;;AAEA,IAAI,gBAAgB;CAClB,MAAM;CACN,cAAc;CACd,UAAU;CAEV,UAAU;AACZ;AACA,IAAI,mBAAmB,OAAO,QAAQ,WAAW;CAC/C,IAAI,MAAM,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK,MAAM,MAAM,UAAU,SAAS,IAAI,UAAU,KAAK,KAAK;CAClI,IAAI,EAAE,UAAU,YAAY,KAAK,GAAG;CACpC,IAAI,YAAY,aAAa,KAAK,GAAG;CACrC,OAAO;EACL,OAAO,cAAc,QAAQ,cAAc,KAAK,IAAI,KAAK,IAAI,UAAU;EACvE,YAAY,cAAc,QAAQ,cAAc,KAAK,IAAI,KAAK,IAAI,UAAU;EAC5E,UAAU,cAAc,QAAQ,cAAc,KAAK,IAAI,KAAK,IAAI,UAAU;EAC1E,WAAW,cAAc,QAAQ,cAAc,KAAK,IAAI,KAAK,IAAI,UAAU;EAC3E,YAAY,cAAc,QAAQ,cAAc,KAAK,IAAI,KAAK,IAAI,UAAU;EAC5E,eAAe,cAAc,QAAQ,cAAc,KAAK,IAAI,KAAK,IAAI,UAAU;EAC/E,YAAY,QAAQ,cAAc,QAAQ,cAAc,KAAK,IAAI,KAAK,IAAI,UAAU,aAAa,KAAK;EACtG,eAAe,cAAc,QAAQ,cAAc,KAAK,IAAI,KAAK,IAAI,UAAU;EAC/E,GAAG;CACL;AACF,CAAC;AACD,IAAI,sBAAsB,OAAO,QAAQ,WAAW;CAClD,IAAI,MAAM,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK,MAAM,MAAM,UAAU,SAAS,IAAI,UAAU,KAAK,KAAK;CAClI,OAAO;EACL,GAAG,iBAAiB,KAAK,GAAG;EAC5B,QAAQ;CACV;AACF,CAAC;AACD,IAAI,sBAAsB,SAAS,OAAO,KAAK;CAC7C,IAAI;CACJ,IAAI,QAAQ,qBAAqB,cAAc,MAAM,UAAU,QAAQ,gBAAgB,KAAK,IAAI,cAAc,MAAM,GAAG;CACvH,IAAI;CACJ,IAAI,YAAY,cAAc,eAAe,MAAM,UAAU,QAAQ,iBAAiB,KAAK,IAAI,eAAe,MAAM,GAAG;CACvH,IAAI;CACJ,IAAI,SAAS,cAAc,MAAM,UAAU,QAAQ,gBAAgB,KAAK,IAAI,cAAc,MAAM;CAChG,IAAI,SAAS,OAAO,UAAU,WAAW,QAAQ,iBAAiB,cAAc,QAAQ,cAAc,KAAK,IAAI,KAAK,IAAI,UAAU,UAAU,IAAI,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;CACpM,OAAO;EACL,cAAc,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;EAClE,OAAO,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;EAC3D,YAAY,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;EAChE,UAAU,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;EAC9D,WAAW,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;EAC/D,YAAY,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;EAChE,eAAe,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;EACnE,YAAY,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;EAChE,eAAe,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;EACnE,iBAAiB,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;EACrE,mBAAmB,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;EACvE;CACF;AACF;AACA,IAAI,4BAA4B,SAAS,OAAO,KAAK;CACnD,IAAI,EAAE,MAAM,OAAO,KAAK,MAAM,aAAa,MAAM,gBAAgB,IAAI;CACrE,OAAO,oBAAoB,OAAO,GAAG;AACvC;AACA,IAAI,aAAa;AACjB,IAAI,aAAa,CACf;CACE,MAAM;CACN,QAAQ;CACR,GAAG;CACH,UAAU;EACR,MAAM;EACN,UAAU,EACR,MAAM,CAAC,EACT;CACF;AACF,GACA,EACE,SAAS,KACX,CACF"}
|
package/dist/esm/types.mjs
CHANGED
package/dist/esm/types.native.js
CHANGED
package/dist/jsx/Input.mjs
CHANGED
|
@@ -1,146 +1,66 @@
|
|
|
1
|
-
import { View,
|
|
1
|
+
import { View, createStyledHOC, styled } from "@tamagui/core";
|
|
2
2
|
import { registerFocusable } from "@tamagui/focusable";
|
|
3
3
|
import { useWebRef } from "@tamagui/element";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import { styledBody } from "./shared.mjs";
|
|
5
|
+
import { resolveMultilineInputSize, styledBody } from "./shared.mjs";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
returnKeyLabel,
|
|
64
|
-
textBreakStrategy,
|
|
65
|
-
textAlignVertical,
|
|
66
|
-
verticalAlign,
|
|
67
|
-
showSoftInputOnFocus,
|
|
68
|
-
numberOfLines,
|
|
69
|
-
...rest
|
|
70
|
-
} = props;
|
|
71
|
-
const {
|
|
72
|
-
ref,
|
|
73
|
-
composedRef
|
|
74
|
-
} = useWebRef(_forwardedRef);
|
|
75
|
-
const theme = useTheme();
|
|
76
|
-
const autoCorrect = autoCorrectProp === true ? "on" : autoCorrectProp === false ? "off" : autoCorrectProp;
|
|
77
|
-
const autoCapitalize = autoCapitalizeProp === "sentences" || autoCapitalizeProp === "words" ? "on" : autoCapitalizeProp === "none" || autoCapitalizeProp === "characters" ? "off" : autoCapitalizeProp;
|
|
78
|
-
React.useEffect(() => {
|
|
79
|
-
if (!onSelectionChange) return;
|
|
80
|
-
const node = ref.current;
|
|
81
|
-
if (!node) return;
|
|
82
|
-
const handleSelectionChange = () => {
|
|
83
|
-
onSelectionChange({
|
|
84
|
-
nativeEvent: {
|
|
85
|
-
selection: {
|
|
86
|
-
start: node.selectionStart ?? 0,
|
|
87
|
-
end: node.selectionEnd ?? 0
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
node.addEventListener("select", handleSelectionChange);
|
|
93
|
-
return () => node.removeEventListener("select", handleSelectionChange);
|
|
94
|
-
}, [onSelectionChange]);
|
|
95
|
-
React.useEffect(() => {
|
|
96
|
-
if (selection && ref.current) {
|
|
97
|
-
ref.current.setSelectionRange(selection.start, selection.end ?? selection.start);
|
|
98
|
-
}
|
|
99
|
-
}, [selection?.start, selection?.end]);
|
|
100
|
-
React.useEffect(() => {
|
|
101
|
-
if (!id || disabled) return;
|
|
102
|
-
return registerFocusable(id, {
|
|
103
|
-
focusAndSelect: () => ref.current?.focus(),
|
|
104
|
-
focus: () => ref.current?.focus()
|
|
105
|
-
});
|
|
106
|
-
}, [id, disabled]);
|
|
107
|
-
const handleKeyDown = e => {
|
|
108
|
-
if (e.key === "Enter" && onSubmitEditing) {
|
|
109
|
-
onSubmitEditing({
|
|
110
|
-
nativeEvent: {
|
|
111
|
-
text: e.target.value
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
rest.onKeyDown?.(e);
|
|
116
|
-
};
|
|
117
|
-
const handleChange = e => {
|
|
118
|
-
onChangeText?.(e.target.value);
|
|
119
|
-
rest.onChange?.(e);
|
|
120
|
-
};
|
|
121
|
-
const finalProps = {
|
|
122
|
-
...rest,
|
|
123
|
-
disabled,
|
|
124
|
-
id,
|
|
125
|
-
rows,
|
|
126
|
-
autoCorrect,
|
|
127
|
-
autoCapitalize,
|
|
128
|
-
onKeyDown: onSubmitEditing ? handleKeyDown : rest.onKeyDown,
|
|
129
|
-
onChange: onChangeText ? handleChange : rest.onChange,
|
|
130
|
-
style: {
|
|
131
|
-
...rest.style,
|
|
132
|
-
...(placeholderTextColor && {
|
|
133
|
-
"--t_placeholderColor": theme[placeholderTextColor]?.variable || placeholderTextColor
|
|
134
|
-
}),
|
|
135
|
-
...(selectionColor && {
|
|
136
|
-
"--t_selectionColor": theme[selectionColor]?.variable || selectionColor
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
return /* @__PURE__ */jsx(StyledInput, {
|
|
141
|
-
ref: composedRef,
|
|
142
|
-
...finalProps
|
|
143
|
-
});
|
|
7
|
+
|
|
8
|
+
const StyledInput = styled(View, styledBody[0], styledBody[1]).resolve(resolveMultilineInputSize);
|
|
9
|
+
const Input = createStyledHOC(StyledInput, (props, _forwardedRef) => {
|
|
10
|
+
const { disabled, id, onChangeText, onSubmitEditing, onSelectionChange, selection, rows, keyboardAppearance, returnKeyType, submitBehavior, blurOnSubmit, caretHidden, contextMenuHidden, selectTextOnFocus, secureTextEntry, maxFontSizeMultiplier, allowFontScaling, multiline, keyboardType, autoCapitalize: autoCapitalizeProp, autoCorrect: autoCorrectProp, autoFocusNative, textContentType, onEndEditing, onContentSizeChange, onScroll, onKeyPress, clearButtonMode, clearTextOnFocus, enablesReturnKeyAutomatically, dataDetectorTypes, scrollEnabled, passwordRules, rejectResponderTermination, spellCheck, lineBreakStrategyIOS, lineBreakModeIOS, smartInsertDelete, inputAccessoryViewID, inputAccessoryViewButtonLabel, disableKeyboardShortcuts, underlineColorAndroid, importantForAutofill, disableFullscreenUI, inlineImageLeft, inlineImagePadding, returnKeyLabel, textBreakStrategy, textAlignVertical, verticalAlign, showSoftInputOnFocus, numberOfLines, ...rest } = props;
|
|
11
|
+
const { ref, composedRef } = useWebRef(_forwardedRef);
|
|
12
|
+
const autoCorrect = autoCorrectProp === true ? "on" : autoCorrectProp === false ? "off" : autoCorrectProp;
|
|
13
|
+
const autoCapitalize = autoCapitalizeProp === "sentences" || autoCapitalizeProp === "words" ? "on" : autoCapitalizeProp === "none" || autoCapitalizeProp === "characters" ? "off" : autoCapitalizeProp;
|
|
14
|
+
React.useEffect(() => {
|
|
15
|
+
if (!onSelectionChange) return;
|
|
16
|
+
const node = ref.current;
|
|
17
|
+
if (!node) return;
|
|
18
|
+
const handleSelectionChange = () => {
|
|
19
|
+
onSelectionChange({ nativeEvent: { selection: {
|
|
20
|
+
start: node.selectionStart ?? 0,
|
|
21
|
+
end: node.selectionEnd ?? 0
|
|
22
|
+
} } });
|
|
23
|
+
};
|
|
24
|
+
node.addEventListener("select", handleSelectionChange);
|
|
25
|
+
return () => node.removeEventListener("select", handleSelectionChange);
|
|
26
|
+
}, [onSelectionChange]);
|
|
27
|
+
React.useEffect(() => {
|
|
28
|
+
if (selection && ref.current) {
|
|
29
|
+
ref.current.setSelectionRange(selection.start, selection.end ?? selection.start);
|
|
30
|
+
}
|
|
31
|
+
}, [selection?.start, selection?.end]);
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
if (!id || disabled) return;
|
|
34
|
+
return registerFocusable(id, {
|
|
35
|
+
focusAndSelect: () => ref.current?.focus(),
|
|
36
|
+
focus: () => ref.current?.focus()
|
|
37
|
+
});
|
|
38
|
+
}, [id, disabled]);
|
|
39
|
+
const handleKeyDown = (e) => {
|
|
40
|
+
if (e.key === "Enter" && onSubmitEditing) {
|
|
41
|
+
onSubmitEditing({ nativeEvent: { text: e.target.value } });
|
|
42
|
+
}
|
|
43
|
+
rest.onKeyDown?.(e);
|
|
44
|
+
};
|
|
45
|
+
const handleChange = (e) => {
|
|
46
|
+
onChangeText?.(e.target.value);
|
|
47
|
+
rest.onChange?.(e);
|
|
48
|
+
};
|
|
49
|
+
const finalProps = {
|
|
50
|
+
...rest,
|
|
51
|
+
disabled,
|
|
52
|
+
id,
|
|
53
|
+
rows,
|
|
54
|
+
autoCorrect,
|
|
55
|
+
autoCapitalize,
|
|
56
|
+
onKeyDown: onSubmitEditing ? handleKeyDown : rest.onKeyDown,
|
|
57
|
+
onChange: onChangeText ? handleChange : rest.onChange
|
|
58
|
+
};
|
|
59
|
+
return /* @__PURE__ */ jsx(StyledInput, {
|
|
60
|
+
ref: composedRef,
|
|
61
|
+
...finalProps
|
|
62
|
+
});
|
|
144
63
|
});
|
|
64
|
+
|
|
145
65
|
export { Input };
|
|
146
66
|
//# sourceMappingURL=Input.mjs.map
|