@jirawatpyk/aura-react 4.5.0 → 4.6.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/dist/esm/extra.js CHANGED
@@ -1,69 +1,95 @@
1
1
  'use client';
2
2
  import * as React from "react";
3
3
  import { createPortal } from "react-dom";
4
- import { cx, omit, uid, useMaybeControlled, useMergedRef, useMounted, useIsoLayoutEffect, trapTab, FOCUSABLE } from "./internal.js";
4
+ import {
5
+ cx,
6
+ omit,
7
+ uid,
8
+ useMaybeControlled,
9
+ useMergedRef,
10
+ useMounted,
11
+ useIsoLayoutEffect,
12
+ trapTab,
13
+ FOCUSABLE
14
+ } from "./internal.js";
5
15
  import { useStrings } from "./locale.js";
6
16
  import { Icon } from "./Icon.js";
7
17
  import { IconButton } from "./IconButton.js";
8
- const h = React.createElement;
9
- var TONES = ["neutral", "accent", "success", "warning", "danger"];
18
+ const TONES = ["neutral", "accent", "success", "warning", "danger"];
10
19
  function tone(t) {
11
20
  return TONES.indexOf(t) >= 0 ? t : "neutral";
12
21
  }
13
22
  const Badge = React.forwardRef(function Badge2(props, ref) {
14
- var rest = omit(props, ["tone", "variant", "icon", "className", "children"]);
15
- return h(
23
+ const rest = omit(props, ["tone", "variant", "icon", "className", "children"]);
24
+ return /* @__PURE__ */ React.createElement(
16
25
  "span",
17
- 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) }),
18
- props.icon ? h(Icon, { name: props.icon, size: 12 }) : null,
26
+ {
27
+ ...rest,
28
+ ref,
29
+ className: cx(
30
+ "aura-badge",
31
+ "aura-badge--" + tone(props.tone),
32
+ props.variant === "solid" && "is-solid",
33
+ props.variant === "outline" && "is-outline",
34
+ props.className
35
+ )
36
+ },
37
+ props.icon ? /* @__PURE__ */ React.createElement(Icon, { name: props.icon, size: 12 }) : null,
19
38
  props.children
20
39
  );
21
40
  });
