@jirawatpyk/aura-react 4.18.0 → 4.20.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 +47 -3
- package/dist/aura.bundle.js +698 -298
- package/dist/cjs/index.cjs +697 -297
- package/dist/esm/ActionBar.js +47 -0
- package/dist/esm/AppShell.js +2 -2
- package/dist/esm/BottomNav.js +45 -0
- package/dist/esm/DataTable.js +187 -114
- package/dist/esm/DatePicker.js +33 -11
- package/dist/esm/DropdownMenu.js +1 -0
- package/dist/esm/Menu.js +64 -22
- package/dist/esm/Separator.js +20 -0
- package/dist/esm/Table.js +79 -0
- package/dist/esm/Tabs.js +35 -0
- package/dist/esm/Toaster.js +23 -6
- package/dist/esm/Tooltip.js +21 -3
- package/dist/esm/dates.js +12 -1
- package/dist/esm/index.js +16 -0
- package/dist/esm/locale.js +4 -2
- package/dist/esm/strings.js +3 -0
- package/dist/index.d.ts +163 -10
- package/dist/server/index.cjs +15 -1
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +15 -1
- package/dist/styles.css +184 -55
- package/dist/styles.layer.css +184 -55
- package/package.json +1 -1
package/dist/esm/DatePicker.js
CHANGED
|
@@ -13,20 +13,38 @@ import {
|
|
|
13
13
|
dateText,
|
|
14
14
|
defaultCalendar,
|
|
15
15
|
fmt,
|
|
16
|
-
formatDate,
|
|
16
|
+
formatDate as formatDateBase,
|
|
17
17
|
fromISO,
|
|
18
18
|
localeTag,
|
|
19
19
|
parseDate,
|
|
20
20
|
same,
|
|
21
|
-
toISO
|
|
21
|
+
toISO,
|
|
22
|
+
todayIn
|
|
22
23
|
} from "./dates.js";
|
|
23
|
-
import {
|
|
24
|
+
import { parseDate as parseDate2 } from "./dates.js";
|
|
25
|
+
let warnedNoLocale = false;
|
|
26
|
+
function isDev() {
|
|
27
|
+
try {
|
|
28
|
+
return true;
|
|
29
|
+
} catch (e) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function formatDate(iso, opts) {
|
|
34
|
+
if (!warnedNoLocale && !(opts && opts.locale) && isDev()) {
|
|
35
|
+
warnedNoLocale = true;
|
|
36
|
+
console.warn(
|
|
37
|
+
"[AURA] formatDate() was called without a locale. It shows Thai with Buddhist-era years today; in 5.0 it will show English with Gregorian years, like '@jirawatpyk/aura-react/server'. Pass { locale: 'th' } to keep Thai, or use useFormatDate() in components."
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return formatDateBase(iso, opts);
|
|
41
|
+
}
|
|
24
42
|
function useFormatDate() {
|
|
25
43
|
const ctx = useAuraLocale(), locale = ctx.locale || "en", calendar = ctx.calendar;
|
|
26
44
|
return React.useCallback(
|
|
27
45
|
function(iso, opts) {
|
|
28
46
|
const o = opts || {}, loc = o.locale || locale;
|
|
29
|
-
return
|
|
47
|
+
return formatDateBase(
|
|
30
48
|
iso,
|
|
31
49
|
Object.assign({}, o, {
|
|
32
50
|
locale: loc,
|
|
@@ -40,9 +58,9 @@ function useFormatDate() {
|
|
|
40
58
|
const Calendar = React.forwardRef(function Calendar2(props, ref) {
|
|
41
59
|
const ctx = useAuraLocale(), locale = props.locale || ctx.locale || "en", calendar = props.calendar || ctx.calendar || defaultCalendar(locale), tag = localeTag(locale, calendar);
|
|
42
60
|
const weekStart = props.weekStartsOn == null ? locale === "sv" ? 1 : 0 : props.weekStartsOn;
|
|
43
|
-
|
|
44
|
-
today =
|
|
45
|
-
const min = fromISO(props.min), max = fromISO(props.max);
|
|
61
|
+
const todayISO = props.today || todayIn(props.timeZone || ctx.timeZone);
|
|
62
|
+
const today = fromISO(todayISO);
|
|
63
|
+
const min = fromISO(props.min === "today" ? todayISO : props.min), max = fromISO(props.max === "today" ? todayISO : props.max);
|
|
46
64
|
const start = fromISO(props.start), end = fromISO(props.end);
|
|
47
65
|
const focusState = React.useState(fromISO(props.focus) || start || today);
|
|
48
66
|
const focusDate = focusState[0], setFocus = focusState[1];
|
|
@@ -428,6 +446,8 @@ const DatePicker = React.forwardRef(function DatePicker2(props, ref) {
|
|
|
428
446
|
weekStartsOn: props.weekStartsOn,
|
|
429
447
|
min: props.min,
|
|
430
448
|
max: props.max,
|
|
449
|
+
timeZone: props.timeZone,
|
|
450
|
+
today: props.today,
|
|
431
451
|
isDateDisabled: props.isDateDisabled,
|
|
432
452
|
start: st[0],
|
|
433
453
|
focus: st[0],
|
|
@@ -456,7 +476,7 @@ const DatePicker = React.forwardRef(function DatePicker2(props, ref) {
|
|
|
456
476
|
boxRef,
|
|
457
477
|
inputRef: inputMerged,
|
|
458
478
|
open: pop.open,
|
|
459
|
-
display:
|
|
479
|
+
display: formatDateBase(st[0], { locale, calendar }),
|
|
460
480
|
placeholder: props.placeholder || dt.datePlaceholder,
|
|
461
481
|
hasValue: st[0] != null,
|
|
462
482
|
clearable: props.clearable,
|
|
@@ -490,8 +510,8 @@ const DateRangePicker = React.forwardRef(
|
|
|
490
510
|
const o = { locale, calendar };
|
|
491
511
|
function show(r) {
|
|
492
512
|
if (!r.start) return "";
|
|
493
|
-
if (!r.end) return
|
|
494
|
-
return
|
|
513
|
+
if (!r.end) return formatDateBase(r.start, o) + " \u2013";
|
|
514
|
+
return formatDateBase(r.start, o) + " \u2013 " + formatDateBase(r.end, o);
|
|
495
515
|
}
|
|
496
516
|
function commit(text) {
|
|
497
517
|
const parts = String(text).split(/\s[–-]\s|\s*–\s*/);
|
|
@@ -544,6 +564,8 @@ const DateRangePicker = React.forwardRef(
|
|
|
544
564
|
weekStartsOn: props.weekStartsOn,
|
|
545
565
|
min: props.min,
|
|
546
566
|
max: props.max,
|
|
567
|
+
timeZone: props.timeZone,
|
|
568
|
+
today: props.today,
|
|
547
569
|
isDateDisabled: props.isDateDisabled,
|
|
548
570
|
start: draft[0] || v.start,
|
|
549
571
|
end: draft[0] ? null : v.end,
|
|
@@ -594,7 +616,7 @@ export {
|
|
|
594
616
|
Calendar,
|
|
595
617
|
DatePicker,
|
|
596
618
|
DateRangePicker,
|
|
597
|
-
|
|
619
|
+
formatDate,
|
|
598
620
|
parseDate2 as parseDate,
|
|
599
621
|
useFormatDate
|
|
600
622
|
};
|
package/dist/esm/DropdownMenu.js
CHANGED
|
@@ -23,6 +23,7 @@ const DropdownMenu = React.forwardRef(function DropdownMenu2(props, ref) {
|
|
|
23
23
|
anchor,
|
|
24
24
|
label: props.label,
|
|
25
25
|
items: props.items,
|
|
26
|
+
linkComponent: props.linkComponent,
|
|
26
27
|
onClose: function(restore) {
|
|
27
28
|
setAnchor(null);
|
|
28
29
|
if (restore && typeof anchor.focus === "function") anchor.focus();
|
package/dist/esm/Menu.js
CHANGED
|
@@ -3,12 +3,14 @@ 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
|
+
import { useLinkComponent } from "./locale.js";
|
|
6
7
|
const Menu = React.forwardRef(function Menu2(props, ref) {
|
|
7
8
|
const own = React.useRef(null), merged = useMergedRef(ref, own);
|
|
8
9
|
const posState = React.useState(null);
|
|
9
10
|
const pos = posState[0], setPos = posState[1];
|
|
10
11
|
const items = props.items || [];
|
|
11
12
|
const mounted = useMounted();
|
|
13
|
+
const Link = useLinkComponent(props.linkComponent);
|
|
12
14
|
useIsoLayoutEffect(
|
|
13
15
|
function() {
|
|
14
16
|
const a = props.anchor, m = own.current;
|
|
@@ -69,6 +71,63 @@ const Menu = React.forwardRef(function Menu2(props, ref) {
|
|
|
69
71
|
}
|
|
70
72
|
e.stopPropagation();
|
|
71
73
|
}
|
|
74
|
+
function groupItems(list) {
|
|
75
|
+
const out = [];
|
|
76
|
+
list.forEach(function(it, i) {
|
|
77
|
+
const g = it.type === "radio" && it.group ? it.group : null;
|
|
78
|
+
const last = out[out.length - 1];
|
|
79
|
+
if (last && last.group === g && g !== null) last.items.push({ it, i });
|
|
80
|
+
else out.push({ group: g, items: [{ it, i }] });
|
|
81
|
+
});
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
function renderItem(it, i) {
|
|
85
|
+
if (it.separator) return /* @__PURE__ */ React.createElement("div", { key: "s" + i, role: "separator", className: "aura-menu__sep" });
|
|
86
|
+
const isRadio = it.type === "radio";
|
|
87
|
+
const isCheck = !isRadio && it.checked !== void 0;
|
|
88
|
+
const lead = isRadio ? /* @__PURE__ */ React.createElement("span", { className: cx("aura-menu__radio", it.checked && "is-on") }) : 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" });
|
|
89
|
+
const body = [
|
|
90
|
+
/* @__PURE__ */ React.createElement(React.Fragment, { key: "l" }, lead),
|
|
91
|
+
/* @__PURE__ */ React.createElement("span", { key: "t", className: "aura-menu__label" }, it.label),
|
|
92
|
+
it.hint ? /* @__PURE__ */ React.createElement("span", { key: "h", className: "aura-menu__hint" }, it.hint) : null
|
|
93
|
+
];
|
|
94
|
+
const cls = cx("aura-menu__item", it.tone === "danger" && "aura-menu__item--danger");
|
|
95
|
+
if (it.href && !it.disabled)
|
|
96
|
+
return /* @__PURE__ */ React.createElement(
|
|
97
|
+
Link,
|
|
98
|
+
{
|
|
99
|
+
key: i,
|
|
100
|
+
href: it.href,
|
|
101
|
+
target: it.target,
|
|
102
|
+
rel: it.target === "_blank" ? "noreferrer" : void 0,
|
|
103
|
+
tabIndex: -1,
|
|
104
|
+
role: "menuitem",
|
|
105
|
+
className: cls,
|
|
106
|
+
onClick: function() {
|
|
107
|
+
if (it.onSelect) it.onSelect();
|
|
108
|
+
props.onClose(false);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
body
|
|
112
|
+
);
|
|
113
|
+
return /* @__PURE__ */ React.createElement(
|
|
114
|
+
"button",
|
|
115
|
+
{
|
|
116
|
+
key: i,
|
|
117
|
+
type: "button",
|
|
118
|
+
tabIndex: -1,
|
|
119
|
+
disabled: it.disabled,
|
|
120
|
+
role: isRadio ? "menuitemradio" : isCheck ? "menuitemcheckbox" : "menuitem",
|
|
121
|
+
"aria-checked": isRadio || isCheck ? !!it.checked : void 0,
|
|
122
|
+
className: cls,
|
|
123
|
+
onClick: function() {
|
|
124
|
+
if (it.onSelect) it.onSelect();
|
|
125
|
+
if (!it.keepOpen) props.onClose(true);
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
body
|
|
129
|
+
);
|
|
130
|
+
}
|
|
72
131
|
const el = /* @__PURE__ */ React.createElement(
|
|
73
132
|
"div",
|
|
74
133
|
{
|
|
@@ -79,28 +138,11 @@ const Menu = React.forwardRef(function Menu2(props, ref) {
|
|
|
79
138
|
onKeyDown,
|
|
80
139
|
style: { top: pos ? pos.top : -9999, left: pos ? pos.left : -9999 }
|
|
81
140
|
},
|
|
82
|
-
items.map(function(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
);
|
|
141
|
+
groupItems(items).map(function(block, bi) {
|
|
142
|
+
const rendered = block.items.map(function(x) {
|
|
143
|
+
return renderItem(x.it, x.i);
|
|
144
|
+
});
|
|
145
|
+
return block.group ? /* @__PURE__ */ React.createElement("div", { key: "g" + bi, role: "group", "aria-label": block.group, className: "aura-menu__group" }, rendered) : /* @__PURE__ */ React.createElement(React.Fragment, { key: "f" + bi }, rendered);
|
|
104
146
|
})
|
|
105
147
|
);
|
|
106
148
|
return mounted ? createPortal(el, document.body) : null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cx } from "./internal.js";
|
|
4
|
+
const Separator = React.forwardRef(function Separator2(props, ref) {
|
|
5
|
+
const vertical = props.orientation === "vertical";
|
|
6
|
+
const decorative = props.decorative !== false;
|
|
7
|
+
return /* @__PURE__ */ React.createElement(
|
|
8
|
+
"div",
|
|
9
|
+
{
|
|
10
|
+
ref,
|
|
11
|
+
className: cx("aura-separator", vertical && "aura-separator--vertical", props.className),
|
|
12
|
+
role: decorative ? "none" : "separator",
|
|
13
|
+
"aria-orientation": !decorative && vertical ? "vertical" : void 0,
|
|
14
|
+
style: props.spacing != null ? { ["--aura-separator-space"]: "var(--aura-space-" + props.spacing + ")" } : void 0
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
Separator
|
|
20
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cx, uid, useIsoLayoutEffect } from "./internal.js";
|
|
4
|
+
const Table = React.forwardRef(function Table2(props, ref) {
|
|
5
|
+
const { caption, captionHidden, density, className, children, ...rest } = props;
|
|
6
|
+
const capId = uid();
|
|
7
|
+
const wrap = React.useRef(null);
|
|
8
|
+
const sc = React.useState(false), scrolls = sc[0];
|
|
9
|
+
useIsoLayoutEffect(function() {
|
|
10
|
+
const el = wrap.current;
|
|
11
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
12
|
+
function check() {
|
|
13
|
+
sc[1](el.scrollWidth > el.clientWidth + 1);
|
|
14
|
+
}
|
|
15
|
+
check();
|
|
16
|
+
const ro = new ResizeObserver(check);
|
|
17
|
+
ro.observe(el);
|
|
18
|
+
return function() {
|
|
19
|
+
ro.disconnect();
|
|
20
|
+
};
|
|
21
|
+
}, []);
|
|
22
|
+
return /* @__PURE__ */ React.createElement(
|
|
23
|
+
"div",
|
|
24
|
+
{
|
|
25
|
+
ref: wrap,
|
|
26
|
+
className: "aura-tbl-wrap",
|
|
27
|
+
"data-density": density,
|
|
28
|
+
tabIndex: scrolls ? 0 : void 0,
|
|
29
|
+
role: scrolls ? "region" : void 0,
|
|
30
|
+
"aria-labelledby": scrolls && caption != null ? capId : void 0
|
|
31
|
+
},
|
|
32
|
+
/* @__PURE__ */ React.createElement("table", { ref, className: cx("aura-tbl", className), ...rest }, caption != null ? /* @__PURE__ */ React.createElement("caption", { id: capId, className: cx("aura-tbl__caption", captionHidden && "aura-sr-only") }, caption) : null, children)
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
function section(tag, cls) {
|
|
36
|
+
const C = React.forwardRef(function TableSection(props, ref) {
|
|
37
|
+
const { className, ...rest } = props;
|
|
38
|
+
return React.createElement(tag, Object.assign({ ref, className: cx(cls, className) }, rest));
|
|
39
|
+
});
|
|
40
|
+
return C;
|
|
41
|
+
}
|
|
42
|
+
const THead = section("thead", "aura-tbl__head");
|
|
43
|
+
THead.displayName = "THead";
|
|
44
|
+
const TBody = section("tbody", "aura-tbl__body");
|
|
45
|
+
TBody.displayName = "TBody";
|
|
46
|
+
const TFoot = section("tfoot", "aura-tbl__foot");
|
|
47
|
+
TFoot.displayName = "TFoot";
|
|
48
|
+
const Tr = React.forwardRef(function Tr2(props, ref) {
|
|
49
|
+
const { className, ...rest } = props;
|
|
50
|
+
return /* @__PURE__ */ React.createElement("tr", { ref, className: cx("aura-tbl__row", className), ...rest });
|
|
51
|
+
});
|
|
52
|
+
function cellClass(base, p) {
|
|
53
|
+
const align = p.align || (p.numeric ? "end" : void 0);
|
|
54
|
+
return cx(
|
|
55
|
+
base,
|
|
56
|
+
align === "end" && "is-end",
|
|
57
|
+
align === "center" && "is-center",
|
|
58
|
+
p.numeric && "is-numeric",
|
|
59
|
+
p.mono && "aura-table__mono",
|
|
60
|
+
p.className
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
const Th = React.forwardRef(function Th2(props, ref) {
|
|
64
|
+
const { align, numeric, mono, className, scope, ...rest } = props;
|
|
65
|
+
return /* @__PURE__ */ React.createElement("th", { ref, scope: scope || "col", className: cellClass("aura-tbl__th", props), ...rest });
|
|
66
|
+
});
|
|
67
|
+
const Td = React.forwardRef(function Td2(props, ref) {
|
|
68
|
+
const { align, numeric, mono, className, scope, ...rest } = props;
|
|
69
|
+
return /* @__PURE__ */ React.createElement("td", { ref, className: cellClass("aura-tbl__td", props), ...rest });
|
|
70
|
+
});
|
|
71
|
+
export {
|
|
72
|
+
TBody,
|
|
73
|
+
TFoot,
|
|
74
|
+
THead,
|
|
75
|
+
Table,
|
|
76
|
+
Td,
|
|
77
|
+
Th,
|
|
78
|
+
Tr
|
|
79
|
+
};
|
package/dist/esm/Tabs.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Icon } from "./Icon.js";
|
|
4
4
|
import { cx, uid, useMaybeControlled } from "./internal.js";
|
|
5
|
+
import { useLinkComponent } from "./locale.js";
|
|
5
6
|
const Tabs = React.forwardRef(function Tabs2(props, ref) {
|
|
6
7
|
const items = props.tabs || [], base = uid();
|
|
7
8
|
const st = useMaybeControlled(
|
|
@@ -13,6 +14,40 @@ const Tabs = React.forwardRef(function Tabs2(props, ref) {
|
|
|
13
14
|
const current = items.filter(function(t) {
|
|
14
15
|
return t.id === st[0];
|
|
15
16
|
})[0] || items[0];
|
|
17
|
+
const Link = useLinkComponent(props.linkComponent);
|
|
18
|
+
const asLinks = items.length > 0 && items.every(function(t) {
|
|
19
|
+
return !!t.href;
|
|
20
|
+
});
|
|
21
|
+
if (asLinks)
|
|
22
|
+
return /* @__PURE__ */ React.createElement(
|
|
23
|
+
"nav",
|
|
24
|
+
{
|
|
25
|
+
ref,
|
|
26
|
+
"aria-label": props.label,
|
|
27
|
+
className: cx("aura-tabs aura-tabs--links", props.className)
|
|
28
|
+
},
|
|
29
|
+
/* @__PURE__ */ React.createElement("div", { className: "aura-tabs__list" }, items.map(function(t) {
|
|
30
|
+
const on = current && t.id === current.id;
|
|
31
|
+
const inner = [
|
|
32
|
+
t.icon ? /* @__PURE__ */ React.createElement(Icon, { key: "i", name: t.icon }) : null,
|
|
33
|
+
t.label,
|
|
34
|
+
t.count != null ? /* @__PURE__ */ React.createElement("span", { key: "c", className: "aura-tab__count" }, t.count) : null
|
|
35
|
+
];
|
|
36
|
+
return t.disabled ? /* @__PURE__ */ React.createElement("span", { key: t.id, className: "aura-tab is-disabled", "aria-disabled": true }, inner) : /* @__PURE__ */ React.createElement(
|
|
37
|
+
Link,
|
|
38
|
+
{
|
|
39
|
+
key: t.id,
|
|
40
|
+
href: t.href,
|
|
41
|
+
className: cx("aura-tab", on && "is-active"),
|
|
42
|
+
"aria-current": on ? "page" : void 0,
|
|
43
|
+
onClick: function() {
|
|
44
|
+
st[1](t.id);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
inner
|
|
48
|
+
);
|
|
49
|
+
}))
|
|
50
|
+
);
|
|
16
51
|
function go(i) {
|
|
17
52
|
const enabled = items.filter(function(t2) {
|
|
18
53
|
return !t2.disabled;
|
package/dist/esm/Toaster.js
CHANGED
|
@@ -6,11 +6,19 @@ import { IconButton } from "./IconButton.js";
|
|
|
6
6
|
import { cx, useMounted } from "./internal.js";
|
|
7
7
|
import { useStrings } from "./locale.js";
|
|
8
8
|
import { createPortal } from "react-dom";
|
|
9
|
+
const MAX_VISIBLE = 3;
|
|
9
10
|
const toastState = {
|
|
10
11
|
list: [],
|
|
12
|
+
queue: [],
|
|
11
13
|
subs: [],
|
|
12
14
|
n: 0
|
|
13
15
|
};
|
|
16
|
+
function promote() {
|
|
17
|
+
while (toastState.list.length < MAX_VISIBLE && toastState.queue.length) {
|
|
18
|
+
toastState.list = toastState.list.concat([toastState.queue[0]]);
|
|
19
|
+
toastState.queue = toastState.queue.slice(1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
14
22
|
function emitToasts() {
|
|
15
23
|
toastState.subs.forEach(function(f) {
|
|
16
24
|
f(toastState.list.slice());
|
|
@@ -18,18 +26,24 @@ function emitToasts() {
|
|
|
18
26
|
}
|
|
19
27
|
function show(opts) {
|
|
20
28
|
const id = opts.id || "t" + ++toastState.n;
|
|
21
|
-
const
|
|
29
|
+
const byId = function(t) {
|
|
22
30
|
return t.id === id;
|
|
23
|
-
}
|
|
31
|
+
};
|
|
32
|
+
const at = toastState.list.findIndex(byId), queued = toastState.queue.findIndex(byId);
|
|
33
|
+
const prev = at >= 0 ? toastState.list[at] : queued >= 0 ? toastState.queue[queued] : null;
|
|
24
34
|
const entry = Object.assign({ tone: "info" }, opts, {
|
|
25
35
|
id,
|
|
26
36
|
loading: !!opts.loading,
|
|
27
|
-
rev:
|
|
37
|
+
rev: prev ? prev.rev + 1 : 0
|
|
28
38
|
});
|
|
29
39
|
if (at >= 0) {
|
|
30
40
|
toastState.list = toastState.list.slice();
|
|
31
41
|
toastState.list[at] = entry;
|
|
32
|
-
} else
|
|
42
|
+
} else if (queued >= 0) {
|
|
43
|
+
toastState.queue = toastState.queue.slice();
|
|
44
|
+
toastState.queue[queued] = entry;
|
|
45
|
+
} else if (toastState.list.length < MAX_VISIBLE) toastState.list = toastState.list.concat([entry]);
|
|
46
|
+
else toastState.queue = toastState.queue.concat([entry]);
|
|
33
47
|
emitToasts();
|
|
34
48
|
return id;
|
|
35
49
|
}
|
|
@@ -51,9 +65,12 @@ toast.loading = function(title, opts) {
|
|
|
51
65
|
);
|
|
52
66
|
};
|
|
53
67
|
toast.dismiss = function(id) {
|
|
54
|
-
|
|
68
|
+
const keep = function(t) {
|
|
55
69
|
return t.id !== id;
|
|
56
|
-
}
|
|
70
|
+
};
|
|
71
|
+
toastState.list = toastState.list.filter(keep);
|
|
72
|
+
toastState.queue = toastState.queue.filter(keep);
|
|
73
|
+
promote();
|
|
57
74
|
emitToasts();
|
|
58
75
|
};
|
|
59
76
|
function ToastItem(props) {
|
package/dist/esm/Tooltip.js
CHANGED
|
@@ -23,9 +23,27 @@ const Tooltip = React.forwardRef(function Tooltip2(props, ref) {
|
|
|
23
23
|
function() {
|
|
24
24
|
if (!open || !anchor.current || !tip.current) return;
|
|
25
25
|
const r = anchor.current.getBoundingClientRect(), t = tip.current.getBoundingClientRect();
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const vw = window.innerWidth, vh = window.innerHeight, gap = 8, m = 8;
|
|
27
|
+
let side = props.side || "top";
|
|
28
|
+
if (side === "top" && r.top - t.height - gap < m && r.bottom + gap + t.height <= vh - m) side = "bottom";
|
|
29
|
+
else if (side === "bottom" && r.bottom + gap + t.height > vh - m && r.top - t.height - gap >= m) side = "top";
|
|
30
|
+
else if (side === "left" && r.left - t.width - gap < m && r.right + gap + t.width <= vw - m) side = "right";
|
|
31
|
+
else if (side === "right" && r.right + gap + t.width > vw - m && r.left - t.width - gap >= m) side = "left";
|
|
32
|
+
const clampX = function(x) {
|
|
33
|
+
return Math.max(m, Math.min(x, vw - t.width - m));
|
|
34
|
+
};
|
|
35
|
+
const clampY = function(y) {
|
|
36
|
+
return Math.max(m, Math.min(y, vh - t.height - m));
|
|
37
|
+
};
|
|
38
|
+
let top, left;
|
|
39
|
+
if (side === "top" || side === "bottom") {
|
|
40
|
+
top = side === "top" ? r.top - t.height - gap : r.bottom + gap;
|
|
41
|
+
left = clampX(r.left + r.width / 2 - t.width / 2);
|
|
42
|
+
} else {
|
|
43
|
+
left = side === "left" ? r.left - t.width - gap : r.right + gap;
|
|
44
|
+
left = clampX(left);
|
|
45
|
+
top = clampY(r.top + r.height / 2 - t.height / 2);
|
|
46
|
+
}
|
|
29
47
|
pos[1]({ top, left });
|
|
30
48
|
},
|
|
31
49
|
[open]
|
package/dist/esm/dates.js
CHANGED
|
@@ -141,6 +141,16 @@ function parseDate(text) {
|
|
|
141
141
|
const dt = new Date(y, mo - 1, d);
|
|
142
142
|
return dt.getMonth() === mo - 1 && dt.getDate() === d ? toISO(dt) : null;
|
|
143
143
|
}
|
|
144
|
+
function todayIn(timeZone) {
|
|
145
|
+
const now = /* @__PURE__ */ new Date();
|
|
146
|
+
if (!timeZone) return toISO(now);
|
|
147
|
+
return new Intl.DateTimeFormat("en-CA", {
|
|
148
|
+
timeZone,
|
|
149
|
+
year: "numeric",
|
|
150
|
+
month: "2-digit",
|
|
151
|
+
day: "2-digit"
|
|
152
|
+
}).format(now);
|
|
153
|
+
}
|
|
144
154
|
export {
|
|
145
155
|
DATE_TEXT,
|
|
146
156
|
ERA,
|
|
@@ -160,5 +170,6 @@ export {
|
|
|
160
170
|
pad,
|
|
161
171
|
parseDate,
|
|
162
172
|
same,
|
|
163
|
-
toISO
|
|
173
|
+
toISO,
|
|
174
|
+
todayIn
|
|
164
175
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import { RadioGroup } from "./RadioGroup.js";
|
|
|
14
14
|
import { Switch } from "./Switch.js";
|
|
15
15
|
import { Combobox, defaultFilter } from "./Combobox.js";
|
|
16
16
|
import { DatePicker, DateRangePicker, Calendar, formatDate, parseDate, useFormatDate } from "./DatePicker.js";
|
|
17
|
+
import { todayIn } from "./dates.js";
|
|
17
18
|
import { Alert } from "./Alert.js";
|
|
18
19
|
import { Toaster, toast } from "./Toaster.js";
|
|
19
20
|
import { PasswordField } from "./PasswordField.js";
|
|
@@ -32,6 +33,10 @@ import { Stack } from "./Stack.js";
|
|
|
32
33
|
import { Grid } from "./Grid.js";
|
|
33
34
|
import { Container } from "./Container.js";
|
|
34
35
|
import { AppShell } from "./AppShell.js";
|
|
36
|
+
import { ActionBar } from "./ActionBar.js";
|
|
37
|
+
import { Separator } from "./Separator.js";
|
|
38
|
+
import { Table, THead, TBody, TFoot, Tr, Th, Td } from "./Table.js";
|
|
39
|
+
import { BottomNav } from "./BottomNav.js";
|
|
35
40
|
import { useBreakpoint, useResponsive, breakpoints } from "./responsive.js";
|
|
36
41
|
import { Surface } from "./Surface.js";
|
|
37
42
|
import { AuraProvider, useAuraLocale, useDensity, STRINGS } from "./locale.js";
|
|
@@ -54,11 +59,13 @@ import { Stepper } from "./Stepper.js";
|
|
|
54
59
|
import { SegmentedControl } from "./SegmentedControl.js";
|
|
55
60
|
export {
|
|
56
61
|
Accordion,
|
|
62
|
+
ActionBar,
|
|
57
63
|
Alert,
|
|
58
64
|
AppShell,
|
|
59
65
|
AuraProvider,
|
|
60
66
|
Avatar,
|
|
61
67
|
Badge,
|
|
68
|
+
BottomNav,
|
|
62
69
|
Breadcrumb,
|
|
63
70
|
Button,
|
|
64
71
|
Calendar,
|
|
@@ -94,6 +101,7 @@ export {
|
|
|
94
101
|
STRINGS,
|
|
95
102
|
SegmentedControl,
|
|
96
103
|
Select,
|
|
104
|
+
Separator,
|
|
97
105
|
SideNav,
|
|
98
106
|
Skeleton,
|
|
99
107
|
Stack,
|
|
@@ -102,14 +110,21 @@ export {
|
|
|
102
110
|
Stepper,
|
|
103
111
|
Surface,
|
|
104
112
|
Switch,
|
|
113
|
+
TBody,
|
|
114
|
+
TFoot,
|
|
115
|
+
THead,
|
|
116
|
+
Table,
|
|
105
117
|
Tabs,
|
|
106
118
|
Tag,
|
|
119
|
+
Td,
|
|
107
120
|
TextField,
|
|
108
121
|
Textarea,
|
|
122
|
+
Th,
|
|
109
123
|
ThemeStyle,
|
|
110
124
|
TimePicker,
|
|
111
125
|
Toaster,
|
|
112
126
|
Tooltip,
|
|
127
|
+
Tr,
|
|
113
128
|
scale as brandScale,
|
|
114
129
|
breakpoints,
|
|
115
130
|
colorSchemeScript,
|
|
@@ -123,6 +138,7 @@ export {
|
|
|
123
138
|
parseTime,
|
|
124
139
|
statusTone,
|
|
125
140
|
toast,
|
|
141
|
+
todayIn,
|
|
126
142
|
useAuraLocale,
|
|
127
143
|
useBreakpoint,
|
|
128
144
|
useColorScheme,
|
package/dist/esm/locale.js
CHANGED
|
@@ -5,6 +5,7 @@ const LocaleContext = React.createContext(null);
|
|
|
5
5
|
function AuraProvider(props) {
|
|
6
6
|
const outer = React.useContext(LocaleContext);
|
|
7
7
|
const density = props.density || outer && outer.density || null;
|
|
8
|
+
const timeZone = props.timeZone || outer && outer.timeZone || null;
|
|
8
9
|
const value = React.useMemo(
|
|
9
10
|
function() {
|
|
10
11
|
const base = props.locale && STRINGS[props.locale] || STRINGS.en;
|
|
@@ -13,10 +14,11 @@ function AuraProvider(props) {
|
|
|
13
14
|
calendar: props.calendar || null,
|
|
14
15
|
strings: props.strings ? Object.assign({}, base, props.strings) : base,
|
|
15
16
|
linkComponent: props.linkComponent || null,
|
|
16
|
-
density
|
|
17
|
+
density,
|
|
18
|
+
timeZone
|
|
17
19
|
};
|
|
18
20
|
},
|
|
19
|
-
[props.locale, props.calendar, props.strings, props.linkComponent, density]
|
|
21
|
+
[props.locale, props.calendar, props.strings, props.linkComponent, density, timeZone]
|
|
20
22
|
);
|
|
21
23
|
return /* @__PURE__ */ React.createElement(LocaleContext.Provider, { value }, props.density ? /* @__PURE__ */ React.createElement("div", { className: "aura-density", "data-density": props.density }, props.children) : props.children);
|
|
22
24
|
}
|
package/dist/esm/strings.js
CHANGED
|
@@ -76,6 +76,7 @@ const STRINGS = {
|
|
|
76
76
|
},
|
|
77
77
|
prevPage: "Previous page",
|
|
78
78
|
nextPage: "Next page",
|
|
79
|
+
totals: "Totals",
|
|
79
80
|
rowCount: function(c) {
|
|
80
81
|
return n(c) + " rows";
|
|
81
82
|
},
|
|
@@ -189,6 +190,7 @@ const STRINGS = {
|
|
|
189
190
|
},
|
|
190
191
|
prevPage: "\u0E2B\u0E19\u0E49\u0E32\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32",
|
|
191
192
|
nextPage: "\u0E2B\u0E19\u0E49\u0E32\u0E16\u0E31\u0E14\u0E44\u0E1B",
|
|
193
|
+
totals: "\u0E23\u0E27\u0E21",
|
|
192
194
|
rowCount: function(c) {
|
|
193
195
|
return n(c) + " \u0E41\u0E16\u0E27";
|
|
194
196
|
},
|
|
@@ -302,6 +304,7 @@ const STRINGS = {
|
|
|
302
304
|
},
|
|
303
305
|
prevPage: "F\xF6reg\xE5ende sida",
|
|
304
306
|
nextPage: "N\xE4sta sida",
|
|
307
|
+
totals: "Summa",
|
|
305
308
|
rowCount: function(c) {
|
|
306
309
|
return nsv(c) + " rader";
|
|
307
310
|
},
|