@momo-webplatform/mobase 0.0.16 → 0.0.17
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/package.json +3 -2
- package/publish/cjs/components/TextArea/TextArea.js +5 -5
- package/publish/cjs/components/TextInput/TextInput.js +6 -6
- package/publish/cjs/mobase-tw-plugin/foundation/index.js +20 -0
- package/publish/cjs/mobase-tw-plugin/plugin.js +15 -56
- package/publish/cjs/tsconfig.lib.tsbuildinfo +1 -1
- package/publish/esm/components/TextArea/TextArea.js +5 -5
- package/publish/esm/components/TextInput/TextInput.js +6 -6
- package/publish/esm/mobase-tw-plugin/foundation/index.d.ts +4 -0
- package/publish/esm/mobase-tw-plugin/foundation/index.js +4 -0
- package/publish/esm/mobase-tw-plugin/plugin.js +11 -52
- package/publish/esm/tsconfig.lib.tsbuildinfo +1 -1
- /package/publish/cjs/mobase-tw-plugin/{animations → foundation/animations}/index.js +0 -0
- /package/publish/cjs/mobase-tw-plugin/{colors → foundation/colors}/blue.js +0 -0
- /package/publish/cjs/mobase-tw-plugin/{colors → foundation/colors}/common.js +0 -0
- /package/publish/cjs/mobase-tw-plugin/{colors → foundation/colors}/gray.js +0 -0
- /package/publish/cjs/mobase-tw-plugin/{colors → foundation/colors}/green.js +0 -0
- /package/publish/cjs/mobase-tw-plugin/{colors → foundation/colors}/index.js +0 -0
- /package/publish/cjs/mobase-tw-plugin/{colors → foundation/colors}/orange.js +0 -0
- /package/publish/cjs/mobase-tw-plugin/{colors → foundation/colors}/pink.js +0 -0
- /package/publish/cjs/mobase-tw-plugin/{colors → foundation/colors}/purple.js +0 -0
- /package/publish/cjs/mobase-tw-plugin/{colors → foundation/colors}/red.js +0 -0
- /package/publish/cjs/mobase-tw-plugin/{colors → foundation/colors}/yellow.js +0 -0
- /package/publish/cjs/mobase-tw-plugin/{font-sizes → foundation/font-sizes}/index.js +0 -0
- /package/publish/cjs/mobase-tw-plugin/{shadows → foundation/shadows}/index.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{animations → foundation/animations}/index.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{animations → foundation/animations}/index.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/blue.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/blue.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/common.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/common.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/gray.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/gray.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/green.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/green.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/index.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/index.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/orange.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/orange.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/pink.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/pink.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/purple.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/purple.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/red.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/red.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/yellow.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{colors → foundation/colors}/yellow.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{font-sizes → foundation/font-sizes}/index.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{font-sizes → foundation/font-sizes}/index.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{shadows → foundation/shadows}/index.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{shadows → foundation/shadows}/index.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-webplatform/mobase",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "Mobase is the UI framework upon we build product experiences at MoMo.vn, base on Radix primitives, and Tailwind CSS.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "next dev",
|
|
@@ -71,11 +71,12 @@
|
|
|
71
71
|
"date-fns": "^3.2.0",
|
|
72
72
|
"deepmerge": "^4.3.1",
|
|
73
73
|
"dlv": "^1.1.3",
|
|
74
|
-
"flat": "^
|
|
74
|
+
"flat": "^3.0.1",
|
|
75
75
|
"flowbite-react": "^0.7.2",
|
|
76
76
|
"framer-motion": "^11.0.3",
|
|
77
77
|
"fs": "0.0.1-security",
|
|
78
78
|
"lodash": "^4.17.21",
|
|
79
|
+
"lodash.foreach": "^4.5.0",
|
|
79
80
|
"lodash.omit": "^4.5.0",
|
|
80
81
|
"lucide-react": "^0.307.0",
|
|
81
82
|
"next": "^13.0.0",
|
|
@@ -9,11 +9,11 @@ const utils_1 = require("../../helpers/utils");
|
|
|
9
9
|
exports.TextArea = (0, react_1.forwardRef)(({ disabled, isError, message, label, className, inputClassName, rows = 3, ...restProps }, ref) => {
|
|
10
10
|
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("relative", className, isError && "mobase-text-area-error"), children: [label && ((0, jsx_runtime_1.jsx)("span", { className: (0, utils_1.cn)("mobase-text-area-label absolute bg-white -top-2.5 px-1.5 left-2 text-sm", disabled ? "text-gray-400" : "text-gray-500"), children: label })), (0, jsx_runtime_1.jsx)("textarea", { disabled: disabled, ref: ref, className: (0, utils_1.cn)("mobase-text-area-box bg-white w-full transition-all rounded border border-gray-400 placeholder:text-base placeholder:text-gray-500 p-3 text-gray-900 focus:border-pink-500 disabled:bg-gray-50 disabled:border-gray-300 outline-none block", inputClassName), rows: rows, ...restProps }), message && ((0, jsx_runtime_1.jsxs)("div", { className: "mobase-text-area-message flex space-x-1 items-center mt-0.5", children: [isError ? ((0, jsx_runtime_1.jsx)(solid_1.XCircleIcon, { width: 16, height: 16, className: "text-red-500" })) : ((0, jsx_runtime_1.jsx)(outline_1.QuestionMarkCircleIcon, { width: 16, height: 16, className: "text-gray-500" })), (0, jsx_runtime_1.jsx)("span", { className: "text-gray-500 text-sm", children: message })] })), (0, jsx_runtime_1.jsx)("style", { children: `
|
|
11
11
|
.mobase-text-area-box:hover {
|
|
12
|
-
box-shadow: 0px 0px 0px 1px
|
|
12
|
+
box-shadow: 0px 0px 0px 1px rgb(var(--gray-400) / 1) inset;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
.mobase-text-area-box:focus {
|
|
16
|
-
box-shadow: 0px 0px 0px 1px
|
|
16
|
+
box-shadow: 0px 0px 0px 1px rgb(var(--pink-500) / 1) inset;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.mobase-text-area-box:disabled {
|
|
@@ -22,16 +22,16 @@ exports.TextArea = (0, react_1.forwardRef)(({ disabled, isError, message, label,
|
|
|
22
22
|
|
|
23
23
|
.mobase-text-area-error {
|
|
24
24
|
.mobase-text-area-label {
|
|
25
|
-
color:
|
|
25
|
+
color: rgb(var(--red-500) / 1);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
.mobase-text-area-box {
|
|
29
29
|
box-shadow: 0px 0px 0px 1px hsl(var(--red-500) / 1) inset;
|
|
30
|
-
border-color:
|
|
30
|
+
border-color: rgb(var(--red-500) / 1);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
.mobase-text-area-message span {
|
|
34
|
-
color:
|
|
34
|
+
color: rgb(var(--red-500) / 1);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
` })] }));
|
|
@@ -41,25 +41,25 @@ exports.TextInput = (0, react_1.forwardRef)(({ disabled, isError, message, label
|
|
|
41
41
|
}, [value, defaultValue]);
|
|
42
42
|
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)(className, isError && "mobase-text-input-error"), ref: rootRef, children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [label && ((0, jsx_runtime_1.jsx)("span", { className: (0, utils_1.cn)("mobase-text-input-label absolute bg-white -top-2.5 px-1.5 left-2 text-sm", disabled ? "text-gray-400" : "text-gray-500"), children: label })), (0, jsx_runtime_1.jsx)("input", { disabled: disabled, type: type, ref: ref, className: (0, utils_1.cn)("mobase-text-input-box bg-white w-full transition-all rounded border border-gray-400 placeholder:text-base placeholder:text-gray-500 p-3 text-gray-900 h-12 focus:border-pink-500 disabled:bg-gray-50 disabled:border-gray-300 disabled:pointer-events-none block", inputClassName), onChange: onChangeFactory, onFocus: onFocusFactory, value: value, defaultValue: defaultValue, ...restProps }), withClearButton && clearable && ((0, jsx_runtime_1.jsx)("button", { "aria-label": "button", type: "button", className: "absolute right-3 top-1/2 -translate-y-1/2 shrink-0 cursor-pointer text-gray-500 duration-200 hover:opacity-70 disabled:pointer-events-none", disabled: disabled, onClick: handleClear, children: (0, jsx_runtime_1.jsx)(outline_1.XCircleIcon, { strokeWidth: 2, width: 20, height: 20 }) }))] }), message && ((0, jsx_runtime_1.jsxs)("div", { className: "mobase-text-input-message flex space-x-1 items-center mt-0.5", children: [isError ? ((0, jsx_runtime_1.jsx)(solid_1.XCircleIcon, { width: 16, height: 16, className: "text-red-500" })) : ((0, jsx_runtime_1.jsx)(outline_1.QuestionMarkCircleIcon, { width: 16, height: 16, className: "text-gray-500" })), (0, jsx_runtime_1.jsx)("span", { className: "text-gray-500 text-sm", children: message })] })), (0, jsx_runtime_1.jsx)("style", { children: `
|
|
43
43
|
.mobase-text-input-box:hover {
|
|
44
|
-
box-shadow: 0px 0px 0px 1px
|
|
44
|
+
box-shadow: 0px 0px 0px 1px rgb(var(--gray-400) / 1) inset;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
.mobase-text-input-box:focus {
|
|
48
|
-
box-shadow: 0px 0px 0px 1px
|
|
48
|
+
box-shadow: 0px 0px 0px 1px rgb(var(--pink-500) / 1) inset;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
.mobase-text-input-error {
|
|
52
52
|
.mobase-text-input-label {
|
|
53
|
-
color:
|
|
53
|
+
color: rgb(var(--red-500) / 1);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
.mobase-text-input-box {
|
|
57
|
-
box-shadow: 0px 0px 0px 1px
|
|
58
|
-
border-color:
|
|
57
|
+
box-shadow: 0px 0px 0px 1px rgb(var(--red-500) / 1) inset;
|
|
58
|
+
border-color: rgb(var(--red-500) / 1);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
.mobase-text-input-message span {
|
|
62
|
-
color:
|
|
62
|
+
color: rgb(var(--red-500) / 1);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
` })] }));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./colors"), exports);
|
|
18
|
+
__exportStar(require("./font-sizes"), exports);
|
|
19
|
+
__exportStar(require("./shadows"), exports);
|
|
20
|
+
__exportStar(require("./animations"), exports);
|
|
@@ -17,58 +17,35 @@ const color_1 = __importDefault(require("color"));
|
|
|
17
17
|
const plugin_js_1 = __importDefault(require("tailwindcss/plugin.js"));
|
|
18
18
|
const utilities_1 = require("./utilities");
|
|
19
19
|
const utils_1 = require("./utils");
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const shadows_1 = require("./shadows");
|
|
23
|
-
const font_sizes_1 = require("./font-sizes");
|
|
20
|
+
const foundation_1 = require("./foundation");
|
|
21
|
+
const lodash_foreach_1 = __importDefault(require("lodash.foreach"));
|
|
24
22
|
const parsedColorsCache = {};
|
|
25
23
|
const resolveConfig = () => {
|
|
26
24
|
const resolved = {
|
|
27
25
|
utilities: {},
|
|
28
26
|
colors: {},
|
|
29
27
|
};
|
|
30
|
-
const flatColors = (0, utils_1.flattenThemeObject)(
|
|
31
|
-
const cssSelector =
|
|
28
|
+
const flatColors = (0, utils_1.flattenThemeObject)(foundation_1.colors);
|
|
29
|
+
const cssSelector = ":root";
|
|
32
30
|
resolved.utilities[cssSelector] = {};
|
|
33
|
-
|
|
31
|
+
(0, lodash_foreach_1.default)(flatColors, (colorValue, colorName) => {
|
|
34
32
|
if (!colorValue)
|
|
35
33
|
return;
|
|
36
34
|
try {
|
|
37
35
|
const parsedColor = parsedColorsCache[colorValue] ||
|
|
38
|
-
(0, color_1.default)(colorValue).
|
|
36
|
+
(0, color_1.default)(colorValue).rgb().round().array();
|
|
39
37
|
parsedColorsCache[colorValue] = parsedColor;
|
|
40
|
-
const [
|
|
38
|
+
const [r, g, b] = parsedColor;
|
|
41
39
|
const colorVar = `--${colorName}`;
|
|
42
|
-
const opacityVar = `--${colorName}-opacity`;
|
|
43
40
|
// Set the css variable in "@layer utilities"
|
|
44
|
-
resolved.utilities[cssSelector][colorVar] = `${
|
|
45
|
-
|
|
46
|
-
if (typeof defaultAlphaValue === "number") {
|
|
47
|
-
resolved.utilities[cssSelector][opacityVar] =
|
|
48
|
-
defaultAlphaValue.toFixed(2);
|
|
49
|
-
}
|
|
50
|
-
// set the dynamic color in tailwind config theme.colors
|
|
51
|
-
// opacityVariable va opacityValue ở đâu ra, đm nó
|
|
52
|
-
resolved.colors[colorName] = ({ opacityVariable, opacityValue }) => {
|
|
53
|
-
// if the opacity is set with a slash (e.g. bg-primary/90), use the provided value
|
|
54
|
-
if (!isNaN(+opacityValue)) {
|
|
55
|
-
return `hsl(var(${colorVar}) / ${opacityValue})`;
|
|
56
|
-
}
|
|
57
|
-
// if no opacityValue was provided (=it is not parsable to a number)
|
|
58
|
-
// the nextuiOpacityVariable (opacity defined in the color definition rgb(0, 0, 0, 0.5)) should have the priority
|
|
59
|
-
// over the tw class based opacity(e.g. "bg-opacity-90")
|
|
60
|
-
// This is how tailwind behaves as for v3.2.4
|
|
61
|
-
if (opacityVariable) {
|
|
62
|
-
return `hsl(var(${colorVar}) / var(${opacityVar}, var(${opacityVariable})))`;
|
|
63
|
-
}
|
|
64
|
-
return `hsl(var(${colorVar}) / var(${opacityVar}, 1))`;
|
|
65
|
-
};
|
|
41
|
+
resolved.utilities[cssSelector][colorVar] = `${r} ${g} ${b}`;
|
|
42
|
+
resolved.colors[colorName] = `rgb(var(${colorVar}) / <alpha-value>)`;
|
|
66
43
|
}
|
|
67
44
|
catch (error) {
|
|
68
45
|
// eslint-disable-next-line no-console
|
|
69
46
|
console.log("error", error?.message);
|
|
70
47
|
}
|
|
71
|
-
}
|
|
48
|
+
});
|
|
72
49
|
return resolved;
|
|
73
50
|
};
|
|
74
51
|
const mobaseTW = () => {
|
|
@@ -78,7 +55,7 @@ const mobaseTW = () => {
|
|
|
78
55
|
":root": {
|
|
79
56
|
"font-smooth--webkit": "antialiased",
|
|
80
57
|
},
|
|
81
|
-
...resolved?.utilities, //Xem lai cho nay, addBase
|
|
58
|
+
...resolved?.utilities, // Xem lai cho nay, addBase
|
|
82
59
|
});
|
|
83
60
|
addUtilities({
|
|
84
61
|
// ...resolved?.utilities, //Xem lai cho nay, addBase
|
|
@@ -90,34 +67,16 @@ const mobaseTW = () => {
|
|
|
90
67
|
theme: {
|
|
91
68
|
extend: {
|
|
92
69
|
colors: {
|
|
93
|
-
...
|
|
70
|
+
...foundation_1.colors,
|
|
94
71
|
...resolved?.colors,
|
|
95
72
|
},
|
|
96
|
-
screens: {
|
|
97
|
-
xs: "480px",
|
|
98
|
-
},
|
|
99
|
-
padding: {
|
|
100
|
-
"2px": "calc(2px - var(--wg-border-width, 0px))",
|
|
101
|
-
"4px": "calc(4px - var(--wg-border-width, 0px))",
|
|
102
|
-
"6px": "calc(6px - var(--wg-border-width, 0px))",
|
|
103
|
-
"8px": "calc(8px - var(--wg-border-width, 0px))",
|
|
104
|
-
"12px": "calc(12px - var(--wg-border-width, 0px))",
|
|
105
|
-
"14px": "14px",
|
|
106
|
-
"16px": "calc(16px - var(--wg-border-width, 0px))",
|
|
107
|
-
},
|
|
108
|
-
outlineOffset: {
|
|
109
|
-
3: "3px",
|
|
110
|
-
},
|
|
111
|
-
textUnderlineOffset: {
|
|
112
|
-
3: "3px",
|
|
113
|
-
},
|
|
114
73
|
boxShadow: {
|
|
115
|
-
...
|
|
74
|
+
...foundation_1.boxShadows,
|
|
116
75
|
},
|
|
117
76
|
fontSize: {
|
|
118
|
-
...
|
|
77
|
+
...foundation_1.fontSizes,
|
|
119
78
|
},
|
|
120
|
-
...
|
|
79
|
+
...foundation_1.animations,
|
|
121
80
|
},
|
|
122
81
|
},
|
|
123
82
|
});
|