@mirai/ui 1.0.206 → 1.0.207
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 +1 -0
- package/build/components/InputSelect/InputSelect.js +9 -3
- package/build/components/InputSelect/InputSelect.js.map +1 -1
- package/build/components/InputSelect/InputSelect.stories.js +1 -0
- package/build/components/InputSelect/InputSelect.stories.js.map +1 -1
- package/build/components/InputSelect/__tests__/__snapshots__/InputSelect.test.js.snap +74 -0
- package/build/components/InputText/InputText.js +6 -6
- package/build/components/InputText/InputText.js.map +1 -1
- package/build/components/InputText/__tests__/__snapshots__/InputText.test.js.snap +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -791,6 +791,7 @@ export const Story = (props) => {
|
|
|
791
791
|
|
|
792
792
|
A select input component that receives the following props:
|
|
793
793
|
|
|
794
|
+
- `caption:string` a support text (Ex. currency symbol)
|
|
794
795
|
- `disabled:boolean` applying 'disabled' attribute
|
|
795
796
|
- `error:boolean` indicating whether there is an error in the input
|
|
796
797
|
- `hint:string` text with additional info to be displayed below the input
|
|
@@ -11,7 +11,7 @@ var _helpers = require("../../helpers");
|
|
|
11
11
|
var _primitives = require("../../primitives");
|
|
12
12
|
var _InputTextModule = _interopRequireDefault(require("../InputText/InputText.module.css"));
|
|
13
13
|
var _partials = require("../InputText/partials");
|
|
14
|
-
var _excluded = ["disabled", "error", "hint", "label", "showRequired", "showState", "success", "warning", "onChange", "onEnter", "onLeave"];
|
|
14
|
+
var _excluded = ["caption", "disabled", "error", "hint", "label", "showRequired", "showState", "success", "warning", "onChange", "onEnter", "onLeave"];
|
|
15
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -26,7 +26,8 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
26
26
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
27
27
|
var InputSelect = function InputSelect(_ref) {
|
|
28
28
|
var _others$value;
|
|
29
|
-
var
|
|
29
|
+
var caption = _ref.caption,
|
|
30
|
+
disabled = _ref.disabled,
|
|
30
31
|
error = _ref.error,
|
|
31
32
|
hint = _ref.hint,
|
|
32
33
|
label = _ref.label,
|
|
@@ -72,7 +73,11 @@ var InputSelect = function InputSelect(_ref) {
|
|
|
72
73
|
}, /*#__PURE__*/_react.default.createElement(_primitives.View, {
|
|
73
74
|
row: true,
|
|
74
75
|
className: (0, _helpers.styles)(_InputTextModule.default.inputBorder, disabled && _InputTextModule.default.disabled, focus && !error && _InputTextModule.default.focus, error && _InputTextModule.default.error)
|
|
75
|
-
}, /*#__PURE__*/_react.default.createElement(_primitives.
|
|
76
|
+
}, caption && /*#__PURE__*/_react.default.createElement(_primitives.Text, {
|
|
77
|
+
action: true,
|
|
78
|
+
lighten: true,
|
|
79
|
+
className: _InputTextModule.default.caption
|
|
80
|
+
}, caption), /*#__PURE__*/_react.default.createElement(_primitives.View, {
|
|
76
81
|
wide: true,
|
|
77
82
|
className: _InputTextModule.default.content
|
|
78
83
|
}, label && /*#__PURE__*/_react.default.createElement(_partials.Label, {
|
|
@@ -106,6 +111,7 @@ var InputSelect = function InputSelect(_ref) {
|
|
|
106
111
|
exports.InputSelect = InputSelect;
|
|
107
112
|
InputSelect.displayName = 'Component:InputSelect';
|
|
108
113
|
InputSelect.propTypes = {
|
|
114
|
+
caption: _propTypes.default.string,
|
|
109
115
|
disabled: _propTypes.default.bool,
|
|
110
116
|
error: _propTypes.default.bool,
|
|
111
117
|
hint: _propTypes.default.string,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputSelect.js","names":["InputSelect","disabled","error","hint","label","showRequired","showState","success","warning","onChange","onEnter","onLeave","others","useState","focus","setFocus","handleChange","value","event","target","blur","handleEnter","handleLeave","has","undefined","length","stateIcon","role","styles","style","inputContainer","className","inputBorder","content","required","input","withLabel","empty","ICON","EXPAND_MORE","icon","select","displayName","propTypes","PropTypes","
|
|
1
|
+
{"version":3,"file":"InputSelect.js","names":["InputSelect","caption","disabled","error","hint","label","showRequired","showState","success","warning","onChange","onEnter","onLeave","others","useState","focus","setFocus","handleChange","value","event","target","blur","handleEnter","handleLeave","has","undefined","length","stateIcon","role","styles","style","inputContainer","className","inputBorder","content","required","input","withLabel","empty","ICON","EXPAND_MORE","icon","select","displayName","propTypes","PropTypes","string","bool","name","isRequired","func"],"sources":["../../../src/components/InputSelect/InputSelect.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useState } from 'react';\n\nimport { styles } from '../../helpers';\nimport { Icon, ICON, Select, Text, View } from '../../primitives';\nimport style from '../InputText/InputText.module.css';\nimport { Hint, IconState, Label } from '../InputText/partials';\n\nconst InputSelect = ({\n caption,\n disabled,\n error,\n hint,\n label,\n showRequired = false,\n showState = true,\n success,\n warning,\n onChange = () => {},\n onEnter = () => {},\n onLeave = () => {},\n ...others\n}) => {\n const [focus, setFocus] = useState(false);\n\n const handleChange = (value, event) => {\n onChange(value, event);\n event.target?.blur();\n };\n\n const handleEnter = (event) => {\n setFocus(true);\n onEnter(event);\n };\n\n const handleLeave = (event) => {\n setFocus(false);\n onLeave(event);\n };\n\n const has = {\n label: !!label,\n value: others.value !== undefined && others.value?.length > 0,\n stateIcon: showState && (error || success || warning),\n };\n\n return (\n <View\n role={others.role || 'input-select'}\n className={styles(style.inputContainer, others.className)}\n style={others.style}\n >\n <View\n row\n className={styles(\n style.inputBorder,\n disabled && style.disabled,\n focus && !error && style.focus,\n error && style.error,\n )}\n >\n {caption && (\n <Text action lighten className={style.caption}>\n {caption}\n </Text>\n )}\n\n <View wide className={style.content}>\n {label && (\n <Label\n {...{\n disabled,\n error,\n focus,\n label,\n required: showRequired && others.required,\n value: others.value,\n }}\n />\n )}\n\n <Select\n {...others}\n disabled={disabled}\n value={others.value || ''}\n className={styles(\n style.input,\n has.label && style.withLabel,\n !!label && !(focus || error || has.value) && style.empty,\n )}\n style={undefined}\n onChange={handleChange}\n onEnter={handleEnter}\n onLeave={handleLeave}\n />\n </View>\n\n {!disabled && <Icon value={ICON.EXPAND_MORE} className={styles(style.icon, style.select)} />}\n {has.stateIcon && <IconState {...{ error, success, warning }} />}\n </View>\n\n {hint && <Hint {...{ disabled, error, hint }} />}\n </View>\n );\n};\n\nInputSelect.displayName = 'Component:InputSelect';\n\nInputSelect.propTypes = {\n caption: PropTypes.string,\n disabled: PropTypes.bool,\n error: PropTypes.bool,\n hint: PropTypes.string,\n label: PropTypes.string,\n name: PropTypes.string.isRequired,\n showRequired: PropTypes.bool,\n showState: PropTypes.bool,\n success: PropTypes.bool,\n warning: PropTypes.bool,\n onChange: PropTypes.func,\n onEnter: PropTypes.func,\n onLeave: PropTypes.func,\n};\n\nexport { InputSelect };\n"],"mappings":";;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AAS,CAACE,IAAI;EACvBtC,OAAO,EAAEoC,kBAAS,CAACE,IAAI;EACvBrC,QAAQ,EAAEmC,kBAAS,CAACK,IAAI;EACxBvC,OAAO,EAAEkC,kBAAS,CAACK,IAAI;EACvBtC,OAAO,EAAEiC,kBAAS,CAACK;AACrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputSelect.stories.js","names":["title","Story","props","useState","value","setValue","handleChange","next","others","console","log","handleEnter","handleLeave","storyName","args","disabled","emptyOption","error","hint","label","name","required","showRequired","showState","success","warning","options","testId","style","argTypes"],"sources":["../../../src/components/InputSelect/InputSelect.stories.jsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport { InputSelect } from './InputSelect';\n\nexport default { title: 'Components' };\n\nexport const Story = (props) => {\n const [value, setValue] = useState('two');\n\n const handleChange = (next, ...others) => {\n setValue(next);\n console.log('<InputSelect>::onChange', next, ...others);\n };\n\n const handleEnter = (...others) => console.log('<InputSelect>::onEnter', ...others);\n\n const handleLeave = (...others) => console.log('<InputSelect>::onLeave', ...others);\n\n return <InputSelect {...props} value={value} onChange={handleChange} onEnter={handleEnter} onLeave={handleLeave} />;\n};\n\nStory.storyName = 'InputSelect';\n\nStory.args = {\n disabled: false,\n emptyOption: 'Select one option...',\n error: false,\n hint: 'hint',\n label: 'label',\n name: 'name',\n required: false,\n showRequired: false,\n showState: true,\n success: false,\n warning: false,\n options: ['one', 'two', 'three', 'four', 'five'],\n // inherited properties\n testId: 'test-story',\n style: {},\n};\n\nStory.argTypes = {};\n"],"mappings":";;;;;;;AAAA;AAEA;AAA4C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAE7B;EAAEA,KAAK,EAAE;AAAa,CAAC;AAAA;AAE/B,IAAMC,KAAK,GAAG,SAARA,KAAK,CAAIC,KAAK,EAAK;EAC9B,gBAA0B,IAAAC,eAAQ,EAAC,KAAK,CAAC;IAAA;IAAlCC,KAAK;IAAEC,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+
{"version":3,"file":"InputSelect.stories.js","names":["title","Story","props","useState","value","setValue","handleChange","next","others","console","log","handleEnter","handleLeave","storyName","args","caption","disabled","emptyOption","error","hint","label","name","required","showRequired","showState","success","warning","options","testId","style","argTypes"],"sources":["../../../src/components/InputSelect/InputSelect.stories.jsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport { InputSelect } from './InputSelect';\n\nexport default { title: 'Components' };\n\nexport const Story = (props) => {\n const [value, setValue] = useState('two');\n\n const handleChange = (next, ...others) => {\n setValue(next);\n console.log('<InputSelect>::onChange', next, ...others);\n };\n\n const handleEnter = (...others) => console.log('<InputSelect>::onEnter', ...others);\n\n const handleLeave = (...others) => console.log('<InputSelect>::onLeave', ...others);\n\n return <InputSelect {...props} value={value} onChange={handleChange} onEnter={handleEnter} onLeave={handleLeave} />;\n};\n\nStory.storyName = 'InputSelect';\n\nStory.args = {\n caption: '%',\n disabled: false,\n emptyOption: 'Select one option...',\n error: false,\n hint: 'hint',\n label: 'label',\n name: 'name',\n required: false,\n showRequired: false,\n showState: true,\n success: false,\n warning: false,\n options: ['one', 'two', 'three', 'four', 'five'],\n // inherited properties\n testId: 'test-story',\n style: {},\n};\n\nStory.argTypes = {};\n"],"mappings":";;;;;;;AAAA;AAEA;AAA4C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAE7B;EAAEA,KAAK,EAAE;AAAa,CAAC;AAAA;AAE/B,IAAMC,KAAK,GAAG,SAARA,KAAK,CAAIC,KAAK,EAAK;EAC9B,gBAA0B,IAAAC,eAAQ,EAAC,KAAK,CAAC;IAAA;IAAlCC,KAAK;IAAEC,QAAQ;EAEtB,IAAMC,YAAY,GAAG,SAAfA,YAAY,CAAIC,IAAI,EAAgB;IAAA;IACxCF,QAAQ,CAACE,IAAI,CAAC;IAAC,kCADcC,MAAM;MAANA,MAAM;IAAA;IAEnC,YAAAC,OAAO,EAACC,GAAG,kBAAC,yBAAyB,EAAEH,IAAI,SAAKC,MAAM,EAAC;EACzD,CAAC;EAED,IAAMG,WAAW,GAAG,SAAdA,WAAW;IAAA;IAAA,mCAAOH,MAAM;MAANA,MAAM;IAAA;IAAA,OAAK,aAAAC,OAAO,EAACC,GAAG,mBAAC,wBAAwB,SAAKF,MAAM,EAAC;EAAA;EAEnF,IAAMI,WAAW,GAAG,SAAdA,WAAW;IAAA;IAAA,mCAAOJ,MAAM;MAANA,MAAM;IAAA;IAAA,OAAK,aAAAC,OAAO,EAACC,GAAG,mBAAC,wBAAwB,SAAKF,MAAM,EAAC;EAAA;EAEnF,oBAAO,6BAAC,wBAAW,eAAKN,KAAK;IAAE,KAAK,EAAEE,KAAM;IAAC,QAAQ,EAAEE,YAAa;IAAC,OAAO,EAAEK,WAAY;IAAC,OAAO,EAAEC;EAAY,GAAG;AACrH,CAAC;AAAC;AAEFX,KAAK,CAACY,SAAS,GAAG,aAAa;AAE/BZ,KAAK,CAACa,IAAI,GAAG;EACXC,OAAO,EAAE,GAAG;EACZC,QAAQ,EAAE,KAAK;EACfC,WAAW,EAAE,sBAAsB;EACnCC,KAAK,EAAE,KAAK;EACZC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,QAAQ,EAAE,KAAK;EACfC,YAAY,EAAE,KAAK;EACnBC,SAAS,EAAE,IAAI;EACfC,OAAO,EAAE,KAAK;EACdC,OAAO,EAAE,KAAK;EACdC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;EAChD;EACAC,MAAM,EAAE,YAAY;EACpBC,KAAK,EAAE,CAAC;AACV,CAAC;AAED5B,KAAK,CAAC6B,QAAQ,GAAG,CAAC,CAAC"}
|
|
@@ -69,6 +69,80 @@ exports[`component:<InputSelect> inherit:className 1`] = `
|
|
|
69
69
|
</DocumentFragment>
|
|
70
70
|
`;
|
|
71
71
|
|
|
72
|
+
exports[`component:<InputSelect> prop:caption 1`] = `
|
|
73
|
+
<DocumentFragment>
|
|
74
|
+
<div
|
|
75
|
+
class="view inputContainer"
|
|
76
|
+
>
|
|
77
|
+
<div
|
|
78
|
+
class="view row inputBorder"
|
|
79
|
+
>
|
|
80
|
+
<span
|
|
81
|
+
class="text action lighten caption"
|
|
82
|
+
>
|
|
83
|
+
caption
|
|
84
|
+
</span>
|
|
85
|
+
<div
|
|
86
|
+
class="view wide content"
|
|
87
|
+
>
|
|
88
|
+
<select
|
|
89
|
+
class="select empty input"
|
|
90
|
+
name="name"
|
|
91
|
+
>
|
|
92
|
+
<option
|
|
93
|
+
value="one"
|
|
94
|
+
>
|
|
95
|
+
one
|
|
96
|
+
</option>
|
|
97
|
+
<option
|
|
98
|
+
value="two"
|
|
99
|
+
>
|
|
100
|
+
two
|
|
101
|
+
</option>
|
|
102
|
+
<option
|
|
103
|
+
value="three"
|
|
104
|
+
>
|
|
105
|
+
three
|
|
106
|
+
</option>
|
|
107
|
+
<option
|
|
108
|
+
value="four"
|
|
109
|
+
>
|
|
110
|
+
four
|
|
111
|
+
</option>
|
|
112
|
+
<option
|
|
113
|
+
value="five"
|
|
114
|
+
>
|
|
115
|
+
five
|
|
116
|
+
</option>
|
|
117
|
+
</select>
|
|
118
|
+
</div>
|
|
119
|
+
<span
|
|
120
|
+
class="icon headline-3 icon select"
|
|
121
|
+
>
|
|
122
|
+
<svg
|
|
123
|
+
fill="currentColor"
|
|
124
|
+
height="1em"
|
|
125
|
+
stroke="currentColor"
|
|
126
|
+
stroke-width="0"
|
|
127
|
+
viewBox="0 0 24 24"
|
|
128
|
+
width="1em"
|
|
129
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
130
|
+
>
|
|
131
|
+
<path
|
|
132
|
+
d="M24 24H0V0h24v24z"
|
|
133
|
+
fill="none"
|
|
134
|
+
opacity=".87"
|
|
135
|
+
/>
|
|
136
|
+
<path
|
|
137
|
+
d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6-1.41-1.41z"
|
|
138
|
+
/>
|
|
139
|
+
</svg>
|
|
140
|
+
</span>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
</DocumentFragment>
|
|
144
|
+
`;
|
|
145
|
+
|
|
72
146
|
exports[`component:<InputSelect> prop:disabled 1`] = `
|
|
73
147
|
<DocumentFragment>
|
|
74
148
|
<div
|
|
@@ -99,7 +99,11 @@ var InputText = function InputText(_ref) {
|
|
|
99
99
|
}, has.icon && /*#__PURE__*/_react.default.createElement(_primitives.Icon, {
|
|
100
100
|
value: icon || _primitives.ICON.SEARCH,
|
|
101
101
|
className: (0, _helpers.styles)(_InputTextModule.default.icon, _InputTextModule.default.left, disabled && _InputTextModule.default.disabled, error && _InputTextModule.default.error)
|
|
102
|
-
}), /*#__PURE__*/_react.default.createElement(_primitives.
|
|
102
|
+
}), caption && /*#__PURE__*/_react.default.createElement(_primitives.Text, {
|
|
103
|
+
action: true,
|
|
104
|
+
lighten: true,
|
|
105
|
+
className: _InputTextModule.default.caption
|
|
106
|
+
}, caption), /*#__PURE__*/_react.default.createElement(_primitives.View, {
|
|
103
107
|
wide: true,
|
|
104
108
|
className: _InputTextModule.default.content
|
|
105
109
|
}, label && /*#__PURE__*/_react.default.createElement(_partials.Label, {
|
|
@@ -125,11 +129,7 @@ var InputText = function InputText(_ref) {
|
|
|
125
129
|
return setInputMode(true);
|
|
126
130
|
},
|
|
127
131
|
className: (0, _helpers.styles)(_InputTextModule.default.input, has.label && _InputTextModule.default.withLabel, multiLine && _InputTextModule.default.multiLine)
|
|
128
|
-
}, others.value)),
|
|
129
|
-
action: true,
|
|
130
|
-
lighten: true,
|
|
131
|
-
className: _InputTextModule.default.caption
|
|
132
|
-
}, caption), markdown && /*#__PURE__*/_react.default.createElement(_primitives.Pressable, {
|
|
132
|
+
}, others.value)), markdown && /*#__PURE__*/_react.default.createElement(_primitives.Pressable, {
|
|
133
133
|
onPress: function onPress() {
|
|
134
134
|
return setInputMode(!inputMode);
|
|
135
135
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputText.js","names":["InputText","caption","disabled","error","hint","icon","label","markdown","multiLine","showRequired","showState","success","type","warning","onChange","onEnter","onLeave","others","useState","focus","setFocus","password","setPassword","inputMode","setInputMode","handleChange","value","event","handleEnter","handleLeave","handlePress","is","search","undefined","has","length","stateIcon","role","styles","style","inputContainer","className","inputBorder","ICON","SEARCH","left","content","required","input","withLabel","MARKDOWN","EYE_CLOSE","EYE_OPEN","CLOSE","displayName","propTypes","PropTypes","string","bool","func","name","isRequired"],"sources":["../../../src/components/InputText/InputText.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useState } from 'react';\n\nimport { styles } from '../../helpers';\nimport { ICON, Icon, Input, Pressable, Text, View } from '../../primitives';\nimport style from './InputText.module.css';\nimport { Hint, IconState, Label } from './partials';\n\nconst InputText = ({\n caption,\n disabled,\n error,\n hint,\n icon,\n label,\n markdown,\n multiLine,\n showRequired = false,\n showState = true,\n success,\n type,\n warning,\n onChange = () => {},\n onEnter = () => {},\n onLeave = () => {},\n ...others\n}) => {\n const [focus, setFocus] = useState(false);\n const [password, setPassword] = useState(true);\n const [inputMode, setInputMode] = useState(true);\n\n const handleChange = (value, event) => {\n onChange(value, event);\n };\n\n const handleEnter = (event) => {\n setFocus(true);\n onEnter(event);\n };\n\n const handleLeave = (event) => {\n setFocus(false);\n onLeave(event);\n };\n\n const handlePress = (event) => {\n if (is.password) setPassword(!password);\n else if (is.search) onChange(undefined, event);\n };\n\n const is = {\n password: type === 'password',\n search: type === 'search',\n };\n\n const has = {\n icon: !!icon || is.search,\n label: !!label,\n value: others.value !== undefined && (others.value?.length > 0 || typeof others.value === 'number'),\n stateIcon: showState && (error || success || warning),\n };\n\n return (\n <View\n role={others.role || 'input-text'}\n className={styles(style.inputContainer, others.className)}\n style={others.style}\n >\n <View\n row\n className={styles(\n style.inputBorder,\n disabled && style.disabled,\n error && style.error,\n focus && !error && style.focus,\n )}\n >\n {has.icon && (\n <Icon\n value={icon || ICON.SEARCH}\n className={styles(style.icon, style.left, disabled && style.disabled, error && style.error)}\n />\n )}\n <View wide className={style.content}>\n {label && (\n <Label\n {...{ disabled, error, focus, label, required: showRequired && others.required, value: others.value }}\n />\n )}\n\n {inputMode && (\n <Input\n {...{ disabled, multiLine, ...others }}\n type={!is.password || password ? type : 'text'}\n value={others.value || ''}\n className={styles(style.input, has.label && style.withLabel, multiLine && style.multiLine)}\n onChange={handleChange}\n onEnter={handleEnter}\n onLeave={handleLeave}\n />\n )}\n {markdown && !inputMode && (\n <Text\n markdown\n onClick={() => setInputMode(true)}\n className={styles(style.input, has.label && style.withLabel, multiLine && style.multiLine)}\n >\n {others.value}\n </Text>\n )}\n </View>\n\n {caption && (\n <Text action lighten className={style.caption}>\n {caption}\n </Text>\n )}\n\n {markdown && (\n <Pressable onPress={() => setInputMode(!inputMode)}>\n <Icon value={ICON.MARKDOWN} className={styles(style.icon, inputMode && style.disabled)} />\n </Pressable>\n )}\n\n {(is.password || (is.search && has.value)) && !disabled && (\n <Pressable tabIndex={-1} onPress={handlePress}>\n <Icon\n value={is.password ? (password ? ICON.EYE_CLOSE : ICON.EYE_OPEN) : ICON.CLOSE}\n className={styles(style.icon, style.password)}\n />\n </Pressable>\n )}\n\n {has.stateIcon && <IconState {...{ error, success, warning }} />}\n </View>\n\n {hint && <Hint {...{ disabled, error, hint }} />}\n </View>\n );\n};\n\nInputText.displayName = 'Component:InputText';\n\nInputText.propTypes = {\n caption: PropTypes.string,\n disabled: PropTypes.bool,\n error: PropTypes.bool,\n hint: PropTypes.string,\n icon: PropTypes.func,\n label: PropTypes.string,\n markdown: PropTypes.bool,\n multiLine: PropTypes.bool,\n name: PropTypes.string.isRequired,\n showRequired: PropTypes.bool,\n showState: PropTypes.bool,\n success: PropTypes.bool,\n type: PropTypes.string,\n warning: PropTypes.bool,\n onChange: PropTypes.func,\n onEnter: PropTypes.func,\n onLeave: PropTypes.func,\n};\n\nexport { InputText };\n"],"mappings":";;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AEQ,OAAO,EAAPA,OAAO;IAAEE,OAAO,EAAPA;EAAO,EAAM,CAC3D,EAENT,IAAI,iBAAI,6BAAC,cAAI;IAAOF,QAAQ,EAARA,QAAQ;IAAEC,KAAK,EAALA,KAAK;IAAEC,IAAI,EAAJA;EAAI,EAAM,CAC3C;AAEX,CAAC;AAAC;AAEFJ,SAAS,CAACsD,WAAW,GAAG,qBAAqB;AAE7CtD,SAAS,CAACuD,SAAS,GAAG;EACpBtD,OAAO,EAAEuD,kBAAS,CAACC,MAAM;EACzBvD,QAAQ,EAAEsD,kBAAS,CAACE,IAAI;EACxBvD,KAAK,EAAEqD,kBAAS,CAACE,IAAI;EACrBtD,IAAI,EAAEoD,kBAAS,CAACC,MAAM;EACtBpD,IAAI,EAAEmD,kBAAS,CAACG,IAAI;EACpBrD,KAAK,EAAEkD,kBAAS,CAACC,MAAM;EACvBlD,QAAQ,EAAEiD,kBAAS,CAACE,IAAI;EACxBlD,SAAS,EAAEgD,kBAAS,CAACE,IAAI;EACzBE,IAAI,EAAEJ,kBAAS,CAACC,MAAM,CAACI,UAAU;EACjCpD,YAAY,EAAE+C,kBAAS,CAACE,IAAI;EAC5BhD,SAAS,EAAE8C,kBAAS,CAACE,IAAI;EACzB/C,OAAO,EAAE6C,kBAAS,CAACE,IAAI;EACvB9C,IAAI,EAAE4C,kBAAS,CAACC,MAAM;EACtB5C,OAAO,EAAE2C,kBAAS,CAACE,IAAI;EACvB5C,QAAQ,EAAE0C,kBAAS,CAACG,IAAI;EACxB5C,OAAO,EAAEyC,kBAAS,CAACG,IAAI;EACvB3C,OAAO,EAAEwC,kBAAS,CAACG;AACrB,CAAC"}
|
|
1
|
+
{"version":3,"file":"InputText.js","names":["InputText","caption","disabled","error","hint","icon","label","markdown","multiLine","showRequired","showState","success","type","warning","onChange","onEnter","onLeave","others","useState","focus","setFocus","password","setPassword","inputMode","setInputMode","handleChange","value","event","handleEnter","handleLeave","handlePress","is","search","undefined","has","length","stateIcon","role","styles","style","inputContainer","className","inputBorder","ICON","SEARCH","left","content","required","input","withLabel","MARKDOWN","EYE_CLOSE","EYE_OPEN","CLOSE","displayName","propTypes","PropTypes","string","bool","func","name","isRequired"],"sources":["../../../src/components/InputText/InputText.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useState } from 'react';\n\nimport { styles } from '../../helpers';\nimport { ICON, Icon, Input, Pressable, Text, View } from '../../primitives';\nimport style from './InputText.module.css';\nimport { Hint, IconState, Label } from './partials';\n\nconst InputText = ({\n caption,\n disabled,\n error,\n hint,\n icon,\n label,\n markdown,\n multiLine,\n showRequired = false,\n showState = true,\n success,\n type,\n warning,\n onChange = () => {},\n onEnter = () => {},\n onLeave = () => {},\n ...others\n}) => {\n const [focus, setFocus] = useState(false);\n const [password, setPassword] = useState(true);\n const [inputMode, setInputMode] = useState(true);\n\n const handleChange = (value, event) => {\n onChange(value, event);\n };\n\n const handleEnter = (event) => {\n setFocus(true);\n onEnter(event);\n };\n\n const handleLeave = (event) => {\n setFocus(false);\n onLeave(event);\n };\n\n const handlePress = (event) => {\n if (is.password) setPassword(!password);\n else if (is.search) onChange(undefined, event);\n };\n\n const is = {\n password: type === 'password',\n search: type === 'search',\n };\n\n const has = {\n icon: !!icon || is.search,\n label: !!label,\n value: others.value !== undefined && (others.value?.length > 0 || typeof others.value === 'number'),\n stateIcon: showState && (error || success || warning),\n };\n\n return (\n <View\n role={others.role || 'input-text'}\n className={styles(style.inputContainer, others.className)}\n style={others.style}\n >\n <View\n row\n className={styles(\n style.inputBorder,\n disabled && style.disabled,\n error && style.error,\n focus && !error && style.focus,\n )}\n >\n {has.icon && (\n <Icon\n value={icon || ICON.SEARCH}\n className={styles(style.icon, style.left, disabled && style.disabled, error && style.error)}\n />\n )}\n\n {caption && (\n <Text action lighten className={style.caption}>\n {caption}\n </Text>\n )}\n\n <View wide className={style.content}>\n {label && (\n <Label\n {...{ disabled, error, focus, label, required: showRequired && others.required, value: others.value }}\n />\n )}\n\n {inputMode && (\n <Input\n {...{ disabled, multiLine, ...others }}\n type={!is.password || password ? type : 'text'}\n value={others.value || ''}\n className={styles(style.input, has.label && style.withLabel, multiLine && style.multiLine)}\n onChange={handleChange}\n onEnter={handleEnter}\n onLeave={handleLeave}\n />\n )}\n {markdown && !inputMode && (\n <Text\n markdown\n onClick={() => setInputMode(true)}\n className={styles(style.input, has.label && style.withLabel, multiLine && style.multiLine)}\n >\n {others.value}\n </Text>\n )}\n </View>\n\n {markdown && (\n <Pressable onPress={() => setInputMode(!inputMode)}>\n <Icon value={ICON.MARKDOWN} className={styles(style.icon, inputMode && style.disabled)} />\n </Pressable>\n )}\n\n {(is.password || (is.search && has.value)) && !disabled && (\n <Pressable tabIndex={-1} onPress={handlePress}>\n <Icon\n value={is.password ? (password ? ICON.EYE_CLOSE : ICON.EYE_OPEN) : ICON.CLOSE}\n className={styles(style.icon, style.password)}\n />\n </Pressable>\n )}\n\n {has.stateIcon && <IconState {...{ error, success, warning }} />}\n </View>\n\n {hint && <Hint {...{ disabled, error, hint }} />}\n </View>\n );\n};\n\nInputText.displayName = 'Component:InputText';\n\nInputText.propTypes = {\n caption: PropTypes.string,\n disabled: PropTypes.bool,\n error: PropTypes.bool,\n hint: PropTypes.string,\n icon: PropTypes.func,\n label: PropTypes.string,\n markdown: PropTypes.bool,\n multiLine: PropTypes.bool,\n name: PropTypes.string.isRequired,\n showRequired: PropTypes.bool,\n showState: PropTypes.bool,\n success: PropTypes.bool,\n type: PropTypes.string,\n warning: PropTypes.bool,\n onChange: PropTypes.func,\n onEnter: PropTypes.func,\n onLeave: PropTypes.func,\n};\n\nexport { InputText };\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AACA;AACA;AACA;AAAoD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEpD,IAAMA,SAAS,GAAG,SAAZA,SAAS,OAkBT;EAAA;EAAA,IAjBJC,OAAO,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S,CAACsD,WAAW,GAAG,qBAAqB;AAE7CtD,SAAS,CAACuD,SAAS,GAAG;EACpBtD,OAAO,EAAEuD,kBAAS,CAACC,MAAM;EACzBvD,QAAQ,EAAEsD,kBAAS,CAACE,IAAI;EACxBvD,KAAK,EAAEqD,kBAAS,CAACE,IAAI;EACrBtD,IAAI,EAAEoD,kBAAS,CAACC,MAAM;EACtBpD,IAAI,EAAEmD,kBAAS,CAACG,IAAI;EACpBrD,KAAK,EAAEkD,kBAAS,CAACC,MAAM;EACvBlD,QAAQ,EAAEiD,kBAAS,CAACE,IAAI;EACxBlD,SAAS,EAAEgD,kBAAS,CAACE,IAAI;EACzBE,IAAI,EAAEJ,kBAAS,CAACC,MAAM,CAACI,UAAU;EACjCpD,YAAY,EAAE+C,kBAAS,CAACE,IAAI;EAC5BhD,SAAS,EAAE8C,kBAAS,CAACE,IAAI;EACzB/C,OAAO,EAAE6C,kBAAS,CAACE,IAAI;EACvB9C,IAAI,EAAE4C,kBAAS,CAACC,MAAM;EACtB5C,OAAO,EAAE2C,kBAAS,CAACE,IAAI;EACvB5C,QAAQ,EAAE0C,kBAAS,CAACG,IAAI;EACxB5C,OAAO,EAAEyC,kBAAS,CAACG,IAAI;EACvB3C,OAAO,EAAEwC,kBAAS,CAACG;AACrB,CAAC"}
|
|
@@ -31,6 +31,11 @@ exports[`component:<InputText> prop:caption 1`] = `
|
|
|
31
31
|
<div
|
|
32
32
|
class="view row inputBorder"
|
|
33
33
|
>
|
|
34
|
+
<span
|
|
35
|
+
class="text action lighten caption"
|
|
36
|
+
>
|
|
37
|
+
caption
|
|
38
|
+
</span>
|
|
34
39
|
<div
|
|
35
40
|
class="view wide content"
|
|
36
41
|
>
|
|
@@ -41,11 +46,6 @@ exports[`component:<InputText> prop:caption 1`] = `
|
|
|
41
46
|
value=""
|
|
42
47
|
/>
|
|
43
48
|
</div>
|
|
44
|
-
<span
|
|
45
|
-
class="text action lighten caption"
|
|
46
|
-
>
|
|
47
|
-
caption
|
|
48
|
-
</span>
|
|
49
49
|
</div>
|
|
50
50
|
</div>
|
|
51
51
|
</DocumentFragment>
|