@jirawatpyk/aura-react 4.15.0 → 4.17.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 +76 -5
- package/dist/aura.bundle.js +239 -142
- package/dist/cjs/index.cjs +239 -142
- package/dist/esm/AppShell.js +9 -9
- package/dist/esm/Breadcrumb.js +1 -1
- package/dist/esm/Button.js +12 -3
- package/dist/esm/Command.js +69 -49
- package/dist/esm/DataTable.js +43 -16
- package/dist/esm/DatePicker.js +17 -146
- package/dist/esm/FileUpload.js +1 -10
- package/dist/esm/Pagination.js +35 -23
- package/dist/esm/Skeleton.js +4 -1
- package/dist/esm/Stat.js +1 -1
- package/dist/esm/StatusPill.js +4 -13
- package/dist/esm/TimePicker.js +1 -12
- package/dist/esm/breakpoints.js +5 -0
- package/dist/esm/colorScheme.js +1 -11
- package/dist/esm/colorSchemeScript.js +19 -0
- package/dist/esm/dates.js +164 -0
- package/dist/esm/locale.js +1 -347
- package/dist/esm/responsive.js +1 -1
- package/dist/esm/status.js +17 -0
- package/dist/esm/strings.js +351 -0
- package/dist/esm/text.js +30 -0
- package/dist/index.d.ts +537 -503
- package/dist/server/index.cjs +791 -0
- package/dist/server/index.d.ts +171 -0
- package/dist/server/index.js +768 -0
- package/dist/styles.css +69 -4
- package/dist/styles.layer.css +1352 -0
- package/package.json +11 -4
package/dist/esm/AppShell.js
CHANGED
|
@@ -8,26 +8,25 @@ import { useBreakpoint } from "./responsive.js";
|
|
|
8
8
|
const AppShell = React.forwardRef(function AppShell2(props, ref) {
|
|
9
9
|
const t = useStrings();
|
|
10
10
|
const bp = useBreakpoint();
|
|
11
|
-
const
|
|
11
|
+
const wide = bp === "lg" || bp === "xl";
|
|
12
12
|
const st = React.useState(false), open = st[0], setOpen = st[1];
|
|
13
13
|
React.useEffect(
|
|
14
14
|
function() {
|
|
15
|
-
if (
|
|
15
|
+
if (wide) setOpen(false);
|
|
16
16
|
},
|
|
17
|
-
[
|
|
17
|
+
[wide]
|
|
18
18
|
);
|
|
19
|
-
const navEl = props.nav;
|
|
20
|
-
const
|
|
19
|
+
const navEl = props.nav && React.isValidElement(props.nav) ? props.nav : null;
|
|
20
|
+
const drawerNav = navEl ? React.cloneElement(navEl, {
|
|
21
21
|
onChange: function(id) {
|
|
22
22
|
if (navEl.props.onChange) navEl.props.onChange(id);
|
|
23
23
|
setOpen(false);
|
|
24
24
|
},
|
|
25
25
|
className: cx(navEl.props.className, "is-in-drawer"),
|
|
26
|
-
/* The drawer is already full-size: never a rail, no collapse button. */
|
|
27
26
|
collapsed: false,
|
|
28
27
|
collapsible: false
|
|
29
28
|
}) : props.nav;
|
|
30
|
-
return /* @__PURE__ */ React.createElement("div", { ref, className: cx("aura-shell",
|
|
29
|
+
return /* @__PURE__ */ React.createElement("div", { ref, className: cx("aura-shell", props.className) }, props.nav ? /* @__PURE__ */ React.createElement("div", { className: "aura-shell__nav" }, props.nav) : null, props.nav ? /* @__PURE__ */ React.createElement(
|
|
31
30
|
Drawer,
|
|
32
31
|
{
|
|
33
32
|
open,
|
|
@@ -39,10 +38,11 @@ const AppShell = React.forwardRef(function AppShell2(props, ref) {
|
|
|
39
38
|
"aria-label": props.navLabel || t.navigation,
|
|
40
39
|
dismissible: true
|
|
41
40
|
},
|
|
42
|
-
|
|
43
|
-
) : null, /* @__PURE__ */ React.createElement("div", { className: "aura-shell__main" }, props.header ||
|
|
41
|
+
drawerNav
|
|
42
|
+
) : null, /* @__PURE__ */ React.createElement("div", { className: "aura-shell__main" }, props.header || props.nav ? /* @__PURE__ */ React.createElement("header", { className: cx("aura-shell__bar", !props.header && "aura-shell__bar--menu-only") }, props.nav ? /* @__PURE__ */ React.createElement(
|
|
44
43
|
IconButton,
|
|
45
44
|
{
|
|
45
|
+
className: "aura-shell__menu",
|
|
46
46
|
icon: "menu",
|
|
47
47
|
label: props.menuLabel || t.openNav,
|
|
48
48
|
size: "md",
|
package/dist/esm/Breadcrumb.js
CHANGED
|
@@ -5,7 +5,7 @@ import { cx } from "./internal.js";
|
|
|
5
5
|
import { useLinkComponent, useStrings } from "./locale.js";
|
|
6
6
|
const Breadcrumb = React.forwardRef(function Breadcrumb2(props, ref) {
|
|
7
7
|
const t = useStrings();
|
|
8
|
-
const Link = useLinkComponent();
|
|
8
|
+
const Link = useLinkComponent(props.linkComponent);
|
|
9
9
|
const items = props.items || [];
|
|
10
10
|
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) {
|
|
11
11
|
const last = i === items.length - 1;
|
package/dist/esm/Button.js
CHANGED
|
@@ -15,7 +15,8 @@ function ButtonLink(props, ref, Link) {
|
|
|
15
15
|
"disabled",
|
|
16
16
|
"linkComponent",
|
|
17
17
|
"href",
|
|
18
|
-
"fullWidth"
|
|
18
|
+
"fullWidth",
|
|
19
|
+
"size"
|
|
19
20
|
]);
|
|
20
21
|
const Tag = disabled ? "a" : Link;
|
|
21
22
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -27,7 +28,13 @@ function ButtonLink(props, ref, Link) {
|
|
|
27
28
|
role: disabled ? "link" : void 0,
|
|
28
29
|
"aria-disabled": disabled || void 0,
|
|
29
30
|
tabIndex: disabled ? -1 : props.tabIndex,
|
|
30
|
-
className: cx(
|
|
31
|
+
className: cx(
|
|
32
|
+
"aura-btn",
|
|
33
|
+
"aura-btn--" + variant,
|
|
34
|
+
props.size === "sm" && "aura-btn--sm",
|
|
35
|
+
props.fullWidth && "aura-btn--full",
|
|
36
|
+
props.className
|
|
37
|
+
),
|
|
31
38
|
onClick: disabled ? void 0 : props.onClick
|
|
32
39
|
},
|
|
33
40
|
props.icon ? /* @__PURE__ */ React.createElement(Icon, { name: props.icon }) : null,
|
|
@@ -53,7 +60,8 @@ const Button = React.forwardRef(
|
|
|
53
60
|
"iconRight",
|
|
54
61
|
"loading",
|
|
55
62
|
"onClick",
|
|
56
|
-
"fullWidth"
|
|
63
|
+
"fullWidth",
|
|
64
|
+
"size"
|
|
57
65
|
]);
|
|
58
66
|
return /* @__PURE__ */ React.createElement(
|
|
59
67
|
"button",
|
|
@@ -64,6 +72,7 @@ const Button = React.forwardRef(
|
|
|
64
72
|
className: cx(
|
|
65
73
|
"aura-btn",
|
|
66
74
|
"aura-btn--" + variant,
|
|
75
|
+
props.size === "sm" && "aura-btn--sm",
|
|
67
76
|
props.fullWidth && "aura-btn--full",
|
|
68
77
|
loading && "is-loading",
|
|
69
78
|
props.className
|
package/dist/esm/Command.js
CHANGED
|
@@ -15,7 +15,12 @@ function Command(props) {
|
|
|
15
15
|
const id = uid(), listId = id + "-list";
|
|
16
16
|
const box = React.useRef(null);
|
|
17
17
|
const input = React.useRef(null);
|
|
18
|
-
const
|
|
18
|
+
const qState = React.useState(""), act = React.useState(null);
|
|
19
|
+
const query = props.query !== void 0 ? props.query : qState[0];
|
|
20
|
+
function setQuery(v) {
|
|
21
|
+
if (props.query === void 0) qState[1](v);
|
|
22
|
+
if (props.onQueryChange) props.onQueryChange(v);
|
|
23
|
+
}
|
|
19
24
|
const openRef = React.useRef(props.open);
|
|
20
25
|
openRef.current = props.open;
|
|
21
26
|
const close = function() {
|
|
@@ -41,15 +46,15 @@ function Command(props) {
|
|
|
41
46
|
React.useEffect(
|
|
42
47
|
function() {
|
|
43
48
|
if (!props.open) {
|
|
44
|
-
|
|
45
|
-
act[1](
|
|
49
|
+
if (query) setQuery("");
|
|
50
|
+
act[1](null);
|
|
46
51
|
}
|
|
47
52
|
},
|
|
48
53
|
[props.open]
|
|
49
54
|
);
|
|
50
|
-
const filter = props.filter || defaultFilter;
|
|
55
|
+
const filter = props.filter === false ? null : props.filter || defaultFilter;
|
|
51
56
|
const shown = (props.items || []).filter(function(it) {
|
|
52
|
-
return filter(it,
|
|
57
|
+
return !filter || filter(it, query);
|
|
53
58
|
});
|
|
54
59
|
const groups = [];
|
|
55
60
|
shown.forEach(function(it) {
|
|
@@ -71,7 +76,10 @@ function Command(props) {
|
|
|
71
76
|
}).filter(function(i2) {
|
|
72
77
|
return i2 >= 0;
|
|
73
78
|
});
|
|
74
|
-
const
|
|
79
|
+
const byId = act[0] == null ? -1 : flat.findIndex(function(it) {
|
|
80
|
+
return it.id === act[0];
|
|
81
|
+
});
|
|
82
|
+
const active = enabled.indexOf(byId) >= 0 ? byId : enabled.length ? enabled[0] : -1;
|
|
75
83
|
const optId = function(i2) {
|
|
76
84
|
return id + "-o" + i2;
|
|
77
85
|
};
|
|
@@ -96,7 +104,7 @@ function Command(props) {
|
|
|
96
104
|
if (dir === "first") n = 0;
|
|
97
105
|
else if (dir === "last") n = enabled.length - 1;
|
|
98
106
|
else n = (at + dir + enabled.length) % enabled.length;
|
|
99
|
-
act[1](enabled[n]);
|
|
107
|
+
act[1](flat[enabled[n]].id);
|
|
100
108
|
}
|
|
101
109
|
function onKey(e) {
|
|
102
110
|
if (e.key === "ArrowDown") {
|
|
@@ -154,56 +162,68 @@ function Command(props) {
|
|
|
154
162
|
"aria-label": props.label || t.commandMenu,
|
|
155
163
|
placeholder: props.placeholder || t.commandPlaceholder,
|
|
156
164
|
className: "aura-command__input",
|
|
157
|
-
value:
|
|
165
|
+
value: query,
|
|
158
166
|
autoComplete: "off",
|
|
159
167
|
spellCheck: false,
|
|
160
168
|
onChange: function(e) {
|
|
161
|
-
|
|
162
|
-
act[1](
|
|
169
|
+
setQuery(e.target.value);
|
|
170
|
+
act[1](null);
|
|
163
171
|
},
|
|
164
172
|
onKeyDown: onKey
|
|
165
173
|
}
|
|
166
174
|
), /* @__PURE__ */ React.createElement("kbd", { className: "aura-command__kbd" }, "Esc")),
|
|
167
|
-
/* @__PURE__ */ React.createElement(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
"
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
g
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
175
|
+
/* @__PURE__ */ React.createElement(
|
|
176
|
+
"div",
|
|
177
|
+
{
|
|
178
|
+
className: "aura-command__list",
|
|
179
|
+
id: listId,
|
|
180
|
+
role: "listbox",
|
|
181
|
+
"aria-label": props.label || t.commandMenu,
|
|
182
|
+
"aria-busy": props.loading || void 0
|
|
183
|
+
},
|
|
184
|
+
props.loading ? /* @__PURE__ */ React.createElement("div", { className: "aura-command__loading", role: "presentation" }, /* @__PURE__ */ React.createElement(Icon, { name: "loader-circle", className: "aura-spin" }), t.searching) : null,
|
|
185
|
+
!flat.length ? props.loading ? null : /* @__PURE__ */ React.createElement("div", { className: "aura-command__empty", role: "presentation" }, props.empty != null ? props.empty : props.emptyText || t.noMatches) : groups.map(function(g, gi) {
|
|
186
|
+
const gid = id + "-g" + gi;
|
|
187
|
+
return /* @__PURE__ */ React.createElement(
|
|
188
|
+
"div",
|
|
189
|
+
{
|
|
190
|
+
key: g.name || gi,
|
|
191
|
+
role: "group",
|
|
192
|
+
"aria-labelledby": g.name ? gid : void 0,
|
|
193
|
+
className: "aura-command__group"
|
|
194
|
+
},
|
|
195
|
+
g.name ? /* @__PURE__ */ React.createElement("div", { className: "aura-command__heading", id: gid, role: "presentation" }, g.name) : null,
|
|
196
|
+
g.items.map(function(it) {
|
|
197
|
+
i++;
|
|
198
|
+
const n = i;
|
|
199
|
+
return /* @__PURE__ */ React.createElement(
|
|
200
|
+
"div",
|
|
201
|
+
{
|
|
202
|
+
key: it.id,
|
|
203
|
+
id: optId(n),
|
|
204
|
+
role: "option",
|
|
205
|
+
"aria-selected": n === active,
|
|
206
|
+
"aria-disabled": it.disabled || void 0,
|
|
207
|
+
className: cx("aura-command__item", n === active && "is-active", it.disabled && "is-disabled"),
|
|
208
|
+
onPointerDown: function(e) {
|
|
209
|
+
e.preventDefault();
|
|
210
|
+
},
|
|
211
|
+
onPointerMove: function() {
|
|
212
|
+
if (!it.disabled && act[0] !== it.id) act[1](it.id);
|
|
213
|
+
},
|
|
214
|
+
onClick: function() {
|
|
215
|
+
run(it);
|
|
216
|
+
}
|
|
195
217
|
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
);
|
|
206
|
-
})),
|
|
218
|
+
it.icon ? /* @__PURE__ */ React.createElement(Icon, { name: it.icon }) : null,
|
|
219
|
+
/* @__PURE__ */ React.createElement("span", { className: "aura-command__text" }, /* @__PURE__ */ React.createElement("span", { className: "aura-command__label" }, it.label), it.description ? /* @__PURE__ */ React.createElement("span", { className: "aura-command__desc" }, it.description) : null),
|
|
220
|
+
it.shortcut ? /* @__PURE__ */ React.createElement("kbd", { className: "aura-command__kbd" }, it.shortcut) : null
|
|
221
|
+
);
|
|
222
|
+
})
|
|
223
|
+
);
|
|
224
|
+
})
|
|
225
|
+
),
|
|
226
|
+
/* @__PURE__ */ React.createElement("span", { className: "aura-sr-only", role: "status" }, props.loading ? t.searching : props.loading === false && query ? t.results(flat.length) : ""),
|
|
207
227
|
/* @__PURE__ */ React.createElement("div", { className: "aura-command__foot", "aria-hidden": true }, t.commandHint, /* @__PURE__ */ React.createElement("span", { className: "aura-command__mod" }, isMac() ? "\u2318K" : "Ctrl K"))
|
|
208
228
|
)
|
|
209
229
|
),
|
package/dist/esm/DataTable.js
CHANGED
|
@@ -15,6 +15,7 @@ const DEFAULT_COLUMNS = [
|
|
|
15
15
|
{ key: "owner", label: "OWNER" }
|
|
16
16
|
];
|
|
17
17
|
const SKELETON_WIDTHS = ["72%", "56%", "84%", "44%", "64%"];
|
|
18
|
+
const STACK_WIDTHS = [360, 400, 480, 520, 560, 600, 640, 720, 768, 800, 900, 960, 1024];
|
|
18
19
|
const ROW_H_DEFAULT = 48, OVERSCAN = 8, FLEX_MIN = 160;
|
|
19
20
|
const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
20
21
|
const t = useStrings();
|
|
@@ -33,11 +34,20 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
33
34
|
const selectable = !!props.selectable;
|
|
34
35
|
const reorderable = props.reorderable !== false && !!props.columnControls;
|
|
35
36
|
const controls = !!props.columnControls;
|
|
36
|
-
const
|
|
37
|
+
const oneCallback = !!props.onStateChange;
|
|
38
|
+
const sortState = useMaybeControlled(
|
|
39
|
+
props.sort,
|
|
40
|
+
props.defaultSort || null,
|
|
41
|
+
oneCallback ? null : props.onSortChange
|
|
42
|
+
);
|
|
37
43
|
const sort = sortState[0], setSort = sortState[1];
|
|
38
44
|
const selState = useMaybeControlled(props.selected, props.defaultSelected || [], props.onSelectionChange);
|
|
39
45
|
const selected = selState[0], setSelected = selState[1];
|
|
40
|
-
const pageState = useMaybeControlled(
|
|
46
|
+
const pageState = useMaybeControlled(
|
|
47
|
+
props.page,
|
|
48
|
+
props.defaultPage || 1,
|
|
49
|
+
oneCallback ? null : props.onPageChange
|
|
50
|
+
);
|
|
41
51
|
const orderState = useMaybeControlled(
|
|
42
52
|
props.columnOrder,
|
|
43
53
|
columns.map(function(c) {
|
|
@@ -79,6 +89,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
79
89
|
const measure = !!props.stackBelow || columns.some(function(c) {
|
|
80
90
|
return c.hideBelow != null;
|
|
81
91
|
});
|
|
92
|
+
const dual = !!props.stackBelow && boxWidth[0] == null && STACK_WIDTHS.indexOf(props.stackBelow) >= 0;
|
|
82
93
|
React.useEffect(
|
|
83
94
|
function() {
|
|
84
95
|
if (!measure || !wrapRef.current || typeof ResizeObserver === "undefined") return;
|
|
@@ -90,9 +101,15 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
90
101
|
ro.disconnect();
|
|
91
102
|
};
|
|
92
103
|
},
|
|
93
|
-
[measure]
|
|
104
|
+
[measure, dual]
|
|
94
105
|
);
|
|
95
106
|
const stacked = !!props.stackBelow && boxWidth[0] != null && boxWidth[0] < props.stackBelow;
|
|
107
|
+
useIsoLayoutEffect(
|
|
108
|
+
function() {
|
|
109
|
+
if (measure && boxWidth[0] == null && wrapRef.current) boxWidth[1](wrapRef.current.getBoundingClientRect().width);
|
|
110
|
+
},
|
|
111
|
+
[measure]
|
|
112
|
+
);
|
|
96
113
|
function tooNarrow(c) {
|
|
97
114
|
if (c.hideBelow == null || boxWidth[0] == null || stacked) return false;
|
|
98
115
|
const px = typeof c.hideBelow === "number" ? c.hideBelow : BP[c.hideBelow];
|
|
@@ -200,11 +217,15 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
200
217
|
const pageRows = pageSize && !manual ? view.slice(first, first + pageSize) : view;
|
|
201
218
|
const canSortAny = !busy && (manual ? total > 1 : rows.length > 1);
|
|
202
219
|
const shownTotal = manual && props.totalRows == null ? first + rows.length : total;
|
|
203
|
-
const linkPaging = !!props.getPageHref && !props.onPageChange;
|
|
220
|
+
const linkPaging = !!props.getPageHref && !props.onPageChange && !oneCallback;
|
|
204
221
|
const prevLink = React.useRef(null), nextLink = React.useRef(null);
|
|
205
|
-
function
|
|
222
|
+
function emit(s, p) {
|
|
223
|
+
if (props.onStateChange) props.onStateChange({ sort: s, page: p });
|
|
224
|
+
}
|
|
225
|
+
function goPage(p, focus, quiet) {
|
|
206
226
|
const next = Math.min(Math.max(1, p), pageCount);
|
|
207
227
|
if (next === page) return false;
|
|
228
|
+
if (!quiet) emit(sort, next);
|
|
208
229
|
if (linkPaging) {
|
|
209
230
|
const a = next === page - 1 ? prevLink.current : next === page + 1 ? nextLink.current : null;
|
|
210
231
|
if (a) a.click();
|
|
@@ -216,8 +237,12 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
216
237
|
return true;
|
|
217
238
|
}
|
|
218
239
|
function sortBy(key) {
|
|
219
|
-
|
|
220
|
-
|
|
240
|
+
applySort(nextSort(key));
|
|
241
|
+
}
|
|
242
|
+
function applySort(s) {
|
|
243
|
+
setSort(s);
|
|
244
|
+
if (!(manual && linkPaging)) goPage(1, void 0, true);
|
|
245
|
+
emit(s, 1);
|
|
221
246
|
}
|
|
222
247
|
const rowHref = props.getRowHref;
|
|
223
248
|
function followRow(el, e) {
|
|
@@ -432,16 +457,14 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
432
457
|
label: t.sortAsc,
|
|
433
458
|
icon: "arrow-up",
|
|
434
459
|
onSelect: function() {
|
|
435
|
-
|
|
436
|
-
goPage(1);
|
|
460
|
+
applySort({ key: c.key, dir: "asc" });
|
|
437
461
|
}
|
|
438
462
|
},
|
|
439
463
|
{
|
|
440
464
|
label: t.sortDesc,
|
|
441
465
|
icon: "arrow-down",
|
|
442
466
|
onSelect: function() {
|
|
443
|
-
|
|
444
|
-
goPage(1);
|
|
467
|
+
applySort({ key: c.key, dir: "desc" });
|
|
445
468
|
}
|
|
446
469
|
},
|
|
447
470
|
{ separator: true }
|
|
@@ -878,9 +901,10 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
878
901
|
className: "aura-icon-btn",
|
|
879
902
|
"aria-label": label,
|
|
880
903
|
onClick: function(e) {
|
|
881
|
-
if (props.onPageChange) {
|
|
904
|
+
if (props.onPageChange || oneCallback) {
|
|
882
905
|
e.preventDefault();
|
|
883
906
|
pageState[1](p);
|
|
907
|
+
emit(sort, p);
|
|
884
908
|
}
|
|
885
909
|
}
|
|
886
910
|
},
|
|
@@ -904,7 +928,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
904
928
|
} else if (height && rows.length && !loading) {
|
|
905
929
|
foot = /* @__PURE__ */ React.createElement("div", { className: "aura-table__foot" }, /* @__PURE__ */ React.createElement("span", null, t.rowCount(shownTotal)), selectable && selected.length ? /* @__PURE__ */ React.createElement("span", null, t.selectedCount(selected.length)) : /* @__PURE__ */ React.createElement("span", null));
|
|
906
930
|
}
|
|
907
|
-
|
|
931
|
+
function renderStacked(wrapRefArg) {
|
|
908
932
|
const titleCol = vis[0], pillCol = vis.filter(function(c) {
|
|
909
933
|
return c.pill && c !== titleCol;
|
|
910
934
|
})[0];
|
|
@@ -968,7 +992,7 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
968
992
|
return /* @__PURE__ */ React.createElement(
|
|
969
993
|
"div",
|
|
970
994
|
{
|
|
971
|
-
ref:
|
|
995
|
+
ref: wrapRefArg,
|
|
972
996
|
"data-density": props.density,
|
|
973
997
|
className: cx("aura-table aura-table--stacked", refreshing && "is-refreshing", props.className),
|
|
974
998
|
role: "region",
|
|
@@ -989,15 +1013,16 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
989
1013
|
foot
|
|
990
1014
|
);
|
|
991
1015
|
}
|
|
1016
|
+
if (stacked) return renderStacked(wrapMerged);
|
|
992
1017
|
const scrollStyle = {
|
|
993
1018
|
scrollPaddingLeft: "calc(var(--aura-space-6)" + selW + " + " + acc + "px)",
|
|
994
1019
|
scrollPaddingTop: ROW_H + "px"
|
|
995
1020
|
};
|
|
996
1021
|
if (height) scrollStyle.height = height + "px";
|
|
997
|
-
|
|
1022
|
+
const gridEl = /* @__PURE__ */ React.createElement(
|
|
998
1023
|
"div",
|
|
999
1024
|
{
|
|
1000
|
-
ref: wrapMerged,
|
|
1025
|
+
ref: dual ? void 0 : wrapMerged,
|
|
1001
1026
|
"data-density": props.density,
|
|
1002
1027
|
className: cx("aura-table", scrolledX[0] && "is-scrolled-x", refreshing && "is-refreshing", props.className)
|
|
1003
1028
|
},
|
|
@@ -1053,6 +1078,8 @@ const DataTable = React.forwardRef(function DataTable2(props, ref) {
|
|
|
1053
1078
|
}
|
|
1054
1079
|
) : null
|
|
1055
1080
|
);
|
|
1081
|
+
if (!dual) return gridEl;
|
|
1082
|
+
return /* @__PURE__ */ React.createElement("div", { ref: wrapMerged, className: "aura-table-dual", "data-stack-below": props.stackBelow }, renderStacked(void 0), gridEl);
|
|
1056
1083
|
});
|
|
1057
1084
|
export {
|
|
1058
1085
|
DataTable
|
package/dist/esm/DatePicker.js
CHANGED
|
@@ -6,111 +6,21 @@ import { cx, uid, useMaybeControlled, useMounted, useIsoLayoutEffect, trapTab, u
|
|
|
6
6
|
import { Icon } from "./Icon.js";
|
|
7
7
|
import { IconButton } from "./IconButton.js";
|
|
8
8
|
import { Field } from "./Field.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
function addMonths(d, n) {
|
|
25
|
-
const t = new Date(d.getFullYear(), d.getMonth() + n, 1);
|
|
26
|
-
const last = new Date(t.getFullYear(), t.getMonth() + 1, 0).getDate();
|
|
27
|
-
return new Date(t.getFullYear(), t.getMonth(), Math.min(d.getDate(), last));
|
|
28
|
-
}
|
|
29
|
-
function same(a, b) {
|
|
30
|
-
return !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
31
|
-
}
|
|
32
|
-
const TAGS = { th: "th-TH", en: "en-GB", sv: "sv-SE" };
|
|
33
|
-
function defaultCalendar(locale) {
|
|
34
|
-
return locale === "th" ? "buddhist" : "gregory";
|
|
35
|
-
}
|
|
36
|
-
function localeTag(locale, calendar) {
|
|
37
|
-
const cal = calendar || defaultCalendar(locale);
|
|
38
|
-
return (TAGS[locale || "en"] || "en-GB") + "-u-ca-" + (cal === "gregory" ? "gregory" : "buddhist");
|
|
39
|
-
}
|
|
40
|
-
const DATE_TEXT = {
|
|
41
|
-
th: {
|
|
42
|
-
prevYears: "\u0E0A\u0E48\u0E27\u0E07\u0E1B\u0E35\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32",
|
|
43
|
-
nextYears: "\u0E0A\u0E48\u0E27\u0E07\u0E1B\u0E35\u0E16\u0E31\u0E14\u0E44\u0E1B",
|
|
44
|
-
prevMonth: "\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32",
|
|
45
|
-
nextMonth: "\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E16\u0E31\u0E14\u0E44\u0E1B",
|
|
46
|
-
today: "\u0E27\u0E31\u0E19\u0E19\u0E35\u0E49",
|
|
47
|
-
clear: "\u0E25\u0E49\u0E32\u0E07",
|
|
48
|
-
chooseDate: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48",
|
|
49
|
-
datePlaceholder: "\u0E27\u0E27/\u0E14\u0E14/\u0E1B\u0E1B\u0E1B\u0E1B",
|
|
50
|
-
clearDate: "\u0E25\u0E49\u0E32\u0E07\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48",
|
|
51
|
-
openCalendar: "\u0E40\u0E1B\u0E34\u0E14\u0E1B\u0E0F\u0E34\u0E17\u0E34\u0E19",
|
|
52
|
-
chooseDates: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E0A\u0E48\u0E27\u0E07\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48",
|
|
53
|
-
rangePlaceholder: "\u0E27\u0E27/\u0E14\u0E14/\u0E1B\u0E1B\u0E1B\u0E1B \u2013 \u0E27\u0E27/\u0E14\u0E14/\u0E1B\u0E1B\u0E1B\u0E1B",
|
|
54
|
-
clearDates: "\u0E25\u0E49\u0E32\u0E07\u0E0A\u0E48\u0E27\u0E07\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48",
|
|
55
|
-
chooseStart: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E27\u0E31\u0E19\u0E40\u0E23\u0E34\u0E48\u0E21\u0E15\u0E49\u0E19",
|
|
56
|
-
chooseEnd: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E27\u0E31\u0E19\u0E2A\u0E34\u0E49\u0E19\u0E2A\u0E38\u0E14"
|
|
57
|
-
},
|
|
58
|
-
en: {
|
|
59
|
-
prevYears: "Previous years",
|
|
60
|
-
nextYears: "Next years",
|
|
61
|
-
prevMonth: "Previous month",
|
|
62
|
-
nextMonth: "Next month",
|
|
63
|
-
today: "Today",
|
|
64
|
-
clear: "Clear",
|
|
65
|
-
chooseDate: "Choose date",
|
|
66
|
-
datePlaceholder: "DD/MM/YYYY",
|
|
67
|
-
clearDate: "Clear date",
|
|
68
|
-
openCalendar: "Open calendar",
|
|
69
|
-
chooseDates: "Choose dates",
|
|
70
|
-
rangePlaceholder: "DD/MM/YYYY \u2013 DD/MM/YYYY",
|
|
71
|
-
clearDates: "Clear dates",
|
|
72
|
-
chooseStart: "Choose the start date",
|
|
73
|
-
chooseEnd: "Choose the end date"
|
|
74
|
-
},
|
|
75
|
-
sv: {
|
|
76
|
-
prevYears: "Tidigare \xE5r",
|
|
77
|
-
nextYears: "Senare \xE5r",
|
|
78
|
-
prevMonth: "F\xF6reg\xE5ende m\xE5nad",
|
|
79
|
-
nextMonth: "N\xE4sta m\xE5nad",
|
|
80
|
-
today: "Idag",
|
|
81
|
-
clear: "Rensa",
|
|
82
|
-
chooseDate: "V\xE4lj datum",
|
|
83
|
-
datePlaceholder: "\xE5\xE5\xE5\xE5-mm-dd",
|
|
84
|
-
clearDate: "Rensa datum",
|
|
85
|
-
openCalendar: "\xD6ppna kalendern",
|
|
86
|
-
chooseDates: "V\xE4lj datum",
|
|
87
|
-
rangePlaceholder: "\xE5\xE5\xE5\xE5-mm-dd \u2013 \xE5\xE5\xE5\xE5-mm-dd",
|
|
88
|
-
clearDates: "Rensa datumen",
|
|
89
|
-
chooseStart: "V\xE4lj startdatum",
|
|
90
|
-
chooseEnd: "V\xE4lj slutdatum"
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
function dateText(locale) {
|
|
94
|
-
return DATE_TEXT[locale || "en"] || DATE_TEXT.en;
|
|
95
|
-
}
|
|
96
|
-
const fmtCache = {};
|
|
97
|
-
const PRESETS = {
|
|
98
|
-
short: { day: "numeric", month: "short", year: "numeric" },
|
|
99
|
-
long: { day: "numeric", month: "long", year: "numeric" },
|
|
100
|
-
numeric: { day: "2-digit", month: "2-digit", year: "numeric" }
|
|
101
|
-
};
|
|
102
|
-
function fmt(tag, opts, d) {
|
|
103
|
-
const k = tag + JSON.stringify(opts);
|
|
104
|
-
if (!fmtCache[k]) fmtCache[k] = new Intl.DateTimeFormat(tag, opts);
|
|
105
|
-
return fmtCache[k].format(d);
|
|
106
|
-
}
|
|
107
|
-
function formatDate(iso, opts) {
|
|
108
|
-
const o = opts || {}, d = fromISO(iso);
|
|
109
|
-
if (!d) return "";
|
|
110
|
-
const f = typeof o.format === "object" ? o.format : PRESETS[o.format || "short"];
|
|
111
|
-
const loc = o.locale || "th";
|
|
112
|
-
return fmt(localeTag(loc, o.calendar || defaultCalendar(loc)), f, d).replace(ERA, "");
|
|
113
|
-
}
|
|
9
|
+
import {
|
|
10
|
+
ERA,
|
|
11
|
+
addDays,
|
|
12
|
+
addMonths,
|
|
13
|
+
dateText,
|
|
14
|
+
defaultCalendar,
|
|
15
|
+
fmt,
|
|
16
|
+
formatDate,
|
|
17
|
+
fromISO,
|
|
18
|
+
localeTag,
|
|
19
|
+
parseDate,
|
|
20
|
+
same,
|
|
21
|
+
toISO
|
|
22
|
+
} from "./dates.js";
|
|
23
|
+
import { formatDate as formatDate2, parseDate as parseDate2 } from "./dates.js";
|
|
114
24
|
function useFormatDate() {
|
|
115
25
|
const ctx = useAuraLocale(), locale = ctx.locale || "en", calendar = ctx.calendar;
|
|
116
26
|
return React.useCallback(
|
|
@@ -127,43 +37,6 @@ function useFormatDate() {
|
|
|
127
37
|
[locale, calendar]
|
|
128
38
|
);
|
|
129
39
|
}
|
|
130
|
-
let MONTHS = null;
|
|
131
|
-
function monthIndex(word) {
|
|
132
|
-
if (!MONTHS) {
|
|
133
|
-
MONTHS = {};
|
|
134
|
-
["th-TH", "en-GB", "sv-SE"].forEach(function(tag) {
|
|
135
|
-
["short", "long"].forEach(function(w) {
|
|
136
|
-
for (let i = 0; i < 12; i++) {
|
|
137
|
-
const n = new Intl.DateTimeFormat(tag, { month: w }).format(new Date(2020, i, 1)).toLowerCase().replace(/\.$/, "");
|
|
138
|
-
MONTHS[n] = i;
|
|
139
|
-
if (/^[a-zåäö]/.test(n)) MONTHS[n.slice(0, 3)] = i;
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
const k = word.toLowerCase().replace(/\.$/, "");
|
|
145
|
-
return MONTHS[k] != null ? MONTHS[k] : -1;
|
|
146
|
-
}
|
|
147
|
-
function parseDate(text) {
|
|
148
|
-
const s = String(text || "").trim();
|
|
149
|
-
let m = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(s), y, mo, d;
|
|
150
|
-
if (m) {
|
|
151
|
-
y = +m[1];
|
|
152
|
-
mo = +m[2];
|
|
153
|
-
d = +m[3];
|
|
154
|
-
} else if (m = /^(\d{1,2})[\/.\-](\d{1,2})[\/.\-](\d{4})$/.exec(s)) {
|
|
155
|
-
d = +m[1];
|
|
156
|
-
mo = +m[2];
|
|
157
|
-
y = +m[3];
|
|
158
|
-
} else if ((m = /^(\d{1,2})\s+(\S+)\s+(\d{4})$/.exec(s.replace(ERA, "").trim())) && monthIndex(m[2]) >= 0) {
|
|
159
|
-
d = +m[1];
|
|
160
|
-
mo = monthIndex(m[2]) + 1;
|
|
161
|
-
y = +m[3];
|
|
162
|
-
} else return null;
|
|
163
|
-
if (y >= 2400) y -= 543;
|
|
164
|
-
const dt = new Date(y, mo - 1, d);
|
|
165
|
-
return dt.getMonth() === mo - 1 && dt.getDate() === d ? toISO(dt) : null;
|
|
166
|
-
}
|
|
167
40
|
const Calendar = React.forwardRef(function Calendar2(props, ref) {
|
|
168
41
|
const ctx = useAuraLocale(), locale = props.locale || ctx.locale || "en", calendar = props.calendar || ctx.calendar || defaultCalendar(locale), tag = localeTag(locale, calendar);
|
|
169
42
|
const weekStart = props.weekStartsOn == null ? locale === "sv" ? 1 : 0 : props.weekStartsOn;
|
|
@@ -721,9 +594,7 @@ export {
|
|
|
721
594
|
Calendar,
|
|
722
595
|
DatePicker,
|
|
723
596
|
DateRangePicker,
|
|
724
|
-
formatDate,
|
|
725
|
-
|
|
726
|
-
parseDate,
|
|
727
|
-
toISO,
|
|
597
|
+
formatDate2 as formatDate,
|
|
598
|
+
parseDate2 as parseDate,
|
|
728
599
|
useFormatDate
|
|
729
600
|
};
|
package/dist/esm/FileUpload.js
CHANGED
|
@@ -5,16 +5,7 @@ import { useStrings } from "./locale.js";
|
|
|
5
5
|
import { Icon } from "./Icon.js";
|
|
6
6
|
import { IconButton } from "./IconButton.js";
|
|
7
7
|
import { Field } from "./Field.js";
|
|
8
|
-
|
|
9
|
-
if (n == null) return "";
|
|
10
|
-
if (n < 1024) return n + " B";
|
|
11
|
-
let u = ["KB", "MB", "GB"], i = -1;
|
|
12
|
-
do {
|
|
13
|
-
n /= 1024;
|
|
14
|
-
i++;
|
|
15
|
-
} while (n >= 1024 && i < u.length - 1);
|
|
16
|
-
return (n >= 10 || Math.round(n) === n ? Math.round(n) : n.toFixed(1)) + " " + u[i];
|
|
17
|
-
}
|
|
8
|
+
import { formatBytes } from "./text.js";
|
|
18
9
|
function matches(file, accept) {
|
|
19
10
|
if (!accept) return true;
|
|
20
11
|
const name = (file.name || "").toLowerCase(), type = (file.type || "").toLowerCase();
|