22
41
  const Tag = React.forwardRef(function Tag2(props, ref) {
23
- var t = useStrings();
24
- var selectable = props.onClick != null || props.selected != null;
25
- var rest = omit(props, ["onRemove", "selected", "icon", "className", "children", "disabled", "removeLabel"]);
26
- var inner = [props.icon ? h(Icon, { key: "i", name: props.icon, size: 14 }) : null, h("span", { key: "t", className: "aura-tag__text" }, props.children)];
42
+ const t = useStrings();
43
+ const selectable = props.onClick != null || props.selected != null;
44
+ const rest = omit(props, ["onRemove", "selected", "icon", "className", "children", "disabled", "removeLabel"]);
45
+ const inner = [
46
+ props.icon ? /* @__PURE__ */ React.createElement(Icon, { key: "i", name: props.icon, size: 14 }) : null,
47
+ /* @__PURE__ */ React.createElement("span", { key: "t", className: "aura-tag__text" }, props.children)
48
+ ];
27
49
  if (selectable) {
28
- return h(
50
+ return /* @__PURE__ */ React.createElement(
29
51
  "button",
30
- Object.assign({}, rest, {
52
+ {
53
+ ...rest,
31
54
  ref,
32
55
  type: "button",
33
56
  "aria-pressed": !!props.selected,
34
57
  disabled: props.disabled,
35
58
  className: cx("aura-tag is-selectable", props.selected && "is-selected", props.className)
36
- }),
37
- props.selected ? h(Icon, { name: "check", size: 14 }) : inner[0],
59
+ },
60
+ props.selected ? /* @__PURE__ */ React.createElement(Icon, { name: "check", size: 14 }) : inner[0],
38
61
  inner[1]
39
62
  );
40
63
  }
41
- return h(
42
- "span",
43
- Object.assign({}, rest, { ref, className: cx("aura-tag", props.disabled && "is-disabled", props.className) }),
44
- inner,
45
- props.onRemove && !props.disabled ? h(
46
- "button",
47
- { type: "button", className: "aura-tag__remove", "aria-label": props.removeLabel || t.remove(typeof props.children === "string" ? props.children : ""), onClick: props.onRemove },
48
- h(Icon, { name: "x", size: 12 })
49
- ) : null
50
- );
64
+ return /* @__PURE__ */ React.createElement("span", { ...rest, ref, className: cx("aura-tag", props.disabled && "is-disabled", props.className) }, inner, props.onRemove && !props.disabled ? /* @__PURE__ */ React.createElement(
65
+ "button",
66
+ {
67
+ type: "button",
68
+ className: "aura-tag__remove",
69
+ "aria-label": props.removeLabel || t.remove(typeof props.children === "string" ? props.children : ""),
70
+ onClick: props.onRemove
71
+ },
72
+ /* @__PURE__ */ React.createElement(Icon, { name: "x", size: 12 })
73
+ ) : null);
51
74
  });
52
75
  const Progress = React.forwardRef(function Progress2(props, ref) {
53
- var auto = uid(), id = props.id || auto;
54
- var max = props.max || 100, det = props.value != null;
55
- var pct = det ? Math.max(0, Math.min(100, props.value / max * 100)) : 0;
56
- var shown = props.valueLabel != null ? props.valueLabel : det ? Math.round(pct) + "%" : null;
57
- return h(
76
+ const auto = uid(), id = props.id || auto;
77
+ const max = props.max || 100, det = props.value != null;
78
+ const pct = det ? Math.max(0, Math.min(100, props.value / max * 100)) : 0;
79
+ const shown = props.valueLabel != null ? props.valueLabel : det ? Math.round(pct) + "%" : null;
80
+ return /* @__PURE__ */ React.createElement(
58
81
  "div",
59
- { ref, className: cx("aura-progress", "aura-progress--" + tone(props.tone || "accent"), props.size === "sm" && "is-sm", props.className) },
60
- props.label || props.showValue && shown ? h(
61
- "div",
62
- { className: "aura-progress__head" },
63
- props.label ? h("span", { className: "aura-progress__label", id: id + "-label" }, props.label) : h("span"),
64
- props.showValue && shown ? h("span", { className: "aura-progress__value" }, shown) : null
65
- ) : null,
66
- h(
82
+ {
83
+ ref,
84
+ className: cx(
85
+ "aura-progress",
86
+ "aura-progress--" + tone(props.tone || "accent"),
87
+ props.size === "sm" && "is-sm",
88
+ props.className
89
+ )
90
+ },
91
+ props.label || props.showValue && shown ? /* @__PURE__ */ React.createElement("div", { className: "aura-progress__head" }, props.label ? /* @__PURE__ */ React.createElement("span", { className: "aura-progress__label", id: id + "-label" }, props.label) : /* @__PURE__ */ React.createElement("span", null), props.showValue && shown ? /* @__PURE__ */ React.createElement("span", { className: "aura-progress__value" }, shown) : null) : null,
92
+ /* @__PURE__ */ React.createElement(
67
93
  "div",
68
94
  {
69
95
  className: cx("aura-progress__track", !det && "is-indeterminate"),
@@ -75,37 +101,50 @@ const Progress = React.forwardRef(function Progress2(props, ref) {
75
101
  "aria-valuenow": det ? props.value : void 0,
76
102
  "aria-valuetext": det && props.valueLabel != null ? String(props.valueLabel) : void 0
77
103
  },
78
- h("span", { className: "aura-progress__bar", style: det ? { width: pct + "%" } : void 0 })
104
+ /* @__PURE__ */ React.createElement("span", { className: "aura-progress__bar", style: det ? { width: pct + "%" } : void 0 })
79
105
  ),
80
- props.hint ? h("p", { className: "aura-progress__hint" }, props.hint) : null
106
+ props.hint ? /* @__PURE__ */ React.createElement("p", { className: "aura-progress__hint" }, props.hint) : null
81
107
  );
82
108
  });
83
109
  const Skeleton = React.forwardRef(function Skeleton2(props, ref) {
84
- var v = props.variant || "text";
110
+ const v = props.variant || "text";
85
111
  if (v === "text" && (props.lines || 1) > 1) {
86
- var n = props.lines, rows = [];
87
- for (var i = 0; i < n; i++) rows.push(h("span", { key: i, className: "aura-skel aura-skel--text", style: { width: i === n - 1 ? "60%" : "100%" } }));
88
- return h("span", { ref, className: cx("aura-skel-lines", props.className), "aria-hidden": true, style: props.width ? { width: props.width } : void 0 }, rows);
112
+ const n = props.lines, rows = [];
113
+ for (let i = 0; i < n; i++)
114
+ rows.push(/* @__PURE__ */ React.createElement("span", { key: i, className: "aura-skel aura-skel--text", style: { width: i === n - 1 ? "60%" : "100%" } }));
115
+ return /* @__PURE__ */ React.createElement(
116
+ "span",
117
+ {
118
+ ref,
119
+ className: cx("aura-skel-lines", props.className),
120
+ "aria-hidden": true,
121
+ style: props.width ? { width: props.width } : void 0
122
+ },
123
+ rows
124
+ );
89
125
  }
90
- var style = { width: props.width, height: props.height };
126
+ const style = { width: props.width, height: props.height };
91
127
  if (v === "circle") {
92
128
  style.width = style.height = props.size || props.width || 40;
93
129
  }
94
- return h("span", { ref, "aria-hidden": true, className: cx("aura-skel", "aura-skel--" + v, props.className), style });
130
+ return /* @__PURE__ */ React.createElement("span", { ref, "aria-hidden": true, className: cx("aura-skel", "aura-skel--" + v, props.className), style });
95
131
  });
96
132
  const EmptyState = React.forwardRef(function EmptyState2(props, ref) {
97
- var HT = "h" + (props.headingLevel || 3);
98
- return h(
133
+ const HT = "h" + (props.headingLevel || 3);
134
+ return /* @__PURE__ */ React.createElement(
99
135
  "div",
100
- { ref, className: cx("aura-empty", props.size === "sm" && "is-sm", props.bordered && "is-bordered", props.className) },
101
- h("span", { className: "aura-empty__icon", "aria-hidden": true }, h(Icon, { name: props.icon || "inbox", size: props.size === "sm" ? "md" : "lg" })),
102
- h(HT, { className: "aura-empty__title" }, props.title),
103
- props.description ? h("p", { className: "aura-empty__text" }, props.description) : null,
104
- props.action ? h("div", { className: "aura-empty__action" }, props.action) : null
136
+ {
137
+ ref,
138
+ className: cx("aura-empty", props.size === "sm" && "is-sm", props.bordered && "is-bordered", props.className)
139
+ },
140
+ /* @__PURE__ */ React.createElement("span", { className: "aura-empty__icon", "aria-hidden": true }, /* @__PURE__ */ React.createElement(Icon, { name: props.icon || "inbox", size: props.size === "sm" ? "md" : "lg" })),
141
+ /* @__PURE__ */ React.createElement(HT, { className: "aura-empty__title" }, props.title),
142
+ props.description ? /* @__PURE__ */ React.createElement("p", { className: "aura-empty__text" }, props.description) : null,
143
+ props.action ? /* @__PURE__ */ React.createElement("div", { className: "aura-empty__action" }, props.action) : null
105
144
  );
106
145
  });
107
146
  function pageList(page, count, sib) {
108
- var out = [], lo = Math.max(2, page - sib), hi = Math.min(count - 1, page + sib);
147
+ let out = [], lo = Math.max(2, page - sib), hi = Math.min(count - 1, page + sib);
109
148
  if (page - sib <= 3) {
110
149
  lo = 2;
111
150
  hi = Math.min(count - 1, Math.max(hi, 3 + 2 * sib));
@@ -117,64 +156,107 @@ function pageList(page, count, sib) {
117
156
  out.push(1);
118
157
  if (lo === 3) out.push(2);
119
158
  else if (lo > 3) out.push("\u2026a");
120
- for (var i = lo; i <= hi; i++) out.push(i);
159
+ for (let i = lo; i <= hi; i++) out.push(i);
121
160
  if (hi === count - 2) out.push(count - 1);
122
161
  else if (hi < count - 2) out.push("\u2026b");
123
162
  if (count > 1) out.push(count);
124
163
  return out;
125
164
  }
126
165
  const Pagination = React.forwardRef(function Pagination2(props, ref) {
127
- var t = useStrings();
128
- var count = Math.max(1, props.pageCount || 1);
129
- var st = useMaybeControlled(props.page, props.defaultPage || 1, props.onChange);
130
- var page = Math.min(count, Math.max(1, st[0]));
166
+ const t = useStrings();
167
+ const count = Math.max(1, props.pageCount || 1);
168
+ const st = useMaybeControlled(props.page, props.defaultPage || 1, props.onChange);
169
+ const page = Math.min(count, Math.max(1, st[0]));
131
170
  function go(p) {
132
171
  if (p >= 1 && p <= count && p !== page) st[1](p);
133
172
  }
134
- var link = props.getHref;
173
+ const link = props.getHref;
135
174
  function item(p, label, extra) {
136
- 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);
137
- return link ? h("a", Object.assign({ href: link(p), onClick: function(e) {
138
- if (props.onChange) {
139
- e.preventDefault();
140
- go(p);
141
- }
142
- } }, common), label) : h("button", Object.assign({ type: "button", onClick: function() {
143
- go(p);
144
- } }, common), label);
175
+ const common = Object.assign(
176
+ {
177
+ className: cx("aura-page", p === page && "is-current"),
178
+ "aria-current": p === page ? "page" : void 0,
179
+ "aria-label": t.pageN(p)
180
+ },
181
+ extra
182
+ );
183
+ return link ? /* @__PURE__ */ React.createElement(
184
+ "a",
185
+ {
186
+ href: link(p),
187
+ onClick: function(e) {
188
+ if (props.onChange) {
189
+ e.preventDefault();
190
+ go(p);
191
+ }
192
+ },
193
+ ...common
194
+ },
195
+ label
196
+ ) : /* @__PURE__ */ React.createElement(
197
+ "button",
198
+ {
199
+ type: "button",
200
+ onClick: function() {
201
+ go(p);
202
+ },
203
+ ...common
204
+ },
205
+ label
206
+ );
145
207
  }
146
- return h(
147
- "nav",
148
- { ref, className: cx("aura-pagination", props.className), "aria-label": props.label || t.pagination },
149
- h(IconButton, { icon: "chevron-left", label: t.prevPage, disabled: page <= 1, onClick: function() {
150
- go(page - 1);
151
- } }),
152
- h("ol", { className: "aura-pagination__list" }, pageList(page, count, props.siblingCount == null ? 1 : props.siblingCount).map(function(p) {
153
- return typeof p === "number" ? h("li", { key: p }, item(p, p)) : h("li", { key: p, className: "aura-pagination__gap", "aria-hidden": true }, "\u2026");
154
- })),
155
- h("span", { className: "aura-pagination__compact", "aria-hidden": true }, t.page(page, count)),
156
- h(IconButton, { icon: "chevron-right", label: t.nextPage, disabled: page >= count, onClick: function() {
157
- go(page + 1);
158
- } })
159
- );
208
+ return /* @__PURE__ */ React.createElement("nav", { ref, className: cx("aura-pagination", props.className), "aria-label": props.label || t.pagination }, /* @__PURE__ */ React.createElement(
209
+ IconButton,
210
+ {
211
+ icon: "chevron-left",
212
+ label: t.prevPage,
213
+ disabled: page <= 1,
214
+ onClick: function() {
215
+ go(page - 1);
216
+ }
217
+ }
218
+ ), /* @__PURE__ */ React.createElement("ol", { className: "aura-pagination__list" }, pageList(page, count, props.siblingCount == null ? 1 : props.siblingCount).map(function(p) {
219
+ return typeof p === "number" ? /* @__PURE__ */ React.createElement("li", { key: p }, item(p, p)) : /* @__PURE__ */ React.createElement("li", { key: p, className: "aura-pagination__gap", "aria-hidden": true }, "\u2026");
220
+ })), /* @__PURE__ */ React.createElement("span", { className: "aura-pagination__compact", "aria-hidden": true }, t.page(page, count)), /* @__PURE__ */ React.createElement(
221
+ IconButton,
222
+ {
223
+ icon: "chevron-right",
224
+ label: t.nextPage,
225
+ disabled: page >= count,
226
+ onClick: function() {
227
+ go(page + 1);
228
+ }
229
+ }
230
+ ));
160
231
  });
161
232
  const Accordion = React.forwardRef(function Accordion2(props, ref) {
162
- var auto = uid(), base = props.id || auto;
163
- var multiple = props.type === "multiple";
164
- var st = useMaybeControlled(props.value, props.defaultValue != null ? props.defaultValue : multiple ? [] : null, props.onChange);
165
- var open = multiple ? st[0] || [] : st[0] ? [st[0]] : [];
166
- var HT = "h" + (props.headingLevel || 3);
167
- var items = props.items || [];
233
+ const auto = uid(), base = props.id || auto;
234
+ const multiple = props.type === "multiple";
235
+ const st = useMaybeControlled(
236
+ props.value,
237
+ props.defaultValue != null ? props.defaultValue : multiple ? [] : null,
238
+ props.onChange
239
+ );
240
+ const open = multiple ? st[0] || [] : st[0] ? [st[0]] : [];
241
+ const HT = "h" + (props.headingLevel || 3);
242
+ const items = props.items || [];
168
243
  function toggle(id) {
169
- var isOpen = open.indexOf(id) >= 0;
170
- if (multiple) st[1](isOpen ? open.filter(function(x) {
171
- return x !== id;
172
- }) : open.concat([id]));
244
+ const isOpen = open.indexOf(id) >= 0;
245
+ if (multiple)
246
+ st[1](
247
+ isOpen ? open.filter(function(x) {
248
+ return x !== id;
249
+ }) : open.concat([id])
250
+ );
173
251
  else st[1](isOpen ? props.collapsible === false ? id : null : id);
174
252
  }
175
253
  function onKey(e) {
176
- var btns = Array.prototype.slice.call(e.currentTarget.querySelectorAll(":scope > .aura-accordion__item > .aura-accordion__heading > button:not([disabled])"));
177
- var i = btns.indexOf(document.activeElement), k = e.key, n = null;
254
+ const btns = Array.prototype.slice.call(
255
+ e.currentTarget.querySelectorAll(
256
+ ":scope > .aura-accordion__item > .aura-accordion__heading > button:not([disabled])"
257
+ )
258
+ );
259
+ let i = btns.indexOf(document.activeElement), k = e.key, n = null;
178
260
  if (i < 0) return;
179
261
  if (k === "ArrowDown") n = btns[(i + 1) % btns.length];
180
262
  else if (k === "ArrowUp") n = btns[(i - 1 + btns.length) % btns.length];
@@ -185,95 +267,90 @@ const Accordion = React.forwardRef(function Accordion2(props, ref) {
185
267
  n.focus();
186
268
  }
187
269
  }
188
- return h(
189
- "div",
190
- { ref, className: cx("aura-accordion", props.className), onKeyDown: onKey },
191
- items.map(function(it) {
192
- var on = open.indexOf(it.id) >= 0, bid = base + "-btn-" + it.id, pid = base + "-panel-" + it.id;
193
- return h(
194
- "div",
195
- { key: it.id, className: cx("aura-accordion__item", on && "is-open") },
196
- h(
197
- HT,
198
- { className: "aura-accordion__heading" },
199
- h(
200
- "button",
201
- { type: "button", id: bid, "aria-expanded": on, "aria-controls": pid, disabled: it.disabled, onClick: function() {
202
- toggle(it.id);
203
- } },
204
- it.icon ? h(Icon, { name: it.icon, className: "aura-accordion__lead" }) : null,
205
- h(
206
- "span",
207
- { className: "aura-accordion__title" },
208
- it.title,
209
- it.description ? h("span", { className: "aura-accordion__desc" }, it.description) : null
210
- ),
211
- h(Icon, { name: "chevron-down", className: "aura-accordion__chevron" })
212
- )
213
- ),
214
- h("div", { id: pid, role: "region", "aria-labelledby": bid, className: "aura-accordion__panel", hidden: !on }, it.content)
215
- );
216
- })
217
- );
270
+ return /* @__PURE__ */ React.createElement("div", { ref, className: cx("aura-accordion", props.className), onKeyDown: onKey }, items.map(function(it) {
271
+ const on = open.indexOf(it.id) >= 0, bid = base + "-btn-" + it.id, pid = base + "-panel-" + it.id;
272
+ return /* @__PURE__ */ React.createElement("div", { key: it.id, className: cx("aura-accordion__item", on && "is-open") }, /* @__PURE__ */ React.createElement(HT, { className: "aura-accordion__heading" }, /* @__PURE__ */ React.createElement(
273
+ "button",
274
+ {
275
+ type: "button",
276
+ id: bid,
277
+ "aria-expanded": on,
278
+ "aria-controls": pid,
279
+ disabled: it.disabled,
280
+ onClick: function() {
281
+ toggle(it.id);
282
+ }
283
+ },
284
+ it.icon ? /* @__PURE__ */ React.createElement(Icon, { name: it.icon, className: "aura-accordion__lead" }) : null,
285
+ /* @__PURE__ */ React.createElement("span", { className: "aura-accordion__title" }, it.title, it.description ? /* @__PURE__ */ React.createElement("span", { className: "aura-accordion__desc" }, it.description) : null),
286
+ /* @__PURE__ */ React.createElement(Icon, { name: "chevron-down", className: "aura-accordion__chevron" })
287
+ )), /* @__PURE__ */ React.createElement("div", { id: pid, role: "region", "aria-labelledby": bid, className: "aura-accordion__panel", hidden: !on }, it.content));
288
+ }));
218
289
  });
219
290
  function position(anchor, pop, placement) {
220
- var r = anchor.getBoundingClientRect(), pw = pop.offsetWidth, ph = pop.offsetHeight, vw = window.innerWidth, vh = window.innerHeight, gap = 6;
221
- var side = (placement || "bottom-start").split("-")[0], align = (placement || "bottom-start").split("-")[1] || "start";
291
+ const r = anchor.getBoundingClientRect(), pw = pop.offsetWidth, ph = pop.offsetHeight, vw = window.innerWidth, vh = window.innerHeight, gap = 6;
292
+ let side = (placement || "bottom-start").split("-")[0], align = (placement || "bottom-start").split("-")[1] || "start";
222
293
  if (side === "bottom" && r.bottom + gap + ph > vh - 8 && r.top - gap - ph > 8) side = "top";
223
294
  else if (side === "top" && r.top - gap - ph < 8 && r.bottom + gap + ph < vh - 8) side = "bottom";
224
- var top = side === "top" ? r.top - gap - ph : r.bottom + gap;
225
- var left = align === "end" ? r.right - pw : align === "center" ? r.left + r.width / 2 - pw / 2 : r.left;
295
+ const top = side === "top" ? r.top - gap - ph : r.bottom + gap;
296
+ const left = align === "end" ? r.right - pw : align === "center" ? r.left + r.width / 2 - pw / 2 : r.left;
226
297
  return { top: Math.max(8, top), left: Math.max(8, Math.min(left, vw - pw - 8)), side };
227
298
  }
228
299
  const Popover = React.forwardRef(function Popover2(props, ref) {
229
- var t = useStrings();
230
- var auto = uid(), id = props.id || auto;
231
- var st = useMaybeControlled(props.open, !!props.defaultOpen, props.onOpenChange);
232
- var open = !!st[0];
233
- var wrap = React.useRef(null), pop = React.useRef(null), popMerged = useMergedRef(ref, pop);
234
- var pos = React.useState(null), mounted = useMounted();
300
+ const t = useStrings();
301
+ const auto = uid(), id = props.id || auto;
302
+ const st = useMaybeControlled(props.open, !!props.defaultOpen, props.onOpenChange);
303
+ const open = !!st[0];
304
+ const wrap = React.useRef(null), pop = React.useRef(null), popMerged = useMergedRef(ref, pop);
305
+ const pos = React.useState(null), mounted = useMounted();
235
306
  function trigger() {
236
307
  return wrap.current && (wrap.current.querySelector('button, [role="button"], a, input') || wrap.current.firstElementChild);
237
308
  }
238
309
  function close(restore) {
239
310
  st[1](false);
240
311
  if (restore) {
241
- var tr = trigger();
312
+ const tr = trigger();
242
313
  if (tr && tr.focus) tr.focus();
243
314
  }
244
315
  }
245
- useIsoLayoutEffect(function() {
246
- if (!open || !pop.current || !trigger()) return;
247
- function place() {
248
- if (pop.current && trigger()) pos[1](position(trigger(), pop.current, props.placement));
249
- }
250
- place();
251
- window.addEventListener("resize", place);
252
- window.addEventListener("scroll", place, true);
253
- return function() {
254
- window.removeEventListener("resize", place);
255
- window.removeEventListener("scroll", place, true);
256
- };
257
- }, [open, mounted, props.placement]);
258
- React.useEffect(function() {
259
- if (!open || !mounted) return;
260
- if (props.autoFocus !== false && pop.current) {
261
- var f = pop.current.querySelector("[data-autofocus]") || pop.current.querySelector(FOCUSABLE);
262
- (f || pop.current).focus();
263
- }
264
- function outside(e) {
265
- if (pop.current && pop.current.contains(e.target)) return;
266
- if (wrap.current && wrap.current.contains(e.target)) return;
267
- close(false);
268
- }
269
- document.addEventListener("pointerdown", outside, true);
270
- return function() {
271
- document.removeEventListener("pointerdown", outside, true);
272
- };
273
- }, [open, mounted]);
274
- var child = React.Children.only(props.trigger);
275
- var panel = open && mounted ? createPortal(
276
- h(
316
+ useIsoLayoutEffect(
317
+ function() {
318
+ if (!open || !pop.current || !trigger()) return;
319
+ function place() {
320
+ if (pop.current && trigger()) pos[1](position(trigger(), pop.current, props.placement));
321
+ }
322
+ place();
323
+ window.addEventListener("resize", place);
324
+ window.addEventListener("scroll", place, true);
325
+ return function() {
326
+ window.removeEventListener("resize", place);
327
+ window.removeEventListener("scroll", place, true);
328
+ };
329
+ },
330
+ [open, mounted, props.placement]
331
+ );
332
+ React.useEffect(
333
+ function() {
334
+ if (!open || !mounted) return;
335
+ if (props.autoFocus !== false && pop.current) {
336
+ const f = pop.current.querySelector("[data-autofocus]") || pop.current.querySelector(FOCUSABLE);
337
+ (f || pop.current).focus();
338
+ }
339
+ function outside(e) {
340
+ if (pop.current && pop.current.contains(e.target)) return;
341
+ if (wrap.current && wrap.current.contains(e.target)) return;
342
+ close(false);
343
+ }
344
+ document.addEventListener("pointerdown", outside, true);
345
+ return function() {
346
+ document.removeEventListener("pointerdown", outside, true);
347
+ };
348
+ },
349
+ [open, mounted]
350
+ );
351
+ const child = React.Children.only(props.trigger);
352
+ const panel = open && mounted ? createPortal(
353
+ /* @__PURE__ */ React.createElement(
277
354
  "div",
278
355
  {
279
356
  ref: popMerged,
@@ -284,7 +361,10 @@ const Popover = React.forwardRef(function Popover2(props, ref) {
284
361
  "aria-labelledby": props.title ? id + "-title" : void 0,
285
362
  tabIndex: -1,
286
363
  className: cx("aura-popover", pos[0] && "is-" + pos[0].side, props.className),
287
- style: Object.assign({ top: pos[0] ? pos[0].top : -9999, left: pos[0] ? pos[0].left : -9999 }, props.width ? { width: props.width } : null),
364
+ style: Object.assign(
365
+ { top: pos[0] ? pos[0].top : -9999, left: pos[0] ? pos[0].left : -9999 },
366
+ props.width ? { width: props.width } : null
367
+ ),
288
368
  onKeyDown: function(e) {
289
369
  if (e.key === "Escape") {
290
370
  e.stopPropagation();
@@ -292,29 +372,33 @@ const Popover = React.forwardRef(function Popover2(props, ref) {
292
372
  } else trapTab(e, pop.current);
293
373
  }
294
374
  },
295
- props.title ? h(
296
- "div",
297
- { className: "aura-popover__head" },
298
- h("p", { className: "aura-popover__title", id: id + "-title" }, props.title),
299
- h(IconButton, { icon: "x", label: t.close, onClick: function() {
375
+ props.title ? /* @__PURE__ */ React.createElement("div", { className: "aura-popover__head" }, /* @__PURE__ */ React.createElement("p", { className: "aura-popover__title", id: id + "-title" }, props.title), /* @__PURE__ */ React.createElement(
376
+ IconButton,
377
+ {
378
+ icon: "x",
379
+ label: t.close,
380
+ onClick: function() {
381
+ close(true);
382
+ }
383
+ }
384
+ )) : null,
385
+ /* @__PURE__ */ React.createElement("div", { className: "aura-popover__body" }, typeof props.children === "function" ? props.children({
386
+ close: function() {
300
387
  close(true);
301
- } })
302
- ) : null,
303
- h("div", { className: "aura-popover__body" }, typeof props.children === "function" ? props.children({ close: function() {
304
- close(true);
305
- } }) : props.children)
388
+ }
389
+ }) : props.children)
306
390
  ),
307
391
  document.body
308
392
  ) : null;
309
- return h(
310
- "span",
311
- { ref: wrap, className: "aura-popover-anchor" },
312
- React.cloneElement(child, { onClick: function(e) {
393
+ return /* @__PURE__ */ React.createElement("span", { ref: wrap, className: "aura-popover-anchor" }, React.cloneElement(child, {
394
+ onClick: function(e) {
313
395
  if (child.props.onClick) child.props.onClick(e);
314
396
  st[1](!open);
315
- }, "aria-haspopup": "dialog", "aria-expanded": open, "aria-controls": open ? id : void 0 }),
316
- panel
317
- );
397
+ },
398
+ "aria-haspopup": "dialog",
399
+ "aria-expanded": open,
400
+ "aria-controls": open ? id : void 0
401
+ }), panel);
318
402
  });
319
403
  export {
320
404
  Accordion,