@rovula/ui 0.0.4 → 0.0.6
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/cjs/bundle.css +1477 -0
- package/dist/cjs/bundle.js +2 -0
- package/dist/cjs/bundle.js.map +1 -0
- package/dist/cjs/types/components/Button/Button.d.ts +15 -0
- package/dist/cjs/types/components/Button/Button.styles.d.ts +7 -0
- package/dist/cjs/types/components/Button/Buttons.stories.d.ts +375 -0
- package/dist/cjs/types/components/Text/Text.d.ts +12 -0
- package/dist/cjs/types/components/Text/Text.stories.d.ts +35 -0
- package/dist/cjs/types/components/TextInput/TextInput.d.ts +19 -0
- package/dist/cjs/types/components/TextInput/TextInput.stories.d.ts +338 -0
- package/dist/cjs/types/components/TextInput/TextInput.styles.d.ts +26 -0
- package/dist/cjs/types/index.d.ts +7 -0
- package/dist/components/Button/Button.js +31 -0
- package/dist/components/Button/Button.styles.js +90 -0
- package/dist/components/Button/Buttons.stories.js +66 -0
- package/dist/components/Form/Form.js +106 -0
- package/dist/components/Form/Text.js +6 -0
- package/dist/components/Form/TextInput.js +6 -0
- package/dist/components/Table/Table.js +6 -0
- package/dist/components/Tabs/Tabs.js +8 -0
- package/dist/components/Text/Text.js +6 -0
- package/dist/components/Text/Text.stories.js +73 -0
- package/dist/components/TextInput/TextInput.js +61 -0
- package/dist/components/TextInput/TextInput.stories.js +39 -0
- package/dist/components/TextInput/TextInput.styles.js +155 -0
- package/dist/esm/bundle.css +1477 -0
- package/dist/esm/bundle.js +2 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/types/components/Button/Button.d.ts +15 -0
- package/dist/esm/types/components/Button/Button.styles.d.ts +7 -0
- package/dist/esm/types/components/Button/Buttons.stories.d.ts +375 -0
- package/dist/esm/types/components/Form/Form.d.ts +12 -0
- package/dist/esm/types/components/Form/Text.d.ts +9 -0
- package/dist/esm/types/components/Form/TextInput.d.ts +11 -0
- package/dist/esm/types/components/Table/Table.d.ts +11 -0
- package/dist/esm/types/components/Tabs/Tabs.d.ts +11 -0
- package/dist/esm/types/components/Text/Text.d.ts +12 -0
- package/dist/esm/types/components/Text/Text.stories.d.ts +35 -0
- package/dist/esm/types/components/TextInput/TextInput.d.ts +19 -0
- package/dist/esm/types/components/TextInput/TextInput.stories.d.ts +338 -0
- package/dist/esm/types/components/TextInput/TextInput.styles.d.ts +26 -0
- package/dist/esm/types/index.d.ts +7 -0
- package/dist/esm/types/utils/datetime.d.ts +9 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +12 -0
- package/dist/src/theme/global.css +1825 -0
- package/dist/theme/global.css +149 -0
- package/dist/theme/main-preset.js +159 -0
- package/dist/theme/plugins/utilities/typography.js +69 -0
- package/dist/theme/presets/colors.js +166 -0
- package/dist/utils/datetime.js +30 -0
- package/package.json +41 -10
- package/src/components/Button/Button.styles.ts +98 -0
- package/src/components/Button/Button.tsx +48 -18
- package/src/components/Button/Buttons.stories.tsx +120 -0
- package/src/components/Text/Text.stories.tsx +112 -0
- package/src/components/Text/Text.tsx +59 -0
- package/src/components/TextInput/TextInput.stories.tsx +44 -0
- package/src/components/TextInput/TextInput.styles.ts +177 -0
- package/src/components/TextInput/TextInput.tsx +119 -0
- package/src/index.ts +21 -0
- package/src/stories/Typography.mdx +160 -0
- package/src/theme/global.css +149 -0
- package/src/theme/main-preset.js +159 -0
- package/src/theme/plugins/utilities/typography.js +69 -0
- package/src/theme/presets/colors.js +166 -0
- package/dist/main.d.ts +0 -7
- package/dist/main.js +0 -25
- package/dist/src/components/Button/Button.d.ts +0 -12
- package/dist/src/components/Button/Button.js +0 -10
- package/dist/src/components/Form/Form.js +0 -91
- package/dist/src/components/Form/Text.js +0 -10
- package/dist/src/components/Form/TextInput.js +0 -10
- package/dist/src/components/Table/Table.js +0 -13
- package/dist/src/components/Tabs/Tabs.js +0 -33
- package/dist/src/style.css +0 -3
- package/dist/src/utils/datetime.js +0 -37
- package/src/style.css +0 -3
- /package/dist/{src → cjs/types}/components/Form/Form.d.ts +0 -0
- /package/dist/{src → cjs/types}/components/Form/Text.d.ts +0 -0
- /package/dist/{src → cjs/types}/components/Form/TextInput.d.ts +0 -0
- /package/dist/{src → cjs/types}/components/Table/Table.d.ts +0 -0
- /package/dist/{src → cjs/types}/components/Tabs/Tabs.d.ts +0 -0
- /package/dist/{src → cjs/types}/utils/datetime.d.ts +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
+
// src/Form.tsx
|
|
50
|
+
import { useState } from "react";
|
|
51
|
+
import * as yup from "yup";
|
|
52
|
+
var schema = yup.object().shape({
|
|
53
|
+
name: yup.string().required("Name is required"),
|
|
54
|
+
email: yup.string().email("Invalid email").required("Email is required"),
|
|
55
|
+
password: yup
|
|
56
|
+
.string()
|
|
57
|
+
.min(6, "Password must be at least 6 characters")
|
|
58
|
+
.required("Password is required"),
|
|
59
|
+
});
|
|
60
|
+
var Form = function (_a) {
|
|
61
|
+
var onSubmit = _a.onSubmit, _b = _a.className, className = _b === void 0 ? "" : _b;
|
|
62
|
+
var _c = useState({
|
|
63
|
+
name: "",
|
|
64
|
+
email: "",
|
|
65
|
+
password: "",
|
|
66
|
+
}), values = _c[0], setValues = _c[1];
|
|
67
|
+
var _d = useState({}), errors = _d[0], setErrors = _d[1];
|
|
68
|
+
var handleChange = function (e) {
|
|
69
|
+
var _a;
|
|
70
|
+
var _b = e.target, name = _b.name, value = _b.value;
|
|
71
|
+
setValues(__assign(__assign({}, values), (_a = {}, _a[name] = value, _a)));
|
|
72
|
+
};
|
|
73
|
+
var handleSubmit = function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
74
|
+
var err_1, validationErrors_1;
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
switch (_a.label) {
|
|
77
|
+
case 0:
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
_a.label = 1;
|
|
80
|
+
case 1:
|
|
81
|
+
_a.trys.push([1, 3, , 4]);
|
|
82
|
+
return [4 /*yield*/, schema.validate(values, { abortEarly: false })];
|
|
83
|
+
case 2:
|
|
84
|
+
_a.sent();
|
|
85
|
+
setErrors({});
|
|
86
|
+
onSubmit(values);
|
|
87
|
+
return [3 /*break*/, 4];
|
|
88
|
+
case 3:
|
|
89
|
+
err_1 = _a.sent();
|
|
90
|
+
if (err_1 instanceof yup.ValidationError) {
|
|
91
|
+
validationErrors_1 = {};
|
|
92
|
+
err_1.inner.forEach(function (error) {
|
|
93
|
+
if (error.path) {
|
|
94
|
+
validationErrors_1[error.path] = error.message;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
setErrors(validationErrors_1);
|
|
98
|
+
}
|
|
99
|
+
return [3 /*break*/, 4];
|
|
100
|
+
case 4: return [2 /*return*/];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}); };
|
|
104
|
+
return (_jsxs("form", { className: "form ".concat(className), onSubmit: handleSubmit, children: [_jsxs("div", { className: "form-group", children: [_jsx("label", { htmlFor: "name", children: "Name" }), _jsx("input", { id: "name", name: "name", type: "text", value: values.name, onChange: handleChange }), errors.name && _jsx("span", { className: "error", children: errors.name })] }), _jsxs("div", { className: "form-group", children: [_jsx("label", { htmlFor: "email", children: "Email" }), _jsx("input", { id: "email", name: "email", type: "email", value: values.email, onChange: handleChange }), errors.email && _jsx("span", { className: "error", children: errors.email })] }), _jsxs("div", { className: "form-group", children: [_jsx("label", { htmlFor: "password", children: "Password" }), _jsx("input", { id: "password", name: "password", type: "password", value: values.password, onChange: handleChange }), errors.password && _jsx("span", { className: "error", children: errors.password })] }), _jsx("button", { type: "submit", children: "Submit" })] }));
|
|
105
|
+
};
|
|
106
|
+
export default Form;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
var Text = function (_a) {
|
|
3
|
+
var children = _a.children, _b = _a.size, size = _b === void 0 ? "medium" : _b, _c = _a.color, color = _c === void 0 ? "black" : _c, _d = _a.className, className = _d === void 0 ? "" : _d;
|
|
4
|
+
return (_jsx("span", { className: "text ".concat(size, " ").concat(className), style: { color: color }, children: children }));
|
|
5
|
+
};
|
|
6
|
+
export default Text;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
var TextInput = function (_a) {
|
|
3
|
+
var value = _a.value, onChange = _a.onChange, _b = _a.placeholder, placeholder = _b === void 0 ? '' : _b, _c = _a.type, type = _c === void 0 ? 'text' : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.className, className = _e === void 0 ? '' : _e;
|
|
4
|
+
return (_jsx("input", { className: "text-input ".concat(className), type: type, value: value, onChange: onChange, placeholder: placeholder, disabled: disabled }));
|
|
5
|
+
};
|
|
6
|
+
export default TextInput;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
var Table = function (_a) {
|
|
3
|
+
var columns = _a.columns, data = _a.data;
|
|
4
|
+
return (_jsxs("table", { className: "table", children: [_jsx("thead", { children: _jsx("tr", { children: columns.map(function (column, index) { return (_jsx("th", { children: column.header }, index)); }) }) }), _jsx("tbody", { children: data.map(function (row, rowIndex) { return (_jsx("tr", { children: columns.map(function (column, colIndex) { return (_jsx("td", { children: row[column.accessor] }, colIndex)); }) }, rowIndex)); }) })] }));
|
|
5
|
+
};
|
|
6
|
+
export default Table;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
var Tabs = function (_a) {
|
|
4
|
+
var tabs = _a.tabs, _b = _a.initialTab, initialTab = _b === void 0 ? 0 : _b;
|
|
5
|
+
var _c = useState(initialTab), activeTab = _c[0], setActiveTab = _c[1];
|
|
6
|
+
return (_jsxs("div", { className: "tabs", children: [_jsx("div", { className: "tab-buttons", children: tabs.map(function (tab, index) { return (_jsx("button", { className: index === activeTab ? "active" : "", onClick: function () { return setActiveTab(index); }, children: tab.label }, index)); }) }), _jsx("div", { className: "tab-content", children: tabs[activeTab].content })] }));
|
|
7
|
+
};
|
|
8
|
+
export default Tabs;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
var Text = function (_a) {
|
|
3
|
+
var _b = _a.variant, variant = _b === void 0 ? "body1" : _b, _c = _a.tag, Tag = _c === void 0 ? "p" : _c, children = _a.children, className = _a.className, color = _a.color, style = _a.style;
|
|
4
|
+
return (_jsx(Tag, { className: "typography-".concat(variant, " text-").concat(color, " ").concat(className), style: style, children: children }));
|
|
5
|
+
};
|
|
6
|
+
export default Text;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import Text from "./Text";
|
|
14
|
+
// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction
|
|
15
|
+
var meta = {
|
|
16
|
+
title: "Components/Text",
|
|
17
|
+
component: Text,
|
|
18
|
+
tags: ["autodocs"],
|
|
19
|
+
parameters: {
|
|
20
|
+
// More on how to position stories at: https://storybook.js.org/docs/7.0/react/configure/story-layout
|
|
21
|
+
layout: "fullscreen",
|
|
22
|
+
},
|
|
23
|
+
decorators: [
|
|
24
|
+
function (Story) { return (_jsx("div", { className: "p-5 flex w-full", children: _jsx(Story, {}) })); },
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
export default meta;
|
|
28
|
+
var variant = [
|
|
29
|
+
"h1",
|
|
30
|
+
"h2",
|
|
31
|
+
"h3",
|
|
32
|
+
"h4",
|
|
33
|
+
"h5",
|
|
34
|
+
"h6",
|
|
35
|
+
"subtitile1",
|
|
36
|
+
"subtitile2",
|
|
37
|
+
"subtitile3",
|
|
38
|
+
"subtitile4",
|
|
39
|
+
"subtitile5",
|
|
40
|
+
"subtitile6",
|
|
41
|
+
"body1",
|
|
42
|
+
"body2",
|
|
43
|
+
"body3",
|
|
44
|
+
"body4",
|
|
45
|
+
"small1",
|
|
46
|
+
"small2",
|
|
47
|
+
"small3",
|
|
48
|
+
"label1",
|
|
49
|
+
"label2",
|
|
50
|
+
];
|
|
51
|
+
var color = [
|
|
52
|
+
"primary",
|
|
53
|
+
"secondary",
|
|
54
|
+
"tertiary",
|
|
55
|
+
"success",
|
|
56
|
+
"info",
|
|
57
|
+
"warning",
|
|
58
|
+
"error",
|
|
59
|
+
];
|
|
60
|
+
export var Default = {
|
|
61
|
+
args: {},
|
|
62
|
+
render: function (args) {
|
|
63
|
+
var props = __assign({}, args);
|
|
64
|
+
return (_jsx("div", { className: "flex flex-col gap-2 gap-y-6 w-full", children: variant.map(function (value) { return (_jsxs("div", { className: "flex flex-row ", children: [_jsx("div", { className: "w-[200px]", children: _jsx(Text, { variant: value, color: "primary", children: value }) }), _jsx("div", { className: "w-full", children: _jsx(Text, { variant: value, color: "primary", children: "Lorem ipsum dolor sit amet, adipiscing elit." }) })] }, value)); }) }));
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
export var Color = {
|
|
68
|
+
args: {},
|
|
69
|
+
render: function (args) {
|
|
70
|
+
var props = __assign({}, args);
|
|
71
|
+
return (_jsx("div", { className: "flex flex-col gap-2 gap-y-6 w-full", children: color.map(function (color, i) { return (_jsxs("div", { className: "flex flex-row ", children: [_jsx("div", { className: "w-[400px]", children: _jsx(Text, { variant: variant === null || variant === void 0 ? void 0 : variant[i], color: color, children: color }) }), _jsx("div", { className: "w-full", children: _jsx(Text, { variant: variant === null || variant === void 0 ? void 0 : variant[i], color: color, children: "Lorem ipsum dolor sit amet, adipiscing elit." }) })] }, color)); }) }));
|
|
72
|
+
},
|
|
73
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
import { forwardRef, useImperativeHandle, useRef } from "react";
|
|
25
|
+
import { helperTextVariant, iconVariant, iconWrapperVariant, inputVariant, labelVariant, } from "./TextInput.styles";
|
|
26
|
+
import { twMerge } from "tailwind-merge";
|
|
27
|
+
import { XCircleIcon, ExclamationCircleIcon } from "@heroicons/react/16/solid";
|
|
28
|
+
var TextInput = forwardRef(function (_a, ref) {
|
|
29
|
+
var _b;
|
|
30
|
+
var id = _a.id, label = _a.label, _c = _a.size, size = _c === void 0 ? "md" : _c, _d = _a.rounded, rounded = _d === void 0 ? "normal" : _d, _e = _a.variant, variant = _e === void 0 ? "outline" : _e, _f = _a.type, type = _f === void 0 ? "text" : _f, helperText = _a.helperText, errorMessage = _a.errorMessage, _g = _a.fullwidth, fullwidth = _g === void 0 ? false : _g, _h = _a.disabled, disabled = _h === void 0 ? false : _h, _j = _a.error, error = _j === void 0 ? false : _j, _k = _a.required, required = _k === void 0 ? true : _k, _l = _a.hasClearIcon, hasClearIcon = _l === void 0 ? true : _l, props = __rest(_a, ["id", "label", "size", "rounded", "variant", "type", "helperText", "errorMessage", "fullwidth", "disabled", "error", "required", "hasClearIcon"]);
|
|
31
|
+
var inputRef = useRef(null);
|
|
32
|
+
var _id = id || "".concat(type, "-").concat(label, "-input");
|
|
33
|
+
var inputClassname = inputVariant({
|
|
34
|
+
size: size,
|
|
35
|
+
rounded: rounded,
|
|
36
|
+
variant: variant,
|
|
37
|
+
fullwidth: fullwidth,
|
|
38
|
+
disabled: disabled,
|
|
39
|
+
error: error,
|
|
40
|
+
hasClearIcon: hasClearIcon,
|
|
41
|
+
});
|
|
42
|
+
var labelClassname = labelVariant({
|
|
43
|
+
size: size,
|
|
44
|
+
disabled: disabled,
|
|
45
|
+
error: error,
|
|
46
|
+
isFloating: (_b = !!props.value) !== null && _b !== void 0 ? _b : false,
|
|
47
|
+
});
|
|
48
|
+
var helperTextClassname = helperTextVariant({ size: size, error: error, disabled: disabled });
|
|
49
|
+
var iconWrapperClassname = iconWrapperVariant({ size: size });
|
|
50
|
+
var iconClassname = iconVariant({ size: size });
|
|
51
|
+
useImperativeHandle(ref, function () { return ({
|
|
52
|
+
clearInput: handleClearInput,
|
|
53
|
+
}); });
|
|
54
|
+
var handleClearInput = function () {
|
|
55
|
+
if (inputRef.current) {
|
|
56
|
+
inputRef.current.value = "";
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
return (_jsxs("div", { className: "flex flex-col ".concat(fullwidth ? "w-full" : ""), children: [_jsxs("div", { className: "relative", children: [_jsx("input", __assign({}, props, { ref: inputRef, type: type, id: _id, disabled: disabled, className: twMerge(inputClassname, props.className) })), hasClearIcon && (_jsx("div", { className: iconWrapperClassname, children: _jsx(XCircleIcon, { type: "button", className: iconClassname, onMouseDown: handleClearInput }) })), _jsxs("label", { htmlFor: _id, className: labelClassname, children: [label, " ", required && _jsx("span", { className: "text-error", children: "*" })] })] }), (errorMessage || helperText) && (_jsxs("span", { className: helperTextClassname, children: [_jsx(ExclamationCircleIcon, { width: 16, height: 16, className: error ? "fill-error" : "" }), " ", errorMessage || helperText] }))] }));
|
|
60
|
+
});
|
|
61
|
+
export default TextInput;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import TextInput from "./TextInput";
|
|
14
|
+
// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction
|
|
15
|
+
var meta = {
|
|
16
|
+
title: "Components/TextInput",
|
|
17
|
+
component: TextInput,
|
|
18
|
+
tags: ["autodocs"],
|
|
19
|
+
parameters: {
|
|
20
|
+
// More on how to position stories at: https://storybook.js.org/docs/7.0/react/configure/story-layout
|
|
21
|
+
layout: "fullscreen",
|
|
22
|
+
},
|
|
23
|
+
decorators: [
|
|
24
|
+
function (Story) { return (_jsx("div", { className: "p-5 flex w-full", children: _jsx(Story, {}) })); },
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
export default meta;
|
|
28
|
+
export var Default = {
|
|
29
|
+
args: {
|
|
30
|
+
label: "Lorem Ipsum",
|
|
31
|
+
// value: "Lorem Ipsum",
|
|
32
|
+
fullwidth: true,
|
|
33
|
+
},
|
|
34
|
+
render: function (args) {
|
|
35
|
+
console.log("args ", args);
|
|
36
|
+
var props = __assign({}, args);
|
|
37
|
+
return (_jsxs("div", { className: "flex flex-row gap-4 w-full", children: [_jsx(TextInput, __assign({ id: "1", placeholder: "placeholder", size: "lg" }, args)), _jsx(TextInput, __assign({ id: "2", placeholder: "placeholder", size: "md" }, args)), _jsx(TextInput, __assign({ id: "3", placeholder: "placeholder", size: "sm" }, args))] }));
|
|
38
|
+
},
|
|
39
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
export var inputVariant = cva([
|
|
3
|
+
"border-0 outline-none",
|
|
4
|
+
"p-1 flex",
|
|
5
|
+
"peer text-black placeholder:text-transparent",
|
|
6
|
+
], {
|
|
7
|
+
variants: {
|
|
8
|
+
size: {
|
|
9
|
+
sm: "p-2 px-3 typography-small1",
|
|
10
|
+
md: "py-2 px-3 typography-subtitile4",
|
|
11
|
+
lg: "p-4 typography-subtitile1",
|
|
12
|
+
},
|
|
13
|
+
rounded: {
|
|
14
|
+
none: "rounded-none",
|
|
15
|
+
normal: "rounded-xl",
|
|
16
|
+
full: "rounded-full",
|
|
17
|
+
},
|
|
18
|
+
variant: {
|
|
19
|
+
flat: "",
|
|
20
|
+
outline: "ring-1 ring-inset ring-input-stroke hover:ring-input-active focus:ring-2 focus:ring-inset focus:ring-input-active",
|
|
21
|
+
underline: "border-b-2 border-input-stroke transition-colors hover:border-input-stroke-active focus:border-input-stroke",
|
|
22
|
+
},
|
|
23
|
+
fullwidth: {
|
|
24
|
+
true: "w-full",
|
|
25
|
+
},
|
|
26
|
+
disabled: {
|
|
27
|
+
true: "text-input-text-disabled ring-input-stroke-disabled placeholder:text-input-text-disabled",
|
|
28
|
+
},
|
|
29
|
+
error: {
|
|
30
|
+
true: "ring-error",
|
|
31
|
+
},
|
|
32
|
+
hasClearIcon: {
|
|
33
|
+
true: "",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
compoundVariants: [
|
|
37
|
+
{
|
|
38
|
+
variant: "underline",
|
|
39
|
+
className: "rounded-none",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
hasClearIcon: true,
|
|
43
|
+
size: "sm",
|
|
44
|
+
class: "focus:pe-6",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
hasClearIcon: true,
|
|
48
|
+
size: "md",
|
|
49
|
+
class: "focus:pe-8",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
hasClearIcon: true,
|
|
53
|
+
size: "lg",
|
|
54
|
+
class: "focus:pe-10",
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
defaultVariants: {
|
|
58
|
+
size: "md",
|
|
59
|
+
variant: "outline",
|
|
60
|
+
rounded: "normal",
|
|
61
|
+
fullwidth: false,
|
|
62
|
+
disabled: false,
|
|
63
|
+
error: false,
|
|
64
|
+
hasClearIcon: false,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
export var labelVariant = cva([
|
|
68
|
+
"absolute block transition-all px-[2px] text-input-text peer-focus:text-input-text-active peer-focus:bg-input-label-background",
|
|
69
|
+
], {
|
|
70
|
+
variants: {
|
|
71
|
+
size: {
|
|
72
|
+
sm: [
|
|
73
|
+
"left-3 top-2 typography-small1 peer-focus:-top-1.5 peer-focus:typography-label2",
|
|
74
|
+
"bg-input-label-background peer-[:not(:placeholder-shown)]:-top-1.5 peer-[:not(:placeholder-shown)]:typography-label2",
|
|
75
|
+
],
|
|
76
|
+
md: [
|
|
77
|
+
"left-3 top-2 typography-subtitile4 peer-focus:-top-1.5 peer-focus:typography-label1",
|
|
78
|
+
"bg-input-label-background peer-[:not(:placeholder-shown)]:-top-1.5 peer-[:not(:placeholder-shown)]:typography-label1",
|
|
79
|
+
],
|
|
80
|
+
lg: [
|
|
81
|
+
"left-4 top-4 typography-subtitile1 peer-focus:-top-1.5 peer-focus:typography-label1",
|
|
82
|
+
"bg-input-label-background peer-[:not(:placeholder-shown)]:-top-1.5 peer-[:not(:placeholder-shown)]:typography-label1",
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
disabled: {
|
|
86
|
+
true: "text-input-text-disabled ring-input-stroke-disabled placeholder:text-input-text-disabled",
|
|
87
|
+
},
|
|
88
|
+
error: {
|
|
89
|
+
true: "ring-error",
|
|
90
|
+
},
|
|
91
|
+
isFloating: {
|
|
92
|
+
true: "-top-1.5 typography-label1 bg-input-label-background",
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
compoundVariants: [
|
|
96
|
+
{
|
|
97
|
+
size: "sm",
|
|
98
|
+
isFloating: true,
|
|
99
|
+
class: "-top-1.5 typography-label2 bg-input-label-background",
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
defaultVariants: {
|
|
103
|
+
size: "md",
|
|
104
|
+
disabled: false,
|
|
105
|
+
error: false,
|
|
106
|
+
isFloating: false,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
export var helperTextVariant = cva(["text-small1 flex flex-row items-center gap-1"], {
|
|
110
|
+
variants: {
|
|
111
|
+
size: {
|
|
112
|
+
sm: "mt-1",
|
|
113
|
+
md: "mt-[6px]",
|
|
114
|
+
lg: "mt-[6px]",
|
|
115
|
+
},
|
|
116
|
+
disabled: {
|
|
117
|
+
true: "text-input-text-disabled",
|
|
118
|
+
},
|
|
119
|
+
error: {
|
|
120
|
+
true: "text-error",
|
|
121
|
+
false: "text-input-text",
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
defaultVariants: {
|
|
125
|
+
size: "md",
|
|
126
|
+
disabled: false,
|
|
127
|
+
error: false,
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
export var iconWrapperVariant = cva([
|
|
131
|
+
"absolute inset-y-0 right-0 items-center justify-center hidden peer-focus:flex",
|
|
132
|
+
], {
|
|
133
|
+
variants: {
|
|
134
|
+
size: {
|
|
135
|
+
sm: "mr-2",
|
|
136
|
+
md: "mr-3",
|
|
137
|
+
lg: "mr-4",
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
defaultVariants: {
|
|
141
|
+
size: "md",
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
export var iconVariant = cva(["cursor-pointer z-50 fill-input-stroke-active hover:fill-input-text"], {
|
|
145
|
+
variants: {
|
|
146
|
+
size: {
|
|
147
|
+
sm: "size-3",
|
|
148
|
+
md: "size-4",
|
|
149
|
+
lg: "size-5",
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
defaultVariants: {
|
|
153
|
+
size: "md",
|
|
154
|
+
},
|
|
155
|
+
});
|