@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.
- package/README.md +2 -2
- package/dist/aura.bundle.js +2518 -2028
- package/dist/cjs/index.cjs +2516 -2028
- package/dist/esm/Button.js +9 -9
- package/dist/esm/Checkbox.js +41 -33
- package/dist/esm/Combobox.js +143 -125
- package/dist/esm/DataTable.js +629 -495
- package/dist/esm/DatePicker.js +378 -305
- package/dist/esm/Dialog.js +48 -59
- package/dist/esm/DropdownMenu.js +9 -12
- package/dist/esm/FileUpload.js +91 -73
- package/dist/esm/Icon.js +27 -22
- package/dist/esm/IconButton.js +13 -9
- package/dist/esm/Menu.js +78 -66
- package/dist/esm/Stat.js +9 -26
- package/dist/esm/StatusPill.js +12 -13
- package/dist/esm/Surface.js +17 -13
- package/dist/esm/ThemeStyle.js +9 -5
- package/dist/esm/TimePicker.js +155 -127
- package/dist/esm/extra.js +270 -186
- package/dist/esm/feedback.js +112 -84
- package/dist/esm/forms.js +144 -113
- package/dist/esm/internal.js +33 -23
- package/dist/esm/layout.js +113 -128
- package/dist/esm/layout2.js +67 -45
- package/dist/esm/locale.js +15 -9
- package/dist/esm/overlay.js +21 -18
- package/dist/esm/theme.js +101 -49
- package/dist/index.d.ts +6 -6
- package/package.json +5 -3
package/dist/esm/feedback.js
CHANGED
|
@@ -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
|
|
9
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
return
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
54
|
-
|
|
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
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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(
|
|
131
|
-
|
|
132
|
-
|
|
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(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
|
174
|
-
React.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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
|
-
|
|
9
|
-
return
|
|
8
|
+
const t = useStrings();
|
|
9
|
+
return /* @__PURE__ */ React.createElement(
|
|
10
10
|
"div",
|
|
11
|
-
{
|
|
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 ?
|
|
17
|
-
props.optional ?
|
|
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 ?
|
|
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
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
return
|
|
43
|
+
const auto = uid(), id = props.id || auto;
|
|
44
|
+
const rest = omit(props, FIELD_KEYS);
|
|
45
|
+
return /* @__PURE__ */ React.createElement(
|
|
31
46
|
Field,
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
return
|
|
74
|
+
const auto = uid(), id = props.id || auto;
|
|
75
|
+
const rest = omit(props, FIELD_KEYS);
|
|
76
|
+
return /* @__PURE__ */ React.createElement(
|
|
54
77
|
Field,
|
|
55
|
-
{
|
|
56
|
-
h("textarea", Object.assign({ rows: 4 }, rest, {
|
|
57
|
-
ref,
|
|
78
|
+
{
|
|
58
79
|
id,
|
|
59
|
-
|
|
60
|
-
|
|
80
|
+
label: props.label,
|
|
81
|
+
hint: props.hint,
|
|
82
|
+
error: props.error,
|
|
61
83
|
required: props.required,
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return
|
|
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)
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
{
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
}),
|
|
91
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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 ?
|
|
109
|
-
|
|
110
|
-
"
|
|
111
|
-
{ className: cx("aura-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
"
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return
|
|
145
|
-
"
|
|
146
|
-
{
|
|
147
|
-
|
|
148
|
-
"button",
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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,
|