@wix/editor-react-components 1.2763.0 → 1.2765.0
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/site/components/AccordionComponent/manifest.js +1 -1
- package/dist/site/components/AudioPlayer/component.js +4 -3
- package/dist/site/components/AudioPlayer/manifest.js +1 -1
- package/dist/site/components/BoxContainer/component.js +2 -2
- package/dist/site/components/Breadcrumbs/component.js +3 -3
- package/dist/site/components/Breadcrumbs/manifest.js +1 -1
- package/dist/site/components/Button/component.js +1 -1
- package/dist/site/components/Button/manifest.js +1 -1
- package/dist/site/components/Checkbox/component.js +2 -2
- package/dist/site/components/CheckboxGroup/component.js +2 -2
- package/dist/site/components/CollapsibleText/component.js +2 -2
- package/dist/site/components/CollapsibleText/manifest.js +1 -1
- package/dist/site/components/DatePicker/component.js +6 -4
- package/dist/site/components/Dropdown/component.js +1 -1
- package/dist/site/components/Dropdown/manifest.js +1 -1
- package/dist/site/components/GoogleMap/manifest.js +1 -1
- package/dist/site/components/HTMLComponent/manifest.js +1 -1
- package/dist/site/components/HeadingTextBlock/component.js +2 -2
- package/dist/site/components/HipaaIcon/component.js +1 -1
- package/dist/site/components/Image3/component.js +1 -1
- package/dist/site/components/Image3/component.preview.d.ts +1 -3
- package/dist/site/components/Image3/manifest.js +1 -4
- package/dist/site/components/ImageReveal/component.js +2 -2
- package/dist/site/components/LegacyAppWidget/component.js +1 -1
- package/dist/site/components/LegacyContainer/component.js +1 -1
- package/dist/site/components/LegacyMultiStateBox/component.js +2 -2
- package/dist/site/components/Line/component.js +1 -1
- package/dist/site/components/LinkBar/manifest.js +1 -1
- package/dist/site/components/Lottie/component.js +1 -1
- package/dist/site/components/Lottie/manifest.js +1 -1
- package/dist/site/components/MarkdownBlock/component.js +1 -1
- package/dist/site/components/Menu/component.js +3 -3
- package/dist/site/components/Menu/manifest.js +1 -1
- package/dist/site/components/MultiStateBox/manifest.js +1 -1
- package/dist/site/components/RadioButtons/component.js +2 -2
- package/dist/site/components/ShareButtons/component.js +1 -1
- package/dist/site/components/ShareButtons/manifest.js +1 -1
- package/dist/site/components/Slideshow/component.js +1 -1
- package/dist/site/components/Slideshow/manifest.js +1 -1
- package/dist/site/components/Tabs/manifest.js +1 -1
- package/dist/site/components/TestComp/manifest.js +1 -1
- package/dist/site/components/TextBox/component.js +1 -1
- package/dist/site/components/TextEffects3d/component.js +1 -1
- package/dist/site/components/TextEffectsBauhaus/component.js +1 -1
- package/dist/site/components/TextEffectsGlass/component.js +1 -1
- package/dist/site/components/TextEffectsGlitch/component.js +1 -1
- package/dist/site/components/TextEffectsLetterPress/component.js +1 -1
- package/dist/site/components/TextEffectsMatrix/component.js +1 -1
- package/dist/site/components/TextEffectsNeonSign/component.js +1 -1
- package/dist/site/components/TextEffectsNoisy/component.js +1 -1
- package/dist/site/components/TextEffectsOutlineOut/component.js +1 -1
- package/dist/site/components/TextEffectsRetro/component.js +1 -1
- package/dist/site/components/TextEffectsShook/component.js +1 -1
- package/dist/site/components/TextEffectsSticker/component.js +1 -1
- package/dist/site/components/TextEffectsStriped/component.js +1 -1
- package/dist/site/components/TextInput/TextInput.d.ts +3 -7
- package/dist/site/components/TextInput/TextInput.types.d.ts +38 -105
- package/dist/site/components/TextInput/component.js +104 -780
- package/dist/site/components/TextInput/component.preview.d.ts +1 -4
- package/dist/site/components/TextInput/constants.d.ts +17 -65
- package/dist/site/components/TextInput/css.css +25 -223
- package/dist/site/components/TextInput/manifest.js +181 -367
- package/dist/site/components/TimePicker/component.js +6 -5
- package/dist/site/components/chunks/AnimatedIcon.js +1 -1
- package/dist/site/components/chunks/Button.js +1055 -466
- package/dist/site/components/chunks/Button2.js +486 -0
- package/dist/site/components/chunks/Group.js +46 -970
- package/dist/site/components/chunks/I18nProvider.js +125 -0
- package/dist/site/components/chunks/Input.js +369 -0
- package/dist/site/components/chunks/Link.js +1 -1
- package/dist/site/components/chunks/ResponsiveBox.js +1 -1
- package/dist/site/components/chunks/ResponsiveContainer.js +1 -1
- package/dist/site/components/chunks/TextEffectsShared.js +1 -1
- package/dist/site/components/chunks/Tooltip.js +6745 -351
- package/dist/site/components/chunks/VisuallyHidden.js +1 -1
- package/dist/site/components/chunks/a11y.js +4 -5
- package/dist/site/components/chunks/constants3.js +23 -63
- package/dist/site/components/chunks/filterDOMProps.js +18 -139
- package/dist/site/components/chunks/index10.js +3 -2020
- package/dist/site/components/chunks/index11.js +31184 -232
- package/dist/site/components/chunks/index12.js +3 -31191
- package/dist/site/components/chunks/index13.js +44 -3
- package/dist/site/components/chunks/index3.js +1 -1
- package/dist/site/components/chunks/index4.js +1 -1
- package/dist/site/components/chunks/index5.js +1 -1
- package/dist/site/components/chunks/index7.js +67 -3
- package/dist/site/components/chunks/index8.js +2020 -3
- package/dist/site/components/chunks/index9.js +232 -60
- package/dist/site/components/chunks/manifestSdkMixins.js +4 -4
- package/dist/site/components/chunks/parseHtml.js +1 -1
- package/dist/site/components/chunks/parseSvg.js +1 -1
- package/dist/site/components/chunks/staticService.js +1 -1
- package/dist/site/components/chunks/useConsentPolicyProps.js +1 -1
- package/dist/site/components/chunks/useLocalizedStringFormatter.js +1 -1
- package/package.json +2 -2
- package/dist/site/components/TextInput/TextInput.viewer.constants.d.ts +0 -24
- package/dist/site/components/TextInput/sdk.d.ts +0 -4
- package/dist/site/components/TextInput/sdk.js +0 -91
- package/dist/site/components/TextInput/utils.d.ts +0 -9
- package/dist/site/components/chunks/DateField.js +0 -6762
- package/dist/site/components/chunks/NumberFormatter.js +0 -140
- package/dist/site/components/chunks/index14.js +0 -46
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import React__default, { createContext, useState, useRef, useCallback
|
|
3
|
+
import React__default, { createContext, useState, useRef, useCallback } from "react";
|
|
4
4
|
import { c as clsx } from "../chunks/clsx.js";
|
|
5
5
|
import { E as EnvironmentDefinition } from "../chunks/index2.js";
|
|
6
|
-
import { b as getAccessibilityAttributes, H as HAS_CUSTOM_FOCUS_CLASSNAME } from "../chunks/a11y.js";
|
|
7
6
|
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
8
|
-
import {
|
|
7
|
+
import { p as presetWrapperStyles } from "../chunks/presetWrapper.module.js";
|
|
9
8
|
import { d as directionStyles } from "../chunks/direction.module.js";
|
|
10
9
|
import { a as accessibilityStyles } from "../chunks/accessibility.module.js";
|
|
11
|
-
import {
|
|
10
|
+
import { c as componentClassNames, D as DesignStates, E as ERROR_MESSAGE_PREVIEW_TEXT } from "../chunks/constants3.js";
|
|
12
11
|
import { useService } from "@wix/services-manager-react";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { a as $8e9d2fae0ecb9001$export$457c3d6518dd4c6f, b as $f39a9eba43920ace$export$86427a43e3e48ebb, c as $64fa3d84918910a7$export$29f1550f4b0d4415, d as $64fa3d84918910a7$export$fabf2dc03a41866e, e as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, f as $64fa3d84918910a7$export$ef03459518577ad4, g as $64fa3d84918910a7$export$4d86445c2cf5e3, h as $65484d02dcb7eb3e$export$457c3d6518dd4c6f, i as $64fa3d84918910a7$export$2881499e37b75b9a } from "../chunks/filterDOMProps.js";
|
|
17
|
-
import { S as SdkStateDefinition } from "../chunks/index7.js";
|
|
18
|
-
import { I as InfoCircleSmall_default } from "../chunks/InfoCircleSmall.js";
|
|
12
|
+
import { b as $fd2148440a13ec26$export$fc1a364ae1f3ff10, c as $191c9b6d48a0a4e2$export$294aa081a6c6f55d, d as $860f7da480e22816$export$b8473d3665f3a75a, e as $d3e0e05bdfcf66bd$export$c24727297075ec6a, f as $3985021b0ad6602f$export$37fb8590cf2c088c, g as $514c0188e459b4c0$export$9afb8bc826b033ea, h as $ee014567cb39d3f0$export$ff05c3ac10437e03, i as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../chunks/Input.js";
|
|
13
|
+
import { b as $3e6197669829fe11$export$40bfa8c7b0832715, c as $d1116acdf220c2da$export$4c014de7c8940b4c, d as $3274bf1495747a7b$export$5add1d006293d136, e as $bbaa08b3cd72f041$export$9d1611c77c2fe928, f as $23f2114a1b82827e$export$e58f029f0fbfdb29, g as $01b77f81d0f07f68$export$75b6ee27786ba447, h as $a049562f99e7db0e$export$f9c6924e160136d1, a as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../chunks/Group.js";
|
|
14
|
+
import { $ as $8e9d2fae0ecb9001$export$457c3d6518dd4c6f, a as $f39a9eba43920ace$export$86427a43e3e48ebb, b as $64fa3d84918910a7$export$29f1550f4b0d4415, c as $64fa3d84918910a7$export$fabf2dc03a41866e, d as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, e as $64fa3d84918910a7$export$ef03459518577ad4, f as $64fa3d84918910a7$export$4d86445c2cf5e3, g as $65484d02dcb7eb3e$export$457c3d6518dd4c6f, h as $64fa3d84918910a7$export$2881499e37b75b9a } from "../chunks/filterDOMProps.js";
|
|
19
15
|
const $8e6cc465cc68f603$export$698f465ec27e93df = /* @__PURE__ */ createContext(null);
|
|
20
16
|
function $054f71d2330da2e3$export$712718f7aec83d5(props, ref) {
|
|
21
17
|
let { inputElementType = "input", isDisabled = false, isRequired = false, isReadOnly = false, type = "text", validationBehavior = "aria" } = props;
|
|
@@ -183,837 +179,165 @@ const $bcdf0525bf22703d$export$2c73285ae9390cec = /* @__PURE__ */ $f39a9eba43920
|
|
|
183
179
|
]
|
|
184
180
|
}, renderProps.children));
|
|
185
181
|
});
|
|
186
|
-
const ABORT_SIGNAL_TIMEOUT = 5e3;
|
|
187
|
-
function createTimeoutSignal(timeout) {
|
|
188
|
-
if (typeof AbortSignal.timeout === "function") {
|
|
189
|
-
return AbortSignal.timeout(timeout);
|
|
190
|
-
}
|
|
191
|
-
const controller = new AbortController();
|
|
192
|
-
setTimeout(() => {
|
|
193
|
-
try {
|
|
194
|
-
controller.abort(
|
|
195
|
-
new DOMException(
|
|
196
|
-
"The operation was aborted due to timeout",
|
|
197
|
-
"TimeoutError"
|
|
198
|
-
)
|
|
199
|
-
);
|
|
200
|
-
} catch {
|
|
201
|
-
controller.abort();
|
|
202
|
-
}
|
|
203
|
-
}, timeout);
|
|
204
|
-
return controller.signal;
|
|
205
|
-
}
|
|
206
|
-
class IconContentFetcher {
|
|
207
|
-
constructor() {
|
|
208
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
209
|
-
this.pendingRequests = /* @__PURE__ */ new Map();
|
|
210
|
-
this.failedRequests = /* @__PURE__ */ new Set();
|
|
211
|
-
}
|
|
212
|
-
fetch(params) {
|
|
213
|
-
const { name, theme, category, hash } = params;
|
|
214
|
-
const cacheKey = `${name}.${theme}`;
|
|
215
|
-
if (this.cache.has(cacheKey)) {
|
|
216
|
-
return this.cache.get(cacheKey);
|
|
217
|
-
}
|
|
218
|
-
if (this.failedRequests.has(cacheKey)) {
|
|
219
|
-
throw new Error(`Icon ${name} failed to load`);
|
|
220
|
-
}
|
|
221
|
-
if (this.pendingRequests.has(cacheKey)) {
|
|
222
|
-
throw this.pendingRequests.get(cacheKey);
|
|
223
|
-
}
|
|
224
|
-
if (typeof fetch !== "function") {
|
|
225
|
-
return "";
|
|
226
|
-
}
|
|
227
|
-
const url = `https://static.parastorage.com/services/wix-ui-icons-common/dist/icons/${theme}/${category}/${name}.${hash}.json`;
|
|
228
|
-
const request = fetch(url, {
|
|
229
|
-
signal: createTimeoutSignal(ABORT_SIGNAL_TIMEOUT)
|
|
230
|
-
}).then((res) => {
|
|
231
|
-
if (!res.ok) {
|
|
232
|
-
throw new Error(`Failed to fetch icon: ${res.status}`);
|
|
233
|
-
}
|
|
234
|
-
return res.json();
|
|
235
|
-
}).then((data) => {
|
|
236
|
-
this.cache.set(cacheKey, data.content);
|
|
237
|
-
this.pendingRequests.delete(cacheKey);
|
|
238
|
-
}).catch((error) => {
|
|
239
|
-
this.pendingRequests.delete(cacheKey);
|
|
240
|
-
this.failedRequests.add(cacheKey);
|
|
241
|
-
console.error(`Error fetching icon ${name}:`, error);
|
|
242
|
-
throw error;
|
|
243
|
-
});
|
|
244
|
-
this.pendingRequests.set(cacheKey, request);
|
|
245
|
-
throw request;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
const iconContentFetcher = new IconContentFetcher();
|
|
249
|
-
const ErrorBoundaryContext = createContext(null);
|
|
250
|
-
const initialState = {
|
|
251
|
-
didCatch: false,
|
|
252
|
-
error: null
|
|
253
|
-
};
|
|
254
|
-
class ErrorBoundary extends Component {
|
|
255
|
-
constructor(props) {
|
|
256
|
-
super(props);
|
|
257
|
-
this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
|
|
258
|
-
this.state = initialState;
|
|
259
|
-
}
|
|
260
|
-
static getDerivedStateFromError(error) {
|
|
261
|
-
return {
|
|
262
|
-
didCatch: true,
|
|
263
|
-
error
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
resetErrorBoundary() {
|
|
267
|
-
const {
|
|
268
|
-
error
|
|
269
|
-
} = this.state;
|
|
270
|
-
if (error !== null) {
|
|
271
|
-
var _this$props$onReset, _this$props;
|
|
272
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
273
|
-
args[_key] = arguments[_key];
|
|
274
|
-
}
|
|
275
|
-
(_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, {
|
|
276
|
-
args,
|
|
277
|
-
reason: "imperative-api"
|
|
278
|
-
});
|
|
279
|
-
this.setState(initialState);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
componentDidCatch(error, info) {
|
|
283
|
-
var _this$props$onError, _this$props2;
|
|
284
|
-
(_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);
|
|
285
|
-
}
|
|
286
|
-
componentDidUpdate(prevProps, prevState) {
|
|
287
|
-
const {
|
|
288
|
-
didCatch
|
|
289
|
-
} = this.state;
|
|
290
|
-
const {
|
|
291
|
-
resetKeys
|
|
292
|
-
} = this.props;
|
|
293
|
-
if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {
|
|
294
|
-
var _this$props$onReset2, _this$props3;
|
|
295
|
-
(_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, {
|
|
296
|
-
next: resetKeys,
|
|
297
|
-
prev: prevProps.resetKeys,
|
|
298
|
-
reason: "keys"
|
|
299
|
-
});
|
|
300
|
-
this.setState(initialState);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
render() {
|
|
304
|
-
const {
|
|
305
|
-
children,
|
|
306
|
-
fallbackRender,
|
|
307
|
-
FallbackComponent,
|
|
308
|
-
fallback
|
|
309
|
-
} = this.props;
|
|
310
|
-
const {
|
|
311
|
-
didCatch,
|
|
312
|
-
error
|
|
313
|
-
} = this.state;
|
|
314
|
-
let childToRender = children;
|
|
315
|
-
if (didCatch) {
|
|
316
|
-
const props = {
|
|
317
|
-
error,
|
|
318
|
-
resetErrorBoundary: this.resetErrorBoundary
|
|
319
|
-
};
|
|
320
|
-
if (typeof fallbackRender === "function") {
|
|
321
|
-
childToRender = fallbackRender(props);
|
|
322
|
-
} else if (FallbackComponent) {
|
|
323
|
-
childToRender = createElement(FallbackComponent, props);
|
|
324
|
-
} else if (fallback !== void 0) {
|
|
325
|
-
childToRender = fallback;
|
|
326
|
-
} else {
|
|
327
|
-
throw error;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
return createElement(ErrorBoundaryContext.Provider, {
|
|
331
|
-
value: {
|
|
332
|
-
didCatch,
|
|
333
|
-
error,
|
|
334
|
-
resetErrorBoundary: this.resetErrorBoundary
|
|
335
|
-
}
|
|
336
|
-
}, childToRender);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
function hasArrayChanged() {
|
|
340
|
-
let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
341
|
-
let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
342
|
-
return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
|
|
343
|
-
}
|
|
344
|
-
function getIconAttrs(params) {
|
|
345
|
-
const { size, width, height } = params;
|
|
346
|
-
return {
|
|
347
|
-
dimensions: size ? { width: size, height: size } : { width, height },
|
|
348
|
-
viewBox: `0 0 ${width} ${height}`
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
function EmptyState({
|
|
352
|
-
width,
|
|
353
|
-
height,
|
|
354
|
-
size,
|
|
355
|
-
restProps
|
|
356
|
-
}) {
|
|
357
|
-
const { dimensions, viewBox } = getIconAttrs({
|
|
358
|
-
size,
|
|
359
|
-
width,
|
|
360
|
-
height
|
|
361
|
-
});
|
|
362
|
-
return /* @__PURE__ */ React__default.createElement("svg", { viewBox, ...dimensions, ...restProps });
|
|
363
|
-
}
|
|
364
|
-
if (!globalThis.__WDSIconThemeContext__) {
|
|
365
|
-
globalThis.__WDSIconThemeContext__ = createContext("default");
|
|
366
|
-
}
|
|
367
|
-
const IconThemeContext = globalThis.__WDSIconThemeContext__;
|
|
368
|
-
const icon = (params) => {
|
|
369
|
-
const { name, hashes, category, width, height } = params;
|
|
370
|
-
const IconContent = (props) => {
|
|
371
|
-
const { size, ...restProps } = props;
|
|
372
|
-
const selectedTheme = useContext(IconThemeContext);
|
|
373
|
-
let themeToUse = selectedTheme;
|
|
374
|
-
let hash = hashes[themeToUse];
|
|
375
|
-
if (!hash) {
|
|
376
|
-
themeToUse = hashes.default ? "default" : "odeditor";
|
|
377
|
-
hash = hashes.default || hashes.odeditor;
|
|
378
|
-
}
|
|
379
|
-
const content = iconContentFetcher.fetch({
|
|
380
|
-
name,
|
|
381
|
-
theme: themeToUse,
|
|
382
|
-
category,
|
|
383
|
-
hash
|
|
384
|
-
});
|
|
385
|
-
const { dimensions, viewBox } = getIconAttrs({
|
|
386
|
-
size,
|
|
387
|
-
width,
|
|
388
|
-
height
|
|
389
|
-
});
|
|
390
|
-
return /* @__PURE__ */ React__default.createElement("svg", { fill: "currentColor", viewBox, ...dimensions, ...restProps }, /* @__PURE__ */ React__default.createElement(
|
|
391
|
-
"g",
|
|
392
|
-
{
|
|
393
|
-
...{
|
|
394
|
-
// eslint-disable-next-line no-useless-concat
|
|
395
|
-
["dangerouslySetInnerHTML"]: { __html: content }
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
));
|
|
399
|
-
};
|
|
400
|
-
const Icon = (props) => {
|
|
401
|
-
const { size, ...restProps } = props;
|
|
402
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
403
|
-
ErrorBoundary,
|
|
404
|
-
{
|
|
405
|
-
fallback: /* @__PURE__ */ React__default.createElement(
|
|
406
|
-
EmptyState,
|
|
407
|
-
{
|
|
408
|
-
width,
|
|
409
|
-
height,
|
|
410
|
-
size,
|
|
411
|
-
restProps
|
|
412
|
-
}
|
|
413
|
-
)
|
|
414
|
-
},
|
|
415
|
-
/* @__PURE__ */ React__default.createElement(
|
|
416
|
-
Suspense,
|
|
417
|
-
{
|
|
418
|
-
fallback: /* @__PURE__ */ React__default.createElement(
|
|
419
|
-
EmptyState,
|
|
420
|
-
{
|
|
421
|
-
width,
|
|
422
|
-
height,
|
|
423
|
-
size,
|
|
424
|
-
restProps
|
|
425
|
-
}
|
|
426
|
-
)
|
|
427
|
-
},
|
|
428
|
-
/* @__PURE__ */ React__default.createElement(IconContent, { ...props })
|
|
429
|
-
)
|
|
430
|
-
);
|
|
431
|
-
};
|
|
432
|
-
Icon.displayName = `Icon(${params.name})`;
|
|
433
|
-
return Icon;
|
|
434
|
-
};
|
|
435
|
-
var StatusAlertSmall_default = icon({
|
|
436
|
-
name: "StatusAlertSmall",
|
|
437
|
-
hashes: { "default": "0ea2", "odeditor": "a9df" },
|
|
438
|
-
category: "general",
|
|
439
|
-
width: 18,
|
|
440
|
-
height: 18
|
|
441
|
-
});
|
|
442
|
-
const inlineErrorIndication = "inlineErrorIndication__3ZgfF";
|
|
443
|
-
const iconErrorMessage = "iconErrorMessage__ZKTPr";
|
|
444
|
-
const txtErrMsg = "txtErrMsg__Wqn6o";
|
|
445
|
-
const style$1 = {
|
|
446
|
-
inlineErrorIndication,
|
|
447
|
-
iconErrorMessage,
|
|
448
|
-
txtErrMsg
|
|
449
|
-
};
|
|
450
|
-
const errorMessageFallbackText = "Error text displays here.";
|
|
451
|
-
const InlineErrorMessage = ({
|
|
452
|
-
id,
|
|
453
|
-
errorMessage,
|
|
454
|
-
errorMessageType,
|
|
455
|
-
shouldShowValidityIndication,
|
|
456
|
-
translations,
|
|
457
|
-
dataHook,
|
|
458
|
-
componentViewMode
|
|
459
|
-
}) => {
|
|
460
|
-
const getOnStageErrorText = () => {
|
|
461
|
-
return (translations == null ? void 0 : translations.errorMessage) || errorMessageFallbackText;
|
|
462
|
-
};
|
|
463
|
-
const errorMessageText = componentViewMode === "editor" ? getOnStageErrorText() : errorMessage;
|
|
464
|
-
const hasInlineErrorMessage = errorMessageType === "inline" && shouldShowValidityIndication && errorMessageText;
|
|
465
|
-
return hasInlineErrorMessage ? /* @__PURE__ */ jsxs(
|
|
466
|
-
"div",
|
|
467
|
-
{
|
|
468
|
-
"data-hook": dataHook ? dataHook : "inline-error-message",
|
|
469
|
-
className: style$1.inlineErrorIndication,
|
|
470
|
-
children: [
|
|
471
|
-
/* @__PURE__ */ jsx(StatusAlertSmall_default, { className: style$1.iconErrorMessage }),
|
|
472
|
-
/* @__PURE__ */ jsx("span", { id, className: style$1.txtErrMsg, children: errorMessageText })
|
|
473
|
-
]
|
|
474
|
-
}
|
|
475
|
-
) : null;
|
|
476
|
-
};
|
|
477
182
|
const root = "root__zQlRz";
|
|
478
183
|
const inputWrapper = "inputWrapper__2KDrH";
|
|
479
|
-
const prefix = "prefix__fIo1S";
|
|
480
184
|
const input = "input__fyTfx";
|
|
481
|
-
const hideNumberSpinner = "hideNumberSpinner__nYhia";
|
|
482
|
-
const hasPrefix = "hasPrefix__RXMKp";
|
|
483
|
-
const validationIndication = "validationIndication__GE20D";
|
|
484
|
-
const helperText = "helperText__SfMAH";
|
|
485
185
|
const label = "label__mbGIM";
|
|
486
|
-
const
|
|
487
|
-
const
|
|
488
|
-
const infoIcon = "infoIcon__Ksarp";
|
|
489
|
-
const tooltip = "tooltip__JnxIe";
|
|
490
|
-
const hasLabel = "hasLabel__AGhlP";
|
|
491
|
-
const requiredIndicator = "requiredIndicator__RyrLe";
|
|
186
|
+
const helperText = "helperText__SfMAH";
|
|
187
|
+
const errorMessage = "errorMessage__4XDzv";
|
|
492
188
|
const style = {
|
|
493
189
|
root,
|
|
494
190
|
inputWrapper,
|
|
495
|
-
prefix,
|
|
496
191
|
input,
|
|
497
|
-
hideNumberSpinner,
|
|
498
|
-
hasPrefix,
|
|
499
|
-
validationIndication,
|
|
500
|
-
helperText,
|
|
501
192
|
label,
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
infoIcon,
|
|
505
|
-
tooltip,
|
|
506
|
-
hasLabel,
|
|
507
|
-
requiredIndicator
|
|
508
|
-
};
|
|
509
|
-
const TranslationKeys = {
|
|
510
|
-
NAMESPACE: "Text_Input",
|
|
511
|
-
PHONE_FORMAT_LENGTH_VALIDATION_ERROR: "text_input_phone_format_length_validation_error",
|
|
512
|
-
PHONE_FORMAT_LENGTH_VALIDATION_ERROR_DEFAULT: "Please enter a phone number with {digits} digits",
|
|
513
|
-
PHONE_FORMAT_DEFAULT_VALIDATION_ERROR: "text_input_phone_format_default_validation_error",
|
|
514
|
-
PHONE_FORMAT_DEFAULT_VALIDATION_ERROR_DEFAULT: "Please enter between 4 to 17 digits. You can include hyphens (-) or start with a (+), e.g., 555-123-4567 or +(222)987654321",
|
|
515
|
-
PHONE_FORMAT_COMPLEX_PHONE_DEFAULT_VALIDATION_ERROR: "text_input_phone_format_complex_phone_default_validation_error",
|
|
516
|
-
PHONE_FORMAT_COMPLEX_PHONE_DEFAULT_VALIDATION_ERROR_DEFAULT: "Please enter between 4 to 17 digits. You can include dividers (-), e.g., 555-123-4567.",
|
|
517
|
-
INLINE_ERROR_MESSAGE_DEFAULT_ERROR_MESSAGE: "Text_Input_On_Stage_Error_Text_Label"
|
|
518
|
-
};
|
|
519
|
-
const formatPhoneNumber = (unformattedValue, phoneFormat) => {
|
|
520
|
-
const spaceInfo = getSpaceIndexesForPhoneFormat(
|
|
521
|
-
unformattedValue,
|
|
522
|
-
phoneFormat,
|
|
523
|
-
false
|
|
524
|
-
);
|
|
525
|
-
const newValueAsArray = Array.from(unformattedValue);
|
|
526
|
-
spaceInfo.forEach((spaceIdx) => {
|
|
527
|
-
if (spaceIdx < newValueAsArray.length) {
|
|
528
|
-
newValueAsArray.splice(spaceIdx, 0, " ");
|
|
529
|
-
}
|
|
530
|
-
});
|
|
531
|
-
return newValueAsArray.join("");
|
|
532
|
-
};
|
|
533
|
-
const getSpaceIndexesForPhoneFormat = (val, phoneFormat, isValueFormatted = true) => {
|
|
534
|
-
const updatedSpaceInfo = Array.from(phoneFormat).reduce((agg, curr, idx) => {
|
|
535
|
-
return curr === "-" ? [...agg, idx] : agg;
|
|
536
|
-
}, []).filter((spaceIdx, index) => {
|
|
537
|
-
return isValueFormatted ? spaceIdx <= val.length : spaceIdx <= val.length + index;
|
|
538
|
-
});
|
|
539
|
-
return updatedSpaceInfo;
|
|
540
|
-
};
|
|
541
|
-
const getUnformattedNumber = (val, phoneFormat, didDeleteChars) => {
|
|
542
|
-
const updatedSpaceInfo = getSpaceIndexesForPhoneFormat(val, phoneFormat);
|
|
543
|
-
return updatedSpaceInfo.reduce((agg, curr, idx) => {
|
|
544
|
-
if (val[curr] === " ") {
|
|
545
|
-
agg.splice(curr - idx, 1);
|
|
546
|
-
} else if (val[curr + 1] === " " && !didDeleteChars) {
|
|
547
|
-
const offset = 1 - idx;
|
|
548
|
-
agg.splice(curr + offset, 1);
|
|
549
|
-
} else if (val[curr - 1] === " " && didDeleteChars) {
|
|
550
|
-
const didDeleteSpace = val.split(" ").length - 1 < updatedSpaceInfo.length;
|
|
551
|
-
if (didDeleteSpace) {
|
|
552
|
-
agg.splice(curr - idx, 1);
|
|
553
|
-
} else {
|
|
554
|
-
agg.splice(curr - idx - 1, 1);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
return agg;
|
|
558
|
-
}, Array.from(val)).join("");
|
|
559
|
-
};
|
|
560
|
-
const hasNonNumericChar = (str) => !!str.match(/[^\d]/);
|
|
561
|
-
const translateHtmlValidationMessage = (message, {
|
|
562
|
-
translations,
|
|
563
|
-
phoneFormat
|
|
564
|
-
}) => {
|
|
565
|
-
switch (message.key) {
|
|
566
|
-
case "PHONE_FORMAT_LENGTH_VALIDATION_ERROR":
|
|
567
|
-
return getPhoneFormatLengthValidationError(
|
|
568
|
-
phoneFormat,
|
|
569
|
-
(translations == null ? void 0 : translations.phoneFormatLengthValidationError) || TranslationKeys.PHONE_FORMAT_LENGTH_VALIDATION_ERROR_DEFAULT
|
|
570
|
-
);
|
|
571
|
-
case "PHONE_FORMAT_DEFAULT_VALIDATION_ERROR":
|
|
572
|
-
return (translations == null ? void 0 : translations.phoneFormatDefaultValidationError) || TranslationKeys.PHONE_FORMAT_DEFAULT_VALIDATION_ERROR_DEFAULT;
|
|
573
|
-
case "PHONE_FORMAT_COMPLEX_PHONE_DEFAULT_VALIDATION_ERROR":
|
|
574
|
-
return (translations == null ? void 0 : translations.phoneFormatComplexPhoneDefaultValidationError) || TranslationKeys.PHONE_FORMAT_COMPLEX_PHONE_DEFAULT_VALIDATION_ERROR_DEFAULT;
|
|
575
|
-
default:
|
|
576
|
-
return message.key;
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
const getPhoneFormatLengthValidationError = (phoneFormat, phoneFormatLengthValidationError) => phoneFormatLengthValidationError.replace(
|
|
580
|
-
"{digits}",
|
|
581
|
-
`${phoneFormat ? phoneFormat.replace(/-/g, "").length : 0}`
|
|
582
|
-
);
|
|
583
|
-
const useSdkState = (componentId, key, defaultValue) => {
|
|
584
|
-
const $sig = useService(SdkStateDefinition).for(componentId).getSignal(key, defaultValue);
|
|
585
|
-
return [$sig.get(), (value) => $sig.set(value)];
|
|
193
|
+
helperText,
|
|
194
|
+
errorMessage
|
|
586
195
|
};
|
|
587
196
|
const noop = () => {
|
|
588
197
|
};
|
|
589
|
-
const TextInput = (props
|
|
590
|
-
var _a;
|
|
198
|
+
const TextInput = (props) => {
|
|
199
|
+
var _a, _b, _c, _d;
|
|
591
200
|
const {
|
|
592
|
-
name,
|
|
593
201
|
id,
|
|
594
202
|
className = "",
|
|
595
203
|
dataTestId,
|
|
596
|
-
inputType = "text",
|
|
597
204
|
label: label2,
|
|
598
|
-
tooltip: tooltip2,
|
|
599
205
|
placeholder,
|
|
600
|
-
|
|
206
|
+
helperText: helperText2,
|
|
207
|
+
errorMessage: errorMessage2,
|
|
208
|
+
previewError,
|
|
601
209
|
direction,
|
|
602
|
-
labelDirection,
|
|
603
|
-
inputDirection,
|
|
604
210
|
readOnly,
|
|
605
|
-
|
|
606
|
-
isDisabled,
|
|
607
|
-
pattern,
|
|
608
|
-
autoComplete,
|
|
609
|
-
autoComplete_,
|
|
610
|
-
autocompleteToken,
|
|
611
|
-
maxLength,
|
|
612
|
-
minLength,
|
|
613
|
-
min,
|
|
614
|
-
max,
|
|
615
|
-
step,
|
|
616
|
-
numberSpinnerHidden,
|
|
211
|
+
disabled,
|
|
617
212
|
autoFocus,
|
|
618
|
-
|
|
619
|
-
phoneFormat = "",
|
|
620
|
-
errorMessageType = "inline",
|
|
621
|
-
validateValue = noop,
|
|
622
|
-
onBlur = noop,
|
|
623
|
-
onFocus = noop,
|
|
624
|
-
onKeyPress = noop,
|
|
625
|
-
onInput = noop,
|
|
626
|
-
onChange = noop,
|
|
627
|
-
onClick = noop,
|
|
628
|
-
onDblClick = noop,
|
|
629
|
-
onMouseEnter = noop,
|
|
630
|
-
onMouseLeave = noop,
|
|
631
|
-
onHydrationComplete = noop,
|
|
213
|
+
onValueChange = noop,
|
|
632
214
|
a11y,
|
|
633
|
-
|
|
634
|
-
|
|
215
|
+
contentRef,
|
|
216
|
+
elementProps,
|
|
217
|
+
wix
|
|
635
218
|
} = props;
|
|
636
|
-
const {
|
|
637
|
-
|
|
638
|
-
);
|
|
639
|
-
const { translate } = useService(
|
|
640
|
-
TranslationsDefinition
|
|
641
|
-
);
|
|
642
|
-
const [sdkValue, setSdkValue] = useSdkState(
|
|
643
|
-
props.wix.wixPath,
|
|
644
|
-
"value",
|
|
645
|
-
props.defaultValue ?? ""
|
|
646
|
-
);
|
|
647
|
-
const [sdkValidityIndication, setSdkValidityIndication] = useSdkState(
|
|
648
|
-
props.wix.wixPath,
|
|
649
|
-
"shouldShowValidityIndication",
|
|
650
|
-
false
|
|
651
|
-
);
|
|
652
|
-
const [value, setValue] = React.useState(sdkValue);
|
|
653
|
-
const [shouldShowValidityIndication, setValidityIndication] = React.useState(
|
|
654
|
-
sdkValidityIndication
|
|
655
|
-
);
|
|
656
|
-
const boundValue = props.value;
|
|
657
|
-
React.useEffect(() => {
|
|
658
|
-
if (boundValue !== void 0 && boundValue !== value) {
|
|
659
|
-
setValue(boundValue);
|
|
660
|
-
setSdkValue(boundValue);
|
|
661
|
-
}
|
|
662
|
-
}, [boundValue]);
|
|
663
|
-
const defaultValue = props.defaultValue;
|
|
664
|
-
React.useEffect(() => {
|
|
665
|
-
if (boundValue === void 0 && defaultValue !== void 0) {
|
|
666
|
-
setValue(defaultValue);
|
|
667
|
-
setSdkValue(defaultValue);
|
|
668
|
-
}
|
|
669
|
-
}, [defaultValue]);
|
|
670
|
-
const isTextInputAutoFillFixExperimentEnabled = isExperimentOpen(
|
|
671
|
-
"specs.thunderbolt.TextInputAutoFillFix"
|
|
672
|
-
);
|
|
673
|
-
const translations = {
|
|
674
|
-
phoneFormatLengthValidationError: translate(TranslationKeys.NAMESPACE)(
|
|
675
|
-
TranslationKeys.PHONE_FORMAT_LENGTH_VALIDATION_ERROR
|
|
676
|
-
),
|
|
677
|
-
phoneFormatDefaultValidationError: translate(TranslationKeys.NAMESPACE)(
|
|
678
|
-
TranslationKeys.PHONE_FORMAT_DEFAULT_VALIDATION_ERROR
|
|
679
|
-
),
|
|
680
|
-
phoneFormatComplexPhoneDefaultValidationError: translate(
|
|
681
|
-
TranslationKeys.NAMESPACE
|
|
682
|
-
)(TranslationKeys.PHONE_FORMAT_COMPLEX_PHONE_DEFAULT_VALIDATION_ERROR),
|
|
683
|
-
errorMessage: translate(TranslationKeys.NAMESPACE)(
|
|
684
|
-
TranslationKeys.INLINE_ERROR_MESSAGE_DEFAULT_ERROR_MESSAGE
|
|
685
|
-
)
|
|
686
|
-
};
|
|
219
|
+
const { language } = useService(EnvironmentDefinition);
|
|
220
|
+
const value = props.value ?? "";
|
|
687
221
|
const inputRef = React.useRef(null);
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
var _a2;
|
|
692
|
-
(_a2 = inputRef.current) == null ? void 0 : _a2.focus();
|
|
693
|
-
},
|
|
694
|
-
blur: () => {
|
|
695
|
-
var _a2;
|
|
696
|
-
(_a2 = inputRef.current) == null ? void 0 : _a2.blur();
|
|
697
|
-
},
|
|
698
|
-
setCustomValidity: (message) => {
|
|
699
|
-
var _a2, _b;
|
|
700
|
-
if (message.type === "message") {
|
|
701
|
-
(_a2 = inputRef.current) == null ? void 0 : _a2.setCustomValidity(message.message);
|
|
702
|
-
} else {
|
|
703
|
-
(_b = inputRef.current) == null ? void 0 : _b.setCustomValidity(
|
|
704
|
-
translateHtmlValidationMessage(message, {
|
|
705
|
-
translations: props.translations,
|
|
706
|
-
phoneFormat: props.phoneFormat
|
|
707
|
-
})
|
|
708
|
-
);
|
|
709
|
-
}
|
|
710
|
-
},
|
|
711
|
-
getValidationMessage: () => {
|
|
712
|
-
var _a2;
|
|
713
|
-
return (_a2 = inputRef.current) == null ? void 0 : _a2.validationMessage;
|
|
714
|
-
}
|
|
715
|
-
};
|
|
716
|
-
});
|
|
717
|
-
const valueChanged = React.useRef();
|
|
718
|
-
const activePhoneFormat = inputType === "tel" ? phoneFormat : "";
|
|
719
|
-
const formattedValue = React.useMemo(() => {
|
|
720
|
-
return activePhoneFormat ? formatPhoneNumber(value, activePhoneFormat) : value;
|
|
721
|
-
}, [value, activePhoneFormat]);
|
|
722
|
-
const handleAutoFillChange = (event) => {
|
|
723
|
-
if (isTextInputAutoFillFixExperimentEnabled && !hasFocus()) {
|
|
724
|
-
onChange({
|
|
725
|
-
...event,
|
|
726
|
-
type: "change"
|
|
727
|
-
});
|
|
728
|
-
}
|
|
729
|
-
};
|
|
730
|
-
const getOnChangeFn = ({
|
|
731
|
-
shouldHideValidityIndication,
|
|
732
|
-
shouldCallOnInput
|
|
733
|
-
}) => (newValue) => {
|
|
734
|
-
let unformattedNumber = newValue;
|
|
735
|
-
if (activePhoneFormat) {
|
|
736
|
-
const didDeleteChars = newValue.length < formattedValue.length;
|
|
737
|
-
unformattedNumber = getUnformattedNumber(
|
|
738
|
-
newValue,
|
|
739
|
-
activePhoneFormat,
|
|
740
|
-
didDeleteChars
|
|
741
|
-
);
|
|
742
|
-
if (hasNonNumericChar(unformattedNumber)) {
|
|
743
|
-
return;
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
const shouldUpdateValue = unformattedNumber !== value;
|
|
747
|
-
if (shouldUpdateValue) {
|
|
748
|
-
valueChanged.current = true;
|
|
749
|
-
setSdkValue(unformattedNumber);
|
|
750
|
-
setValue(unformattedNumber);
|
|
751
|
-
const syntheticEvent = {
|
|
752
|
-
target: { value: unformattedNumber },
|
|
753
|
-
type: "change"
|
|
754
|
-
};
|
|
755
|
-
unformattedNumber !== value && handleAutoFillChange(syntheticEvent);
|
|
756
|
-
validateValue();
|
|
757
|
-
}
|
|
758
|
-
{
|
|
759
|
-
setValidityIndication(false);
|
|
760
|
-
setSdkValidityIndication(false);
|
|
761
|
-
}
|
|
762
|
-
if (shouldCallOnInput) {
|
|
763
|
-
const syntheticEvent = {
|
|
764
|
-
target: { value: unformattedNumber },
|
|
765
|
-
type: "input"
|
|
766
|
-
};
|
|
767
|
-
onInput(syntheticEvent);
|
|
222
|
+
const handleValueChange = (newValue) => {
|
|
223
|
+
if (newValue !== value) {
|
|
224
|
+
onValueChange(newValue);
|
|
768
225
|
}
|
|
769
226
|
};
|
|
770
227
|
React.useEffect(() => {
|
|
771
228
|
var _a2;
|
|
772
|
-
|
|
773
|
-
shouldHideValidityIndication: true,
|
|
774
|
-
shouldCallOnInput: false
|
|
775
|
-
});
|
|
776
|
-
onChangeFn(((_a2 = inputRef.current) == null ? void 0 : _a2.value) ?? "");
|
|
777
|
-
onHydrationComplete({ type: "onHydrationComplete" });
|
|
229
|
+
handleValueChange(((_a2 = inputRef.current) == null ? void 0 : _a2.value) ?? "");
|
|
778
230
|
}, []);
|
|
779
|
-
const
|
|
780
|
-
|
|
781
|
-
);
|
|
782
|
-
const nativeValidationMessage = ((_a = inputRef.current) == null ? void 0 : _a.validationMessage) ?? "";
|
|
783
|
-
const valueMissing = required && !value;
|
|
784
|
-
const intrinsic = valueMissing ? { valid: false, validationMessage: VALUE_MISSING_MESSAGE } : {
|
|
785
|
-
valid: !nativeValidationMessage,
|
|
786
|
-
validationMessage: nativeValidationMessage
|
|
787
|
-
};
|
|
788
|
-
const validityGate = props.showValidityIndication !== void 0 ? props.showValidityIndication : shouldShowValidityIndication;
|
|
789
|
-
const {
|
|
790
|
-
validity,
|
|
791
|
-
showValidityIndication: showIndication,
|
|
792
|
-
handleBlur: validateOnBlur
|
|
793
|
-
} = useValidatedField({
|
|
794
|
-
value,
|
|
795
|
-
intrinsic,
|
|
796
|
-
fieldValidity: useValidationContract ? props.fieldValidity : void 0,
|
|
797
|
-
showValidityIndication: validityGate,
|
|
798
|
-
onValidate: useValidationContract ? props.onValidate : void 0,
|
|
799
|
-
onValidityChange: useValidationContract ? props.onValidityChange : void 0
|
|
800
|
-
});
|
|
801
|
-
const showErrorIndication = useValidationContract ? showIndication : shouldShowValidityIndication;
|
|
802
|
-
const isInvalid = useValidationContract ? showIndication && !validity.valid : !!nativeValidationMessage && shouldShowValidityIndication;
|
|
803
|
-
const errorMessageToShow = useValidationContract ? validity.validationMessage : nativeValidationMessage;
|
|
804
|
-
const _onBlur = (event) => {
|
|
805
|
-
onBlur(event);
|
|
806
|
-
if (valueChanged.current) {
|
|
807
|
-
onChange({
|
|
808
|
-
...event,
|
|
809
|
-
type: "change"
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
valueChanged.current = false;
|
|
813
|
-
setValidityIndication(true);
|
|
814
|
-
setSdkValidityIndication(true);
|
|
815
|
-
validateOnBlur();
|
|
816
|
-
};
|
|
817
|
-
const _onClick = (event) => {
|
|
818
|
-
if (!isDisabled) {
|
|
819
|
-
onClick(event);
|
|
820
|
-
}
|
|
821
|
-
};
|
|
822
|
-
const _onDblClick = (event) => {
|
|
823
|
-
if (!isDisabled) {
|
|
824
|
-
onDblClick(event);
|
|
825
|
-
}
|
|
826
|
-
};
|
|
827
|
-
const _onMouseEnter = (event) => {
|
|
828
|
-
if (!isDisabled) {
|
|
829
|
-
onMouseEnter(event);
|
|
830
|
-
}
|
|
831
|
-
};
|
|
832
|
-
const _onMouseLeave = (event) => {
|
|
833
|
-
if (!isDisabled) {
|
|
834
|
-
onMouseLeave(event);
|
|
835
|
-
}
|
|
836
|
-
};
|
|
231
|
+
const hasError = !!errorMessage2;
|
|
232
|
+
const showErrorMessage = previewError === true || hasError;
|
|
837
233
|
const containerClasses = clsx(
|
|
838
234
|
style.root,
|
|
839
|
-
|
|
235
|
+
componentClassNames.root,
|
|
840
236
|
className,
|
|
841
|
-
!direction && directionStyles.fallbackDirection
|
|
842
|
-
{
|
|
843
|
-
[style.hasLabel]: !!label2,
|
|
844
|
-
[style.validationIndication]: showErrorIndication
|
|
845
|
-
}
|
|
237
|
+
!direction && directionStyles.fallbackDirection
|
|
846
238
|
);
|
|
847
|
-
const
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
return updatedMaxLength;
|
|
853
|
-
};
|
|
854
|
-
const getMinLength = () => activePhoneFormat ? activePhoneFormat.length : minLength ?? void 0;
|
|
855
|
-
const {
|
|
856
|
-
ariaAttributes: { "aria-label": sdkAriaLabel, ...restAriaAttributes }
|
|
857
|
-
} = getAccessibilityAttributes({ ariaAttributes });
|
|
858
|
-
const ariaLabel = (a11y == null ? void 0 : a11y.ariaLabel) || sdkAriaLabel;
|
|
859
|
-
const explicitLabelledBy = restAriaAttributes["aria-labelledby"];
|
|
860
|
-
const customAccessibleNameId = label2 && ariaLabel && !explicitLabelledBy ? `${id}-accessible-name` : void 0;
|
|
861
|
-
const componentViewMode = (getPreviewMode == null ? void 0 : getPreviewMode()) ? "preview" : "editor";
|
|
862
|
-
const hasFocus = () => !!inputRef.current && inputRef.current === document.activeElement;
|
|
863
|
-
const descriptionId = description ? `description_${id}` : void 0;
|
|
864
|
-
const errorId = `${id}-error`;
|
|
865
|
-
const describedByIds = [
|
|
866
|
-
restAriaAttributes["aria-describedby"],
|
|
867
|
-
descriptionId,
|
|
868
|
-
errorMessageType === "inline" && showErrorIndication && (componentViewMode === "editor" || errorMessageToShow) ? errorId : void 0
|
|
869
|
-
].filter(Boolean);
|
|
239
|
+
const ariaLabel = a11y == null ? void 0 : a11y.ariaLabel;
|
|
240
|
+
const ariaInvalid = hasError ? true : (a11y == null ? void 0 : a11y.ariaInvalid) ?? false;
|
|
241
|
+
const customAccessibleNameId = label2 && ariaLabel ? `${id}-accessible-name` : void 0;
|
|
242
|
+
const helperTextId = helperText2 ? `helper_${id}` : void 0;
|
|
243
|
+
const errorMessageId = showErrorMessage ? `error_${id}` : void 0;
|
|
870
244
|
const inputClasses = clsx(
|
|
871
245
|
style.input,
|
|
872
|
-
|
|
873
|
-
|
|
246
|
+
componentClassNames.input,
|
|
247
|
+
(_a = elementProps == null ? void 0 : elementProps.input) == null ? void 0 : _a.className,
|
|
874
248
|
{
|
|
875
|
-
[
|
|
876
|
-
[style.hasPrefix]: !!prefix2
|
|
249
|
+
[DesignStates.input.error.className]: hasError
|
|
877
250
|
}
|
|
878
251
|
);
|
|
879
|
-
const labelClasses = clsx(
|
|
252
|
+
const labelClasses = clsx(
|
|
253
|
+
style.label,
|
|
254
|
+
componentClassNames.label,
|
|
255
|
+
(_b = elementProps == null ? void 0 : elementProps.label) == null ? void 0 : _b.className
|
|
256
|
+
);
|
|
880
257
|
const textFieldProps = {
|
|
881
|
-
value
|
|
882
|
-
onChange:
|
|
883
|
-
|
|
884
|
-
shouldCallOnInput: true
|
|
885
|
-
}),
|
|
886
|
-
isDisabled,
|
|
258
|
+
value,
|
|
259
|
+
onChange: handleValueChange,
|
|
260
|
+
isDisabled: disabled,
|
|
887
261
|
isReadOnly: readOnly,
|
|
888
|
-
isRequired: required,
|
|
889
262
|
autoFocus,
|
|
890
263
|
"data-testid": "text-field"
|
|
891
264
|
};
|
|
265
|
+
const describedBy = [
|
|
266
|
+
a11y == null ? void 0 : a11y.ariaDescribedby,
|
|
267
|
+
helperTextId,
|
|
268
|
+
errorMessageId
|
|
269
|
+
].filter(Boolean);
|
|
892
270
|
const inputProps = {
|
|
893
271
|
ref: inputRef,
|
|
894
|
-
|
|
895
|
-
type: inputType,
|
|
272
|
+
tabIndex: a11y == null ? void 0 : a11y.tabIndex,
|
|
896
273
|
placeholder,
|
|
897
|
-
// An empty pattern must NOT set the attribute — `pattern=""` matches only the
|
|
898
|
-
// empty string, so it would reject every non-empty value.
|
|
899
|
-
pattern: pattern || void 0,
|
|
900
|
-
maxLength: getMaxLength(),
|
|
901
|
-
minLength: getMinLength(),
|
|
902
|
-
autoComplete: autoComplete ? autocompleteToken || "on" : autoComplete_ || "off",
|
|
903
|
-
step: step === null ? void 0 : step,
|
|
904
|
-
min: min === null ? void 0 : min,
|
|
905
|
-
max: max === null ? void 0 : max,
|
|
906
274
|
className: inputClasses,
|
|
907
275
|
id: `input_${id}`,
|
|
908
|
-
|
|
909
|
-
onFocus,
|
|
910
|
-
onKeyDown: onKeyPress,
|
|
911
|
-
onBlur: _onBlur,
|
|
912
|
-
"aria-invalid": isInvalid,
|
|
276
|
+
"aria-invalid": ariaInvalid,
|
|
913
277
|
...ariaLabel && { "aria-label": ariaLabel },
|
|
914
|
-
...!required && { "aria-required": false },
|
|
915
|
-
...restAriaAttributes,
|
|
916
278
|
...customAccessibleNameId && {
|
|
917
279
|
"aria-labelledby": customAccessibleNameId
|
|
918
280
|
},
|
|
919
|
-
...
|
|
920
|
-
"aria-describedby": describedByIds.join(" ")
|
|
921
|
-
} : {}
|
|
281
|
+
...describedBy.length ? { "aria-describedby": describedBy.join(" ") } : {}
|
|
922
282
|
};
|
|
923
283
|
return /* @__PURE__ */ jsx(
|
|
924
284
|
"div",
|
|
925
285
|
{
|
|
926
|
-
|
|
927
|
-
...
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
$
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
htmlFor: `input_${id}`,
|
|
952
|
-
dir: labelDirection || void 0,
|
|
953
|
-
children: [
|
|
954
|
-
label2,
|
|
955
|
-
required && /* @__PURE__ */ jsx(
|
|
956
|
-
RequiredIndicator,
|
|
957
|
-
{
|
|
958
|
-
className: clsx(
|
|
959
|
-
style.requiredIndicator,
|
|
960
|
-
selectors.requiredIndicator
|
|
961
|
-
),
|
|
962
|
-
"data-testid": TestIds.requiredIndicator
|
|
963
|
-
}
|
|
964
|
-
)
|
|
965
|
-
]
|
|
966
|
-
}
|
|
967
|
-
),
|
|
968
|
-
tooltip2 && /* @__PURE__ */ jsxs($4e3b923658d69c60$export$8c610744efcf8a1d, { delay: 0, children: [
|
|
969
|
-
/* @__PURE__ */ jsx(
|
|
970
|
-
$d2b4bc8c273e7be6$export$353f5b6fc5456de1,
|
|
286
|
+
className: presetWrapperStyles.presetWrapper,
|
|
287
|
+
...wix == null ? void 0 : wix.presetsWrapperProps,
|
|
288
|
+
children: /* @__PURE__ */ jsx(
|
|
289
|
+
"div",
|
|
290
|
+
{
|
|
291
|
+
id,
|
|
292
|
+
...getDataAttributes(props),
|
|
293
|
+
ref: contentRef,
|
|
294
|
+
className: containerClasses,
|
|
295
|
+
dir: direction || void 0,
|
|
296
|
+
"data-testid": dataTestId,
|
|
297
|
+
lang: language,
|
|
298
|
+
children: /* @__PURE__ */ jsxs($bcdf0525bf22703d$export$2c73285ae9390cec, { ...textFieldProps, children: [
|
|
299
|
+
customAccessibleNameId && /* @__PURE__ */ jsx(
|
|
300
|
+
"span",
|
|
301
|
+
{
|
|
302
|
+
id: customAccessibleNameId,
|
|
303
|
+
className: accessibilityStyles.visuallyHidden,
|
|
304
|
+
children: ariaLabel
|
|
305
|
+
}
|
|
306
|
+
),
|
|
307
|
+
label2 && /* @__PURE__ */ jsx($01b77f81d0f07f68$export$b04be29aa201d4f5, { className: labelClasses, htmlFor: `input_${id}`, children: label2 }),
|
|
308
|
+
/* @__PURE__ */ jsx("div", { className: style.inputWrapper, children: /* @__PURE__ */ jsx($3985021b0ad6602f$export$f5b8910cec6cf069, { ...inputProps }) }),
|
|
309
|
+
helperText2 && /* @__PURE__ */ jsx(
|
|
310
|
+
"p",
|
|
971
311
|
{
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
312
|
+
id: helperTextId,
|
|
313
|
+
className: clsx(
|
|
314
|
+
style.helperText,
|
|
315
|
+
componentClassNames.helperText,
|
|
316
|
+
(_c = elementProps == null ? void 0 : elementProps.helperText) == null ? void 0 : _c.className
|
|
317
|
+
),
|
|
318
|
+
"data-testid": "helper-text",
|
|
319
|
+
children: helperText2
|
|
976
320
|
}
|
|
977
321
|
),
|
|
978
|
-
/* @__PURE__ */ jsx(
|
|
322
|
+
showErrorMessage && /* @__PURE__ */ jsx(
|
|
323
|
+
"p",
|
|
324
|
+
{
|
|
325
|
+
id: errorMessageId,
|
|
326
|
+
className: clsx(
|
|
327
|
+
style.errorMessage,
|
|
328
|
+
componentClassNames.errorMessage,
|
|
329
|
+
(_d = elementProps == null ? void 0 : elementProps.errorMessage) == null ? void 0 : _d.className
|
|
330
|
+
),
|
|
331
|
+
"data-testid": "error-message",
|
|
332
|
+
children: errorMessage2 || ERROR_MESSAGE_PREVIEW_TEXT
|
|
333
|
+
}
|
|
334
|
+
)
|
|
979
335
|
] })
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
prefix2 && /* @__PURE__ */ jsx(
|
|
983
|
-
"div",
|
|
984
|
-
{
|
|
985
|
-
className: clsx(style.prefix, selectors.prefix),
|
|
986
|
-
"data-testid": "prefix",
|
|
987
|
-
children: prefix2
|
|
988
|
-
}
|
|
989
|
-
),
|
|
990
|
-
/* @__PURE__ */ jsx($3985021b0ad6602f$export$f5b8910cec6cf069, { ...inputProps })
|
|
991
|
-
] }),
|
|
992
|
-
description && /* @__PURE__ */ jsx(
|
|
993
|
-
"p",
|
|
994
|
-
{
|
|
995
|
-
id: descriptionId,
|
|
996
|
-
className: clsx(style.helperText, selectors.helperText),
|
|
997
|
-
"data-testid": "helper-text",
|
|
998
|
-
children: description
|
|
999
|
-
}
|
|
1000
|
-
),
|
|
1001
|
-
/* @__PURE__ */ jsx(
|
|
1002
|
-
InlineErrorMessage,
|
|
1003
|
-
{
|
|
1004
|
-
id: errorId,
|
|
1005
|
-
errorMessageType,
|
|
1006
|
-
errorMessage: errorMessageToShow,
|
|
1007
|
-
shouldShowValidityIndication: showErrorIndication,
|
|
1008
|
-
translations,
|
|
1009
|
-
componentViewMode
|
|
1010
|
-
}
|
|
1011
|
-
)
|
|
1012
|
-
] })
|
|
336
|
+
}
|
|
337
|
+
)
|
|
1013
338
|
}
|
|
1014
339
|
);
|
|
1015
340
|
};
|
|
1016
|
-
const TextInput_default = React.forwardRef(TextInput);
|
|
1017
341
|
export {
|
|
1018
|
-
|
|
342
|
+
TextInput as default
|
|
1019
343
|
};
|