bj-web-components 0.2.26 → 0.2.28

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 (109) hide show
  1. package/dist/favicon.ico +0 -0
  2. package/dist/file.svg +1 -0
  3. package/dist/globe.svg +1 -0
  4. package/dist/index.d.ts +1141 -0
  5. package/dist/index.js +51 -0
  6. package/dist/index.mjs +51 -0
  7. package/dist/miniapp.d.ts +1 -0
  8. package/dist/miniapp.js +1 -0
  9. package/dist/miniapp.mjs +1 -0
  10. package/dist/mobile.d.ts +1 -0
  11. package/dist/mobile.js +1 -0
  12. package/dist/mobile.mjs +1 -0
  13. package/dist/next.svg +1 -0
  14. package/dist/react.d.ts +1 -0
  15. package/dist/react.js +1 -0
  16. package/dist/react.mjs +1 -0
  17. package/dist/shared.d.ts +1 -0
  18. package/dist/shared.js +1 -0
  19. package/dist/shared.mjs +1 -0
  20. package/dist/style.css +3744 -0
  21. package/dist/vercel.svg +1 -0
  22. package/dist/web/BasicInput/BInput.js +208 -0
  23. package/dist/web/BasicInput/BInput.mjs +209 -0
  24. package/dist/web/BasicInput/utils.js +47 -0
  25. package/dist/web/BasicInput/utils.mjs +47 -0
  26. package/dist/web/CategoryDropdown/CategoryDropdown.js +307 -0
  27. package/dist/web/CategoryDropdown/CategoryDropdown.mjs +308 -0
  28. package/dist/web/CheckBox/BCheckBox.js +116 -0
  29. package/dist/web/CheckBox/BCheckBox.mjs +117 -0
  30. package/dist/web/CheckBox/Group.js +73 -0
  31. package/dist/web/CheckBox/Group.mjs +74 -0
  32. package/dist/web/CheckBox/context.js +5 -0
  33. package/dist/web/CheckBox/context.mjs +5 -0
  34. package/dist/web/CheckBox/index.js +8 -0
  35. package/dist/web/CheckBox/index.mjs +8 -0
  36. package/dist/web/Dropdown/BDropdown.js +186 -0
  37. package/dist/web/Dropdown/BDropdown.mjs +186 -0
  38. package/dist/web/EmptyInputBox/EmptyInputBox.js +77 -0
  39. package/dist/web/EmptyInputBox/EmptyInputBox.mjs +78 -0
  40. package/dist/web/FileCard/FileCard.js +157 -0
  41. package/dist/web/FileCard/FileCard.mjs +158 -0
  42. package/dist/web/Icon/Icon.js +9 -0
  43. package/dist/web/Icon/Icon.mjs +10 -0
  44. package/dist/web/Input/Input.js +181 -0
  45. package/dist/web/Input/Input.mjs +182 -0
  46. package/dist/web/InputNumber/BInputNumber.js +311 -0
  47. package/dist/web/InputNumber/BInputNumber.mjs +312 -0
  48. package/dist/web/InputNumber/StepHandler.js +69 -0
  49. package/dist/web/InputNumber/StepHandler.mjs +70 -0
  50. package/dist/web/InputNumber/hooks/useCursor.js +40 -0
  51. package/dist/web/InputNumber/hooks/useCursor.mjs +41 -0
  52. package/dist/web/InputNumber/hooks/useFrame.js +12 -0
  53. package/dist/web/InputNumber/hooks/useFrame.mjs +13 -0
  54. package/dist/web/InputNumber/utils/decimal.js +147 -0
  55. package/dist/web/InputNumber/utils/decimal.mjs +147 -0
  56. package/dist/web/Modal/Modal.js +84 -0
  57. package/dist/web/Modal/Modal.mjs +85 -0
  58. package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +232 -0
  59. package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +233 -0
  60. package/dist/web/Pagination/Pagination.js +328 -0
  61. package/dist/web/Pagination/Pagination.mjs +329 -0
  62. package/dist/web/ProductField/ProductField.js +272 -0
  63. package/dist/web/ProductField/ProductField.mjs +273 -0
  64. package/dist/web/ProductField/arrow-up.svg.js +3 -0
  65. package/dist/web/ProductField/arrow-up.svg.mjs +4 -0
  66. package/dist/web/ProductField/checkbox-no.svg.js +3 -0
  67. package/dist/web/ProductField/checkbox-no.svg.mjs +4 -0
  68. package/dist/web/ProductField/checkbox-ok.svg.js +3 -0
  69. package/dist/web/ProductField/checkbox-ok.svg.mjs +4 -0
  70. package/dist/web/ProductField/no_data_light.svg.js +3 -0
  71. package/dist/web/ProductField/no_data_light.svg.mjs +4 -0
  72. package/dist/web/ProductField/search.svg.js +3 -0
  73. package/dist/web/ProductField/search.svg.mjs +4 -0
  74. package/dist/web/ProductField/sort.svg.js +3 -0
  75. package/dist/web/ProductField/sort.svg.mjs +4 -0
  76. package/dist/web/SkuInputCard/SkuInputCard.js +276 -0
  77. package/dist/web/SkuInputCard/SkuInputCard.mjs +277 -0
  78. package/dist/web/SkuInputCard/spin_loading_red.gif.js +3 -0
  79. package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +4 -0
  80. package/dist/web/Switch/Switch.js +70 -0
  81. package/dist/web/Switch/Switch.mjs +71 -0
  82. package/dist/web/Table/BTable.js +950 -0
  83. package/dist/web/Table/BTable.mjs +950 -0
  84. package/dist/web/Table/Column.js +5 -0
  85. package/dist/web/Table/Column.mjs +6 -0
  86. package/dist/web/Table/ColumnGroup.js +5 -0
  87. package/dist/web/Table/ColumnGroup.mjs +6 -0
  88. package/dist/web/Table/utils/columns.js +48 -0
  89. package/dist/web/Table/utils/columns.mjs +48 -0
  90. package/dist/web/Table/utils/sortFilter.js +84 -0
  91. package/dist/web/Table/utils/sortFilter.mjs +84 -0
  92. package/dist/web/Tabs/BTabs.js +150 -0
  93. package/dist/web/Tabs/BTabs.mjs +150 -0
  94. package/dist/web/Tabs/TabPane.js +8 -0
  95. package/dist/web/Tabs/TabPane.mjs +8 -0
  96. package/dist/web/Tooltip/ConfirmTooltip.js +26 -0
  97. package/dist/web/Tooltip/ConfirmTooltip.mjs +27 -0
  98. package/dist/web/Tooltip/ContentTooltip.js +94 -0
  99. package/dist/web/Tooltip/ContentTooltip.mjs +95 -0
  100. package/dist/web/Tooltip/ProgressTooltip.js +36 -0
  101. package/dist/web/Tooltip/ProgressTooltip.mjs +37 -0
  102. package/dist/web/Tooltip/TooltipWrapper.js +12 -0
  103. package/dist/web/Tooltip/TooltipWrapper.mjs +13 -0
  104. package/dist/web/Tooltip/useAutoPlacement.js +41 -0
  105. package/dist/web/Tooltip/useAutoPlacement.mjs +41 -0
  106. package/dist/web.d.ts +1141 -0
  107. package/dist/web.js +51 -0
  108. package/dist/web.mjs +51 -0
  109. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ <svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ const jsxRuntime = require("react/jsx-runtime");
