quantumai-design-system
Version:
퀀텀에이아이의 디자인 시스템
52 lines (51 loc) • 3.6 kB
JavaScript
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
import { forwardRef, useState } from 'react';
import { TYPOGRAPHYS_STYLE } from '../../../../styles/theme';
import { materialInputSize } from '../options';
import { MaterialContext } from '../context';
import { restProps } from '../../../../utils/styleSet';
import styled from '@emotion/styled';
import SwitchInput from './SwitchInput';
import MaterialBase from '../MaterialBase';
var MaterialInput = forwardRef(function (_a, ref) {
var _b = _a.variant, variant = _b === void 0 ? 'line' : _b, _c = _a.size, size = _c === void 0 ? 's' : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, label = _a.label, value = _a.value, helperText = _a.helperText, className = _a.className, error = _a.error, icon = _a.icon, type = _a.type, id = _a.id, onIsValue = _a.onIsValue, onValue = _a.onValue, props = __rest(_a, ["variant", "size", "disabled", "label", "value", "helperText", "className", "error", "icon", "type", "id", "onIsValue", "onValue"]);
var _e = useState(false), isValue = _e[0], setIsValue = _e[1];
var handleIsValue = function (isValue) {
setIsValue(isValue);
onIsValue === null || onIsValue === void 0 ? void 0 : onIsValue(isValue);
};
var _f = restProps(props), styleProps = _f[0], rest = _f[1];
return (_jsx(MaterialContext.Provider, { value: { variant: variant, size: size, disabled: disabled }, children: _jsx(MaterialBase, __assign({ "data-active": isValue, "data-error": error, label: label, helperText: helperText, className: className, error: error, icon: icon }, styleProps, { children: _jsx(MaterialInputContainer, { variant: variant, size: size, children: _jsx(SwitchInput, __assign({ ref: ref, disabled: disabled, type: type, id: id, onIsValue: handleIsValue, onValue: onValue, value: value }, rest)) }) })) }));
});
export default MaterialInput;
var MaterialInputContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n flex-grow: 1;\n\n input {\n border: 0;\n outline: none;\n width: 0;\n flex-grow: 1;\n }\n\n /* ", " */\n ", "\n"], ["\n display: flex;\n align-items: center;\n flex-grow: 1;\n\n input {\n border: 0;\n outline: none;\n width: 0;\n flex-grow: 1;\n }\n\n /* ", " */\n ", "\n"])), function (_a) {
var variant = _a.variant, size = _a.size;
return materialInputSize[variant][size];
}, TYPOGRAPHYS_STYLE['body1']);
var templateObject_1;