@jirawatpyk/aura-react 4.4.2 → 4.5.1
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 +9 -3
- package/dist/aura.bundle.js +2558 -2059
- package/dist/cjs/index.cjs +2556 -2059
- package/dist/esm/Button.js +9 -9
- package/dist/esm/Checkbox.js +41 -33
- package/dist/esm/Combobox.js +145 -127
- package/dist/esm/DataTable.js +637 -496
- package/dist/esm/DatePicker.js +379 -306
- package/dist/esm/Dialog.js +49 -60
- package/dist/esm/DropdownMenu.js +10 -13
- package/dist/esm/FileUpload.js +91 -73
- package/dist/esm/Icon.js +27 -22
- package/dist/esm/IconButton.js +13 -9
- package/dist/esm/Menu.js +78 -66
- package/dist/esm/Stat.js +9 -26
- package/dist/esm/StatusPill.js +12 -13
- package/dist/esm/Surface.js +17 -13
- package/dist/esm/ThemeStyle.js +9 -5
- package/dist/esm/TimePicker.js +155 -127
- package/dist/esm/extra.js +270 -186
- package/dist/esm/feedback.js +113 -85
- package/dist/esm/forms.js +144 -113
- package/dist/esm/internal.js +33 -23
- package/dist/esm/layout.js +114 -129
- package/dist/esm/layout2.js +69 -45
- package/dist/esm/locale.js +15 -9
- package/dist/esm/overlay.js +22 -19
- package/dist/esm/theme.js +101 -49
- package/dist/index.d.ts +916 -753
- package/package.json +11 -8
- package/scripts/aura-theme.mjs +1 -1
- package/src/theme.js +0 -147
package/dist/esm/Menu.js
CHANGED
|
@@ -3,44 +3,52 @@ import * as React from "react";
|
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
4
|
import { cx, useIsoLayoutEffect, useMounted, useMergedRef } from "./internal.js";
|
|
5
5
|
import { Icon } from "./Icon.js";
|
|
6
|
-
const h = React.createElement;
|
|
7
6
|
const Menu = React.forwardRef(function Menu2(props, ref) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
useIsoLayoutEffect(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
window.
|
|
39
|
-
|
|
40
|
-
|
|
7
|
+
const own = React.useRef(null), merged = useMergedRef(ref, own);
|
|
8
|
+
const posState = React.useState(null);
|
|
9
|
+
const pos = posState[0], setPos = posState[1];
|
|
10
|
+
const items = props.items || [];
|
|
11
|
+
const mounted = useMounted();
|
|
12
|
+
useIsoLayoutEffect(
|
|
13
|
+
function() {
|
|
14
|
+
const a = props.anchor, m = own.current;
|
|
15
|
+
if (!a || !m) return;
|
|
16
|
+
const r = a.getBoundingClientRect(), mh = m.offsetHeight, mw = m.offsetWidth;
|
|
17
|
+
let top = r.bottom + 4;
|
|
18
|
+
if (top + mh > window.innerHeight - 8 && r.top - mh - 4 > 8) top = r.top - mh - 4;
|
|
19
|
+
const left = Math.max(8, Math.min(r.right - mw, window.innerWidth - mw - 8));
|
|
20
|
+
setPos({ top, left });
|
|
21
|
+
},
|
|
22
|
+
[props.anchor, mounted]
|
|
23
|
+
);
|
|
24
|
+
React.useEffect(
|
|
25
|
+
function() {
|
|
26
|
+
if (!mounted) return;
|
|
27
|
+
const first = own.current && own.current.querySelector('[role^="menuitem"]:not([disabled])');
|
|
28
|
+
if (first && props.autoFocus !== false) first.focus();
|
|
29
|
+
function outside(e) {
|
|
30
|
+
if (own.current && !own.current.contains(e.target) && !(props.anchor && props.anchor.contains(e.target)))
|
|
31
|
+
props.onClose(false);
|
|
32
|
+
}
|
|
33
|
+
function onScroll(e) {
|
|
34
|
+
if (own.current && !own.current.contains(e.target)) props.onClose(false);
|
|
35
|
+
}
|
|
36
|
+
document.addEventListener("pointerdown", outside, true);
|
|
37
|
+
window.addEventListener("scroll", onScroll, true);
|
|
38
|
+
window.addEventListener("resize", onScroll);
|
|
39
|
+
return function() {
|
|
40
|
+
document.removeEventListener("pointerdown", outside, true);
|
|
41
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
42
|
+
window.removeEventListener("resize", onScroll);
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
[mounted]
|
|
46
|
+
);
|
|
41
47
|
function onKeyDown(e) {
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
const list = Array.prototype.slice.call(
|
|
49
|
+
own.current.querySelectorAll('[role^="menuitem"]:not([disabled])')
|
|
50
|
+
);
|
|
51
|
+
const i = list.indexOf(document.activeElement);
|
|
44
52
|
if (e.key === "ArrowDown") {
|
|
45
53
|
e.preventDefault();
|
|
46
54
|
list[(i + 1) % list.length].focus();
|
|
@@ -61,36 +69,40 @@ const Menu = React.forwardRef(function Menu2(props, ref) {
|
|
|
61
69
|
}
|
|
62
70
|
e.stopPropagation();
|
|
63
71
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
it.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
72
|
+
const el = /* @__PURE__ */ React.createElement(
|
|
73
|
+
"div",
|
|
74
|
+
{
|
|
75
|
+
ref: merged,
|
|
76
|
+
role: "menu",
|
|
77
|
+
"aria-label": props.label,
|
|
78
|
+
className: "aura-menu",
|
|
79
|
+
onKeyDown,
|
|
80
|
+
style: { top: pos ? pos.top : -9999, left: pos ? pos.left : -9999 }
|
|
81
|
+
},
|
|
82
|
+
items.map(function(it, i) {
|
|
83
|
+
if (it.separator) return /* @__PURE__ */ React.createElement("div", { key: "s" + i, role: "separator", className: "aura-menu__sep" });
|
|
84
|
+
const isCheck = it.checked !== void 0;
|
|
85
|
+
return /* @__PURE__ */ React.createElement(
|
|
86
|
+
"button",
|
|
87
|
+
{
|
|
88
|
+
key: i,
|
|
89
|
+
type: "button",
|
|
90
|
+
tabIndex: -1,
|
|
91
|
+
disabled: it.disabled,
|
|
92
|
+
role: isCheck ? "menuitemcheckbox" : "menuitem",
|
|
93
|
+
"aria-checked": isCheck ? !!it.checked : void 0,
|
|
94
|
+
className: "aura-menu__item",
|
|
95
|
+
onClick: function() {
|
|
96
|
+
it.onSelect();
|
|
97
|
+
if (!it.keepOpen) props.onClose(true);
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
isCheck ? /* @__PURE__ */ React.createElement("span", { className: cx("aura-menu__check", it.checked && "is-on") }, it.checked ? /* @__PURE__ */ React.createElement(Icon, { name: "check", size: 12, strokeWidth: 3 }) : null) : it.icon ? /* @__PURE__ */ React.createElement(Icon, { name: it.icon }) : /* @__PURE__ */ React.createElement("span", { className: "aura-menu__blank" }),
|
|
101
|
+
/* @__PURE__ */ React.createElement("span", { className: "aura-menu__label" }, it.label),
|
|
102
|
+
it.hint ? /* @__PURE__ */ React.createElement("span", { className: "aura-menu__hint" }, it.hint) : null
|
|
103
|
+
);
|
|
104
|
+
})
|
|
105
|
+
);
|
|
94
106
|
return mounted ? createPortal(el, document.body) : null;
|
|
95
107
|
});
|
|
96
108
|
export {
|
package/dist/esm/Stat.js
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { cx } from "./internal.js";
|
|
4
4
|
import { Icon } from "./Icon.js";
|
|
5
|
-
const h = React.createElement;
|
|
6
5
|
const Stat = React.forwardRef(function Stat2(props, ref) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return
|
|
6
|
+
const ch = props.change;
|
|
7
|
+
const dir = ch && (ch.direction || "flat");
|
|
8
|
+
const tone = ch && (ch.tone || (dir === "up" ? "positive" : dir === "down" ? "negative" : "neutral"));
|
|
9
|
+
const Tag = props.href ? "a" : props.onClick ? "button" : "div";
|
|
10
|
+
const interactive = Tag !== "div";
|
|
11
|
+
return /* @__PURE__ */ React.createElement(
|
|
13
12
|
Tag,
|
|
14
13
|
{
|
|
15
14
|
ref,
|
|
@@ -19,25 +18,9 @@ const Stat = React.forwardRef(function Stat2(props, ref) {
|
|
|
19
18
|
type: Tag === "button" ? "button" : void 0,
|
|
20
19
|
"aria-busy": props.loading || void 0
|
|
21
20
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
h("span", { className: "aura-stat__label" }, props.label),
|
|
26
|
-
props.icon ? h("span", { className: "aura-stat__icon" }, h(Icon, { name: props.icon })) : null
|
|
27
|
-
),
|
|
28
|
-
props.loading ? h("span", { className: "aura-stat__value" }, h("span", { className: "aura-skel aura-stat__skel" })) : h("span", { className: "aura-stat__value" }, props.value, props.unit ? h("span", { className: "aura-stat__unit" }, props.unit) : null),
|
|
29
|
-
ch && !props.loading || props.caption ? h(
|
|
30
|
-
"span",
|
|
31
|
-
{ className: "aura-stat__foot" },
|
|
32
|
-
ch && !props.loading ? h(
|
|
33
|
-
"span",
|
|
34
|
-
{ className: cx("aura-stat__change", "is-" + tone) },
|
|
35
|
-
h(Icon, { name: dir === "up" ? "trending-up" : dir === "down" ? "trending-down" : "minus", size: 14 }),
|
|
36
|
-
h("span", null, ch.value)
|
|
37
|
-
) : null,
|
|
38
|
-
ch && ch.label && !props.loading ? h("span", { className: "aura-stat__caption" }, ch.label) : null,
|
|
39
|
-
props.caption ? h("span", { className: "aura-stat__caption" }, props.caption) : null
|
|
40
|
-
) : null
|
|
21
|
+
/* @__PURE__ */ React.createElement("span", { className: "aura-stat__head" }, /* @__PURE__ */ React.createElement("span", { className: "aura-stat__label" }, props.label), props.icon ? /* @__PURE__ */ React.createElement("span", { className: "aura-stat__icon" }, /* @__PURE__ */ React.createElement(Icon, { name: props.icon })) : null),
|
|
22
|
+
props.loading ? /* @__PURE__ */ React.createElement("span", { className: "aura-stat__value" }, /* @__PURE__ */ React.createElement("span", { className: "aura-skel aura-stat__skel" })) : /* @__PURE__ */ React.createElement("span", { className: "aura-stat__value" }, props.value, props.unit ? /* @__PURE__ */ React.createElement("span", { className: "aura-stat__unit" }, props.unit) : null),
|
|
23
|
+
ch && !props.loading || props.caption ? /* @__PURE__ */ React.createElement("span", { className: "aura-stat__foot" }, ch && !props.loading ? /* @__PURE__ */ React.createElement("span", { className: cx("aura-stat__change", "is-" + tone) }, /* @__PURE__ */ React.createElement(Icon, { name: dir === "up" ? "trending-up" : dir === "down" ? "trending-down" : "minus", size: 14 }), /* @__PURE__ */ React.createElement("span", null, ch.value)) : null, ch && ch.label && !props.loading ? /* @__PURE__ */ React.createElement("span", { className: "aura-stat__caption" }, ch.label) : null, props.caption ? /* @__PURE__ */ React.createElement("span", { className: "aura-stat__caption" }, props.caption) : null) : null
|
|
41
24
|
);
|
|
42
25
|
});
|
|
43
26
|
export {
|
package/dist/esm/StatusPill.js
CHANGED
|
@@ -2,27 +2,26 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { cx } from "./internal.js";
|
|
4
4
|
import { Icon } from "./Icon.js";
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const TONE_ICON = {
|
|
6
|
+
neutral: "circle",
|
|
7
|
+
progress: "circle-dot-dashed",
|
|
8
|
+
ready: "circle-check",
|
|
9
|
+
blocked: "ban"
|
|
10
|
+
};
|
|
11
|
+
const TONE_WORDS = {
|
|
8
12
|
ready: ["ready", "done", "complete", "completed", "approved", "live", "passed"],
|
|
9
13
|
progress: ["in progress", "in review", "review", "syncing", "running", "pending"],
|
|
10
14
|
blocked: ["blocked", "failed", "error", "rejected", "on hold", "cancelled"]
|
|
11
15
|
};
|
|
12
16
|
function toneFor(status) {
|
|
13
|
-
|
|
14
|
-
for (
|
|
17
|
+
const s = String(status == null ? "" : status).trim().toLowerCase();
|
|
18
|
+
for (const t in TONE_WORDS) if (TONE_WORDS[t].indexOf(s) >= 0) return t;
|
|
15
19
|
return "neutral";
|
|
16
20
|
}
|
|
17
|
-
|
|
21
|
+
const TONE_ORDER = { neutral: 0, progress: 1, ready: 2, blocked: 3 };
|
|
18
22
|
const StatusPill = React.forwardRef(function StatusPill2(props, ref) {
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
"span",
|
|
22
|
-
{ ref, className: cx("aura-pill", "aura-pill--" + tone, props.className) },
|
|
23
|
-
h(Icon, { name: TONE_ICON[tone] || "circle", size: 12 }),
|
|
24
|
-
props.children
|
|
25
|
-
);
|
|
23
|
+
const tone = props.tone || toneFor(props.children);
|
|
24
|
+
return /* @__PURE__ */ React.createElement("span", { ref, className: cx("aura-pill", "aura-pill--" + tone, props.className) }, /* @__PURE__ */ React.createElement(Icon, { name: TONE_ICON[tone] || "circle", size: 12 }), props.children);
|
|
26
25
|
});
|
|
27
26
|
export {
|
|
28
27
|
StatusPill,
|
package/dist/esm/Surface.js
CHANGED
|
@@ -3,19 +3,23 @@ import * as React from "react";
|
|
|
3
3
|
import { cx, omit } from "./internal.js";
|
|
4
4
|
const h = React.createElement;
|
|
5
5
|
const Surface = React.forwardRef(function Surface2(props, ref) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return h(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
const t = props.texture || "mesh";
|
|
7
|
+
const rest = omit(props, ["texture", "className", "children", "as"]);
|
|
8
|
+
return h(
|
|
9
|
+
props.as || "div",
|
|
10
|
+
Object.assign({}, rest, {
|
|
11
|
+
ref,
|
|
12
|
+
/* Textures stay light in every theme, so everything on them uses the light tokens. */
|
|
13
|
+
"data-theme": "light",
|
|
14
|
+
className: cx(
|
|
15
|
+
"aura-surface",
|
|
16
|
+
(t === "mesh" || t === "mesh-grain") && "aura-mesh",
|
|
17
|
+
(t === "grain" || t === "mesh-grain") && "aura-grain",
|
|
18
|
+
props.className
|
|
19
|
+
)
|
|
20
|
+
}),
|
|
21
|
+
props.children
|
|
22
|
+
);
|
|
19
23
|
});
|
|
20
24
|
export {
|
|
21
25
|
Surface
|
package/dist/esm/ThemeStyle.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { createTheme } from "./theme.js";
|
|
4
|
-
const h = React.createElement;
|
|
5
4
|
function ThemeStyle(props) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const css = React.useMemo(
|
|
6
|
+
function() {
|
|
7
|
+
return createTheme({ brand: props.brand, signal: props.signal, primary: props.primary, name: props.name }).css(
|
|
8
|
+
props.selector
|
|
9
|
+
);
|
|
10
|
+
},
|
|
11
|
+
[props.brand, props.signal, props.primary, props.name, props.selector]
|
|
12
|
+
);
|
|
13
|
+
return /* @__PURE__ */ React.createElement("style", { "data-aura-theme": props.name || props.brand, dangerouslySetInnerHTML: { __html: css } });
|
|
10
14
|
}
|
|
11
15
|
export {
|
|
12
16
|
ThemeStyle
|