@ukiahinsure/a2ui-react-adapter 0.1.22 → 0.1.24
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/dist/index.js +111 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -55,6 +55,69 @@ var HospitalChoice = createComponentImplementation(ChoicePickerApi, ({ props, co
|
|
|
55
55
|
import { useId as useId2, useLayoutEffect, useRef, useState } from "react";
|
|
56
56
|
import { createComponentImplementation as createComponentImplementation2 } from "@a2ui/react/v0_9";
|
|
57
57
|
import { DateTimeInputApi } from "@a2ui/web_core/v0_9/basic_catalog";
|
|
58
|
+
|
|
59
|
+
// src/fieldLabel.ts
|
|
60
|
+
var ACRONYMS = {
|
|
61
|
+
aep: "AEP",
|
|
62
|
+
champva: "CHAMPVA",
|
|
63
|
+
dob: "DOB",
|
|
64
|
+
hmo: "HMO",
|
|
65
|
+
id: "ID",
|
|
66
|
+
iep: "IEP",
|
|
67
|
+
lis: "LIS",
|
|
68
|
+
ma: "MA",
|
|
69
|
+
mapd: "MAPD",
|
|
70
|
+
mbi: "MBI",
|
|
71
|
+
npi: "NPI",
|
|
72
|
+
oep: "OEP",
|
|
73
|
+
pcp: "PCP",
|
|
74
|
+
pdp: "PDP",
|
|
75
|
+
ppo: "PPO",
|
|
76
|
+
sep: "SEP",
|
|
77
|
+
snp: "SNP",
|
|
78
|
+
ssn: "SSN",
|
|
79
|
+
tricare: "TRICARE",
|
|
80
|
+
url: "URL",
|
|
81
|
+
us: "US",
|
|
82
|
+
va: "VA",
|
|
83
|
+
zip: "ZIP"
|
|
84
|
+
};
|
|
85
|
+
var MINOR_WORDS = /* @__PURE__ */ new Set([
|
|
86
|
+
"a",
|
|
87
|
+
"an",
|
|
88
|
+
"and",
|
|
89
|
+
"for",
|
|
90
|
+
"in",
|
|
91
|
+
"of",
|
|
92
|
+
"on",
|
|
93
|
+
"or",
|
|
94
|
+
"the",
|
|
95
|
+
"to",
|
|
96
|
+
"with"
|
|
97
|
+
]);
|
|
98
|
+
function displayFieldLabel(field) {
|
|
99
|
+
const words = field.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_-]+/).filter(Boolean);
|
|
100
|
+
return words.map((word, index) => displayFieldLabelWord(word, index, words[index - 1])).join(" ");
|
|
101
|
+
}
|
|
102
|
+
function readableLabel(label) {
|
|
103
|
+
return /^[a-z][a-z0-9]*(_[a-z0-9]+)+$/.test(label) ? displayFieldLabel(label) : label;
|
|
104
|
+
}
|
|
105
|
+
function displayFieldLabelWord(word, index, previous) {
|
|
106
|
+
const lower = word.toLowerCase();
|
|
107
|
+
if (previous?.toLowerCase() === "part" && /^[a-d]$/.test(lower)) {
|
|
108
|
+
return lower.toUpperCase();
|
|
109
|
+
}
|
|
110
|
+
const acronym = ACRONYMS[lower];
|
|
111
|
+
if (acronym !== void 0) {
|
|
112
|
+
return acronym;
|
|
113
|
+
}
|
|
114
|
+
if (index > 0 && MINOR_WORDS.has(lower)) {
|
|
115
|
+
return lower;
|
|
116
|
+
}
|
|
117
|
+
return lower.charAt(0).toUpperCase() + lower.slice(1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// src/DateTimeInput.tsx
|
|
58
121
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
59
122
|
var inputStyle = {
|
|
60
123
|
backgroundColor: "var(--a2ui-datetimeinput-background, var(--a2ui-color-input, #fff))",
|
|
@@ -167,7 +230,7 @@ function DateOnlyInput(props) {
|
|
|
167
230
|
"button",
|
|
168
231
|
{
|
|
169
232
|
type: "button",
|
|
170
|
-
"aria-label": `Choose ${props.label
|
|
233
|
+
"aria-label": `Choose ${props.label ? readableLabel(props.label) : "date"} from calendar`,
|
|
171
234
|
style: inputStyle,
|
|
172
235
|
onClick: () => openPicker(pickerRef.current, () => setPickerOpen(true)),
|
|
173
236
|
children: "\u25A6"
|
|
@@ -178,7 +241,7 @@ function DateOnlyInput(props) {
|
|
|
178
241
|
{
|
|
179
242
|
ref: pickerRef,
|
|
180
243
|
type: "date",
|
|
181
|
-
"aria-label": `${props.label
|
|
244
|
+
"aria-label": `${props.label ? readableLabel(props.label) : "Date"} calendar`,
|
|
182
245
|
tabIndex: pickerOpen ? 0 : -1,
|
|
183
246
|
"aria-hidden": !pickerOpen,
|
|
184
247
|
"data-a2ui-calendar-input": "true",
|
|
@@ -2121,6 +2184,12 @@ function currentQuestionElement(root) {
|
|
|
2121
2184
|
}
|
|
2122
2185
|
return container !== null && container !== root && root.contains(container) ? container : action;
|
|
2123
2186
|
}
|
|
2187
|
+
var RENDERER_CONTROL_SELECTOR = "input:not([data-a2ui-loop-edit-input]), select, textarea";
|
|
2188
|
+
function addsRendererControl(record) {
|
|
2189
|
+
return [...record.addedNodes].some(
|
|
2190
|
+
(node) => node instanceof Element && (node.matches(RENDERER_CONTROL_SELECTOR) || node.querySelector(RENDERER_CONTROL_SELECTOR) !== null)
|
|
2191
|
+
);
|
|
2192
|
+
}
|
|
2124
2193
|
function textOf(element) {
|
|
2125
2194
|
return (element.textContent ?? "").replace(/\s+/g, "");
|
|
2126
2195
|
}
|
|
@@ -2665,6 +2734,21 @@ function formatFieldLabels(root) {
|
|
|
2665
2734
|
originals.set(element, element.textContent ?? "");
|
|
2666
2735
|
element.textContent = displayFieldLabel(field);
|
|
2667
2736
|
}
|
|
2737
|
+
const fields = new Set(
|
|
2738
|
+
[...root.querySelectorAll("[data-a2ui-field]")].map((control) => control.dataset.a2uiField).filter((field) => field !== void 0)
|
|
2739
|
+
);
|
|
2740
|
+
for (const element of root.querySelectorAll("*")) {
|
|
2741
|
+
if (element.childElementCount !== 0 || originals.has(element)) {
|
|
2742
|
+
continue;
|
|
2743
|
+
}
|
|
2744
|
+
const text = element.textContent ?? "";
|
|
2745
|
+
const match = /^(\s*)([A-Za-z][A-Za-z0-9_]*)(\s+\S[\s\S]*)$/.exec(text);
|
|
2746
|
+
if (match === null || !fields.has(match[2]) || !match[2].includes("_")) {
|
|
2747
|
+
continue;
|
|
2748
|
+
}
|
|
2749
|
+
originals.set(element, text);
|
|
2750
|
+
element.textContent = `${match[1]}${displayFieldLabel(match[2])}${match[3]}`;
|
|
2751
|
+
}
|
|
2668
2752
|
return () => {
|
|
2669
2753
|
for (const [label, text] of originals) {
|
|
2670
2754
|
label.textContent = text;
|
|
@@ -3355,28 +3439,6 @@ function labelElementForControl(root, control) {
|
|
|
3355
3439
|
const label = root.ownerDocument.getElementById(labelledBy);
|
|
3356
3440
|
return label instanceof HTMLElement && root.contains(label) ? label : void 0;
|
|
3357
3441
|
}
|
|
3358
|
-
function displayFieldLabel(field) {
|
|
3359
|
-
const words = field.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_-]+/).filter(Boolean);
|
|
3360
|
-
return words.map((word, index) => displayFieldLabelWord(word, index)).join(" ");
|
|
3361
|
-
}
|
|
3362
|
-
function displayFieldLabelWord(word, index) {
|
|
3363
|
-
const lower = word.toLowerCase();
|
|
3364
|
-
const acronyms = {
|
|
3365
|
-
dob: "DOB",
|
|
3366
|
-
id: "ID",
|
|
3367
|
-
ssn: "SSN",
|
|
3368
|
-
url: "URL",
|
|
3369
|
-
us: "US",
|
|
3370
|
-
zip: "ZIP"
|
|
3371
|
-
};
|
|
3372
|
-
if (lower in acronyms) {
|
|
3373
|
-
return acronyms[lower];
|
|
3374
|
-
}
|
|
3375
|
-
if (index > 0 && ["a", "an", "and", "for", "in", "of", "on", "or", "the", "to", "with"].includes(lower)) {
|
|
3376
|
-
return lower;
|
|
3377
|
-
}
|
|
3378
|
-
return lower.charAt(0).toUpperCase() + lower.slice(1);
|
|
3379
|
-
}
|
|
3380
3442
|
function cssString(value) {
|
|
3381
3443
|
return globalThis.CSS?.escape?.(value) ?? value.replace(/["\\]/g, "\\$&");
|
|
3382
3444
|
}
|
|
@@ -3422,6 +3484,30 @@ function enhanceTabs(root, tabs, navigation, viewedSectionId, frameId, onPanelCh
|
|
|
3422
3484
|
});
|
|
3423
3485
|
panel.setAttribute("aria-labelledby", selected.id);
|
|
3424
3486
|
onPanelChange();
|
|
3487
|
+
watchPanelRender();
|
|
3488
|
+
};
|
|
3489
|
+
let panelObserver;
|
|
3490
|
+
let panelObserverTimer;
|
|
3491
|
+
const stopWatchingPanel = () => {
|
|
3492
|
+
panelObserver?.disconnect();
|
|
3493
|
+
panelObserver = void 0;
|
|
3494
|
+
if (panelObserverTimer !== void 0) {
|
|
3495
|
+
globalThis.clearTimeout(panelObserverTimer);
|
|
3496
|
+
panelObserverTimer = void 0;
|
|
3497
|
+
}
|
|
3498
|
+
};
|
|
3499
|
+
const watchPanelRender = () => {
|
|
3500
|
+
stopWatchingPanel();
|
|
3501
|
+
if (typeof MutationObserver === "undefined") {
|
|
3502
|
+
return;
|
|
3503
|
+
}
|
|
3504
|
+
panelObserver = new MutationObserver((records) => {
|
|
3505
|
+
if (records.some(addsRendererControl)) {
|
|
3506
|
+
onPanelChange();
|
|
3507
|
+
}
|
|
3508
|
+
});
|
|
3509
|
+
panelObserver.observe(panel, { childList: true, subtree: true });
|
|
3510
|
+
panelObserverTimer = globalThis.setTimeout(stopWatchingPanel, 3e3);
|
|
3425
3511
|
};
|
|
3426
3512
|
buttons.forEach((button, index) => {
|
|
3427
3513
|
button.dataset.a2uiTab = statuses[index];
|
|
@@ -3464,6 +3550,7 @@ function enhanceTabs(root, tabs, navigation, viewedSectionId, frameId, onPanelCh
|
|
|
3464
3550
|
synchronizingRenderer = false;
|
|
3465
3551
|
activate(selectedIndex);
|
|
3466
3552
|
return () => {
|
|
3553
|
+
stopWatchingPanel();
|
|
3467
3554
|
for (const remove of listeners) {
|
|
3468
3555
|
remove();
|
|
3469
3556
|
}
|