@jirawatpyk/aura-react 4.9.0 → 4.11.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 +17 -2
- package/dist/aura.bundle.js +910 -463
- package/dist/cjs/index.cjs +910 -463
- package/dist/esm/Breadcrumb.js +3 -2
- package/dist/esm/Button.js +26 -7
- package/dist/esm/DataTable.js +176 -94
- package/dist/esm/DatePicker.js +88 -24
- package/dist/esm/Icon.js +12 -1
- package/dist/esm/IconButton.js +2 -2
- package/dist/esm/Pagination.js +3 -2
- package/dist/esm/SideNav.js +116 -10
- package/dist/esm/Stat.js +7 -3
- package/dist/esm/Switch.js +27 -15
- package/dist/esm/colorScheme.js +8 -1
- package/dist/esm/locale.js +109 -2
- package/dist/esm/theme.js +38 -2
- package/dist/index.d.ts +76 -34
- package/dist/styles.css +71 -5
- package/package.json +1 -1
package/dist/esm/DatePicker.js
CHANGED
|
@@ -29,8 +29,69 @@ function addMonths(d, n) {
|
|
|
29
29
|
function same(a, b) {
|
|
30
30
|
return !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
31
31
|
}
|
|
32
|
+
const TAGS = { th: "th-TH", en: "en-GB", sv: "sv-SE" };
|
|
33
|
+
function defaultCalendar(locale) {
|
|
34
|
+
return locale === "th" ? "buddhist" : "gregory";
|
|
35
|
+
}
|
|
32
36
|
function localeTag(locale, calendar) {
|
|
33
|
-
|
|
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;
|
|
34
95
|
}
|
|
35
96
|
const fmtCache = {};
|
|
36
97
|
const PRESETS = {
|
|
@@ -47,18 +108,19 @@ function formatDate(iso, opts) {
|
|
|
47
108
|
const o = opts || {}, d = fromISO(iso);
|
|
48
109
|
if (!d) return "";
|
|
49
110
|
const f = typeof o.format === "object" ? o.format : PRESETS[o.format || "short"];
|
|
50
|
-
|
|
111
|
+
const loc = o.locale || "th";
|
|
112
|
+
return fmt(localeTag(loc, o.calendar || defaultCalendar(loc)), f, d).replace(ERA, "");
|
|
51
113
|
}
|
|
52
114
|
let MONTHS = null;
|
|
53
115
|
function monthIndex(word) {
|
|
54
116
|
if (!MONTHS) {
|
|
55
117
|
MONTHS = {};
|
|
56
|
-
["th-TH", "en-GB"].forEach(function(tag) {
|
|
118
|
+
["th-TH", "en-GB", "sv-SE"].forEach(function(tag) {
|
|
57
119
|
["short", "long"].forEach(function(w) {
|
|
58
120
|
for (let i = 0; i < 12; i++) {
|
|
59
121
|
const n = new Intl.DateTimeFormat(tag, { month: w }).format(new Date(2020, i, 1)).toLowerCase().replace(/\.$/, "");
|
|
60
122
|
MONTHS[n] = i;
|
|
61
|
-
if (/^[a-
|
|
123
|
+
if (/^[a-zåäö]/.test(n)) MONTHS[n.slice(0, 3)] = i;
|
|
62
124
|
}
|
|
63
125
|
});
|
|
64
126
|
});
|
|
@@ -87,8 +149,8 @@ function parseDate(text) {
|
|
|
87
149
|
return dt.getMonth() === mo - 1 && dt.getDate() === d ? toISO(dt) : null;
|
|
88
150
|
}
|
|
89
151
|
const Calendar = React.forwardRef(function Calendar2(props, ref) {
|
|
90
|
-
const ctx = useAuraLocale(), locale = props.locale || ctx.locale || "
|
|
91
|
-
const weekStart = props.weekStartsOn == null ? 0 : props.weekStartsOn;
|
|
152
|
+
const ctx = useAuraLocale(), locale = props.locale || ctx.locale || "en", calendar = props.calendar || ctx.calendar || defaultCalendar(locale), tag = localeTag(locale, calendar);
|
|
153
|
+
const weekStart = props.weekStartsOn == null ? locale === "sv" ? 1 : 0 : props.weekStartsOn;
|
|
92
154
|
let today = /* @__PURE__ */ new Date();
|
|
93
155
|
today = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
94
156
|
const min = fromISO(props.min), max = fromISO(props.max);
|
|
@@ -98,7 +160,8 @@ const Calendar = React.forwardRef(function Calendar2(props, ref) {
|
|
|
98
160
|
const viewState = React.useState("days"), view = viewState[0], setView = viewState[1];
|
|
99
161
|
const hoverState = React.useState(null);
|
|
100
162
|
const gridRef = React.useRef(null), gridMerged = useMergedRef(ref, gridRef), moved = React.useRef(false);
|
|
101
|
-
const th = locale
|
|
163
|
+
const th = locale === "th";
|
|
164
|
+
const dt = dateText(locale);
|
|
102
165
|
function disabled(d) {
|
|
103
166
|
return !!(min && d < min || max && d > max || props.isDateDisabled && props.isDateDisabled(toISO(d)));
|
|
104
167
|
}
|
|
@@ -164,7 +227,7 @@ const Calendar = React.forwardRef(function Calendar2(props, ref) {
|
|
|
164
227
|
IconButton,
|
|
165
228
|
{
|
|
166
229
|
icon: "chevron-left",
|
|
167
|
-
label:
|
|
230
|
+
label: dt.prevYears,
|
|
168
231
|
onClick: function() {
|
|
169
232
|
setFocus(new Date(yr - 12, focusDate.getMonth(), 1));
|
|
170
233
|
}
|
|
@@ -183,7 +246,7 @@ const Calendar = React.forwardRef(function Calendar2(props, ref) {
|
|
|
183
246
|
IconButton,
|
|
184
247
|
{
|
|
185
248
|
icon: "chevron-right",
|
|
186
|
-
label:
|
|
249
|
+
label: dt.nextYears,
|
|
187
250
|
onClick: function() {
|
|
188
251
|
setFocus(new Date(yr + 12, focusDate.getMonth(), 1));
|
|
189
252
|
}
|
|
@@ -211,7 +274,7 @@ const Calendar = React.forwardRef(function Calendar2(props, ref) {
|
|
|
211
274
|
IconButton,
|
|
212
275
|
{
|
|
213
276
|
icon: "chevron-left",
|
|
214
|
-
label:
|
|
277
|
+
label: dt.prevMonth,
|
|
215
278
|
onClick: function() {
|
|
216
279
|
setFocus(addMonths(focusDate, -1));
|
|
217
280
|
}
|
|
@@ -232,7 +295,7 @@ const Calendar = React.forwardRef(function Calendar2(props, ref) {
|
|
|
232
295
|
IconButton,
|
|
233
296
|
{
|
|
234
297
|
icon: "chevron-right",
|
|
235
|
-
label:
|
|
298
|
+
label: dt.nextMonth,
|
|
236
299
|
onClick: function() {
|
|
237
300
|
setFocus(addMonths(focusDate, 1));
|
|
238
301
|
}
|
|
@@ -271,6 +334,7 @@ const Calendar = React.forwardRef(function Calendar2(props, ref) {
|
|
|
271
334
|
tabIndex: same(d, focusDate) ? 0 : -1,
|
|
272
335
|
disabled: dis,
|
|
273
336
|
"aria-label": fmt(tag, { weekday: "long", day: "numeric", month: "long", year: "numeric" }, d),
|
|
337
|
+
suppressHydrationWarning: true,
|
|
274
338
|
"aria-current": same(d, today) ? "date" : void 0,
|
|
275
339
|
"aria-pressed": sel || void 0,
|
|
276
340
|
className: cx(
|
|
@@ -306,8 +370,8 @@ const Calendar = React.forwardRef(function Calendar2(props, ref) {
|
|
|
306
370
|
props.onSelect(toISO(today));
|
|
307
371
|
}
|
|
308
372
|
},
|
|
309
|
-
|
|
310
|
-
), props.onClear ? /* @__PURE__ */ React.createElement("button", { type: "button", className: "aura-cal__link", onClick: props.onClear },
|
|
373
|
+
dt.today
|
|
374
|
+
), props.onClear ? /* @__PURE__ */ React.createElement("button", { type: "button", className: "aura-cal__link", onClick: props.onClear }, dt.clear) : null));
|
|
311
375
|
});
|
|
312
376
|
function useCalendarPopover(boxRef) {
|
|
313
377
|
const openState = React.useState(false), open = openState[0], setOpen = openState[1];
|
|
@@ -429,7 +493,7 @@ function DateField(props) {
|
|
|
429
493
|
}
|
|
430
494
|
const DatePicker = React.forwardRef(function DatePicker2(props, ref) {
|
|
431
495
|
const auto = uid(), id = props.id || auto, dialogId = id + "-cal";
|
|
432
|
-
const ctx = useAuraLocale(), locale = props.locale || ctx.locale || "
|
|
496
|
+
const ctx = useAuraLocale(), locale = props.locale || ctx.locale || "en", calendar = props.calendar || ctx.calendar || defaultCalendar(locale), dt = dateText(locale);
|
|
433
497
|
const st = useMaybeControlled(
|
|
434
498
|
props.value,
|
|
435
499
|
props.defaultValue == null ? null : props.defaultValue,
|
|
@@ -457,7 +521,7 @@ const DatePicker = React.forwardRef(function DatePicker2(props, ref) {
|
|
|
457
521
|
id: dialogId,
|
|
458
522
|
role: "dialog",
|
|
459
523
|
"aria-modal": false,
|
|
460
|
-
"aria-label": props.label ||
|
|
524
|
+
"aria-label": props.label || dt.chooseDate,
|
|
461
525
|
className: "aura-cal__popover",
|
|
462
526
|
style: pop.pos,
|
|
463
527
|
onKeyDown: function(e) {
|
|
@@ -504,15 +568,15 @@ const DatePicker = React.forwardRef(function DatePicker2(props, ref) {
|
|
|
504
568
|
inputRef: inputMerged,
|
|
505
569
|
open: pop.open,
|
|
506
570
|
display: formatDate(st[0], { locale, calendar }),
|
|
507
|
-
placeholder: props.placeholder ||
|
|
571
|
+
placeholder: props.placeholder || dt.datePlaceholder,
|
|
508
572
|
hasValue: st[0] != null,
|
|
509
573
|
clearable: props.clearable,
|
|
510
574
|
onClear: function() {
|
|
511
575
|
st[1](null);
|
|
512
576
|
inputRef.current && inputRef.current.focus();
|
|
513
577
|
},
|
|
514
|
-
clearLabel:
|
|
515
|
-
toggleLabel:
|
|
578
|
+
clearLabel: dt.clearDate,
|
|
579
|
+
toggleLabel: dt.openCalendar,
|
|
516
580
|
onCommit: commit,
|
|
517
581
|
onToggle: function(o) {
|
|
518
582
|
pop.setOpen(o);
|
|
@@ -524,7 +588,7 @@ const DatePicker = React.forwardRef(function DatePicker2(props, ref) {
|
|
|
524
588
|
const DateRangePicker = React.forwardRef(
|
|
525
589
|
function DateRangePicker2(props, ref) {
|
|
526
590
|
const auto = uid(), id = props.id || auto, dialogId = id + "-cal";
|
|
527
|
-
const ctx = useAuraLocale(), locale = props.locale || ctx.locale || "
|
|
591
|
+
const ctx = useAuraLocale(), locale = props.locale || ctx.locale || "en", calendar = props.calendar || ctx.calendar || defaultCalendar(locale), dt = dateText(locale);
|
|
528
592
|
const st = useMaybeControlled(
|
|
529
593
|
props.value,
|
|
530
594
|
props.defaultValue || { start: null, end: null },
|
|
@@ -571,7 +635,7 @@ const DateRangePicker = React.forwardRef(
|
|
|
571
635
|
id: dialogId,
|
|
572
636
|
role: "dialog",
|
|
573
637
|
"aria-modal": false,
|
|
574
|
-
"aria-label": props.label ||
|
|
638
|
+
"aria-label": props.label || dt.chooseDates,
|
|
575
639
|
className: "aura-cal__popover",
|
|
576
640
|
style: pop.pos,
|
|
577
641
|
onKeyDown: function(e) {
|
|
@@ -581,7 +645,7 @@ const DateRangePicker = React.forwardRef(
|
|
|
581
645
|
} else trapTab(e, pop.popRef.current);
|
|
582
646
|
}
|
|
583
647
|
},
|
|
584
|
-
/* @__PURE__ */ React.createElement("p", { className: "aura-cal__hint", "aria-live": "polite" }, draft[0] ?
|
|
648
|
+
/* @__PURE__ */ React.createElement("p", { className: "aura-cal__hint", "aria-live": "polite" }, draft[0] ? dt.chooseEnd : dt.chooseStart),
|
|
585
649
|
/* @__PURE__ */ React.createElement(
|
|
586
650
|
Calendar,
|
|
587
651
|
{
|
|
@@ -618,15 +682,15 @@ const DateRangePicker = React.forwardRef(
|
|
|
618
682
|
inputRef: inputMerged,
|
|
619
683
|
open: pop.open,
|
|
620
684
|
display: show(v),
|
|
621
|
-
placeholder: props.placeholder ||
|
|
685
|
+
placeholder: props.placeholder || dt.rangePlaceholder,
|
|
622
686
|
hasValue: v.start != null,
|
|
623
687
|
clearable: props.clearable,
|
|
624
688
|
onClear: function() {
|
|
625
689
|
st[1]({ start: null, end: null });
|
|
626
690
|
inputRef.current && inputRef.current.focus();
|
|
627
691
|
},
|
|
628
|
-
clearLabel:
|
|
629
|
-
toggleLabel:
|
|
692
|
+
clearLabel: dt.clearDates,
|
|
693
|
+
toggleLabel: dt.openCalendar,
|
|
630
694
|
onCommit: commit,
|
|
631
695
|
onToggle: function(op) {
|
|
632
696
|
pop.setOpen(op);
|
package/dist/esm/Icon.js
CHANGED
|
@@ -5,9 +5,20 @@ const h = React.createElement;
|
|
|
5
5
|
const ICONS = { "check": [["path", { "d": "M20 6 9 17l-5-5" }]], "x": [["path", { "d": "M18 6 6 18" }], ["path", { "d": "m6 6 12 12" }]], "plus": [["path", { "d": "M5 12h14" }], ["path", { "d": "M12 5v14" }]], "minus": [["path", { "d": "M5 12h14" }]], "search": [["path", { "d": "m21 21-4.34-4.34" }], ["circle", { "cx": "11", "cy": "11", "r": "8" }]], "chevron-down": [["path", { "d": "m6 9 6 6 6-6" }]], "chevron-up": [["path", { "d": "m18 15-6-6-6 6" }]], "chevron-left": [["path", { "d": "m15 18-6-6 6-6" }]], "chevron-right": [["path", { "d": "m9 18 6-6-6-6" }]], "arrow-right": [["path", { "d": "M5 12h14" }], ["path", { "d": "m12 5 7 7-7 7" }]], "arrow-up-right": [["path", { "d": "M7 7h10v10" }], ["path", { "d": "M7 17 17 7" }]], "arrow-up-down": [["path", { "d": "m21 16-4 4-4-4" }], ["path", { "d": "M17 20V4" }], ["path", { "d": "m3 8 4-4 4 4" }], ["path", { "d": "M7 4v16" }]], "loader-circle": [["path", { "d": "M21 12a9 9 0 1 1-6.219-8.56" }]], "circle-alert": [["circle", { "cx": "12", "cy": "12", "r": "10" }], ["line", { "x1": "12", "x2": "12", "y1": "8", "y2": "12" }], ["line", { "x1": "12", "x2": "12.01", "y1": "16", "y2": "16" }]], "circle-check": [["circle", { "cx": "12", "cy": "12", "r": "10" }], ["path", { "d": "m16 9-5.5 5.5L8 12" }]], "info": [["circle", { "cx": "12", "cy": "12", "r": "10" }], ["path", { "d": "M12 16v-4" }], ["path", { "d": "M12 8h.01" }]], "triangle-alert": [["path", { "d": "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" }], ["path", { "d": "M12 9v4" }], ["path", { "d": "M12 17h.01" }]], "settings": [["path", { "d": "M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915" }], ["circle", { "cx": "12", "cy": "12", "r": "3" }]], "user": [["path", { "d": "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" }], ["circle", { "cx": "12", "cy": "7", "r": "4" }]], "users": [["path", { "d": "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" }], ["path", { "d": "M16 3.128a4 4 0 0 1 0 7.744" }], ["path", { "d": "M22 21v-2a4 4 0 0 0-3-3.87" }], ["circle", { "cx": "9", "cy": "7", "r": "4" }]], "filter": [["path", { "d": "M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z" }]], "ellipsis": [["circle", { "cx": "12", "cy": "12", "r": "1" }], ["circle", { "cx": "19", "cy": "12", "r": "1" }], ["circle", { "cx": "5", "cy": "12", "r": "1" }]], "external-link": [["path", { "d": "M15 3h6v6" }], ["path", { "d": "M10 14 21 3" }], ["path", { "d": "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }]], "copy": [["rect", { "width": "14", "height": "14", "x": "8", "y": "8", "rx": "2", "ry": "2" }], ["path", { "d": "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" }]], "trash-2": [["path", { "d": "M10 11v6" }], ["path", { "d": "M14 11v6" }], ["path", { "d": "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }], ["path", { "d": "M3 6h18" }], ["path", { "d": "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }]], "pencil": [["path", { "d": "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" }], ["path", { "d": "m15 5 4 4" }]], "download": [["path", { "d": "M12 15V3" }], ["path", { "d": "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }], ["path", { "d": "m7 10 5 5 5-5" }]], "upload": [["path", { "d": "M12 3v12" }], ["path", { "d": "m17 8-5-5-5 5" }], ["path", { "d": "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }]], "calendar": [["path", { "d": "M8 2v3" }], ["path", { "d": "M16 2v3" }], ["rect", { "x": "3", "y": "3", "width": "18", "height": "18", "rx": "2" }], ["path", { "d": "M3 9h18" }]], "bell": [["path", { "d": "M10.268 21a2 2 0 0 0 3.464 0" }], ["path", { "d": "M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326" }]], "menu": [["path", { "d": "M4 5h16" }], ["path", { "d": "M4 12h16" }], ["path", { "d": "M4 19h16" }]], "eye": [["path", { "d": "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" }], ["circle", { "cx": "12", "cy": "12", "r": "3" }]], "log-out": [["path", { "d": "m16 17 5-5-5-5" }], ["path", { "d": "M21 12H9" }], ["path", { "d": "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }]], "circle": [["circle", { "cx": "12", "cy": "12", "r": "10" }]], "circle-dot-dashed": [["path", { "d": "M10.1 2.18a9.93 9.93 0 0 1 3.8 0" }], ["path", { "d": "M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7" }], ["path", { "d": "M21.82 10.1a9.93 9.93 0 0 1 0 3.8" }], ["path", { "d": "M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69" }], ["path", { "d": "M13.9 21.82a9.94 9.94 0 0 1-3.8 0" }], ["path", { "d": "M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7" }], ["path", { "d": "M2.18 13.9a9.93 9.93 0 0 1 0-3.8" }], ["path", { "d": "M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69" }], ["circle", { "cx": "12", "cy": "12", "r": "1" }]], "ban": [["circle", { "cx": "12", "cy": "12", "r": "10" }], ["path", { "d": "M4.929 4.929 19.07 19.071" }]], "arrow-up": [["path", { "d": "m5 12 7-7 7 7" }], ["path", { "d": "M12 19V5" }]], "arrow-down": [["path", { "d": "M12 5v14" }], ["path", { "d": "m19 12-7 7-7-7" }]], "inbox": [["polyline", { "points": "22 12 16 12 14 15 10 15 8 12 2 12" }], ["path", { "d": "M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" }]], "pin": [["path", { "d": "M12 17v5" }], ["path", { "d": "M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z" }]], "pin-off": [["path", { "d": "M12 17v5" }], ["path", { "d": "M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89" }], ["path", { "d": "m2 2 20 20" }], ["path", { "d": "M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11" }]], "eye-off": [["path", { "d": "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49" }], ["path", { "d": "M14.084 14.158a3 3 0 0 1-4.242-4.242" }], ["path", { "d": "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143" }], ["path", { "d": "m2 2 20 20" }]], "columns-3": [["rect", { "width": "18", "height": "18", "x": "3", "y": "3", "rx": "2" }], ["path", { "d": "M9 3v18" }], ["path", { "d": "M15 3v18" }]], "arrow-left": [["path", { "d": "m12 19-7-7 7-7" }], ["path", { "d": "M19 12H5" }]], "rotate-ccw": [["path", { "d": "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }], ["path", { "d": "M3 3v5h5" }]], "house": [["path", { "d": "M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8" }], ["path", { "d": "M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" }]], "layout-dashboard": [["rect", { "width": "7", "height": "9", "x": "3", "y": "3", "rx": "1" }], ["rect", { "width": "7", "height": "5", "x": "14", "y": "3", "rx": "1" }], ["rect", { "width": "7", "height": "9", "x": "14", "y": "12", "rx": "1" }], ["rect", { "width": "7", "height": "5", "x": "3", "y": "16", "rx": "1" }]], "folder": [["path", { "d": "M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" }]], "chart-column": [["path", { "d": "M3 3v16a2 2 0 0 0 2 2h16" }], ["path", { "d": "M18 17V9" }], ["path", { "d": "M13 17V5" }], ["path", { "d": "M8 17v-3" }]], "file-text": [["path", { "d": "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }], ["path", { "d": "M14 2v5a1 1 0 0 0 1 1h5" }], ["path", { "d": "M10 9H8" }], ["path", { "d": "M16 13H8" }], ["path", { "d": "M16 17H8" }]], "mail": [["path", { "d": "m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7" }], ["rect", { "x": "2", "y": "4", "width": "20", "height": "16", "rx": "2" }]], "lock": [["rect", { "width": "18", "height": "11", "x": "3", "y": "11", "rx": "2", "ry": "2" }], ["path", { "d": "M7 11V7a5 5 0 0 1 10 0v4" }]], "clock": [["circle", { "cx": "12", "cy": "12", "r": "10" }], ["path", { "d": "M12 6v6l4 2" }]], "trending-up": [["path", { "d": "M16 7h6v6" }], ["path", { "d": "m22 7-8.5 8.5-5-5L2 17" }]], "trending-down": [["path", { "d": "M16 17h6v-6" }], ["path", { "d": "m22 17-8.5-8.5-5 5L2 7" }]], "image": [["rect", { "width": "18", "height": "18", "x": "3", "y": "3", "rx": "2", "ry": "2" }], ["circle", { "cx": "9", "cy": "9", "r": "2" }], ["path", { "d": "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" }]], "paperclip": [["path", { "d": "m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551" }]], "cloud-upload": [["path", { "d": "M12 13v8" }], ["path", { "d": "M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242" }], ["path", { "d": "m8 17 4-4 4 4" }]], "file": [["path", { "d": "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }], ["path", { "d": "M14 2v5a1 1 0 0 0 1 1h5" }]], "sun": [["circle", { "cx": "12", "cy": "12", "r": "4" }], ["path", { "d": "M12 2v2" }], ["path", { "d": "M12 20v2" }], ["path", { "d": "m4.93 4.93 1.41 1.41" }], ["path", { "d": "m17.66 17.66 1.41 1.41" }], ["path", { "d": "M2 12h2" }], ["path", { "d": "M20 12h2" }], ["path", { "d": "m6.34 17.66-1.41 1.41" }], ["path", { "d": "m19.07 4.93-1.41 1.41" }]], "moon": [["path", { "d": "M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401" }]], "monitor": [["rect", { "width": "20", "height": "14", "x": "2", "y": "3", "rx": "2" }], ["line", { "x1": "8", "x2": "16", "y1": "21", "y2": "21" }], ["line", { "x1": "12", "x2": "12", "y1": "17", "y2": "21" }]] };
|
|
6
6
|
const SIZES = { sm: 16, md: 20, lg: 24 };
|
|
7
7
|
const Icon = React.forwardRef(function Icon2(props, ref) {
|
|
8
|
+
const size = SIZES[props.size] || props.size || 16;
|
|
9
|
+
if (React.isValidElement(props.name)) {
|
|
10
|
+
return /* @__PURE__ */ React.createElement(
|
|
11
|
+
"span",
|
|
12
|
+
{
|
|
13
|
+
className: cx("aura-icon", "aura-icon--custom", props.className),
|
|
14
|
+
style: { width: size, height: size, ["--aura-icon-stroke"]: props.strokeWidth || 2 },
|
|
15
|
+
...props.label ? { role: "img", "aria-label": props.label } : { "aria-hidden": true }
|
|
16
|
+
},
|
|
17
|
+
props.name
|
|
18
|
+
);
|
|
19
|
+
}
|
|
8
20
|
const shapes = ICONS[props.name];
|
|
9
21
|
if (!shapes) return null;
|
|
10
|
-
const size = SIZES[props.size] || props.size || 16;
|
|
11
22
|
const a11y = props.label ? { role: "img", "aria-label": props.label } : { "aria-hidden": true, focusable: "false" };
|
|
12
23
|
return /* @__PURE__ */ React.createElement(
|
|
13
24
|
"svg",
|
package/dist/esm/IconButton.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import { cx, omit } from "./internal.js";
|
|
4
4
|
import { Icon } from "./Icon.js";
|
|
5
5
|
const IconButton = React.forwardRef(function IconButton2(props, ref) {
|
|
6
|
-
const rest = omit(props, ["icon", "label", "className", "size"]);
|
|
6
|
+
const rest = omit(props, ["icon", "label", "className", "size", "tone"]);
|
|
7
7
|
return /* @__PURE__ */ React.createElement(
|
|
8
8
|
"button",
|
|
9
9
|
{
|
|
@@ -12,7 +12,7 @@ const IconButton = React.forwardRef(function IconButton2(props, ref) {
|
|
|
12
12
|
type: props.type || "button",
|
|
13
13
|
"aria-label": props.label,
|
|
14
14
|
title: props.label,
|
|
15
|
-
className: cx("aura-icon-btn", props.className)
|
|
15
|
+
className: cx("aura-icon-btn", props.tone === "danger" && "aura-icon-btn--danger", props.className)
|
|
16
16
|
},
|
|
17
17
|
/* @__PURE__ */ React.createElement(Icon, { name: props.icon, size: props.size || "sm" })
|
|
18
18
|
);
|
package/dist/esm/Pagination.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { IconButton } from "./IconButton.js";
|
|
4
4
|
import { cx, useMaybeControlled } from "./internal.js";
|
|
5
|
-
import { useStrings } from "./locale.js";
|
|
5
|
+
import { useLinkComponent, useStrings } from "./locale.js";
|
|
6
6
|
function pageList(page, count, sib) {
|
|
7
7
|
let out = [], lo = Math.max(2, page - sib), hi = Math.min(count - 1, page + sib);
|
|
8
8
|
if (page - sib <= 3) {
|
|
@@ -31,6 +31,7 @@ const Pagination = React.forwardRef(function Pagination2(props, ref) {
|
|
|
31
31
|
if (p >= 1 && p <= count && p !== page) st[1](p);
|
|
32
32
|
}
|
|
33
33
|
const link = props.getHref;
|
|
34
|
+
const Link = useLinkComponent();
|
|
34
35
|
function item(p, label, extra) {
|
|
35
36
|
const common = Object.assign(
|
|
36
37
|
{
|
|
@@ -41,7 +42,7 @@ const Pagination = React.forwardRef(function Pagination2(props, ref) {
|
|
|
41
42
|
extra
|
|
42
43
|
);
|
|
43
44
|
return link ? /* @__PURE__ */ React.createElement(
|
|
44
|
-
|
|
45
|
+
Link,
|
|
45
46
|
{
|
|
46
47
|
href: link(p),
|
|
47
48
|
onClick: function(e) {
|
package/dist/esm/SideNav.js
CHANGED
|
@@ -1,35 +1,141 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Icon } from "./Icon.js";
|
|
4
|
-
import { cx, useMaybeControlled } from "./internal.js";
|
|
5
|
-
import { useStrings } from "./locale.js";
|
|
4
|
+
import { cx, uid, useMaybeControlled } from "./internal.js";
|
|
5
|
+
import { useLinkComponent, useStrings } from "./locale.js";
|
|
6
|
+
function contains(it, id) {
|
|
7
|
+
return !!id && !!it.children && it.children.some(function(c) {
|
|
8
|
+
return c.id === id || contains(c, id);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
6
11
|
const SideNav = React.forwardRef(function SideNav2(props, ref) {
|
|
7
12
|
const t = useStrings();
|
|
13
|
+
const Link = useLinkComponent(props.linkComponent);
|
|
14
|
+
const base = uid();
|
|
8
15
|
const st = useMaybeControlled(
|
|
9
16
|
props.value,
|
|
10
17
|
props.defaultValue,
|
|
11
18
|
props.onChange
|
|
12
19
|
);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
const active = st[0];
|
|
21
|
+
const sections = props.sections || [{ items: props.items || [] }];
|
|
22
|
+
const openState = React.useState({}), toggled = openState[0], setToggled = openState[1];
|
|
23
|
+
function isOpen(it) {
|
|
24
|
+
if (toggled[it.id] != null) return toggled[it.id];
|
|
25
|
+
return !!it.defaultOpen || contains(it, active);
|
|
26
|
+
}
|
|
27
|
+
React.useEffect(
|
|
28
|
+
function() {
|
|
29
|
+
if (!active) return;
|
|
30
|
+
const next = {};
|
|
31
|
+
let changed = false;
|
|
32
|
+
sections.forEach(function(s) {
|
|
33
|
+
(function walk(list) {
|
|
34
|
+
list.forEach(function(it) {
|
|
35
|
+
if (it.children) {
|
|
36
|
+
if (contains(it, active) && toggled[it.id] !== true) {
|
|
37
|
+
next[it.id] = true;
|
|
38
|
+
changed = true;
|
|
39
|
+
}
|
|
40
|
+
walk(it.children);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
})(s.items);
|
|
44
|
+
});
|
|
45
|
+
if (changed) setToggled(Object.assign({}, toggled, next));
|
|
46
|
+
},
|
|
47
|
+
[active]
|
|
48
|
+
);
|
|
49
|
+
const navRef = React.useRef(null);
|
|
50
|
+
function onKeyDown(e) {
|
|
51
|
+
const k = e.key;
|
|
52
|
+
if (k !== "ArrowDown" && k !== "ArrowUp" && k !== "Home" && k !== "End") return;
|
|
53
|
+
const root = navRef.current;
|
|
54
|
+
if (!root) return;
|
|
55
|
+
const items = Array.prototype.slice.call(root.querySelectorAll(".aura-nav__item"));
|
|
56
|
+
const visible = items.filter(function(el) {
|
|
57
|
+
return el.offsetParent !== null || el === document.activeElement;
|
|
58
|
+
});
|
|
59
|
+
const i = visible.indexOf(document.activeElement);
|
|
60
|
+
if (i < 0) return;
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
const j = k === "Home" ? 0 : k === "End" ? visible.length - 1 : Math.max(0, Math.min(visible.length - 1, i + (k === "ArrowDown" ? 1 : -1)));
|
|
63
|
+
visible[j].focus();
|
|
64
|
+
}
|
|
65
|
+
function inner(it, group, open) {
|
|
66
|
+
return [
|
|
16
67
|
it.icon ? /* @__PURE__ */ React.createElement(Icon, { key: "i", name: it.icon }) : null,
|
|
17
68
|
/* @__PURE__ */ React.createElement("span", { key: "l", className: "aura-nav__label" }, it.label),
|
|
18
|
-
it.
|
|
69
|
+
it.badge != null ? /* @__PURE__ */ React.createElement("span", { key: "b", className: "aura-nav__badge" }, it.badge) : null,
|
|
70
|
+
it.count != null ? /* @__PURE__ */ React.createElement("span", { key: "c", className: "aura-nav__count" }, it.count) : null,
|
|
71
|
+
group ? /* @__PURE__ */ React.createElement(Icon, { key: "g", name: "chevron-down", className: cx("aura-nav__chevron", open && "is-open") }) : null
|
|
19
72
|
];
|
|
73
|
+
}
|
|
74
|
+
function item(it, depth) {
|
|
75
|
+
if (it.children) {
|
|
76
|
+
const open = isOpen(it);
|
|
77
|
+
const listId = base + "-" + it.id;
|
|
78
|
+
const holdsActive = contains(it, active);
|
|
79
|
+
return /* @__PURE__ */ React.createElement("li", { key: it.id, className: "aura-nav__group" }, /* @__PURE__ */ React.createElement(
|
|
80
|
+
"button",
|
|
81
|
+
{
|
|
82
|
+
type: "button",
|
|
83
|
+
className: cx("aura-nav__item", "aura-nav__item--group", holdsActive && "has-active"),
|
|
84
|
+
"aria-expanded": open,
|
|
85
|
+
"aria-controls": listId,
|
|
86
|
+
style: depth ? { ["--aura-nav-depth"]: depth } : void 0,
|
|
87
|
+
onClick: function() {
|
|
88
|
+
const next = Object.assign({}, toggled);
|
|
89
|
+
next[it.id] = !open;
|
|
90
|
+
setToggled(next);
|
|
91
|
+
},
|
|
92
|
+
onKeyDown: function(e) {
|
|
93
|
+
if (e.key === "ArrowRight" && !open) {
|
|
94
|
+
e.preventDefault();
|
|
95
|
+
setToggled(Object.assign({}, toggled, { [it.id]: true }));
|
|
96
|
+
} else if (e.key === "ArrowLeft" && open) {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
setToggled(Object.assign({}, toggled, { [it.id]: false }));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
inner(it, true, open)
|
|
103
|
+
), /* @__PURE__ */ React.createElement("ul", { id: listId, className: "aura-nav__list aura-nav__sub", hidden: !open }, it.children.map(function(c) {
|
|
104
|
+
return item(c, depth + 1);
|
|
105
|
+
})));
|
|
106
|
+
}
|
|
107
|
+
const on = active === it.id;
|
|
20
108
|
const common = {
|
|
21
109
|
className: cx("aura-nav__item", on && "is-active"),
|
|
22
110
|
"aria-current": on ? "page" : void 0,
|
|
111
|
+
style: depth ? { ["--aura-nav-depth"]: depth } : void 0,
|
|
23
112
|
onClick: function(e) {
|
|
24
113
|
if (!it.href) e.preventDefault();
|
|
25
114
|
st[1](it.id);
|
|
26
115
|
}
|
|
27
116
|
};
|
|
28
|
-
return /* @__PURE__ */ React.createElement("li", { key: it.id }, it.href ? /* @__PURE__ */ React.createElement(
|
|
117
|
+
return /* @__PURE__ */ React.createElement("li", { key: it.id }, it.href ? /* @__PURE__ */ React.createElement(Link, { href: it.href, ...common }, inner(it, false, false)) : /* @__PURE__ */ React.createElement("button", { type: "button", ...common }, inner(it, false, false)));
|
|
29
118
|
}
|
|
30
|
-
return /* @__PURE__ */ React.createElement(
|
|
31
|
-
|
|
32
|
-
|
|
119
|
+
return /* @__PURE__ */ React.createElement(
|
|
120
|
+
"nav",
|
|
121
|
+
{
|
|
122
|
+
ref: function(el) {
|
|
123
|
+
navRef.current = el;
|
|
124
|
+
if (typeof ref === "function") ref(el);
|
|
125
|
+
else if (ref) ref.current = el;
|
|
126
|
+
},
|
|
127
|
+
className: cx("aura-nav", props.className),
|
|
128
|
+
"aria-label": props.label || t.mainNav,
|
|
129
|
+
onKeyDown
|
|
130
|
+
},
|
|
131
|
+
props.header ? /* @__PURE__ */ React.createElement("div", { className: "aura-nav__header" }, props.header) : null,
|
|
132
|
+
/* @__PURE__ */ React.createElement("div", { className: "aura-nav__scroll" }, sections.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(function(it) {
|
|
134
|
+
return item(it, 0);
|
|
135
|
+
})));
|
|
136
|
+
})),
|
|
137
|
+
props.footer ? /* @__PURE__ */ React.createElement("div", { className: "aura-nav__footer" }, props.footer) : null
|
|
138
|
+
);
|
|
33
139
|
});
|
|
34
140
|
export {
|
|
35
141
|
SideNav
|
package/dist/esm/Stat.js
CHANGED
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { cx } from "./internal.js";
|
|
4
4
|
import { Icon } from "./Icon.js";
|
|
5
|
+
import { useLinkComponent } from "./locale.js";
|
|
5
6
|
const Stat = React.forwardRef(function Stat2(props, ref) {
|
|
6
7
|
const ch = props.change;
|
|
7
8
|
const dir = ch && (ch.direction || "flat");
|
|
8
9
|
const tone = ch && (ch.tone || (dir === "up" ? "positive" : dir === "down" ? "negative" : "neutral"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
10
|
+
const Link = useLinkComponent();
|
|
11
|
+
const v = props.value;
|
|
12
|
+
const numeric = typeof v === "number" || typeof v === "string" && /\d/.test(v) && /^[\s\d.,:+\-\u2212%()\u0E3F$\u20AC\u00A3\u00A5kKmMbB]+$/.test(v.replace(/\b[A-Z]{3}\b/g, ""));
|
|
13
|
+
const Tag = props.href ? Link : props.onClick ? "button" : "div";
|
|
14
|
+
const interactive = !!(props.href || props.onClick);
|
|
11
15
|
return /* @__PURE__ */ React.createElement(
|
|
12
16
|
Tag,
|
|
13
17
|
{
|
|
@@ -19,7 +23,7 @@ const Stat = React.forwardRef(function Stat2(props, ref) {
|
|
|
19
23
|
"aria-busy": props.loading || void 0
|
|
20
24
|
},
|
|
21
25
|
/* @__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),
|
|
26
|
+
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: cx("aura-stat__value", numeric && "is-numeric") }, props.value, props.unit ? /* @__PURE__ */ React.createElement("span", { className: "aura-stat__unit" }, props.unit) : null),
|
|
23
27
|
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
|
|
24
28
|
);
|
|
25
29
|
});
|
package/dist/esm/Switch.js
CHANGED
|
@@ -5,25 +5,37 @@ const Switch = React.forwardRef(function Switch2(props, ref) {
|
|
|
5
5
|
const auto = uid(), id = props.id || auto;
|
|
6
6
|
const st = useMaybeControlled(props.checked, !!props.defaultChecked, props.onChange);
|
|
7
7
|
const on = !!st[0];
|
|
8
|
-
return /* @__PURE__ */ React.createElement(
|
|
9
|
-
"
|
|
8
|
+
return /* @__PURE__ */ React.createElement(
|
|
9
|
+
"div",
|
|
10
10
|
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"aria-checked": on,
|
|
16
|
-
disabled: props.disabled,
|
|
17
|
-
"aria-labelledby": props.label ? id + "-label" : void 0,
|
|
18
|
-
"aria-label": props.label ? void 0 : props["aria-label"],
|
|
19
|
-
"aria-describedby": props.description ? id + "-desc" : void 0,
|
|
20
|
-
className: cx("aura-switch", on && "is-on"),
|
|
21
|
-
onClick: function() {
|
|
11
|
+
className: cx("aura-switch-row", props.disabled && "is-disabled", props.className),
|
|
12
|
+
onClick: function(e) {
|
|
13
|
+
const t = e.target;
|
|
14
|
+
if (props.disabled || t.closest("button, label, a, input")) return;
|
|
22
15
|
st[1](!on);
|
|
23
16
|
}
|
|
24
17
|
},
|
|
25
|
-
/* @__PURE__ */ React.createElement(
|
|
26
|
-
|
|
18
|
+
/* @__PURE__ */ React.createElement(
|
|
19
|
+
"button",
|
|
20
|
+
{
|
|
21
|
+
ref,
|
|
22
|
+
type: "button",
|
|
23
|
+
role: "switch",
|
|
24
|
+
id,
|
|
25
|
+
"aria-checked": on,
|
|
26
|
+
disabled: props.disabled,
|
|
27
|
+
"aria-labelledby": props.label ? id + "-label" : void 0,
|
|
28
|
+
"aria-label": props.label ? void 0 : props["aria-label"],
|
|
29
|
+
"aria-describedby": props.description ? id + "-desc" : void 0,
|
|
30
|
+
className: cx("aura-switch", on && "is-on"),
|
|
31
|
+
onClick: function() {
|
|
32
|
+
st[1](!on);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
/* @__PURE__ */ React.createElement("span", { className: "aura-switch__thumb" })
|
|
36
|
+
),
|
|
37
|
+
props.label ? /* @__PURE__ */ React.createElement("span", { className: "aura-choice__text" }, /* @__PURE__ */ React.createElement("label", { className: "aura-choice__label", id: id + "-label", htmlFor: id }, props.label), props.description ? /* @__PURE__ */ React.createElement("span", { className: "aura-choice__desc", id: id + "-desc" }, props.description) : null) : null
|
|
38
|
+
);
|
|
27
39
|
});
|
|
28
40
|
export {
|
|
29
41
|
Switch
|
package/dist/esm/colorScheme.js
CHANGED
|
@@ -15,7 +15,14 @@ function colorSchemeScript(options) {
|
|
|
15
15
|
return "(function(){try{var s=localStorage.getItem(" + key + ");if(s!=='light'&&s!=='dark'&&s!=='system')s=" + fallback + `;var d=document.documentElement;d.setAttribute("data-theme",s);var dark=s==='dark'||(s==='system'&&window.matchMedia('(prefers-color-scheme: dark)').matches);d.classList.toggle("dark",dark);}catch(e){}})();`;
|
|
16
16
|
}
|
|
17
17
|
function ColorSchemeScript(props) {
|
|
18
|
-
return /* @__PURE__ */ React.createElement(
|
|
18
|
+
return /* @__PURE__ */ React.createElement(
|
|
19
|
+
"script",
|
|
20
|
+
{
|
|
21
|
+
"data-aura-color-scheme": "",
|
|
22
|
+
nonce: props.nonce,
|
|
23
|
+
dangerouslySetInnerHTML: { __html: colorSchemeScript(props) }
|
|
24
|
+
}
|
|
25
|
+
);
|
|
19
26
|
}
|
|
20
27
|
function systemDark() {
|
|
21
28
|
return typeof window !== "undefined" && !!window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
|