@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/internal.js
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
const h = React.createElement;
|
|
4
3
|
function cx() {
|
|
5
4
|
return Array.prototype.filter.call(arguments, Boolean).join(" ");
|
|
6
5
|
}
|
|
7
6
|
function omit(src, keys) {
|
|
8
|
-
|
|
9
|
-
for (
|
|
7
|
+
const out = {};
|
|
8
|
+
for (const k in src)
|
|
9
|
+
if (Object.prototype.hasOwnProperty.call(src, k) && keys.indexOf(k) < 0)
|
|
10
|
+
out[k] = src[k];
|
|
10
11
|
return out;
|
|
11
12
|
}
|
|
12
13
|
function useMaybeControlled(value, initial, onChange) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const s = React.useState(initial);
|
|
15
|
+
const controlled = value !== void 0;
|
|
16
|
+
return [
|
|
17
|
+
controlled ? value : s[0],
|
|
18
|
+
function(next) {
|
|
19
|
+
if (!controlled) s[1](next);
|
|
20
|
+
if (onChange) onChange(next);
|
|
21
|
+
}
|
|
22
|
+
];
|
|
19
23
|
}
|
|
20
|
-
|
|
24
|
+
const collator = typeof Intl !== "undefined" ? new Intl.Collator(["th", "en"], { numeric: true, sensitivity: "base" }) : null;
|
|
21
25
|
function compare(a, b) {
|
|
22
26
|
if (a == null && b == null) return 0;
|
|
23
27
|
if (a == null) return 1;
|
|
@@ -30,7 +34,7 @@ const uid = React.useId || function() {
|
|
|
30
34
|
if (!r.current) r.current = "aura-" + Math.random().toString(36).slice(2, 9);
|
|
31
35
|
return r.current;
|
|
32
36
|
};
|
|
33
|
-
|
|
37
|
+
const FOCUSABLE = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';
|
|
34
38
|
function noopSubscribe() {
|
|
35
39
|
return function() {
|
|
36
40
|
};
|
|
@@ -44,14 +48,17 @@ function no() {
|
|
|
44
48
|
function useMounted() {
|
|
45
49
|
return React.useSyncExternalStore(noopSubscribe, yes, no);
|
|
46
50
|
}
|
|
47
|
-
|
|
51
|
+
const useIsoLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
48
52
|
function trapTab(e, container) {
|
|
49
53
|
if (e.key !== "Tab" || !container) return;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
const list = Array.prototype.filter.call(
|
|
55
|
+
container.querySelectorAll(FOCUSABLE),
|
|
56
|
+
function(el) {
|
|
57
|
+
return el.tabIndex >= 0 && el.offsetParent !== null;
|
|
58
|
+
}
|
|
59
|
+
);
|
|
53
60
|
if (!list.length) return;
|
|
54
|
-
|
|
61
|
+
const first = list[0], last = list[list.length - 1];
|
|
55
62
|
if (e.shiftKey && document.activeElement === first) {
|
|
56
63
|
e.preventDefault();
|
|
57
64
|
last.focus();
|
|
@@ -61,13 +68,16 @@ function trapTab(e, container) {
|
|
|
61
68
|
}
|
|
62
69
|
}
|
|
63
70
|
function useMergedRef(a, b) {
|
|
64
|
-
return React.useCallback(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
return React.useCallback(
|
|
72
|
+
function(node) {
|
|
73
|
+
[a, b].forEach(function(r) {
|
|
74
|
+
if (!r) return;
|
|
75
|
+
if (typeof r === "function") r(node);
|
|
76
|
+
else r.current = node;
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
[a, b]
|
|
80
|
+
);
|
|
71
81
|
}
|
|
72
82
|
export {
|
|
73
83
|
FOCUSABLE,
|
package/dist/esm/layout.js
CHANGED
|
@@ -1,123 +1,125 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { useStrings
|
|
3
|
+
import { useStrings } from "./locale.js";
|
|
4
4
|
import { cx, useMaybeControlled, uid } from "./internal.js";
|
|
5
5
|
import { Icon } from "./Icon.js";
|
|
6
6
|
const h = React.createElement;
|
|
7
7
|
const Card = React.forwardRef(function Card2(props, ref) {
|
|
8
|
-
|
|
8
|
+
const creative = props.variant === "creative";
|
|
9
9
|
return h(
|
|
10
10
|
props.as || "section",
|
|
11
11
|
{
|
|
12
12
|
ref,
|
|
13
|
-
className: cx(
|
|
13
|
+
className: cx(
|
|
14
|
+
"aura-card",
|
|
15
|
+
creative && "aura-card--creative",
|
|
16
|
+
props.interactive && "is-interactive",
|
|
17
|
+
props.className
|
|
18
|
+
),
|
|
14
19
|
"aria-labelledby": props.title && props.titleId ? props.titleId : void 0
|
|
15
20
|
},
|
|
16
|
-
props.title || props.actions ? h(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
h(
|
|
20
|
-
"div",
|
|
21
|
-
{ className: "aura-card__heading" },
|
|
22
|
-
props.title ? h("h" + (props.headingLevel || 3), { className: "aura-card__title", id: props.titleId }, props.title) : null,
|
|
23
|
-
props.description ? h("p", { className: "aura-card__desc" }, props.description) : null
|
|
24
|
-
),
|
|
25
|
-
props.actions ? h("div", { className: "aura-card__actions" }, props.actions) : null
|
|
26
|
-
) : null,
|
|
27
|
-
props.children ? h("div", { className: "aura-card__body" }, props.children) : null,
|
|
28
|
-
props.footer ? h("div", { className: "aura-card__foot" }, props.footer) : null
|
|
21
|
+
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,
|
|
22
|
+
props.children ? /* @__PURE__ */ React.createElement("div", { className: "aura-card__body" }, props.children) : null,
|
|
23
|
+
props.footer ? /* @__PURE__ */ React.createElement("div", { className: "aura-card__foot" }, props.footer) : null
|
|
29
24
|
);
|
|
30
25
|
});
|
|
31
26
|
const Tabs = React.forwardRef(function Tabs2(props, ref) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
const items = props.tabs || [], base = uid();
|
|
28
|
+
const st = useMaybeControlled(
|
|
29
|
+
props.value,
|
|
30
|
+
props.defaultValue || items[0] && items[0].id,
|
|
31
|
+
props.onChange
|
|
32
|
+
);
|
|
33
|
+
const refs = React.useRef({});
|
|
34
|
+
const current = items.filter(function(t) {
|
|
36
35
|
return t.id === st[0];
|
|
37
36
|
})[0] || items[0];
|
|
38
37
|
function go(i) {
|
|
39
|
-
|
|
38
|
+
const enabled = items.filter(function(t2) {
|
|
40
39
|
return !t2.disabled;
|
|
41
40
|
});
|
|
42
|
-
|
|
41
|
+
const t = enabled[(i + enabled.length) % enabled.length];
|
|
43
42
|
st[1](t.id);
|
|
44
43
|
if (refs.current[t.id]) refs.current[t.id].focus();
|
|
45
44
|
}
|
|
46
|
-
return
|
|
45
|
+
return /* @__PURE__ */ React.createElement("div", { ref, className: cx("aura-tabs", props.className) }, /* @__PURE__ */ React.createElement(
|
|
47
46
|
"div",
|
|
48
|
-
{
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
} else if (e.key === "End") {
|
|
69
|
-
e.preventDefault();
|
|
70
|
-
go(enabled.length - 1);
|
|
71
|
-
}
|
|
47
|
+
{
|
|
48
|
+
role: "tablist",
|
|
49
|
+
"aria-label": props.label,
|
|
50
|
+
className: "aura-tabs__list",
|
|
51
|
+
onKeyDown: function(e) {
|
|
52
|
+
const enabled = items.filter(function(t) {
|
|
53
|
+
return !t.disabled;
|
|
54
|
+
}), i = enabled.indexOf(current);
|
|
55
|
+
if (e.key === "ArrowRight") {
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
go(i + 1);
|
|
58
|
+
} else if (e.key === "ArrowLeft") {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
go(i - 1);
|
|
61
|
+
} else if (e.key === "Home") {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
go(0);
|
|
64
|
+
} else if (e.key === "End") {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
go(enabled.length - 1);
|
|
72
67
|
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
className: cx("aura-tab", on && "is-active"),
|
|
91
|
-
onClick: function() {
|
|
92
|
-
st[1](t.id);
|
|
93
|
-
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
items.map(function(t) {
|
|
71
|
+
const on = current && t.id === current.id;
|
|
72
|
+
return /* @__PURE__ */ React.createElement(
|
|
73
|
+
"button",
|
|
74
|
+
{
|
|
75
|
+
key: t.id,
|
|
76
|
+
type: "button",
|
|
77
|
+
role: "tab",
|
|
78
|
+
id: base + "-tab-" + t.id,
|
|
79
|
+
"aria-selected": on,
|
|
80
|
+
"aria-controls": base + "-panel-" + t.id,
|
|
81
|
+
tabIndex: on ? 0 : -1,
|
|
82
|
+
disabled: t.disabled,
|
|
83
|
+
ref: function(el) {
|
|
84
|
+
refs.current[t.id] = el;
|
|
94
85
|
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
className: cx("aura-tab", on && "is-active"),
|
|
87
|
+
onClick: function() {
|
|
88
|
+
st[1](t.id);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
t.icon ? /* @__PURE__ */ React.createElement(Icon, { name: t.icon }) : null,
|
|
92
|
+
t.label,
|
|
93
|
+
t.count != null ? /* @__PURE__ */ React.createElement("span", { className: "aura-tab__count" }, t.count) : null
|
|
94
|
+
);
|
|
95
|
+
})
|
|
96
|
+
), current && current.content !== void 0 ? /* @__PURE__ */ React.createElement(
|
|
97
|
+
"div",
|
|
98
|
+
{
|
|
102
99
|
role: "tabpanel",
|
|
103
100
|
id: base + "-panel-" + current.id,
|
|
104
101
|
"aria-labelledby": base + "-tab-" + current.id,
|
|
105
102
|
tabIndex: 0,
|
|
106
103
|
className: "aura-tabs__panel"
|
|
107
|
-
},
|
|
108
|
-
|
|
104
|
+
},
|
|
105
|
+
current.content
|
|
106
|
+
) : null);
|
|
109
107
|
});
|
|
110
108
|
const SideNav = React.forwardRef(function SideNav2(props, ref) {
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
const t = useStrings();
|
|
110
|
+
const st = useMaybeControlled(
|
|
111
|
+
props.value,
|
|
112
|
+
props.defaultValue,
|
|
113
|
+
props.onChange
|
|
114
|
+
);
|
|
113
115
|
function item(it) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
it.icon ?
|
|
117
|
-
|
|
118
|
-
it.count != null ?
|
|
116
|
+
const on = st[0] === it.id;
|
|
117
|
+
const inner = [
|
|
118
|
+
it.icon ? /* @__PURE__ */ React.createElement(Icon, { key: "i", name: it.icon }) : null,
|
|
119
|
+
/* @__PURE__ */ React.createElement("span", { key: "l", className: "aura-nav__label" }, it.label),
|
|
120
|
+
it.count != null ? /* @__PURE__ */ React.createElement("span", { key: "c", className: "aura-nav__count" }, it.count) : null
|
|
119
121
|
];
|
|
120
|
-
|
|
122
|
+
const common = {
|
|
121
123
|
className: cx("aura-nav__item", on && "is-active"),
|
|
122
124
|
"aria-current": on ? "page" : void 0,
|
|
123
125
|
onClick: function(e) {
|
|
@@ -125,57 +127,33 @@ const SideNav = React.forwardRef(function SideNav2(props, ref) {
|
|
|
125
127
|
st[1](it.id);
|
|
126
128
|
}
|
|
127
129
|
};
|
|
128
|
-
return
|
|
130
|
+
return /* @__PURE__ */ React.createElement("li", { key: it.id }, it.href ? /* @__PURE__ */ React.createElement("a", { href: it.href, ...common }, inner) : /* @__PURE__ */ React.createElement("button", { type: "button", ...common }, inner));
|
|
129
131
|
}
|
|
130
|
-
return
|
|
131
|
-
"
|
|
132
|
-
|
|
133
|
-
props.header ? h("div", { className: "aura-nav__header" }, props.header) : null,
|
|
134
|
-
h(
|
|
135
|
-
"div",
|
|
136
|
-
{ className: "aura-nav__scroll" },
|
|
137
|
-
(props.sections || [{ items: props.items || [] }]).map(function(s, i) {
|
|
138
|
-
return h(
|
|
139
|
-
"div",
|
|
140
|
-
{ key: i, className: "aura-nav__section" },
|
|
141
|
-
s.title ? h("p", { className: "aura-nav__title" }, s.title) : null,
|
|
142
|
-
h("ul", { className: "aura-nav__list" }, s.items.map(item))
|
|
143
|
-
);
|
|
144
|
-
})
|
|
145
|
-
),
|
|
146
|
-
props.footer ? h("div", { className: "aura-nav__footer" }, props.footer) : null
|
|
147
|
-
);
|
|
132
|
+
return /* @__PURE__ */ React.createElement("nav", { ref, className: cx("aura-nav", props.className), "aria-label": props.label || t.mainNav }, props.header ? /* @__PURE__ */ React.createElement("div", { className: "aura-nav__header" }, props.header) : null, /* @__PURE__ */ React.createElement("div", { className: "aura-nav__scroll" }, (props.sections || [{ items: props.items || [] }]).map(function(s, i) {
|
|
133
|
+
return /* @__PURE__ */ React.createElement("div", { key: i, className: "aura-nav__section" }, s.title ? /* @__PURE__ */ React.createElement("p", { className: "aura-nav__title" }, s.title) : null, /* @__PURE__ */ React.createElement("ul", { className: "aura-nav__list" }, s.items.map(item)));
|
|
134
|
+
})), props.footer ? /* @__PURE__ */ React.createElement("div", { className: "aura-nav__footer" }, props.footer) : null);
|
|
148
135
|
});
|
|
149
136
|
const Breadcrumb = React.forwardRef(function Breadcrumb2(props, ref) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return
|
|
153
|
-
|
|
154
|
-
{
|
|
155
|
-
|
|
156
|
-
var last = i === items.length - 1;
|
|
157
|
-
return h(
|
|
158
|
-
"li",
|
|
159
|
-
{ key: i },
|
|
160
|
-
last ? h("span", { "aria-current": "page", className: "aura-crumbs__current" }, it.label) : it.href ? h("a", { href: it.href, onClick: it.onClick }, it.label) : h("button", { type: "button", onClick: it.onClick }, it.label),
|
|
161
|
-
last ? null : h(Icon, { name: "chevron-right", size: 12, className: "aura-crumbs__sep" })
|
|
162
|
-
);
|
|
163
|
-
}))
|
|
164
|
-
);
|
|
137
|
+
const t = useStrings();
|
|
138
|
+
const items = props.items || [];
|
|
139
|
+
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) {
|
|
140
|
+
const last = i === items.length - 1;
|
|
141
|
+
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" }));
|
|
142
|
+
})));
|
|
165
143
|
});
|
|
166
|
-
|
|
144
|
+
const AVATAR_TONES = ["progress", "ready", "neutral", "warning"];
|
|
167
145
|
function initials(name) {
|
|
168
|
-
|
|
146
|
+
const parts = String(name || "?").trim().split(/\s+/);
|
|
169
147
|
return ((parts[0] || "?")[0] + (parts.length > 1 ? parts[parts.length - 1][0] : parts[0][1] || "")).toUpperCase();
|
|
170
148
|
}
|
|
171
149
|
const Avatar = React.forwardRef(function Avatar2(props, ref) {
|
|
172
|
-
|
|
173
|
-
|
|
150
|
+
const size = props.size || "md", errState = React.useState(false);
|
|
151
|
+
let hash = 0;
|
|
174
152
|
String(props.name || "").split("").forEach(function(ch) {
|
|
175
153
|
hash = hash * 31 + ch.charCodeAt(0) >>> 0;
|
|
176
154
|
});
|
|
177
|
-
|
|
178
|
-
return
|
|
155
|
+
const tone = AVATAR_TONES[hash % AVATAR_TONES.length];
|
|
156
|
+
return /* @__PURE__ */ React.createElement(
|
|
179
157
|
"span",
|
|
180
158
|
{
|
|
181
159
|
ref,
|
|
@@ -183,10 +161,17 @@ const Avatar = React.forwardRef(function Avatar2(props, ref) {
|
|
|
183
161
|
role: "img",
|
|
184
162
|
"aria-label": props.name + (props.status ? ", " + props.status : "")
|
|
185
163
|
},
|
|
186
|
-
props.src && !errState[0] ?
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
164
|
+
props.src && !errState[0] ? /* @__PURE__ */ React.createElement(
|
|
165
|
+
"img",
|
|
166
|
+
{
|
|
167
|
+
src: props.src,
|
|
168
|
+
alt: "",
|
|
169
|
+
onError: function() {
|
|
170
|
+
errState[1](true);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
) : /* @__PURE__ */ React.createElement("span", { "aria-hidden": true }, initials(props.name)),
|
|
174
|
+
props.status === "online" ? /* @__PURE__ */ React.createElement("span", { className: "aura-avatar__status", "aria-hidden": true }) : null
|
|
190
175
|
);
|
|
191
176
|
});
|
|
192
177
|
export {
|
package/dist/esm/layout2.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { useStrings
|
|
3
|
+
import { useStrings } from "./locale.js";
|
|
4
4
|
import { cx } from "./internal.js";
|
|
5
5
|
import { IconButton } from "./IconButton.js";
|
|
6
6
|
import { Drawer } from "./Dialog.js";
|
|
7
7
|
const h = React.createElement;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const breakpoints = { sm: 640, md: 768, lg: 1024, xl: 1280 };
|
|
9
|
+
const ORDER = ["base", "sm", "md", "lg", "xl"];
|
|
10
10
|
function useBreakpoint() {
|
|
11
11
|
return React.useSyncExternalStore(subscribe, current, function() {
|
|
12
12
|
return "lg";
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
function current() {
|
|
16
|
-
|
|
16
|
+
let w = window.innerWidth, bp = "base";
|
|
17
17
|
ORDER.slice(1).forEach(function(k) {
|
|
18
18
|
if (w >= breakpoints[k]) bp = k;
|
|
19
19
|
});
|
|
@@ -26,27 +26,28 @@ function subscribe(cb) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
function useResponsive(value) {
|
|
29
|
-
|
|
29
|
+
const bp = useBreakpoint();
|
|
30
30
|
if (value == null || typeof value !== "object") return value;
|
|
31
|
-
|
|
31
|
+
const map = value;
|
|
32
|
+
for (let i = ORDER.indexOf(bp); i >= 0; i--) if (map[ORDER[i]] !== void 0) return map[ORDER[i]];
|
|
32
33
|
return void 0;
|
|
33
34
|
}
|
|
34
35
|
function respVars(prefix, value, map) {
|
|
35
|
-
|
|
36
|
+
const style = {};
|
|
36
37
|
if (value == null) return style;
|
|
37
38
|
if (typeof value !== "object") value = { base: value };
|
|
38
|
-
|
|
39
|
+
let byBp = value, cur;
|
|
39
40
|
ORDER.forEach(function(k) {
|
|
40
|
-
if (
|
|
41
|
+
if (byBp[k] !== void 0) cur = map ? map(byBp[k]) : byBp[k];
|
|
41
42
|
if (cur !== void 0) style["--" + prefix + "-" + k] = cur;
|
|
42
43
|
});
|
|
43
44
|
return style;
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
+
const space = function(v) {
|
|
46
47
|
return typeof v === "number" ? "var(--aura-space-" + v + ")" : v;
|
|
47
48
|
};
|
|
48
49
|
const Stack = React.forwardRef(function Stack2(props, ref) {
|
|
49
|
-
|
|
50
|
+
const style = Object.assign(
|
|
50
51
|
{},
|
|
51
52
|
respVars("aura-stack-dir", props.direction || "column"),
|
|
52
53
|
respVars("aura-stack-gap", props.gap == null ? 4 : props.gap, space),
|
|
@@ -58,50 +59,73 @@ const Stack = React.forwardRef(function Stack2(props, ref) {
|
|
|
58
59
|
return h(props.as || "div", { ref, className: cx("aura-stack", props.className), style }, props.children);
|
|
59
60
|
});
|
|
60
61
|
const Grid = React.forwardRef(function Grid2(props, ref) {
|
|
61
|
-
|
|
62
|
+
const style = Object.assign(
|
|
62
63
|
{},
|
|
63
64
|
respVars("aura-grid-gap", props.gap == null ? 6 : props.gap, space),
|
|
64
65
|
props.minItemWidth ? { gridTemplateColumns: "repeat(auto-fill, minmax(min(" + props.minItemWidth + "px, 100%), 1fr))" } : respVars("aura-grid-cols", props.columns || 1),
|
|
65
66
|
props.style
|
|
66
67
|
);
|
|
67
|
-
return h(
|
|
68
|
+
return h(
|
|
69
|
+
props.as || "div",
|
|
70
|
+
{ ref, className: cx("aura-grid-layout", props.minItemWidth && "is-auto", props.className), style },
|
|
71
|
+
props.children
|
|
72
|
+
);
|
|
68
73
|
});
|
|
69
74
|
const Container = React.forwardRef(function Container2(props, ref) {
|
|
70
|
-
return h(
|
|
75
|
+
return h(
|
|
76
|
+
props.as || "div",
|
|
77
|
+
{
|
|
78
|
+
ref,
|
|
79
|
+
className: cx("aura-container", props.size === "narrow" && "is-narrow", props.className),
|
|
80
|
+
style: props.style
|
|
81
|
+
},
|
|
82
|
+
props.children
|
|
83
|
+
);
|
|
71
84
|
});
|
|
72
85
|
const AppShell = React.forwardRef(function AppShell2(props, ref) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
React.useEffect(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
setOpen(false);
|
|
83
|
-
}, className: cx(props.nav.props.className, "is-in-drawer") }) : props.nav;
|
|
84
|
-
return h(
|
|
85
|
-
"div",
|
|
86
|
-
{ ref, className: cx("aura-shell", compact && "is-compact", props.className) },
|
|
87
|
-
!compact ? h("div", { className: "aura-shell__nav" }, nav) : null,
|
|
88
|
-
compact ? h(Drawer, { open, onClose: function() {
|
|
89
|
-
setOpen(false);
|
|
90
|
-
}, side: "left", size: "nav", "aria-label": props.navLabel || t.navigation, dismissible: true }, nav) : null,
|
|
91
|
-
h(
|
|
92
|
-
"div",
|
|
93
|
-
{ className: "aura-shell__main" },
|
|
94
|
-
props.header || compact ? h(
|
|
95
|
-
"header",
|
|
96
|
-
{ className: "aura-shell__bar" },
|
|
97
|
-
compact ? h(IconButton, { icon: "menu", label: props.menuLabel || t.openNav, size: "md", onClick: function() {
|
|
98
|
-
setOpen(true);
|
|
99
|
-
}, "aria-expanded": open }) : null,
|
|
100
|
-
h("div", { className: "aura-shell__bar-content" }, props.header)
|
|
101
|
-
) : null,
|
|
102
|
-
h("main", { className: "aura-shell__content", id: props.mainId || "main" }, props.children)
|
|
103
|
-
)
|
|
86
|
+
const t = useStrings();
|
|
87
|
+
const bp = useBreakpoint();
|
|
88
|
+
const compact = bp === "base" || bp === "sm" || bp === "md";
|
|
89
|
+
const st = React.useState(false), open = st[0], setOpen = st[1];
|
|
90
|
+
React.useEffect(
|
|
91
|
+
function() {
|
|
92
|
+
if (!compact) setOpen(false);
|
|
93
|
+
},
|
|
94
|
+
[compact]
|
|
104
95
|
);
|
|
96
|
+
const navEl = props.nav;
|
|
97
|
+
const nav = props.nav && React.isValidElement(props.nav) && compact ? React.cloneElement(navEl, {
|
|
98
|
+
onChange: function(id) {
|
|
99
|
+
if (navEl.props.onChange) navEl.props.onChange(id);
|
|
100
|
+
setOpen(false);
|
|
101
|
+
},
|
|
102
|
+
className: cx(navEl.props.className, "is-in-drawer")
|
|
103
|
+
}) : props.nav;
|
|
104
|
+
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(
|
|
105
|
+
Drawer,
|
|
106
|
+
{
|
|
107
|
+
open,
|
|
108
|
+
onClose: function() {
|
|
109
|
+
setOpen(false);
|
|
110
|
+
},
|
|
111
|
+
side: "left",
|
|
112
|
+
size: "nav",
|
|
113
|
+
"aria-label": props.navLabel || t.navigation,
|
|
114
|
+
dismissible: true
|
|
115
|
+
},
|
|
116
|
+
nav
|
|
117
|
+
) : null, /* @__PURE__ */ React.createElement("div", { className: "aura-shell__main" }, props.header || compact ? /* @__PURE__ */ React.createElement("header", { className: "aura-shell__bar" }, compact ? /* @__PURE__ */ React.createElement(
|
|
118
|
+
IconButton,
|
|
119
|
+
{
|
|
120
|
+
icon: "menu",
|
|
121
|
+
label: props.menuLabel || t.openNav,
|
|
122
|
+
size: "md",
|
|
123
|
+
onClick: function() {
|
|
124
|
+
setOpen(true);
|
|
125
|
+
},
|
|
126
|
+
"aria-expanded": open
|
|
127
|
+
}
|
|
128
|
+
) : 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)));
|
|
105
129
|
});
|
|
106
130
|
export {
|
|
107
131
|
AppShell,
|
package/dist/esm/locale.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
const
|
|
4
|
-
var n = function(x) {
|
|
3
|
+
const n = function(x) {
|
|
5
4
|
return Number(x).toLocaleString("en");
|
|
6
5
|
};
|
|
7
|
-
|
|
6
|
+
const STRINGS = {
|
|
8
7
|
en: {
|
|
9
8
|
close: "Close",
|
|
10
9
|
dismiss: "Dismiss",
|
|
@@ -182,13 +181,20 @@ var STRINGS = {
|
|
|
182
181
|
}
|
|
183
182
|
}
|
|
184
183
|
};
|
|
185
|
-
|
|
184
|
+
const LocaleContext = React.createContext(null);
|
|
186
185
|
function AuraProvider(props) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
186
|
+
const value = React.useMemo(
|
|
187
|
+
function() {
|
|
188
|
+
const base = props.locale && STRINGS[props.locale] || STRINGS.en;
|
|
189
|
+
return {
|
|
190
|
+
locale: props.locale || "en",
|
|
191
|
+
calendar: props.calendar || null,
|
|
192
|
+
strings: props.strings ? Object.assign({}, base, props.strings) : base
|
|
193
|
+
};
|
|
194
|
+
},
|
|
195
|
+
[props.locale, props.calendar, props.strings]
|
|
196
|
+
);
|
|
197
|
+
return /* @__PURE__ */ React.createElement(LocaleContext.Provider, { value }, props.children);
|
|
192
198
|
}
|
|
193
199
|
function useAuraLocale() {
|
|
194
200
|
return React.useContext(LocaleContext) || { locale: null, calendar: null, strings: STRINGS.en };
|