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