@ukiahinsure/a2ui-react-adapter 0.1.20 → 0.1.21

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 CHANGED
@@ -90,6 +90,29 @@ function displayDate(value) {
90
90
  const iso = parseDateDraft(value);
91
91
  return iso ? `${iso.slice(5, 7)}/${iso.slice(8, 10)}/${iso.slice(0, 4)}` : value;
92
92
  }
93
+ var calendarOverlayStyle = {
94
+ position: "absolute",
95
+ inset: 0,
96
+ width: "100%",
97
+ height: "100%",
98
+ margin: 0,
99
+ padding: 0,
100
+ border: 0,
101
+ opacity: 0,
102
+ cursor: "pointer",
103
+ fontSize: 16,
104
+ boxSizing: "border-box"
105
+ };
106
+ function openPicker(picker, fallback) {
107
+ if (picker && typeof picker.showPicker === "function") {
108
+ try {
109
+ picker.showPicker();
110
+ return;
111
+ } catch {
112
+ }
113
+ }
114
+ fallback?.();
115
+ }
93
116
  function DateOnlyInput(props) {
94
117
  const id = useId2();
95
118
  const [draft, setDraft] = useState(() => displayDate(props.value || ""));
@@ -139,45 +162,38 @@ function DateOnlyInput(props) {
139
162
  style: { ...inputStyle, minWidth: 0, flex: 1 }
140
163
  }
141
164
  ),
142
- /* @__PURE__ */ jsx2(
143
- "button",
144
- {
145
- type: "button",
146
- "aria-label": `Choose ${props.label || "date"} from calendar`,
147
- style: inputStyle,
148
- onClick: () => {
149
- const picker = pickerRef.current;
150
- if (picker && typeof picker.showPicker === "function") {
151
- try {
152
- picker.showPicker();
153
- return;
154
- } catch {
155
- }
156
- }
157
- setPickerOpen(true);
158
- },
159
- children: "\u25A6"
160
- }
161
- ),
162
- /* @__PURE__ */ jsx2(
163
- "input",
164
- {
165
- ref: pickerRef,
166
- type: "date",
167
- "aria-label": `${props.label || "Date"} calendar`,
168
- tabIndex: pickerOpen ? 0 : -1,
169
- "aria-hidden": !pickerOpen,
170
- "data-a2ui-calendar-input": "true",
171
- value: parsed || "",
172
- min,
173
- max,
174
- onChange: (event) => {
175
- update(displayDate(event.currentTarget.value));
176
- setPickerOpen(false);
177
- },
178
- style: pickerOpen ? inputStyle : { position: "absolute", opacity: 0, pointerEvents: "none", width: 1, height: 1, bottom: 0, right: 0 }
179
- }
180
- )
165
+ /* @__PURE__ */ jsxs2("span", { style: { position: "relative", display: "flex" }, children: [
166
+ /* @__PURE__ */ jsx2(
167
+ "button",
168
+ {
169
+ type: "button",
170
+ "aria-label": `Choose ${props.label || "date"} from calendar`,
171
+ style: inputStyle,
172
+ onClick: () => openPicker(pickerRef.current, () => setPickerOpen(true)),
173
+ children: "\u25A6"
174
+ }
175
+ ),
176
+ /* @__PURE__ */ jsx2(
177
+ "input",
178
+ {
179
+ ref: pickerRef,
180
+ type: "date",
181
+ "aria-label": `${props.label || "Date"} calendar`,
182
+ tabIndex: pickerOpen ? 0 : -1,
183
+ "aria-hidden": !pickerOpen,
184
+ "data-a2ui-calendar-input": "true",
185
+ value: parsed || "",
186
+ min,
187
+ max,
188
+ onClick: (event) => openPicker(event.currentTarget),
189
+ onChange: (event) => {
190
+ update(displayDate(event.currentTarget.value));
191
+ setPickerOpen(false);
192
+ },
193
+ style: pickerOpen ? inputStyle : calendarOverlayStyle
194
+ }
195
+ )
196
+ ] })
181
197
  ] })
182
198
  ] });
183
199
  }