3
+ const react = require("react");
4
+ const utils = require("./utils.js");
5
+ ;/* empty css */
6
+ function classNames(...values) {
7
+ return values.filter(Boolean).join(" ");
8
+ }
9
+ function BaseInput({
10
+ addonAfter,
11
+ addonBefore,
12
+ allowClear,
13
+ children,
14
+ className,
15
+ disabled,
16
+ focused,
17
+ handleReset,
18
+ onClear,
19
+ prefix,
20
+ readOnly,
21
+ size,
22
+ status,
23
+ suffix,
24
+ triggerInputFocus,
25
+ value
26
+ }) {
27
+ const containerRef = react.useRef(null);
28
+ const hasAffix = utils.hasPrefixSuffix({ prefix, suffix, allowClear });
29
+ const inputElement = react.cloneElement(children, { value });
30
+ let element = inputElement;
31
+ if (hasAffix) {
32
+ const needClear = Boolean(allowClear && !disabled && !readOnly && value);
33
+ const clearIcon = typeof allowClear === "object" && allowClear.clearIcon ? allowClear.clearIcon : "×";
34
+ element = /* @__PURE__ */ jsxRuntime.jsxs(
35
+ "span",
36
+ {
37
+ className: classNames(
38
+ "bj-input__affix-wrapper",
39
+ disabled && "bj-input__affix-wrapper--disabled",
40
+ focused && "bj-input__affix-wrapper--focused",
41
+ readOnly && "bj-input__affix-wrapper--readonly",
42
+ size && `bj-input__affix-wrapper--${size}`,
43
+ status && `bj-input__affix-wrapper--${status}`
44
+ ),
45
+ onClick: triggerInputFocus,
46
+ ref: containerRef,
47
+ children: [
48
+ prefix && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-input__prefix", children: prefix }),
49
+ inputElement,
50
+ (suffix || allowClear) && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bj-input__suffix", children: [
51
+ allowClear && /* @__PURE__ */ jsxRuntime.jsx(
52
+ "button",
53
+ {
54
+ "aria-label": "清除输入内容",
55
+ className: classNames("bj-input__clear-icon", !needClear && "bj-input__clear-icon--hidden"),
56
+ onClick: (event) => {
57
+ handleReset(event);
58
+ onClear == null ? void 0 : onClear();
59
+ },
60
+ onMouseDown: (event) => event.preventDefault(),
61
+ tabIndex: -1,
62
+ type: "button",
63
+ children: clearIcon
64
+ }
65
+ ),
66
+ suffix
67
+ ] })
68
+ ]
69
+ }
70
+ );
71
+ }
72
+ if (utils.hasAddon({ addonBefore, addonAfter })) {
73
+ element = /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-input__group-wrapper", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bj-input__group", children: [
74
+ addonBefore && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-input__group-addon", children: addonBefore }),
75
+ element,
76
+ addonAfter && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-input__group-addon", children: addonAfter })
77
+ ] }) });
78
+ }
79
+ return react.cloneElement(element, { className: classNames(element.props.className, className) });
80
+ }
81
+ const BInput = react.forwardRef((props, ref) => {
82
+ const {
83
+ addonAfter,
84
+ addonBefore,
85
+ allowClear,
86
+ bordered = true,
87
+ className,
88
+ defaultValue,
89
+ disabled,
90
+ htmlSize,
91
+ onBlur,
92
+ onChange,
93
+ onClear,
94
+ onCompositionEnd,
95
+ onCompositionStart,
96
+ onFocus,
97
+ onKeyDown,
98
+ onKeyUp,
99
+ onPressEnter,
100
+ prefix,
101
+ readOnly,
102
+ size = "middle",
103
+ status,
104
+ suffix,
105
+ type = "text",
106
+ value: controlledValue,
107
+ ...restProps
108
+ } = props;
109
+ const [focused, setFocused] = react.useState(false);
110
+ const [innerValue, setInnerValue] = react.useState(defaultValue);
111
+ const inputRef = react.useRef(null);
112
+ const compositionRef = react.useRef(false);
113
+ const keyLockRef = react.useRef(false);
114
+ const hasAffix = utils.hasPrefixSuffix({ prefix, suffix, allowClear });
115
+ const value = controlledValue === void 0 ? innerValue : controlledValue;
116
+ const formattedValue = value === void 0 || value === null ? "" : String(value);
117
+ react.useImperativeHandle(ref, () => ({
118
+ focus: (option) => utils.triggerFocus(inputRef.current, option),
119
+ blur: () => {
120
+ var _a;
121
+ return (_a = inputRef.current) == null ? void 0 : _a.blur();
122
+ },
123
+ setSelectionRange: (...argumentsList) => {
124
+ var _a;
125
+ return (_a = inputRef.current) == null ? void 0 : _a.setSelectionRange(...argumentsList);
126
+ },
127
+ select: () => {
128
+ var _a;
129
+ return (_a = inputRef.current) == null ? void 0 : _a.select();
130
+ },
131
+ input: inputRef.current,
132
+ nativeElement: inputRef.current
133
+ }));
134
+ react.useEffect(() => setFocused((previous) => previous && !disabled), [disabled]);
135
+ const triggerChange = (event, nextValue, source) => {
136
+ if (source === "compositionEnd") return;
137
+ if (controlledValue === void 0) setInnerValue(nextValue);
138
+ if (inputRef.current) utils.resolveOnChange(inputRef.current, event, onChange, nextValue);
139
+ };
140
+ const input = /* @__PURE__ */ jsxRuntime.jsx(
141
+ "input",
142
+ {
143
+ ...restProps,
144
+ className: classNames("bj-input", `bj-input--${size}`, focused && !hasAffix && "bj-input--focused", status && `bj-input--${status}`, !bordered && "bj-input--borderless", disabled && "bj-input--disabled"),
145
+ disabled,
146
+ onBlur: (event) => {
147
+ keyLockRef.current = false;
148
+ setFocused(false);
149
+ onBlur == null ? void 0 : onBlur(event);
150
+ },
151
+ onChange: (event) => triggerChange(event, event.target.value, "change"),
152
+ onCompositionEnd: (event) => {
153
+ compositionRef.current = false;
154
+ triggerChange(event, event.currentTarget.value, "compositionEnd");
155
+ onCompositionEnd == null ? void 0 : onCompositionEnd(event);
156
+ },
157
+ onCompositionStart: (event) => {
158
+ compositionRef.current = true;
159
+ onCompositionStart == null ? void 0 : onCompositionStart(event);
160
+ },
161
+ onFocus: (event) => {
162
+ setFocused(true);
163
+ onFocus == null ? void 0 : onFocus(event);
164
+ },
165
+ onKeyDown: (event) => {
166
+ if (onPressEnter && event.key === "Enter" && !keyLockRef.current) {
167
+ keyLockRef.current = true;
168
+ onPressEnter(event);
169
+ }
170
+ onKeyDown == null ? void 0 : onKeyDown(event);
171
+ },
172
+ onKeyUp: (event) => {
173
+ if (event.key === "Enter") keyLockRef.current = false;
174
+ onKeyUp == null ? void 0 : onKeyUp(event);
175
+ },
176
+ ref: inputRef,
177
+ size: htmlSize,
178
+ type
179
+ }
180
+ );
181
+ return /* @__PURE__ */ jsxRuntime.jsx(
182
+ BaseInput,
183
+ {
184
+ addonAfter,
185
+ addonBefore,
186
+ allowClear,
187
+ className,
188
+ disabled,
189
+ focused,
190
+ handleReset: (event) => {
191
+ if (controlledValue === void 0) setInnerValue("");
192
+ utils.triggerFocus(inputRef.current);
193
+ if (inputRef.current) utils.resolveOnChange(inputRef.current, event, onChange);
194
+ },
195
+ onClear,
196
+ prefix,
197
+ readOnly,
198
+ size,
199
+ status,
200
+ suffix,
201
+ triggerInputFocus: () => utils.triggerFocus(inputRef.current),
202
+ value: formattedValue,
203
+ children: input
204
+ }
205
+ );
206
+ });
207
+ BInput.displayName = "BInput";
208
+ module.exports = BInput;
@@ -0,0 +1,209 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useState, useRef, useImperativeHandle, useEffect, cloneElement } from "react";
3
+ import { triggerFocus, resolveOnChange, hasPrefixSuffix, hasAddon } from "./utils.mjs";
4
+ /* empty css */
5
+ function classNames(...values) {
6
+ return values.filter(Boolean).join(" ");
7
+ }
8
+ function BaseInput({
9
+ addonAfter,
10
+ addonBefore,
11
+ allowClear,
12
+ children,
13
+ className,
14
+ disabled,
15
+ focused,
16
+ handleReset,
17
+ onClear,
18
+ prefix,
19
+ readOnly,
20
+ size,
21
+ status,
22
+ suffix,
23
+ triggerInputFocus,
24
+ value
25
+ }) {
26
+ const containerRef = useRef(null);
27
+ const hasAffix = hasPrefixSuffix({ prefix, suffix, allowClear });
28
+ const inputElement = cloneElement(children, { value });
29
+ let element = inputElement;
30
+ if (hasAffix) {
31
+ const needClear = Boolean(allowClear && !disabled && !readOnly && value);
32
+ const clearIcon = typeof allowClear === "object" && allowClear.clearIcon ? allowClear.clearIcon : "×";
33
+ element = /* @__PURE__ */ jsxs(
34
+ "span",
35
+ {
36
+ className: classNames(
37
+ "bj-input__affix-wrapper",
38
+ disabled && "bj-input__affix-wrapper--disabled",
39
+ focused && "bj-input__affix-wrapper--focused",
40
+ readOnly && "bj-input__affix-wrapper--readonly",
41
+ size && `bj-input__affix-wrapper--${size}`,
42
+ status && `bj-input__affix-wrapper--${status}`
43
+ ),
44
+ onClick: triggerInputFocus,
45
+ ref: containerRef,
46
+ children: [
47
+ prefix && /* @__PURE__ */ jsx("span", { className: "bj-input__prefix", children: prefix }),
48
+ inputElement,
49
+ (suffix || allowClear) && /* @__PURE__ */ jsxs("span", { className: "bj-input__suffix", children: [
50
+ allowClear && /* @__PURE__ */ jsx(
51
+ "button",
52
+ {
53
+ "aria-label": "清除输入内容",
54
+ className: classNames("bj-input__clear-icon", !needClear && "bj-input__clear-icon--hidden"),
55
+ onClick: (event) => {
56
+ handleReset(event);
57
+ onClear == null ? void 0 : onClear();
58
+ },
59
+ onMouseDown: (event) => event.preventDefault(),
60
+ tabIndex: -1,
61
+ type: "button",
62
+ children: clearIcon
63
+ }
64
+ ),
65
+ suffix
66
+ ] })
67
+ ]
68
+ }
69
+ );
70
+ }
71
+ if (hasAddon({ addonBefore, addonAfter })) {
72
+ element = /* @__PURE__ */ jsx("span", { className: "bj-input__group-wrapper", children: /* @__PURE__ */ jsxs("span", { className: "bj-input__group", children: [
73
+ addonBefore && /* @__PURE__ */ jsx("span", { className: "bj-input__group-addon", children: addonBefore }),
74
+ element,
75
+ addonAfter && /* @__PURE__ */ jsx("span", { className: "bj-input__group-addon", children: addonAfter })
76
+ ] }) });
77
+ }
78
+ return cloneElement(element, { className: classNames(element.props.className, className) });
79
+ }
80
+ const BInput = forwardRef((props, ref) => {
81
+ const {
82
+ addonAfter,
83
+ addonBefore,
84
+ allowClear,
85
+ bordered = true,
86
+ className,
87
+ defaultValue,
88
+ disabled,
89
+ htmlSize,
90
+ onBlur,
91
+ onChange,
92
+ onClear,
93
+ onCompositionEnd,
94
+ onCompositionStart,
95
+ onFocus,
96
+ onKeyDown,
97
+ onKeyUp,
98
+ onPressEnter,
99
+ prefix,
100
+ readOnly,
101
+ size = "middle",
102
+ status,
103
+ suffix,
104
+ type = "text",
105
+ value: controlledValue,
106
+ ...restProps
107
+ } = props;
108
+ const [focused, setFocused] = useState(false);
109
+ const [innerValue, setInnerValue] = useState(defaultValue);
110
+ const inputRef = useRef(null);
111
+ const compositionRef = useRef(false);
112
+ const keyLockRef = useRef(false);
113
+ const hasAffix = hasPrefixSuffix({ prefix, suffix, allowClear });
114
+ const value = controlledValue === void 0 ? innerValue : controlledValue;
115
+ const formattedValue = value === void 0 || value === null ? "" : String(value);
116
+ useImperativeHandle(ref, () => ({
117
+ focus: (option) => triggerFocus(inputRef.current, option),
118
+ blur: () => {
119
+ var _a;
120
+ return (_a = inputRef.current) == null ? void 0 : _a.blur();
121
+ },
122
+ setSelectionRange: (...argumentsList) => {
123
+ var _a;
124
+ return (_a = inputRef.current) == null ? void 0 : _a.setSelectionRange(...argumentsList);
125
+ },
126
+ select: () => {
127
+ var _a;
128
+ return (_a = inputRef.current) == null ? void 0 : _a.select();
129
+ },
130
+ input: inputRef.current,
131
+ nativeElement: inputRef.current
132
+ }));
133
+ useEffect(() => setFocused((previous) => previous && !disabled), [disabled]);
134
+ const triggerChange = (event, nextValue, source) => {
135
+ if (source === "compositionEnd") return;
136
+ if (controlledValue === void 0) setInnerValue(nextValue);
137
+ if (inputRef.current) resolveOnChange(inputRef.current, event, onChange, nextValue);
138
+ };
139
+ const input = /* @__PURE__ */ jsx(
140
+ "input",
141
+ {
142
+ ...restProps,
143
+ className: classNames("bj-input", `bj-input--${size}`, focused && !hasAffix && "bj-input--focused", status && `bj-input--${status}`, !bordered && "bj-input--borderless", disabled && "bj-input--disabled"),
144
+ disabled,
145
+ onBlur: (event) => {
146
+ keyLockRef.current = false;
147
+ setFocused(false);
148
+ onBlur == null ? void 0 : onBlur(event);
149
+ },
150
+ onChange: (event) => triggerChange(event, event.target.value, "change"),
151
+ onCompositionEnd: (event) => {
152
+ compositionRef.current = false;
153
+ triggerChange(event, event.currentTarget.value, "compositionEnd");
154
+ onCompositionEnd == null ? void 0 : onCompositionEnd(event);
155
+ },
156
+ onCompositionStart: (event) => {
157
+ compositionRef.current = true;
158
+ onCompositionStart == null ? void 0 : onCompositionStart(event);
159
+ },
160
+ onFocus: (event) => {
161
+ setFocused(true);
162
+ onFocus == null ? void 0 : onFocus(event);
163
+ },
164
+ onKeyDown: (event) => {
165
+ if (onPressEnter && event.key === "Enter" && !keyLockRef.current) {
166
+ keyLockRef.current = true;
167
+ onPressEnter(event);
168
+ }
169
+ onKeyDown == null ? void 0 : onKeyDown(event);
170
+ },
171
+ onKeyUp: (event) => {
172
+ if (event.key === "Enter") keyLockRef.current = false;
173
+ onKeyUp == null ? void 0 : onKeyUp(event);
174
+ },
175
+ ref: inputRef,
176
+ size: htmlSize,
177
+ type
178
+ }
179
+ );
180
+ return /* @__PURE__ */ jsx(
181
+ BaseInput,
182
+ {
183
+ addonAfter,
184
+ addonBefore,
185
+ allowClear,
186
+ className,
187
+ disabled,
188
+ focused,
189
+ handleReset: (event) => {
190
+ if (controlledValue === void 0) setInnerValue("");
191
+ triggerFocus(inputRef.current);
192
+ if (inputRef.current) resolveOnChange(inputRef.current, event, onChange);
193
+ },
194
+ onClear,
195
+ prefix,
196
+ readOnly,
197
+ size,
198
+ status,
199
+ suffix,
200
+ triggerInputFocus: () => triggerFocus(inputRef.current),
201
+ value: formattedValue,
202
+ children: input
203
+ }
204
+ );
205
+ });
206
+ BInput.displayName = "BInput";
207
+ export {
208
+ BInput as default
209
+ };
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function hasAddon(props) {
4
+ return Boolean(props.addonBefore || props.addonAfter);
5
+ }
6
+ function hasPrefixSuffix(props) {
7
+ return Boolean(props.prefix || props.suffix || props.allowClear);
8
+ }
9
+ function cloneEvent(event, target, value) {
10
+ const currentTarget = target.cloneNode(true);
11
+ const nextEvent = Object.create(event, {
12
+ target: { value: currentTarget },
13
+ currentTarget: { value: currentTarget }
14
+ });
15
+ currentTarget.value = value;
16
+ if (typeof target.selectionStart === "number" && typeof target.selectionEnd === "number") {
17
+ currentTarget.selectionStart = target.selectionStart;
18
+ currentTarget.selectionEnd = target.selectionEnd;
19
+ }
20
+ currentTarget.setSelectionRange = (...argumentsList) => target.setSelectionRange(...argumentsList);
21
+ return nextEvent;
22
+ }
23
+ function resolveOnChange(target, event, onChange, targetValue) {
24
+ if (!onChange) return;
25
+ if (event.type === "click") {
26
+ onChange(cloneEvent(event, target, ""));
27
+ return;
28
+ }
29
+ if (target.type !== "file" && targetValue !== void 0) {
30
+ onChange(cloneEvent(event, target, targetValue));
31
+ return;
32
+ }
33
+ onChange(event);
34
+ }
35
+ function triggerFocus(element, option) {
36
+ if (!element) return;
37
+ element.focus(option);
38
+ if (!(option == null ? void 0 : option.cursor)) return;
39
+ const length = element.value.length;
40
+ if (option.cursor === "start") element.setSelectionRange(0, 0);
41
+ else if (option.cursor === "end") element.setSelectionRange(length, length);
42
+ else element.setSelectionRange(0, length);
43
+ }
44
+ exports.hasAddon = hasAddon;
45
+ exports.hasPrefixSuffix = hasPrefixSuffix;
46
+ exports.resolveOnChange = resolveOnChange;
47
+ exports.triggerFocus = triggerFocus;
@@ -0,0 +1,47 @@
1
+ function hasAddon(props) {
2
+ return Boolean(props.addonBefore || props.addonAfter);
3
+ }
4
+ function hasPrefixSuffix(props) {
5
+ return Boolean(props.prefix || props.suffix || props.allowClear);
6
+ }
7
+ function cloneEvent(event, target, value) {
8
+ const currentTarget = target.cloneNode(true);
9
+ const nextEvent = Object.create(event, {
10
+ target: { value: currentTarget },
11
+ currentTarget: { value: currentTarget }
12
+ });
13
+ currentTarget.value = value;
14
+ if (typeof target.selectionStart === "number" && typeof target.selectionEnd === "number") {
15
+ currentTarget.selectionStart = target.selectionStart;
16
+ currentTarget.selectionEnd = target.selectionEnd;
17
+ }
18
+ currentTarget.setSelectionRange = (...argumentsList) => target.setSelectionRange(...argumentsList);
19
+ return nextEvent;
20
+ }
21
+ function resolveOnChange(target, event, onChange, targetValue) {
22
+ if (!onChange) return;
23
+ if (event.type === "click") {
24
+ onChange(cloneEvent(event, target, ""));
25
+ return;
26
+ }
27
+ if (target.type !== "file" && targetValue !== void 0) {
28
+ onChange(cloneEvent(event, target, targetValue));
29
+ return;
30
+ }
31
+ onChange(event);
32
+ }
33
+ function triggerFocus(element, option) {
34
+ if (!element) return;
35
+ element.focus(option);
36
+ if (!(option == null ? void 0 : option.cursor)) return;
37
+ const length = element.value.length;
38
+ if (option.cursor === "start") element.setSelectionRange(0, 0);
39
+ else if (option.cursor === "end") element.setSelectionRange(length, length);
40
+ else element.setSelectionRange(0, length);
41
+ }
42
+ export {
43
+ hasAddon,
44
+ hasPrefixSuffix,
45
+ resolveOnChange,
46
+ triggerFocus
47
+ };