@salutejs/plasma-new-hope 0.185.0-dev.0 → 0.186.0-canary.1541.11711445984.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/TextField/TextField.js +11 -0
- package/cjs/components/TextField/TextField.js.map +1 -1
- package/cjs/utils/syntheticEvent.js +56 -0
- package/cjs/utils/syntheticEvent.js.map +1 -0
- package/emotion/cjs/components/TextField/TextField.js +12 -1
- package/emotion/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +1 -0
- package/emotion/cjs/utils/syntheticEvent.js +54 -0
- package/emotion/es/components/TextField/TextField.js +12 -1
- package/emotion/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +1 -0
- package/emotion/es/utils/syntheticEvent.js +48 -0
- package/es/components/TextField/TextField.js +11 -0
- package/es/components/TextField/TextField.js.map +1 -1
- package/es/utils/syntheticEvent.js +51 -0
- package/es/utils/syntheticEvent.js.map +1 -0
- package/package.json +2 -2
- package/styled-components/cjs/components/TextField/TextField.js +11 -0
- package/styled-components/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +1 -0
- package/styled-components/cjs/utils/syntheticEvent.js +54 -0
- package/styled-components/es/components/TextField/TextField.js +11 -0
- package/styled-components/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +1 -0
- package/styled-components/es/utils/syntheticEvent.js +48 -0
- package/types/components/TextField/TextField.d.ts.map +1 -1
- package/types/utils/syntheticEvent.d.ts +4 -0
- package/types/utils/syntheticEvent.d.ts.map +1 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.createSyntheticEvent = exports.createEvent = void 0;
|
7
|
+
var createEvent = exports.createEvent = function createEvent(ref) {
|
8
|
+
if (ref.current) {
|
9
|
+
var event = new Event('change', {
|
10
|
+
bubbles: true
|
11
|
+
});
|
12
|
+
Object.defineProperty(event, 'target', {
|
13
|
+
writable: false,
|
14
|
+
value: ref.current
|
15
|
+
});
|
16
|
+
var syntheticEvent = createSyntheticEvent(event);
|
17
|
+
console.log(syntheticEvent);
|
18
|
+
return syntheticEvent;
|
19
|
+
}
|
20
|
+
return null;
|
21
|
+
};
|
22
|
+
var createSyntheticEvent = exports.createSyntheticEvent = function createSyntheticEvent(event) {
|
23
|
+
var _isDefaultPrevented = false;
|
24
|
+
var _isPropagationStopped = false;
|
25
|
+
var preventDefault = function preventDefault() {
|
26
|
+
_isDefaultPrevented = true;
|
27
|
+
event.preventDefault();
|
28
|
+
};
|
29
|
+
var stopPropagation = function stopPropagation() {
|
30
|
+
_isPropagationStopped = true;
|
31
|
+
event.stopPropagation();
|
32
|
+
};
|
33
|
+
return {
|
34
|
+
nativeEvent: event,
|
35
|
+
currentTarget: event.currentTarget,
|
36
|
+
target: event.target,
|
37
|
+
bubbles: event.bubbles,
|
38
|
+
cancelable: event.cancelable,
|
39
|
+
defaultPrevented: event.defaultPrevented,
|
40
|
+
eventPhase: event.eventPhase,
|
41
|
+
isTrusted: event.isTrusted,
|
42
|
+
preventDefault: preventDefault,
|
43
|
+
isDefaultPrevented: function isDefaultPrevented() {
|
44
|
+
return _isDefaultPrevented;
|
45
|
+
},
|
46
|
+
stopPropagation: stopPropagation,
|
47
|
+
isPropagationStopped: function isPropagationStopped() {
|
48
|
+
return _isPropagationStopped;
|
49
|
+
},
|
50
|
+
persist: function persist() {},
|
51
|
+
timeStamp: event.timeStamp,
|
52
|
+
type: event.type
|
53
|
+
};
|
54
|
+
};
|
@@ -13,6 +13,7 @@ import { safeUseId, useForkRef } from '@salutejs/plasma-core';
|
|
13
13
|
import { css } from 'styled-components';
|
14
14
|
import { cx } from '../../utils';
|
15
15
|
import { useOutsideClick } from '../../hooks';
|
16
|
+
import { createEvent } from '../../utils/syntheticEvent';
|
16
17
|
import { base as sizeCSS } from './variations/_size/base';
|
17
18
|
import { base as viewCSS } from './variations/_view/base';
|
18
19
|
import { base as clearCSS } from './variations/_clear/base';
|
@@ -222,11 +223,21 @@ export var textFieldRoot = function textFieldRoot(Root) {
|
|
222
223
|
setChips(newChips);
|
223
224
|
}, [isChipEnumeration, values]);
|
224
225
|
useEffect(function () {
|
226
|
+
console.log('Init Value');
|
225
227
|
setHasValue(Boolean(rest === null || rest === void 0 ? void 0 : rest.defaultValue));
|
228
|
+
var event = createEvent(inputRef);
|
229
|
+
if (event) {
|
230
|
+
handleChange(event);
|
231
|
+
}
|
226
232
|
}, [rest.defaultValue]);
|
227
233
|
useEffect(function () {
|
228
234
|
var _inputRef$current2;
|
235
|
+
console.log('Set Value');
|
229
236
|
setHasValue(Boolean(outerValue) || Boolean(inputRef === null || inputRef === void 0 || (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.value));
|
237
|
+
var event = createEvent(inputRef);
|
238
|
+
if (event) {
|
239
|
+
handleChange(event);
|
240
|
+
}
|
230
241
|
}, [outerValue, inputRef === null || inputRef === void 0 || (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.value]);
|
231
242
|
var innerOptional = Boolean(required ? false : optional);
|
232
243
|
var hasPlaceholderOptional = innerOptional && !innerLabelValue && !hasOuterLabel;
|
@@ -171,6 +171,7 @@ const StoryDemo = ({ enableContentLeft, enableContentRight, view, ...rest }: Sto
|
|
171
171
|
|
172
172
|
return (
|
173
173
|
<div style={{ display: 'flex', flexDirection: 'column', gap: '2rem', width: '70%', margin: '0 auto' }}>
|
174
|
+
<div>{text}</div>
|
174
175
|
<TextField
|
175
176
|
{...rest}
|
176
177
|
enumerationType="plain"
|
@@ -0,0 +1,48 @@
|
|
1
|
+
export var createEvent = function createEvent(ref) {
|
2
|
+
if (ref.current) {
|
3
|
+
var event = new Event('change', {
|
4
|
+
bubbles: true
|
5
|
+
});
|
6
|
+
Object.defineProperty(event, 'target', {
|
7
|
+
writable: false,
|
8
|
+
value: ref.current
|
9
|
+
});
|
10
|
+
var syntheticEvent = createSyntheticEvent(event);
|
11
|
+
console.log(syntheticEvent);
|
12
|
+
return syntheticEvent;
|
13
|
+
}
|
14
|
+
return null;
|
15
|
+
};
|
16
|
+
export var createSyntheticEvent = function createSyntheticEvent(event) {
|
17
|
+
var _isDefaultPrevented = false;
|
18
|
+
var _isPropagationStopped = false;
|
19
|
+
var preventDefault = function preventDefault() {
|
20
|
+
_isDefaultPrevented = true;
|
21
|
+
event.preventDefault();
|
22
|
+
};
|
23
|
+
var stopPropagation = function stopPropagation() {
|
24
|
+
_isPropagationStopped = true;
|
25
|
+
event.stopPropagation();
|
26
|
+
};
|
27
|
+
return {
|
28
|
+
nativeEvent: event,
|
29
|
+
currentTarget: event.currentTarget,
|
30
|
+
target: event.target,
|
31
|
+
bubbles: event.bubbles,
|
32
|
+
cancelable: event.cancelable,
|
33
|
+
defaultPrevented: event.defaultPrevented,
|
34
|
+
eventPhase: event.eventPhase,
|
35
|
+
isTrusted: event.isTrusted,
|
36
|
+
preventDefault: preventDefault,
|
37
|
+
isDefaultPrevented: function isDefaultPrevented() {
|
38
|
+
return _isDefaultPrevented;
|
39
|
+
},
|
40
|
+
stopPropagation: stopPropagation,
|
41
|
+
isPropagationStopped: function isPropagationStopped() {
|
42
|
+
return _isPropagationStopped;
|
43
|
+
},
|
44
|
+
persist: function persist() {},
|
45
|
+
timeStamp: event.timeStamp,
|
46
|
+
type: event.type
|
47
|
+
};
|
48
|
+
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAKvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
1
|
+
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAKvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAK/C,OAAO,KAAK,EAAuC,cAAc,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAoCjH,eAAO,MAAM,IAAI,0CAGhB,CAAC;AAIF,eAAO,MAAM,aAAa,SAAU,UAAU,cAAc,EAAE,kBAAkB,CAAC,4FA6Y5E,CAAC;AAEN,eAAO,MAAM,eAAe;;;mBA/YQ,UAAU,cAAc,EAAE,kBAAkB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqbhF,CAAC"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { RefObject } from 'react';
|
2
|
+
export declare const createEvent: (ref: RefObject<HTMLInputElement>) => import("react").ChangeEvent<HTMLInputElement> | null;
|
3
|
+
export declare const createSyntheticEvent: <T extends Element, E extends Event>(event: E) => import("react").SyntheticEvent<T, E>;
|
4
|
+
//# sourceMappingURL=syntheticEvent.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"syntheticEvent.d.ts","sourceRoot":"","sources":["../../src/utils/syntheticEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,eAAO,MAAM,WAAW,QAAS,UAAU,gBAAgB,CAAC,yDAU3D,CAAC;AAEF,eAAO,MAAM,oBAAoB,wFA4BhC,CAAC"}
|