@kaio-xyz/design-system 1.1.66 → 1.1.68
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/index.cjs.js +8 -33
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +9 -34
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -391,49 +391,24 @@ var Hint = function (_a) {
|
|
|
391
391
|
var style$q = {"field":"text-field-module__field__iZ0TF","label":"text-field-module__label__ClJkz","container":"text-field-module__container__IKtNZ","fieldWrapper":"text-field-module__fieldWrapper__nQ7l8","textField":"text-field-module__textField__756eR","hint":"text-field-module__hint__Ad6VA"};
|
|
392
392
|
|
|
393
393
|
var TextField = React.forwardRef(function (_a, ref) {
|
|
394
|
-
var className = _a.className, disabled = _a.disabled, hint = _a.hint, id = _a.id, label = _a.label, onChange = _a.onChange, readOnly = _a.readOnly, button = _a.button, _b = _a.fullWidth, fullWidth = _b === void 0 ? false : _b, _c = _a.size, size = _c === void 0 ? "default" : _c, _d = _a.noPadding, noPadding = _d === void 0 ? false : _d, _e = _a.floatingLabel, floatingLabel = _e === void 0 ? true : _e, value = _a.value, defaultValue = _a.defaultValue, onFocus = _a.onFocus, onBlur = _a.onBlur, attributes = __rest(_a, ["className", "disabled", "hint", "id", "label", "onChange", "readOnly", "button", "fullWidth", "size", "noPadding", "floatingLabel", "value", "defaultValue", "onFocus", "onBlur"]);
|
|
395
|
-
var _f = React.useState(false), isFocused = _f[0], setIsFocused = _f[1];
|
|
394
|
+
var className = _a.className, disabled = _a.disabled, hint = _a.hint, id = _a.id, label = _a.label, onChange = _a.onChange, readOnly = _a.readOnly, button = _a.button, _b = _a.fullWidth, fullWidth = _b === void 0 ? false : _b, _c = _a.size, size = _c === void 0 ? "default" : _c, _d = _a.noPadding, noPadding = _d === void 0 ? false : _d, _e = _a.floatingLabel, floatingLabel = _e === void 0 ? true : _e, value = _a.value, defaultValue = _a.defaultValue, onFocus = _a.onFocus, onBlur = _a.onBlur, _f = _a.type, type = _f === void 0 ? "text" : _f, attributes = __rest(_a, ["className", "disabled", "hint", "id", "label", "onChange", "readOnly", "button", "fullWidth", "size", "noPadding", "floatingLabel", "value", "defaultValue", "onFocus", "onBlur", "type"]);
|
|
396
395
|
var _g = React.useState(false), isAutofilled = _g[0], setIsAutofilled = _g[1];
|
|
397
|
-
var _h = React.useState(function () { return Boolean(value || defaultValue); }), hasValue = _h[0], setHasValue = _h[1];
|
|
398
396
|
var internalRef = React.useRef(null);
|
|
399
|
-
|
|
397
|
+
React.useImperativeHandle(ref, function () { return internalRef.current; });
|
|
400
398
|
React.useEffect(function () {
|
|
401
|
-
var input =
|
|
402
|
-
if (input && input.value) {
|
|
403
|
-
setHasValue(true);
|
|
404
|
-
}
|
|
405
|
-
}, []);
|
|
406
|
-
React.useEffect(function () {
|
|
407
|
-
if (value !== undefined)
|
|
408
|
-
setHasValue(value !== '');
|
|
409
|
-
}, [value]);
|
|
410
|
-
React.useEffect(function () {
|
|
411
|
-
var input = inputRef.current;
|
|
399
|
+
var input = internalRef.current;
|
|
412
400
|
if (!input)
|
|
413
401
|
return;
|
|
414
402
|
var handleAnimationStart = function (e) {
|
|
415
|
-
if (e.animationName
|
|
416
|
-
|
|
417
|
-
if (e.animationName
|
|
418
|
-
|
|
403
|
+
if (e.animationName.indexOf('onAutoFillStart') !== -1)
|
|
404
|
+
setIsAutofilled(true);
|
|
405
|
+
if (e.animationName.indexOf('onAutoFillCancel') !== -1)
|
|
406
|
+
setIsAutofilled(false);
|
|
419
407
|
};
|
|
420
408
|
input.addEventListener('animationstart', handleAnimationStart);
|
|
421
409
|
return function () { return input.removeEventListener('animationstart', handleAnimationStart); };
|
|
422
410
|
}, []);
|
|
423
|
-
|
|
424
|
-
var handleFocus = function (e) {
|
|
425
|
-
setIsFocused(true);
|
|
426
|
-
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
427
|
-
};
|
|
428
|
-
var handleBlur = function (e) {
|
|
429
|
-
setIsFocused(false);
|
|
430
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
431
|
-
};
|
|
432
|
-
var handleChange = function (e) {
|
|
433
|
-
setHasValue(e.target.value.length > 0);
|
|
434
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
435
|
-
};
|
|
436
|
-
return (jsxRuntime.jsx("fieldset", { "aria-disabled": disabled, disabled: disabled, className: clsx(style$q.textField, className), "data-no-padding": noPadding, "data-full-width": fullWidth, children: jsxRuntime.jsxs("div", { className: style$q.container, "data-has-label": !!label, "data-has-hint": !!hint, "data-has-button": !!button, "data-floating-label": floatingLabel, children: [label && (jsxRuntime.jsx("label", { className: style$q.label, htmlFor: id, "data-floating": floatingLabel, "data-active": isLabelFloating, children: label })), jsxRuntime.jsxs("div", { className: style$q.fieldWrapper, children: [jsxRuntime.jsx("input", __assign({ "aria-readonly": readOnly, className: style$q.field, readOnly: readOnly, "data-type": "single", "data-size": size, "data-floating-label": floatingLabel, id: id, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, ref: inputRef, type: "text", value: value, defaultValue: defaultValue }, attributes)), button ? button : null, hint && jsxRuntime.jsx(Hint, { kind: "error", className: style$q.hint, children: hint })] })] }) }));
|
|
411
|
+
return (jsxRuntime.jsx("fieldset", { "aria-disabled": disabled, disabled: disabled, className: clsx(style$q.textField, className), "data-no-padding": noPadding, "data-full-width": fullWidth, children: jsxRuntime.jsx("div", { className: style$q.container, "data-has-label": !!label, "data-has-hint": !!hint, "data-has-button": !!button, "data-floating-label": floatingLabel, children: jsxRuntime.jsxs("div", { className: style$q.fieldWrapper, children: [jsxRuntime.jsx("input", __assign({}, attributes, { id: id, ref: internalRef, type: type, value: value, defaultValue: defaultValue, placeholder: " ", className: style$q.field, "data-size": size, "data-autofilled": isAutofilled, onFocus: onFocus, onBlur: onBlur, onChange: onChange, readOnly: readOnly })), label && (jsxRuntime.jsx("label", { className: style$q.label, htmlFor: id, "data-floating": floatingLabel, children: label })), button ? button : null, hint && jsxRuntime.jsx(Hint, { kind: "error", className: style$q.hint, children: hint })] }) }) }));
|
|
437
412
|
});
|
|
438
413
|
TextField.displayName = "TextField";
|
|
439
414
|
|