@jirawatpyk/aura-react 4.5.0 → 4.5.1

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.
@@ -5,30 +5,32 @@ import { createPortal } from "react-dom";
5
5
  import { cx, uid, useMounted, useIsoLayoutEffect, useMergedRef } from "./internal.js";
6
6
  import { Icon } from "./Icon.js";
7
7
  import { IconButton } from "./IconButton.js";
8
- const h = React.createElement;
9
- var ALERT_ICON = { info: "info", success: "circle-check", warning: "triangle-alert", danger: "circle-alert" };
8
+ const ALERT_ICON = {
9
+ info: "info",
10
+ success: "circle-check",
11
+ warning: "triangle-alert",
12
+ danger: "circle-alert"
13
+ };
10
14
  const Alert = React.forwardRef(function Alert2(props, ref) {
11
- var t = useStrings();
12
- var tone = props.tone || "info";
13
- return h(
15
+ const t = useStrings();
16
+ const tone = props.tone || "info";
17
+ return /* @__PURE__ */ React.createElement(
14
18
  "div",
15
19
  {
16
20
  ref,
17
21
  className: cx("aura-alert", "aura-alert--" + tone, props.className),
18
22
  role: tone === "danger" || tone === "warning" ? "alert" : "status"
19
23
  },
20
- h(Icon, { name: ALERT_ICON[tone], className: "aura-alert__icon" }),
21
- h(
22
- "div",
23
- { className: "aura-alert__body" },
24
- props.title ? h("p", { className: "aura-alert__title" }, props.title) : null,
25
- props.children ? h("div", { className: "aura-alert__text" }, props.children) : null,
26
- props.action ? h("div", { className: "aura-alert__action" }, props.action) : null
27
- ),
28
- props.onDismiss ? h(IconButton, { icon: "x", label: t.dismiss, className: "aura-alert__close", onClick: props.onDismiss }) : null
24
+ /* @__PURE__ */ React.createElement(Icon, { name: ALERT_ICON[tone], className: "aura-alert__icon" }),
25
+ /* @__PURE__ */ React.createElement("div", { className: "aura-alert__body" }, props.title ? /* @__PURE__ */ React.createElement("p", { className: "aura-alert__title" }, props.title) : null, props.children ? /* @__PURE__ */ React.createElement("div", { className: "aura-alert__text" }, props.children) : null, props.action ? /* @__PURE__ */ React.createElement("div", { className: "aura-alert__action" }, props.action) : null),
26
+ props.onDismiss ? /* @__PURE__ */ React.createElement(IconButton, { icon: "x", label: t.dismiss, className: "aura-alert__close", onClick: props.onDismiss }) : null
29
27
  );
30
28
  });
31
- var toastState = { list: [], subs: [], n: 0 };
29
+ const toastState = {
30
+ list: [],
31
+ subs: [],
32
+ n: 0
33
+ };
32
34
  function emitToasts() {
33
35
  toastState.subs.forEach(function(f) {
34
36
  f(toastState.list.slice());
@@ -36,7 +38,7 @@ function emitToasts() {
36
38
  }
37
39
  function toast(opts) {
38
40
  if (typeof opts === "string") opts = { title: opts };
39
- var id = opts.id || "t" + ++toastState.n;
41
+ const id = opts.id || "t" + ++toastState.n;
40
42
  toastState.list = toastState.list.filter(function(t) {
41
43
  return t.id !== id;
42
44
  }).concat([Object.assign({ tone: "info" }, opts, { id })]).slice(-3);
@@ -50,8 +52,8 @@ toast.dismiss = function(id) {
50
52
  emitToasts();
51
53
  };
52
54
  function ToastItem(props) {
53
- var str = useStrings();
54
- var t = props.toast, timer = React.useRef(null), left = React.useRef(t.duration || 5e3), since = React.useRef(0);
55
+ const str = useStrings();
56
+ const t = props.toast, timer = React.useRef(null), left = React.useRef(t.duration || 5e3), since = React.useRef(0);
55
57
  function start() {
56
58
  if (left.current === Infinity) return;
57
59
  since.current = Date.now();
@@ -70,7 +72,7 @@ function ToastItem(props) {
70
72
  start();
71
73
  return pause;
72
74
  }, []);
73
- return h(
75
+ return /* @__PURE__ */ React.createElement(
74
76
  "div",
75
77
  {
76
78
  className: cx("aura-toast", "aura-toast--" + t.tone),
@@ -80,30 +82,37 @@ function ToastItem(props) {
80
82
  onFocus: pause,
81
83
  onBlur: start
82
84
  },
83
- h(Icon, { name: ALERT_ICON[t.tone] || "info", className: "aura-toast__icon" }),
84
- h(
85
- "div",
86
- { className: "aura-toast__body" },
87
- h("p", { className: "aura-toast__title" }, t.title),
88
- t.description ? h("p", { className: "aura-toast__text" }, t.description) : null
89
- ),
90
- t.action ? h("button", {
91
- type: "button",
92
- className: "aura-toast__action",
93
- onClick: function() {
94
- t.action.onClick && t.action.onClick();
95
- toast.dismiss(t.id);
85
+ /* @__PURE__ */ React.createElement(Icon, { name: ALERT_ICON[t.tone] || "info", className: "aura-toast__icon" }),
86
+ /* @__PURE__ */ React.createElement("div", { className: "aura-toast__body" }, /* @__PURE__ */ React.createElement("p", { className: "aura-toast__title" }, t.title), t.description ? /* @__PURE__ */ React.createElement("p", { className: "aura-toast__text" }, t.description) : null),
87
+ t.action ? /* @__PURE__ */ React.createElement(
88
+ "button",
89
+ {
90
+ type: "button",
91
+ className: "aura-toast__action",
92
+ onClick: function() {
93
+ t.action.onClick && t.action.onClick();
94
+ toast.dismiss(t.id);
95
+ }
96
+ },
97
+ t.action.label
98
+ ) : null,
99
+ /* @__PURE__ */ React.createElement(
100
+ IconButton,
101
+ {
102
+ icon: "x",
103
+ label: str.dismissToast,
104
+ className: "aura-toast__close",
105
+ onClick: function() {
106
+ toast.dismiss(t.id);
107
+ }
96
108
  }
97
- }, t.action.label) : null,
98
- h(IconButton, { icon: "x", label: str.dismissToast, className: "aura-toast__close", onClick: function() {
99
- toast.dismiss(t.id);
100
- } })
109
+ )
101
110
  );
102
111
  }
103
112
  function Toaster(props) {
104
- var t = useStrings();
105
- var mounted = useMounted();
106
- var s = React.useState(toastState.list);
113
+ const t = useStrings();
114
+ const mounted = useMounted();
115
+ const s = React.useState(toastState.list);
107
116
  React.useEffect(function() {
108
117
  toastState.subs.push(s[1]);
109
118
  return function() {
@@ -113,48 +122,65 @@ function Toaster(props) {
113
122
  };
114
123
  }, []);
115
124
  if (!mounted) return null;
116
- return createPortal(h(
117
- "div",
118
- { className: cx("aura-toaster", props && props.position === "top" && "is-top"), role: "region", "aria-live": "polite", "aria-label": t.notifications },
119
- s[0].map(function(t2) {
120
- return h(ToastItem, { key: t2.id, toast: t2 });
121
- })
122
- ), document.body);
125
+ return createPortal(
126
+ /* @__PURE__ */ React.createElement(
127
+ "div",
128
+ {
129
+ className: cx("aura-toaster", props && props.position === "top" && "is-top"),
130
+ role: "region",
131
+ "aria-live": "polite",
132
+ "aria-label": t.notifications
133
+ },
134
+ s[0].map(function(t2) {
135
+ return /* @__PURE__ */ React.createElement(ToastItem, { key: t2.id, toast: t2 });
136
+ })
137
+ ),
138
+ document.body
139
+ );
123
140
  }
124
141
  const Tooltip = React.forwardRef(function Tooltip2(props, ref) {
125
- var id = uid(), st = React.useState(false), open = props.open !== void 0 ? props.open : st[0], set = st[1];
126
- var anchor = React.useRef(null), anchorMerged = useMergedRef(ref, anchor), tip = React.useRef(null), timer = React.useRef(void 0);
127
- var pos = React.useState(null);
142
+ const id = uid(), st = React.useState(false), open = props.open !== void 0 ? props.open : st[0], set = st[1];
143
+ const anchor = React.useRef(null), anchorMerged = useMergedRef(ref, anchor), tip = React.useRef(null), timer = React.useRef(void 0);
144
+ const pos = React.useState(null);
128
145
  function show(now) {
129
146
  clearTimeout(timer.current);
130
- timer.current = setTimeout(function() {
131
- set(true);
132
- }, now ? 0 : props.delay == null ? 400 : props.delay);
147
+ timer.current = setTimeout(
148
+ function() {
149
+ set(true);
150
+ },
151
+ now ? 0 : props.delay == null ? 400 : props.delay
152
+ );
133
153
  }
134
154
  function hide() {
135
155
  clearTimeout(timer.current);
136
156
  set(false);
137
157
  }
138
- useIsoLayoutEffect(function() {
139
- if (!open || !anchor.current || !tip.current) return;
140
- var r = anchor.current.getBoundingClientRect(), t = tip.current.getBoundingClientRect();
141
- var side = props.side || "top", top = side === "top" ? r.top - t.height - 8 : r.bottom + 8;
142
- if (side === "top" && top < 8) top = r.bottom + 8;
143
- var left = Math.max(8, Math.min(r.left + r.width / 2 - t.width / 2, window.innerWidth - t.width - 8));
144
- pos[1]({ top, left });
145
- }, [open]);
146
- React.useEffect(function() {
147
- if (!open) return;
148
- function esc(e) {
149
- if (e.key === "Escape") hide();
150
- }
151
- document.addEventListener("keydown", esc);
152
- return function() {
153
- document.removeEventListener("keydown", esc);
154
- };
155
- }, [open]);
156
- var child = React.Children.only(props.children);
157
- var trigger = h(
158
+ useIsoLayoutEffect(
159
+ function() {
160
+ if (!open || !anchor.current || !tip.current) return;
161
+ const r = anchor.current.getBoundingClientRect(), t = tip.current.getBoundingClientRect();
162
+ let side = props.side || "top", top = side === "top" ? r.top - t.height - 8 : r.bottom + 8;
163
+ if (side === "top" && top < 8) top = r.bottom + 8;
164
+ const left = Math.max(8, Math.min(r.left + r.width / 2 - t.width / 2, window.innerWidth - t.width - 8));
165
+ pos[1]({ top, left });
166
+ },
167
+ [open]
168
+ );
169
+ React.useEffect(
170
+ function() {
171
+ if (!open) return;
172
+ function esc(e) {
173
+ if (e.key === "Escape") hide();
174
+ }
175
+ document.addEventListener("keydown", esc);
176
+ return function() {
177
+ document.removeEventListener("keydown", esc);
178
+ };
179
+ },
180
+ [open]
181
+ );
182
+ const child = React.Children.only(props.children);
183
+ const trigger = /* @__PURE__ */ React.createElement(
158
184
  "span",
159
185
  {
160
186
  ref: anchorMerged,
@@ -170,18 +196,20 @@ const Tooltip = React.forwardRef(function Tooltip2(props, ref) {
170
196
  },
171
197
  React.cloneElement(child, { "aria-describedby": open ? id : child.props["aria-describedby"] })
172
198
  );
173
- return h(
174
- React.Fragment,
175
- null,
176
- trigger,
177
- open ? createPortal(h("div", {
178
- ref: tip,
179
- id,
180
- role: "tooltip",
181
- className: "aura-tooltip",
182
- style: { top: pos[0] ? pos[0].top : -9999, left: pos[0] ? pos[0].left : -9999 }
183
- }, props.content), document.body) : null
184
- );
199
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, trigger, open ? createPortal(
200
+ /* @__PURE__ */ React.createElement(
201
+ "div",
202
+ {
203
+ ref: tip,
204
+ id,
205
+ role: "tooltip",
206
+ className: "aura-tooltip",
207
+ style: { top: pos[0] ? pos[0].top : -9999, left: pos[0] ? pos[0].left : -9999 }
208
+ },
209
+ props.content
210
+ ),
211
+ document.body
212
+ ) : null);
185
213
  });
186
214
  export {
187
215
  ALERT_ICON,
package/dist/esm/forms.js CHANGED
@@ -5,36 +5,60 @@ import { cx, omit, useMaybeControlled, uid } from "./internal.js";
5
5
  import { Icon } from "./Icon.js";
6
6
  const h = React.createElement;
7
7
  const Field = React.forwardRef(function Field2(props, ref) {
8
- var t = useStrings();
9
- return h(
8
+ const t = useStrings();
9
+ return /* @__PURE__ */ React.createElement(
10
10
  "div",
11
- { ref, className: cx("aura-field", props.error && "is-invalid", props.disabled && "is-disabled", props.className) },
11
+ {
12
+ ref,
13
+ className: cx("aura-field", props.error && "is-invalid", props.disabled && "is-disabled", props.className)
14
+ },
12
15
  props.label ? h(
13
16
  props.labelAs || "label",
14
17
  { className: "aura-field__label", htmlFor: props.labelAs ? void 0 : props.id, id: props.labelId },
15
18
  props.label,
16
- props.required ? h("span", { className: "aura-field__req", "aria-hidden": true }, " *") : null,
17
- props.optional ? h("span", { className: "aura-field__opt" }, " (" + t.optional + ")") : null
19
+ props.required ? /* @__PURE__ */ React.createElement("span", { className: "aura-field__req", "aria-hidden": true }, " *") : null,
20
+ props.optional ? /* @__PURE__ */ React.createElement("span", { className: "aura-field__opt" }, " (" + t.optional + ")") : null
18
21
  ) : null,
19
22
  props.children,
20
- props.error ? h("p", { className: "aura-field__error", id: props.id + "-error" }, h(Icon, { name: "circle-alert", size: 14 }), props.error) : props.hint ? h("p", { className: "aura-field__hint", id: props.id + "-hint" }, props.hint) : null
23
+ props.error ? /* @__PURE__ */ React.createElement("p", { className: "aura-field__error", id: props.id + "-error" }, /* @__PURE__ */ React.createElement(Icon, { name: "circle-alert", size: 14 }), props.error) : props.hint ? /* @__PURE__ */ React.createElement("p", { className: "aura-field__hint", id: props.id + "-hint" }, props.hint) : null
21
24
  );
22
25
  });
23
26
  function describedBy(id, p) {
24
27
  return p.error ? id + "-error" : p.hint ? id + "-hint" : void 0;
25
28
  }
26
- var FIELD_KEYS = ["label", "hint", "error", "required", "optional", "icon", "className", "id", "suffix", "options", "placeholder"];
29
+ const FIELD_KEYS = [
30
+ "label",
31
+ "hint",
32
+ "error",
33
+ "required",
34
+ "optional",
35
+ "icon",
36
+ "className",
37
+ "id",
38
+ "suffix",
39
+ "options",
40
+ "placeholder"
41
+ ];
27
42
  const TextField = React.forwardRef(function TextField2(props, ref) {
28
- var auto = uid(), id = props.id || auto;
29
- var rest = omit(props, FIELD_KEYS);
30
- return h(
43
+ const auto = uid(), id = props.id || auto;
44
+ const rest = omit(props, FIELD_KEYS);
45
+ return /* @__PURE__ */ React.createElement(
31
46
  Field,
32
- { id, label: props.label, hint: props.hint, error: props.error, required: props.required, optional: props.optional, disabled: props.disabled, className: props.className },
33
- h(
34
- "div",
35
- { className: cx("aura-input", props.icon && "has-icon", props.suffix && "has-suffix") },
36
- props.icon ? h(Icon, { name: props.icon, className: "aura-input__icon" }) : null,
37
- h("input", Object.assign({ type: "text" }, rest, {
47
+ {
48
+ id,
49
+ label: props.label,
50
+ hint: props.hint,
51
+ error: props.error,
52
+ required: props.required,
53
+ optional: props.optional,
54
+ disabled: props.disabled,
55
+ className: props.className
56
+ },
57
+ /* @__PURE__ */ React.createElement("div", { className: cx("aura-input", props.icon && "has-icon", props.suffix && "has-suffix") }, props.icon ? /* @__PURE__ */ React.createElement(Icon, { name: props.icon, className: "aura-input__icon" }) : null, /* @__PURE__ */ React.createElement(
58
+ "input",
59
+ {
60
+ type: "text",
61
+ ...rest,
38
62
  ref,
39
63
  id,
40
64
  className: "aura-input__control",
@@ -42,61 +66,89 @@ const TextField = React.forwardRef(function TextField2(props, ref) {
42
66
  required: props.required,
43
67
  "aria-invalid": props.error ? true : void 0,
44
68
  "aria-describedby": describedBy(id, props)
45
- })),
46
- props.suffix ? h("span", { className: "aura-input__suffix" }, props.suffix) : null
47
- )
69
+ }
70
+ ), props.suffix ? /* @__PURE__ */ React.createElement("span", { className: "aura-input__suffix" }, props.suffix) : null)
48
71
  );
49
72
  });
50
73
  const Textarea = React.forwardRef(function Textarea2(props, ref) {
51
- var auto = uid(), id = props.id || auto;
52
- var rest = omit(props, FIELD_KEYS);
53
- return h(
74
+ const auto = uid(), id = props.id || auto;
75
+ const rest = omit(props, FIELD_KEYS);
76
+ return /* @__PURE__ */ React.createElement(
54
77
  Field,
55
- { id, label: props.label, hint: props.hint, error: props.error, required: props.required, optional: props.optional, disabled: props.disabled, className: props.className },
56
- h("textarea", Object.assign({ rows: 4 }, rest, {
57
- ref,
78
+ {
58
79
  id,
59
- className: "aura-input aura-textarea",
60
- placeholder: props.placeholder,
80
+ label: props.label,
81
+ hint: props.hint,
82
+ error: props.error,
61
83
  required: props.required,
62
- "aria-invalid": props.error ? true : void 0,
63
- "aria-describedby": describedBy(id, props)
64
- }))
84
+ optional: props.optional,
85
+ disabled: props.disabled,
86
+ className: props.className
87
+ },
88
+ /* @__PURE__ */ React.createElement(
89
+ "textarea",
90
+ {
91
+ rows: 4,
92
+ ...rest,
93
+ ref,
94
+ id,
95
+ className: "aura-input aura-textarea",
96
+ placeholder: props.placeholder,
97
+ required: props.required,
98
+ "aria-invalid": props.error ? true : void 0,
99
+ "aria-describedby": describedBy(id, props)
100
+ }
101
+ )
65
102
  );
66
103
  });
67
104
  const Select = React.forwardRef(function Select2(props, ref) {
68
- var auto = uid(), id = props.id || auto;
69
- var rest = omit(props, FIELD_KEYS.concat(["children"]));
70
- var opts = (props.options || []).map(function(o) {
71
- var v = typeof o === "object" ? o : { value: o, label: o };
72
- return h("option", { key: v.value, value: v.value, disabled: v.disabled }, v.label);
105
+ const auto = uid(), id = props.id || auto;
106
+ const rest = omit(props, FIELD_KEYS.concat(["children"]));
107
+ const opts = (props.options || []).map(function(o) {
108
+ const v = typeof o === "object" ? o : { value: o, label: o };
109
+ return /* @__PURE__ */ React.createElement("option", { key: v.value, value: v.value, disabled: v.disabled }, v.label);
73
110
  });
74
- if (props.placeholder) opts.unshift(h("option", { key: "__ph", value: "", disabled: true }, props.placeholder));
75
- var extra = props.value === void 0 && props.defaultValue === void 0 && props.placeholder ? { defaultValue: "" } : {};
76
- return h(
111
+ if (props.placeholder)
112
+ opts.unshift(
113
+ /* @__PURE__ */ React.createElement("option", { key: "__ph", value: "", disabled: true }, props.placeholder)
114
+ );
115
+ const extra = props.value === void 0 && props.defaultValue === void 0 && props.placeholder ? { defaultValue: "" } : {};
116
+ return /* @__PURE__ */ React.createElement(
77
117
  Field,
78
- { id, label: props.label, hint: props.hint, error: props.error, required: props.required, optional: props.optional, disabled: props.disabled, className: props.className },
79
- h(
80
- "div",
81
- { className: cx("aura-input aura-select", props.icon && "has-icon") },
82
- props.icon ? h(Icon, { name: props.icon, className: "aura-input__icon" }) : null,
83
- h("select", Object.assign(extra, rest, {
118
+ {
119
+ id,
120
+ label: props.label,
121
+ hint: props.hint,
122
+ error: props.error,
123
+ required: props.required,
124
+ optional: props.optional,
125
+ disabled: props.disabled,
126
+ className: props.className
127
+ },
128
+ /* @__PURE__ */ React.createElement("div", { className: cx("aura-input aura-select", props.icon && "has-icon") }, props.icon ? /* @__PURE__ */ React.createElement(Icon, { name: props.icon, className: "aura-input__icon" }) : null, h(
129
+ "select",
130
+ Object.assign(extra, rest, {
84
131
  ref,
85
132
  id,
86
133
  className: "aura-input__control",
87
134
  required: props.required,
88
135
  "aria-invalid": props.error ? true : void 0,
89
136
  "aria-describedby": describedBy(id, props)
90
- }), opts, props.children),
91
- h(Icon, { name: "chevron-down", className: "aura-select__chevron" })
92
- )
137
+ }),
138
+ opts,
139
+ props.children
140
+ ), /* @__PURE__ */ React.createElement(Icon, { name: "chevron-down", className: "aura-select__chevron" }))
93
141
  );
94
142
  });
95
143
  const RadioGroup = React.forwardRef(function RadioGroup2(props, ref) {
96
- var auto = uid(), id = props.id || auto;
97
- var st = useMaybeControlled(props.value, props.defaultValue, props.onChange);
98
- var name = props.name || id;
99
- return h(
144
+ const auto = uid(), id = props.id || auto;
145
+ const st = useMaybeControlled(
146
+ props.value,
147
+ props.defaultValue,
148
+ props.onChange
149
+ );
150
+ const name = props.name || id;
151
+ return /* @__PURE__ */ React.createElement(
100
152
  "fieldset",
101
153
  {
102
154
  ref,
@@ -105,71 +157,50 @@ const RadioGroup = React.forwardRef(function RadioGroup2(props, ref) {
105
157
  "aria-invalid": props.error ? true : void 0,
106
158
  disabled: props.disabled
107
159
  },
108
- props.label ? h("legend", { className: "aura-field__label" }, props.label, props.required ? h("span", { className: "aura-field__req", "aria-hidden": true }, " *") : null) : null,
109
- h(
110
- "div",
111
- { className: cx("aura-radio-group__list", props.orientation === "horizontal" && "is-horizontal") },
112
- (props.options || []).map(function(o) {
113
- var v = typeof o === "object" ? o : { value: o, label: o };
114
- return h(
115
- "label",
116
- { key: v.value, className: cx("aura-choice", v.disabled && "is-disabled") },
117
- h("input", {
118
- type: "radio",
119
- className: "aura-radio",
120
- name,
121
- value: v.value,
122
- disabled: v.disabled,
123
- checked: st[0] === v.value,
124
- onChange: function() {
125
- st[1](v.value);
126
- }
127
- }),
128
- h(
129
- "span",
130
- { className: "aura-choice__text" },
131
- h("span", { className: "aura-choice__label" }, v.label),
132
- v.description ? h("span", { className: "aura-choice__desc" }, v.description) : null
133
- )
134
- );
135
- })
136
- ),
137
- props.error ? h("p", { className: "aura-field__error", id: id + "-error" }, h(Icon, { name: "circle-alert", size: 14 }), props.error) : props.hint ? h("p", { className: "aura-field__hint", id: id + "-hint" }, props.hint) : null
160
+ props.label ? /* @__PURE__ */ React.createElement("legend", { className: "aura-field__label" }, props.label, props.required ? /* @__PURE__ */ React.createElement("span", { className: "aura-field__req", "aria-hidden": true }, " *") : null) : null,
161
+ /* @__PURE__ */ React.createElement("div", { className: cx("aura-radio-group__list", props.orientation === "horizontal" && "is-horizontal") }, (props.options || []).map(function(o) {
162
+ const v = typeof o === "object" ? o : { value: o, label: o };
163
+ return /* @__PURE__ */ React.createElement("label", { key: v.value, className: cx("aura-choice", v.disabled && "is-disabled") }, /* @__PURE__ */ React.createElement(
164
+ "input",
165
+ {
166
+ type: "radio",
167
+ className: "aura-radio",
168
+ name,
169
+ value: v.value,
170
+ disabled: v.disabled,
171
+ checked: st[0] === v.value,
172
+ onChange: function() {
173
+ st[1](v.value);
174
+ }
175
+ }
176
+ ), /* @__PURE__ */ React.createElement("span", { className: "aura-choice__text" }, /* @__PURE__ */ React.createElement("span", { className: "aura-choice__label" }, v.label), v.description ? /* @__PURE__ */ React.createElement("span", { className: "aura-choice__desc" }, v.description) : null));
177
+ })),
178
+ props.error ? /* @__PURE__ */ React.createElement("p", { className: "aura-field__error", id: id + "-error" }, /* @__PURE__ */ React.createElement(Icon, { name: "circle-alert", size: 14 }), props.error) : props.hint ? /* @__PURE__ */ React.createElement("p", { className: "aura-field__hint", id: id + "-hint" }, props.hint) : null
138
179
  );
139
180
  });
140
181
  const Switch = React.forwardRef(function Switch2(props, ref) {
141
- var auto = uid(), id = props.id || auto;
142
- var st = useMaybeControlled(props.checked, !!props.defaultChecked, props.onChange);
143
- var on = !!st[0];
144
- return h(
145
- "div",
146
- { className: cx("aura-switch-row", props.disabled && "is-disabled", props.className) },
147
- h(
148
- "button",
149
- {
150
- ref,
151
- type: "button",
152
- role: "switch",
153
- id,
154
- "aria-checked": on,
155
- disabled: props.disabled,
156
- "aria-labelledby": props.label ? id + "-label" : void 0,
157
- "aria-label": props.label ? void 0 : props["aria-label"],
158
- "aria-describedby": props.description ? id + "-desc" : void 0,
159
- className: cx("aura-switch", on && "is-on"),
160
- onClick: function() {
161
- st[1](!on);
162
- }
163
- },
164
- h("span", { className: "aura-switch__thumb" })
165
- ),
166
- props.label ? h(
167
- "span",
168
- { className: "aura-choice__text" },
169
- h("label", { className: "aura-choice__label", id: id + "-label", htmlFor: id }, props.label),
170
- props.description ? h("span", { className: "aura-choice__desc", id: id + "-desc" }, props.description) : null
171
- ) : null
172
- );
182
+ const auto = uid(), id = props.id || auto;
183
+ const st = useMaybeControlled(props.checked, !!props.defaultChecked, props.onChange);
184
+ const on = !!st[0];
185
+ return /* @__PURE__ */ React.createElement("div", { className: cx("aura-switch-row", props.disabled && "is-disabled", props.className) }, /* @__PURE__ */ React.createElement(
186
+ "button",
187
+ {
188
+ ref,
189
+ type: "button",
190
+ role: "switch",
191
+ id,
192
+ "aria-checked": on,
193
+ disabled: props.disabled,
194
+ "aria-labelledby": props.label ? id + "-label" : void 0,
195
+ "aria-label": props.label ? void 0 : props["aria-label"],
196
+ "aria-describedby": props.description ? id + "-desc" : void 0,
197
+ className: cx("aura-switch", on && "is-on"),
198
+ onClick: function() {
199
+ st[1](!on);
200
+ }
201
+ },
202
+ /* @__PURE__ */ React.createElement("span", { className: "aura-switch__thumb" })
203
+ ), props.label ? /* @__PURE__ */ React.createElement("span", { className: "aura-choice__text" }, /* @__PURE__ */ React.createElement("label", { className: "aura-choice__label", id: id + "-label", htmlFor: id }, props.label), props.description ? /* @__PURE__ */ React.createElement("span", { className: "aura-choice__desc", id: id + "-desc" }, props.description) : null) : null);
173
204
  });
174
205
  export {
175
206
  Field,