@jirawatpyk/aura-react 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4069 @@
1
+ 'use client';
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/index.js
32
+ var index_exports = {};
33
+ __export(index_exports, {
34
+ Accordion: () => Accordion,
35
+ Alert: () => Alert,
36
+ AppShell: () => AppShell,
37
+ AuraProvider: () => AuraProvider,
38
+ Avatar: () => Avatar,
39
+ Badge: () => Badge,
40
+ Breadcrumb: () => Breadcrumb,
41
+ Button: () => Button,
42
+ Calendar: () => Calendar,
43
+ Card: () => Card,
44
+ Checkbox: () => Checkbox,
45
+ Combobox: () => Combobox,
46
+ Container: () => Container,
47
+ DataTable: () => DataTable,
48
+ DatePicker: () => DatePicker,
49
+ DateRangePicker: () => DateRangePicker,
50
+ Dialog: () => Dialog,
51
+ Drawer: () => Drawer,
52
+ DropdownMenu: () => DropdownMenu,
53
+ EmptyState: () => EmptyState,
54
+ Field: () => Field,
55
+ FileUpload: () => FileUpload,
56
+ Grid: () => Grid,
57
+ ICONS: () => ICONS,
58
+ Icon: () => Icon,
59
+ IconButton: () => IconButton,
60
+ Menu: () => Menu,
61
+ Pagination: () => Pagination,
62
+ Popover: () => Popover,
63
+ Progress: () => Progress,
64
+ RadioGroup: () => RadioGroup,
65
+ STRINGS: () => STRINGS,
66
+ Select: () => Select,
67
+ SideNav: () => SideNav,
68
+ Skeleton: () => Skeleton,
69
+ Stack: () => Stack,
70
+ Stat: () => Stat,
71
+ StatusPill: () => StatusPill,
72
+ Surface: () => Surface,
73
+ Switch: () => Switch,
74
+ Tabs: () => Tabs,
75
+ Tag: () => Tag,
76
+ TextField: () => TextField,
77
+ Textarea: () => Textarea,
78
+ ThemeStyle: () => ThemeStyle,
79
+ TimePicker: () => TimePicker,
80
+ Toaster: () => Toaster,
81
+ Tooltip: () => Tooltip,
82
+ brandScale: () => scale,
83
+ breakpoints: () => breakpoints,
84
+ comboboxFilter: () => defaultFilter,
85
+ contrast: () => contrast,
86
+ createTheme: () => createTheme,
87
+ formatBytes: () => formatBytes,
88
+ formatDate: () => formatDate,
89
+ iconNames: () => iconNames,
90
+ parseDate: () => parseDate,
91
+ parseTime: () => parseTime,
92
+ statusTone: () => toneFor,
93
+ toast: () => toast,
94
+ useAuraLocale: () => useAuraLocale,
95
+ useBreakpoint: () => useBreakpoint,
96
+ useResponsive: () => useResponsive
97
+ });
98
+ module.exports = __toCommonJS(index_exports);
99
+
100
+ // src/Icon.js
101
+ var React2 = __toESM(require("react"), 1);
102
+
103
+ // src/internal.js
104
+ var React = __toESM(require("react"), 1);
105
+ function cx() {
106
+ return Array.prototype.filter.call(arguments, Boolean).join(" ");
107
+ }
108
+ function omit(src, keys) {
109
+ var out = {};
110
+ for (var k in src) if (Object.prototype.hasOwnProperty.call(src, k) && keys.indexOf(k) < 0) out[k] = src[k];
111
+ return out;
112
+ }
113
+ function useMaybeControlled(value, initial, onChange) {
114
+ var s = React.useState(initial);
115
+ var controlled = value !== void 0;
116
+ return [controlled ? value : s[0], function(next) {
117
+ if (!controlled) s[1](next);
118
+ if (onChange) onChange(next);
119
+ }];
120
+ }
121
+ var collator = typeof Intl !== "undefined" ? new Intl.Collator(["th", "en"], { numeric: true, sensitivity: "base" }) : null;
122
+ function compare(a, b) {
123
+ if (a == null && b == null) return 0;
124
+ if (a == null) return 1;
125
+ if (b == null) return -1;
126
+ if (typeof a === "number" && typeof b === "number") return a - b;
127
+ return collator ? collator.compare(String(a), String(b)) : String(a).localeCompare(String(b));
128
+ }
129
+ var uid = React.useId || function() {
130
+ const r = React.useRef(null);
131
+ if (!r.current) r.current = "aura-" + Math.random().toString(36).slice(2, 9);
132
+ return r.current;
133
+ };
134
+ var FOCUSABLE = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';
135
+ function noopSubscribe() {
136
+ return function() {
137
+ };
138
+ }
139
+ function yes() {
140
+ return true;
141
+ }
142
+ function no() {
143
+ return false;
144
+ }
145
+ function useMounted() {
146
+ return React.useSyncExternalStore(noopSubscribe, yes, no);
147
+ }
148
+ var useIsoLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
149
+ function trapTab(e, container) {
150
+ if (e.key !== "Tab" || !container) return;
151
+ var list = Array.prototype.filter.call(container.querySelectorAll(FOCUSABLE), function(el) {
152
+ return el.tabIndex >= 0 && el.offsetParent !== null;
153
+ });
154
+ if (!list.length) return;
155
+ var first = list[0], last = list[list.length - 1];
156
+ if (e.shiftKey && document.activeElement === first) {
157
+ e.preventDefault();
158
+ last.focus();
159
+ } else if (!e.shiftKey && document.activeElement === last) {
160
+ e.preventDefault();
161
+ first.focus();
162
+ }
163
+ }
164
+ function useMergedRef(a, b) {
165
+ return React.useCallback(function(node) {
166
+ [a, b].forEach(function(r) {
167
+ if (!r) return;
168
+ if (typeof r === "function") r(node);
169
+ else r.current = node;
170
+ });
171
+ }, [a, b]);
172
+ }
173
+
174
+ // src/Icon.js
175
+ var h = React2.createElement;
176
+ var 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" }]] };
177
+ var SIZES = { sm: 16, md: 20, lg: 24 };
178
+ var Icon = React2.forwardRef(function Icon2(props, ref) {
179
+ var shapes = ICONS[props.name];
180
+ if (!shapes) return null;
181
+ var size = SIZES[props.size] || props.size || 16;
182
+ var a11y = props.label ? { role: "img", "aria-label": props.label } : { "aria-hidden": true, focusable: "false" };
183
+ return h("svg", Object.assign({
184
+ ref,
185
+ xmlns: "http://www.w3.org/2000/svg",
186
+ width: size,
187
+ height: size,
188
+ viewBox: "0 0 24 24",
189
+ fill: "none",
190
+ stroke: "currentColor",
191
+ strokeWidth: props.strokeWidth || 2,
192
+ strokeLinecap: "round",
193
+ strokeLinejoin: "round",
194
+ className: cx("aura-icon", props.className)
195
+ }, a11y), shapes.map(function(s, i) {
196
+ var attrs = { key: i };
197
+ for (var k in s[1]) attrs[k === "stroke-width" ? "strokeWidth" : k] = s[1][k];
198
+ return h(s[0], attrs);
199
+ }));
200
+ });
201
+ var iconNames = Object.keys(ICONS);
202
+
203
+ // src/Button.js
204
+ var React3 = __toESM(require("react"), 1);
205
+ var h2 = React3.createElement;
206
+ var Button = React3.forwardRef(function Button2(props, ref) {
207
+ var variant = props.variant || "primary";
208
+ var loading = !!props.loading;
209
+ var rest = omit(props, ["variant", "className", "children", "type", "icon", "iconRight", "loading", "onClick"]);
210
+ return h2(
211
+ "button",
212
+ Object.assign({}, rest, {
213
+ ref,
214
+ type: props.type || "button",
215
+ className: cx("aura-btn", "aura-btn--" + variant, loading && "is-loading", props.className),
216
+ "aria-busy": loading || void 0,
217
+ "aria-disabled": loading || void 0,
218
+ onClick: loading ? function(e) {
219
+ e.preventDefault();
220
+ } : props.onClick
221
+ }),
222
+ loading ? h2(Icon, { name: "loader-circle", className: "aura-spin" }) : props.icon ? h2(Icon, { name: props.icon }) : null,
223
+ props.children,
224
+ props.iconRight && !loading ? h2(Icon, { name: props.iconRight }) : null
225
+ );
226
+ });
227
+
228
+ // src/IconButton.js
229
+ var React4 = __toESM(require("react"), 1);
230
+ var h3 = React4.createElement;
231
+ var IconButton = React4.forwardRef(function IconButton2(props, ref) {
232
+ var rest = omit(props, ["icon", "label", "className", "size"]);
233
+ return h3("button", Object.assign({}, rest, {
234
+ ref,
235
+ type: props.type || "button",
236
+ "aria-label": props.label,
237
+ title: props.label,
238
+ className: cx("aura-icon-btn", props.className)
239
+ }), h3(Icon, { name: props.icon, size: props.size || "sm" }));
240
+ });
241
+
242
+ // src/Menu.js
243
+ var React5 = __toESM(require("react"), 1);
244
+ var import_react_dom = require("react-dom");
245
+ var h4 = React5.createElement;
246
+ var Menu = React5.forwardRef(function Menu2(props, ref) {
247
+ var own = React5.useRef(null), merged = useMergedRef(ref, own);
248
+ var posState = React5.useState(null);
249
+ var pos = posState[0], setPos = posState[1];
250
+ var items = props.items || [];
251
+ var mounted = useMounted();
252
+ useIsoLayoutEffect(function() {
253
+ var a = props.anchor, m = own.current;
254
+ if (!a || !m) return;
255
+ var r = a.getBoundingClientRect(), mh = m.offsetHeight, mw = m.offsetWidth;
256
+ var top = r.bottom + 4;
257
+ if (top + mh > window.innerHeight - 8 && r.top - mh - 4 > 8) top = r.top - mh - 4;
258
+ var left = Math.max(8, Math.min(r.right - mw, window.innerWidth - mw - 8));
259
+ setPos({ top, left });
260
+ }, [props.anchor, mounted]);
261
+ React5.useEffect(function() {
262
+ if (!mounted) return;
263
+ var first = own.current && own.current.querySelector('[role^="menuitem"]:not([disabled])');
264
+ if (first && props.autoFocus !== false) first.focus();
265
+ function outside(e) {
266
+ if (own.current && !own.current.contains(e.target) && !(props.anchor && props.anchor.contains(e.target))) props.onClose(false);
267
+ }
268
+ function onScroll(e) {
269
+ if (own.current && !own.current.contains(e.target)) props.onClose(false);
270
+ }
271
+ document.addEventListener("pointerdown", outside, true);
272
+ window.addEventListener("scroll", onScroll, true);
273
+ window.addEventListener("resize", onScroll);
274
+ return function() {
275
+ document.removeEventListener("pointerdown", outside, true);
276
+ window.removeEventListener("scroll", onScroll, true);
277
+ window.removeEventListener("resize", onScroll);
278
+ };
279
+ }, [mounted]);
280
+ function onKeyDown(e) {
281
+ var list = Array.prototype.slice.call(own.current.querySelectorAll('[role^="menuitem"]:not([disabled])'));
282
+ var i = list.indexOf(document.activeElement);
283
+ if (e.key === "ArrowDown") {
284
+ e.preventDefault();
285
+ list[(i + 1) % list.length].focus();
286
+ } else if (e.key === "ArrowUp") {
287
+ e.preventDefault();
288
+ list[(i - 1 + list.length) % list.length].focus();
289
+ } else if (e.key === "Home") {
290
+ e.preventDefault();
291
+ list[0].focus();
292
+ } else if (e.key === "End") {
293
+ e.preventDefault();
294
+ list[list.length - 1].focus();
295
+ } else if (e.key === "Escape") {
296
+ e.preventDefault();
297
+ props.onClose(true);
298
+ } else if (e.key === "Tab") {
299
+ props.onClose(true);
300
+ }
301
+ e.stopPropagation();
302
+ }
303
+ var el = h4("div", {
304
+ ref: merged,
305
+ role: "menu",
306
+ "aria-label": props.label,
307
+ className: "aura-menu",
308
+ onKeyDown,
309
+ style: { top: pos ? pos.top : -9999, left: pos ? pos.left : -9999 }
310
+ }, items.map(function(it, i) {
311
+ if (it.separator) return h4("div", { key: "s" + i, role: "separator", className: "aura-menu__sep" });
312
+ var isCheck = it.checked !== void 0;
313
+ return h4(
314
+ "button",
315
+ {
316
+ key: i,
317
+ type: "button",
318
+ tabIndex: -1,
319
+ disabled: it.disabled,
320
+ role: isCheck ? "menuitemcheckbox" : "menuitem",
321
+ "aria-checked": isCheck ? !!it.checked : void 0,
322
+ className: "aura-menu__item",
323
+ onClick: function() {
324
+ it.onSelect();
325
+ if (!it.keepOpen) props.onClose(true);
326
+ }
327
+ },
328
+ isCheck ? h4("span", { className: cx("aura-menu__check", it.checked && "is-on") }, it.checked ? h4(Icon, { name: "check", size: 12, strokeWidth: 3 }) : null) : it.icon ? h4(Icon, { name: it.icon }) : h4("span", { className: "aura-menu__blank" }),
329
+ h4("span", { className: "aura-menu__label" }, it.label),
330
+ it.hint ? h4("span", { className: "aura-menu__hint" }, it.hint) : null
331
+ );
332
+ }));
333
+ return mounted ? (0, import_react_dom.createPortal)(el, document.body) : null;
334
+ });
335
+
336
+ // src/DropdownMenu.js
337
+ var React6 = __toESM(require("react"), 1);
338
+ var h5 = React6.createElement;
339
+ var DropdownMenu = React6.forwardRef(function DropdownMenu2(props, ref) {
340
+ var st = React6.useState(null), anchor = st[0], setAnchor = st[1];
341
+ var wrap = React6.useRef(null), wrapMerged = useMergedRef(ref, wrap);
342
+ var child = React6.Children.only(props.trigger);
343
+ function toggle(e) {
344
+ if (child.props.onClick) child.props.onClick(e);
345
+ var el = wrap.current && (wrap.current.querySelector('button, [role="button"], a') || wrap.current);
346
+ setAnchor(anchor ? null : el);
347
+ }
348
+ function onKeyDown(e) {
349
+ if ((e.key === "ArrowDown" || e.key === "ArrowUp") && !anchor) {
350
+ e.preventDefault();
351
+ setAnchor(wrap.current.querySelector('button, [role="button"], a') || wrap.current);
352
+ }
353
+ }
354
+ return h5(
355
+ "span",
356
+ { ref: wrapMerged, className: "aura-dropdown", onKeyDown },
357
+ React6.cloneElement(child, { onClick: toggle, "aria-haspopup": "menu", "aria-expanded": anchor ? true : false }),
358
+ anchor ? h5(Menu, {
359
+ anchor,
360
+ label: props.label,
361
+ items: props.items,
362
+ onClose: function(restore) {
363
+ setAnchor(null);
364
+ if (restore && anchor.focus) anchor.focus();
365
+ }
366
+ }) : null
367
+ );
368
+ });
369
+
370
+ // src/Checkbox.js
371
+ var React7 = __toESM(require("react"), 1);
372
+ var h6 = React7.createElement;
373
+ var Checkbox = React7.forwardRef(function Checkbox2(props, ref) {
374
+ var own = React7.useRef(null), merged = useMergedRef(ref, own);
375
+ var st = useMaybeControlled(props.checked, !!props.defaultChecked, props.onChange);
376
+ var on = !!st[0];
377
+ React7.useEffect(function() {
378
+ if (own.current) own.current.indeterminate = !!props.indeterminate;
379
+ });
380
+ var rest = omit(props, ["checked", "defaultChecked", "onChange", "indeterminate", "label", "children", "description", "className", "tabIndex", "disabled"]);
381
+ var labelled = props.children != null;
382
+ var descId = props.description && props.id ? props.id + "-desc" : void 0;
383
+ return h6(
384
+ "label",
385
+ { className: cx("aura-check", labelled && "aura-check--labelled", props.disabled && "is-disabled", props.className), onClick: function(e) {
386
+ e.stopPropagation();
387
+ } },
388
+ h6("input", Object.assign({}, rest, {
389
+ ref: merged,
390
+ type: "checkbox",
391
+ className: "aura-check__input",
392
+ checked: on,
393
+ tabIndex: props.tabIndex,
394
+ disabled: props.disabled,
395
+ "aria-describedby": descId,
396
+ "aria-label": labelled ? void 0 : props.label,
397
+ onChange: function(e) {
398
+ st[1](e.target.checked);
399
+ }
400
+ })),
401
+ h6(
402
+ "span",
403
+ { className: "aura-check__box", "aria-hidden": true },
404
+ props.indeterminate ? h6(Icon, { name: "minus", size: 12, strokeWidth: 3 }) : on ? h6(Icon, { name: "check", size: 12, strokeWidth: 3 }) : null
405
+ ),
406
+ labelled ? h6(
407
+ "span",
408
+ { className: "aura-check__text" },
409
+ h6("span", { className: "aura-check__label" }, props.children),
410
+ props.description ? h6("span", { className: "aura-check__desc", id: descId }, props.description) : null
411
+ ) : null
412
+ );
413
+ });
414
+
415
+ // src/StatusPill.js
416
+ var React8 = __toESM(require("react"), 1);
417
+ var h7 = React8.createElement;
418
+ var TONE_ICON = { neutral: "circle", progress: "circle-dot-dashed", ready: "circle-check", blocked: "ban" };
419
+ var TONE_WORDS = {
420
+ ready: ["ready", "done", "complete", "completed", "approved", "live", "passed"],
421
+ progress: ["in progress", "in review", "review", "syncing", "running", "pending"],
422
+ blocked: ["blocked", "failed", "error", "rejected", "on hold", "cancelled"]
423
+ };
424
+ function toneFor(status) {
425
+ var s = String(status == null ? "" : status).trim().toLowerCase();
426
+ for (var t in TONE_WORDS) if (TONE_WORDS[t].indexOf(s) >= 0) return t;
427
+ return "neutral";
428
+ }
429
+ var TONE_ORDER = { neutral: 0, progress: 1, ready: 2, blocked: 3 };
430
+ var StatusPill = React8.forwardRef(function StatusPill2(props, ref) {
431
+ var tone2 = props.tone || toneFor(props.children);
432
+ return h7(
433
+ "span",
434
+ { ref, className: cx("aura-pill", "aura-pill--" + tone2, props.className) },
435
+ h7(Icon, { name: TONE_ICON[tone2] || "circle", size: 12 }),
436
+ props.children
437
+ );
438
+ });
439
+
440
+ // src/forms.js
441
+ var React10 = __toESM(require("react"), 1);
442
+
443
+ // src/locale.js
444
+ var React9 = __toESM(require("react"), 1);
445
+ var h8 = React9.createElement;
446
+ var n = function(x) {
447
+ return Number(x).toLocaleString("en");
448
+ };
449
+ var STRINGS = {
450
+ en: {
451
+ close: "Close",
452
+ dismiss: "Dismiss",
453
+ dismissToast: "Dismiss notification",
454
+ notifications: "Notifications",
455
+ mainNav: "Main",
456
+ breadcrumb: "Breadcrumb",
457
+ navigation: "Navigation",
458
+ openNav: "Open navigation",
459
+ searching: "Searching\u2026",
460
+ noMatches: "No matches",
461
+ clear: function(what) {
462
+ return "Clear " + (what || "selection");
463
+ },
464
+ keepTyping: function(total) {
465
+ return "Keep typing to narrow " + n(total) + " options";
466
+ },
467
+ sortAsc: "Sort ascending",
468
+ sortDesc: "Sort descending",
469
+ pin: "Pin to left",
470
+ unpin: "Unpin column",
471
+ moveLeft: "Move left",
472
+ moveRight: "Move right",
473
+ hideColumn: "Hide column",
474
+ resetColumns: "Reset columns",
475
+ selectRows: "Select rows",
476
+ selectAllRows: "Select all rows",
477
+ deselectAllRows: "Deselect all rows",
478
+ selectAll: "Select all",
479
+ selectRow: function(k) {
480
+ return "Select " + k;
481
+ },
482
+ selectedCount: function(c) {
483
+ return n(c) + " selected";
484
+ },
485
+ pinned: "Pinned",
486
+ columnOptions: function(label) {
487
+ return label + " column options";
488
+ },
489
+ column: function(label) {
490
+ return label ? label + " column" : "Column";
491
+ },
492
+ columns: "Columns",
493
+ showHideColumns: "Show or hide columns",
494
+ empty: "Nothing here yet",
495
+ loading: "Loading\u2026",
496
+ loadingRows: "Loading rows",
497
+ range: function(a, b, total) {
498
+ return a + "\u2013" + b + " of " + n(total);
499
+ },
500
+ page: function(p, total) {
501
+ return "Page " + p + " of " + total;
502
+ },
503
+ prevPage: "Previous page",
504
+ nextPage: "Next page",
505
+ rowCount: function(c) {
506
+ return n(c) + " rows";
507
+ },
508
+ actions: "Actions",
509
+ optional: "optional",
510
+ timePlaceholder: "hh:mm",
511
+ timeInvalid: "Type a time like 09:30",
512
+ timeOutOfRange: function(a, b) {
513
+ return "Choose a time between " + a + " and " + b;
514
+ },
515
+ dropFiles: "Drag files here or",
516
+ browse: "Choose files",
517
+ browseOne: "Choose a file",
518
+ remove: function(n2) {
519
+ return "Remove " + n2;
520
+ },
521
+ fileTooBig: function(max) {
522
+ return "Larger than " + max;
523
+ },
524
+ fileWrongType: "This file type isn\u2019t accepted",
525
+ tooManyFiles: function(n2) {
526
+ return "Up to " + n2 + " files";
527
+ },
528
+ uploading: "Uploading\u2026",
529
+ images: "Images",
530
+ pagination: "Pagination",
531
+ pageN: function(p) {
532
+ return "Page " + p;
533
+ },
534
+ accepts: function(list, max) {
535
+ return [list, max && "up to " + max + " each"].filter(Boolean).join(", ");
536
+ }
537
+ },
538
+ th: {
539
+ close: "\u0E1B\u0E34\u0E14",
540
+ dismiss: "\u0E1B\u0E34\u0E14",
541
+ dismissToast: "\u0E1B\u0E34\u0E14\u0E01\u0E32\u0E23\u0E41\u0E08\u0E49\u0E07\u0E40\u0E15\u0E37\u0E2D\u0E19",
542
+ notifications: "\u0E01\u0E32\u0E23\u0E41\u0E08\u0E49\u0E07\u0E40\u0E15\u0E37\u0E2D\u0E19",
543
+ mainNav: "\u0E40\u0E21\u0E19\u0E39\u0E2B\u0E25\u0E31\u0E01",
544
+ breadcrumb: "\u0E40\u0E2A\u0E49\u0E19\u0E17\u0E32\u0E07",
545
+ navigation: "\u0E40\u0E21\u0E19\u0E39",
546
+ openNav: "\u0E40\u0E1B\u0E34\u0E14\u0E40\u0E21\u0E19\u0E39",
547
+ searching: "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E04\u0E49\u0E19\u0E2B\u0E32\u2026",
548
+ noMatches: "\u0E44\u0E21\u0E48\u0E1E\u0E1A\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23\u0E17\u0E35\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E19",
549
+ clear: function(what) {
550
+ return "\u0E25\u0E49\u0E32\u0E07" + (what || "\u0E17\u0E35\u0E48\u0E40\u0E25\u0E37\u0E2D\u0E01");
551
+ },
552
+ keepTyping: function(total) {
553
+ return "\u0E1E\u0E34\u0E21\u0E1E\u0E4C\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E1E\u0E37\u0E48\u0E2D\u0E01\u0E23\u0E2D\u0E07\u0E08\u0E32\u0E01 " + n(total) + " \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23";
554
+ },
555
+ sortAsc: "\u0E40\u0E23\u0E35\u0E22\u0E07\u0E08\u0E32\u0E01\u0E19\u0E49\u0E2D\u0E22\u0E44\u0E1B\u0E21\u0E32\u0E01",
556
+ sortDesc: "\u0E40\u0E23\u0E35\u0E22\u0E07\u0E08\u0E32\u0E01\u0E21\u0E32\u0E01\u0E44\u0E1B\u0E19\u0E49\u0E2D\u0E22",
557
+ pin: "\u0E15\u0E23\u0E36\u0E07\u0E44\u0E27\u0E49\u0E0B\u0E49\u0E32\u0E22",
558
+ unpin: "\u0E40\u0E25\u0E34\u0E01\u0E15\u0E23\u0E36\u0E07\u0E04\u0E2D\u0E25\u0E31\u0E21\u0E19\u0E4C",
559
+ moveLeft: "\u0E22\u0E49\u0E32\u0E22\u0E44\u0E1B\u0E0B\u0E49\u0E32\u0E22",
560
+ moveRight: "\u0E22\u0E49\u0E32\u0E22\u0E44\u0E1B\u0E02\u0E27\u0E32",
561
+ hideColumn: "\u0E0B\u0E48\u0E2D\u0E19\u0E04\u0E2D\u0E25\u0E31\u0E21\u0E19\u0E4C",
562
+ resetColumns: "\u0E04\u0E37\u0E19\u0E04\u0E48\u0E32\u0E04\u0E2D\u0E25\u0E31\u0E21\u0E19\u0E4C",
563
+ selectRows: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E41\u0E16\u0E27",
564
+ selectAllRows: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E17\u0E38\u0E01\u0E41\u0E16\u0E27",
565
+ deselectAllRows: "\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01\u0E01\u0E32\u0E23\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E17\u0E38\u0E01\u0E41\u0E16\u0E27",
566
+ selectAll: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14",
567
+ selectRow: function(k) {
568
+ return "\u0E40\u0E25\u0E37\u0E2D\u0E01 " + k;
569
+ },
570
+ selectedCount: function(c) {
571
+ return "\u0E40\u0E25\u0E37\u0E2D\u0E01 " + n(c) + " \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23";
572
+ },
573
+ pinned: "\u0E15\u0E23\u0E36\u0E07\u0E2D\u0E22\u0E39\u0E48",
574
+ columnOptions: function(label) {
575
+ return "\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E04\u0E2D\u0E25\u0E31\u0E21\u0E19\u0E4C " + label;
576
+ },
577
+ column: function(label) {
578
+ return label ? "\u0E04\u0E2D\u0E25\u0E31\u0E21\u0E19\u0E4C " + label : "\u0E04\u0E2D\u0E25\u0E31\u0E21\u0E19\u0E4C";
579
+ },
580
+ columns: "\u0E04\u0E2D\u0E25\u0E31\u0E21\u0E19\u0E4C",
581
+ showHideColumns: "\u0E41\u0E2A\u0E14\u0E07\u0E2B\u0E23\u0E37\u0E2D\u0E0B\u0E48\u0E2D\u0E19\u0E04\u0E2D\u0E25\u0E31\u0E21\u0E19\u0E4C",
582
+ empty: "\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E21\u0E35\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25",
583
+ loading: "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026",
584
+ loadingRows: "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25",
585
+ range: function(a, b, total) {
586
+ return a + "\u2013" + b + " \u0E08\u0E32\u0E01 " + n(total);
587
+ },
588
+ page: function(p, total) {
589
+ return "\u0E2B\u0E19\u0E49\u0E32 " + p + " / " + total;
590
+ },
591
+ prevPage: "\u0E2B\u0E19\u0E49\u0E32\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32",
592
+ nextPage: "\u0E2B\u0E19\u0E49\u0E32\u0E16\u0E31\u0E14\u0E44\u0E1B",
593
+ rowCount: function(c) {
594
+ return n(c) + " \u0E41\u0E16\u0E27";
595
+ },
596
+ actions: "\u0E01\u0E32\u0E23\u0E08\u0E31\u0E14\u0E01\u0E32\u0E23",
597
+ optional: "\u0E44\u0E21\u0E48\u0E1A\u0E31\u0E07\u0E04\u0E31\u0E1A",
598
+ timePlaceholder: "\u0E0A\u0E0A:\u0E19\u0E19",
599
+ timeInvalid: "\u0E1E\u0E34\u0E21\u0E1E\u0E4C\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A 09:30",
600
+ timeOutOfRange: function(a, b) {
601
+ return "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E40\u0E27\u0E25\u0E32\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07 " + a + "\u2013" + b + " \u0E19.";
602
+ },
603
+ dropFiles: "\u0E25\u0E32\u0E01\u0E44\u0E1F\u0E25\u0E4C\u0E21\u0E32\u0E27\u0E32\u0E07 \u0E2B\u0E23\u0E37\u0E2D",
604
+ browse: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E1F\u0E25\u0E4C",
605
+ browseOne: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E1F\u0E25\u0E4C",
606
+ remove: function(n2) {
607
+ return "\u0E25\u0E1A " + n2;
608
+ },
609
+ fileTooBig: function(max) {
610
+ return "\u0E44\u0E1F\u0E25\u0E4C\u0E43\u0E2B\u0E0D\u0E48\u0E40\u0E01\u0E34\u0E19 " + max;
611
+ },
612
+ fileWrongType: "\u0E44\u0E21\u0E48\u0E23\u0E2D\u0E07\u0E23\u0E31\u0E1A\u0E44\u0E1F\u0E25\u0E4C\u0E0A\u0E19\u0E34\u0E14\u0E19\u0E35\u0E49",
613
+ tooManyFiles: function(n2) {
614
+ return "\u0E41\u0E19\u0E1A\u0E44\u0E14\u0E49\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19 " + n2 + " \u0E44\u0E1F\u0E25\u0E4C";
615
+ },
616
+ uploading: "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E2D\u0E31\u0E1B\u0E42\u0E2B\u0E25\u0E14\u2026",
617
+ images: "\u0E23\u0E39\u0E1B\u0E20\u0E32\u0E1E",
618
+ pagination: "\u0E40\u0E25\u0E02\u0E2B\u0E19\u0E49\u0E32",
619
+ pageN: function(p) {
620
+ return "\u0E2B\u0E19\u0E49\u0E32 " + p;
621
+ },
622
+ accepts: function(list, max) {
623
+ return [list, max && "\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19 " + max + " \u0E15\u0E48\u0E2D\u0E44\u0E1F\u0E25\u0E4C"].filter(Boolean).join(" \xB7 ");
624
+ }
625
+ }
626
+ };
627
+ var LocaleContext = React9.createContext(null);
628
+ function AuraProvider(props) {
629
+ var value = React9.useMemo(function() {
630
+ var base = STRINGS[props.locale] || STRINGS.en;
631
+ return { locale: props.locale || "en", calendar: props.calendar, strings: props.strings ? Object.assign({}, base, props.strings) : base };
632
+ }, [props.locale, props.calendar, props.strings]);
633
+ return h8(LocaleContext.Provider, { value }, props.children);
634
+ }
635
+ function useAuraLocale() {
636
+ return React9.useContext(LocaleContext) || { locale: null, calendar: null, strings: STRINGS.en };
637
+ }
638
+ function useStrings() {
639
+ return useAuraLocale().strings;
640
+ }
641
+
642
+ // src/forms.js
643
+ var h9 = React10.createElement;
644
+ var Field = React10.forwardRef(function Field2(props, ref) {
645
+ var t = useStrings();
646
+ return h9(
647
+ "div",
648
+ { ref, className: cx("aura-field", props.error && "is-invalid", props.disabled && "is-disabled", props.className) },
649
+ props.label ? h9(
650
+ props.labelAs || "label",
651
+ { className: "aura-field__label", htmlFor: props.labelAs ? void 0 : props.id, id: props.labelId },
652
+ props.label,
653
+ props.required ? h9("span", { className: "aura-field__req", "aria-hidden": true }, " *") : null,
654
+ props.optional ? h9("span", { className: "aura-field__opt" }, " (" + t.optional + ")") : null
655
+ ) : null,
656
+ props.children,
657
+ props.error ? h9("p", { className: "aura-field__error", id: props.id + "-error" }, h9(Icon, { name: "circle-alert", size: 14 }), props.error) : props.hint ? h9("p", { className: "aura-field__hint", id: props.id + "-hint" }, props.hint) : null
658
+ );
659
+ });
660
+ function describedBy(id, p) {
661
+ return p.error ? id + "-error" : p.hint ? id + "-hint" : void 0;
662
+ }
663
+ var FIELD_KEYS = ["label", "hint", "error", "required", "optional", "icon", "className", "id", "suffix", "options", "placeholder"];
664
+ var TextField = React10.forwardRef(function TextField2(props, ref) {
665
+ var auto = uid(), id = props.id || auto;
666
+ var rest = omit(props, FIELD_KEYS);
667
+ return h9(
668
+ Field,
669
+ { id, label: props.label, hint: props.hint, error: props.error, required: props.required, optional: props.optional, disabled: props.disabled, className: props.className },
670
+ h9(
671
+ "div",
672
+ { className: cx("aura-input", props.icon && "has-icon", props.suffix && "has-suffix") },
673
+ props.icon ? h9(Icon, { name: props.icon, className: "aura-input__icon" }) : null,
674
+ h9("input", Object.assign({ type: "text" }, rest, {
675
+ ref,
676
+ id,
677
+ className: "aura-input__control",
678
+ placeholder: props.placeholder,
679
+ required: props.required,
680
+ "aria-invalid": props.error ? true : void 0,
681
+ "aria-describedby": describedBy(id, props)
682
+ })),
683
+ props.suffix ? h9("span", { className: "aura-input__suffix" }, props.suffix) : null
684
+ )
685
+ );
686
+ });
687
+ var Textarea = React10.forwardRef(function Textarea2(props, ref) {
688
+ var auto = uid(), id = props.id || auto;
689
+ var rest = omit(props, FIELD_KEYS);
690
+ return h9(
691
+ Field,
692
+ { id, label: props.label, hint: props.hint, error: props.error, required: props.required, optional: props.optional, disabled: props.disabled, className: props.className },
693
+ h9("textarea", Object.assign({ rows: 4 }, rest, {
694
+ ref,
695
+ id,
696
+ className: "aura-input aura-textarea",
697
+ placeholder: props.placeholder,
698
+ required: props.required,
699
+ "aria-invalid": props.error ? true : void 0,
700
+ "aria-describedby": describedBy(id, props)
701
+ }))
702
+ );
703
+ });
704
+ var Select = React10.forwardRef(function Select2(props, ref) {
705
+ var auto = uid(), id = props.id || auto;
706
+ var rest = omit(props, FIELD_KEYS.concat(["children"]));
707
+ var opts = (props.options || []).map(function(o) {
708
+ var v = typeof o === "object" ? o : { value: o, label: o };
709
+ return h9("option", { key: v.value, value: v.value, disabled: v.disabled }, v.label);
710
+ });
711
+ if (props.placeholder) opts.unshift(h9("option", { key: "__ph", value: "", disabled: true }, props.placeholder));
712
+ var extra = props.value === void 0 && props.defaultValue === void 0 && props.placeholder ? { defaultValue: "" } : {};
713
+ return h9(
714
+ Field,
715
+ { id, label: props.label, hint: props.hint, error: props.error, required: props.required, optional: props.optional, disabled: props.disabled, className: props.className },
716
+ h9(
717
+ "div",
718
+ { className: cx("aura-input aura-select", props.icon && "has-icon") },
719
+ props.icon ? h9(Icon, { name: props.icon, className: "aura-input__icon" }) : null,
720
+ h9("select", Object.assign(extra, rest, {
721
+ ref,
722
+ id,
723
+ className: "aura-input__control",
724
+ required: props.required,
725
+ "aria-invalid": props.error ? true : void 0,
726
+ "aria-describedby": describedBy(id, props)
727
+ }), opts, props.children),
728
+ h9(Icon, { name: "chevron-down", className: "aura-select__chevron" })
729
+ )
730
+ );
731
+ });
732
+ var RadioGroup = React10.forwardRef(function RadioGroup2(props, ref) {
733
+ var auto = uid(), id = props.id || auto;
734
+ var st = useMaybeControlled(props.value, props.defaultValue, props.onChange);
735
+ var name = props.name || id;
736
+ return h9(
737
+ "fieldset",
738
+ {
739
+ ref,
740
+ className: cx("aura-field aura-radio-group", props.error && "is-invalid", props.className),
741
+ "aria-describedby": describedBy(id, props),
742
+ "aria-invalid": props.error ? true : void 0,
743
+ disabled: props.disabled
744
+ },
745
+ props.label ? h9("legend", { className: "aura-field__label" }, props.label, props.required ? h9("span", { className: "aura-field__req", "aria-hidden": true }, " *") : null) : null,
746
+ h9(
747
+ "div",
748
+ { className: cx("aura-radio-group__list", props.orientation === "horizontal" && "is-horizontal") },
749
+ (props.options || []).map(function(o) {
750
+ var v = typeof o === "object" ? o : { value: o, label: o };
751
+ return h9(
752
+ "label",
753
+ { key: v.value, className: cx("aura-choice", v.disabled && "is-disabled") },
754
+ h9("input", {
755
+ type: "radio",
756
+ className: "aura-radio",
757
+ name,
758
+ value: v.value,
759
+ disabled: v.disabled,
760
+ checked: st[0] === v.value,
761
+ onChange: function() {
762
+ st[1](v.value);
763
+ }
764
+ }),
765
+ h9(
766
+ "span",
767
+ { className: "aura-choice__text" },
768
+ h9("span", { className: "aura-choice__label" }, v.label),
769
+ v.description ? h9("span", { className: "aura-choice__desc" }, v.description) : null
770
+ )
771
+ );
772
+ })
773
+ ),
774
+ props.error ? h9("p", { className: "aura-field__error", id: id + "-error" }, h9(Icon, { name: "circle-alert", size: 14 }), props.error) : props.hint ? h9("p", { className: "aura-field__hint", id: id + "-hint" }, props.hint) : null
775
+ );
776
+ });
777
+ var Switch = React10.forwardRef(function Switch2(props, ref) {
778
+ var auto = uid(), id = props.id || auto;
779
+ var st = useMaybeControlled(props.checked, !!props.defaultChecked, props.onChange);
780
+ var on = !!st[0];
781
+ return h9(
782
+ "div",
783
+ { className: cx("aura-switch-row", props.disabled && "is-disabled", props.className) },
784
+ h9(
785
+ "button",
786
+ {
787
+ ref,
788
+ type: "button",
789
+ role: "switch",
790
+ id,
791
+ "aria-checked": on,
792
+ disabled: props.disabled,
793
+ "aria-labelledby": props.label ? id + "-label" : void 0,
794
+ "aria-label": props.label ? void 0 : props["aria-label"],
795
+ "aria-describedby": props.description ? id + "-desc" : void 0,
796
+ className: cx("aura-switch", on && "is-on"),
797
+ onClick: function() {
798
+ st[1](!on);
799
+ }
800
+ },
801
+ h9("span", { className: "aura-switch__thumb" })
802
+ ),
803
+ props.label ? h9(
804
+ "span",
805
+ { className: "aura-choice__text" },
806
+ h9("label", { className: "aura-choice__label", id: id + "-label", htmlFor: id }, props.label),
807
+ props.description ? h9("span", { className: "aura-choice__desc", id: id + "-desc" }, props.description) : null
808
+ ) : null
809
+ );
810
+ });
811
+
812
+ // src/Combobox.js
813
+ var React11 = __toESM(require("react"), 1);
814
+ var import_react_dom2 = require("react-dom");
815
+ var h10 = React11.createElement;
816
+ function norm(s) {
817
+ return String(s == null ? "" : s).normalize("NFC").toLocaleLowerCase("th");
818
+ }
819
+ function toOpt(o) {
820
+ return typeof o === "object" ? o : { value: String(o), label: String(o) };
821
+ }
822
+ function defaultFilter(option, query) {
823
+ var q = norm(query).trim();
824
+ if (!q) return true;
825
+ return norm(option.label).indexOf(q) >= 0 || option.description && norm(option.description).indexOf(q) >= 0 || (option.keywords || []).some(function(k) {
826
+ return norm(k).indexOf(q) >= 0;
827
+ });
828
+ }
829
+ var Combobox = React11.forwardRef(function Combobox2(props, ref) {
830
+ var t = useStrings();
831
+ var auto = uid(), id = props.id || auto, listId = id + "-list";
832
+ var options = (props.options || []).map(toOpt);
833
+ var st = useMaybeControlled(props.value, props.defaultValue == null ? null : props.defaultValue, props.onChange);
834
+ var value = st[0], setValue = st[1];
835
+ var selected = options.filter(function(o) {
836
+ return o.value === value;
837
+ })[0] || null;
838
+ var openState = React11.useState(false), open = openState[0], setOpen = openState[1];
839
+ var qState = React11.useState(null), query = qState[0], setQuery = qState[1];
840
+ var aState = React11.useState(0), active = aState[0], setActive = aState[1];
841
+ var posState = React11.useState(null);
842
+ var inputRef = React11.useRef(null), inputMerged = useMergedRef(ref, inputRef), boxRef = React11.useRef(null), listRef = React11.useRef(null);
843
+ var mounted = useMounted();
844
+ var limit = props.limit || 200;
845
+ var filter = props.filter || defaultFilter;
846
+ var shown = props.onSearch || query == null ? options : options.filter(function(o) {
847
+ return filter(o, query);
848
+ });
849
+ var more = shown.length > limit;
850
+ shown = shown.slice(0, limit);
851
+ var activeIdx = Math.min(active, shown.length - 1);
852
+ function place() {
853
+ if (!boxRef.current) return;
854
+ var r = boxRef.current.getBoundingClientRect();
855
+ var maxH = 320, below = window.innerHeight - r.bottom - 8, up = below < 200 && r.top > below;
856
+ posState[1]({ left: r.left, width: r.width, top: up ? void 0 : r.bottom + 4, bottom: up ? window.innerHeight - r.top + 4 : void 0, maxHeight: Math.min(maxH, (up ? r.top : below) - 8) });
857
+ }
858
+ useIsoLayoutEffect(function() {
859
+ if (open) place();
860
+ }, [open, shown.length]);
861
+ React11.useEffect(function() {
862
+ if (!open) return;
863
+ function outside(e) {
864
+ if (boxRef.current && boxRef.current.contains(e.target)) return;
865
+ if (listRef.current && listRef.current.contains(e.target)) return;
866
+ close(false);
867
+ }
868
+ function onScroll(e) {
869
+ if (!listRef.current || !listRef.current.contains(e.target)) place();
870
+ }
871
+ document.addEventListener("pointerdown", outside, true);
872
+ window.addEventListener("scroll", onScroll, true);
873
+ window.addEventListener("resize", place);
874
+ return function() {
875
+ document.removeEventListener("pointerdown", outside, true);
876
+ window.removeEventListener("scroll", onScroll, true);
877
+ window.removeEventListener("resize", place);
878
+ };
879
+ }, [open]);
880
+ React11.useEffect(function() {
881
+ if (!open || !listRef.current) return;
882
+ var el = listRef.current.querySelector('[data-idx="' + activeIdx + '"]');
883
+ if (el && el.scrollIntoView) el.scrollIntoView({ block: "nearest" });
884
+ }, [activeIdx, open]);
885
+ function openList() {
886
+ if (!open && !props.disabled && !props.readOnly) {
887
+ setOpen(true);
888
+ var i = selected ? shown.indexOf(selected) : 0;
889
+ setActive(i < 0 ? 0 : i);
890
+ }
891
+ }
892
+ function close(restoreLabel) {
893
+ setOpen(false);
894
+ setQuery(null);
895
+ }
896
+ function choose(o) {
897
+ if (!o || o.disabled) return;
898
+ setValue(o.value);
899
+ setQuery(null);
900
+ setOpen(false);
901
+ if (inputRef.current) inputRef.current.focus();
902
+ }
903
+ function onKeyDown(e) {
904
+ var k = e.key;
905
+ if (k === "ArrowDown") {
906
+ e.preventDefault();
907
+ if (!open) openList();
908
+ else setActive(Math.min(activeIdx + 1, shown.length - 1));
909
+ } else if (k === "ArrowUp") {
910
+ e.preventDefault();
911
+ if (!open) openList();
912
+ else setActive(Math.max(activeIdx - 1, 0));
913
+ } else if (k === "Home" && open) {
914
+ e.preventDefault();
915
+ setActive(0);
916
+ } else if (k === "End" && open) {
917
+ e.preventDefault();
918
+ setActive(shown.length - 1);
919
+ } else if (k === "Enter") {
920
+ if (open && shown[activeIdx]) {
921
+ e.preventDefault();
922
+ choose(shown[activeIdx]);
923
+ }
924
+ } else if (k === "Escape") {
925
+ if (open) {
926
+ e.preventDefault();
927
+ e.stopPropagation();
928
+ close();
929
+ } else if (props.clearable !== false && value != null && query == null) {
930
+ setValue(null);
931
+ }
932
+ } else if (k === "Tab") {
933
+ if (open) close();
934
+ }
935
+ }
936
+ var text = query != null ? query : selected ? selected.label : "";
937
+ var optId = function(i) {
938
+ return id + "-opt-" + i;
939
+ };
940
+ var list = open && mounted && posState[0] ? (0, import_react_dom2.createPortal)(
941
+ h10(
942
+ "div",
943
+ { ref: listRef, className: "aura-combo__popover", style: posState[0] },
944
+ h10(
945
+ "ul",
946
+ { id: listId, role: "listbox", "aria-label": props.label, className: "aura-combo__list" },
947
+ props.loading ? h10("li", { className: "aura-combo__note", role: "presentation" }, h10(Icon, { name: "loader-circle", className: "aura-spin" }), props.loadingText || t.searching) : !shown.length ? h10("li", { className: "aura-combo__note", role: "presentation" }, props.emptyText || t.noMatches) : shown.map(function(o, i) {
948
+ var isSel = selected && o.value === selected.value;
949
+ return h10(
950
+ "li",
951
+ {
952
+ key: o.value,
953
+ id: optId(i),
954
+ role: "option",
955
+ "data-idx": i,
956
+ "aria-selected": isSel,
957
+ "aria-disabled": o.disabled || void 0,
958
+ className: cx("aura-combo__option", i === activeIdx && "is-active", isSel && "is-selected", o.disabled && "is-disabled"),
959
+ onPointerDown: function(e) {
960
+ e.preventDefault();
961
+ },
962
+ onClick: function() {
963
+ choose(o);
964
+ },
965
+ onPointerMove: function() {
966
+ if (activeIdx !== i) setActive(i);
967
+ }
968
+ },
969
+ o.icon ? h10(Icon, { name: o.icon }) : null,
970
+ h10(
971
+ "span",
972
+ { className: "aura-combo__text" },
973
+ h10("span", { className: "aura-combo__label" }, o.label),
974
+ o.description ? h10("span", { className: "aura-combo__desc" }, o.description) : null
975
+ ),
976
+ isSel ? h10(Icon, { name: "check", className: "aura-combo__check" }) : null
977
+ );
978
+ }),
979
+ more && !props.loading ? h10("li", { className: "aura-combo__note", role: "presentation" }, t.keepTyping((props.options || []).length)) : null
980
+ )
981
+ ),
982
+ document.body
983
+ ) : null;
984
+ return h10(
985
+ Field,
986
+ { id, label: props.label, hint: props.hint, error: props.error, required: props.required, optional: props.optional, disabled: props.disabled, className: props.className },
987
+ h10(
988
+ "div",
989
+ { ref: boxRef, className: cx("aura-input aura-combo has-icon", open && "is-open") },
990
+ h10(Icon, { name: props.icon || "search", className: "aura-input__icon" }),
991
+ h10("input", {
992
+ ref: inputMerged,
993
+ id,
994
+ type: "text",
995
+ role: "combobox",
996
+ className: "aura-input__control",
997
+ autoComplete: "off",
998
+ "aria-expanded": open,
999
+ "aria-controls": listId,
1000
+ "aria-autocomplete": "list",
1001
+ "aria-activedescendant": open && shown[activeIdx] ? optId(activeIdx) : void 0,
1002
+ "aria-invalid": props.error ? true : void 0,
1003
+ "aria-describedby": props.error ? id + "-error" : props.hint ? id + "-hint" : void 0,
1004
+ placeholder: props.placeholder,
1005
+ disabled: props.disabled,
1006
+ readOnly: props.readOnly,
1007
+ required: props.required,
1008
+ name: props.name,
1009
+ value: text,
1010
+ onChange: function(e) {
1011
+ setQuery(e.target.value);
1012
+ setActive(0);
1013
+ if (!open) setOpen(true);
1014
+ if (props.onSearch) props.onSearch(e.target.value);
1015
+ },
1016
+ onClick: openList,
1017
+ onKeyDown,
1018
+ onBlur: function() {
1019
+ setTimeout(function() {
1020
+ if (listRef.current && listRef.current.contains(document.activeElement)) return;
1021
+ setOpen(false);
1022
+ setQuery(null);
1023
+ }, 0);
1024
+ }
1025
+ }),
1026
+ props.clearable !== false && value != null && !props.disabled ? h10("button", {
1027
+ type: "button",
1028
+ className: "aura-combo__clear",
1029
+ "aria-label": t.clear(props.label),
1030
+ tabIndex: -1,
1031
+ onClick: function() {
1032
+ setValue(null);
1033
+ setQuery(null);
1034
+ if (inputRef.current) inputRef.current.focus();
1035
+ }
1036
+ }, h10(Icon, { name: "x" })) : null,
1037
+ h10(
1038
+ "button",
1039
+ {
1040
+ type: "button",
1041
+ tabIndex: -1,
1042
+ "aria-hidden": true,
1043
+ className: "aura-combo__toggle",
1044
+ onPointerDown: function(e) {
1045
+ e.preventDefault();
1046
+ },
1047
+ onClick: function() {
1048
+ if (open) close();
1049
+ else {
1050
+ openList();
1051
+ inputRef.current && inputRef.current.focus();
1052
+ }
1053
+ }
1054
+ },
1055
+ h10(Icon, { name: "chevron-down" })
1056
+ )
1057
+ ),
1058
+ list
1059
+ );
1060
+ });
1061
+
1062
+ // src/DatePicker.js
1063
+ var React12 = __toESM(require("react"), 1);
1064
+ var import_react_dom3 = require("react-dom");
1065
+ var h11 = React12.createElement;
1066
+ var ERA = /^พ\.ศ\.\s?|\s?(BE|พ\.ศ\.)$/g;
1067
+ var pad = function(n2) {
1068
+ return (n2 < 10 ? "0" : "") + n2;
1069
+ };
1070
+ function toISO(d) {
1071
+ return d ? d.getFullYear() + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate()) : null;
1072
+ }
1073
+ function fromISO(s) {
1074
+ if (!s) return null;
1075
+ var m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(s);
1076
+ return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null;
1077
+ }
1078
+ function addDays(d, n2) {
1079
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate() + n2);
1080
+ }
1081
+ function addMonths(d, n2) {
1082
+ var t = new Date(d.getFullYear(), d.getMonth() + n2, 1);
1083
+ var last = new Date(t.getFullYear(), t.getMonth() + 1, 0).getDate();
1084
+ return new Date(t.getFullYear(), t.getMonth(), Math.min(d.getDate(), last));
1085
+ }
1086
+ function same(a, b) {
1087
+ return !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
1088
+ }
1089
+ function localeTag(locale, calendar) {
1090
+ return (locale === "en" ? "en-GB" : "th-TH") + "-u-ca-" + (calendar === "gregory" ? "gregory" : "buddhist");
1091
+ }
1092
+ var fmtCache = {};
1093
+ var PRESETS = { short: { day: "numeric", month: "short", year: "numeric" }, long: { day: "numeric", month: "long", year: "numeric" }, numeric: { day: "2-digit", month: "2-digit", year: "numeric" } };
1094
+ function fmt(tag, opts, d) {
1095
+ var k = tag + JSON.stringify(opts);
1096
+ if (!fmtCache[k]) fmtCache[k] = new Intl.DateTimeFormat(tag, opts);
1097
+ return fmtCache[k].format(d);
1098
+ }
1099
+ function formatDate(iso, opts) {
1100
+ var o = opts || {}, d = fromISO(iso);
1101
+ if (!d) return "";
1102
+ var f = typeof o.format === "object" ? o.format : PRESETS[o.format || "short"];
1103
+ return fmt(localeTag(o.locale, o.calendar), f, d).replace(ERA, "");
1104
+ }
1105
+ var MONTHS = null;
1106
+ function monthIndex(word) {
1107
+ if (!MONTHS) {
1108
+ MONTHS = {};
1109
+ ["th-TH", "en-GB"].forEach(function(tag) {
1110
+ ["short", "long"].forEach(function(w) {
1111
+ for (var i = 0; i < 12; i++) {
1112
+ var n2 = new Intl.DateTimeFormat(tag, { month: w }).format(new Date(2020, i, 1)).toLowerCase().replace(/\.$/, "");
1113
+ MONTHS[n2] = i;
1114
+ if (/^[a-z]/.test(n2)) MONTHS[n2.slice(0, 3)] = i;
1115
+ }
1116
+ });
1117
+ });
1118
+ }
1119
+ var k = word.toLowerCase().replace(/\.$/, "");
1120
+ return MONTHS[k] != null ? MONTHS[k] : -1;
1121
+ }
1122
+ function parseDate(text) {
1123
+ var s = String(text || "").trim();
1124
+ var m = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(s), y, mo, d;
1125
+ if (m) {
1126
+ y = +m[1];
1127
+ mo = +m[2];
1128
+ d = +m[3];
1129
+ } else if (m = /^(\d{1,2})[\/.\-](\d{1,2})[\/.\-](\d{4})$/.exec(s)) {
1130
+ d = +m[1];
1131
+ mo = +m[2];
1132
+ y = +m[3];
1133
+ } else if ((m = /^(\d{1,2})\s+(\S+)\s+(\d{4})$/.exec(s.replace(ERA, "").trim())) && monthIndex(m[2]) >= 0) {
1134
+ d = +m[1];
1135
+ mo = monthIndex(m[2]) + 1;
1136
+ y = +m[3];
1137
+ } else return null;
1138
+ if (y >= 2400) y -= 543;
1139
+ var dt = new Date(y, mo - 1, d);
1140
+ return dt.getMonth() === mo - 1 && dt.getDate() === d ? toISO(dt) : null;
1141
+ }
1142
+ var Calendar = React12.forwardRef(function Calendar2(props, ref) {
1143
+ var ctx = useAuraLocale(), locale = props.locale || ctx.locale || "th", calendar = props.calendar || ctx.calendar || "buddhist", tag = localeTag(locale, calendar);
1144
+ var weekStart = props.weekStartsOn == null ? 0 : props.weekStartsOn;
1145
+ var today = /* @__PURE__ */ new Date();
1146
+ today = new Date(today.getFullYear(), today.getMonth(), today.getDate());
1147
+ var min = fromISO(props.min), max = fromISO(props.max);
1148
+ var start = fromISO(props.start), end = fromISO(props.end);
1149
+ var focusState = React12.useState(fromISO(props.focus) || start || today);
1150
+ var focusDate = focusState[0], setFocus = focusState[1];
1151
+ var viewState = React12.useState("days"), view = viewState[0], setView = viewState[1];
1152
+ var hoverState = React12.useState(null);
1153
+ var gridRef = React12.useRef(null), gridMerged = useMergedRef(ref, gridRef), moved = React12.useRef(false);
1154
+ var th = locale !== "en";
1155
+ function disabled(d) {
1156
+ return min && d < min || max && d > max || props.isDateDisabled && props.isDateDisabled(toISO(d));
1157
+ }
1158
+ React12.useEffect(function() {
1159
+ if (!moved.current) return;
1160
+ moved.current = false;
1161
+ var el = gridRef.current && gridRef.current.querySelector('[data-date="' + toISO(focusDate) + '"]');
1162
+ if (el) el.focus();
1163
+ });
1164
+ React12.useEffect(function() {
1165
+ if (props.autoFocus === false) return;
1166
+ var el = gridRef.current && gridRef.current.querySelector('[tabindex="0"]');
1167
+ if (el) el.focus();
1168
+ }, []);
1169
+ function move(d) {
1170
+ moved.current = true;
1171
+ setFocus(d);
1172
+ }
1173
+ var first = new Date(focusDate.getFullYear(), focusDate.getMonth(), 1);
1174
+ var lead = (first.getDay() - weekStart + 7) % 7;
1175
+ var gridStart = addDays(first, -lead);
1176
+ var days = [];
1177
+ for (var i = 0; i < 42; i++) days.push(addDays(gridStart, i));
1178
+ var weeks = [];
1179
+ for (var w = 0; w < 6; w++) weeks.push(days.slice(w * 7, w * 7 + 7));
1180
+ if (weeks[5][0].getMonth() !== focusDate.getMonth()) weeks.pop();
1181
+ function onKey(e, d) {
1182
+ var k = e.key, n2 = null;
1183
+ if (k === "ArrowLeft") n2 = addDays(d, -1);
1184
+ else if (k === "ArrowRight") n2 = addDays(d, 1);
1185
+ else if (k === "ArrowUp") n2 = addDays(d, -7);
1186
+ else if (k === "ArrowDown") n2 = addDays(d, 7);
1187
+ else if (k === "Home") n2 = addDays(d, -((d.getDay() - weekStart + 7) % 7));
1188
+ else if (k === "End") n2 = addDays(d, 6 - (d.getDay() - weekStart + 7) % 7);
1189
+ else if (k === "PageUp") n2 = addMonths(d, e.shiftKey ? -12 : -1);
1190
+ else if (k === "PageDown") n2 = addMonths(d, e.shiftKey ? 12 : 1);
1191
+ else if (k === "Enter" || k === " ") {
1192
+ e.preventDefault();
1193
+ if (!disabled(d)) props.onSelect(toISO(d));
1194
+ return;
1195
+ }
1196
+ if (n2) {
1197
+ e.preventDefault();
1198
+ move(n2);
1199
+ }
1200
+ }
1201
+ var hover = hoverState[0];
1202
+ var rangeEnd = end || (props.range && start && hover ? hover : null);
1203
+ function inRange(d) {
1204
+ if (!props.range || !start || !rangeEnd) return false;
1205
+ var a = start < rangeEnd ? start : rangeEnd, b = start < rangeEnd ? rangeEnd : start;
1206
+ return d > a && d < b;
1207
+ }
1208
+ var monthTitle = fmt(tag, { month: "long", year: "numeric" }, focusDate).replace(ERA, "");
1209
+ var weekdayNames = weeks[0].map(function(d) {
1210
+ return { short: fmt(tag, { weekday: th ? "narrow" : "short" }, d), long: fmt(tag, { weekday: "long" }, d) };
1211
+ });
1212
+ if (view === "years") {
1213
+ var yr = focusDate.getFullYear(), base = yr - yr % 12;
1214
+ var years = [];
1215
+ for (var y = base; y < base + 12; y++) years.push(y);
1216
+ return h11(
1217
+ "div",
1218
+ { className: "aura-cal", ref: gridMerged },
1219
+ h11(
1220
+ "div",
1221
+ { className: "aura-cal__head" },
1222
+ h11(IconButton, { icon: "chevron-left", label: th ? "\u0E0A\u0E48\u0E27\u0E07\u0E1B\u0E35\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32" : "Previous years", onClick: function() {
1223
+ setFocus(new Date(yr - 12, focusDate.getMonth(), 1));
1224
+ } }),
1225
+ h11(
1226
+ "button",
1227
+ { type: "button", className: "aura-cal__title", onClick: function() {
1228
+ setView("days");
1229
+ } },
1230
+ fmt(tag, { year: "numeric" }, new Date(base, 0, 1)).replace(ERA, "") + " \u2013 " + fmt(tag, { year: "numeric" }, new Date(base + 11, 0, 1)).replace(ERA, "")
1231
+ ),
1232
+ h11(IconButton, { icon: "chevron-right", label: th ? "\u0E0A\u0E48\u0E27\u0E07\u0E1B\u0E35\u0E16\u0E31\u0E14\u0E44\u0E1B" : "Next years", onClick: function() {
1233
+ setFocus(new Date(yr + 12, focusDate.getMonth(), 1));
1234
+ } })
1235
+ ),
1236
+ h11("div", { className: "aura-cal__years" }, years.map(function(y2) {
1237
+ var d = new Date(y2, focusDate.getMonth(), 1);
1238
+ return h11(
1239
+ "button",
1240
+ {
1241
+ key: y2,
1242
+ type: "button",
1243
+ tabIndex: y2 === yr ? 0 : -1,
1244
+ className: cx("aura-cal__year", y2 === yr && "is-selected"),
1245
+ onClick: function() {
1246
+ setFocus(new Date(y2, focusDate.getMonth(), Math.min(focusDate.getDate(), 28)));
1247
+ setView("days");
1248
+ moved.current = true;
1249
+ }
1250
+ },
1251
+ fmt(tag, { year: "numeric" }, d).replace(ERA, "")
1252
+ );
1253
+ }))
1254
+ );
1255
+ }
1256
+ return h11(
1257
+ "div",
1258
+ { className: "aura-cal", ref: gridMerged },
1259
+ h11(
1260
+ "div",
1261
+ { className: "aura-cal__head" },
1262
+ h11(IconButton, { icon: "chevron-left", label: th ? "\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32" : "Previous month", onClick: function() {
1263
+ setFocus(addMonths(focusDate, -1));
1264
+ } }),
1265
+ h11(
1266
+ "button",
1267
+ { type: "button", className: "aura-cal__title", "aria-live": "polite", onClick: function() {
1268
+ setView("years");
1269
+ } },
1270
+ monthTitle,
1271
+ h11(Icon, { name: "chevron-down", size: 14 })
1272
+ ),
1273
+ h11(IconButton, { icon: "chevron-right", label: th ? "\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E16\u0E31\u0E14\u0E44\u0E1B" : "Next month", onClick: function() {
1274
+ setFocus(addMonths(focusDate, 1));
1275
+ } })
1276
+ ),
1277
+ h11(
1278
+ "table",
1279
+ { role: "grid", className: "aura-cal__grid", "aria-label": monthTitle },
1280
+ h11("thead", null, h11("tr", null, weekdayNames.map(function(n2, i2) {
1281
+ return h11("th", { key: i2, scope: "col", abbr: n2.long }, h11("span", { "aria-hidden": true }, n2.short));
1282
+ }))),
1283
+ h11("tbody", { onMouseLeave: function() {
1284
+ hoverState[1](null);
1285
+ } }, weeks.map(function(wk, wi) {
1286
+ return h11("tr", { key: wi }, wk.map(function(d) {
1287
+ var iso = toISO(d), out = d.getMonth() !== focusDate.getMonth(), dis = disabled(d);
1288
+ var isStart = same(d, start), isEnd = same(d, end) || !end && props.range && same(d, hover) && start;
1289
+ var sel = isStart || same(d, end);
1290
+ return h11(
1291
+ "td",
1292
+ {
1293
+ key: iso,
1294
+ role: "gridcell",
1295
+ "aria-selected": sel || void 0,
1296
+ className: cx(inRange(d) && "is-in-range", props.range && isStart && rangeEnd && "is-range-start", props.range && isEnd && start && "is-range-end")
1297
+ },
1298
+ h11("button", {
1299
+ type: "button",
1300
+ "data-date": iso,
1301
+ tabIndex: same(d, focusDate) ? 0 : -1,
1302
+ disabled: dis,
1303
+ "aria-label": fmt(tag, { weekday: "long", day: "numeric", month: "long", year: "numeric" }, d),
1304
+ "aria-current": same(d, today) ? "date" : void 0,
1305
+ "aria-pressed": sel || void 0,
1306
+ className: cx("aura-cal__day", out && "is-outside", sel && "is-selected", same(d, today) && "is-today"),
1307
+ onClick: function() {
1308
+ setFocus(d);
1309
+ props.onSelect(iso);
1310
+ },
1311
+ onKeyDown: function(e) {
1312
+ onKey(e, d);
1313
+ },
1314
+ onMouseEnter: function() {
1315
+ if (props.range) hoverState[1](d);
1316
+ }
1317
+ }, d.getDate())
1318
+ );
1319
+ }));
1320
+ }))
1321
+ ),
1322
+ props.footer === false ? null : h11(
1323
+ "div",
1324
+ { className: "aura-cal__foot" },
1325
+ h11("button", { type: "button", className: "aura-cal__link", disabled: disabled(today), onClick: function() {
1326
+ move(today);
1327
+ props.onSelect(toISO(today));
1328
+ } }, th ? "\u0E27\u0E31\u0E19\u0E19\u0E35\u0E49" : "Today"),
1329
+ props.onClear ? h11("button", { type: "button", className: "aura-cal__link", onClick: props.onClear }, th ? "\u0E25\u0E49\u0E32\u0E07" : "Clear") : null
1330
+ )
1331
+ );
1332
+ });
1333
+ function useCalendarPopover(boxRef) {
1334
+ var openState = React12.useState(false), open = openState[0], setOpen = openState[1];
1335
+ var pos = React12.useState(null), popRef = React12.useRef(null), mounted = useMounted();
1336
+ function place() {
1337
+ if (!boxRef.current) return;
1338
+ var r = boxRef.current.getBoundingClientRect(), H = 380;
1339
+ var up = window.innerHeight - r.bottom < H && r.top > H;
1340
+ var left = Math.max(8, Math.min(r.left, window.innerWidth - 320 - 8));
1341
+ pos[1](up ? { left, bottom: window.innerHeight - r.top + 4 } : { left, top: r.bottom + 4 });
1342
+ }
1343
+ useIsoLayoutEffect(function() {
1344
+ if (open) place();
1345
+ }, [open]);
1346
+ React12.useEffect(function() {
1347
+ if (!open) return;
1348
+ function outside(e) {
1349
+ if (boxRef.current && boxRef.current.contains(e.target)) return;
1350
+ if (popRef.current && popRef.current.contains(e.target)) return;
1351
+ setOpen(false);
1352
+ }
1353
+ document.addEventListener("pointerdown", outside, true);
1354
+ window.addEventListener("resize", place);
1355
+ window.addEventListener("scroll", place, true);
1356
+ return function() {
1357
+ document.removeEventListener("pointerdown", outside, true);
1358
+ window.removeEventListener("resize", place);
1359
+ window.removeEventListener("scroll", place, true);
1360
+ };
1361
+ }, [open]);
1362
+ return { open, setOpen, pos: pos[0], popRef, mounted };
1363
+ }
1364
+ function DateField(props) {
1365
+ var editState = React12.useState(null), editing = editState[0], setEditing = editState[1];
1366
+ return h11(
1367
+ Field,
1368
+ { id: props.id, label: props.label, hint: props.hint, error: props.error, required: props.required, optional: props.optional, disabled: props.disabled, className: props.className },
1369
+ h11(
1370
+ "div",
1371
+ { ref: props.boxRef, className: cx("aura-input aura-date", props.open && "is-open") },
1372
+ h11("input", {
1373
+ ref: props.inputRef,
1374
+ id: props.id,
1375
+ type: "text",
1376
+ inputMode: "numeric",
1377
+ autoComplete: "off",
1378
+ className: "aura-input__control",
1379
+ value: editing != null ? editing : props.display,
1380
+ placeholder: props.placeholder,
1381
+ disabled: props.disabled,
1382
+ required: props.required,
1383
+ name: props.name,
1384
+ "aria-invalid": props.error ? true : void 0,
1385
+ "aria-describedby": props.error ? props.id + "-error" : props.hint ? props.id + "-hint" : void 0,
1386
+ onChange: function(e) {
1387
+ setEditing(e.target.value);
1388
+ },
1389
+ onBlur: function() {
1390
+ if (editing != null) {
1391
+ props.onCommit(editing);
1392
+ setEditing(null);
1393
+ }
1394
+ },
1395
+ onKeyDown: function(e) {
1396
+ if (e.key === "Enter" && editing != null) {
1397
+ e.preventDefault();
1398
+ props.onCommit(editing);
1399
+ setEditing(null);
1400
+ } else if (e.key === "ArrowDown" && (e.altKey || editing == null)) {
1401
+ e.preventDefault();
1402
+ props.onToggle(true);
1403
+ } else if (e.key === "Escape" && props.open) {
1404
+ e.preventDefault();
1405
+ props.onToggle(false);
1406
+ }
1407
+ }
1408
+ }),
1409
+ props.clearable !== false && props.hasValue && !props.disabled ? h11("button", { type: "button", tabIndex: -1, className: "aura-combo__clear", "aria-label": props.clearLabel, onClick: props.onClear }, h11(Icon, { name: "x" })) : null,
1410
+ h11("button", {
1411
+ type: "button",
1412
+ className: "aura-date__toggle",
1413
+ disabled: props.disabled,
1414
+ "aria-label": props.toggleLabel,
1415
+ "aria-haspopup": "dialog",
1416
+ "aria-expanded": props.open,
1417
+ "aria-controls": props.open ? props.dialogId : void 0,
1418
+ onClick: function() {
1419
+ props.onToggle(!props.open);
1420
+ }
1421
+ }, h11(Icon, { name: "calendar" }))
1422
+ )
1423
+ );
1424
+ }
1425
+ var DatePicker = React12.forwardRef(function DatePicker2(props, ref) {
1426
+ var auto = uid(), id = props.id || auto, dialogId = id + "-cal";
1427
+ var ctx = useAuraLocale(), locale = props.locale || ctx.locale || "th", calendar = props.calendar || ctx.calendar || "buddhist", th = locale !== "en";
1428
+ var st = useMaybeControlled(props.value, props.defaultValue == null ? null : props.defaultValue, props.onChange);
1429
+ var boxRef = React12.useRef(null), inputRef = React12.useRef(null), inputMerged = useMergedRef(ref, inputRef);
1430
+ var pop = useCalendarPopover(boxRef);
1431
+ function commit(text) {
1432
+ if (!text.trim()) {
1433
+ st[1](null);
1434
+ return;
1435
+ }
1436
+ var iso = parseDate(text);
1437
+ if (iso) st[1](iso);
1438
+ }
1439
+ function close() {
1440
+ pop.setOpen(false);
1441
+ if (inputRef.current) inputRef.current.focus();
1442
+ }
1443
+ var cal = pop.open && pop.mounted && pop.pos ? (0, import_react_dom3.createPortal)(
1444
+ h11(
1445
+ "div",
1446
+ {
1447
+ ref: pop.popRef,
1448
+ id: dialogId,
1449
+ role: "dialog",
1450
+ "aria-modal": false,
1451
+ "aria-label": props.label || (th ? "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48" : "Choose date"),
1452
+ className: "aura-cal__popover",
1453
+ style: pop.pos,
1454
+ onKeyDown: function(e) {
1455
+ if (e.key === "Escape") {
1456
+ e.stopPropagation();
1457
+ close();
1458
+ } else trapTab(e, pop.popRef.current);
1459
+ }
1460
+ },
1461
+ h11(Calendar, {
1462
+ locale,
1463
+ calendar,
1464
+ weekStartsOn: props.weekStartsOn,
1465
+ min: props.min,
1466
+ max: props.max,
1467
+ isDateDisabled: props.isDateDisabled,
1468
+ start: st[0],
1469
+ focus: st[0],
1470
+ onSelect: function(iso) {
1471
+ st[1](iso);
1472
+ close();
1473
+ }
1474
+ })
1475
+ ),
1476
+ document.body
1477
+ ) : null;
1478
+ return h11(
1479
+ React12.Fragment,
1480
+ null,
1481
+ h11(DateField, {
1482
+ id,
1483
+ dialogId,
1484
+ label: props.label,
1485
+ hint: props.hint,
1486
+ error: props.error,
1487
+ required: props.required,
1488
+ optional: props.optional,
1489
+ disabled: props.disabled,
1490
+ className: props.className,
1491
+ name: props.name,
1492
+ boxRef,
1493
+ inputRef: inputMerged,
1494
+ open: pop.open,
1495
+ display: formatDate(st[0], { locale, calendar }),
1496
+ placeholder: props.placeholder || (th ? "\u0E27\u0E27/\u0E14\u0E14/\u0E1B\u0E1B\u0E1B\u0E1B" : "dd/mm/yyyy"),
1497
+ hasValue: st[0] != null,
1498
+ clearable: props.clearable,
1499
+ onClear: function() {
1500
+ st[1](null);
1501
+ inputRef.current && inputRef.current.focus();
1502
+ },
1503
+ clearLabel: th ? "\u0E25\u0E49\u0E32\u0E07\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48" : "Clear date",
1504
+ toggleLabel: th ? "\u0E40\u0E1B\u0E34\u0E14\u0E1B\u0E0F\u0E34\u0E17\u0E34\u0E19" : "Open calendar",
1505
+ onCommit: commit,
1506
+ onToggle: function(o) {
1507
+ pop.setOpen(o);
1508
+ if (!o && inputRef.current) inputRef.current.focus();
1509
+ }
1510
+ }),
1511
+ cal
1512
+ );
1513
+ });
1514
+ var DateRangePicker = React12.forwardRef(function DateRangePicker2(props, ref) {
1515
+ var auto = uid(), id = props.id || auto, dialogId = id + "-cal";
1516
+ var ctx = useAuraLocale(), locale = props.locale || ctx.locale || "th", calendar = props.calendar || ctx.calendar || "buddhist", th = locale !== "en";
1517
+ var st = useMaybeControlled(props.value, props.defaultValue || { start: null, end: null }, props.onChange);
1518
+ var v = st[0] || { start: null, end: null };
1519
+ var draft = React12.useState(null);
1520
+ var boxRef = React12.useRef(null), inputRef = React12.useRef(null), inputMerged = useMergedRef(ref, inputRef);
1521
+ var pop = useCalendarPopover(boxRef);
1522
+ var o = { locale, calendar };
1523
+ function show(r) {
1524
+ if (!r.start) return "";
1525
+ if (!r.end) return formatDate(r.start, o) + " \u2013";
1526
+ return formatDate(r.start, o) + " \u2013 " + formatDate(r.end, o);
1527
+ }
1528
+ function commit(text) {
1529
+ var parts = String(text).split(/\s[–-]\s|\s*–\s*/);
1530
+ if (!text.trim()) {
1531
+ st[1]({ start: null, end: null });
1532
+ return;
1533
+ }
1534
+ var a = parseDate(parts[0]), b = parseDate(parts[1] || "");
1535
+ if (a && b) st[1](a <= b ? { start: a, end: b } : { start: b, end: a });
1536
+ }
1537
+ function close() {
1538
+ pop.setOpen(false);
1539
+ draft[1](null);
1540
+ if (inputRef.current) inputRef.current.focus();
1541
+ }
1542
+ function pick(iso) {
1543
+ if (!draft[0]) {
1544
+ draft[1](iso);
1545
+ return;
1546
+ }
1547
+ var a = draft[0], b = iso;
1548
+ st[1](a <= b ? { start: a, end: b } : { start: b, end: a });
1549
+ close();
1550
+ }
1551
+ var cal = pop.open && pop.mounted && pop.pos ? (0, import_react_dom3.createPortal)(
1552
+ h11(
1553
+ "div",
1554
+ {
1555
+ ref: pop.popRef,
1556
+ id: dialogId,
1557
+ role: "dialog",
1558
+ "aria-modal": false,
1559
+ "aria-label": props.label || (th ? "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E0A\u0E48\u0E27\u0E07\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48" : "Choose dates"),
1560
+ className: "aura-cal__popover",
1561
+ style: pop.pos,
1562
+ onKeyDown: function(e) {
1563
+ if (e.key === "Escape") {
1564
+ e.stopPropagation();
1565
+ close();
1566
+ } else trapTab(e, pop.popRef.current);
1567
+ }
1568
+ },
1569
+ h11("p", { className: "aura-cal__hint", "aria-live": "polite" }, draft[0] ? th ? "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E27\u0E31\u0E19\u0E2A\u0E34\u0E49\u0E19\u0E2A\u0E38\u0E14" : "Choose the end date" : th ? "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E27\u0E31\u0E19\u0E40\u0E23\u0E34\u0E48\u0E21\u0E15\u0E49\u0E19" : "Choose the start date"),
1570
+ h11(Calendar, {
1571
+ range: true,
1572
+ locale,
1573
+ calendar,
1574
+ weekStartsOn: props.weekStartsOn,
1575
+ min: props.min,
1576
+ max: props.max,
1577
+ isDateDisabled: props.isDateDisabled,
1578
+ start: draft[0] || v.start,
1579
+ end: draft[0] ? null : v.end,
1580
+ focus: draft[0] || v.start,
1581
+ onSelect: pick
1582
+ })
1583
+ ),
1584
+ document.body
1585
+ ) : null;
1586
+ return h11(
1587
+ React12.Fragment,
1588
+ null,
1589
+ h11(DateField, {
1590
+ id,
1591
+ dialogId,
1592
+ label: props.label,
1593
+ hint: props.hint,
1594
+ error: props.error,
1595
+ required: props.required,
1596
+ optional: props.optional,
1597
+ disabled: props.disabled,
1598
+ className: props.className,
1599
+ name: props.name,
1600
+ boxRef,
1601
+ inputRef: inputMerged,
1602
+ open: pop.open,
1603
+ display: show(v),
1604
+ placeholder: props.placeholder || (th ? "\u0E27\u0E27/\u0E14\u0E14/\u0E1B\u0E1B\u0E1B\u0E1B \u2013 \u0E27\u0E27/\u0E14\u0E14/\u0E1B\u0E1B\u0E1B\u0E1B" : "dd/mm/yyyy \u2013 dd/mm/yyyy"),
1605
+ hasValue: v.start != null,
1606
+ clearable: props.clearable,
1607
+ onClear: function() {
1608
+ st[1]({ start: null, end: null });
1609
+ inputRef.current && inputRef.current.focus();
1610
+ },
1611
+ clearLabel: th ? "\u0E25\u0E49\u0E32\u0E07\u0E0A\u0E48\u0E27\u0E07\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48" : "Clear dates",
1612
+ toggleLabel: th ? "\u0E40\u0E1B\u0E34\u0E14\u0E1B\u0E0F\u0E34\u0E17\u0E34\u0E19" : "Open calendar",
1613
+ onCommit: commit,
1614
+ onToggle: function(op) {
1615
+ pop.setOpen(op);
1616
+ draft[1](null);
1617
+ if (!op && inputRef.current) inputRef.current.focus();
1618
+ }
1619
+ }),
1620
+ cal
1621
+ );
1622
+ });
1623
+
1624
+ // src/feedback.js
1625
+ var React13 = __toESM(require("react"), 1);
1626
+ var import_react_dom4 = require("react-dom");
1627
+ var h12 = React13.createElement;
1628
+ var ALERT_ICON = { info: "info", success: "circle-check", warning: "triangle-alert", danger: "circle-alert" };
1629
+ var Alert = React13.forwardRef(function Alert2(props, ref) {
1630
+ var t = useStrings();
1631
+ var tone2 = props.tone || "info";
1632
+ return h12(
1633
+ "div",
1634
+ {
1635
+ ref,
1636
+ className: cx("aura-alert", "aura-alert--" + tone2, props.className),
1637
+ role: tone2 === "danger" || tone2 === "warning" ? "alert" : "status"
1638
+ },
1639
+ h12(Icon, { name: ALERT_ICON[tone2], className: "aura-alert__icon" }),
1640
+ h12(
1641
+ "div",
1642
+ { className: "aura-alert__body" },
1643
+ props.title ? h12("p", { className: "aura-alert__title" }, props.title) : null,
1644
+ props.children ? h12("div", { className: "aura-alert__text" }, props.children) : null,
1645
+ props.action ? h12("div", { className: "aura-alert__action" }, props.action) : null
1646
+ ),
1647
+ props.onDismiss ? h12(IconButton, { icon: "x", label: t.dismiss, className: "aura-alert__close", onClick: props.onDismiss }) : null
1648
+ );
1649
+ });
1650
+ var toastState = { list: [], subs: [], n: 0 };
1651
+ function emitToasts() {
1652
+ toastState.subs.forEach(function(f) {
1653
+ f(toastState.list.slice());
1654
+ });
1655
+ }
1656
+ function toast(opts) {
1657
+ if (typeof opts === "string") opts = { title: opts };
1658
+ var id = opts.id || "t" + ++toastState.n;
1659
+ toastState.list = toastState.list.filter(function(t) {
1660
+ return t.id !== id;
1661
+ }).concat([Object.assign({ tone: "info" }, opts, { id })]).slice(-3);
1662
+ emitToasts();
1663
+ return id;
1664
+ }
1665
+ toast.dismiss = function(id) {
1666
+ toastState.list = toastState.list.filter(function(t) {
1667
+ return t.id !== id;
1668
+ });
1669
+ emitToasts();
1670
+ };
1671
+ function ToastItem(props) {
1672
+ var str = useStrings();
1673
+ var t = props.toast, timer = React13.useRef(null), left = React13.useRef(t.duration || 5e3), since = React13.useRef(0);
1674
+ function start() {
1675
+ if (left.current === Infinity) return;
1676
+ since.current = Date.now();
1677
+ timer.current = setTimeout(function() {
1678
+ toast.dismiss(t.id);
1679
+ }, left.current);
1680
+ }
1681
+ function pause() {
1682
+ if (timer.current) {
1683
+ clearTimeout(timer.current);
1684
+ timer.current = null;
1685
+ left.current -= Date.now() - since.current;
1686
+ }
1687
+ }
1688
+ React13.useEffect(function() {
1689
+ start();
1690
+ return pause;
1691
+ }, []);
1692
+ return h12(
1693
+ "div",
1694
+ {
1695
+ className: cx("aura-toast", "aura-toast--" + t.tone),
1696
+ role: t.tone === "danger" ? "alert" : "status",
1697
+ onMouseEnter: pause,
1698
+ onMouseLeave: start,
1699
+ onFocus: pause,
1700
+ onBlur: start
1701
+ },
1702
+ h12(Icon, { name: ALERT_ICON[t.tone] || "info", className: "aura-toast__icon" }),
1703
+ h12(
1704
+ "div",
1705
+ { className: "aura-toast__body" },
1706
+ h12("p", { className: "aura-toast__title" }, t.title),
1707
+ t.description ? h12("p", { className: "aura-toast__text" }, t.description) : null
1708
+ ),
1709
+ t.action ? h12("button", {
1710
+ type: "button",
1711
+ className: "aura-toast__action",
1712
+ onClick: function() {
1713
+ t.action.onClick && t.action.onClick();
1714
+ toast.dismiss(t.id);
1715
+ }
1716
+ }, t.action.label) : null,
1717
+ h12(IconButton, { icon: "x", label: str.dismissToast, className: "aura-toast__close", onClick: function() {
1718
+ toast.dismiss(t.id);
1719
+ } })
1720
+ );
1721
+ }
1722
+ function Toaster(props) {
1723
+ var t = useStrings();
1724
+ var mounted = useMounted();
1725
+ var s = React13.useState(toastState.list);
1726
+ React13.useEffect(function() {
1727
+ toastState.subs.push(s[1]);
1728
+ return function() {
1729
+ toastState.subs = toastState.subs.filter(function(f) {
1730
+ return f !== s[1];
1731
+ });
1732
+ };
1733
+ }, []);
1734
+ if (!mounted) return null;
1735
+ return (0, import_react_dom4.createPortal)(h12(
1736
+ "div",
1737
+ { className: cx("aura-toaster", props && props.position === "top" && "is-top"), role: "region", "aria-live": "polite", "aria-label": t.notifications },
1738
+ s[0].map(function(t2) {
1739
+ return h12(ToastItem, { key: t2.id, toast: t2 });
1740
+ })
1741
+ ), document.body);
1742
+ }
1743
+ var Tooltip = React13.forwardRef(function Tooltip2(props, ref) {
1744
+ var id = uid(), st = React13.useState(false), open = props.open !== void 0 ? props.open : st[0], set = st[1];
1745
+ var anchor = React13.useRef(null), anchorMerged = useMergedRef(ref, anchor), tip = React13.useRef(null), timer = React13.useRef(null);
1746
+ var pos = React13.useState(null);
1747
+ function show(now) {
1748
+ clearTimeout(timer.current);
1749
+ timer.current = setTimeout(function() {
1750
+ set(true);
1751
+ }, now ? 0 : props.delay == null ? 400 : props.delay);
1752
+ }
1753
+ function hide() {
1754
+ clearTimeout(timer.current);
1755
+ set(false);
1756
+ }
1757
+ useIsoLayoutEffect(function() {
1758
+ if (!open || !anchor.current || !tip.current) return;
1759
+ var r = anchor.current.getBoundingClientRect(), t = tip.current.getBoundingClientRect();
1760
+ var side = props.side || "top", top = side === "top" ? r.top - t.height - 8 : r.bottom + 8;
1761
+ if (side === "top" && top < 8) top = r.bottom + 8;
1762
+ var left = Math.max(8, Math.min(r.left + r.width / 2 - t.width / 2, window.innerWidth - t.width - 8));
1763
+ pos[1]({ top, left });
1764
+ }, [open]);
1765
+ React13.useEffect(function() {
1766
+ if (!open) return;
1767
+ function esc(e) {
1768
+ if (e.key === "Escape") hide();
1769
+ }
1770
+ document.addEventListener("keydown", esc);
1771
+ return function() {
1772
+ document.removeEventListener("keydown", esc);
1773
+ };
1774
+ }, [open]);
1775
+ var child = React13.Children.only(props.children);
1776
+ var trigger = h12(
1777
+ "span",
1778
+ {
1779
+ ref: anchorMerged,
1780
+ className: "aura-tooltip-anchor",
1781
+ onMouseEnter: function() {
1782
+ show(false);
1783
+ },
1784
+ onMouseLeave: hide,
1785
+ onFocus: function() {
1786
+ show(true);
1787
+ },
1788
+ onBlur: hide
1789
+ },
1790
+ React13.cloneElement(child, { "aria-describedby": open ? id : child.props["aria-describedby"] })
1791
+ );
1792
+ return h12(
1793
+ React13.Fragment,
1794
+ null,
1795
+ trigger,
1796
+ open ? (0, import_react_dom4.createPortal)(h12("div", {
1797
+ ref: tip,
1798
+ id,
1799
+ role: "tooltip",
1800
+ className: "aura-tooltip",
1801
+ style: { top: pos[0] ? pos[0].top : -9999, left: pos[0] ? pos[0].left : -9999 }
1802
+ }, props.content), document.body) : null
1803
+ );
1804
+ });
1805
+
1806
+ // src/Dialog.js
1807
+ var React15 = __toESM(require("react"), 1);
1808
+ var import_react_dom5 = require("react-dom");
1809
+
1810
+ // src/overlay.js
1811
+ var React14 = __toESM(require("react"), 1);
1812
+ function useModal(open, ref, opts) {
1813
+ var mounted = useMounted();
1814
+ var prev = React14.useRef(null);
1815
+ var o = opts || {};
1816
+ React14.useEffect(function() {
1817
+ if (!open || !mounted) return;
1818
+ prev.current = document.activeElement;
1819
+ var body = document.body, overflow = body.style.overflow;
1820
+ body.style.overflow = "hidden";
1821
+ var el = ref.current;
1822
+ var target = el && (el.querySelector("[data-autofocus]") || el.querySelector(o.bodySelector + " " + FOCUSABLE) || el.querySelector(o.footSelector + " " + FOCUSABLE) || el);
1823
+ if (target && o.autoFocus !== false) target.focus();
1824
+ return function() {
1825
+ body.style.overflow = overflow;
1826
+ if (prev.current && prev.current.focus) prev.current.focus();
1827
+ };
1828
+ }, [open, mounted]);
1829
+ function onKeyDown(e) {
1830
+ if (e.key === "Escape") {
1831
+ e.stopPropagation();
1832
+ if (o.onEscape) o.onEscape();
1833
+ return;
1834
+ }
1835
+ if (e.key !== "Tab" || !ref.current) return;
1836
+ var list = Array.prototype.slice.call(ref.current.querySelectorAll(FOCUSABLE));
1837
+ if (!list.length) {
1838
+ e.preventDefault();
1839
+ return;
1840
+ }
1841
+ var first = list[0], last = list[list.length - 1];
1842
+ if (e.shiftKey && (document.activeElement === first || document.activeElement === ref.current)) {
1843
+ e.preventDefault();
1844
+ last.focus();
1845
+ } else if (!e.shiftKey && document.activeElement === last) {
1846
+ e.preventDefault();
1847
+ first.focus();
1848
+ }
1849
+ }
1850
+ return { ready: open && mounted, onKeyDown };
1851
+ }
1852
+
1853
+ // src/Dialog.js
1854
+ var h13 = React15.createElement;
1855
+ var Dialog = React15.forwardRef(function Dialog2(props, ref) {
1856
+ var t = useStrings();
1857
+ var own = React15.useRef(null), merged = useMergedRef(ref, own), titleId = uid(), descId = uid();
1858
+ function close() {
1859
+ if (props.dismissible !== false && props.onClose) props.onClose();
1860
+ }
1861
+ var modal = useModal(props.open, own, { autoFocus: props.autoFocus, onEscape: close, bodySelector: ".aura-dialog__body", footSelector: ".aura-dialog__foot" });
1862
+ if (!modal.ready) return null;
1863
+ return (0, import_react_dom5.createPortal)(
1864
+ h13(
1865
+ "div",
1866
+ { className: "aura-dialog-layer", onKeyDown: modal.onKeyDown },
1867
+ h13("div", { className: "aura-scrim", onClick: close, "aria-hidden": true }),
1868
+ h13(
1869
+ "div",
1870
+ {
1871
+ ref: merged,
1872
+ role: props.role || "dialog",
1873
+ "aria-modal": true,
1874
+ "aria-labelledby": titleId,
1875
+ "aria-describedby": props.description ? descId : void 0,
1876
+ tabIndex: -1,
1877
+ className: cx("aura-dialog", "aura-dialog--" + (props.size || "md"), props.className)
1878
+ },
1879
+ h13(
1880
+ "div",
1881
+ { className: "aura-dialog__head" },
1882
+ h13("h2", { className: "aura-dialog__title", id: titleId }, props.title),
1883
+ props.dismissible !== false ? h13(IconButton, { icon: "x", label: t.close, className: "aura-dialog__close", onClick: close }) : null
1884
+ ),
1885
+ props.description ? h13("p", { className: "aura-dialog__desc", id: descId }, props.description) : null,
1886
+ props.children ? h13("div", { className: "aura-dialog__body" }, props.children) : null,
1887
+ props.footer ? h13("div", { className: "aura-dialog__foot" }, props.footer) : null
1888
+ )
1889
+ ),
1890
+ document.body
1891
+ );
1892
+ });
1893
+ var Drawer = React15.forwardRef(function Drawer2(props, ref) {
1894
+ var t = useStrings();
1895
+ var own = React15.useRef(null), merged = useMergedRef(ref, own), titleId = uid(), descId = uid();
1896
+ function close() {
1897
+ if (props.dismissible !== false && props.onClose) props.onClose();
1898
+ }
1899
+ var modal = useModal(props.open, own, { autoFocus: props.autoFocus, onEscape: close, bodySelector: ".aura-drawer__body", footSelector: ".aura-drawer__foot" });
1900
+ if (!modal.ready) return null;
1901
+ var side = props.side === "left" ? "left" : "right";
1902
+ return (0, import_react_dom5.createPortal)(
1903
+ h13(
1904
+ "div",
1905
+ { className: "aura-dialog-layer aura-drawer-layer", onKeyDown: modal.onKeyDown },
1906
+ h13("div", { className: "aura-scrim", onClick: close, "aria-hidden": true }),
1907
+ h13(
1908
+ "div",
1909
+ {
1910
+ ref: merged,
1911
+ role: "dialog",
1912
+ "aria-modal": true,
1913
+ "aria-labelledby": props.title ? titleId : void 0,
1914
+ "aria-label": props.title ? void 0 : props["aria-label"],
1915
+ "aria-describedby": props.description ? descId : void 0,
1916
+ tabIndex: -1,
1917
+ className: cx("aura-drawer", "aura-drawer--" + side, "aura-drawer--" + (props.size || "md"), props.className)
1918
+ },
1919
+ props.title || props.dismissible !== false ? h13(
1920
+ "div",
1921
+ { className: "aura-drawer__head" },
1922
+ props.title ? h13("h2", { className: "aura-drawer__title", id: titleId }, props.title) : h13("span", { style: { flex: 1 } }),
1923
+ props.dismissible !== false ? h13(IconButton, { icon: "x", label: t.close, onClick: close }) : null
1924
+ ) : null,
1925
+ props.description ? h13("p", { className: "aura-drawer__desc", id: descId }, props.description) : null,
1926
+ h13("div", { className: "aura-drawer__body" }, props.children),
1927
+ props.footer ? h13("div", { className: "aura-drawer__foot" }, props.footer) : null
1928
+ )
1929
+ ),
1930
+ document.body
1931
+ );
1932
+ });
1933
+
1934
+ // src/DataTable.js
1935
+ var React16 = __toESM(require("react"), 1);
1936
+ var h14 = React16.createElement;
1937
+ var BP = { sm: 640, md: 768, lg: 1024, xl: 1280 };
1938
+ var DEFAULT_COLUMNS = [
1939
+ { key: "id", label: "ID", width: 96, mono: true },
1940
+ { key: "name", label: "NAME", width: 160 },
1941
+ { key: "status", label: "STATUS", width: 112, pill: true },
1942
+ { key: "owner", label: "OWNER" }
1943
+ ];
1944
+ var SKELETON_WIDTHS = ["72%", "56%", "84%", "44%", "64%"];
1945
+ var ROW_H = 48;
1946
+ var OVERSCAN = 8;
1947
+ var FLEX_MIN = 160;
1948
+ var DataTable = React16.forwardRef(function DataTable2(props, ref) {
1949
+ var t = useStrings();
1950
+ var columns = props.columns || DEFAULT_COLUMNS;
1951
+ var byKey = {};
1952
+ columns.forEach(function(c) {
1953
+ byKey[c.key] = c;
1954
+ });
1955
+ var rows = props.rows || [];
1956
+ var rowKey = props.rowKey || columns[0].key;
1957
+ var loading = !!props.loading;
1958
+ var selectable = !!props.selectable;
1959
+ var reorderable = props.reorderable !== false && !!props.columnControls;
1960
+ var controls = !!props.columnControls;
1961
+ var sortState = useMaybeControlled(props.sort, props.defaultSort || null, props.onSortChange);
1962
+ var sort = sortState[0], setSort = sortState[1];
1963
+ var selState = useMaybeControlled(props.selected, props.defaultSelected || [], props.onSelectionChange);
1964
+ var selected = selState[0], setSelected = selState[1];
1965
+ var pageState = useMaybeControlled(props.page, props.defaultPage || 1, props.onPageChange);
1966
+ var orderState = useMaybeControlled(props.columnOrder, columns.map(function(c) {
1967
+ return c.key;
1968
+ }), props.onColumnOrderChange);
1969
+ var hiddenState = useMaybeControlled(props.hiddenColumns, columns.filter(function(c) {
1970
+ return c.hidden;
1971
+ }).map(function(c) {
1972
+ return c.key;
1973
+ }), props.onHiddenColumnsChange);
1974
+ var pinState = useMaybeControlled(props.pinnedColumns, columns.filter(function(c) {
1975
+ return c.pinned;
1976
+ }).map(function(c) {
1977
+ return c.key;
1978
+ }), props.onPinnedColumnsChange);
1979
+ var widthState = React16.useState({});
1980
+ var widths = widthState[0], setWidths = widthState[1];
1981
+ var activeState = React16.useState({ r: 1, c: 0 });
1982
+ var scrollState = React16.useState(0);
1983
+ var scrollTop = scrollState[0], setScrollTop = scrollState[1];
1984
+ var scrolledX = React16.useState(false);
1985
+ var menuState = React16.useState(null);
1986
+ var menu = menuState[0], setMenu = menuState[1];
1987
+ var dragState = React16.useState(null);
1988
+ var drag = dragState[0], setDrag = dragState[1];
1989
+ var gridRef = React16.useRef(null);
1990
+ var wrapRef = React16.useRef(null), wrapMerged = useMergedRef(ref, wrapRef);
1991
+ var boxWidth = React16.useState(null);
1992
+ var measure = !!props.stackBelow || columns.some(function(c) {
1993
+ return c.hideBelow != null;
1994
+ });
1995
+ React16.useEffect(function() {
1996
+ if (!measure || !wrapRef.current || typeof ResizeObserver === "undefined") return;
1997
+ var ro = new ResizeObserver(function(en) {
1998
+ boxWidth[1](en[0].contentRect.width);
1999
+ });
2000
+ ro.observe(wrapRef.current);
2001
+ return function() {
2002
+ ro.disconnect();
2003
+ };
2004
+ }, [measure]);
2005
+ var stacked = !!props.stackBelow && boxWidth[0] != null && boxWidth[0] < props.stackBelow;
2006
+ function tooNarrow(c) {
2007
+ if (c.hideBelow == null || boxWidth[0] == null || stacked) return false;
2008
+ var px = typeof c.hideBelow === "number" ? c.hideBelow : BP[c.hideBelow];
2009
+ return px != null && boxWidth[0] < px;
2010
+ }
2011
+ var scrollRef = React16.useRef(null);
2012
+ var pending = React16.useRef(null);
2013
+ var resizing = React16.useRef(false);
2014
+ useIsoLayoutEffect(function() {
2015
+ if (stacked || !gridRef.current) return;
2016
+ var els = gridRef.current.querySelectorAll('.aura-table__td button, .aura-table__td a[href], .aura-table__td input, .aura-table__td select, .aura-table__td textarea, .aura-table__td [tabindex="0"]');
2017
+ for (var i2 = 0; i2 < els.length; i2++) if (els[i2].tabIndex !== -1) els[i2].tabIndex = -1;
2018
+ });
2019
+ function widthOf(c) {
2020
+ return widths[c.key] != null ? widths[c.key] : c.width;
2021
+ }
2022
+ var order = orderState[0].filter(function(k) {
2023
+ return byKey[k];
2024
+ });
2025
+ columns.forEach(function(c) {
2026
+ if (order.indexOf(c.key) < 0) order.push(c.key);
2027
+ });
2028
+ var hidden = hiddenState[0], pinnedKeys = pinState[0];
2029
+ var shown = order.filter(function(k) {
2030
+ return hidden.indexOf(k) < 0;
2031
+ }).map(function(k) {
2032
+ return byKey[k];
2033
+ }).filter(function(c) {
2034
+ return !tooNarrow(c);
2035
+ });
2036
+ function isPinned(c) {
2037
+ return pinnedKeys.indexOf(c.key) >= 0 && c.width != null;
2038
+ }
2039
+ var vis = shown.filter(isPinned).concat(shown.filter(function(c) {
2040
+ return !isPinned(c);
2041
+ }));
2042
+ var nPinned = vis.filter(isPinned).length;
2043
+ var hasFlex = vis.some(function(c) {
2044
+ return widthOf(c) == null;
2045
+ });
2046
+ var fixedSum = 0;
2047
+ vis.forEach(function(c) {
2048
+ fixedSum += widthOf(c) != null ? widthOf(c) : FLEX_MIN;
2049
+ });
2050
+ var pinOffsets = {}, acc = 0;
2051
+ vis.forEach(function(c) {
2052
+ if (isPinned(c)) {
2053
+ pinOffsets[c.key] = acc;
2054
+ acc += widthOf(c);
2055
+ }
2056
+ });
2057
+ var selW = selectable ? " + var(--aura-table-select-width)" : "";
2058
+ var gutterR = controls ? "var(--aura-space-12)" : "var(--aura-space-6)";
2059
+ var rowMinWidth = "calc(" + fixedSum + "px + var(--aura-space-6) + " + gutterR + selW + ")";
2060
+ function cellStyle(c, i2) {
2061
+ var w = widthOf(c), s;
2062
+ if (w == null) s = { flex: "1 1 0", minWidth: (c.minWidth || FLEX_MIN) + "px" };
2063
+ else if (!hasFlex && i2 === vis.length - 1) s = { flex: "1 0 auto", width: w + "px" };
2064
+ else s = { width: w + "px", flex: "none" };
2065
+ if (isPinned(c)) s.left = "calc(var(--aura-space-6)" + selW + " + " + pinOffsets[c.key] + "px)";
2066
+ return s;
2067
+ }
2068
+ var view = React16.useMemo(function() {
2069
+ if (!sort || !sort.key || !byKey[sort.key]) return rows;
2070
+ var col = byKey[sort.key];
2071
+ var val = col.sortValue || (col.pill ? function(r) {
2072
+ return TONE_ORDER[col.tones && col.tones[r[col.key]] || toneFor(r[col.key])];
2073
+ } : function(r) {
2074
+ return r[col.key];
2075
+ });
2076
+ var dir = sort.dir === "desc" ? -1 : 1;
2077
+ return rows.map(function(r, i2) {
2078
+ return [r, i2];
2079
+ }).sort(function(a, b) {
2080
+ return compare(val(a[0]), val(b[0])) * dir || a[1] - b[1];
2081
+ }).map(function(p) {
2082
+ return p[0];
2083
+ });
2084
+ }, [rows, sort && sort.key, sort && sort.dir]);
2085
+ function nextSort(key) {
2086
+ if (!sort || sort.key !== key) return { key, dir: "asc" };
2087
+ if (sort.dir === "asc") return { key, dir: "desc" };
2088
+ return null;
2089
+ }
2090
+ var pageSize = props.pageSize || 0;
2091
+ var pageCount = pageSize ? Math.max(1, Math.ceil(view.length / pageSize)) : 1;
2092
+ var page = Math.min(Math.max(1, pageState[0] || 1), pageCount);
2093
+ var first = pageSize ? (page - 1) * pageSize : 0;
2094
+ var pageRows = pageSize ? view.slice(first, first + pageSize) : view;
2095
+ function goPage(p, focus) {
2096
+ var next = Math.min(Math.max(1, p), pageCount);
2097
+ if (next === page) return false;
2098
+ if (focus) pending.current = focus;
2099
+ pageState[1](next);
2100
+ if (scrollRef.current) scrollRef.current.scrollTop = 0;
2101
+ return true;
2102
+ }
2103
+ var height = props.height || 0;
2104
+ var virtual = !!height && !loading && pageRows.length > 0;
2105
+ var bodyH = Math.max(ROW_H, height - ROW_H);
2106
+ var start = 0, end = pageRows.length;
2107
+ if (virtual) {
2108
+ start = Math.max(0, Math.floor(scrollTop / ROW_H) - OVERSCAN);
2109
+ end = Math.min(pageRows.length, Math.ceil((scrollTop + bodyH) / ROW_H) + OVERSCAN);
2110
+ }
2111
+ var visibleRows = Math.max(1, Math.floor(bodyH / ROW_H));
2112
+ var nCols = vis.length + (selectable ? 1 : 0);
2113
+ var nRows = loading ? 0 : pageRows.length;
2114
+ var active = activeState[0];
2115
+ var ar = Math.min(active.r, nRows), ac = Math.min(active.c, nCols - 1);
2116
+ var activeRendered = ar === 0 || ar - 1 >= start && ar - 1 < end;
2117
+ function colAt(ci) {
2118
+ return selectable ? ci === 0 ? null : vis[ci - 1] : vis[ci];
2119
+ }
2120
+ function tabFor(r, c) {
2121
+ if (!activeRendered) return r === 0 && c === ac ? 0 : -1;
2122
+ return r === ar && c === ac ? 0 : -1;
2123
+ }
2124
+ React16.useEffect(function() {
2125
+ var p = pending.current;
2126
+ if (!p || !gridRef.current) return;
2127
+ var c = p.c;
2128
+ if (p.key) {
2129
+ var at = -1;
2130
+ vis.forEach(function(x, i2) {
2131
+ if (x.key === p.key) at = i2;
2132
+ });
2133
+ c = at >= 0 ? at + (selectable ? 1 : 0) : Math.min(p.c || 0, nCols - 1);
2134
+ }
2135
+ var el = gridRef.current.querySelector('[data-rc="' + p.r + ":" + c + '"]');
2136
+ if (el) {
2137
+ pending.current = null;
2138
+ el.focus();
2139
+ }
2140
+ });
2141
+ function focusCell(r, c) {
2142
+ r = Math.max(0, Math.min(r, nRows));
2143
+ c = Math.max(0, Math.min(c, nCols - 1));
2144
+ activeState[1]({ r, c });
2145
+ pending.current = { r, c };
2146
+ if (virtual && r > 0) {
2147
+ var sc = scrollRef.current, top = (r - 1) * ROW_H;
2148
+ if (top < sc.scrollTop) sc.scrollTop = top;
2149
+ else if (top + ROW_H > sc.scrollTop + bodyH) sc.scrollTop = top + ROW_H - bodyH;
2150
+ setScrollTop(sc.scrollTop);
2151
+ }
2152
+ var el = gridRef.current && gridRef.current.querySelector('[data-rc="' + r + ":" + c + '"]');
2153
+ if (el) {
2154
+ pending.current = null;
2155
+ el.focus();
2156
+ }
2157
+ }
2158
+ var pageKeys = pageRows.map(function(r) {
2159
+ return r[rowKey];
2160
+ });
2161
+ var selSet = {};
2162
+ selected.forEach(function(k) {
2163
+ selSet[k] = true;
2164
+ });
2165
+ var nSel = pageKeys.filter(function(k) {
2166
+ return selSet[k];
2167
+ }).length;
2168
+ var all = nSel > 0 && nSel === pageKeys.length;
2169
+ function toggle(k, on) {
2170
+ setSelected(on ? selected.concat([k]) : selected.filter(function(x) {
2171
+ return x !== k;
2172
+ }));
2173
+ }
2174
+ function toggleAll() {
2175
+ setSelected(all ? selected.filter(function(k) {
2176
+ return pageKeys.indexOf(k) < 0;
2177
+ }) : selected.concat(pageKeys.filter(function(k) {
2178
+ return !selSet[k];
2179
+ })));
2180
+ }
2181
+ function canResize(c) {
2182
+ return props.resizable && c.resizable !== false && c.width != null;
2183
+ }
2184
+ function clampW(c, w) {
2185
+ return Math.round(Math.min(c.maxWidth || 480, Math.max(c.minWidth || 64, w)));
2186
+ }
2187
+ function setW(c, w, done) {
2188
+ var nw = clampW(c, w);
2189
+ setWidths(function(prev) {
2190
+ var o = Object.assign({}, prev);
2191
+ o[c.key] = nw;
2192
+ return o;
2193
+ });
2194
+ if (done && props.onColumnResize) props.onColumnResize(c.key, nw);
2195
+ }
2196
+ function startResize(c, e) {
2197
+ e.preventDefault();
2198
+ e.stopPropagation();
2199
+ resizing.current = true;
2200
+ var x0 = e.clientX, w0 = widthOf(c), last = w0;
2201
+ var el = e.currentTarget;
2202
+ el.classList.add("is-dragging");
2203
+ document.body.style.cursor = "col-resize";
2204
+ function move(ev) {
2205
+ last = clampW(c, w0 + ev.clientX - x0);
2206
+ setW(c, last);
2207
+ }
2208
+ function up() {
2209
+ window.removeEventListener("pointermove", move);
2210
+ window.removeEventListener("pointerup", up);
2211
+ el.classList.remove("is-dragging");
2212
+ document.body.style.cursor = "";
2213
+ setTimeout(function() {
2214
+ resizing.current = false;
2215
+ }, 0);
2216
+ if (props.onColumnResize) props.onColumnResize(c.key, last);
2217
+ }
2218
+ window.addEventListener("pointermove", move);
2219
+ window.addEventListener("pointerup", up);
2220
+ }
2221
+ function moveCol(key, delta) {
2222
+ var c = byKey[key], group = vis.filter(function(x) {
2223
+ return isPinned(x) === isPinned(c);
2224
+ });
2225
+ var gi = group.indexOf(c), target = group[gi + delta];
2226
+ if (!target) return false;
2227
+ var o = order.slice(), from2 = o.indexOf(key), to2 = o.indexOf(target.key);
2228
+ o.splice(from2, 1);
2229
+ o.splice(to2, 0, key);
2230
+ orderState[1](o);
2231
+ return true;
2232
+ }
2233
+ function dropCol(key, targetKey, after) {
2234
+ if (key === targetKey) return;
2235
+ var a = byKey[key], b = byKey[targetKey];
2236
+ if (isPinned(a) !== isPinned(b)) return;
2237
+ var o = order.slice();
2238
+ o.splice(o.indexOf(key), 1);
2239
+ var to2 = o.indexOf(targetKey) + (after ? 1 : 0);
2240
+ o.splice(to2, 0, key);
2241
+ orderState[1](o);
2242
+ }
2243
+ function togglePin(key) {
2244
+ pinState[1](pinnedKeys.indexOf(key) >= 0 ? pinnedKeys.filter(function(k) {
2245
+ return k !== key;
2246
+ }) : pinnedKeys.concat([key]));
2247
+ }
2248
+ function setHidden(key, hide) {
2249
+ if (hide && shown.length <= 1) return;
2250
+ hiddenState[1](hide ? hidden.concat([key]) : hidden.filter(function(k) {
2251
+ return k !== key;
2252
+ }));
2253
+ }
2254
+ function resetColumns() {
2255
+ orderState[1](columns.map(function(c) {
2256
+ return c.key;
2257
+ }));
2258
+ hiddenState[1](columns.filter(function(c) {
2259
+ return c.hidden;
2260
+ }).map(function(c) {
2261
+ return c.key;
2262
+ }));
2263
+ pinState[1](columns.filter(function(c) {
2264
+ return c.pinned;
2265
+ }).map(function(c) {
2266
+ return c.key;
2267
+ }));
2268
+ setWidths({});
2269
+ }
2270
+ function columnMenuItems(c) {
2271
+ var group = vis.filter(function(x) {
2272
+ return isPinned(x) === isPinned(c);
2273
+ }), gi = group.indexOf(c);
2274
+ var items = [];
2275
+ if (c.sortable) items.push(
2276
+ { label: t.sortAsc, icon: "arrow-up", onSelect: function() {
2277
+ setSort({ key: c.key, dir: "asc" });
2278
+ goPage(1);
2279
+ } },
2280
+ { label: t.sortDesc, icon: "arrow-down", onSelect: function() {
2281
+ setSort({ key: c.key, dir: "desc" });
2282
+ goPage(1);
2283
+ } },
2284
+ { separator: true }
2285
+ );
2286
+ if (c.width != null) items.push({ label: isPinned(c) ? t.unpin : t.pin, icon: isPinned(c) ? "pin-off" : "pin", onSelect: function() {
2287
+ togglePin(c.key);
2288
+ } });
2289
+ if (reorderable) items.push(
2290
+ { label: t.moveLeft, icon: "arrow-left", disabled: gi <= 0, onSelect: function() {
2291
+ moveCol(c.key, -1);
2292
+ } },
2293
+ { label: t.moveRight, icon: "arrow-right", disabled: gi >= group.length - 1, onSelect: function() {
2294
+ moveCol(c.key, 1);
2295
+ } }
2296
+ );
2297
+ items.push({ separator: true }, { label: t.hideColumn, icon: "eye-off", disabled: shown.length <= 1, onSelect: function() {
2298
+ setHidden(c.key, true);
2299
+ } });
2300
+ return items;
2301
+ }
2302
+ function pickerItems() {
2303
+ return order.map(function(k) {
2304
+ var c = byKey[k], on = hidden.indexOf(k) < 0;
2305
+ return { label: c.label || (c.actions ? t.actions : c.key), checked: on, keepOpen: true, disabled: on && shown.length <= 1, onSelect: function() {
2306
+ setHidden(k, on);
2307
+ } };
2308
+ }).concat([{ separator: true }, { label: t.resetColumns, icon: "rotate-ccw", onSelect: resetColumns }]);
2309
+ }
2310
+ function openMenu(kind, key, anchor, rc) {
2311
+ setMenu({ kind, key, anchor, rc });
2312
+ }
2313
+ function closeMenu(restore) {
2314
+ var m = menu;
2315
+ setMenu(null);
2316
+ if (restore && m) {
2317
+ if (m.kind === "col") pending.current = { r: 0, key: m.key, c: m.rc ? m.rc.c : 0 };
2318
+ else if (m.anchor) m.anchor.focus();
2319
+ }
2320
+ }
2321
+ function onGridKey(e) {
2322
+ if (!gridRef.current || !gridRef.current.contains(e.target)) return;
2323
+ var rc = e.target.getAttribute && e.target.getAttribute("data-rc");
2324
+ if (!rc) {
2325
+ var cell = e.key === "Escape" && e.target.closest && e.target.closest("[data-rc]");
2326
+ if (cell) {
2327
+ e.preventDefault();
2328
+ cell.focus();
2329
+ }
2330
+ return;
2331
+ }
2332
+ var p = rc.split(":"), r = +p[0], c = +p[1], k = e.key, col = colAt(c);
2333
+ var row = r > 0 ? pageRows[r - 1] : null;
2334
+ var handled = true;
2335
+ if (r === 0 && col && e.altKey && (k === "ArrowLeft" || k === "ArrowRight") && canResize(col)) setW(col, widthOf(col) + (k === "ArrowLeft" ? -1 : 1) * (e.shiftKey ? 48 : 16), true);
2336
+ else if (r === 0 && col && e.ctrlKey && e.shiftKey && (k === "ArrowLeft" || k === "ArrowRight") && reorderable) {
2337
+ if (moveCol(col.key, k === "ArrowLeft" ? -1 : 1)) pending.current = { r: 0, key: col.key, c };
2338
+ } else if (r === 0 && col && (e.altKey && k === "ArrowDown" || k === "ContextMenu" || e.shiftKey && k === "F10") && controls) openMenu("col", col.key, e.target, { r: 0, c });
2339
+ else if (k === "ArrowRight") focusCell(r, c + 1);
2340
+ else if (k === "ArrowLeft") focusCell(r, c - 1);
2341
+ else if (k === "ArrowDown") {
2342
+ if (r < nRows) focusCell(r + 1, c);
2343
+ else if (pageSize && page < pageCount && goPage(page + 1, { r: 1, c })) activeState[1]({ r: 1, c });
2344
+ } else if (k === "ArrowUp") {
2345
+ if (r > 1 || r === 1 && !(pageSize && page > 1)) focusCell(r - 1, c);
2346
+ else if (r === 1 && goPage(page - 1, { r: pageSize, c })) activeState[1]({ r: pageSize, c });
2347
+ } else if (k === "Home") focusCell(e.ctrlKey ? 1 : r, 0);
2348
+ else if (k === "End") focusCell(e.ctrlKey ? nRows : r, nCols - 1);
2349
+ else if (k === "PageDown") {
2350
+ if (pageSize) {
2351
+ if (goPage(page + 1, { r: 1, c })) activeState[1]({ r: 1, c });
2352
+ } else focusCell(Math.min(nRows, r + visibleRows), c);
2353
+ } else if (k === "PageUp") {
2354
+ if (pageSize) {
2355
+ if (goPage(page - 1, { r: 1, c })) activeState[1]({ r: 1, c });
2356
+ } else focusCell(Math.max(1, r - visibleRows), c);
2357
+ } else if (k === " " || k === "Enter") {
2358
+ if (r === 0 && !col && selectable && nRows) toggleAll();
2359
+ else if (r === 0 && col && col.sortable && nRows > 1) {
2360
+ setSort(nextSort(col.key));
2361
+ goPage(1);
2362
+ } else if (r > 0 && k === " " && selectable) toggle(row[rowKey], !selSet[row[rowKey]]);
2363
+ else if (r > 0 && (k === "Enter" || k === "F2") && e.target.querySelector("button, a[href], input, select, textarea")) e.target.querySelector("button, a[href], input, select, textarea").focus();
2364
+ else if (r > 0 && k === "Enter" && props.onRowActivate) props.onRowActivate(row);
2365
+ else handled = false;
2366
+ } else handled = false;
2367
+ if (handled) {
2368
+ e.preventDefault();
2369
+ e.stopPropagation();
2370
+ }
2371
+ }
2372
+ var head = [h14("span", { key: "__gl", className: "aura-table__gutter", "aria-hidden": true })];
2373
+ if (selectable) head.push(h14("span", {
2374
+ key: "__sel",
2375
+ role: "columnheader",
2376
+ "aria-colindex": 1,
2377
+ className: cx("aura-table__sel", nPinned && "is-pinned"),
2378
+ tabIndex: tabFor(0, 0),
2379
+ "data-rc": "0:0",
2380
+ "aria-label": t.selectRows,
2381
+ onFocus: function() {
2382
+ activeState[1]({ r: 0, c: 0 });
2383
+ }
2384
+ }, nRows ? h14(Checkbox, {
2385
+ checked: all,
2386
+ indeterminate: nSel > 0 && !all,
2387
+ tabIndex: -1,
2388
+ label: all ? t.deselectAllRows : t.selectAllRows,
2389
+ onChange: toggleAll
2390
+ }) : null));
2391
+ vis.forEach(function(c, i2) {
2392
+ var ci = i2 + (selectable ? 1 : 0);
2393
+ var isSorted = sort && sort.key === c.key;
2394
+ var canSort = c.sortable && rows.length > 1 && !loading;
2395
+ var ariaSort = isSorted && canSort ? sort.dir === "desc" ? "descending" : "ascending" : canSort ? "none" : void 0;
2396
+ var pin = isPinned(c), edge = pin && i2 === nPinned - 1;
2397
+ head.push(h14(
2398
+ "span",
2399
+ {
2400
+ key: c.key,
2401
+ role: "columnheader",
2402
+ "aria-sort": ariaSort,
2403
+ "aria-colindex": ci + 1,
2404
+ style: cellStyle(c, i2),
2405
+ tabIndex: tabFor(0, ci),
2406
+ "data-rc": "0:" + ci,
2407
+ className: cx(
2408
+ "aura-table__th",
2409
+ pin && "is-pinned",
2410
+ edge && "is-pin-edge",
2411
+ drag && drag.over === c.key && (drag.after ? "is-drop-after" : "is-drop-before"),
2412
+ drag && drag.key === c.key && "is-dragging"
2413
+ ),
2414
+ draggable: reorderable && !loading ? true : void 0,
2415
+ onFocus: function(e) {
2416
+ if (e.target === e.currentTarget) activeState[1]({ r: 0, c: ci });
2417
+ },
2418
+ onDragStart: function(e) {
2419
+ if (resizing.current) {
2420
+ e.preventDefault();
2421
+ return;
2422
+ }
2423
+ e.dataTransfer.effectAllowed = "move";
2424
+ try {
2425
+ e.dataTransfer.setData("text/plain", c.key);
2426
+ } catch (x) {
2427
+ }
2428
+ setDrag({ key: c.key });
2429
+ },
2430
+ onDragOver: function(e) {
2431
+ if (!drag || drag.key === c.key || isPinned(byKey[drag.key]) !== pin) return;
2432
+ e.preventDefault();
2433
+ var b = e.currentTarget.getBoundingClientRect(), after = e.clientX > b.left + b.width / 2;
2434
+ if (drag.over !== c.key || drag.after !== after) setDrag({ key: drag.key, over: c.key, after });
2435
+ },
2436
+ onDrop: function(e) {
2437
+ e.preventDefault();
2438
+ if (drag && drag.over) dropCol(drag.key, drag.over, drag.after);
2439
+ setDrag(null);
2440
+ },
2441
+ onDragEnd: function() {
2442
+ setDrag(null);
2443
+ }
2444
+ },
2445
+ h14(
2446
+ "span",
2447
+ { className: "aura-table__th-inner" },
2448
+ canSort ? h14(
2449
+ "button",
2450
+ {
2451
+ type: "button",
2452
+ tabIndex: -1,
2453
+ className: cx("aura-table__sort", isSorted && "is-active"),
2454
+ onClick: function() {
2455
+ setSort(nextSort(c.key));
2456
+ goPage(1);
2457
+ activeState[1]({ r: 0, c: ci });
2458
+ }
2459
+ },
2460
+ c.label,
2461
+ h14(Icon, { name: isSorted ? sort.dir === "desc" ? "arrow-down" : "arrow-up" : "arrow-up-down", size: 12 })
2462
+ ) : h14("span", { className: cx("aura-table__th-label", !c.label && "aura-sr-only") }, c.label || (c.actions ? t.actions : c.key)),
2463
+ pin ? h14(Icon, { name: "pin", size: 12, className: "aura-table__pin-icon", label: t.pinned }) : null,
2464
+ controls ? h14(
2465
+ "button",
2466
+ {
2467
+ type: "button",
2468
+ tabIndex: -1,
2469
+ className: "aura-table__menu-btn",
2470
+ "aria-label": t.columnOptions(c.label),
2471
+ "aria-haspopup": "menu",
2472
+ "aria-expanded": menu && menu.key === c.key ? true : void 0,
2473
+ onClick: function(e) {
2474
+ e.stopPropagation();
2475
+ openMenu("col", c.key, e.currentTarget, { r: 0, c: ci });
2476
+ }
2477
+ },
2478
+ h14(Icon, { name: "ellipsis" })
2479
+ ) : null
2480
+ ),
2481
+ canResize(c) ? h14("span", {
2482
+ className: "aura-table__resize",
2483
+ role: "separator",
2484
+ "aria-orientation": "vertical",
2485
+ "aria-hidden": true,
2486
+ onPointerDown: function(e) {
2487
+ startResize(c, e);
2488
+ },
2489
+ onClick: function(e) {
2490
+ e.stopPropagation();
2491
+ },
2492
+ onDoubleClick: function() {
2493
+ setW(c, c.width, true);
2494
+ }
2495
+ }) : null
2496
+ ));
2497
+ });
2498
+ head.push(h14("span", { key: "__gr", className: cx("aura-table__gutter aura-table__gutter--end", controls && "has-picker"), "aria-hidden": true }));
2499
+ function rowCells(r, i2, k, isSel) {
2500
+ var ri2 = i2 + 1;
2501
+ var cells = [h14("span", { key: "__gl", className: "aura-table__gutter", "aria-hidden": true })];
2502
+ if (selectable) cells.push(h14("span", {
2503
+ key: "__sel",
2504
+ role: "gridcell",
2505
+ "aria-colindex": 1,
2506
+ className: cx("aura-table__sel", nPinned && "is-pinned"),
2507
+ tabIndex: tabFor(ri2, 0),
2508
+ "data-rc": ri2 + ":0",
2509
+ "aria-label": t.selectRow(k),
2510
+ onFocus: function(e) {
2511
+ if (e.target === e.currentTarget) activeState[1]({ r: ri2, c: 0 });
2512
+ }
2513
+ }, h14(Checkbox, { checked: isSel, tabIndex: -1, label: t.selectRow(k), onChange: function(on) {
2514
+ toggle(k, on);
2515
+ } })));
2516
+ vis.forEach(function(c, j) {
2517
+ var ci = j + (selectable ? 1 : 0), v = r[c.key], pin = isPinned(c);
2518
+ cells.push(h14("span", {
2519
+ key: c.key,
2520
+ role: "gridcell",
2521
+ "aria-colindex": ci + 1,
2522
+ tabIndex: tabFor(ri2, ci),
2523
+ "data-rc": ri2 + ":" + ci,
2524
+ className: cx("aura-table__td", c.mono && "aura-table__mono", pin && "is-pinned", pin && j === nPinned - 1 && "is-pin-edge"),
2525
+ style: cellStyle(c, j),
2526
+ onFocus: function() {
2527
+ if (activeState[0].r !== ri2 || activeState[0].c !== ci) activeState[1]({ r: ri2, c: ci });
2528
+ }
2529
+ }, c.render ? c.render(r) : c.pill ? h14(StatusPill, { tone: c.tones && c.tones[v] }, v) : v));
2530
+ });
2531
+ cells.push(h14("span", { key: "__gr", className: cx("aura-table__gutter aura-table__gutter--end", controls && "has-picker"), "aria-hidden": true }));
2532
+ return cells;
2533
+ }
2534
+ var body;
2535
+ var rowStyle = { minWidth: rowMinWidth };
2536
+ if (loading) {
2537
+ var n2 = pageSize || props.skeletonRows || 5;
2538
+ body = [];
2539
+ for (var i = 0; i < n2; i++) {
2540
+ var sk = [h14("span", { key: "__gl", className: "aura-table__gutter" })];
2541
+ if (selectable) sk.push(h14("span", { key: "__sel", className: cx("aura-table__sel", nPinned && "is-pinned") }, h14("span", { className: "aura-skel aura-skel--box" })));
2542
+ vis.forEach(function(c, j) {
2543
+ sk.push(h14(
2544
+ "span",
2545
+ { key: c.key, className: cx("aura-table__td", isPinned(c) && "is-pinned"), style: cellStyle(c, j) },
2546
+ h14("span", { className: cx("aura-skel", c.pill && "aura-skel--pill"), style: c.pill ? null : { width: SKELETON_WIDTHS[(i + j) % SKELETON_WIDTHS.length] } })
2547
+ ));
2548
+ });
2549
+ sk.push(h14("span", { key: "__gr", className: cx("aura-table__gutter aura-table__gutter--end", controls && "has-picker") }));
2550
+ body.push(h14("div", { key: "sk" + i, className: "aura-table__row aura-table__row--skeleton", "aria-hidden": true, style: rowStyle }, sk));
2551
+ }
2552
+ } else if (!rows.length) {
2553
+ var em = props.empty || {};
2554
+ body = h14(
2555
+ "div",
2556
+ { className: "aura-table__empty", role: "row" },
2557
+ h14(
2558
+ "div",
2559
+ { role: "gridcell" },
2560
+ h14("span", { className: "aura-table__empty-icon" }, h14(Icon, { name: em.icon || "inbox", size: "lg" })),
2561
+ h14("p", { className: "aura-table__empty-title" }, em.title || t.empty),
2562
+ em.description ? h14("p", { className: "aura-table__empty-text" }, em.description) : null,
2563
+ em.action ? h14("div", { className: "aura-table__empty-action" }, em.action) : null
2564
+ )
2565
+ );
2566
+ } else {
2567
+ body = [];
2568
+ if (virtual && start > 0) body.push(h14("div", { key: "__top", style: { height: start * ROW_H + "px" }, "aria-hidden": true }));
2569
+ for (var ri = start; ri < end; ri++) {
2570
+ (function(r, i2) {
2571
+ var k = r[rowKey], isSel = !!selSet[k];
2572
+ body.push(h14("div", {
2573
+ key: k,
2574
+ role: "row",
2575
+ "aria-rowindex": first + i2 + 2,
2576
+ "aria-selected": selectable ? isSel : void 0,
2577
+ className: cx("aura-table__row", isSel && "is-selected", props.onRowActivate && "is-actionable"),
2578
+ style: rowStyle,
2579
+ onClick: function(e) {
2580
+ if (e.target.closest && e.target.closest(".aura-check, button, a, input")) return;
2581
+ if (props.onRowActivate) props.onRowActivate(r);
2582
+ }
2583
+ }, rowCells(r, i2, k, isSel)));
2584
+ })(pageRows[ri], ri);
2585
+ }
2586
+ if (virtual && end < pageRows.length) body.push(h14("div", { key: "__bot", style: { height: (pageRows.length - end) * ROW_H + "px" }, "aria-hidden": true }));
2587
+ }
2588
+ var foot = null;
2589
+ if (pageSize && (rows.length || loading)) {
2590
+ var from = rows.length ? first + 1 : 0, to = Math.min(first + pageSize, view.length);
2591
+ foot = h14(
2592
+ "div",
2593
+ { className: "aura-table__foot" },
2594
+ h14("span", { "aria-live": "polite" }, loading ? t.loading : t.range(from, to, view.length)),
2595
+ h14(
2596
+ "span",
2597
+ { className: "aura-table__pager" },
2598
+ h14("span", null, t.page(page, pageCount)),
2599
+ h14(IconButton, { icon: "chevron-left", label: t.prevPage, disabled: loading || page <= 1, onClick: function() {
2600
+ goPage(page - 1);
2601
+ } }),
2602
+ h14(IconButton, { icon: "chevron-right", label: t.nextPage, disabled: loading || page >= pageCount, onClick: function() {
2603
+ goPage(page + 1);
2604
+ } })
2605
+ )
2606
+ );
2607
+ } else if (height && rows.length && !loading) {
2608
+ foot = h14(
2609
+ "div",
2610
+ { className: "aura-table__foot" },
2611
+ h14("span", null, t.rowCount(view.length)),
2612
+ selectable && selected.length ? h14("span", null, t.selectedCount(selected.length)) : h14("span", null)
2613
+ );
2614
+ }
2615
+ if (stacked) {
2616
+ var titleCol = vis[0], pillCol = vis.filter(function(c) {
2617
+ return c.pill && c !== titleCol;
2618
+ })[0];
2619
+ var actionCols = vis.filter(function(c) {
2620
+ return c.actions && c !== titleCol;
2621
+ });
2622
+ var rest = vis.filter(function(c) {
2623
+ return c !== titleCol && c !== pillCol && !c.actions;
2624
+ });
2625
+ var cardBody;
2626
+ if (loading) {
2627
+ cardBody = h14("ul", { className: "aura-table__cards", "aria-busy": true }, [0, 1, 2].map(function(i2) {
2628
+ return h14(
2629
+ "li",
2630
+ { key: i2, className: "aura-table__card", "aria-hidden": true },
2631
+ h14("span", { className: "aura-skel", style: { width: "50%", height: "14px" } }),
2632
+ h14("span", { className: "aura-skel", style: { width: "80%" } }),
2633
+ h14("span", { className: "aura-skel", style: { width: "64%" } })
2634
+ );
2635
+ }));
2636
+ } else if (!rows.length) {
2637
+ var em2 = props.empty || {};
2638
+ cardBody = h14("div", { className: "aura-table__empty" }, h14(
2639
+ "div",
2640
+ null,
2641
+ h14("span", { className: "aura-table__empty-icon" }, h14(Icon, { name: em2.icon || "inbox", size: "lg" })),
2642
+ h14("p", { className: "aura-table__empty-title" }, em2.title || t.empty),
2643
+ em2.description ? h14("p", { className: "aura-table__empty-text" }, em2.description) : null,
2644
+ em2.action ? h14("div", { className: "aura-table__empty-action" }, em2.action) : null
2645
+ ));
2646
+ } else {
2647
+ var cellVal = function(c, r) {
2648
+ var v = r[c.key];
2649
+ return c.render ? c.render(r) : c.pill ? h14(StatusPill, { tone: c.tones && c.tones[v] }, v) : v;
2650
+ };
2651
+ cardBody = h14("ul", { className: "aura-table__cards", "aria-label": props.label }, pageRows.map(function(r) {
2652
+ var k = r[rowKey], isSel = !!selSet[k];
2653
+ return h14(
2654
+ "li",
2655
+ {
2656
+ key: k,
2657
+ className: cx("aura-table__card", isSel && "is-selected", props.onRowActivate && "is-actionable"),
2658
+ tabIndex: props.onRowActivate ? 0 : void 0,
2659
+ onClick: function(e) {
2660
+ if (e.target.closest && e.target.closest(".aura-check, button, a, input")) return;
2661
+ if (props.onRowActivate) props.onRowActivate(r);
2662
+ },
2663
+ onKeyDown: function(e) {
2664
+ if (e.target === e.currentTarget && e.key === "Enter" && props.onRowActivate) props.onRowActivate(r);
2665
+ }
2666
+ },
2667
+ h14(
2668
+ "div",
2669
+ { className: "aura-table__card-head" },
2670
+ selectable ? h14(Checkbox, { checked: isSel, label: t.selectRow(k), onChange: function(on) {
2671
+ toggle(k, on);
2672
+ } }) : null,
2673
+ h14("span", { className: cx("aura-table__card-title", titleCol.mono && "aura-table__mono") }, cellVal(titleCol, r)),
2674
+ pillCol ? cellVal(pillCol, r) : null,
2675
+ actionCols.map(function(c) {
2676
+ return h14("span", { key: c.key, className: "aura-table__card-actions" }, cellVal(c, r));
2677
+ })
2678
+ ),
2679
+ rest.length ? h14("dl", { className: "aura-table__card-fields" }, rest.map(function(c) {
2680
+ return h14("div", { key: c.key }, h14("dt", null, c.label), h14("dd", { className: c.mono ? "aura-table__mono" : void 0 }, cellVal(c, r)));
2681
+ })) : null
2682
+ );
2683
+ }));
2684
+ }
2685
+ return h14(
2686
+ "div",
2687
+ { ref: wrapMerged, className: cx("aura-table aura-table--stacked", props.className), role: "region", "aria-label": props.label, "aria-busy": loading || void 0 },
2688
+ selectable && pageRows.length && !loading ? h14(
2689
+ "div",
2690
+ { className: "aura-table__stack-bar" },
2691
+ h14(Checkbox, { checked: all, indeterminate: nSel > 0 && !all, label: all ? t.deselectAllRows : t.selectAllRows, onChange: toggleAll }),
2692
+ h14("span", null, nSel ? t.selectedCount(nSel) : t.selectAll)
2693
+ ) : null,
2694
+ cardBody,
2695
+ foot
2696
+ );
2697
+ }
2698
+ var scrollStyle = { scrollPaddingLeft: "calc(var(--aura-space-6)" + selW + " + " + acc + "px)", scrollPaddingTop: ROW_H + "px" };
2699
+ if (height) scrollStyle.height = height + "px";
2700
+ return h14(
2701
+ "div",
2702
+ { ref: wrapMerged, className: cx("aura-table", scrolledX[0] && "is-scrolled-x", props.className) },
2703
+ h14(
2704
+ "div",
2705
+ {
2706
+ ref: function(el) {
2707
+ scrollRef.current = el;
2708
+ gridRef.current = el;
2709
+ },
2710
+ className: "aura-table__scroll",
2711
+ style: scrollStyle,
2712
+ role: "grid",
2713
+ "aria-label": props.label,
2714
+ "aria-busy": loading || void 0,
2715
+ "aria-rowcount": loading ? -1 : view.length + 1,
2716
+ "aria-colcount": nCols,
2717
+ "aria-multiselectable": selectable || void 0,
2718
+ onKeyDown: onGridKey,
2719
+ onScroll: function(e) {
2720
+ var t2 = e.currentTarget;
2721
+ if (virtual && Math.abs(t2.scrollTop - scrollTop) >= ROW_H / 2) setScrollTop(t2.scrollTop);
2722
+ else if (virtual && (t2.scrollTop === 0 || t2.scrollTop + t2.clientHeight >= t2.scrollHeight - 1)) setScrollTop(t2.scrollTop);
2723
+ var sx = t2.scrollLeft > 0;
2724
+ if (sx !== scrolledX[0]) scrolledX[1](sx);
2725
+ }
2726
+ },
2727
+ h14("div", { className: "aura-table__head", role: "row", "aria-rowindex": 1, style: rowStyle }, head),
2728
+ body
2729
+ ),
2730
+ loading ? h14("span", { className: "aura-sr-only", role: "status" }, t.loadingRows) : null,
2731
+ controls ? h14(
2732
+ "div",
2733
+ { className: "aura-table__picker" },
2734
+ h14(IconButton, {
2735
+ icon: "columns-3",
2736
+ label: t.showHideColumns,
2737
+ "aria-haspopup": "menu",
2738
+ onClick: function(e) {
2739
+ openMenu("picker", null, e.currentTarget);
2740
+ }
2741
+ })
2742
+ ) : null,
2743
+ foot,
2744
+ menu ? h14(Menu, {
2745
+ anchor: menu.anchor,
2746
+ onClose: closeMenu,
2747
+ label: menu.kind === "picker" ? t.columns : t.column(byKey[menu.key] && byKey[menu.key].label),
2748
+ items: menu.kind === "picker" ? pickerItems() : byKey[menu.key] ? columnMenuItems(byKey[menu.key]) : []
2749
+ }) : null
2750
+ );
2751
+ });
2752
+
2753
+ // src/layout.js
2754
+ var React17 = __toESM(require("react"), 1);
2755
+ var h15 = React17.createElement;
2756
+ var Card = React17.forwardRef(function Card2(props, ref) {
2757
+ var creative = props.variant === "creative";
2758
+ return h15(
2759
+ props.as || "section",
2760
+ {
2761
+ ref,
2762
+ className: cx("aura-card", creative && "aura-card--creative", props.interactive && "is-interactive", props.className),
2763
+ "aria-labelledby": props.title && props.titleId ? props.titleId : void 0
2764
+ },
2765
+ props.title || props.actions ? h15(
2766
+ "div",
2767
+ { className: "aura-card__head" },
2768
+ h15(
2769
+ "div",
2770
+ { className: "aura-card__heading" },
2771
+ props.title ? h15("h" + (props.headingLevel || 3), { className: "aura-card__title", id: props.titleId }, props.title) : null,
2772
+ props.description ? h15("p", { className: "aura-card__desc" }, props.description) : null
2773
+ ),
2774
+ props.actions ? h15("div", { className: "aura-card__actions" }, props.actions) : null
2775
+ ) : null,
2776
+ props.children ? h15("div", { className: "aura-card__body" }, props.children) : null,
2777
+ props.footer ? h15("div", { className: "aura-card__foot" }, props.footer) : null
2778
+ );
2779
+ });
2780
+ var Tabs = React17.forwardRef(function Tabs2(props, ref) {
2781
+ var items = props.tabs || [], base = uid();
2782
+ var st = useMaybeControlled(props.value, props.defaultValue || items[0] && items[0].id, props.onChange);
2783
+ var refs = React17.useRef({});
2784
+ var current2 = items.filter(function(t) {
2785
+ return t.id === st[0];
2786
+ })[0] || items[0];
2787
+ function go(i) {
2788
+ var enabled = items.filter(function(t2) {
2789
+ return !t2.disabled;
2790
+ });
2791
+ var t = enabled[(i + enabled.length) % enabled.length];
2792
+ st[1](t.id);
2793
+ if (refs.current[t.id]) refs.current[t.id].focus();
2794
+ }
2795
+ return h15(
2796
+ "div",
2797
+ { ref, className: cx("aura-tabs", props.className) },
2798
+ h15(
2799
+ "div",
2800
+ {
2801
+ role: "tablist",
2802
+ "aria-label": props.label,
2803
+ className: "aura-tabs__list",
2804
+ onKeyDown: function(e) {
2805
+ var enabled = items.filter(function(t) {
2806
+ return !t.disabled;
2807
+ }), i = enabled.indexOf(current2);
2808
+ if (e.key === "ArrowRight") {
2809
+ e.preventDefault();
2810
+ go(i + 1);
2811
+ } else if (e.key === "ArrowLeft") {
2812
+ e.preventDefault();
2813
+ go(i - 1);
2814
+ } else if (e.key === "Home") {
2815
+ e.preventDefault();
2816
+ go(0);
2817
+ } else if (e.key === "End") {
2818
+ e.preventDefault();
2819
+ go(enabled.length - 1);
2820
+ }
2821
+ }
2822
+ },
2823
+ items.map(function(t) {
2824
+ var on = current2 && t.id === current2.id;
2825
+ return h15(
2826
+ "button",
2827
+ {
2828
+ key: t.id,
2829
+ type: "button",
2830
+ role: "tab",
2831
+ id: base + "-tab-" + t.id,
2832
+ "aria-selected": on,
2833
+ "aria-controls": base + "-panel-" + t.id,
2834
+ tabIndex: on ? 0 : -1,
2835
+ disabled: t.disabled,
2836
+ ref: function(el) {
2837
+ refs.current[t.id] = el;
2838
+ },
2839
+ className: cx("aura-tab", on && "is-active"),
2840
+ onClick: function() {
2841
+ st[1](t.id);
2842
+ }
2843
+ },
2844
+ t.icon ? h15(Icon, { name: t.icon }) : null,
2845
+ t.label,
2846
+ t.count != null ? h15("span", { className: "aura-tab__count" }, t.count) : null
2847
+ );
2848
+ })
2849
+ ),
2850
+ current2 && current2.content !== void 0 ? h15("div", {
2851
+ role: "tabpanel",
2852
+ id: base + "-panel-" + current2.id,
2853
+ "aria-labelledby": base + "-tab-" + current2.id,
2854
+ tabIndex: 0,
2855
+ className: "aura-tabs__panel"
2856
+ }, current2.content) : null
2857
+ );
2858
+ });
2859
+ var SideNav = React17.forwardRef(function SideNav2(props, ref) {
2860
+ var t = useStrings();
2861
+ var st = useMaybeControlled(props.value, props.defaultValue, props.onChange);
2862
+ function item(it) {
2863
+ var on = st[0] === it.id;
2864
+ var inner = [
2865
+ it.icon ? h15(Icon, { key: "i", name: it.icon }) : null,
2866
+ h15("span", { key: "l", className: "aura-nav__label" }, it.label),
2867
+ it.count != null ? h15("span", { key: "c", className: "aura-nav__count" }, it.count) : null
2868
+ ];
2869
+ var common = {
2870
+ className: cx("aura-nav__item", on && "is-active"),
2871
+ "aria-current": on ? "page" : void 0,
2872
+ onClick: function(e) {
2873
+ if (!it.href) e.preventDefault();
2874
+ st[1](it.id);
2875
+ }
2876
+ };
2877
+ return h15("li", { key: it.id }, it.href ? h15("a", Object.assign({ href: it.href }, common), inner) : h15("button", Object.assign({ type: "button" }, common), inner));
2878
+ }
2879
+ return h15(
2880
+ "nav",
2881
+ { ref, className: cx("aura-nav", props.className), "aria-label": props.label || t.mainNav },
2882
+ props.header ? h15("div", { className: "aura-nav__header" }, props.header) : null,
2883
+ h15(
2884
+ "div",
2885
+ { className: "aura-nav__scroll" },
2886
+ (props.sections || [{ items: props.items || [] }]).map(function(s, i) {
2887
+ return h15(
2888
+ "div",
2889
+ { key: i, className: "aura-nav__section" },
2890
+ s.title ? h15("p", { className: "aura-nav__title" }, s.title) : null,
2891
+ h15("ul", { className: "aura-nav__list" }, s.items.map(item))
2892
+ );
2893
+ })
2894
+ ),
2895
+ props.footer ? h15("div", { className: "aura-nav__footer" }, props.footer) : null
2896
+ );
2897
+ });
2898
+ var Breadcrumb = React17.forwardRef(function Breadcrumb2(props, ref) {
2899
+ var t = useStrings();
2900
+ var items = props.items || [];
2901
+ return h15(
2902
+ "nav",
2903
+ { ref, "aria-label": props.label || t.breadcrumb, className: cx("aura-crumbs", props.className) },
2904
+ h15("ol", null, items.map(function(it, i) {
2905
+ var last = i === items.length - 1;
2906
+ return h15(
2907
+ "li",
2908
+ { key: i },
2909
+ last ? h15("span", { "aria-current": "page", className: "aura-crumbs__current" }, it.label) : it.href ? h15("a", { href: it.href, onClick: it.onClick }, it.label) : h15("button", { type: "button", onClick: it.onClick }, it.label),
2910
+ last ? null : h15(Icon, { name: "chevron-right", size: 12, className: "aura-crumbs__sep" })
2911
+ );
2912
+ }))
2913
+ );
2914
+ });
2915
+ var AVATAR_TONES = ["progress", "ready", "neutral", "warning"];
2916
+ function initials(name) {
2917
+ var parts = String(name || "?").trim().split(/\s+/);
2918
+ return ((parts[0] || "?")[0] + (parts.length > 1 ? parts[parts.length - 1][0] : parts[0][1] || "")).toUpperCase();
2919
+ }
2920
+ var Avatar = React17.forwardRef(function Avatar2(props, ref) {
2921
+ var size = props.size || "md", errState = React17.useState(false);
2922
+ var hash = 0;
2923
+ String(props.name || "").split("").forEach(function(ch) {
2924
+ hash = hash * 31 + ch.charCodeAt(0) >>> 0;
2925
+ });
2926
+ var tone2 = AVATAR_TONES[hash % AVATAR_TONES.length];
2927
+ return h15(
2928
+ "span",
2929
+ {
2930
+ ref,
2931
+ className: cx("aura-avatar", "aura-avatar--" + size, "aura-avatar--" + tone2, props.className),
2932
+ role: "img",
2933
+ "aria-label": props.name + (props.status ? ", " + props.status : "")
2934
+ },
2935
+ props.src && !errState[0] ? h15("img", { src: props.src, alt: "", onError: function() {
2936
+ errState[1](true);
2937
+ } }) : h15("span", { "aria-hidden": true }, initials(props.name)),
2938
+ props.status === "online" ? h15("span", { className: "aura-avatar__status", "aria-hidden": true }) : null
2939
+ );
2940
+ });
2941
+
2942
+ // src/layout2.js
2943
+ var React18 = __toESM(require("react"), 1);
2944
+ var h16 = React18.createElement;
2945
+ var breakpoints = { sm: 640, md: 768, lg: 1024, xl: 1280 };
2946
+ var ORDER = ["base", "sm", "md", "lg", "xl"];
2947
+ function useBreakpoint() {
2948
+ return React18.useSyncExternalStore(subscribe, current, function() {
2949
+ return "lg";
2950
+ });
2951
+ }
2952
+ function current() {
2953
+ var w = window.innerWidth, bp = "base";
2954
+ ORDER.slice(1).forEach(function(k) {
2955
+ if (w >= breakpoints[k]) bp = k;
2956
+ });
2957
+ return bp;
2958
+ }
2959
+ function subscribe(cb) {
2960
+ window.addEventListener("resize", cb);
2961
+ return function() {
2962
+ window.removeEventListener("resize", cb);
2963
+ };
2964
+ }
2965
+ function useResponsive(value) {
2966
+ var bp = useBreakpoint();
2967
+ if (value == null || typeof value !== "object") return value;
2968
+ for (var i = ORDER.indexOf(bp); i >= 0; i--) if (value[ORDER[i]] !== void 0) return value[ORDER[i]];
2969
+ return void 0;
2970
+ }
2971
+ function respVars(prefix, value, map) {
2972
+ var style = {};
2973
+ if (value == null) return style;
2974
+ if (typeof value !== "object") value = { base: value };
2975
+ var cur;
2976
+ ORDER.forEach(function(k) {
2977
+ if (value[k] !== void 0) cur = map ? map(value[k]) : value[k];
2978
+ if (cur !== void 0) style["--" + prefix + "-" + k] = cur;
2979
+ });
2980
+ return style;
2981
+ }
2982
+ var space = function(v) {
2983
+ return typeof v === "number" ? "var(--aura-space-" + v + ")" : v;
2984
+ };
2985
+ var Stack = React18.forwardRef(function Stack2(props, ref) {
2986
+ var style = Object.assign(
2987
+ {},
2988
+ respVars("aura-stack-dir", props.direction || "column"),
2989
+ respVars("aura-stack-gap", props.gap == null ? 4 : props.gap, space),
2990
+ respVars("aura-stack-align", props.align || "stretch"),
2991
+ props.justify ? { justifyContent: props.justify } : null,
2992
+ props.wrap ? { flexWrap: "wrap" } : null,
2993
+ props.style
2994
+ );
2995
+ return h16(props.as || "div", { ref, className: cx("aura-stack", props.className), style }, props.children);
2996
+ });
2997
+ var Grid = React18.forwardRef(function Grid2(props, ref) {
2998
+ var style = Object.assign(
2999
+ {},
3000
+ respVars("aura-grid-gap", props.gap == null ? 6 : props.gap, space),
3001
+ props.minItemWidth ? { gridTemplateColumns: "repeat(auto-fill, minmax(min(" + props.minItemWidth + "px, 100%), 1fr))" } : respVars("aura-grid-cols", props.columns || 1),
3002
+ props.style
3003
+ );
3004
+ return h16(props.as || "div", { ref, className: cx("aura-grid-layout", props.minItemWidth && "is-auto", props.className), style }, props.children);
3005
+ });
3006
+ var Container = React18.forwardRef(function Container2(props, ref) {
3007
+ return h16(props.as || "div", { ref, className: cx("aura-container", props.size === "narrow" && "is-narrow", props.className), style: props.style }, props.children);
3008
+ });
3009
+ var AppShell = React18.forwardRef(function AppShell2(props, ref) {
3010
+ var t = useStrings();
3011
+ var bp = useBreakpoint();
3012
+ var compact = bp === "base" || bp === "sm" || bp === "md";
3013
+ var st = React18.useState(false), open = st[0], setOpen = st[1];
3014
+ React18.useEffect(function() {
3015
+ if (!compact) setOpen(false);
3016
+ }, [compact]);
3017
+ var nav = props.nav && React18.isValidElement(props.nav) && compact ? React18.cloneElement(props.nav, { onChange: function(id) {
3018
+ if (props.nav.props.onChange) props.nav.props.onChange(id);
3019
+ setOpen(false);
3020
+ }, className: cx(props.nav.props.className, "is-in-drawer") }) : props.nav;
3021
+ return h16(
3022
+ "div",
3023
+ { ref, className: cx("aura-shell", compact && "is-compact", props.className) },
3024
+ !compact ? h16("div", { className: "aura-shell__nav" }, nav) : null,
3025
+ compact ? h16(Drawer, { open, onClose: function() {
3026
+ setOpen(false);
3027
+ }, side: "left", size: "nav", "aria-label": props.navLabel || t.navigation, dismissible: true }, nav) : null,
3028
+ h16(
3029
+ "div",
3030
+ { className: "aura-shell__main" },
3031
+ props.header || compact ? h16(
3032
+ "header",
3033
+ { className: "aura-shell__bar" },
3034
+ compact ? h16(IconButton, { icon: "menu", label: props.menuLabel || t.openNav, size: "md", onClick: function() {
3035
+ setOpen(true);
3036
+ }, "aria-expanded": open }) : null,
3037
+ h16("div", { className: "aura-shell__bar-content" }, props.header)
3038
+ ) : null,
3039
+ h16("main", { className: "aura-shell__content", id: props.mainId || "main" }, props.children)
3040
+ )
3041
+ );
3042
+ });
3043
+
3044
+ // src/Surface.js
3045
+ var React19 = __toESM(require("react"), 1);
3046
+ var h17 = React19.createElement;
3047
+ var Surface = React19.forwardRef(function Surface2(props, ref) {
3048
+ var t = props.texture || "mesh";
3049
+ var rest = omit(props, ["texture", "className", "children", "as"]);
3050
+ return h17(props.as || "div", Object.assign({}, rest, {
3051
+ ref,
3052
+ /* Textures stay light in every theme, so everything on them uses the light tokens. */
3053
+ "data-theme": "light",
3054
+ className: cx(
3055
+ "aura-surface",
3056
+ (t === "mesh" || t === "mesh-grain") && "aura-mesh",
3057
+ (t === "grain" || t === "mesh-grain") && "aura-grain",
3058
+ props.className
3059
+ )
3060
+ }), props.children);
3061
+ });
3062
+
3063
+ // src/Stat.js
3064
+ var React20 = __toESM(require("react"), 1);
3065
+ var h18 = React20.createElement;
3066
+ var Stat = React20.forwardRef(function Stat2(props, ref) {
3067
+ var ch = props.change;
3068
+ var dir = ch && (ch.direction || "flat");
3069
+ var tone2 = ch && (ch.tone || (dir === "up" ? "positive" : dir === "down" ? "negative" : "neutral"));
3070
+ var Tag3 = props.href ? "a" : props.onClick ? "button" : "div";
3071
+ var interactive = Tag3 !== "div";
3072
+ return h18(
3073
+ Tag3,
3074
+ {
3075
+ ref,
3076
+ className: cx("aura-stat", interactive && "is-interactive", props.loading && "is-loading", props.className),
3077
+ href: props.href,
3078
+ onClick: props.onClick,
3079
+ type: Tag3 === "button" ? "button" : void 0,
3080
+ "aria-busy": props.loading || void 0
3081
+ },
3082
+ h18(
3083
+ "span",
3084
+ { className: "aura-stat__head" },
3085
+ h18("span", { className: "aura-stat__label" }, props.label),
3086
+ props.icon ? h18("span", { className: "aura-stat__icon" }, h18(Icon, { name: props.icon })) : null
3087
+ ),
3088
+ props.loading ? h18("span", { className: "aura-stat__value" }, h18("span", { className: "aura-skel aura-stat__skel" })) : h18("span", { className: "aura-stat__value" }, props.value, props.unit ? h18("span", { className: "aura-stat__unit" }, props.unit) : null),
3089
+ ch && !props.loading || props.caption ? h18(
3090
+ "span",
3091
+ { className: "aura-stat__foot" },
3092
+ ch && !props.loading ? h18(
3093
+ "span",
3094
+ { className: cx("aura-stat__change", "is-" + tone2) },
3095
+ h18(Icon, { name: dir === "up" ? "trending-up" : dir === "down" ? "trending-down" : "minus", size: 14 }),
3096
+ h18("span", null, ch.value)
3097
+ ) : null,
3098
+ ch && ch.label && !props.loading ? h18("span", { className: "aura-stat__caption" }, ch.label) : null,
3099
+ props.caption ? h18("span", { className: "aura-stat__caption" }, props.caption) : null
3100
+ ) : null
3101
+ );
3102
+ });
3103
+
3104
+ // src/TimePicker.js
3105
+ var React21 = __toESM(require("react"), 1);
3106
+ var import_react_dom6 = require("react-dom");
3107
+ var h19 = React21.createElement;
3108
+ function pad2(n2) {
3109
+ return (n2 < 10 ? "0" : "") + n2;
3110
+ }
3111
+ function toMin(t) {
3112
+ var m = /^(\d{2}):(\d{2})$/.exec(t || "");
3113
+ return m ? +m[1] * 60 + +m[2] : null;
3114
+ }
3115
+ function fromMin(n2) {
3116
+ return pad2(Math.floor(n2 / 60)) + ":" + pad2(n2 % 60);
3117
+ }
3118
+ function parseTime(text) {
3119
+ var s = String(text || "").trim().toLowerCase().replace(/\s*(น\.?|นาฬิกา)$/, "").trim();
3120
+ var pm = /\s*(pm|p\.m\.)$/.test(s), am = /\s*(am|a\.m\.)$/.test(s);
3121
+ s = s.replace(/\s*(am|pm|a\.m\.|p\.m\.)$/, "");
3122
+ var m = /^(\d{1,2})(?:[:.](\d{2}))?$/.exec(s) || /^(\d{1,2})(\d{2})$/.exec(s);
3123
+ if (!m) return null;
3124
+ var hh = +m[1], mm = m[2] ? +m[2] : 0;
3125
+ if (pm && hh < 12) hh += 12;
3126
+ if (am && hh === 12) hh = 0;
3127
+ if (hh > 23 || mm > 59) return null;
3128
+ return pad2(hh) + ":" + pad2(mm);
3129
+ }
3130
+ var TimePicker = React21.forwardRef(function TimePicker2(props, ref) {
3131
+ var t = useStrings();
3132
+ var auto = uid(), id = props.id || auto, listId = id + "-list";
3133
+ var st = useMaybeControlled(props.value, props.defaultValue == null ? null : props.defaultValue, props.onChange);
3134
+ var value = st[0];
3135
+ var step = props.step || 30, lo = toMin(props.min) != null ? toMin(props.min) : 0, hi = toMin(props.max) != null ? toMin(props.max) : 24 * 60 - 1;
3136
+ var slots = React21.useMemo(function() {
3137
+ var out = [];
3138
+ for (var m = lo; m <= hi; m += step) out.push(fromMin(m));
3139
+ return out;
3140
+ }, [lo, hi, step]);
3141
+ function blocked(v) {
3142
+ var n2 = toMin(v);
3143
+ return n2 == null || n2 < lo || n2 > hi || props.isTimeDisabled && props.isTimeDisabled(v);
3144
+ }
3145
+ var openState = React21.useState(false), open = openState[0], setOpen = openState[1];
3146
+ var editState = React21.useState(null), editing = editState[0], setEditing = editState[1];
3147
+ var aState = React21.useState(0), active = aState[0], setActive = aState[1];
3148
+ var errState = React21.useState(null);
3149
+ var pos = React21.useState(null);
3150
+ var boxRef = React21.useRef(null), inputRef = React21.useRef(null), listRef = React21.useRef(null), inputMerged = useMergedRef(ref, inputRef);
3151
+ var mounted = useMounted();
3152
+ function nearest(v) {
3153
+ var n2 = toMin(v);
3154
+ if (n2 == null) return 0;
3155
+ var best = 0;
3156
+ slots.forEach(function(s, i) {
3157
+ if (Math.abs(toMin(s) - n2) < Math.abs(toMin(slots[best]) - n2)) best = i;
3158
+ });
3159
+ return best;
3160
+ }
3161
+ function place() {
3162
+ if (!boxRef.current) return;
3163
+ var r = boxRef.current.getBoundingClientRect(), below = window.innerHeight - r.bottom - 8, up = below < 200 && r.top > below;
3164
+ pos[1]({ left: r.left, width: Math.max(r.width, 160), top: up ? void 0 : r.bottom + 4, bottom: up ? window.innerHeight - r.top + 4 : void 0, maxHeight: Math.min(280, (up ? r.top : below) - 8) });
3165
+ }
3166
+ useIsoLayoutEffect(function() {
3167
+ if (open) place();
3168
+ }, [open]);
3169
+ React21.useEffect(function() {
3170
+ if (!open) return;
3171
+ function outside(e) {
3172
+ if (boxRef.current && boxRef.current.contains(e.target) || listRef.current && listRef.current.contains(e.target)) return;
3173
+ setOpen(false);
3174
+ }
3175
+ function onScroll(e) {
3176
+ if (!listRef.current || !listRef.current.contains(e.target)) place();
3177
+ }
3178
+ document.addEventListener("pointerdown", outside, true);
3179
+ window.addEventListener("scroll", onScroll, true);
3180
+ window.addEventListener("resize", place);
3181
+ return function() {
3182
+ document.removeEventListener("pointerdown", outside, true);
3183
+ window.removeEventListener("scroll", onScroll, true);
3184
+ window.removeEventListener("resize", place);
3185
+ };
3186
+ }, [open]);
3187
+ React21.useEffect(function() {
3188
+ if (!open || !listRef.current) return;
3189
+ var el = listRef.current.querySelector('[data-idx="' + active + '"]');
3190
+ if (el && el.scrollIntoView) el.scrollIntoView({ block: "nearest" });
3191
+ }, [active, open]);
3192
+ function show() {
3193
+ if (open || props.disabled || props.readOnly) return;
3194
+ setActive(nearest(value || props.suggest || fromMin(lo)));
3195
+ setOpen(true);
3196
+ }
3197
+ function commit(v) {
3198
+ if (v == null) {
3199
+ errState[1](null);
3200
+ st[1](null);
3201
+ return true;
3202
+ }
3203
+ if (blocked(v)) {
3204
+ errState[1](t.timeOutOfRange(fromMin(lo), fromMin(hi)));
3205
+ return false;
3206
+ }
3207
+ errState[1](null);
3208
+ st[1](v);
3209
+ return true;
3210
+ }
3211
+ function choose(i) {
3212
+ var v = slots[i];
3213
+ if (!v || blocked(v)) return;
3214
+ commit(v);
3215
+ setEditing(null);
3216
+ setOpen(false);
3217
+ if (inputRef.current) inputRef.current.focus();
3218
+ }
3219
+ function commitTyped() {
3220
+ if (editing == null) return;
3221
+ var txt = editing.trim();
3222
+ if (!txt) commit(null);
3223
+ else {
3224
+ var v = parseTime(txt);
3225
+ if (v) commit(v);
3226
+ else errState[1](t.timeInvalid);
3227
+ }
3228
+ setEditing(null);
3229
+ }
3230
+ function move(d) {
3231
+ var i = active;
3232
+ for (var k = 0; k < slots.length; k++) {
3233
+ i = Math.min(slots.length - 1, Math.max(0, i + d));
3234
+ if (!blocked(slots[i])) break;
3235
+ }
3236
+ setActive(i);
3237
+ }
3238
+ function onKeyDown(e) {
3239
+ var k = e.key;
3240
+ if (k === "ArrowDown") {
3241
+ e.preventDefault();
3242
+ if (!open) show();
3243
+ else move(1);
3244
+ } else if (k === "ArrowUp") {
3245
+ e.preventDefault();
3246
+ if (!open) show();
3247
+ else move(-1);
3248
+ } else if (k === "Home" && open) {
3249
+ e.preventDefault();
3250
+ setActive(0);
3251
+ } else if (k === "End" && open) {
3252
+ e.preventDefault();
3253
+ setActive(slots.length - 1);
3254
+ } else if (k === "PageDown" && open) {
3255
+ e.preventDefault();
3256
+ move(Math.max(1, Math.round(60 / step)));
3257
+ } else if (k === "PageUp" && open) {
3258
+ e.preventDefault();
3259
+ move(-Math.max(1, Math.round(60 / step)));
3260
+ } else if (k === "Enter") {
3261
+ if (editing != null) {
3262
+ e.preventDefault();
3263
+ commitTyped();
3264
+ setOpen(false);
3265
+ } else if (open) {
3266
+ e.preventDefault();
3267
+ choose(active);
3268
+ }
3269
+ } else if (k === "Escape") {
3270
+ if (open) {
3271
+ e.preventDefault();
3272
+ e.stopPropagation();
3273
+ setOpen(false);
3274
+ setEditing(null);
3275
+ }
3276
+ } else if (k === "Tab") {
3277
+ if (open) setOpen(false);
3278
+ }
3279
+ }
3280
+ var error = errState[0] || props.error;
3281
+ var list = open && mounted && pos[0] ? (0, import_react_dom6.createPortal)(
3282
+ h19(
3283
+ "div",
3284
+ { ref: listRef, className: "aura-combo__popover aura-time__popover", style: pos[0] },
3285
+ h19(
3286
+ "ul",
3287
+ { id: listId, role: "listbox", "aria-label": props.label, className: "aura-combo__list" },
3288
+ slots.map(function(s, i) {
3289
+ var dis = blocked(s), sel = s === value;
3290
+ return h19(
3291
+ "li",
3292
+ {
3293
+ key: s,
3294
+ id: id + "-opt-" + i,
3295
+ role: "option",
3296
+ "data-idx": i,
3297
+ "aria-selected": sel,
3298
+ "aria-disabled": dis || void 0,
3299
+ className: cx("aura-combo__option aura-time__option", i === active && "is-active", sel && "is-selected", dis && "is-disabled"),
3300
+ onPointerDown: function(e) {
3301
+ e.preventDefault();
3302
+ },
3303
+ onClick: function() {
3304
+ choose(i);
3305
+ },
3306
+ onPointerMove: function() {
3307
+ if (active !== i) setActive(i);
3308
+ }
3309
+ },
3310
+ h19("span", { className: "aura-combo__label" }, s),
3311
+ sel ? h19(Icon, { name: "check", className: "aura-combo__check" }) : null
3312
+ );
3313
+ })
3314
+ )
3315
+ ),
3316
+ document.body
3317
+ ) : null;
3318
+ return h19(
3319
+ Field,
3320
+ { id, label: props.label, hint: props.hint, error, required: props.required, optional: props.optional, disabled: props.disabled, className: props.className },
3321
+ h19(
3322
+ "div",
3323
+ { ref: boxRef, className: cx("aura-input aura-combo aura-time has-icon", open && "is-open") },
3324
+ h19(Icon, { name: "clock", className: "aura-input__icon" }),
3325
+ h19("input", {
3326
+ ref: inputMerged,
3327
+ id,
3328
+ type: "text",
3329
+ role: "combobox",
3330
+ inputMode: "numeric",
3331
+ autoComplete: "off",
3332
+ className: "aura-input__control",
3333
+ "aria-expanded": open,
3334
+ "aria-controls": listId,
3335
+ "aria-autocomplete": "none",
3336
+ "aria-activedescendant": open && editing == null ? id + "-opt-" + active : void 0,
3337
+ "aria-invalid": error ? true : void 0,
3338
+ "aria-describedby": error ? id + "-error" : props.hint ? id + "-hint" : void 0,
3339
+ placeholder: props.placeholder || t.timePlaceholder,
3340
+ disabled: props.disabled,
3341
+ readOnly: props.readOnly,
3342
+ required: props.required,
3343
+ name: props.name,
3344
+ value: editing != null ? editing : value || "",
3345
+ onChange: function(e) {
3346
+ setEditing(e.target.value);
3347
+ var v = parseTime(e.target.value);
3348
+ if (v) {
3349
+ if (!open) show();
3350
+ setActive(nearest(v));
3351
+ }
3352
+ },
3353
+ onClick: show,
3354
+ onKeyDown,
3355
+ onBlur: function() {
3356
+ setTimeout(function() {
3357
+ if (listRef.current && listRef.current.contains(document.activeElement)) return;
3358
+ commitTyped();
3359
+ setOpen(false);
3360
+ }, 0);
3361
+ }
3362
+ }),
3363
+ props.clearable !== false && value != null && !props.disabled ? h19("button", {
3364
+ type: "button",
3365
+ className: "aura-combo__clear",
3366
+ "aria-label": t.clear(props.label),
3367
+ tabIndex: -1,
3368
+ onClick: function() {
3369
+ commit(null);
3370
+ setEditing(null);
3371
+ if (inputRef.current) inputRef.current.focus();
3372
+ }
3373
+ }, h19(Icon, { name: "x" })) : null,
3374
+ h19(
3375
+ "button",
3376
+ {
3377
+ type: "button",
3378
+ tabIndex: -1,
3379
+ "aria-hidden": true,
3380
+ className: "aura-combo__toggle",
3381
+ onPointerDown: function(e) {
3382
+ e.preventDefault();
3383
+ },
3384
+ onClick: function() {
3385
+ if (open) setOpen(false);
3386
+ else {
3387
+ show();
3388
+ inputRef.current && inputRef.current.focus();
3389
+ }
3390
+ }
3391
+ },
3392
+ h19(Icon, { name: "chevron-down" })
3393
+ )
3394
+ ),
3395
+ list
3396
+ );
3397
+ });
3398
+
3399
+ // src/FileUpload.js
3400
+ var React22 = __toESM(require("react"), 1);
3401
+ var h20 = React22.createElement;
3402
+ function formatBytes(n2) {
3403
+ if (n2 == null) return "";
3404
+ if (n2 < 1024) return n2 + " B";
3405
+ var u = ["KB", "MB", "GB"], i = -1;
3406
+ do {
3407
+ n2 /= 1024;
3408
+ i++;
3409
+ } while (n2 >= 1024 && i < u.length - 1);
3410
+ return (n2 >= 10 || Math.round(n2) === n2 ? Math.round(n2) : n2.toFixed(1)) + " " + u[i];
3411
+ }
3412
+ function matches(file, accept) {
3413
+ if (!accept) return true;
3414
+ var name = (file.name || "").toLowerCase(), type = (file.type || "").toLowerCase();
3415
+ return accept.split(",").some(function(a) {
3416
+ a = a.trim().toLowerCase();
3417
+ if (!a) return false;
3418
+ if (a[0] === ".") return name.slice(-a.length) === a;
3419
+ if (a.slice(-2) === "/*") return type.indexOf(a.slice(0, -1)) === 0;
3420
+ return type === a;
3421
+ });
3422
+ }
3423
+ function describeAccept(accept, t) {
3424
+ if (!accept) return "";
3425
+ return accept.split(",").map(function(a) {
3426
+ a = a.trim();
3427
+ if (a === "image/*") return t.images;
3428
+ if (a === "application/pdf") return "PDF";
3429
+ return a.replace(/^\./, "").toUpperCase();
3430
+ }).filter(function(x, i, arr) {
3431
+ return arr.indexOf(x) === i;
3432
+ }).join(", ");
3433
+ }
3434
+ var seq = 0;
3435
+ var FileUpload = React22.forwardRef(function FileUpload2(props, ref) {
3436
+ var t = useStrings();
3437
+ var auto = uid(), id = props.id || auto;
3438
+ var st = useMaybeControlled(props.value, props.defaultValue || [], props.onChange);
3439
+ var items = st[0] || [];
3440
+ var dragState = React22.useState(false), over = dragState[0];
3441
+ var inputRef = React22.useRef(null), inputMerged = useMergedRef(ref, inputRef);
3442
+ var urls = React22.useRef({});
3443
+ var maxFiles = props.multiple ? props.maxFiles : 1;
3444
+ var note = t.accepts(describeAccept(props.accept, t), props.maxSize ? formatBytes(props.maxSize) : "");
3445
+ React22.useEffect(function() {
3446
+ return function() {
3447
+ Object.keys(urls.current).forEach(function(k) {
3448
+ URL.revokeObjectURL(urls.current[k]);
3449
+ });
3450
+ };
3451
+ }, []);
3452
+ function thumb(it) {
3453
+ if (!it.file || !/^image\//.test(it.type || "") || typeof URL === "undefined" || !URL.createObjectURL) return null;
3454
+ if (!urls.current[it.id]) urls.current[it.id] = URL.createObjectURL(it.file);
3455
+ return urls.current[it.id];
3456
+ }
3457
+ function add(list) {
3458
+ var files = Array.prototype.slice.call(list || []);
3459
+ if (!files.length || props.disabled) return;
3460
+ var keep = props.multiple ? items.slice() : [];
3461
+ var room = maxFiles ? maxFiles - keep.filter(function(i) {
3462
+ return !i.error;
3463
+ }).length : Infinity;
3464
+ files.forEach(function(f) {
3465
+ var err = null;
3466
+ if (!matches(f, props.accept)) err = t.fileWrongType;
3467
+ else if (props.maxSize && f.size > props.maxSize) err = t.fileTooBig(formatBytes(props.maxSize));
3468
+ else if (room <= 0) err = t.tooManyFiles(maxFiles);
3469
+ else room--;
3470
+ keep.push({ id: "f" + ++seq, file: f, name: f.name, size: f.size, type: f.type, status: err ? "error" : "ready", error: err || void 0 });
3471
+ });
3472
+ st[1](keep);
3473
+ }
3474
+ function remove(it) {
3475
+ if (urls.current[it.id]) {
3476
+ URL.revokeObjectURL(urls.current[it.id]);
3477
+ delete urls.current[it.id];
3478
+ }
3479
+ st[1](items.filter(function(x) {
3480
+ return x.id !== it.id;
3481
+ }));
3482
+ if (props.onRemove) props.onRemove(it);
3483
+ if (inputRef.current) inputRef.current.focus();
3484
+ }
3485
+ var error = props.error;
3486
+ return h20(
3487
+ Field,
3488
+ { id, label: props.label, hint: props.hint, error, required: props.required, optional: props.optional, disabled: props.disabled, className: props.className },
3489
+ h20(
3490
+ "div",
3491
+ {
3492
+ className: cx("aura-upload", over && "is-over", props.disabled && "is-disabled", error && "is-invalid"),
3493
+ onClick: function(e) {
3494
+ if (!props.disabled && e.target !== inputRef.current && inputRef.current) inputRef.current.click();
3495
+ },
3496
+ onDragOver: function(e) {
3497
+ if (props.disabled) return;
3498
+ e.preventDefault();
3499
+ if (!over) dragState[1](true);
3500
+ },
3501
+ onDragLeave: function(e) {
3502
+ if (!e.currentTarget.contains(e.relatedTarget)) dragState[1](false);
3503
+ },
3504
+ onDrop: function(e) {
3505
+ e.preventDefault();
3506
+ dragState[1](false);
3507
+ add(e.dataTransfer && e.dataTransfer.files);
3508
+ }
3509
+ },
3510
+ h20(Icon, { name: "cloud-upload", size: "lg", className: "aura-upload__icon" }),
3511
+ h20("span", { className: "aura-upload__text" }, t.dropFiles, " "),
3512
+ /* The real input: visually hidden, still the labelled, focusable control (keyboard and screen readers use it). */
3513
+ h20("input", {
3514
+ ref: inputMerged,
3515
+ id,
3516
+ type: "file",
3517
+ className: "aura-upload__input",
3518
+ accept: props.accept,
3519
+ multiple: !!props.multiple,
3520
+ disabled: props.disabled,
3521
+ name: props.name,
3522
+ required: props.required && !items.some(function(i) {
3523
+ return !i.error;
3524
+ }),
3525
+ "aria-invalid": error ? true : void 0,
3526
+ "aria-describedby": [error ? id + "-error" : props.hint ? id + "-hint" : null, note ? id + "-note" : null].filter(Boolean).join(" ") || void 0,
3527
+ onChange: function(e) {
3528
+ add(e.target.files);
3529
+ e.target.value = "";
3530
+ }
3531
+ }),
3532
+ h20("span", { className: "aura-upload__browse", "aria-hidden": true }, props.multiple ? t.browse : t.browseOne),
3533
+ note ? h20("span", { className: "aura-upload__note", id: id + "-note" }, note) : null
3534
+ ),
3535
+ items.length ? h20("ul", { className: "aura-upload__list", "aria-live": "polite" }, items.map(function(it) {
3536
+ var src = thumb(it);
3537
+ return h20(
3538
+ "li",
3539
+ { key: it.id, className: cx("aura-upload__item", it.error && "is-error") },
3540
+ src ? h20("img", { className: "aura-upload__thumb", src, alt: "" }) : h20("span", { className: "aura-upload__thumb is-icon", "aria-hidden": true }, h20(Icon, { name: /^image\//.test(it.type || "") ? "image" : "file", size: "md" })),
3541
+ h20(
3542
+ "span",
3543
+ { className: "aura-upload__meta" },
3544
+ h20("span", { className: "aura-upload__name" }, it.name),
3545
+ h20(
3546
+ "span",
3547
+ { className: "aura-upload__sub" },
3548
+ it.error ? h20(React22.Fragment, null, h20(Icon, { name: "circle-alert", size: 12 }), it.error) : it.status === "uploading" ? t.uploading + (it.progress != null ? " " + Math.round(it.progress) + "%" : "") : it.status === "done" ? h20(React22.Fragment, null, h20(Icon, { name: "circle-check", size: 12 }), formatBytes(it.size)) : formatBytes(it.size)
3549
+ ),
3550
+ it.status === "uploading" ? h20(
3551
+ "span",
3552
+ { className: "aura-upload__bar", role: "progressbar", "aria-label": it.name, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": it.progress != null ? Math.round(it.progress) : void 0 },
3553
+ h20("span", { style: { width: (it.progress || 0) + "%" } })
3554
+ ) : null
3555
+ ),
3556
+ h20(IconButton, { icon: "x", label: t.remove(it.name), onClick: function() {
3557
+ remove(it);
3558
+ } })
3559
+ );
3560
+ })) : null
3561
+ );
3562
+ });
3563
+
3564
+ // src/theme.js
3565
+ function hexToRgb(hex) {
3566
+ var h23 = String(hex).trim().replace("#", "");
3567
+ if (h23.length === 3) h23 = h23.split("").map(function(c) {
3568
+ return c + c;
3569
+ }).join("");
3570
+ if (!/^[0-9a-f]{6}$/i.test(h23)) throw new Error('createTheme: "' + hex + '" is not a #rgb or #rrggbb colour');
3571
+ return [0, 2, 4].map(function(i) {
3572
+ return parseInt(h23.slice(i, i + 2), 16) / 255;
3573
+ });
3574
+ }
3575
+ function rgbToHex(rgb) {
3576
+ return "#" + rgb.map(function(v) {
3577
+ var n2 = Math.round(Math.min(1, Math.max(0, v)) * 255);
3578
+ return (n2 < 16 ? "0" : "") + n2.toString(16);
3579
+ }).join("");
3580
+ }
3581
+ function lin(c) {
3582
+ return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
3583
+ }
3584
+ function delin(c) {
3585
+ return c <= 31308e-7 ? 12.92 * c : 1.055 * Math.pow(c, 1 / 2.4) - 0.055;
3586
+ }
3587
+ function rgbToOklch(rgb) {
3588
+ var r = lin(rgb[0]), g = lin(rgb[1]), b = lin(rgb[2]);
3589
+ var l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
3590
+ var m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
3591
+ var s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
3592
+ var L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s;
3593
+ var A = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;
3594
+ var B = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;
3595
+ return [L, Math.sqrt(A * A + B * B), (Math.atan2(B, A) * 180 / Math.PI + 360) % 360];
3596
+ }
3597
+ function oklchToRgbRaw(L, C, H) {
3598
+ var a = C * Math.cos(H * Math.PI / 180), b = C * Math.sin(H * Math.PI / 180);
3599
+ var l = Math.pow(L + 0.3963377774 * a + 0.2158037573 * b, 3);
3600
+ var m = Math.pow(L - 0.1055613458 * a - 0.0638541728 * b, 3);
3601
+ var s = Math.pow(L - 0.0894841775 * a - 1.291485548 * b, 3);
3602
+ return [
3603
+ 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
3604
+ -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
3605
+ -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s
3606
+ ].map(delin);
3607
+ }
3608
+ function inGamut(rgb) {
3609
+ return rgb.every(function(v) {
3610
+ return v >= -5e-4 && v <= 1.0005;
3611
+ });
3612
+ }
3613
+ function oklchToHex(L, C, H) {
3614
+ var lo = 0, hi = C, rgb = oklchToRgbRaw(L, C, H);
3615
+ if (inGamut(rgb)) return rgbToHex(rgb);
3616
+ for (var i = 0; i < 24; i++) {
3617
+ var mid = (lo + hi) / 2;
3618
+ if (inGamut(oklchToRgbRaw(L, mid, H))) lo = mid;
3619
+ else hi = mid;
3620
+ }
3621
+ return rgbToHex(oklchToRgbRaw(L, lo, H));
3622
+ }
3623
+ function luminance(hex) {
3624
+ var c = hexToRgb(hex).map(lin);
3625
+ return 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];
3626
+ }
3627
+ function contrast(a, b) {
3628
+ var x = luminance(a), y = luminance(b);
3629
+ return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05);
3630
+ }
3631
+ function mix(a, b, t) {
3632
+ var x = hexToRgb(a), y = hexToRgb(b);
3633
+ return rgbToHex(x.map(function(v, i) {
3634
+ return v + (y[i] - v) * t;
3635
+ }));
3636
+ }
3637
+ var STEPS = { 50: [0.975, 0.18], 100: [0.945, 0.3], 200: [0.895, 0.5], 300: [0.81, 0.72], 400: [0.715, 0.9], 500: [0.635, 1], 600: [0.555, 1], 700: [0.49, 0.95], 800: [0.43, 0.85], 900: [0.38, 0.72] };
3638
+ function scale(hex) {
3639
+ var o = rgbToOklch(hexToRgb(hex)), C = Math.max(o[1], 0.02), out = {};
3640
+ Object.keys(STEPS).forEach(function(k) {
3641
+ out[k] = oklchToHex(STEPS[k][0], C * STEPS[k][1] / 0.95 * (o[1] < 0.03 ? 0.4 : 1), o[2]);
3642
+ });
3643
+ return out;
3644
+ }
3645
+ function fit(hex, grounds, target, dir) {
3646
+ var o = rgbToOklch(hexToRgb(hex)), L = o[0], c = hex;
3647
+ for (var i = 0; i < 80; i++) {
3648
+ if (grounds.every(function(g) {
3649
+ return contrast(c, g) >= target;
3650
+ })) return c;
3651
+ L = Math.min(1, Math.max(0, L + dir * 0.01));
3652
+ c = oklchToHex(L, o[1], o[2]);
3653
+ }
3654
+ return c;
3655
+ }
3656
+ var ZINC = { 0: "#ffffff", 50: "#fafafa", 100: "#f4f4f5", 800: "#27272a", 900: "#18181b", 950: "#09090b" };
3657
+ var INK = "#18181b";
3658
+ function createTheme(opts) {
3659
+ var o = opts || {};
3660
+ if (!o.brand) throw new Error('createTheme: pass { brand: "#rrggbb" }');
3661
+ var b = scale(o.brand), s = o.signal ? scale(o.signal) : null;
3662
+ var lightGrounds = [ZINC[0], ZINC[50]], darkGrounds = [ZINC[900], ZINC[950]];
3663
+ var L = {}, D = {};
3664
+ L["fg-accent"] = fit(b[700], lightGrounds, 4.5, -1);
3665
+ L["accent-violet"] = L["fg-accent"];
3666
+ L["focus-ring"] = fit(b[700], lightGrounds.concat([b[50]]), 3, -1);
3667
+ L["bg-selected"] = b[50];
3668
+ L["status-progress-bg"] = b[100];
3669
+ L["status-progress-fg"] = fit(b[800], [b[100]], 4.5, -1);
3670
+ L["alert-info-bg"] = b[50];
3671
+ L["alert-info-fg"] = fit(b[800], [b[50]], 4.5, -1);
3672
+ L["alert-info-border"] = b[200];
3673
+ L["mesh-from"] = b[400];
3674
+ D["fg-accent"] = fit(b[300], darkGrounds, 4.5, 1);
3675
+ D["accent-violet"] = fit(b[400], darkGrounds, 3, 1);
3676
+ D["focus-ring"] = fit(b[400], darkGrounds, 3, 1);
3677
+ D["bg-selected"] = mix(ZINC[900], b[500], 0.16);
3678
+ D["alert-info-bg"] = D["bg-selected"];
3679
+ D["alert-info-fg"] = fit(b[300], [D["alert-info-bg"]], 4.5, 1);
3680
+ D["alert-info-border"] = mix(ZINC[900], b[400], 0.4);
3681
+ D["status-progress-bg"] = b[100];
3682
+ D["status-progress-fg"] = L["status-progress-fg"];
3683
+ if (s) {
3684
+ L["accent-dot"] = s[200];
3685
+ L["accent-lime"] = s[200];
3686
+ L["mesh-to"] = s[200];
3687
+ D["accent-dot"] = s[200];
3688
+ D["accent-lime"] = s[200];
3689
+ D["mesh-to"] = s[200];
3690
+ }
3691
+ var shadowLight = INK, shadowDark = D["accent-violet"];
3692
+ if (o.primary === "brand") {
3693
+ L["button-primary-bg"] = fit(b[600], [ZINC[0]], 4.5, -1);
3694
+ L["button-primary-fg"] = ZINC[0];
3695
+ L["button-primary-bg-hover"] = fit(b[700], [ZINC[0]], 4.5, -1);
3696
+ D["button-primary-bg"] = fit(b[400], [ZINC[900]], 4.5, 1);
3697
+ D["button-primary-fg"] = ZINC[900];
3698
+ D["button-primary-bg-hover"] = fit(b[300], [ZINC[900]], 4.5, 1);
3699
+ }
3700
+ L["shadow-creative"] = "4px 4px 0px " + shadowLight;
3701
+ L["shadow-creative-hover"] = "6px 6px 0px " + shadowLight;
3702
+ L["card-shadow-creative"] = "8px 8px 0px " + shadowLight;
3703
+ D["shadow-creative"] = "4px 4px 0px " + shadowDark;
3704
+ D["shadow-creative-hover"] = "6px 6px 0px " + shadowDark;
3705
+ D["card-shadow-creative"] = "8px 8px 0px " + shadowDark;
3706
+ var checks = [];
3707
+ function check(theme, fg, bg, target, fgHex, bgHex) {
3708
+ var r = contrast(fgHex, bgHex);
3709
+ checks.push({ theme, pair: fg + " on " + bg, ratio: Math.round(r * 100) / 100, target, pass: r >= target - 5e-3 });
3710
+ }
3711
+ [["bg-surface", ZINC[0]], ["bg-canvas", ZINC[50]], ["bg-selected", L["bg-selected"]]].forEach(function(g) {
3712
+ check("light", "fg-accent", g[0], 4.5, L["fg-accent"], g[1]);
3713
+ check("light", "focus-ring", g[0], 3, L["focus-ring"], g[1]);
3714
+ });
3715
+ [["bg-surface", ZINC[900]], ["bg-canvas", ZINC[950]], ["bg-selected", D["bg-selected"]]].forEach(function(g) {
3716
+ check("dark", "fg-accent", g[0], 4.5, D["fg-accent"], g[1]);
3717
+ check("dark", "focus-ring", g[0], 3, D["focus-ring"], g[1]);
3718
+ });
3719
+ check("light", "fg-primary", "bg-selected", 4.5, INK, L["bg-selected"]);
3720
+ check("dark", "fg-primary", "bg-selected", 4.5, "#ffffff", D["bg-selected"]);
3721
+ check("light", "status-progress-fg", "status-progress-bg", 4.5, L["status-progress-fg"], L["status-progress-bg"]);
3722
+ check("light", "alert-info-fg", "alert-info-bg", 4.5, L["alert-info-fg"], L["alert-info-bg"]);
3723
+ check("dark", "alert-info-fg", "alert-info-bg", 4.5, D["alert-info-fg"], D["alert-info-bg"]);
3724
+ if (o.primary === "brand") {
3725
+ check("light", "button-primary-fg", "button-primary-bg", 4.5, L["button-primary-fg"], L["button-primary-bg"]);
3726
+ check("light", "button-primary-fg", "button-primary-bg-hover", 4.5, L["button-primary-fg"], L["button-primary-bg-hover"]);
3727
+ check("dark", "button-primary-fg", "button-primary-bg", 4.5, D["button-primary-fg"], D["button-primary-bg"]);
3728
+ check("dark", "button-primary-fg", "button-primary-bg-hover", 4.5, D["button-primary-fg"], D["button-primary-bg-hover"]);
3729
+ }
3730
+ if (s) check("light", "ink", "accent-lime (signal)", 4.5, INK, s[200]);
3731
+ function css(selector) {
3732
+ var light = selector ? selector : ':root, [data-theme="light"]';
3733
+ var dark = selector ? selector + ".dark, .dark " + selector + ", " + selector + '[data-theme="dark"], [data-theme="dark"] ' + selector : '.dark, [data-theme="dark"]';
3734
+ function block(sel, m) {
3735
+ return sel + " {\n" + Object.keys(m).map(function(k) {
3736
+ return " --aura-" + k + ": " + m[k] + ";";
3737
+ }).join("\n") + "\n}";
3738
+ }
3739
+ return "/* AURA theme" + (o.name ? ' "' + o.name + '"' : "") + ": brand " + o.brand + (o.signal ? ", signal " + o.signal : "") + (o.primary === "brand" ? ", brand primary buttons" : "") + ". Load after aura.css. Generated by createTheme. */\n" + block(light, L) + "\n" + block(dark, D) + "\n";
3740
+ }
3741
+ return { name: o.name || null, brand: b, signal: s, light: L, dark: D, checks, ok: checks.every(function(c) {
3742
+ return c.pass;
3743
+ }), css };
3744
+ }
3745
+
3746
+ // src/ThemeStyle.js
3747
+ var React23 = __toESM(require("react"), 1);
3748
+ var h21 = React23.createElement;
3749
+ function ThemeStyle(props) {
3750
+ var css = React23.useMemo(function() {
3751
+ return createTheme({ brand: props.brand, signal: props.signal, primary: props.primary, name: props.name }).css(props.selector);
3752
+ }, [props.brand, props.signal, props.primary, props.name, props.selector]);
3753
+ return h21("style", { "data-aura-theme": props.name || props.brand, dangerouslySetInnerHTML: { __html: css } });
3754
+ }
3755
+
3756
+ // src/extra.js
3757
+ var React24 = __toESM(require("react"), 1);
3758
+ var import_react_dom7 = require("react-dom");
3759
+ var h22 = React24.createElement;
3760
+ var TONES = ["neutral", "accent", "success", "warning", "danger"];
3761
+ function tone(t) {
3762
+ return TONES.indexOf(t) >= 0 ? t : "neutral";
3763
+ }
3764
+ var Badge = React24.forwardRef(function Badge2(props, ref) {
3765
+ var rest = omit(props, ["tone", "variant", "icon", "className", "children"]);
3766
+ return h22(
3767
+ "span",
3768
+ Object.assign({}, rest, { ref, className: cx("aura-badge", "aura-badge--" + tone(props.tone), props.variant === "solid" && "is-solid", props.variant === "outline" && "is-outline", props.className) }),
3769
+ props.icon ? h22(Icon, { name: props.icon, size: 12 }) : null,
3770
+ props.children
3771
+ );
3772
+ });
3773
+ var Tag = React24.forwardRef(function Tag2(props, ref) {
3774
+ var t = useStrings();
3775
+ var selectable = props.onClick != null || props.selected != null;
3776
+ var rest = omit(props, ["onRemove", "selected", "icon", "className", "children", "disabled", "removeLabel"]);
3777
+ var inner = [props.icon ? h22(Icon, { key: "i", name: props.icon, size: 14 }) : null, h22("span", { key: "t", className: "aura-tag__text" }, props.children)];
3778
+ if (selectable) {
3779
+ return h22(
3780
+ "button",
3781
+ Object.assign({}, rest, {
3782
+ ref,
3783
+ type: "button",
3784
+ "aria-pressed": !!props.selected,
3785
+ disabled: props.disabled,
3786
+ className: cx("aura-tag is-selectable", props.selected && "is-selected", props.className)
3787
+ }),
3788
+ props.selected ? h22(Icon, { name: "check", size: 14 }) : inner[0],
3789
+ inner[1]
3790
+ );
3791
+ }
3792
+ return h22(
3793
+ "span",
3794
+ Object.assign({}, rest, { ref, className: cx("aura-tag", props.disabled && "is-disabled", props.className) }),
3795
+ inner,
3796
+ props.onRemove && !props.disabled ? h22(
3797
+ "button",
3798
+ { type: "button", className: "aura-tag__remove", "aria-label": props.removeLabel || t.remove(typeof props.children === "string" ? props.children : ""), onClick: props.onRemove },
3799
+ h22(Icon, { name: "x", size: 12 })
3800
+ ) : null
3801
+ );
3802
+ });
3803
+ var Progress = React24.forwardRef(function Progress2(props, ref) {
3804
+ var auto = uid(), id = props.id || auto;
3805
+ var max = props.max || 100, det = props.value != null;
3806
+ var pct = det ? Math.max(0, Math.min(100, props.value / max * 100)) : 0;
3807
+ var shown = props.valueLabel != null ? props.valueLabel : det ? Math.round(pct) + "%" : null;
3808
+ return h22(
3809
+ "div",
3810
+ { ref, className: cx("aura-progress", "aura-progress--" + tone(props.tone || "accent"), props.size === "sm" && "is-sm", props.className) },
3811
+ props.label || props.showValue && shown ? h22(
3812
+ "div",
3813
+ { className: "aura-progress__head" },
3814
+ props.label ? h22("span", { className: "aura-progress__label", id: id + "-label" }, props.label) : h22("span"),
3815
+ props.showValue && shown ? h22("span", { className: "aura-progress__value" }, shown) : null
3816
+ ) : null,
3817
+ h22(
3818
+ "div",
3819
+ {
3820
+ className: cx("aura-progress__track", !det && "is-indeterminate"),
3821
+ role: "progressbar",
3822
+ "aria-labelledby": props.label ? id + "-label" : void 0,
3823
+ "aria-label": props.label ? void 0 : props["aria-label"],
3824
+ "aria-valuemin": det ? 0 : void 0,
3825
+ "aria-valuemax": det ? max : void 0,
3826
+ "aria-valuenow": det ? props.value : void 0,
3827
+ "aria-valuetext": det && props.valueLabel != null ? String(props.valueLabel) : void 0
3828
+ },
3829
+ h22("span", { className: "aura-progress__bar", style: det ? { width: pct + "%" } : void 0 })
3830
+ ),
3831
+ props.hint ? h22("p", { className: "aura-progress__hint" }, props.hint) : null
3832
+ );
3833
+ });
3834
+ var Skeleton = React24.forwardRef(function Skeleton2(props, ref) {
3835
+ var v = props.variant || "text";
3836
+ if (v === "text" && (props.lines || 1) > 1) {
3837
+ var n2 = props.lines, rows = [];
3838
+ for (var i = 0; i < n2; i++) rows.push(h22("span", { key: i, className: "aura-skel aura-skel--text", style: { width: i === n2 - 1 ? "60%" : "100%" } }));
3839
+ return h22("span", { ref, className: cx("aura-skel-lines", props.className), "aria-hidden": true, style: props.width ? { width: props.width } : void 0 }, rows);
3840
+ }
3841
+ var style = { width: props.width, height: props.height };
3842
+ if (v === "circle") {
3843
+ style.width = style.height = props.size || props.width || 40;
3844
+ }
3845
+ return h22("span", { ref, "aria-hidden": true, className: cx("aura-skel", "aura-skel--" + v, props.className), style });
3846
+ });
3847
+ var EmptyState = React24.forwardRef(function EmptyState2(props, ref) {
3848
+ var HT = "h" + (props.headingLevel || 3);
3849
+ return h22(
3850
+ "div",
3851
+ { ref, className: cx("aura-empty", props.size === "sm" && "is-sm", props.bordered && "is-bordered", props.className) },
3852
+ h22("span", { className: "aura-empty__icon", "aria-hidden": true }, h22(Icon, { name: props.icon || "inbox", size: props.size === "sm" ? "md" : "lg" })),
3853
+ h22(HT, { className: "aura-empty__title" }, props.title),
3854
+ props.description ? h22("p", { className: "aura-empty__text" }, props.description) : null,
3855
+ props.action ? h22("div", { className: "aura-empty__action" }, props.action) : null
3856
+ );
3857
+ });
3858
+ function pageList(page, count, sib) {
3859
+ var out = [], lo = Math.max(2, page - sib), hi = Math.min(count - 1, page + sib);
3860
+ if (page - sib <= 3) {
3861
+ lo = 2;
3862
+ hi = Math.min(count - 1, Math.max(hi, 3 + 2 * sib));
3863
+ }
3864
+ if (page + sib >= count - 2) {
3865
+ hi = count - 1;
3866
+ lo = Math.max(2, Math.min(lo, count - 2 - 2 * sib));
3867
+ }
3868
+ out.push(1);
3869
+ if (lo === 3) out.push(2);
3870
+ else if (lo > 3) out.push("\u2026a");
3871
+ for (var i = lo; i <= hi; i++) out.push(i);
3872
+ if (hi === count - 2) out.push(count - 1);
3873
+ else if (hi < count - 2) out.push("\u2026b");
3874
+ if (count > 1) out.push(count);
3875
+ return out;
3876
+ }
3877
+ var Pagination = React24.forwardRef(function Pagination2(props, ref) {
3878
+ var t = useStrings();
3879
+ var count = Math.max(1, props.pageCount || 1);
3880
+ var st = useMaybeControlled(props.page, props.defaultPage || 1, props.onChange);
3881
+ var page = Math.min(count, Math.max(1, st[0]));
3882
+ function go(p) {
3883
+ if (p >= 1 && p <= count && p !== page) st[1](p);
3884
+ }
3885
+ var link = props.getHref;
3886
+ function item(p, label, extra) {
3887
+ var common = Object.assign({ className: cx("aura-page", p === page && "is-current"), "aria-current": p === page ? "page" : void 0, "aria-label": t.pageN(p) }, extra);
3888
+ return link ? h22("a", Object.assign({ href: link(p), onClick: function(e) {
3889
+ if (props.onChange) {
3890
+ e.preventDefault();
3891
+ go(p);
3892
+ }
3893
+ } }, common), label) : h22("button", Object.assign({ type: "button", onClick: function() {
3894
+ go(p);
3895
+ } }, common), label);
3896
+ }
3897
+ return h22(
3898
+ "nav",
3899
+ { ref, className: cx("aura-pagination", props.className), "aria-label": props.label || t.pagination },
3900
+ h22(IconButton, { icon: "chevron-left", label: t.prevPage, disabled: page <= 1, onClick: function() {
3901
+ go(page - 1);
3902
+ } }),
3903
+ h22("ol", { className: "aura-pagination__list" }, pageList(page, count, props.siblingCount == null ? 1 : props.siblingCount).map(function(p) {
3904
+ return typeof p === "number" ? h22("li", { key: p }, item(p, p)) : h22("li", { key: p, className: "aura-pagination__gap", "aria-hidden": true }, "\u2026");
3905
+ })),
3906
+ h22("span", { className: "aura-pagination__compact", "aria-hidden": true }, t.page(page, count)),
3907
+ h22(IconButton, { icon: "chevron-right", label: t.nextPage, disabled: page >= count, onClick: function() {
3908
+ go(page + 1);
3909
+ } })
3910
+ );
3911
+ });
3912
+ var Accordion = React24.forwardRef(function Accordion2(props, ref) {
3913
+ var auto = uid(), base = props.id || auto;
3914
+ var multiple = props.type === "multiple";
3915
+ var st = useMaybeControlled(props.value, props.defaultValue != null ? props.defaultValue : multiple ? [] : null, props.onChange);
3916
+ var open = multiple ? st[0] || [] : st[0] ? [st[0]] : [];
3917
+ var HT = "h" + (props.headingLevel || 3);
3918
+ var items = props.items || [];
3919
+ function toggle(id) {
3920
+ var isOpen = open.indexOf(id) >= 0;
3921
+ if (multiple) st[1](isOpen ? open.filter(function(x) {
3922
+ return x !== id;
3923
+ }) : open.concat([id]));
3924
+ else st[1](isOpen ? props.collapsible === false ? id : null : id);
3925
+ }
3926
+ function onKey(e) {
3927
+ var btns = Array.prototype.slice.call(e.currentTarget.querySelectorAll(":scope > .aura-accordion__item > .aura-accordion__heading > button:not([disabled])"));
3928
+ var i = btns.indexOf(document.activeElement), k = e.key, n2 = null;
3929
+ if (i < 0) return;
3930
+ if (k === "ArrowDown") n2 = btns[(i + 1) % btns.length];
3931
+ else if (k === "ArrowUp") n2 = btns[(i - 1 + btns.length) % btns.length];
3932
+ else if (k === "Home") n2 = btns[0];
3933
+ else if (k === "End") n2 = btns[btns.length - 1];
3934
+ if (n2) {
3935
+ e.preventDefault();
3936
+ n2.focus();
3937
+ }
3938
+ }
3939
+ return h22(
3940
+ "div",
3941
+ { ref, className: cx("aura-accordion", props.className), onKeyDown: onKey },
3942
+ items.map(function(it) {
3943
+ var on = open.indexOf(it.id) >= 0, bid = base + "-btn-" + it.id, pid = base + "-panel-" + it.id;
3944
+ return h22(
3945
+ "div",
3946
+ { key: it.id, className: cx("aura-accordion__item", on && "is-open") },
3947
+ h22(
3948
+ HT,
3949
+ { className: "aura-accordion__heading" },
3950
+ h22(
3951
+ "button",
3952
+ { type: "button", id: bid, "aria-expanded": on, "aria-controls": pid, disabled: it.disabled, onClick: function() {
3953
+ toggle(it.id);
3954
+ } },
3955
+ it.icon ? h22(Icon, { name: it.icon, className: "aura-accordion__lead" }) : null,
3956
+ h22(
3957
+ "span",
3958
+ { className: "aura-accordion__title" },
3959
+ it.title,
3960
+ it.description ? h22("span", { className: "aura-accordion__desc" }, it.description) : null
3961
+ ),
3962
+ h22(Icon, { name: "chevron-down", className: "aura-accordion__chevron" })
3963
+ )
3964
+ ),
3965
+ h22("div", { id: pid, role: "region", "aria-labelledby": bid, className: "aura-accordion__panel", hidden: !on }, it.content)
3966
+ );
3967
+ })
3968
+ );
3969
+ });
3970
+ function position(anchor, pop, placement) {
3971
+ var r = anchor.getBoundingClientRect(), pw = pop.offsetWidth, ph = pop.offsetHeight, vw = window.innerWidth, vh = window.innerHeight, gap = 6;
3972
+ var side = (placement || "bottom-start").split("-")[0], align = (placement || "bottom-start").split("-")[1] || "start";
3973
+ if (side === "bottom" && r.bottom + gap + ph > vh - 8 && r.top - gap - ph > 8) side = "top";
3974
+ else if (side === "top" && r.top - gap - ph < 8 && r.bottom + gap + ph < vh - 8) side = "bottom";
3975
+ var top = side === "top" ? r.top - gap - ph : r.bottom + gap;
3976
+ var left = align === "end" ? r.right - pw : align === "center" ? r.left + r.width / 2 - pw / 2 : r.left;
3977
+ return { top: Math.max(8, top), left: Math.max(8, Math.min(left, vw - pw - 8)), side };
3978
+ }
3979
+ var Popover = React24.forwardRef(function Popover2(props, ref) {
3980
+ var t = useStrings();
3981
+ var auto = uid(), id = props.id || auto;
3982
+ var st = useMaybeControlled(props.open, !!props.defaultOpen, props.onOpenChange);
3983
+ var open = !!st[0];
3984
+ var wrap = React24.useRef(null), pop = React24.useRef(null), popMerged = useMergedRef(ref, pop);
3985
+ var pos = React24.useState(null), mounted = useMounted();
3986
+ function trigger() {
3987
+ return wrap.current && (wrap.current.querySelector('button, [role="button"], a, input') || wrap.current.firstElementChild);
3988
+ }
3989
+ function close(restore) {
3990
+ st[1](false);
3991
+ if (restore) {
3992
+ var tr = trigger();
3993
+ if (tr && tr.focus) tr.focus();
3994
+ }
3995
+ }
3996
+ useIsoLayoutEffect(function() {
3997
+ if (!open || !pop.current || !trigger()) return;
3998
+ function place() {
3999
+ if (pop.current && trigger()) pos[1](position(trigger(), pop.current, props.placement));
4000
+ }
4001
+ place();
4002
+ window.addEventListener("resize", place);
4003
+ window.addEventListener("scroll", place, true);
4004
+ return function() {
4005
+ window.removeEventListener("resize", place);
4006
+ window.removeEventListener("scroll", place, true);
4007
+ };
4008
+ }, [open, mounted, props.placement]);
4009
+ React24.useEffect(function() {
4010
+ if (!open || !mounted) return;
4011
+ if (props.autoFocus !== false && pop.current) {
4012
+ var f = pop.current.querySelector("[data-autofocus]") || pop.current.querySelector(FOCUSABLE);
4013
+ (f || pop.current).focus();
4014
+ }
4015
+ function outside(e) {
4016
+ if (pop.current && pop.current.contains(e.target)) return;
4017
+ if (wrap.current && wrap.current.contains(e.target)) return;
4018
+ close(false);
4019
+ }
4020
+ document.addEventListener("pointerdown", outside, true);
4021
+ return function() {
4022
+ document.removeEventListener("pointerdown", outside, true);
4023
+ };
4024
+ }, [open, mounted]);
4025
+ var child = React24.Children.only(props.trigger);
4026
+ var panel = open && mounted ? (0, import_react_dom7.createPortal)(
4027
+ h22(
4028
+ "div",
4029
+ {
4030
+ ref: popMerged,
4031
+ id,
4032
+ role: "dialog",
4033
+ "aria-modal": false,
4034
+ "aria-label": props.title ? void 0 : props.label,
4035
+ "aria-labelledby": props.title ? id + "-title" : void 0,
4036
+ tabIndex: -1,
4037
+ className: cx("aura-popover", pos[0] && "is-" + pos[0].side, props.className),
4038
+ style: Object.assign({ top: pos[0] ? pos[0].top : -9999, left: pos[0] ? pos[0].left : -9999 }, props.width ? { width: props.width } : null),
4039
+ onKeyDown: function(e) {
4040
+ if (e.key === "Escape") {
4041
+ e.stopPropagation();
4042
+ close(true);
4043
+ } else trapTab(e, pop.current);
4044
+ }
4045
+ },
4046
+ props.title ? h22(
4047
+ "div",
4048
+ { className: "aura-popover__head" },
4049
+ h22("p", { className: "aura-popover__title", id: id + "-title" }, props.title),
4050
+ h22(IconButton, { icon: "x", label: t.close, onClick: function() {
4051
+ close(true);
4052
+ } })
4053
+ ) : null,
4054
+ h22("div", { className: "aura-popover__body" }, typeof props.children === "function" ? props.children({ close: function() {
4055
+ close(true);
4056
+ } }) : props.children)
4057
+ ),
4058
+ document.body
4059
+ ) : null;
4060
+ return h22(
4061
+ "span",
4062
+ { ref: wrap, className: "aura-popover-anchor" },
4063
+ React24.cloneElement(child, { onClick: function(e) {
4064
+ if (child.props.onClick) child.props.onClick(e);
4065
+ st[1](!open);
4066
+ }, "aria-haspopup": "dialog", "aria-expanded": open, "aria-controls": open ? id : void 0 }),
4067
+ panel
4068
+ );
4069
+ });