@jirawatpyk/aura-react 4.7.2 → 4.9.0
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 +3 -3
- package/dist/aura.bundle.js +1075 -595
- package/dist/cjs/index.cjs +1074 -594
- package/dist/esm/Accordion.js +66 -0
- package/dist/esm/Alert.js +31 -0
- package/dist/esm/AppShell.js +55 -0
- package/dist/esm/Avatar.js +39 -0
- package/dist/esm/Badge.js +26 -0
- package/dist/esm/Breadcrumb.js +16 -0
- package/dist/esm/Card.js +26 -0
- package/dist/esm/Combobox.js +311 -236
- package/dist/esm/Container.js +18 -0
- package/dist/esm/DatePicker.js +1 -1
- package/dist/esm/Dialog.js +1 -1
- package/dist/esm/EmptyState.js +22 -0
- package/dist/esm/Field.js +46 -0
- package/dist/esm/FileUpload.js +1 -1
- package/dist/esm/Grid.js +21 -0
- package/dist/esm/NumberField.js +175 -0
- package/dist/esm/Pagination.js +94 -0
- package/dist/esm/Popover.js +131 -0
- package/dist/esm/Progress.js +40 -0
- package/dist/esm/RadioGroup.js +46 -0
- package/dist/esm/SegmentedControl.js +104 -0
- package/dist/esm/Select.js +48 -0
- package/dist/esm/SideNav.js +36 -0
- package/dist/esm/Skeleton.js +29 -0
- package/dist/esm/Stack.js +20 -0
- package/dist/esm/Stepper.js +54 -0
- package/dist/esm/Switch.js +30 -0
- package/dist/esm/Tabs.js +89 -0
- package/dist/esm/Tag.js +42 -0
- package/dist/esm/TextField.js +39 -0
- package/dist/esm/Textarea.js +38 -0
- package/dist/esm/TimePicker.js +1 -1
- package/dist/esm/Toaster.js +124 -0
- package/dist/esm/Tooltip.js +80 -0
- package/dist/esm/index.js +33 -5
- package/dist/esm/internal.js +5 -0
- package/dist/esm/locale.js +12 -0
- package/dist/esm/responsive.js +50 -0
- package/dist/index.d.ts +109 -10
- package/dist/styles.css +107 -0
- package/package.json +1 -1
- package/dist/esm/extra.js +0 -412
- package/dist/esm/feedback.js +0 -220
- package/dist/esm/forms.js +0 -212
- package/dist/esm/layout.js +0 -183
- package/dist/esm/layout2.js +0 -138
- /package/dist/esm/{overlay.js → useModal.js} +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Icon } from "./Icon.js";
|
|
4
|
+
import { cx, uid, useMaybeControlled } from "./internal.js";
|
|
5
|
+
const h = React.createElement;
|
|
6
|
+
const Accordion = React.forwardRef(function Accordion2(props, ref) {
|
|
7
|
+
const auto = uid(), base = props.id || auto;
|
|
8
|
+
const multiple = props.type === "multiple";
|
|
9
|
+
const st = useMaybeControlled(
|
|
10
|
+
props.value,
|
|
11
|
+
props.defaultValue != null ? props.defaultValue : multiple ? [] : null,
|
|
12
|
+
props.onChange
|
|
13
|
+
);
|
|
14
|
+
const open = multiple ? st[0] || [] : st[0] ? [st[0]] : [];
|
|
15
|
+
const HT = "h" + (props.headingLevel || 3);
|
|
16
|
+
const items = props.items || [];
|
|
17
|
+
function toggle(id) {
|
|
18
|
+
const isOpen = open.indexOf(id) >= 0;
|
|
19
|
+
if (multiple)
|
|
20
|
+
st[1](
|
|
21
|
+
isOpen ? open.filter(function(x) {
|
|
22
|
+
return x !== id;
|
|
23
|
+
}) : open.concat([id])
|
|
24
|
+
);
|
|
25
|
+
else st[1](isOpen ? props.collapsible === false ? id : null : id);
|
|
26
|
+
}
|
|
27
|
+
function onKey(e) {
|
|
28
|
+
const btns = Array.prototype.slice.call(
|
|
29
|
+
e.currentTarget.querySelectorAll(
|
|
30
|
+
":scope > .aura-accordion__item > .aura-accordion__heading > button:not([disabled])"
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
let i = btns.indexOf(document.activeElement), k = e.key, n = null;
|
|
34
|
+
if (i < 0) return;
|
|
35
|
+
if (k === "ArrowDown") n = btns[(i + 1) % btns.length];
|
|
36
|
+
else if (k === "ArrowUp") n = btns[(i - 1 + btns.length) % btns.length];
|
|
37
|
+
else if (k === "Home") n = btns[0];
|
|
38
|
+
else if (k === "End") n = btns[btns.length - 1];
|
|
39
|
+
if (n) {
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
n.focus();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return /* @__PURE__ */ React.createElement("div", { ref, className: cx("aura-accordion", props.className), onKeyDown: onKey }, items.map(function(it) {
|
|
45
|
+
const on = open.indexOf(it.id) >= 0, bid = base + "-btn-" + it.id, pid = base + "-panel-" + it.id;
|
|
46
|
+
return /* @__PURE__ */ React.createElement("div", { key: it.id, className: cx("aura-accordion__item", on && "is-open") }, /* @__PURE__ */ React.createElement(HT, { className: "aura-accordion__heading" }, /* @__PURE__ */ React.createElement(
|
|
47
|
+
"button",
|
|
48
|
+
{
|
|
49
|
+
type: "button",
|
|
50
|
+
id: bid,
|
|
51
|
+
"aria-expanded": on,
|
|
52
|
+
"aria-controls": pid,
|
|
53
|
+
disabled: it.disabled,
|
|
54
|
+
onClick: function() {
|
|
55
|
+
toggle(it.id);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
it.icon ? /* @__PURE__ */ React.createElement(Icon, { name: it.icon, className: "aura-accordion__lead" }) : null,
|
|
59
|
+
/* @__PURE__ */ React.createElement("span", { className: "aura-accordion__title" }, it.title, it.description ? /* @__PURE__ */ React.createElement("span", { className: "aura-accordion__desc" }, it.description) : null),
|
|
60
|
+
/* @__PURE__ */ React.createElement(Icon, { name: "chevron-down", className: "aura-accordion__chevron" })
|
|
61
|
+
)), /* @__PURE__ */ React.createElement("div", { id: pid, role: "region", "aria-labelledby": bid, className: "aura-accordion__panel", hidden: !on }, it.content));
|
|
62
|
+
}));
|
|
63
|
+
});
|
|
64
|
+
export {
|
|
65
|
+
Accordion
|
|
66
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Icon } from "./Icon.js";
|
|
4
|
+
import { IconButton } from "./IconButton.js";
|
|
5
|
+
import { cx } from "./internal.js";
|
|
6
|
+
import { useStrings } from "./locale.js";
|
|
7
|
+
const ALERT_ICON = {
|
|
8
|
+
info: "info",
|
|
9
|
+
success: "circle-check",
|
|
10
|
+
warning: "triangle-alert",
|
|
11
|
+
danger: "circle-alert"
|
|
12
|
+
};
|
|
13
|
+
const Alert = React.forwardRef(function Alert2(props, ref) {
|
|
14
|
+
const t = useStrings();
|
|
15
|
+
const tone = props.tone || "info";
|
|
16
|
+
return /* @__PURE__ */ React.createElement(
|
|
17
|
+
"div",
|
|
18
|
+
{
|
|
19
|
+
ref,
|
|
20
|
+
className: cx("aura-alert", "aura-alert--" + tone, props.className),
|
|
21
|
+
role: tone === "danger" || tone === "warning" ? "alert" : "status"
|
|
22
|
+
},
|
|
23
|
+
/* @__PURE__ */ React.createElement(Icon, { name: ALERT_ICON[tone], className: "aura-alert__icon" }),
|
|
24
|
+
/* @__PURE__ */ React.createElement("div", { className: "aura-alert__body" }, props.title ? /* @__PURE__ */ React.createElement("p", { className: "aura-alert__title" }, props.title) : null, props.children ? /* @__PURE__ */ React.createElement("div", { className: "aura-alert__text" }, props.children) : null, props.action ? /* @__PURE__ */ React.createElement("div", { className: "aura-alert__action" }, props.action) : null),
|
|
25
|
+
props.onDismiss ? /* @__PURE__ */ React.createElement(IconButton, { icon: "x", label: t.dismiss, className: "aura-alert__close", onClick: props.onDismiss }) : null
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
export {
|
|
29
|
+
ALERT_ICON,
|
|
30
|
+
Alert
|
|
31
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Drawer } from "./Dialog.js";
|
|
4
|
+
import { IconButton } from "./IconButton.js";
|
|
5
|
+
import { cx } from "./internal.js";
|
|
6
|
+
import { useStrings } from "./locale.js";
|
|
7
|
+
import { useBreakpoint } from "./responsive.js";
|
|
8
|
+
const AppShell = React.forwardRef(function AppShell2(props, ref) {
|
|
9
|
+
const t = useStrings();
|
|
10
|
+
const bp = useBreakpoint();
|
|
11
|
+
const compact = bp === "base" || bp === "sm" || bp === "md";
|
|
12
|
+
const st = React.useState(false), open = st[0], setOpen = st[1];
|
|
13
|
+
React.useEffect(
|
|
14
|
+
function() {
|
|
15
|
+
if (!compact) setOpen(false);
|
|
16
|
+
},
|
|
17
|
+
[compact]
|
|
18
|
+
);
|
|
19
|
+
const navEl = props.nav;
|
|
20
|
+
const nav = props.nav && React.isValidElement(props.nav) && compact ? React.cloneElement(navEl, {
|
|
21
|
+
onChange: function(id) {
|
|
22
|
+
if (navEl.props.onChange) navEl.props.onChange(id);
|
|
23
|
+
setOpen(false);
|
|
24
|
+
},
|
|
25
|
+
className: cx(navEl.props.className, "is-in-drawer")
|
|
26
|
+
}) : props.nav;
|
|
27
|
+
return /* @__PURE__ */ React.createElement("div", { ref, className: cx("aura-shell", compact && "is-compact", props.className) }, !compact ? /* @__PURE__ */ React.createElement("div", { className: "aura-shell__nav" }, nav) : null, compact ? /* @__PURE__ */ React.createElement(
|
|
28
|
+
Drawer,
|
|
29
|
+
{
|
|
30
|
+
open,
|
|
31
|
+
onClose: function() {
|
|
32
|
+
setOpen(false);
|
|
33
|
+
},
|
|
34
|
+
side: "left",
|
|
35
|
+
size: "nav",
|
|
36
|
+
"aria-label": props.navLabel || t.navigation,
|
|
37
|
+
dismissible: true
|
|
38
|
+
},
|
|
39
|
+
nav
|
|
40
|
+
) : null, /* @__PURE__ */ React.createElement("div", { className: "aura-shell__main" }, props.header || compact ? /* @__PURE__ */ React.createElement("header", { className: "aura-shell__bar" }, compact ? /* @__PURE__ */ React.createElement(
|
|
41
|
+
IconButton,
|
|
42
|
+
{
|
|
43
|
+
icon: "menu",
|
|
44
|
+
label: props.menuLabel || t.openNav,
|
|
45
|
+
size: "md",
|
|
46
|
+
onClick: function() {
|
|
47
|
+
setOpen(true);
|
|
48
|
+
},
|
|
49
|
+
"aria-expanded": open
|
|
50
|
+
}
|
|
51
|
+
) : null, /* @__PURE__ */ React.createElement("div", { className: "aura-shell__bar-content" }, props.header)) : null, /* @__PURE__ */ React.createElement("main", { className: "aura-shell__content", id: props.mainId || "main" }, props.children)));
|
|
52
|
+
});
|
|
53
|
+
export {
|
|
54
|
+
AppShell
|
|
55
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cx } from "./internal.js";
|
|
4
|
+
const AVATAR_TONES = ["progress", "ready", "neutral", "warning"];
|
|
5
|
+
function initials(name) {
|
|
6
|
+
const parts = String(name || "?").trim().split(/\s+/);
|
|
7
|
+
return ((parts[0] || "?")[0] + (parts.length > 1 ? parts[parts.length - 1][0] : parts[0][1] || "")).toUpperCase();
|
|
8
|
+
}
|
|
9
|
+
const Avatar = React.forwardRef(function Avatar2(props, ref) {
|
|
10
|
+
const size = props.size || "md", errState = React.useState(false);
|
|
11
|
+
let hash = 0;
|
|
12
|
+
String(props.name || "").split("").forEach(function(ch) {
|
|
13
|
+
hash = hash * 31 + ch.charCodeAt(0) >>> 0;
|
|
14
|
+
});
|
|
15
|
+
const tone = AVATAR_TONES[hash % AVATAR_TONES.length];
|
|
16
|
+
return /* @__PURE__ */ React.createElement(
|
|
17
|
+
"span",
|
|
18
|
+
{
|
|
19
|
+
ref,
|
|
20
|
+
className: cx("aura-avatar", "aura-avatar--" + size, "aura-avatar--" + tone, props.className),
|
|
21
|
+
role: "img",
|
|
22
|
+
"aria-label": props.name + (props.status ? ", " + props.status : "")
|
|
23
|
+
},
|
|
24
|
+
props.src && !errState[0] ? /* @__PURE__ */ React.createElement(
|
|
25
|
+
"img",
|
|
26
|
+
{
|
|
27
|
+
src: props.src,
|
|
28
|
+
alt: "",
|
|
29
|
+
onError: function() {
|
|
30
|
+
errState[1](true);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
) : /* @__PURE__ */ React.createElement("span", { "aria-hidden": true }, initials(props.name)),
|
|
34
|
+
props.status === "online" ? /* @__PURE__ */ React.createElement("span", { className: "aura-avatar__status", "aria-hidden": true }) : null
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
export {
|
|
38
|
+
Avatar
|
|
39
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Icon } from "./Icon.js";
|
|
4
|
+
import { cx, omit, tone } from "./internal.js";
|
|
5
|
+
const Badge = React.forwardRef(function Badge2(props, ref) {
|
|
6
|
+
const rest = omit(props, ["tone", "variant", "icon", "className", "children"]);
|
|
7
|
+
return /* @__PURE__ */ React.createElement(
|
|
8
|
+
"span",
|
|
9
|
+
{
|
|
10
|
+
...rest,
|
|
11
|
+
ref,
|
|
12
|
+
className: cx(
|
|
13
|
+
"aura-badge",
|
|
14
|
+
"aura-badge--" + tone(props.tone),
|
|
15
|
+
props.variant === "solid" && "is-solid",
|
|
16
|
+
props.variant === "outline" && "is-outline",
|
|
17
|
+
props.className
|
|
18
|
+
)
|
|
19
|
+
},
|
|
20
|
+
props.icon ? /* @__PURE__ */ React.createElement(Icon, { name: props.icon, size: 12 }) : null,
|
|
21
|
+
props.children
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
export {
|
|
25
|
+
Badge
|
|
26
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Icon } from "./Icon.js";
|
|
4
|
+
import { cx } from "./internal.js";
|
|
5
|
+
import { useStrings } from "./locale.js";
|
|
6
|
+
const Breadcrumb = React.forwardRef(function Breadcrumb2(props, ref) {
|
|
7
|
+
const t = useStrings();
|
|
8
|
+
const items = props.items || [];
|
|
9
|
+
return /* @__PURE__ */ React.createElement("nav", { ref, "aria-label": props.label || t.breadcrumb, className: cx("aura-crumbs", props.className) }, /* @__PURE__ */ React.createElement("ol", null, items.map(function(it, i) {
|
|
10
|
+
const last = i === items.length - 1;
|
|
11
|
+
return /* @__PURE__ */ React.createElement("li", { key: i }, last ? /* @__PURE__ */ React.createElement("span", { "aria-current": "page", className: "aura-crumbs__current" }, it.label) : it.href ? /* @__PURE__ */ React.createElement("a", { href: it.href, onClick: it.onClick }, it.label) : /* @__PURE__ */ React.createElement("button", { type: "button", onClick: it.onClick }, it.label), last ? null : /* @__PURE__ */ React.createElement(Icon, { name: "chevron-right", size: 12, className: "aura-crumbs__sep" }));
|
|
12
|
+
})));
|
|
13
|
+
});
|
|
14
|
+
export {
|
|
15
|
+
Breadcrumb
|
|
16
|
+
};
|
package/dist/esm/Card.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cx } from "./internal.js";
|
|
4
|
+
const h = React.createElement;
|
|
5
|
+
const Card = React.forwardRef(function Card2(props, ref) {
|
|
6
|
+
const creative = props.variant === "creative";
|
|
7
|
+
return h(
|
|
8
|
+
props.as || "section",
|
|
9
|
+
{
|
|
10
|
+
ref,
|
|
11
|
+
className: cx(
|
|
12
|
+
"aura-card",
|
|
13
|
+
creative && "aura-card--creative",
|
|
14
|
+
props.interactive && "is-interactive",
|
|
15
|
+
props.className
|
|
16
|
+
),
|
|
17
|
+
"aria-labelledby": props.title && props.titleId ? props.titleId : void 0
|
|
18
|
+
},
|
|
19
|
+
props.title || props.actions ? /* @__PURE__ */ React.createElement("div", { className: "aura-card__head" }, /* @__PURE__ */ React.createElement("div", { className: "aura-card__heading" }, props.title ? h("h" + (props.headingLevel || 3), { className: "aura-card__title", id: props.titleId }, props.title) : null, props.description ? /* @__PURE__ */ React.createElement("p", { className: "aura-card__desc" }, props.description) : null), props.actions ? /* @__PURE__ */ React.createElement("div", { className: "aura-card__actions" }, props.actions) : null) : null,
|
|
20
|
+
props.children ? /* @__PURE__ */ React.createElement("div", { className: "aura-card__body" }, props.children) : null,
|
|
21
|
+
props.footer ? /* @__PURE__ */ React.createElement("div", { className: "aura-card__foot" }, props.footer) : null
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
export {
|
|
25
|
+
Card
|
|
26
|
+
};
|