@prokodo/ui 0.0.33 → 0.0.34
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/components/button/Button.client.js +15 -87
- package/dist/components/button/Button.server.js +9 -65
- package/dist/components/button/Button.view.js +61 -0
- package/dist/constants/project.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/components/button/Button.client.d.ts +1 -1
- package/dist/types/components/button/Button.model.d.ts +10 -0
- package/dist/types/components/button/Button.server.d.ts +2 -2
- package/dist/types/components/button/Button.view.d.ts +3 -0
- package/dist/ui.css +209 -209
- package/package.json +1 -1
|
@@ -1,98 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
-
import {
|
|
5
|
-
import { useId, useRef, useMemo } from "react";
|
|
6
|
-
import { create } from "../../helpers/bem.js";
|
|
7
|
-
import { isString } from "../../helpers/validations.js";
|
|
8
|
-
import styles from "./Button.module.scss.js";
|
|
4
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
9
5
|
import { Link } from "../link/Link.js";
|
|
10
|
-
import {
|
|
6
|
+
import { ButtonView } from "./Button.view.js";
|
|
11
7
|
import { Loading } from "../loading/Loading.js";
|
|
12
|
-
const bem = create(styles, "Button");
|
|
13
|
-
const mockEvent = {};
|
|
14
|
-
const mockKeyDownEvent = {};
|
|
15
8
|
function ButtonClient(props) {
|
|
16
|
-
const {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
className,
|
|
24
|
-
contentClassName,
|
|
25
|
-
disabled,
|
|
26
|
-
redirect,
|
|
27
|
-
onClick,
|
|
28
|
-
onKeyDown,
|
|
29
|
-
...rest
|
|
30
|
-
} = props;
|
|
31
|
-
const uniqueId = useId();
|
|
32
|
-
const labelRef = useRef(null);
|
|
33
|
-
const ariaLabelId = `Button-${uniqueId}`;
|
|
34
|
-
const isOutlined = variant === "outlined";
|
|
35
|
-
const iconName = iconProps == null ? void 0 : iconProps.name;
|
|
36
|
-
const isIconOnly = iconName && !(props == null ? void 0 : props.title);
|
|
37
|
-
const iconModifier = useMemo(
|
|
38
|
-
() => ({
|
|
39
|
-
"icon-only": Boolean(isIconOnly)
|
|
40
|
-
}),
|
|
41
|
-
[isIconOnly]
|
|
42
|
-
);
|
|
43
|
-
const renderInnerContent = /* @__PURE__ */ __name(() => /* @__PURE__ */ jsxs("span", { ref: labelRef, "aria-labelledby": ariaLabelId, className: bem("title"), children: [
|
|
44
|
-
iconName && /* @__PURE__ */ jsx(Icon, { className: bem("icon", iconModifier), ...iconProps }),
|
|
45
|
-
props == null ? void 0 : props.title
|
|
46
|
-
] }), "renderInnerContent");
|
|
47
|
-
const renderContent = /* @__PURE__ */ __name(() => Boolean(loading) ? /* @__PURE__ */ jsx(Loading, { size: "xs" }) : renderInnerContent(), "renderContent");
|
|
48
|
-
const renderVariant = /* @__PURE__ */ __name(() => isOutlined ? /* @__PURE__ */ jsx("div", { className: bem("content", iconModifier, contentClassName), children: renderContent() }) : renderContent(), "renderVariant");
|
|
49
|
-
if (redirect) {
|
|
50
|
-
return /* @__PURE__ */ jsx(
|
|
51
|
-
Link,
|
|
9
|
+
const { loading, iconProps = {}, ...rest } = props;
|
|
10
|
+
const isIconOnly = typeof (iconProps == null ? void 0 : iconProps.name) === "string" && !props.title;
|
|
11
|
+
const finalIconProps = Boolean(loading) ? { name: void 0 } : iconProps;
|
|
12
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
13
|
+
Boolean(loading) && /* @__PURE__ */ jsx(Loading, { size: "xs" }),
|
|
14
|
+
/* @__PURE__ */ jsx(
|
|
15
|
+
ButtonView,
|
|
52
16
|
{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
{
|
|
58
|
-
"has-fullWidth": Boolean(fullWidth),
|
|
59
|
-
[`has-variant-${variant}`]: true,
|
|
60
|
-
[`has-bg-${color}`]: variant === "contained",
|
|
61
|
-
[`has-text-${color}`]: variant === "text",
|
|
62
|
-
"is-disabled": Boolean(disabled),
|
|
63
|
-
...iconModifier
|
|
64
|
-
},
|
|
65
|
-
className
|
|
66
|
-
),
|
|
67
|
-
onClick: /* @__PURE__ */ __name(() => onClick == null ? void 0 : onClick(mockEvent), "onClick"),
|
|
68
|
-
onKeyDown: /* @__PURE__ */ __name(() => onKeyDown == null ? void 0 : onKeyDown(mockKeyDownEvent), "onKeyDown"),
|
|
69
|
-
children: renderVariant()
|
|
17
|
+
...rest,
|
|
18
|
+
iconProps: finalIconProps,
|
|
19
|
+
isIconOnly: Boolean(isIconOnly),
|
|
20
|
+
LinkComponent: Link
|
|
70
21
|
}
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
return /* @__PURE__ */ jsx(
|
|
74
|
-
"button",
|
|
75
|
-
{
|
|
76
|
-
...rest,
|
|
77
|
-
color,
|
|
78
|
-
disabled: Boolean(disabled) || Boolean(loading),
|
|
79
|
-
id: `${ariaLabelId}${isString(id) ? ` ${id}` : ""}`,
|
|
80
|
-
tabIndex: redirect !== void 0 || Boolean(disabled) ? -1 : rest.tabIndex,
|
|
81
|
-
className: bem(
|
|
82
|
-
void 0,
|
|
83
|
-
{
|
|
84
|
-
"has-fullWidth": Boolean(fullWidth),
|
|
85
|
-
[`has-variant-${variant}`]: true,
|
|
86
|
-
[`has-bg-${color}`]: variant === "contained",
|
|
87
|
-
[`has-text-${color}`]: variant === "text",
|
|
88
|
-
"is-disabled": Boolean(disabled),
|
|
89
|
-
...iconModifier
|
|
90
|
-
},
|
|
91
|
-
className
|
|
92
|
-
),
|
|
93
|
-
children: renderVariant()
|
|
94
|
-
}
|
|
95
|
-
);
|
|
22
|
+
)
|
|
23
|
+
] });
|
|
96
24
|
}
|
|
97
25
|
__name(ButtonClient, "ButtonClient");
|
|
98
26
|
export {
|
|
@@ -1,73 +1,17 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { jsx
|
|
4
|
-
import { create } from "../../helpers/bem.js";
|
|
5
|
-
import styles from "./Button.module.scss.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
4
|
import { Link } from "../link/Link.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
fullWidth,
|
|
12
|
-
color = "primary",
|
|
13
|
-
iconProps = {},
|
|
14
|
-
variant = "contained",
|
|
15
|
-
className,
|
|
16
|
-
contentClassName,
|
|
17
|
-
disabled,
|
|
18
|
-
redirect
|
|
19
|
-
} = props;
|
|
20
|
-
const isOutlined = variant === "outlined";
|
|
21
|
-
const iconName = iconProps == null ? void 0 : iconProps.name;
|
|
22
|
-
const isIconOnly = iconName && !(props == null ? void 0 : props.title);
|
|
23
|
-
const iconModifier = {
|
|
24
|
-
"icon-only": Boolean(isIconOnly)
|
|
25
|
-
};
|
|
26
|
-
const renderInnerContent = /* @__PURE__ */ __name(() => /* @__PURE__ */ jsxs("span", { className: bem("title"), children: [
|
|
27
|
-
iconName && /* @__PURE__ */ jsx(Icon, { className: bem("icon", iconModifier), ...iconProps }),
|
|
28
|
-
props == null ? void 0 : props.title
|
|
29
|
-
] }), "renderInnerContent");
|
|
30
|
-
const renderVariant = /* @__PURE__ */ __name(() => isOutlined ? /* @__PURE__ */ jsx("div", { className: bem("content", iconModifier, contentClassName), children: renderInnerContent() }) : renderInnerContent(), "renderVariant");
|
|
31
|
-
if (redirect) {
|
|
32
|
-
return /* @__PURE__ */ jsx(
|
|
33
|
-
Link,
|
|
34
|
-
{
|
|
35
|
-
disabled,
|
|
36
|
-
href: redirect.href,
|
|
37
|
-
className: bem(
|
|
38
|
-
void 0,
|
|
39
|
-
{
|
|
40
|
-
"has-fullWidth": Boolean(fullWidth),
|
|
41
|
-
[`has-variant-${variant}`]: true,
|
|
42
|
-
[`has-bg-${color}`]: variant === "contained",
|
|
43
|
-
[`has-text-${color}`]: variant === "text",
|
|
44
|
-
"is-disabled": Boolean(disabled),
|
|
45
|
-
...iconModifier
|
|
46
|
-
},
|
|
47
|
-
className
|
|
48
|
-
),
|
|
49
|
-
children: renderVariant()
|
|
50
|
-
}
|
|
51
|
-
);
|
|
52
|
-
}
|
|
5
|
+
import { ButtonView } from "./Button.view.js";
|
|
6
|
+
function ButtonServer(p) {
|
|
7
|
+
var _a;
|
|
8
|
+
const isIconOnly = ((_a = p.iconProps) == null ? void 0 : _a.name) && !("title" in p && p.title);
|
|
53
9
|
return /* @__PURE__ */ jsx(
|
|
54
|
-
|
|
10
|
+
ButtonView,
|
|
55
11
|
{
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
void 0,
|
|
60
|
-
{
|
|
61
|
-
"has-fullWidth": Boolean(fullWidth),
|
|
62
|
-
[`has-variant-${variant}`]: true,
|
|
63
|
-
[`has-bg-${color}`]: variant === "contained",
|
|
64
|
-
[`has-text-${color}`]: variant === "text",
|
|
65
|
-
"is-disabled": Boolean(disabled),
|
|
66
|
-
...iconModifier
|
|
67
|
-
},
|
|
68
|
-
className
|
|
69
|
-
),
|
|
70
|
-
children: renderVariant()
|
|
12
|
+
...p,
|
|
13
|
+
isIconOnly: Boolean(isIconOnly),
|
|
14
|
+
LinkComponent: Link
|
|
71
15
|
}
|
|
72
16
|
);
|
|
73
17
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
4
|
+
import { create } from "../../helpers/bem.js";
|
|
5
|
+
import styles from "./Button.module.scss.js";
|
|
6
|
+
import { Icon } from "../icon/Icon.js";
|
|
7
|
+
const bem = create(styles, "Button");
|
|
8
|
+
function ButtonView({
|
|
9
|
+
fullWidth,
|
|
10
|
+
color,
|
|
11
|
+
variant,
|
|
12
|
+
className,
|
|
13
|
+
contentClassName,
|
|
14
|
+
disabled,
|
|
15
|
+
redirect,
|
|
16
|
+
iconProps = {},
|
|
17
|
+
isIconOnly,
|
|
18
|
+
LinkComponent,
|
|
19
|
+
...rest
|
|
20
|
+
}) {
|
|
21
|
+
const isOutlined = variant === "outlined";
|
|
22
|
+
const iconName = iconProps == null ? void 0 : iconProps.name;
|
|
23
|
+
const iconMod = { "icon-only": isIconOnly };
|
|
24
|
+
const { title } = rest;
|
|
25
|
+
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
26
|
+
iconName && /* @__PURE__ */ jsx(Icon, { className: bem("icon", iconMod), ...iconProps }),
|
|
27
|
+
title
|
|
28
|
+
] });
|
|
29
|
+
const variantNode = isOutlined ? /* @__PURE__ */ jsx("div", { className: bem("content", iconMod, contentClassName), children: inner }) : inner;
|
|
30
|
+
const common = {
|
|
31
|
+
id: rest.id,
|
|
32
|
+
"aria-label": title ?? void 0,
|
|
33
|
+
className: bem(
|
|
34
|
+
void 0,
|
|
35
|
+
{
|
|
36
|
+
"has-fullWidth": Boolean(fullWidth),
|
|
37
|
+
[`has-variant-${variant}`]: true,
|
|
38
|
+
[`has-bg-${color}`]: variant === "contained",
|
|
39
|
+
[`has-text-${color}`]: variant === "text",
|
|
40
|
+
"is-disabled": Boolean(disabled),
|
|
41
|
+
...iconMod
|
|
42
|
+
},
|
|
43
|
+
className
|
|
44
|
+
)
|
|
45
|
+
};
|
|
46
|
+
return redirect ? /* @__PURE__ */ jsx(LinkComponent, { ...common, disabled, href: redirect.href, children: variantNode }) : /* @__PURE__ */ jsx(
|
|
47
|
+
"button",
|
|
48
|
+
{
|
|
49
|
+
...common,
|
|
50
|
+
disabled: Boolean(disabled),
|
|
51
|
+
tabIndex: redirect !== void 0 || Boolean(disabled) ? -1 : rest.tabIndex,
|
|
52
|
+
type: "button",
|
|
53
|
+
...rest,
|
|
54
|
+
children: variantNode
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
__name(ButtonView, "ButtonView");
|
|
59
|
+
export {
|
|
60
|
+
ButtonView
|
|
61
|
+
};
|