@jirawatpyk/aura-react 5.2.0 → 5.3.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 +8 -1
- package/dist/aura.bundle.js +495 -39
- package/dist/cjs/index.cjs +495 -39
- package/dist/esm/Combobox.js +3 -2
- package/dist/esm/Select.js +471 -15
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/styles.css +9 -0
- package/dist/styles.layer.css +9 -0
- package/package.json +1 -1
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,259 @@ 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
|
+
const selRef = React13.useRef(null), trigRef = React13.useRef(null), listRef = React13.useRef(null);
|
|
1272
|
+
const shown = React13.useState(function() {
|
|
1273
|
+
return initialLabel(props);
|
|
1274
|
+
});
|
|
1275
|
+
const openState = React13.useState(false), open = openState[0];
|
|
1276
|
+
const activeState = React13.useState(-1), active = activeState[0];
|
|
1277
|
+
const items2 = React13.useState([]);
|
|
1278
|
+
const pos = React13.useState(null);
|
|
1279
|
+
const typed = React13.useRef({ text: "", at: 0 });
|
|
1280
|
+
const sync = React13.useCallback(function() {
|
|
1281
|
+
const el = selRef.current;
|
|
1282
|
+
if (!el) return;
|
|
1283
|
+
const o = el.selectedIndex >= 0 ? el.options[el.selectedIndex] : null;
|
|
1284
|
+
const next = o ? { label: o.textContent || "", empty: o.value === "" } : { label: "", empty: true };
|
|
1285
|
+
shown[1](function(cur) {
|
|
1286
|
+
return cur.label === next.label && cur.empty === next.empty ? cur : next;
|
|
1287
|
+
});
|
|
1288
|
+
}, []);
|
|
1289
|
+
const hook = React13.useCallback(
|
|
1290
|
+
function(el) {
|
|
1291
|
+
selRef.current = el;
|
|
1292
|
+
if (!el || native || el.__auraHooked) return;
|
|
1293
|
+
el.__auraHooked = true;
|
|
1294
|
+
const proto = HTMLSelectElement.prototype;
|
|
1295
|
+
const pv = Object.getOwnPropertyDescriptor(proto, "value"), pi = Object.getOwnPropertyDescriptor(proto, "selectedIndex");
|
|
1296
|
+
if (pv && pv.set && pv.get)
|
|
1297
|
+
Object.defineProperty(el, "value", {
|
|
1298
|
+
configurable: true,
|
|
1299
|
+
get: function() {
|
|
1300
|
+
return pv.get.call(el);
|
|
1301
|
+
},
|
|
1302
|
+
set: function(v) {
|
|
1303
|
+
pv.set.call(el, v);
|
|
1304
|
+
sync();
|
|
1305
|
+
}
|
|
1306
|
+
});
|
|
1307
|
+
if (pi && pi.set && pi.get)
|
|
1308
|
+
Object.defineProperty(el, "selectedIndex", {
|
|
1309
|
+
configurable: true,
|
|
1310
|
+
get: function() {
|
|
1311
|
+
return pi.get.call(el);
|
|
1312
|
+
},
|
|
1313
|
+
set: function(v) {
|
|
1314
|
+
pi.set.call(el, v);
|
|
1315
|
+
sync();
|
|
1316
|
+
}
|
|
1317
|
+
});
|
|
1318
|
+
el.focus = function(o) {
|
|
1319
|
+
if (trigRef.current) trigRef.current.focus(o);
|
|
1320
|
+
else proto.focus.call(el, o);
|
|
1321
|
+
};
|
|
1322
|
+
},
|
|
1323
|
+
[native, sync]
|
|
1324
|
+
);
|
|
1325
|
+
const selMerged = useMergedRef(ref, hook);
|
|
1326
|
+
React13.useEffect(
|
|
1327
|
+
function() {
|
|
1328
|
+
const f = selRef.current && selRef.current.form;
|
|
1329
|
+
if (!f || native) return;
|
|
1330
|
+
function onReset() {
|
|
1331
|
+
setTimeout(sync, 0);
|
|
1332
|
+
}
|
|
1333
|
+
f.addEventListener("reset", onReset);
|
|
1334
|
+
return function() {
|
|
1335
|
+
f.removeEventListener("reset", onReset);
|
|
1336
|
+
};
|
|
1337
|
+
},
|
|
1338
|
+
[native, sync]
|
|
1339
|
+
);
|
|
1340
|
+
const focusedOnce = React13.useRef(false);
|
|
1341
|
+
React13.useEffect(
|
|
1342
|
+
function() {
|
|
1343
|
+
if (!live || focusedOnce.current || !trigRef.current) return;
|
|
1344
|
+
focusedOnce.current = true;
|
|
1345
|
+
if (props.autoFocus || selRef.current && document.activeElement === selRef.current) trigRef.current.focus();
|
|
1346
|
+
},
|
|
1347
|
+
[live]
|
|
1348
|
+
);
|
|
1349
|
+
useIsoLayoutEffect(function() {
|
|
1350
|
+
if (!live) return;
|
|
1351
|
+
sync();
|
|
1352
|
+
if (!open) return;
|
|
1353
|
+
const now = readItems(selRef.current), was = items2[0];
|
|
1354
|
+
const same2 = now.length === was.length && now.every(function(it, i) {
|
|
1355
|
+
const w = was[i];
|
|
1356
|
+
return w.value === it.value && w.label === it.label && w.disabled === it.disabled && w.group === it.group;
|
|
1357
|
+
});
|
|
1358
|
+
if (same2) return;
|
|
1359
|
+
items2[1](now);
|
|
1360
|
+
if (!choices(now).length) {
|
|
1361
|
+
close(false);
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1364
|
+
const hv = was[active] ? was[active].value : null;
|
|
1365
|
+
const again = now.filter(function(it) {
|
|
1366
|
+
return !it.disabled && it.value === hv;
|
|
1367
|
+
})[0];
|
|
1368
|
+
const cur = selRef.current ? selRef.current.selectedIndex : -1;
|
|
1369
|
+
activeState[1](again ? again.index : now[cur] && !now[cur].disabled ? cur : choices(now)[0].index);
|
|
1370
|
+
});
|
|
1371
|
+
function choices(list) {
|
|
1372
|
+
return list.filter(function(i) {
|
|
1373
|
+
return !i.disabled;
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
function choose(it) {
|
|
1377
|
+
const el = selRef.current;
|
|
1378
|
+
if (!el || it.disabled) return;
|
|
1379
|
+
if (el.value !== it.value) {
|
|
1380
|
+
el.value = it.value;
|
|
1381
|
+
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
1382
|
+
el.dispatchEvent(new Event("change", { bubbles: true }));
|
|
1383
|
+
}
|
|
1384
|
+
sync();
|
|
1385
|
+
close(true);
|
|
1386
|
+
}
|
|
1387
|
+
function openList(at) {
|
|
1388
|
+
if (props.disabled || trigRef.current && trigRef.current.disabled) return;
|
|
1389
|
+
const list = readItems(selRef.current);
|
|
1390
|
+
const ok = choices(list);
|
|
1391
|
+
if (!ok.length) return;
|
|
1392
|
+
items2[1](list);
|
|
1393
|
+
const cur = selRef.current ? selRef.current.selectedIndex : -1;
|
|
1394
|
+
let a = at === "first" ? ok[0].index : at === "last" ? ok[ok.length - 1].index : cur;
|
|
1395
|
+
if (typeof at === "number") a = at;
|
|
1396
|
+
if (a < 0 || !list[a] || list[a].disabled) a = ok[0].index;
|
|
1397
|
+
activeState[1](a);
|
|
1398
|
+
openState[1](true);
|
|
1399
|
+
}
|
|
1400
|
+
function close(focus) {
|
|
1401
|
+
openState[1](false);
|
|
1402
|
+
pos[1](null);
|
|
1403
|
+
if (focus && trigRef.current) trigRef.current.focus();
|
|
1404
|
+
}
|
|
1405
|
+
function step(from, dir, list) {
|
|
1406
|
+
for (let i = from + dir; i >= 0 && i < list.length; i += dir) if (!list[i].disabled) return i;
|
|
1407
|
+
return from;
|
|
1408
|
+
}
|
|
1409
|
+
function typing() {
|
|
1410
|
+
return !!typed.current.text && Date.now() - typed.current.at < 500;
|
|
1411
|
+
}
|
|
1412
|
+
function typeahead(ch, list, from) {
|
|
1413
|
+
const now = Date.now(), t = typed.current;
|
|
1414
|
+
t.text = now - t.at < 500 ? t.text + ch : ch;
|
|
1415
|
+
t.at = now;
|
|
1416
|
+
const q = t.text.toLocaleLowerCase();
|
|
1417
|
+
for (let k = 1; k <= list.length; k++) {
|
|
1418
|
+
const i = (from + (t.text.length > 1 ? 0 : 1) + k - 1 + list.length) % list.length;
|
|
1419
|
+
if (!list[i].disabled && list[i].label.toLocaleLowerCase().indexOf(q) === 0) return i;
|
|
1420
|
+
}
|
|
1421
|
+
t.text = "";
|
|
1422
|
+
return -1;
|
|
1423
|
+
}
|
|
1424
|
+
function onKeyDown(e) {
|
|
1425
|
+
const k = e.key;
|
|
1426
|
+
const printable = k.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey;
|
|
1427
|
+
const search = printable && (k !== " " || typing());
|
|
1428
|
+
if (!open) {
|
|
1429
|
+
if (search) {
|
|
1430
|
+
const list2 = readItems(selRef.current);
|
|
1431
|
+
const i = typeahead(k, list2, selRef.current ? selRef.current.selectedIndex : -1);
|
|
1432
|
+
e.preventDefault();
|
|
1433
|
+
if (i >= 0) openList(i);
|
|
1434
|
+
} else if (k === "ArrowDown" || k === "ArrowUp" || k === "Enter" || k === " ") {
|
|
1435
|
+
e.preventDefault();
|
|
1436
|
+
openList(k === "ArrowUp" && !(selRef.current && selRef.current.value) ? "last" : void 0);
|
|
1437
|
+
}
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
const list = items2[0];
|
|
1441
|
+
if (search) {
|
|
1442
|
+
e.preventDefault();
|
|
1443
|
+
const i = typeahead(k, list, active);
|
|
1444
|
+
if (i >= 0) activeState[1](i);
|
|
1445
|
+
} else if (k === "ArrowDown") {
|
|
1446
|
+
e.preventDefault();
|
|
1447
|
+
activeState[1](step(active, 1, list));
|
|
1448
|
+
} else if (k === "ArrowUp") {
|
|
1449
|
+
e.preventDefault();
|
|
1450
|
+
activeState[1](step(active, -1, list));
|
|
1451
|
+
} else if (k === "Home" || k === "PageUp") {
|
|
1452
|
+
e.preventDefault();
|
|
1453
|
+
activeState[1](k === "Home" ? step(-1, 1, list) : Math.max(step(-1, 1, list), step(active - 9, 1, list)));
|
|
1454
|
+
} else if (k === "End" || k === "PageDown") {
|
|
1455
|
+
e.preventDefault();
|
|
1456
|
+
activeState[1](
|
|
1457
|
+
k === "End" ? step(list.length, -1, list) : Math.min(step(list.length, -1, list), step(active + 9, -1, list))
|
|
1458
|
+
);
|
|
1459
|
+
} else if (k === "Enter" || k === " ") {
|
|
1460
|
+
e.preventDefault();
|
|
1461
|
+
if (list[active]) choose(list[active]);
|
|
1462
|
+
} else if (k === "Escape") {
|
|
1463
|
+
e.preventDefault();
|
|
1464
|
+
e.stopPropagation();
|
|
1465
|
+
close(true);
|
|
1466
|
+
} else if (k === "Tab") {
|
|
1467
|
+
close(false);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
useIsoLayoutEffect(
|
|
1471
|
+
function() {
|
|
1472
|
+
if (!open) return;
|
|
1473
|
+
function place() {
|
|
1474
|
+
const t = trigRef.current && trigRef.current.parentElement;
|
|
1475
|
+
if (!t) return;
|
|
1476
|
+
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;
|
|
1477
|
+
pos[1]({
|
|
1478
|
+
left: r.left,
|
|
1479
|
+
width: r.width,
|
|
1480
|
+
top: up ? void 0 : r.bottom + 4,
|
|
1481
|
+
bottom: up ? window.innerHeight - r.top + 4 : void 0,
|
|
1482
|
+
maxHeight: Math.min(320, (up ? above : below2) - 4)
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
place();
|
|
1486
|
+
function outside(e) {
|
|
1487
|
+
const n2 = e.target;
|
|
1488
|
+
if (listRef.current && listRef.current.contains(n2)) return;
|
|
1489
|
+
if (trigRef.current && trigRef.current.contains(n2)) return;
|
|
1490
|
+
close(false);
|
|
1491
|
+
}
|
|
1492
|
+
function onScroll(e) {
|
|
1493
|
+
if (!listRef.current || !listRef.current.contains(e.target)) place();
|
|
1494
|
+
}
|
|
1495
|
+
document.addEventListener("pointerdown", outside, true);
|
|
1496
|
+
window.addEventListener("scroll", onScroll, true);
|
|
1497
|
+
window.addEventListener("resize", place);
|
|
1498
|
+
return function() {
|
|
1499
|
+
document.removeEventListener("pointerdown", outside, true);
|
|
1500
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
1501
|
+
window.removeEventListener("resize", place);
|
|
1502
|
+
};
|
|
1503
|
+
},
|
|
1504
|
+
[open]
|
|
1505
|
+
);
|
|
1506
|
+
React13.useEffect(
|
|
1507
|
+
function() {
|
|
1508
|
+
if (!open || !listRef.current || active < 0) return;
|
|
1509
|
+
const el = listRef.current.querySelector('[data-idx="' + active + '"]');
|
|
1510
|
+
if (el && el.scrollIntoView) el.scrollIntoView({ block: "nearest" });
|
|
1511
|
+
},
|
|
1512
|
+
[open, active, pos[0] != null]
|
|
1513
|
+
);
|
|
1514
|
+
const described = [describedBy(id, props), rest["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
1515
|
+
const field = (child) => /* @__PURE__ */ React13.createElement(
|
|
1223
1516
|
Field,
|
|
1224
1517
|
{
|
|
1225
1518
|
id,
|
|
1519
|
+
labelId: native ? void 0 : id + "-label",
|
|
1226
1520
|
label: props.label,
|
|
1227
1521
|
hint: props.hint,
|
|
1228
1522
|
error: props.error,
|
|
@@ -1231,19 +1525,180 @@ var Select = React13.forwardRef(function Select2(props, ref) {
|
|
|
1231
1525
|
disabled: props.disabled,
|
|
1232
1526
|
className: props.className
|
|
1233
1527
|
},
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1528
|
+
child
|
|
1529
|
+
);
|
|
1530
|
+
if (!live)
|
|
1531
|
+
return field(
|
|
1532
|
+
/* @__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(
|
|
1533
|
+
"select",
|
|
1534
|
+
Object.assign(extra, rest, {
|
|
1535
|
+
ref: native ? ref : selMerged,
|
|
1536
|
+
id,
|
|
1537
|
+
className: "aura-input__control",
|
|
1538
|
+
required: props.required,
|
|
1539
|
+
"aria-invalid": props.error ? true : void 0,
|
|
1540
|
+
"aria-describedby": described
|
|
1541
|
+
}),
|
|
1542
|
+
opts,
|
|
1543
|
+
props.children
|
|
1544
|
+
), /* @__PURE__ */ React13.createElement(Icon, { name: "chevron-down", className: "aura-select__chevron" }))
|
|
1545
|
+
);
|
|
1546
|
+
const listId = id + "-list", labelId = id + "-label";
|
|
1547
|
+
const optId = function(i) {
|
|
1548
|
+
return id + "-opt-" + i;
|
|
1549
|
+
};
|
|
1550
|
+
const labelledBy = rest["aria-labelledby"] || (props.label ? labelId : void 0);
|
|
1551
|
+
const selIndex = selRef.current ? selRef.current.selectedIndex : -1;
|
|
1552
|
+
const option = function(it) {
|
|
1553
|
+
const sel = selIndex === it.index;
|
|
1554
|
+
return /* @__PURE__ */ React13.createElement(
|
|
1555
|
+
"div",
|
|
1556
|
+
{
|
|
1557
|
+
key: it.index,
|
|
1558
|
+
id: optId(it.index),
|
|
1559
|
+
role: "option",
|
|
1560
|
+
"data-idx": it.index,
|
|
1561
|
+
"aria-selected": sel,
|
|
1562
|
+
"aria-disabled": it.disabled || void 0,
|
|
1563
|
+
className: cx(
|
|
1564
|
+
"aura-combo__option",
|
|
1565
|
+
it.index === active && "is-active",
|
|
1566
|
+
sel && "is-selected",
|
|
1567
|
+
it.disabled && "is-disabled"
|
|
1568
|
+
),
|
|
1569
|
+
onPointerDown: function(e) {
|
|
1570
|
+
e.preventDefault();
|
|
1571
|
+
},
|
|
1572
|
+
onPointerMove: function() {
|
|
1573
|
+
if (!it.disabled && active !== it.index) activeState[1](it.index);
|
|
1574
|
+
},
|
|
1575
|
+
onClick: function() {
|
|
1576
|
+
choose(it);
|
|
1577
|
+
}
|
|
1578
|
+
},
|
|
1579
|
+
/* @__PURE__ */ React13.createElement("span", { className: "aura-combo__text" }, /* @__PURE__ */ React13.createElement("span", { className: "aura-combo__label" }, it.label)),
|
|
1580
|
+
sel ? /* @__PURE__ */ React13.createElement(Icon, { name: "check", className: "aura-combo__check" }) : null
|
|
1581
|
+
);
|
|
1582
|
+
};
|
|
1583
|
+
const runs = [];
|
|
1584
|
+
items2[0].forEach(function(it) {
|
|
1585
|
+
if (it.value === "" && it.disabled) return;
|
|
1586
|
+
const last = runs[runs.length - 1];
|
|
1587
|
+
if (last && last.group === it.group) last.items.push(it);
|
|
1588
|
+
else runs.push({ group: it.group, items: [it] });
|
|
1589
|
+
});
|
|
1590
|
+
const popup = open ? (0, import_react_dom2.createPortal)(
|
|
1591
|
+
/* @__PURE__ */ React13.createElement(
|
|
1592
|
+
"div",
|
|
1593
|
+
{
|
|
1594
|
+
ref: listRef,
|
|
1595
|
+
"data-density": density,
|
|
1596
|
+
className: "aura-combo__popover aura-select__popover",
|
|
1597
|
+
style: pos[0] ? {
|
|
1598
|
+
left: pos[0].left,
|
|
1599
|
+
minWidth: pos[0].width,
|
|
1600
|
+
top: pos[0].top,
|
|
1601
|
+
bottom: pos[0].bottom,
|
|
1602
|
+
maxHeight: pos[0].maxHeight
|
|
1603
|
+
} : { left: -9999, top: -9999 }
|
|
1604
|
+
},
|
|
1605
|
+
/* @__PURE__ */ React13.createElement(
|
|
1606
|
+
"div",
|
|
1607
|
+
{
|
|
1608
|
+
id: listId,
|
|
1609
|
+
role: "listbox",
|
|
1610
|
+
"aria-labelledby": labelledBy,
|
|
1611
|
+
"aria-label": labelledBy ? void 0 : rest["aria-label"],
|
|
1612
|
+
className: "aura-combo__list"
|
|
1613
|
+
},
|
|
1614
|
+
runs.map(function(r, n2) {
|
|
1615
|
+
if (r.group === null) return /* @__PURE__ */ React13.createElement(React13.Fragment, { key: "r" + n2 }, r.items.map(option));
|
|
1616
|
+
const gid = id + "-group-" + n2;
|
|
1617
|
+
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));
|
|
1618
|
+
})
|
|
1619
|
+
)
|
|
1620
|
+
),
|
|
1621
|
+
document.body
|
|
1622
|
+
) : null;
|
|
1623
|
+
const userFocus = rest.onFocus, userBlur = rest.onBlur, userKey = rest.onKeyDown, userClick = rest.onClick;
|
|
1624
|
+
return field(
|
|
1625
|
+
/* @__PURE__ */ React13.createElement(
|
|
1626
|
+
"div",
|
|
1627
|
+
{
|
|
1628
|
+
className: cx("aura-input aura-select aura-select--custom", props.icon && "has-icon", open && "is-open"),
|
|
1629
|
+
"data-invalid": props.error ? "" : void 0
|
|
1630
|
+
},
|
|
1631
|
+
props.icon ? /* @__PURE__ */ React13.createElement(Icon, { name: props.icon, className: "aura-input__icon" }) : null,
|
|
1632
|
+
h3(
|
|
1633
|
+
"select",
|
|
1634
|
+
Object.assign(extra, pick(rest, FORM_KEYS), {
|
|
1635
|
+
ref: selMerged,
|
|
1636
|
+
id: id + "-select",
|
|
1637
|
+
className: "aura-select__native",
|
|
1638
|
+
tabIndex: -1,
|
|
1639
|
+
"aria-hidden": true,
|
|
1640
|
+
required: props.required,
|
|
1641
|
+
onChange: function(e) {
|
|
1642
|
+
sync();
|
|
1643
|
+
if (props.onChange) props.onChange(e);
|
|
1644
|
+
},
|
|
1645
|
+
/* A browser focusing the <select> (the required bubble, a label click) hands focus to the button. */
|
|
1646
|
+
onFocus: function() {
|
|
1647
|
+
if (trigRef.current) trigRef.current.focus();
|
|
1648
|
+
},
|
|
1649
|
+
/* Only the blur the button reports (below): the <select>'s own, while it hands focus over, is not one. */
|
|
1650
|
+
onBlur: function(e) {
|
|
1651
|
+
if (!e.nativeEvent.isTrusted && userBlur) userBlur(e);
|
|
1652
|
+
}
|
|
1653
|
+
}),
|
|
1654
|
+
opts,
|
|
1655
|
+
props.children
|
|
1656
|
+
),
|
|
1657
|
+
/* @__PURE__ */ React13.createElement(
|
|
1658
|
+
"button",
|
|
1659
|
+
{
|
|
1660
|
+
...omit(rest, HANDLED_KEYS),
|
|
1661
|
+
ref: trigRef,
|
|
1662
|
+
type: "button",
|
|
1663
|
+
role: "combobox",
|
|
1664
|
+
form: id + "-no-form",
|
|
1665
|
+
className: "aura-input__control aura-select__trigger",
|
|
1666
|
+
disabled: props.disabled,
|
|
1667
|
+
tabIndex: rest.tabIndex,
|
|
1668
|
+
"aria-haspopup": "listbox",
|
|
1669
|
+
"aria-expanded": open,
|
|
1670
|
+
"aria-controls": open ? listId : void 0,
|
|
1671
|
+
"aria-activedescendant": open && active >= 0 ? optId(active) : void 0,
|
|
1672
|
+
id,
|
|
1673
|
+
"aria-label": rest["aria-label"],
|
|
1674
|
+
"aria-labelledby": rest["aria-labelledby"],
|
|
1675
|
+
"aria-required": props.required || void 0,
|
|
1676
|
+
"aria-invalid": props.error ? true : void 0,
|
|
1677
|
+
"aria-describedby": described,
|
|
1678
|
+
onFocus: function(e) {
|
|
1679
|
+
if (userFocus) userFocus(e);
|
|
1680
|
+
},
|
|
1681
|
+
onClick: function(e) {
|
|
1682
|
+
if (userClick) userClick(e);
|
|
1683
|
+
if (e.defaultPrevented) return;
|
|
1684
|
+
if (open) close(true);
|
|
1685
|
+
else openList();
|
|
1686
|
+
},
|
|
1687
|
+
onKeyDown: function(e) {
|
|
1688
|
+
if (userKey) userKey(e);
|
|
1689
|
+
if (!e.defaultPrevented) onKeyDown(e);
|
|
1690
|
+
},
|
|
1691
|
+
onBlur: function(e) {
|
|
1692
|
+
if (listRef.current && e.relatedTarget && listRef.current.contains(e.relatedTarget)) return;
|
|
1693
|
+
if (open) close(false);
|
|
1694
|
+
if (selRef.current) selRef.current.dispatchEvent(new FocusEvent("focusout", { bubbles: true }));
|
|
1695
|
+
}
|
|
1696
|
+
},
|
|
1697
|
+
/* @__PURE__ */ React13.createElement("span", { id: id + "-value", className: cx("aura-select__value", shown[0].empty && "is-placeholder") }, shown[0].label || " ")
|
|
1698
|
+
),
|
|
1699
|
+
/* @__PURE__ */ React13.createElement(Icon, { name: "chevron-down", className: "aura-select__chevron" }),
|
|
1700
|
+
popup
|
|
1701
|
+
)
|
|
1247
1702
|
);
|
|
1248
1703
|
});
|
|
1249
1704
|
|
|
@@ -1342,7 +1797,7 @@ var Switch = React15.forwardRef(function Switch2(props, ref) {
|
|
|
1342
1797
|
|
|
1343
1798
|
// src/Combobox.tsx
|
|
1344
1799
|
var React16 = __toESM(require("react"), 1);
|
|
1345
|
-
var
|
|
1800
|
+
var import_react_dom3 = require("react-dom");
|
|
1346
1801
|
function norm(s) {
|
|
1347
1802
|
return String(s == null ? "" : s).normalize("NFC").toLocaleLowerCase("th");
|
|
1348
1803
|
}
|
|
@@ -1362,6 +1817,7 @@ var Combobox = React16.forwardRef(
|
|
|
1362
1817
|
const multi = all.multiple === true;
|
|
1363
1818
|
const mp = all;
|
|
1364
1819
|
const t = useStrings();
|
|
1820
|
+
const density = useDensity();
|
|
1365
1821
|
const auto = uid(), id = props.id || auto, listId = id + "-list";
|
|
1366
1822
|
const options = (props.options || []).map(toOpt);
|
|
1367
1823
|
const st = useMaybeControlled(
|
|
@@ -1524,8 +1980,8 @@ var Combobox = React16.forwardRef(
|
|
|
1524
1980
|
const optId = function(i) {
|
|
1525
1981
|
return id + "-opt-" + i;
|
|
1526
1982
|
};
|
|
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(
|
|
1983
|
+
const list = open && mounted && posState[0] ? (0, import_react_dom3.createPortal)(
|
|
1984
|
+
/* @__PURE__ */ React16.createElement("div", { ref: listRef, "data-density": density, className: "aura-combo__popover", style: posState[0] }, live.length ? /* @__PURE__ */ React16.createElement(
|
|
1529
1985
|
"ul",
|
|
1530
1986
|
{
|
|
1531
1987
|
id: listId,
|
|
@@ -1685,7 +2141,7 @@ var Combobox = React16.forwardRef(
|
|
|
1685
2141
|
|
|
1686
2142
|
// src/DatePicker.tsx
|
|
1687
2143
|
var React17 = __toESM(require("react"), 1);
|
|
1688
|
-
var
|
|
2144
|
+
var import_react_dom4 = require("react-dom");
|
|
1689
2145
|
|
|
1690
2146
|
// src/dates.ts
|
|
1691
2147
|
var ERA = /^พ\.ศ\.\s?|\s?(BE|พ\.ศ\.)$/g;
|
|
@@ -2290,7 +2746,7 @@ var DatePicker = React17.forwardRef(function DatePicker2(props, ref) {
|
|
|
2290
2746
|
pop.setOpen(false);
|
|
2291
2747
|
if (inputRef.current) inputRef.current.focus();
|
|
2292
2748
|
}
|
|
2293
|
-
const cal = pop.open && pop.mounted && pop.pos ? (0,
|
|
2749
|
+
const cal = pop.open && pop.mounted && pop.pos ? (0, import_react_dom4.createPortal)(
|
|
2294
2750
|
/* @__PURE__ */ React17.createElement(
|
|
2295
2751
|
"div",
|
|
2296
2752
|
{
|
|
@@ -2415,7 +2871,7 @@ var DateRangePicker = React17.forwardRef(
|
|
|
2415
2871
|
draft[1](null);
|
|
2416
2872
|
if (inputRef.current) inputRef.current.focus();
|
|
2417
2873
|
}
|
|
2418
|
-
function
|
|
2874
|
+
function pick2(iso) {
|
|
2419
2875
|
if (!draft[0]) {
|
|
2420
2876
|
draft[1](iso);
|
|
2421
2877
|
return;
|
|
@@ -2425,7 +2881,7 @@ var DateRangePicker = React17.forwardRef(
|
|
|
2425
2881
|
st[1](a <= b ? { start: a, end: b } : { start: b, end: a });
|
|
2426
2882
|
close();
|
|
2427
2883
|
}
|
|
2428
|
-
const cal = pop.open && pop.mounted && pop.pos ? (0,
|
|
2884
|
+
const cal = pop.open && pop.mounted && pop.pos ? (0, import_react_dom4.createPortal)(
|
|
2429
2885
|
/* @__PURE__ */ React17.createElement(
|
|
2430
2886
|
"div",
|
|
2431
2887
|
{
|
|
@@ -2459,7 +2915,7 @@ var DateRangePicker = React17.forwardRef(
|
|
|
2459
2915
|
start: draft[0] || v.start,
|
|
2460
2916
|
end: draft[0] ? null : v.end,
|
|
2461
2917
|
focus: draft[0] || v.start,
|
|
2462
|
-
onSelect:
|
|
2918
|
+
onSelect: pick2
|
|
2463
2919
|
}
|
|
2464
2920
|
)
|
|
2465
2921
|
),
|
|
@@ -2529,7 +2985,7 @@ var Alert = React18.forwardRef(function Alert2(props, ref) {
|
|
|
2529
2985
|
|
|
2530
2986
|
// src/Toaster.tsx
|
|
2531
2987
|
var React19 = __toESM(require("react"), 1);
|
|
2532
|
-
var
|
|
2988
|
+
var import_react_dom5 = require("react-dom");
|
|
2533
2989
|
var MAX_VISIBLE = 3;
|
|
2534
2990
|
var toastState = {
|
|
2535
2991
|
list: [],
|
|
@@ -2690,7 +3146,7 @@ function Toaster(props) {
|
|
|
2690
3146
|
};
|
|
2691
3147
|
}, []);
|
|
2692
3148
|
if (!mounted) return null;
|
|
2693
|
-
return (0,
|
|
3149
|
+
return (0, import_react_dom5.createPortal)(
|
|
2694
3150
|
/* @__PURE__ */ React19.createElement(
|
|
2695
3151
|
"div",
|
|
2696
3152
|
{
|
|
@@ -2971,7 +3427,7 @@ var FilterBar = React23.forwardRef(function FilterBar2(props, ref) {
|
|
|
2971
3427
|
|
|
2972
3428
|
// src/Command.tsx
|
|
2973
3429
|
var React25 = __toESM(require("react"), 1);
|
|
2974
|
-
var
|
|
3430
|
+
var import_react_dom6 = require("react-dom");
|
|
2975
3431
|
|
|
2976
3432
|
// src/useModal.tsx
|
|
2977
3433
|
var React24 = __toESM(require("react"), 1);
|
|
@@ -3175,7 +3631,7 @@ function Command(props) {
|
|
|
3175
3631
|
}
|
|
3176
3632
|
if (!modal.ready) return null;
|
|
3177
3633
|
let i = -1;
|
|
3178
|
-
return (0,
|
|
3634
|
+
return (0, import_react_dom6.createPortal)(
|
|
3179
3635
|
/* @__PURE__ */ React25.createElement(
|
|
3180
3636
|
"div",
|
|
3181
3637
|
{
|
|
@@ -3284,7 +3740,7 @@ function Command(props) {
|
|
|
3284
3740
|
|
|
3285
3741
|
// src/Tooltip.tsx
|
|
3286
3742
|
var React26 = __toESM(require("react"), 1);
|
|
3287
|
-
var
|
|
3743
|
+
var import_react_dom7 = require("react-dom");
|
|
3288
3744
|
var Tooltip = React26.forwardRef(function Tooltip2(props, ref) {
|
|
3289
3745
|
const id = uid(), st = React26.useState(false), open = props.open !== void 0 ? props.open : st[0], set = st[1];
|
|
3290
3746
|
const anchor = React26.useRef(null), anchorMerged = useMergedRef(ref, anchor), tip = React26.useRef(null), timer = React26.useRef(void 0);
|
|
@@ -3382,7 +3838,7 @@ var Tooltip = React26.forwardRef(function Tooltip2(props, ref) {
|
|
|
3382
3838
|
},
|
|
3383
3839
|
React26.cloneElement(child, { "aria-describedby": open ? id : child.props["aria-describedby"] })
|
|
3384
3840
|
);
|
|
3385
|
-
return /* @__PURE__ */ React26.createElement(React26.Fragment, null, trigger, open && mounted ? (0,
|
|
3841
|
+
return /* @__PURE__ */ React26.createElement(React26.Fragment, null, trigger, open && mounted ? (0, import_react_dom7.createPortal)(
|
|
3386
3842
|
/* @__PURE__ */ React26.createElement(
|
|
3387
3843
|
"div",
|
|
3388
3844
|
{
|
|
@@ -3404,7 +3860,7 @@ var Tooltip = React26.forwardRef(function Tooltip2(props, ref) {
|
|
|
3404
3860
|
|
|
3405
3861
|
// src/Dialog.tsx
|
|
3406
3862
|
var React27 = __toESM(require("react"), 1);
|
|
3407
|
-
var
|
|
3863
|
+
var import_react_dom8 = require("react-dom");
|
|
3408
3864
|
var Dialog = React27.forwardRef(function Dialog2(props, ref) {
|
|
3409
3865
|
const t = useStrings();
|
|
3410
3866
|
const density = useDensity();
|
|
@@ -3419,7 +3875,7 @@ var Dialog = React27.forwardRef(function Dialog2(props, ref) {
|
|
|
3419
3875
|
footSelector: ".aura-dialog__foot"
|
|
3420
3876
|
});
|
|
3421
3877
|
if (!modal.ready) return null;
|
|
3422
|
-
return (0,
|
|
3878
|
+
return (0, import_react_dom8.createPortal)(
|
|
3423
3879
|
/* @__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
3880
|
"div",
|
|
3425
3881
|
{
|
|
@@ -3454,7 +3910,7 @@ var Drawer = React27.forwardRef(function Drawer2(props, ref) {
|
|
|
3454
3910
|
});
|
|
3455
3911
|
if (!modal.ready) return null;
|
|
3456
3912
|
const side = props.side === "left" ? "left" : "right";
|
|
3457
|
-
return (0,
|
|
3913
|
+
return (0, import_react_dom8.createPortal)(
|
|
3458
3914
|
/* @__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
3915
|
"div",
|
|
3460
3916
|
{
|
|
@@ -3478,7 +3934,7 @@ var Drawer = React27.forwardRef(function Drawer2(props, ref) {
|
|
|
3478
3934
|
|
|
3479
3935
|
// src/DataTable.tsx
|
|
3480
3936
|
var React28 = __toESM(require("react"), 1);
|
|
3481
|
-
var
|
|
3937
|
+
var import_react_dom9 = require("react-dom");
|
|
3482
3938
|
var BP = { sm: 640, md: 768, lg: 1024, xl: 1280 };
|
|
3483
3939
|
var DEFAULT_COLUMNS = [
|
|
3484
3940
|
{ key: "id", label: "ID", width: 96, mono: true },
|
|
@@ -3635,7 +4091,7 @@ var DataTable = React28.forwardRef(function DataTable2(props, ref) {
|
|
|
3635
4091
|
function hideFull() {
|
|
3636
4092
|
setTip(null);
|
|
3637
4093
|
}
|
|
3638
|
-
const tipEl = tip && typeof document !== "undefined" ? (0,
|
|
4094
|
+
const tipEl = tip && typeof document !== "undefined" ? (0, import_react_dom9.createPortal)(
|
|
3639
4095
|
/* @__PURE__ */ React28.createElement(
|
|
3640
4096
|
"div",
|
|
3641
4097
|
{
|
|
@@ -4885,7 +5341,7 @@ var Tabs = React30.forwardRef(function Tabs2(props, ref) {
|
|
|
4885
5341
|
|
|
4886
5342
|
// src/SideNav.tsx
|
|
4887
5343
|
var React31 = __toESM(require("react"), 1);
|
|
4888
|
-
var
|
|
5344
|
+
var import_react_dom10 = require("react-dom");
|
|
4889
5345
|
function contains(it, id) {
|
|
4890
5346
|
return !!id && !!it.children && it.children.some(function(c) {
|
|
4891
5347
|
return c.id === id || contains(c, id);
|
|
@@ -5078,7 +5534,7 @@ var SideNav = React31.forwardRef(function SideNav2(props, ref) {
|
|
|
5078
5534
|
}
|
|
5079
5535
|
}
|
|
5080
5536
|
)) : null,
|
|
5081
|
-
tip && typeof document !== "undefined" ? (0,
|
|
5537
|
+
tip && typeof document !== "undefined" ? (0, import_react_dom10.createPortal)(
|
|
5082
5538
|
/* @__PURE__ */ React31.createElement(
|
|
5083
5539
|
"div",
|
|
5084
5540
|
{
|
|
@@ -5522,7 +5978,7 @@ var Stat = React44.forwardRef(function Stat2(props, ref) {
|
|
|
5522
5978
|
|
|
5523
5979
|
// src/TimePicker.tsx
|
|
5524
5980
|
var React45 = __toESM(require("react"), 1);
|
|
5525
|
-
var
|
|
5981
|
+
var import_react_dom11 = require("react-dom");
|
|
5526
5982
|
|
|
5527
5983
|
// src/text.ts
|
|
5528
5984
|
function formatBytes(n2) {
|
|
@@ -5738,7 +6194,7 @@ var TimePicker = React45.forwardRef(function TimePicker2(props, ref) {
|
|
|
5738
6194
|
}
|
|
5739
6195
|
}
|
|
5740
6196
|
const error = errState[0] || props.error;
|
|
5741
|
-
const list = open && mounted && pos[0] ? (0,
|
|
6197
|
+
const list = open && mounted && pos[0] ? (0, import_react_dom11.createPortal)(
|
|
5742
6198
|
/* @__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
6199
|
const dis = blocked(s), sel = s === value;
|
|
5744
6200
|
return /* @__PURE__ */ React45.createElement(
|
|
@@ -6729,7 +7185,7 @@ var Accordion = React54.forwardRef(function Accordion2(props, ref) {
|
|
|
6729
7185
|
|
|
6730
7186
|
// src/Popover.tsx
|
|
6731
7187
|
var React55 = __toESM(require("react"), 1);
|
|
6732
|
-
var
|
|
7188
|
+
var import_react_dom12 = require("react-dom");
|
|
6733
7189
|
function position(anchor, pop, placement) {
|
|
6734
7190
|
const r = anchor.getBoundingClientRect(), pw = pop.offsetWidth, ph = pop.scrollHeight, vw = window.innerWidth, vh = window.innerHeight, gap = 6;
|
|
6735
7191
|
let side = (placement || "bottom-start").split("-")[0], align = (placement || "bottom-start").split("-")[1] || "start";
|
|
@@ -6807,7 +7263,7 @@ var Popover = React55.forwardRef(function Popover2(props, ref) {
|
|
|
6807
7263
|
[open, mounted]
|
|
6808
7264
|
);
|
|
6809
7265
|
const child = React55.Children.only(props.trigger);
|
|
6810
|
-
const panel = open && mounted ? (0,
|
|
7266
|
+
const panel = open && mounted ? (0, import_react_dom12.createPortal)(
|
|
6811
7267
|
/* @__PURE__ */ React55.createElement(
|
|
6812
7268
|
"div",
|
|
6813
7269
|
{
|