@momo-webplatform/mobase 0.0.40 → 0.0.41
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/README.md +1 -1
- package/package.json +1 -1
- package/publish/cjs/components/Choicebox/Choicebox.js +90 -0
- package/publish/cjs/components/Choicebox/index.js +6 -0
- package/publish/cjs/components/Dialog/Dialog.js +7 -7
- package/publish/cjs/index.js +1 -0
- package/publish/cjs/tsconfig.lib.tsbuildinfo +1 -1
- package/publish/esm/components/Choicebox/Choicebox.d.ts +31 -0
- package/publish/esm/components/Choicebox/Choicebox.js +62 -0
- package/publish/esm/components/Choicebox/index.d.ts +1 -0
- package/publish/esm/components/Choicebox/index.js +1 -0
- package/publish/esm/components/Dialog/Dialog.js +7 -7
- package/publish/esm/index.d.ts +1 -0
- package/publish/esm/index.js +1 -0
- package/publish/esm/tsconfig.lib.tsbuildinfo +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://momo.vn/">
|
|
3
|
-
<img width="100%" src="https://homepage.momocdn.net/img/momo-upload-api-
|
|
3
|
+
<img width="100%" src="https://homepage.momocdn.net/img/momo-upload-api-240509152105-638508648658180278.jpg" alt="Mobase UI library" />
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ChoiceboxGroup = exports.ChoiceboxGroupItem = void 0;
|
|
27
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const Checkbox_1 = require("../Checkbox");
|
|
30
|
+
const utils_1 = require("../../helpers/utils");
|
|
31
|
+
const lucide_react_1 = require("lucide-react");
|
|
32
|
+
const ChoiceboxGroupItem = ({ title, description, value, type, name, checked, disabled, hiddenInput, classNameDescription, classNameTitle, className, onChange, children, }) => {
|
|
33
|
+
const [checkedCheckbox, setCheckedCheckbox] = (0, react_1.useState)(false);
|
|
34
|
+
const handleChange = (event) => {
|
|
35
|
+
if (onChange) {
|
|
36
|
+
onChange(event?.target?.value);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const handleChangeCheckbox = (checked) => {
|
|
40
|
+
setCheckedCheckbox(checked);
|
|
41
|
+
onChange?.(checked);
|
|
42
|
+
};
|
|
43
|
+
return ((0, jsx_runtime_1.jsxs)("label", { className: (0, utils_1.cn)(" flex rounded-md cursor-pointer p-4 items-center space-x-6", checked || checkedCheckbox ? "mobase-focus" : "mobase-visible", disabled ? "opacity-60 bg-gray-100" : "", className), htmlFor: value, children: [!title && !description ? null : ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("text-gray-900 text-sm select-none font-bold", classNameTitle), children: title }), (0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("text-gray-900 select-none text-sm", classNameDescription), children: description })] })), children, type === "radio" ? ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("relative", hiddenInput ? "hidden" : ""), children: [(0, jsx_runtime_1.jsx)("input", { "aria-checked": checked, "data-state": checked ? "checked" : "unchecked", checked: checked, type: "radio", value: value, name: name, id: value, disabled: disabled, onChange: handleChange, className: "custom-radio cursor-pointer aspect-square ml-auto h-4 w-4 rounded-full border border-gray-700 disabled:bg-gray-300 disabled:data-[state=checked]:text-gray-500 data-[state=checked]:text-white disabled:data-[state=checked]:bg-gray-300 data-[state=checked]:bg-pink-500 disabled:border-none data-[state=checked]:border-none text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-default disabled:opacity-40" }), (0, jsx_runtime_1.jsx)(lucide_react_1.Circle, { className: (0, utils_1.cn)("h-2 w-2 absolute top-[6px] right-[4px] fill-white text-current transition-opacity", checked ? "opacti-100" : "opacity-0", disabled ? "fill-gray-300" : "") })] })) : ((0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { disabled: disabled, id: value, value: value, name: value, onCheckedChange: handleChangeCheckbox, className: (0, utils_1.cn)("ml-auto", hiddenInput ? "hidden" : "") })), (0, jsx_runtime_1.jsx)("style", { children: `
|
|
44
|
+
.custom-radio {
|
|
45
|
+
appearance: none;
|
|
46
|
+
border: 1px solid #ccc;
|
|
47
|
+
border-radius: 50%;
|
|
48
|
+
width: 16px;
|
|
49
|
+
height: 16px;
|
|
50
|
+
position: relative;
|
|
51
|
+
}
|
|
52
|
+
.mobase-visible {
|
|
53
|
+
box-shadow: 0px 0px 0px 1px rgb(var(--mobase-gray-400) / 1) inset;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.mobase-focus {
|
|
57
|
+
box-shadow: 0px 0px 0px 2px rgb(var(--mobase-pink-500) / 1) inset;
|
|
58
|
+
}
|
|
59
|
+
` })] }));
|
|
60
|
+
};
|
|
61
|
+
exports.ChoiceboxGroupItem = ChoiceboxGroupItem;
|
|
62
|
+
const ChoiceboxGroup = ({ direction = "row", label, type, value, children, disabled, hiddenInput, onChange, className, ...props }) => {
|
|
63
|
+
const name = `choicebox-group-${label?.replace(/\s+/g, "-").toLowerCase()}`;
|
|
64
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ...props, children: [(0, jsx_runtime_1.jsx)("label", { children: label }), (0, jsx_runtime_1.jsx)("ul", { className: (0, utils_1.cn)("", className, direction
|
|
65
|
+
? "flex md:flex-row md:space-y-0 md:space-x-4 flex-col space-y-4"
|
|
66
|
+
: "block"), children: react_1.default.Children?.map(children, (child) => {
|
|
67
|
+
if (react_1.default.isValidElement(child)) {
|
|
68
|
+
const updatedProps = {
|
|
69
|
+
disabled: child.props.disabled ?? disabled,
|
|
70
|
+
type,
|
|
71
|
+
name,
|
|
72
|
+
checked: child.props.value === value,
|
|
73
|
+
hiddenInput,
|
|
74
|
+
className: child.props.className,
|
|
75
|
+
classNameTitle: child.props.classNameTitle,
|
|
76
|
+
classNameDescription: child.props.classNameDescription,
|
|
77
|
+
onChange,
|
|
78
|
+
};
|
|
79
|
+
const knownProps = Object.keys(updatedProps).reduce((acc, key) => {
|
|
80
|
+
if (updatedProps[key] !== undefined) {
|
|
81
|
+
acc[key] = updatedProps[key];
|
|
82
|
+
}
|
|
83
|
+
return acc;
|
|
84
|
+
}, {});
|
|
85
|
+
return react_1.default.cloneElement(child, knownProps);
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}) })] }));
|
|
89
|
+
};
|
|
90
|
+
exports.ChoiceboxGroup = ChoiceboxGroup;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChoiceboxGroupItem = exports.ChoiceboxGroup = void 0;
|
|
4
|
+
var Choicebox_1 = require("./Choicebox");
|
|
5
|
+
Object.defineProperty(exports, "ChoiceboxGroup", { enumerable: true, get: function () { return Choicebox_1.ChoiceboxGroup; } });
|
|
6
|
+
Object.defineProperty(exports, "ChoiceboxGroupItem", { enumerable: true, get: function () { return Choicebox_1.ChoiceboxGroupItem; } });
|
|
@@ -42,11 +42,11 @@ exports.DialogOverlay = DialogOverlay;
|
|
|
42
42
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
43
43
|
const DialogContent = React.forwardRef(({ className, isRightCloseButton, size = "md", position = "center", height = "auto", isFull = false, children, ...props }, ref) => {
|
|
44
44
|
const classNames = {
|
|
45
|
-
base: "fixed z-50 flex
|
|
46
|
-
center: "left-[50%] top-[50%] translate-x-[-50%] translate-y-[-50%] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-
|
|
47
|
-
bottom: "!duration-300 bottom-0 sm:bottom-1/2 left-1/2 rounded-t-
|
|
48
|
-
left: "!duration-300 max-h-screen !h-full rounded-r-
|
|
49
|
-
right: "!duration-300 !h-full rounded-l-
|
|
45
|
+
base: "fixed z-50 flex bg-white shadow-lg sm:rounded-xl bg-white text-gray-900 w-full max-w-[calc(-64px_+_100vw)] max-h-[calc(-64px_+_100vh)] flex-col",
|
|
46
|
+
center: "left-[50%] top-[50%] translate-x-[-50%] translate-y-[-50%] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-xl",
|
|
47
|
+
bottom: "!duration-300 bottom-0 sm:bottom-1/2 left-1/2 rounded-t-xl sm:translate-y-1/2 data-[state=closed]:animate-out -translate-x-1/2 data-[state=open]:animate-in data-[state=open]:slide-in-from-left-1/2 ease-in-out data-[state=open]:slide-in-from-bottom-2/3 data-[state=closed]:slide-out-to-bottom-2/3 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 max-w-full max-h-[calc(-32px_+_100vh)] sm:max-h-[calc(-64px_+_100vh)]",
|
|
48
|
+
left: "!duration-300 max-h-screen !h-full rounded-r-xl sm:rounded-l-none top-0 data-[state=open]:animate-in data-[state=open]:slide-in-from-left data-[state=closed]:animate-out data-[state=closed]:slide-out-to-left ease-in-out",
|
|
49
|
+
right: "!duration-300 !h-full rounded-l-xl sm:rounded-r-none max-h-screen top-0 right-0 data-[state=open]:animate-in data-[state=open]:slide-in-from-right data-[state=closed]:animate-out data-[state=closed]:slide-out-to-right ease-in-out",
|
|
50
50
|
};
|
|
51
51
|
const sizeClassNames = {
|
|
52
52
|
sm: "w-80 sm:w-80",
|
|
@@ -66,10 +66,10 @@ const DialogContent = React.forwardRef(({ className, isRightCloseButton, size =
|
|
|
66
66
|
sizeClassNames[size],
|
|
67
67
|
heightClassNames[height],
|
|
68
68
|
isFull &&
|
|
69
|
-
"h-full max-h-screen max-w-full w-full rounded-none sm:rounded-
|
|
69
|
+
"h-full max-h-screen max-w-full w-full rounded-none sm:rounded-xl sm:max-h-[calc(-64px_+_100vh)]",
|
|
70
70
|
className,
|
|
71
71
|
];
|
|
72
|
-
return ((0, jsx_runtime_1.jsxs)(DialogPortal, { children: [(0, jsx_runtime_1.jsx)(DialogOverlay, {}), (0, jsx_runtime_1.jsxs)(DialogPrimitive.Content, { ref: ref, className: (0, utils_1.cn)(...classNamesDialogContent), ...props, children: [children, (0, jsx_runtime_1.jsxs)(DialogPrimitive.Close, { className: (0, utils_1.cn)("absolute md:top-4 top-2 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-gray-100 data-[state=open]:text-gray-700 text-gray-900 w-8 h-8 flex justify-center items-center rounded-full before:opacity-0 hover:before:opacity-100 before:transition-opacity before:z-[-1] before:content-[''] before:absolute before:inset-0 before:rounded-full before:select-none before:left-0 before:top-0 before:bg-gray-200 left-3 md:left-auto md:right-4", isRightCloseButton && "left-auto right-3 md:right-4"), title: "\u0110\u00F3ng", children: [(0, jsx_runtime_1.jsx)(solid_1.XMarkIcon, { className: "h-5 w-5 text-gray-
|
|
72
|
+
return ((0, jsx_runtime_1.jsxs)(DialogPortal, { children: [(0, jsx_runtime_1.jsx)(DialogOverlay, {}), (0, jsx_runtime_1.jsxs)(DialogPrimitive.Content, { ref: ref, className: (0, utils_1.cn)(...classNamesDialogContent), ...props, children: [children, (0, jsx_runtime_1.jsxs)(DialogPrimitive.Close, { className: (0, utils_1.cn)("absolute md:top-4 top-2 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-gray-100 data-[state=open]:text-gray-700 text-gray-900 w-8 h-8 flex justify-center items-center rounded-full before:opacity-0 hover:before:opacity-100 before:transition-opacity before:z-[-1] before:content-[''] before:absolute before:inset-0 before:rounded-full before:select-none before:left-0 before:top-0 before:bg-gray-200 left-3 md:left-auto md:right-4", isRightCloseButton && "left-auto right-3 md:right-4"), title: "\u0110\u00F3ng", children: [(0, jsx_runtime_1.jsx)(solid_1.XMarkIcon, { className: "h-5 w-5 text-gray-700" }), (0, jsx_runtime_1.jsx)("span", { className: "sr-only", children: "Close" })] })] })] }));
|
|
73
73
|
});
|
|
74
74
|
exports.DialogContent = DialogContent;
|
|
75
75
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
package/publish/cjs/index.js
CHANGED
|
@@ -42,5 +42,6 @@ __exportStar(require("./components/Command"), exports);
|
|
|
42
42
|
__exportStar(require("./components/Combobox"), exports);
|
|
43
43
|
__exportStar(require("./components/Callout"), exports);
|
|
44
44
|
__exportStar(require("./components/SearchBar"), exports);
|
|
45
|
+
__exportStar(require("./components/Choicebox"), exports);
|
|
45
46
|
__exportStar(require("./mobase-tw-plugin"), exports);
|
|
46
47
|
__exportStar(require("./site"), exports);
|