@ebscn/ui 1.0.3-beta.1 → 1.0.3-beta.2

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.
Files changed (77) hide show
  1. package/cjs/components/common-input/common-input.css +28 -0
  2. package/cjs/components/common-input/common-input.d.ts +27 -0
  3. package/cjs/components/common-input/common-input.js +88 -0
  4. package/cjs/components/common-input/index.d.ts +4 -0
  5. package/cjs/components/common-input/index.js +9 -0
  6. package/cjs/components/fene-input/fene-input.css +35 -0
  7. package/cjs/components/fene-input/fene-input.d.ts +14 -0
  8. package/cjs/components/fene-input/fene-input.js +63 -0
  9. package/cjs/components/fene-input/index.d.ts +4 -0
  10. package/cjs/components/fene-input/index.js +9 -0
  11. package/cjs/components/input/index.d.ts +4 -0
  12. package/cjs/components/input/index.js +9 -0
  13. package/cjs/components/input/input.css +96 -0
  14. package/cjs/components/input/input.d.ts +41 -0
  15. package/cjs/components/input/input.js +161 -0
  16. package/cjs/components/marketTag/marketTag.css +4 -4
  17. package/cjs/components/money-input/index.d.ts +4 -0
  18. package/cjs/components/money-input/index.js +9 -0
  19. package/cjs/components/money-input/money-input.css +35 -0
  20. package/cjs/components/money-input/money-input.d.ts +27 -0
  21. package/cjs/components/money-input/money-input.js +111 -0
  22. package/cjs/components/passcode-input/index.d.ts +4 -0
  23. package/cjs/components/passcode-input/index.js +9 -0
  24. package/cjs/components/passcode-input/passcode-input.css +136 -0
  25. package/cjs/components/passcode-input/passcode-input.d.ts +40 -0
  26. package/cjs/components/passcode-input/passcode-input.js +136 -0
  27. package/cjs/components/pay-input/index.d.ts +4 -0
  28. package/cjs/components/pay-input/index.js +10 -0
  29. package/cjs/components/pay-input/pay-input.css +136 -0
  30. package/cjs/components/pay-input/pay-input.d.ts +14 -0
  31. package/cjs/components/pay-input/pay-input.js +126 -0
  32. package/cjs/components/virtual-input/index.d.ts +4 -0
  33. package/cjs/components/virtual-input/index.js +9 -0
  34. package/cjs/components/virtual-input/virtual-input.css +99 -0
  35. package/cjs/components/virtual-input/virtual-input.d.ts +45 -0
  36. package/cjs/components/virtual-input/virtual-input.js +145 -0
  37. package/cjs/index.d.ts +5 -0
  38. package/cjs/index.js +41 -1
  39. package/es/components/common-input/common-input.css +28 -0
  40. package/es/components/common-input/common-input.d.ts +27 -0
  41. package/es/components/common-input/common-input.js +80 -0
  42. package/es/components/common-input/index.d.ts +4 -0
  43. package/es/components/common-input/index.js +3 -0
  44. package/es/components/fene-input/fene-input.css +35 -0
  45. package/es/components/fene-input/fene-input.d.ts +14 -0
  46. package/es/components/fene-input/fene-input.js +56 -0
  47. package/es/components/fene-input/index.d.ts +4 -0
  48. package/es/components/fene-input/index.js +3 -0
  49. package/es/components/input/index.d.ts +4 -0
  50. package/es/components/input/index.js +3 -0
  51. package/es/components/input/input.css +96 -0
  52. package/es/components/input/input.d.ts +41 -0
  53. package/es/components/input/input.js +152 -0
  54. package/es/components/marketTag/marketTag.css +4 -4
  55. package/es/components/money-input/index.d.ts +4 -0
  56. package/es/components/money-input/index.js +3 -0
  57. package/es/components/money-input/money-input.css +35 -0
  58. package/es/components/money-input/money-input.d.ts +27 -0
  59. package/es/components/money-input/money-input.js +103 -0
  60. package/es/components/passcode-input/index.d.ts +4 -0
  61. package/es/components/passcode-input/index.js +3 -0
  62. package/es/components/passcode-input/passcode-input.css +136 -0
  63. package/es/components/passcode-input/passcode-input.d.ts +40 -0
  64. package/es/components/passcode-input/passcode-input.js +127 -0
  65. package/es/components/pay-input/index.d.ts +4 -0
  66. package/es/components/pay-input/index.js +3 -0
  67. package/es/components/pay-input/pay-input.css +136 -0
  68. package/es/components/pay-input/pay-input.d.ts +14 -0
  69. package/es/components/pay-input/pay-input.js +115 -0
  70. package/es/components/virtual-input/index.d.ts +4 -0
  71. package/es/components/virtual-input/index.js +3 -0
  72. package/es/components/virtual-input/virtual-input.css +99 -0
  73. package/es/components/virtual-input/virtual-input.d.ts +45 -0
  74. package/es/components/virtual-input/virtual-input.js +134 -0
  75. package/es/index.d.ts +5 -0
  76. package/es/index.js +6 -1
  77. package/package.json +1 -1
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import type { ReactElement } from 'react';
3
+ import { NativeProps } from '../../utils/native-props';
4
+ import { NumberKeyboardProps } from '../number-keyboard';
5
+ type NativeInputProps = React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
6
+ type AriaProps = {
7
+ role?: string;
8
+ };
9
+ export type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength' | 'autoComplete' | 'autoFocus' | 'pattern' | 'inputMode' | 'type' | 'name' | 'onFocus' | 'onBlur' | 'autoCapitalize' | 'autoCorrect' | 'onKeyDown' | 'onKeyUp' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick' | 'step' | 'id' | 'placeholder' | 'readOnly' | 'disabled'> & {
10
+ value?: string;
11
+ defaultValue?: string;
12
+ onChange?: (val: string) => void;
13
+ clearable?: boolean;
14
+ onlyShowClearWhenFocus?: boolean;
15
+ onClear?: () => void;
16
+ onEnterPress?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
17
+ enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
18
+ min?: number;
19
+ max?: number;
20
+ } & NativeProps<'--font-size' | '--color' | '--placeholder-color' | '--text-align'> & AriaProps;
21
+ export type VirtualInputProps = {
22
+ onFocus?: () => void;
23
+ onBlur?: () => void;
24
+ onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
25
+ keyboard?: ReactElement<NumberKeyboardProps>;
26
+ clearable?: boolean;
27
+ onClear?: () => void;
28
+ } & Pick<InputProps, 'value' | 'onChange' | 'placeholder' | 'disabled'> & NativeProps<'--font-size' | '--color' | '--placeholder-color' | '--disabled-color' | '--text-align' | '--caret-width' | '--caret-color'>;
29
+ export type VirtualInputRef = {
30
+ focus: () => void;
31
+ blur: () => void;
32
+ };
33
+ export declare const VirtualInput: React.ForwardRefExoticComponent<{
34
+ onFocus?: (() => void) | undefined;
35
+ onBlur?: (() => void) | undefined;
36
+ onClick?: ((e: React.MouseEvent<HTMLDivElement>) => void) | undefined;
37
+ keyboard?: React.ReactElement<NumberKeyboardProps, string | React.JSXElementConstructor<any>> | undefined;
38
+ clearable?: boolean | undefined;
39
+ onClear?: (() => void) | undefined;
40
+ } & Pick<InputProps, "disabled" | "value" | "onChange" | "placeholder"> & {
41
+ className?: string | undefined;
42
+ style?: (React.CSSProperties & Partial<Record<"--color" | "--font-size" | "--placeholder-color" | "--text-align" | "--disabled-color" | "--caret-width" | "--caret-color", string>>) | undefined;
43
+ tabIndex?: number | undefined;
44
+ } & React.AriaAttributes & React.RefAttributes<VirtualInputRef>>;
45
+ export {};
@@ -0,0 +1,134 @@
1
+ import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
2
+ // import type { InputProps } from '../input'
3
+ import { withNativeProps } from '../../utils/native-props';
4
+ import { mergeProps } from '../../utils/with-default-props';
5
+ import { usePropsValue } from '../../utils/use-props-value';
6
+ import classNames from 'classnames';
7
+ // import { CloseCircleFill } from 'antd-mobile-icons'
8
+ import { useIsomorphicLayoutEffect } from 'ahooks';
9
+ // import { useConfig } from '../config-provider'
10
+ var classPrefix = 'ebscn-virtual-input';
11
+ var defaultProps = {
12
+ defaultValue: ''
13
+ };
14
+ export var VirtualInput = forwardRef(function (p, ref) {
15
+ var _a;
16
+ var props = mergeProps(defaultProps, p);
17
+ var _b = usePropsValue(props),
18
+ value = _b[0],
19
+ setValue = _b[1];
20
+ console.log(props, value, 11);
21
+ var rootRef = useRef(null);
22
+ var contentRef = useRef(null);
23
+ var _c = useState(false),
24
+ hasFocus = _c[0],
25
+ setHasFocus = _c[1];
26
+ // const { locale } = useConfig()
27
+ function scrollToEnd() {
28
+ var root = rootRef.current;
29
+ if (!root) return;
30
+ if (document.activeElement !== root) {
31
+ return;
32
+ }
33
+ var content = contentRef.current;
34
+ if (!content) return;
35
+ content.scrollLeft = content.clientWidth;
36
+ }
37
+ useIsomorphicLayoutEffect(function () {
38
+ scrollToEnd();
39
+ }, [value]);
40
+ useEffect(function () {
41
+ if (hasFocus) {
42
+ scrollToEnd();
43
+ }
44
+ }, [hasFocus]);
45
+ useImperativeHandle(ref, function () {
46
+ return {
47
+ focus: function () {
48
+ var _a;
49
+ (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.focus();
50
+ },
51
+ blur: function () {
52
+ var _a;
53
+ (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
54
+ }
55
+ };
56
+ });
57
+ function onFocus() {
58
+ var _a;
59
+ setHasFocus(true);
60
+ (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props);
61
+ }
62
+ function onBlur() {
63
+ var _a;
64
+ setHasFocus(false);
65
+ (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props);
66
+ }
67
+ var keyboard = props.keyboard;
68
+ var keyboardElement = keyboard && React.cloneElement(keyboard, {
69
+ onInput: function (v) {
70
+ var _a, _b;
71
+ setValue(value + v);
72
+ (_b = (_a = keyboard.props).onInput) === null || _b === void 0 ? void 0 : _b.call(_a, v);
73
+ },
74
+ onDelete: function () {
75
+ var _a, _b;
76
+ setValue(value.slice(0, -1));
77
+ (_b = (_a = keyboard.props).onDelete) === null || _b === void 0 ? void 0 : _b.call(_a);
78
+ },
79
+ visible: hasFocus,
80
+ onClose: function () {
81
+ var _a, _b, _c, _d;
82
+ var activeElement = document.activeElement;
83
+ // Long press makes `activeElement` to be the child of rootRef
84
+ // We will trigger blur on the child element instead
85
+ if (activeElement && ((_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.contains(activeElement))) {
86
+ activeElement.blur();
87
+ } else {
88
+ (_b = rootRef.current) === null || _b === void 0 ? void 0 : _b.blur();
89
+ }
90
+ (_d = (_c = keyboard.props).onClose) === null || _d === void 0 ? void 0 : _d.call(_c);
91
+ },
92
+ onChangeKeyBoard: function () {},
93
+ onClean: function () {
94
+ var _a, _b;
95
+ setValue('');
96
+ (_b = (_a = keyboard.props).onClean) === null || _b === void 0 ? void 0 : _b.call(_a);
97
+ },
98
+ onConfirm: function () {
99
+ var _a, _b;
100
+ setHasFocus(false);
101
+ (_b = (_a = keyboard.props).onConfirm) === null || _b === void 0 ? void 0 : _b.call(_a);
102
+ },
103
+ getContainer: null
104
+ });
105
+ return withNativeProps(props, React.createElement("div", {
106
+ ref: rootRef,
107
+ className: classNames(classPrefix, (_a = {}, _a["".concat(classPrefix, "-disabled")] = props.disabled, _a)),
108
+ tabIndex: props.disabled ? undefined : 0,
109
+ role: 'textbox',
110
+ onFocus: onFocus,
111
+ onBlur: onBlur,
112
+ onClick: props.onClick
113
+ }, React.createElement("div", {
114
+ className: "".concat(classPrefix, "-content"),
115
+ ref: contentRef,
116
+ "aria-disabled": props.disabled,
117
+ "aria-label": props.placeholder
118
+ }, value, React.createElement("div", {
119
+ className: "".concat(classPrefix, "-caret-container")
120
+ }, hasFocus && React.createElement("div", {
121
+ className: "".concat(classPrefix, "-caret")
122
+ }))), props.clearable && !!value && hasFocus && React.createElement("div", {
123
+ className: "".concat(classPrefix, "-clear"),
124
+ onClick: function (e) {
125
+ var _a;
126
+ e.stopPropagation();
127
+ setValue('');
128
+ (_a = props.onClear) === null || _a === void 0 ? void 0 : _a.call(props);
129
+ },
130
+ role: 'button'
131
+ }), [undefined, null, ''].includes(value) && React.createElement("div", {
132
+ className: "".concat(classPrefix, "-placeholder")
133
+ }, props.placeholder), keyboardElement));
134
+ });
package/es/index.d.ts CHANGED
@@ -35,3 +35,8 @@ export { default as Switch } from './components/switch';
35
35
  export { default as Tabs } from './components/tabs';
36
36
  export { default as Tip } from './components/tip';
37
37
  export { default as ToastLoading } from './components/toastLoading';
38
+ export { default as PayInput } from './components/pay-input';
39
+ export { default as MoneyInput } from './components/money-input';
40
+ export { default as FeneInput } from './components/fene-input';
41
+ export { default as Input } from './components/input';
42
+ export { default as CommonInput } from './components/common-input';
package/es/index.js CHANGED
@@ -36,4 +36,9 @@ export { default as Swiper } from './components/swiper';
36
36
  export { default as Switch } from './components/switch';
37
37
  export { default as Tabs } from './components/tabs';
38
38
  export { default as Tip } from './components/tip';
39
- export { default as ToastLoading } from './components/toastLoading';
39
+ export { default as ToastLoading } from './components/toastLoading';
40
+ export { default as PayInput } from './components/pay-input';
41
+ export { default as MoneyInput } from './components/money-input';
42
+ export { default as FeneInput } from './components/fene-input';
43
+ export { default as Input } from './components/input';
44
+ export { default as CommonInput } from './components/common-input';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebscn/ui",
3
- "version": "1.0.3-beta.1",
3
+ "version": "1.0.3-beta.2",
4
4
  "description": "ebscn react library",
5
5
  "module": "./es/index.js",
6
6
  "types": "./es/index.d.ts",