@jirawatpyk/aura-react 5.2.0 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -4
- package/dist/aura.bundle.js +503 -39
- package/dist/cjs/index.cjs +503 -39
- package/dist/esm/Combobox.js +3 -2
- package/dist/esm/Select.js +479 -15
- package/dist/index.d.cts +29 -12
- package/dist/index.d.ts +29 -12
- package/dist/styles.css +9 -0
- package/dist/styles.layer.css +9 -0
- package/package.json +14 -14
- package/scripts/aura-theme.mjs +20 -8
package/dist/cjs/index.cjs
CHANGED
|
@@ -1206,7 +1206,52 @@ var Textarea = React12.forwardRef(function Textarea2(props, ref) {
|
|
|
1206
1206
|
|
|
1207
1207
|
// src/Select.tsx
|
|
1208
1208
|
var React13 = __toESM(require("react"), 1);
|
|
1209
|
+
var import_react_dom2 = require("react-dom");
|
|
1209
1210
|
var h3 = React13.createElement;
|
|
1211
|
+
var FORM_KEYS = ["name", "form", "value", "defaultValue", "disabled", "autoComplete", "onInput", "onInvalid"];
|
|
1212
|
+
var HANDLED_KEYS = FORM_KEYS.concat([
|
|
1213
|
+
"onChange",
|
|
1214
|
+
"onBlur",
|
|
1215
|
+
"onFocus",
|
|
1216
|
+
"onKeyDown",
|
|
1217
|
+
"onClick",
|
|
1218
|
+
"autoFocus",
|
|
1219
|
+
"tabIndex",
|
|
1220
|
+
"aria-label",
|
|
1221
|
+
"aria-labelledby",
|
|
1222
|
+
"aria-describedby",
|
|
1223
|
+
"multiple",
|
|
1224
|
+
"size"
|
|
1225
|
+
]);
|
|
1226
|
+
function pick(o, keys) {
|
|
1227
|
+
const r = {};
|
|
1228
|
+
for (const k of keys) if (k in o) r[k] = o[k];
|
|
1229
|
+
return r;
|
|
1230
|
+
}
|
|
1231
|
+
function readItems(el) {
|
|
1232
|
+
if (!el) return [];
|
|
1233
|
+
return Array.prototype.map.call(el.options, function(o, i) {
|
|
1234
|
+
const g = o.parentElement && o.parentElement.tagName === "OPTGROUP" ? o.parentElement : null;
|
|
1235
|
+
return {
|
|
1236
|
+
value: o.value,
|
|
1237
|
+
label: o.textContent || "",
|
|
1238
|
+
disabled: o.disabled || !!(g && g.disabled),
|
|
1239
|
+
group: g ? g.label : null,
|
|
1240
|
+
index: i
|
|
1241
|
+
};
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
function initialLabel(props) {
|
|
1245
|
+
const opts = (props.options || []).map(function(o) {
|
|
1246
|
+
return typeof o === "object" ? o : { value: o, label: o };
|
|
1247
|
+
});
|
|
1248
|
+
const v = props.value !== void 0 && props.value !== null ? String(props.value) : props.defaultValue !== void 0 && props.defaultValue !== null ? String(props.defaultValue) : props.placeholder ? "" : opts[0] ? opts[0].value : "";
|
|
1249
|
+
const hit = opts.filter(function(o) {
|
|
1250
|
+
return o.value === v;
|
|
1251
|
+
})[0];
|
|
1252
|
+
if (hit) return { label: hit.label, empty: false };
|
|
1253
|
+
return { label: props.placeholder || "", empty: true };
|
|
1254
|
+
}
|
|
1210
1255
|
var Select = React13.forwardRef(function Select2(props, ref) {
|
|
1211
1256
|
const auto = uid(), id = props.id || auto;
|
|
1212
1257
|
const rest = omit(props, FIELD_KEYS.concat(["children"]));
|
|
@@ -1219,10 +1264,267 @@ var Select = React13.forwardRef(function Select2(props, ref) {
|
|
|
1219
1264
|
/* @__PURE__ */ React13.createElement("option", { key: "__ph", value: "", disabled: true }, props.placeholder)
|
|
1220
1265
|
);
|
|
1221
1266
|
const extra = props.value === void 0 && props.defaultValue === void 0 && props.placeholder ? { defaultValue: "" } : {};
|
|
1222
|
-
|
|
1267
|
+
const native = !!props.multiple || props.size != null && props.size > 1;
|
|
1268
|
+
const mounted = useMounted();
|
|
1269
|
+
const live = !native && mounted;
|
|
1270
|
+
const density = useDensity();
|
|
1271
|
+
React13.useEffect(function() {
|
|
1272
|
+
if (props.label || props["aria-label"] || props["aria-labelledby"] || props.title) return;
|
|
1273
|
+
if (document.querySelector('label[for="' + id.replace(/["\\]/g, "\\$&") + '"]')) return;
|
|
1274
|
+
devWarnOnce(
|
|
1275
|
+
"select-name",
|
|
1276
|
+
"Select needs a label, aria-label or aria-labelledby: screen readers announce it with no name."
|
|
1277
|
+
);
|
|
1278
|
+
}, []);
|
|
1279
|
+
const selRef = React13.useRef(null), trigRef = React13.useRef(null), listRef = React13.useRef(null);
|
|
1280
|
+
const shown = React13.useState(function() {
|
|
1281
|
+
return initialLabel(props);
|
|
1282
|
+
});
|
|
1283
|
+
const openState = React13.useState(false), open = openState[0];
|
|
1284
|
+
const activeState = React13.useState(-1), active = activeState[0];
|
|
1285
|
+
const items2 = React13.useState([]);
|
|
1286
|
+
const pos = React13.useState(null);
|
|
1287
|
+
const typed = React13.useRef({ text: "", at: 0 });
|
|
1288
|
+
const sync = React13.useCallback(function() {
|
|
1289
|
+
const el = selRef.current;
|
|
1290
|
+
if (!el) return;
|
|
1291
|
+
const o = el.selectedIndex >= 0 ? el.options[el.selectedIndex] : null;
|
|
1292
|
+
const next = o ? { label: o.textContent || "", empty: o.value === "" } : { label: "", empty: true };
|
|
1293
|
+
shown[1](function(cur) {
|
|
1294
|
+
return cur.label === next.label && cur.empty === next.empty ? cur : next;
|
|
1295
|
+
});
|
|
1296
|
+
}, []);
|
|
1297
|
+
const hook = React13.useCallback(
|
|
1298
|
+
function(el) {
|
|
1299
|
+
selRef.current = el;
|
|
1300
|
+
if (!el || native || el.__auraHooked) return;
|
|
1301
|
+
el.__auraHooked = true;
|
|
1302
|
+
const proto = HTMLSelectElement.prototype;
|
|
1303
|
+
const pv = Object.getOwnPropertyDescriptor(proto, "value"), pi = Object.getOwnPropertyDescriptor(proto, "selectedIndex");
|
|
1304
|
+
if (pv && pv.set && pv.get)
|
|
1305
|
+
Object.defineProperty(el, "value", {
|
|
1306
|
+
configurable: true,
|
|
1307
|
+
get: function() {
|
|
1308
|
+
return pv.get.call(el);
|
|
1309
|
+
},
|
|
1310
|
+
set: function(v) {
|
|
1311
|
+
pv.set.call(el, v);
|
|
1312
|
+
sync();
|
|
1313
|
+
}
|
|
1314
|
+
});
|
|
1315
|
+
if (pi && pi.set && pi.get)
|
|
1316
|
+
Object.defineProperty(el, "selectedIndex", {
|
|
1317
|
+
configurable: true,
|
|
1318
|
+
get: function() {
|
|
1319
|
+
return pi.get.call(el);
|
|
1320
|
+
},
|
|
1321
|
+
set: function(v) {
|
|
1322
|
+
pi.set.call(el, v);
|
|
1323
|
+
sync();
|
|
1324
|
+
}
|
|
1325
|
+
});
|
|
1326
|
+
el.focus = function(o) {
|
|
1327
|
+
if (trigRef.current) trigRef.current.focus(o);
|
|
1328
|
+
else proto.focus.call(el, o);
|
|
1329
|
+
};
|
|
1330
|
+
},
|
|
1331
|
+
[native, sync]
|
|
1332
|
+
);
|
|
1333
|
+
const selMerged = useMergedRef(ref, hook);
|
|
1334
|
+
React13.useEffect(
|
|
1335
|
+
function() {
|
|
1336
|
+
const f = selRef.current && selRef.current.form;
|
|
1337
|
+
if (!f || native) return;
|
|
1338
|
+
function onReset() {
|
|
1339
|
+
setTimeout(sync, 0);
|
|
1340
|
+
}
|
|
1341
|
+
f.addEventListener("reset", onReset);
|
|
1342
|
+
return function() {
|
|
1343
|
+
f.removeEventListener("reset", onReset);
|
|
1344
|
+
};
|
|
1345
|
+
},
|
|
1346
|
+
[native, sync]
|
|
1347
|
+
);
|
|
1348
|
+
const focusedOnce = React13.useRef(false);
|
|
1349
|
+
React13.useEffect(
|
|
1350
|
+
function() {
|
|
1351
|
+
if (!live || focusedOnce.current || !trigRef.current) return;
|
|
1352
|
+
focusedOnce.current = true;
|
|
1353
|
+
if (props.autoFocus || selRef.current && document.activeElement === selRef.current) trigRef.current.focus();
|
|
1354
|
+
},
|
|
1355
|
+
[live]
|
|
1356
|
+
);
|
|
1357
|
+
useIsoLayoutEffect(function() {
|
|
1358
|
+
if (!live) return;
|
|
1359
|
+
sync();
|
|
1360
|
+
if (!open) return;
|
|
1361
|
+
const now = readItems(selRef.current), was = items2[0];
|
|
1362
|
+
const same2 = now.length === was.length && now.every(function(it, i) {
|
|
1363
|
+
const w = was[i];
|
|
1364
|
+
return w.value === it.value && w.label === it.label && w.disabled === it.disabled && w.group === it.group;
|
|
1365
|
+
});
|
|
1366
|
+
if (same2) return;
|
|
1367
|
+
items2[1](now);
|
|
1368
|
+
if (!choices(now).length) {
|
|
1369
|
+
close(false);
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
const hv = was[active] ? was[active].value : null;
|
|
1373
|
+
const again = now.filter(function(it) {
|
|
1374
|
+
return !it.disabled && it.value === hv;
|
|
1375
|
+
})[0];
|
|
1376
|
+
const cur = selRef.current ? selRef.current.selectedIndex : -1;
|
|
1377
|
+
activeState[1](again ? again.index : now[cur] && !now[cur].disabled ? cur : choices(now)[0].index);
|
|
1378
|
+
});
|
|
1379
|
+
function choices(list) {
|
|
1380
|
+
return list.filter(function(i) {
|
|
1381
|
+
return !i.disabled;
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
function choose(it) {
|
|
1385
|
+
const el = selRef.current;
|
|
1386
|
+
if (!el || it.disabled) return;
|
|
1387
|
+
if (el.value !== it.value) {
|
|
1388
|
+
el.value = it.value;
|
|
1389
|
+
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
1390
|
+
el.dispatchEvent(new Event("change", { bubbles: true }));
|
|
1391
|
+
}
|
|
1392
|
+
sync();
|
|
1393
|
+
close(true);
|
|
1394
|
+
}
|
|
1395
|
+
function openList(at) {
|
|
1396
|
+
if (props.disabled || trigRef.current && trigRef.current.disabled) return;
|
|
1397
|
+
const list = readItems(selRef.current);
|
|
1398
|
+
const ok = choices(list);
|
|
1399
|
+
if (!ok.length) return;
|
|
1400
|
+
items2[1](list);
|
|
1401
|
+
const cur = selRef.current ? selRef.current.selectedIndex : -1;
|
|
1402
|
+
let a = at === "first" ? ok[0].index : at === "last" ? ok[ok.length - 1].index : cur;
|
|
1403
|
+
if (typeof at === "number") a = at;
|
|
1404
|
+
if (a < 0 || !list[a] || list[a].disabled) a = ok[0].index;
|
|
1405
|
+
activeState[1](a);
|
|
1406
|
+
openState[1](true);
|
|
1407
|
+
}
|
|
1408
|
+
function close(focus) {
|
|
1409
|
+
openState[1](false);
|
|
1410
|
+
pos[1](null);
|
|
1411
|
+
if (focus && trigRef.current) trigRef.current.focus();
|
|
1412
|
+
}
|
|
1413
|
+
function step(from, dir, list) {
|
|
1414
|
+
for (let i = from + dir; i >= 0 && i < list.length; i += dir) if (!list[i].disabled) return i;
|
|
1415
|
+
return from;
|
|
1416
|
+
}
|
|
1417
|
+
function typing() {
|
|
1418
|
+
return !!typed.current.text && Date.now() - typed.current.at < 500;
|
|
1419
|
+
}
|
|
1420
|
+
function typeahead(ch, list, from) {
|
|
1421
|
+
const now = Date.now(), t = typed.current;
|
|
1422
|
+
t.text = now - t.at < 500 ? t.text + ch : ch;
|
|
1423
|
+
t.at = now;
|
|
1424
|
+
const q = t.text.toLocaleLowerCase();
|
|
1425
|
+
for (let k = 1; k <= list.length; k++) {
|
|
1426
|
+
const i = (from + (t.text.length > 1 ? 0 : 1) + k - 1 + list.length) % list.length;
|
|
1427
|
+
if (!list[i].disabled && list[i].label.toLocaleLowerCase().indexOf(q) === 0) return i;
|
|
1428
|
+
}
|
|
1429
|
+
t.text = "";
|
|
1430
|
+
return -1;
|
|
1431
|
+
}
|
|
1432
|
+
function onKeyDown(e) {
|
|
1433
|
+
const k = e.key;
|
|
1434
|
+
const printable = k.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey;
|
|
1435
|
+
const search = printable && (k !== " " || typing());
|
|
1436
|
+
if (!open) {
|
|
1437
|
+
if (search) {
|
|
1438
|
+
const list2 = readItems(selRef.current);
|
|
1439
|
+
const i = typeahead(k, list2, selRef.current ? selRef.current.selectedIndex : -1);
|
|
1440
|
+
e.preventDefault();
|
|
1441
|
+
if (i >= 0) openList(i);
|
|
1442
|
+
} else if (k === "ArrowDown" || k === "ArrowUp" || k === "Enter" || k === " ") {
|
|
1443
|
+
e.preventDefault();
|
|
1444
|
+
openList(k === "ArrowUp" && !(selRef.current && selRef.current.value) ? "last" : void 0);
|
|
1445
|
+
}
|
|
1446
|
+
return;
|
|
1447
|
+
}
|
|
1448
|
+
const list = items2[0];
|
|
1449
|
+
if (search) {
|
|
1450
|
+
e.preventDefault();
|
|
1451
|
+
const i = typeahead(k, list, active);
|
|
1452
|
+
if (i >= 0) activeState[1](i);
|
|
1453
|
+
} else if (k === "ArrowDown") {
|
|
1454
|
+
e.preventDefault();
|
|
1455
|
+
activeState[1](step(active, 1, list));
|
|
1456
|
+
} else if (k === "ArrowUp") {
|
|
1457
|
+
e.preventDefault();
|
|
1458
|
+
activeState[1](step(active, -1, list));
|
|
1459
|
+
} else if (k === "Home" || k === "PageUp") {
|
|
1460
|
+
e.preventDefault();
|
|
1461
|
+
activeState[1](k === "Home" ? step(-1, 1, list) : Math.max(step(-1, 1, list), step(active - 9, 1, list)));
|
|
1462
|
+
} else if (k === "End" || k === "PageDown") {
|
|
1463
|
+
e.preventDefault();
|
|
1464
|
+
activeState[1](
|
|
1465
|
+
k === "End" ? step(list.length, -1, list) : Math.min(step(list.length, -1, list), step(active + 9, -1, list))
|
|
1466
|
+
);
|
|
1467
|
+
} else if (k === "Enter" || k === " ") {
|
|
1468
|
+
e.preventDefault();
|
|
1469
|
+
if (list[active]) choose(list[active]);
|
|
1470
|
+
} else if (k === "Escape") {
|
|
1471
|
+
e.preventDefault();
|
|
1472
|
+
e.stopPropagation();
|
|
1473
|
+
close(true);
|
|
1474
|
+
} else if (k === "Tab") {
|
|
1475
|
+
close(false);
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
useIsoLayoutEffect(
|
|
1479
|
+
function() {
|
|
1480
|
+
if (!open) return;
|
|
1481
|
+
function place() {
|
|
1482
|
+
const t = trigRef.current && trigRef.current.parentElement;
|
|
1483
|
+
if (!t) return;
|
|
1484
|
+
const r = t.getBoundingClientRect(), below2 = window.innerHeight - r.bottom - 8, above = r.top - 8, want = listRef.current ? listRef.current.scrollHeight : 320, up = below2 < Math.min(want, 200) && above > below2;
|
|
1485
|
+
pos[1]({
|
|
1486
|
+
left: r.left,
|
|
1487
|
+
width: r.width,
|
|
1488
|
+
top: up ? void 0 : r.bottom + 4,
|
|
1489
|
+
bottom: up ? window.innerHeight - r.top + 4 : void 0,
|
|
1490
|
+
maxHeight: Math.min(320, (up ? above : below2) - 4)
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
place();
|
|
1494
|
+
function outside(e) {
|
|
1495
|
+
const n2 = e.target;
|
|
1496
|
+
if (listRef.current && listRef.current.contains(n2)) return;
|
|
1497
|
+
if (trigRef.current && trigRef.current.contains(n2)) return;
|
|
1498
|
+
close(false);
|
|
1499
|
+
}
|
|
1500
|
+
function onScroll(e) {
|
|
1501
|
+
if (!listRef.current || !listRef.current.contains(e.target)) place();
|
|
1502
|
+
}
|
|
1503
|
+
document.addEventListener("pointerdown", outside, true);
|
|
1504
|
+
window.addEventListener("scroll", onScroll, true);
|
|
1505
|
+
window.addEventListener("resize", place);
|
|
1506
|
+
return function() {
|
|
1507
|
+
document.removeEventListener("pointerdown", outside, true);
|
|
1508
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
1509
|
+
window.removeEventListener("resize", place);
|
|
1510
|
+
};
|
|
1511
|
+
},
|
|
1512
|
+
[open]
|
|
1513
|
+
);
|
|
1514
|
+
React13.useEffect(
|
|
1515
|
+
function() {
|
|
1516
|
+
if (!open || !listRef.current || active < 0) return;
|
|
1517
|
+
const el = listRef.current.querySelector('[data-idx="' + active + '"]');
|
|
1518
|
+
if (el && el.scrollIntoView) el.scrollIntoView({ block: "nearest" });
|
|
1519
|
+
},
|
|
1520
|
+
[open, active, pos[0] != null]
|
|
1521
|
+
);
|
|
1522
|
+
const described = [describedBy(id, props), rest["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
1523
|
+
const field = (child) => /* @__PURE__ */ React13.createElement(
|
|
1223
1524
|
Field,
|
|
1224
1525
|
{
|
|
1225
1526
|
id,
|
|
1527
|
+
labelId: native ? void 0 : id + "-label",
|
|
1226
1528
|
label: props.label,
|
|
1227
1529
|
hint: props.hint,
|
|
1228
1530
|
error: props.error,
|
|
@@ -1231,19 +1533,180 @@ var Select = React13.forwardRef(function Select2(props, ref) {
|
|
|
1231
1533
|
disabled: props.disabled,
|
|
1232
1534
|
className: props.className
|
|
1233
1535
|
},
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1536
|
+
child
|
|
1537
|
+
);
|
|
1538
|
+
if (!live)
|
|
1539
|
+
return field(
|
|
1540
|
+
/* @__PURE__ */ React13.createElement("div", { className: cx("aura-input aura-select", props.icon && "has-icon") }, props.icon ? /* @__PURE__ */ React13.createElement(Icon, { name: props.icon, className: "aura-input__icon" }) : null, h3(
|
|
1541
|
+
"select",
|
|
1542
|
+
Object.assign(extra, rest, {
|
|
1543
|
+
ref: native ? ref : selMerged,
|
|
1544
|
+
id,
|
|
1545
|
+
className: "aura-input__control",
|
|
1546
|
+
required: props.required,
|
|
1547
|
+
"aria-invalid": props.error ? true : void 0,
|
|
1548
|
+
"aria-describedby": described
|
|
1549
|
+
}),
|
|
1550
|
+
opts,
|
|
1551
|
+
props.children
|
|
1552
|
+
), /* @__PURE__ */ React13.createElement(Icon, { name: "chevron-down", className: "aura-select__chevron" }))
|
|
1553
|
+
);
|
|
1554
|
+
const listId = id + "-list", labelId = id + "-label";
|
|
1555
|
+
const optId = function(i) {
|
|
1556
|
+
return id + "-opt-" + i;
|
|
1557
|
+
};
|
|
1558
|
+
const labelledBy = rest["aria-labelledby"] || (props.label ? labelId : void 0);
|
|
1559
|
+
const selIndex = selRef.current ? selRef.current.selectedIndex : -1;
|
|
1560
|
+
const option = function(it) {
|
|
1561
|
+
const sel = selIndex === it.index;
|
|
1562
|
+
return /* @__PURE__ */ React13.createElement(
|
|
1563
|
+
"div",
|
|
1564
|
+
{
|
|
1565
|
+
key: it.index,
|
|
1566
|
+
id: optId(it.index),
|
|
1567
|
+
role: "option",
|
|
1568
|
+
"data-idx": it.index,
|
|
1569
|
+
"aria-selected": sel,
|
|
1570
|
+
"aria-disabled": it.disabled || void 0,
|
|
1571
|
+
className: cx(
|
|
1572
|
+
"aura-combo__option",
|
|
1573
|
+
it.index === active && "is-active",
|
|
1574
|
+
sel && "is-selected",
|
|
1575
|
+
it.disabled && "is-disabled"
|
|
1576
|
+
),
|
|
1577
|
+
onPointerDown: function(e) {
|
|
1578
|
+
e.preventDefault();
|
|
1579
|
+
},
|
|
1580
|
+
onPointerMove: function() {
|
|
1581
|
+
if (!it.disabled && active !== it.index) activeState[1](it.index);
|
|
1582
|
+
},
|
|
1583
|
+
onClick: function() {
|
|
1584
|
+
choose(it);
|
|
1585
|
+
}
|
|
1586
|
+
},
|
|
1587
|
+
/* @__PURE__ */ React13.createElement("span", { className: "aura-combo__text" }, /* @__PURE__ */ React13.createElement("span", { className: "aura-combo__label" }, it.label)),
|
|
1588
|
+
sel ? /* @__PURE__ */ React13.createElement(Icon, { name: "check", className: "aura-combo__check" }) : null
|
|
1589
|
+
);
|
|
1590
|
+
};
|
|
1591
|
+
const runs = [];
|
|
1592
|
+
items2[0].forEach(function(it) {
|
|
1593
|
+
if (it.value === "" && it.disabled) return;
|
|
1594
|
+
const last = runs[runs.length - 1];
|
|
1595
|
+
if (last && last.group === it.group) last.items.push(it);
|
|
1596
|
+
else runs.push({ group: it.group, items: [it] });
|
|
1597
|
+
});
|
|
1598
|
+
const popup = open ? (0, import_react_dom2.createPortal)(
|
|
1599
|
+
/* @__PURE__ */ React13.createElement(
|
|
1600
|
+
"div",
|
|
1601
|
+
{
|
|
1602
|
+
ref: listRef,
|
|
1603
|
+
"data-density": density,
|
|
1604
|
+
className: "aura-combo__popover aura-select__popover",
|
|
1605
|
+
style: pos[0] ? {
|
|
1606
|
+
left: pos[0].left,
|
|
1607
|
+
minWidth: pos[0].width,
|
|
1608
|
+
top: pos[0].top,
|
|
1609
|
+
bottom: pos[0].bottom,
|
|
1610
|
+
maxHeight: pos[0].maxHeight
|
|
1611
|
+
} : { left: -9999, top: -9999 }
|
|
1612
|
+
},
|
|
1613
|
+
/* @__PURE__ */ React13.createElement(
|
|
1614
|
+
"div",
|
|
1615
|
+
{
|
|
1616
|
+
id: listId,
|
|
1617
|
+
role: "listbox",
|
|
1618
|
+
"aria-labelledby": labelledBy,
|
|
1619
|
+
"aria-label": labelledBy ? void 0 : rest["aria-label"],
|
|
1620
|
+
className: "aura-combo__list"
|
|
1621
|
+
},
|
|
1622
|
+
runs.map(function(r, n2) {
|
|
1623
|
+
if (r.group === null) return /* @__PURE__ */ React13.createElement(React13.Fragment, { key: "r" + n2 }, r.items.map(option));
|
|
1624
|
+
const gid = id + "-group-" + n2;
|
|
1625
|
+
return /* @__PURE__ */ React13.createElement("div", { key: "r" + n2, role: "group", "aria-labelledby": gid }, /* @__PURE__ */ React13.createElement("div", { id: gid, className: "aura-select__group" }, r.group), r.items.map(option));
|
|
1626
|
+
})
|
|
1627
|
+
)
|
|
1628
|
+
),
|
|
1629
|
+
document.body
|
|
1630
|
+
) : null;
|
|
1631
|
+
const userFocus = rest.onFocus, userBlur = rest.onBlur, userKey = rest.onKeyDown, userClick = rest.onClick;
|
|
1632
|
+
return field(
|
|
1633
|
+
/* @__PURE__ */ React13.createElement(
|
|
1634
|
+
"div",
|
|
1635
|
+
{
|
|
1636
|
+
className: cx("aura-input aura-select aura-select--custom", props.icon && "has-icon", open && "is-open"),
|
|
1637
|
+
"data-invalid": props.error ? "" : void 0
|
|
1638
|
+
},
|
|
1639
|
+
props.icon ? /* @__PURE__ */ React13.createElement(Icon, { name: props.icon, className: "aura-input__icon" }) : null,
|
|
1640
|
+
h3(
|
|
1641
|
+
"select",
|
|
1642
|
+
Object.assign(extra, pick(rest, FORM_KEYS), {
|
|
1643
|
+
ref: selMerged,
|
|
1644
|
+
id: id + "-select",
|
|
1645
|
+
className: "aura-select__native",
|
|
1646
|
+
tabIndex: -1,
|
|
1647
|
+
"aria-hidden": true,
|
|
1648
|
+
required: props.required,
|
|
1649
|
+
onChange: function(e) {
|
|
1650
|
+
sync();
|
|
1651
|
+
if (props.onChange) props.onChange(e);
|
|
1652
|
+
},
|
|
1653
|
+
/* A browser focusing the <select> (the required bubble, a label click) hands focus to the button. */
|
|
1654
|
+
onFocus: function() {
|
|
1655
|
+
if (trigRef.current) trigRef.current.focus();
|
|
1656
|
+
},
|
|
1657
|
+
/* Only the blur the button reports (below): the <select>'s own, while it hands focus over, is not one. */
|
|
1658
|
+
onBlur: function(e) {
|
|
1659
|
+
if (!e.nativeEvent.isTrusted && userBlur) userBlur(e);
|
|
1660
|
+
}
|
|
1661
|
+
}),
|
|
1662
|
+
opts,
|
|
1663
|
+
props.children
|
|
1664
|
+
),
|
|
1665
|
+
/* @__PURE__ */ React13.createElement(
|
|
1666
|
+
"button",
|
|
1667
|
+
{
|
|
1668
|
+
...omit(rest, HANDLED_KEYS),
|
|
1669
|
+
ref: trigRef,
|
|
1670
|
+
type: "button",
|
|
1671
|
+
role: "combobox",
|
|
1672
|
+
form: id + "-no-form",
|
|
1673
|
+
className: "aura-input__control aura-select__trigger",
|
|
1674
|
+
disabled: props.disabled,
|
|
1675
|
+
tabIndex: rest.tabIndex,
|
|
1676
|
+
"aria-haspopup": "listbox",
|
|
1677
|
+
"aria-expanded": open,
|
|
1678
|
+
"aria-controls": open ? listId : void 0,
|
|
1679
|
+
"aria-activedescendant": open && active >= 0 ? optId(active) : void 0,
|
|
1680
|
+
id,
|
|
1681
|
+
"aria-label": rest["aria-label"],
|
|
1682
|
+
"aria-labelledby": rest["aria-labelledby"],
|
|
1683
|
+
"aria-required": props.required || void 0,
|
|
1684
|
+
"aria-invalid": props.error ? true : void 0,
|
|
1685
|
+
"aria-describedby": described,
|
|
1686
|
+
onFocus: function(e) {
|
|
1687
|
+
if (userFocus) userFocus(e);
|
|
1688
|
+
},
|
|
1689
|
+
onClick: function(e) {
|
|
1690
|
+
if (userClick) userClick(e);
|
|
1691
|
+
if (e.defaultPrevented) return;
|
|
1692
|
+
if (open) close(true);
|
|
1693
|
+
else openList();
|
|
1694
|
+
},
|
|
1695
|
+
onKeyDown: function(e) {
|
|
1696
|
+
if (userKey) userKey(e);
|
|
1697
|
+
if (!e.defaultPrevented) onKeyDown(e);
|
|
1698
|
+
},
|
|
1699
|
+
onBlur: function(e) {
|
|
1700
|
+
if (listRef.current && e.relatedTarget && listRef.current.contains(e.relatedTarget)) return;
|
|
1701
|
+
if (open) close(false);
|
|
1702
|
+
if (selRef.current) selRef.current.dispatchEvent(new FocusEvent("focusout", { bubbles: true }));
|
|
1703
|
+
}
|
|
1704
|
+
},
|
|
1705
|
+
/* @__PURE__ */ React13.createElement("span", { id: id + "-value", className: cx("aura-select__value", shown[0].empty && "is-placeholder") }, shown[0].label || " ")
|
|
1706
|
+
),
|
|
1707
|
+
/* @__PURE__ */ React13.createElement(Icon, { name: "chevron-down", className: "aura-select__chevron" }),
|
|
1708
|
+
popup
|
|
1709
|
+
)
|
|
1247
1710
|
);
|
|
1248
1711
|
});
|
|
1249
1712
|
|
|
@@ -1342,7 +1805,7 @@ var Switch = React15.forwardRef(function Switch2(props, ref) {
|
|
|
1342
1805
|
|
|
1343
1806
|
// src/Combobox.tsx
|
|
1344
1807
|
var React16 = __toESM(require("react"), 1);
|
|
1345
|
-
var
|
|
1808
|
+
var import_react_dom3 = require("react-dom");
|
|
1346
1809
|
function norm(s) {
|
|
1347
1810
|
return String(s == null ? "" : s).normalize("NFC").toLocaleLowerCase("th");
|
|
1348
1811
|
}
|
|
@@ -1362,6 +1825,7 @@ var Combobox = React16.forwardRef(
|
|
|
1362
1825
|
const multi = all.multiple === true;
|
|
1363
1826
|
const mp = all;
|
|
1364
1827
|
const t = useStrings();
|
|
1828
|
+
const density = useDensity();
|
|
1365
1829
|
const auto = uid(), id = props.id || auto, listId = id + "-list";
|
|
1366
1830
|
const options = (props.options || []).map(toOpt);
|
|
1367
1831
|
const st = useMaybeControlled(
|
|
@@ -1524,8 +1988,8 @@ var Combobox = React16.forwardRef(
|
|
|
1524
1988
|
const optId = function(i) {
|
|
1525
1989
|
return id + "-opt-" + i;
|
|
1526
1990
|
};
|
|
1527
|
-
const list = open && mounted && posState[0] ? (0,
|
|
1528
|
-
/* @__PURE__ */ React16.createElement("div", { ref: listRef, className: "aura-combo__popover", style: posState[0] }, live.length ? /* @__PURE__ */ React16.createElement(
|
|
1991
|
+
const list = open && mounted && posState[0] ? (0, import_react_dom3.createPortal)(
|
|
1992
|
+
/* @__PURE__ */ React16.createElement("div", { ref: listRef, "data-density": density, className: "aura-combo__popover", style: posState[0] }, live.length ? /* @__PURE__ */ React16.createElement(
|
|
1529
1993
|
"ul",
|
|
1530
1994
|
{
|
|
1531
1995
|
id: listId,
|
|
@@ -1685,7 +2149,7 @@ var Combobox = React16.forwardRef(
|
|
|
1685
2149
|
|
|
1686
2150
|
// src/DatePicker.tsx
|
|
1687
2151
|
var React17 = __toESM(require("react"), 1);
|
|
1688
|
-
var
|
|
2152
|
+
var import_react_dom4 = require("react-dom");
|
|
1689
2153
|
|
|
1690
2154
|
// src/dates.ts
|
|
1691
2155
|
var ERA = /^พ\.ศ\.\s?|\s?(BE|พ\.ศ\.)$/g;
|
|
@@ -2290,7 +2754,7 @@ var DatePicker = React17.forwardRef(function DatePicker2(props, ref) {
|
|
|
2290
2754
|
pop.setOpen(false);
|
|
2291
2755
|
if (inputRef.current) inputRef.current.focus();
|
|
2292
2756
|
}
|
|
2293
|
-
const cal = pop.open && pop.mounted && pop.pos ? (0,
|
|
2757
|
+
const cal = pop.open && pop.mounted && pop.pos ? (0, import_react_dom4.createPortal)(
|
|
2294
2758
|
/* @__PURE__ */ React17.createElement(
|
|
2295
2759
|
"div",
|
|
2296
2760
|
{
|
|
@@ -2415,7 +2879,7 @@ var DateRangePicker = React17.forwardRef(
|
|
|
2415
2879
|
draft[1](null);
|
|
2416
2880
|
if (inputRef.current) inputRef.current.focus();
|
|
2417
2881
|
}
|
|
2418
|
-
function
|
|
2882
|
+
function pick2(iso) {
|
|
2419
2883
|
if (!draft[0]) {
|
|
2420
2884
|
draft[1](iso);
|
|
2421
2885
|
return;
|
|
@@ -2425,7 +2889,7 @@ var DateRangePicker = React17.forwardRef(
|
|
|
2425
2889
|
st[1](a <= b ? { start: a, end: b } : { start: b, end: a });
|
|
2426
2890
|
close();
|
|
2427
2891
|
}
|
|
2428
|
-
const cal = pop.open && pop.mounted && pop.pos ? (0,
|
|
2892
|
+
const cal = pop.open && pop.mounted && pop.pos ? (0, import_react_dom4.createPortal)(
|
|
2429
2893
|
/* @__PURE__ */ React17.createElement(
|
|
2430
2894
|
"div",
|
|
2431
2895
|
{
|
|
@@ -2459,7 +2923,7 @@ var DateRangePicker = React17.forwardRef(
|
|
|
2459
2923
|
start: draft[0] || v.start,
|
|
2460
2924
|
end: draft[0] ? null : v.end,
|
|
2461
2925
|
focus: draft[0] || v.start,
|
|
2462
|
-
onSelect:
|
|
2926
|
+
onSelect: pick2
|
|
2463
2927
|
}
|
|
2464
2928
|
)
|
|
2465
2929
|
),
|
|
@@ -2529,7 +2993,7 @@ var Alert = React18.forwardRef(function Alert2(props, ref) {
|
|
|
2529
2993
|
|
|
2530
2994
|
// src/Toaster.tsx
|
|
2531
2995
|
var React19 = __toESM(require("react"), 1);
|
|
2532
|
-
var
|
|
2996
|
+
var import_react_dom5 = require("react-dom");
|
|
2533
2997
|
var MAX_VISIBLE = 3;
|
|
2534
2998
|
var toastState = {
|
|
2535
2999
|
list: [],
|
|
@@ -2690,7 +3154,7 @@ function Toaster(props) {
|
|
|
2690
3154
|
};
|
|
2691
3155
|
}, []);
|
|
2692
3156
|
if (!mounted) return null;
|
|
2693
|
-
return (0,
|
|
3157
|
+
return (0, import_react_dom5.createPortal)(
|
|
2694
3158
|
/* @__PURE__ */ React19.createElement(
|
|
2695
3159
|
"div",
|
|
2696
3160
|
{
|
|
@@ -2971,7 +3435,7 @@ var FilterBar = React23.forwardRef(function FilterBar2(props, ref) {
|
|
|
2971
3435
|
|
|
2972
3436
|
// src/Command.tsx
|
|
2973
3437
|
var React25 = __toESM(require("react"), 1);
|
|
2974
|
-
var
|
|
3438
|
+
var import_react_dom6 = require("react-dom");
|
|
2975
3439
|
|
|
2976
3440
|
// src/useModal.tsx
|
|
2977
3441
|
var React24 = __toESM(require("react"), 1);
|
|
@@ -3175,7 +3639,7 @@ function Command(props) {
|
|
|
3175
3639
|
}
|
|
3176
3640
|
if (!modal.ready) return null;
|
|
3177
3641
|
let i = -1;
|
|
3178
|
-
return (0,
|
|
3642
|
+
return (0, import_react_dom6.createPortal)(
|
|
3179
3643
|
/* @__PURE__ */ React25.createElement(
|
|
3180
3644
|
"div",
|
|
3181
3645
|
{
|
|
@@ -3284,7 +3748,7 @@ function Command(props) {
|
|
|
3284
3748
|
|
|
3285
3749
|
// src/Tooltip.tsx
|
|
3286
3750
|
var React26 = __toESM(require("react"), 1);
|
|
3287
|
-
var
|
|
3751
|
+
var import_react_dom7 = require("react-dom");
|
|
3288
3752
|
var Tooltip = React26.forwardRef(function Tooltip2(props, ref) {
|
|
3289
3753
|
const id = uid(), st = React26.useState(false), open = props.open !== void 0 ? props.open : st[0], set = st[1];
|
|
3290
3754
|
const anchor = React26.useRef(null), anchorMerged = useMergedRef(ref, anchor), tip = React26.useRef(null), timer = React26.useRef(void 0);
|
|
@@ -3382,7 +3846,7 @@ var Tooltip = React26.forwardRef(function Tooltip2(props, ref) {
|
|
|
3382
3846
|
},
|
|
3383
3847
|
React26.cloneElement(child, { "aria-describedby": open ? id : child.props["aria-describedby"] })
|
|
3384
3848
|
);
|
|
3385
|
-
return /* @__PURE__ */ React26.createElement(React26.Fragment, null, trigger, open && mounted ? (0,
|
|
3849
|
+
return /* @__PURE__ */ React26.createElement(React26.Fragment, null, trigger, open && mounted ? (0, import_react_dom7.createPortal)(
|
|
3386
3850
|
/* @__PURE__ */ React26.createElement(
|
|
3387
3851
|
"div",
|
|
3388
3852
|
{
|
|
@@ -3404,7 +3868,7 @@ var Tooltip = React26.forwardRef(function Tooltip2(props, ref) {
|
|
|
3404
3868
|
|
|
3405
3869
|
// src/Dialog.tsx
|
|
3406
3870
|
var React27 = __toESM(require("react"), 1);
|
|
3407
|
-
var
|
|
3871
|
+
var import_react_dom8 = require("react-dom");
|
|
3408
3872
|
var Dialog = React27.forwardRef(function Dialog2(props, ref) {
|
|
3409
3873
|
const t = useStrings();
|
|
3410
3874
|
const density = useDensity();
|
|
@@ -3419,7 +3883,7 @@ var Dialog = React27.forwardRef(function Dialog2(props, ref) {
|
|
|
3419
3883
|
footSelector: ".aura-dialog__foot"
|
|
3420
3884
|
});
|
|
3421
3885
|
if (!modal.ready) return null;
|
|
3422
|
-
return (0,
|
|
3886
|
+
return (0, import_react_dom8.createPortal)(
|
|
3423
3887
|
/* @__PURE__ */ React27.createElement("div", { className: "aura-dialog-layer", "data-density": density, onKeyDown: modal.onKeyDown }, /* @__PURE__ */ React27.createElement("div", { className: "aura-scrim", onClick: close, "aria-hidden": true }), /* @__PURE__ */ React27.createElement(
|
|
3424
3888
|
"div",
|
|
3425
3889
|
{
|
|
@@ -3454,7 +3918,7 @@ var Drawer = React27.forwardRef(function Drawer2(props, ref) {
|
|
|
3454
3918
|
});
|
|
3455
3919
|
if (!modal.ready) return null;
|
|
3456
3920
|
const side = props.side === "left" ? "left" : "right";
|
|
3457
|
-
return (0,
|
|
3921
|
+
return (0, import_react_dom8.createPortal)(
|
|
3458
3922
|
/* @__PURE__ */ React27.createElement("div", { className: "aura-dialog-layer aura-drawer-layer", "data-density": density, onKeyDown: modal.onKeyDown }, /* @__PURE__ */ React27.createElement("div", { className: "aura-scrim", onClick: close, "aria-hidden": true }), /* @__PURE__ */ React27.createElement(
|
|
3459
3923
|
"div",
|
|
3460
3924
|
{
|
|
@@ -3478,7 +3942,7 @@ var Drawer = React27.forwardRef(function Drawer2(props, ref) {
|
|
|
3478
3942
|
|
|
3479
3943
|
// src/DataTable.tsx
|
|
3480
3944
|
var React28 = __toESM(require("react"), 1);
|
|
3481
|
-
var
|
|
3945
|
+
var import_react_dom9 = require("react-dom");
|
|
3482
3946
|
var BP = { sm: 640, md: 768, lg: 1024, xl: 1280 };
|
|
3483
3947
|
var DEFAULT_COLUMNS = [
|
|
3484
3948
|
{ key: "id", label: "ID", width: 96, mono: true },
|
|
@@ -3635,7 +4099,7 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
|
|
|
3635
4099
|
function hideFull() {
|
|
3636
4100
|
setTip(null);
|
|
3637
4101
|
}
|
|
3638
|
-
const tipEl = tip && typeof document !== "undefined" ? (0,
|
|
4102
|
+
const tipEl = tip && typeof document !== "undefined" ? (0, import_react_dom9.createPortal)(
|
|
3639
4103
|
/* @__PURE__ */ React28.createElement(
|
|
3640
4104
|
"div",
|
|
3641
4105
|
{
|
|
@@ -4885,7 +5349,7 @@ var Tabs = React30.forwardRef(function Tabs2(props, ref) {
|
|
|
4885
5349
|
|
|
4886
5350
|
// src/SideNav.tsx
|
|
4887
5351
|
var React31 = __toESM(require("react"), 1);
|
|
4888
|
-
var
|
|
5352
|
+
var import_react_dom10 = require("react-dom");
|
|
4889
5353
|
function contains(it, id) {
|
|
4890
5354
|
return !!id && !!it.children && it.children.some(function(c) {
|
|
4891
5355
|
return c.id === id || contains(c, id);
|
|
@@ -5078,7 +5542,7 @@ var SideNav = React31.forwardRef(function SideNav2(props, ref) {
|
|
|
5078
5542
|
}
|
|
5079
5543
|
}
|
|
5080
5544
|
)) : null,
|
|
5081
|
-
tip && typeof document !== "undefined" ? (0,
|
|
5545
|
+
tip && typeof document !== "undefined" ? (0, import_react_dom10.createPortal)(
|
|
5082
5546
|
/* @__PURE__ */ React31.createElement(
|
|
5083
5547
|
"div",
|
|
5084
5548
|
{
|
|
@@ -5522,7 +5986,7 @@ var Stat = React44.forwardRef(function Stat2(props, ref) {
|
|
|
5522
5986
|
|
|
5523
5987
|
// src/TimePicker.tsx
|
|
5524
5988
|
var React45 = __toESM(require("react"), 1);
|
|
5525
|
-
var
|
|
5989
|
+
var import_react_dom11 = require("react-dom");
|
|
5526
5990
|
|
|
5527
5991
|
// src/text.ts
|
|
5528
5992
|
function formatBytes(n2) {
|
|
@@ -5738,7 +6202,7 @@ var TimePicker = React45.forwardRef(function TimePicker2(props, ref) {
|
|
|
5738
6202
|
}
|
|
5739
6203
|
}
|
|
5740
6204
|
const error = errState[0] || props.error;
|
|
5741
|
-
const list = open && mounted && pos[0] ? (0,
|
|
6205
|
+
const list = open && mounted && pos[0] ? (0, import_react_dom11.createPortal)(
|
|
5742
6206
|
/* @__PURE__ */ React45.createElement("div", { ref: listRef, className: "aura-combo__popover aura-time__popover", style: pos[0] }, /* @__PURE__ */ React45.createElement("ul", { id: listId, role: "listbox", "aria-label": props.label, className: "aura-combo__list" }, slots.map(function(s, i) {
|
|
5743
6207
|
const dis = blocked(s), sel = s === value;
|
|
5744
6208
|
return /* @__PURE__ */ React45.createElement(
|
|
@@ -6729,7 +7193,7 @@ var Accordion = React54.forwardRef(function Accordion2(props, ref) {
|
|
|
6729
7193
|
|
|
6730
7194
|
// src/Popover.tsx
|
|
6731
7195
|
var React55 = __toESM(require("react"), 1);
|
|
6732
|
-
var
|
|
7196
|
+
var import_react_dom12 = require("react-dom");
|
|
6733
7197
|
function position(anchor, pop, placement) {
|
|
6734
7198
|
const r = anchor.getBoundingClientRect(), pw = pop.offsetWidth, ph = pop.scrollHeight, vw = window.innerWidth, vh = window.innerHeight, gap = 6;
|
|
6735
7199
|
let side = (placement || "bottom-start").split("-")[0], align = (placement || "bottom-start").split("-")[1] || "start";
|
|
@@ -6807,7 +7271,7 @@ var Popover = React55.forwardRef(function Popover2(props, ref) {
|
|
|
6807
7271
|
[open, mounted]
|
|
6808
7272
|
);
|
|
6809
7273
|
const child = React55.Children.only(props.trigger);
|
|
6810
|
-
const panel = open && mounted ? (0,
|
|
7274
|
+
const panel = open && mounted ? (0, import_react_dom12.createPortal)(
|
|
6811
7275
|
/* @__PURE__ */ React55.createElement(
|
|
6812
7276
|
"div",
|
|
6813
7277
|
{
|