@jirawatpyk/aura-react 5.7.3 → 5.9.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/README.md +40 -0
- package/dist/aura.bundle.js +1751 -1208
- package/dist/cjs/index.cjs +1751 -1208
- package/dist/esm/Accordion.js +2 -1
- package/dist/esm/Alert.js +7 -19
- package/dist/esm/AppShell.js +2 -1
- package/dist/esm/Badge.js +2 -19
- package/dist/esm/Breadcrumb.js +2 -1
- package/dist/esm/Button.js +17 -17
- package/dist/esm/Card.js +2 -19
- package/dist/esm/Checkbox.js +2 -1
- package/dist/esm/Combobox.js +7 -6
- package/dist/esm/Command.js +3 -2
- package/dist/esm/DataTable.js +35 -13
- package/dist/esm/DatePicker.js +8 -7
- package/dist/esm/Dialog.js +38 -5
- package/dist/esm/EmptyState.js +2 -15
- package/dist/esm/Field.js +2 -1
- package/dist/esm/FileUpload.js +4 -3
- package/dist/esm/FilterBar.js +3 -2
- package/dist/esm/FormErrorSummary.js +2 -1
- package/dist/esm/Icon.js +50 -31
- package/dist/esm/Menu.js +2 -1
- package/dist/esm/NumberField.js +3 -2
- package/dist/esm/Pagination.js +3 -2
- package/dist/esm/PasswordField.js +2 -1
- package/dist/esm/Popover.js +2 -1
- package/dist/esm/RadioGroup.js +2 -1
- package/dist/esm/Select.js +4 -3
- package/dist/esm/SideNav.js +3 -2
- package/dist/esm/Stat.js +8 -1
- package/dist/esm/StatusPill.js +4 -14
- package/dist/esm/Stepper.js +2 -1
- package/dist/esm/Table.js +104 -11
- package/dist/esm/Tabs.js +79 -9
- package/dist/esm/Tag.js +3 -2
- package/dist/esm/TimePicker.js +5 -4
- package/dist/esm/Toaster.js +3 -2
- package/dist/esm/classes.js +33 -0
- package/dist/esm/colorScheme.js +8 -1
- package/dist/esm/display.js +155 -0
- package/dist/esm/iconSvg.js +53 -0
- package/dist/esm/icons.js +531 -0
- package/dist/esm/index.js +4 -1
- package/dist/esm/internal.js +1 -27
- package/dist/esm/locale.js +7 -0
- package/dist/esm/strings.js +4 -245
- package/dist/esm/strings.sv.js +127 -0
- package/dist/esm/strings.th.js +127 -0
- package/dist/icons/index.cjs +613 -0
- package/dist/icons/index.d.cts +106 -0
- package/dist/icons/index.d.ts +106 -0
- package/dist/index.d.cts +69 -6
- package/dist/index.d.ts +69 -6
- package/dist/locales/sv.cjs +149 -0
- package/dist/locales/sv.d.cts +96 -0
- package/dist/locales/sv.d.ts +96 -0
- package/dist/locales/th.cjs +149 -0
- package/dist/locales/th.d.cts +96 -0
- package/dist/locales/th.d.ts +96 -0
- package/dist/server/index.cjs +618 -275
- package/dist/server/index.d.cts +141 -0
- package/dist/server/index.d.ts +141 -0
- package/dist/server/index.js +608 -275
- package/dist/styles.css +35 -0
- package/dist/styles.layer.css +35 -0
- package/package.json +35 -3
- package/scripts/aura-icons-codemod.mjs +345 -0
package/dist/esm/Table.js
CHANGED
|
@@ -1,8 +1,60 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { cx, uid, useIsoLayoutEffect } from "./internal.js";
|
|
3
|
+
import { cx, devWarnOnce, uid, useIsoLayoutEffect } from "./internal.js";
|
|
4
|
+
const StackLabels = React.createContext(null);
|
|
5
|
+
const ColumnIndex = React.createContext(-1);
|
|
6
|
+
function flat(children) {
|
|
7
|
+
const out = [];
|
|
8
|
+
React.Children.toArray(children).forEach(function(c) {
|
|
9
|
+
if (React.isValidElement(c) && c.type === React.Fragment)
|
|
10
|
+
out.push.apply(out, flat(c.props.children));
|
|
11
|
+
else out.push(c);
|
|
12
|
+
});
|
|
13
|
+
return out;
|
|
14
|
+
}
|
|
15
|
+
function text(node) {
|
|
16
|
+
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
17
|
+
if (Array.isArray(node)) {
|
|
18
|
+
const parts = node.map(text).filter(function(x) {
|
|
19
|
+
return x != null;
|
|
20
|
+
});
|
|
21
|
+
return parts.length ? parts.join("") : void 0;
|
|
22
|
+
}
|
|
23
|
+
if (React.isValidElement(node)) {
|
|
24
|
+
const p = node.props;
|
|
25
|
+
if (p["aria-hidden"] === true || p["aria-hidden"] === "true") return void 0;
|
|
26
|
+
return text(p.children);
|
|
27
|
+
}
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
function headerLabels(children) {
|
|
31
|
+
let out = [];
|
|
32
|
+
flat(children).forEach(function(c) {
|
|
33
|
+
if (out.length || !React.isValidElement(c) || c.type !== THead) return;
|
|
34
|
+
const row = flat(c.props.children).find(function(r) {
|
|
35
|
+
return React.isValidElement(r);
|
|
36
|
+
});
|
|
37
|
+
if (!row) return;
|
|
38
|
+
flat(row.props.children).forEach(function(cell) {
|
|
39
|
+
if (!React.isValidElement(cell)) return;
|
|
40
|
+
const p = cell.props;
|
|
41
|
+
const t = text(p.children);
|
|
42
|
+
const label = p.label != null ? p.label : t != null ? t.replace(/\s+/g, " ").trim() || void 0 : void 0;
|
|
43
|
+
const span = Math.max(1, Number(p.colSpan) || 1);
|
|
44
|
+
for (let i = 0; i < span; i++) out.push(label);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
4
49
|
const Table = React.forwardRef(function Table2(props, ref) {
|
|
5
|
-
const { caption, captionHidden, density, className, children, ...rest } = props;
|
|
50
|
+
const { caption, captionHidden, density, stackBelow, className, children, ...rest } = props;
|
|
51
|
+
const labels = stackBelow ? headerLabels(children) : null;
|
|
52
|
+
if (labels && !labels.length)
|
|
53
|
+
devWarnOnce(
|
|
54
|
+
"tbl-stack-labels",
|
|
55
|
+
"Table stackBelow: no THead > Tr > Th found among its children, so cells have no labels. Pass `label` on each Td."
|
|
56
|
+
);
|
|
57
|
+
const outer = React.useContext(StackLabels);
|
|
6
58
|
const capId = uid();
|
|
7
59
|
const wrap = React.useRef(null);
|
|
8
60
|
const sc = React.useState(false), scrolls = sc[0];
|
|
@@ -23,20 +75,34 @@ const Table = React.forwardRef(function Table2(props, ref) {
|
|
|
23
75
|
"div",
|
|
24
76
|
{
|
|
25
77
|
ref: wrap,
|
|
26
|
-
className: "aura-tbl-wrap",
|
|
78
|
+
className: cx("aura-tbl-wrap", stackBelow && "is-stackable"),
|
|
27
79
|
"data-density": density,
|
|
28
80
|
tabIndex: scrolls ? 0 : void 0,
|
|
29
81
|
role: scrolls && (caption != null || rest["aria-label"]) ? "region" : void 0,
|
|
30
82
|
"aria-labelledby": scrolls && caption != null ? capId : void 0,
|
|
31
83
|
"aria-label": scrolls && caption == null ? rest["aria-label"] : void 0
|
|
32
84
|
},
|
|
33
|
-
/* @__PURE__ */ React.createElement(
|
|
85
|
+
/* @__PURE__ */ React.createElement(
|
|
86
|
+
"table",
|
|
87
|
+
{
|
|
88
|
+
ref,
|
|
89
|
+
className: cx("aura-tbl", stackBelow && "aura-tbl--stack-" + stackBelow, className),
|
|
90
|
+
role: stackBelow ? "table" : void 0,
|
|
91
|
+
...rest
|
|
92
|
+
},
|
|
93
|
+
caption != null ? /* @__PURE__ */ React.createElement("caption", { id: capId, className: cx("aura-tbl__caption", captionHidden && "aura-sr-only") }, caption) : null,
|
|
94
|
+
labels ? /* @__PURE__ */ React.createElement(StackLabels.Provider, { value: labels }, children) : outer ? /* @__PURE__ */ React.createElement(StackLabels.Provider, { value: null }, children) : children
|
|
95
|
+
)
|
|
34
96
|
);
|
|
35
97
|
});
|
|
36
98
|
function section(tag, cls) {
|
|
37
99
|
const C = React.forwardRef(function TableSection(props, ref) {
|
|
38
100
|
const { className, ...rest } = props;
|
|
39
|
-
|
|
101
|
+
const stacked = React.useContext(StackLabels) != null;
|
|
102
|
+
return React.createElement(
|
|
103
|
+
tag,
|
|
104
|
+
Object.assign({ ref, className: cx(cls, className), role: stacked ? "rowgroup" : void 0 }, rest)
|
|
105
|
+
);
|
|
40
106
|
});
|
|
41
107
|
return C;
|
|
42
108
|
}
|
|
@@ -47,8 +113,14 @@ TBody.displayName = "TBody";
|
|
|
47
113
|
const TFoot = section("tfoot", "aura-tbl__foot");
|
|
48
114
|
TFoot.displayName = "TFoot";
|
|
49
115
|
const Tr = React.forwardRef(function Tr2(props, ref) {
|
|
50
|
-
const { className, ...rest } = props;
|
|
51
|
-
|
|
116
|
+
const { className, children, ...rest } = props;
|
|
117
|
+
const stacked = React.useContext(StackLabels) != null;
|
|
118
|
+
let col = 0;
|
|
119
|
+
return /* @__PURE__ */ React.createElement("tr", { ref, className: cx("aura-tbl__row", className), role: stacked ? "row" : void 0, ...rest }, stacked ? flat(children).map(function(c) {
|
|
120
|
+
const at = col;
|
|
121
|
+
if (React.isValidElement(c)) col += Math.max(1, Number(c.props.colSpan) || 1);
|
|
122
|
+
return /* @__PURE__ */ React.createElement(ColumnIndex.Provider, { key: React.isValidElement(c) && c.key != null ? c.key : at, value: at }, c);
|
|
123
|
+
}) : children);
|
|
52
124
|
});
|
|
53
125
|
function cellClass(base, p) {
|
|
54
126
|
const align = p.align || (p.numeric ? "end" : void 0);
|
|
@@ -62,12 +134,33 @@ function cellClass(base, p) {
|
|
|
62
134
|
);
|
|
63
135
|
}
|
|
64
136
|
const Th = React.forwardRef(function Th2(props, ref) {
|
|
65
|
-
const { align, numeric, mono, className, scope, ...rest } = props;
|
|
66
|
-
|
|
137
|
+
const { align, numeric, mono, className, scope, label, ...rest } = props;
|
|
138
|
+
const stacked = React.useContext(StackLabels) != null;
|
|
139
|
+
return /* @__PURE__ */ React.createElement(
|
|
140
|
+
"th",
|
|
141
|
+
{
|
|
142
|
+
ref,
|
|
143
|
+
scope: scope || "col",
|
|
144
|
+
className: cellClass("aura-tbl__th", props),
|
|
145
|
+
role: stacked ? scope === "row" ? "rowheader" : "columnheader" : void 0,
|
|
146
|
+
...rest
|
|
147
|
+
}
|
|
148
|
+
);
|
|
67
149
|
});
|
|
68
150
|
const Td = React.forwardRef(function Td2(props, ref) {
|
|
69
|
-
const { align, numeric, mono, className, scope, ...rest } = props;
|
|
70
|
-
|
|
151
|
+
const { align, numeric, mono, className, scope, label, ...rest } = props;
|
|
152
|
+
const labels = React.useContext(StackLabels), col = React.useContext(ColumnIndex);
|
|
153
|
+
const shown = labels ? label != null ? label : col >= 0 ? labels[col] : void 0 : void 0;
|
|
154
|
+
return /* @__PURE__ */ React.createElement(
|
|
155
|
+
"td",
|
|
156
|
+
{
|
|
157
|
+
ref,
|
|
158
|
+
className: cellClass("aura-tbl__td", props),
|
|
159
|
+
role: labels ? "cell" : void 0,
|
|
160
|
+
"data-label": shown || void 0,
|
|
161
|
+
...rest
|
|
162
|
+
}
|
|
163
|
+
);
|
|
71
164
|
});
|
|
72
165
|
export {
|
|
73
166
|
TBody,
|
package/dist/esm/Tabs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Icon } from "./Icon.js";
|
|
4
|
-
import { cx, uid, useMaybeControlled } from "./internal.js";
|
|
4
|
+
import { cx, devWarnOnce, omit, uid, useMaybeControlled } from "./internal.js";
|
|
5
5
|
import { useLinkComponent } from "./locale.js";
|
|
6
6
|
const Tabs = React.forwardRef(function Tabs2(props, ref) {
|
|
7
7
|
const items = props.tabs || [], base = uid();
|
|
@@ -22,6 +22,16 @@ const Tabs = React.forwardRef(function Tabs2(props, ref) {
|
|
|
22
22
|
return t.id === cur;
|
|
23
23
|
})[0] || firstOn || items[0];
|
|
24
24
|
const Link = useLinkComponent(props.linkComponent);
|
|
25
|
+
const manual = props.activation === "manual";
|
|
26
|
+
const [focusId, setFocusId] = React.useState(null);
|
|
27
|
+
items.forEach(function(t) {
|
|
28
|
+
const al = t.tabProps && t.tabProps["aria-label"];
|
|
29
|
+
if (al && al.toLowerCase().indexOf(String(t.label).toLowerCase()) !== 0)
|
|
30
|
+
devWarnOnce(
|
|
31
|
+
"tab-label-in-name",
|
|
32
|
+
'Tabs: tabProps aria-label "' + al + '" should start with the visible label "' + t.label + '" so voice control finds the tab (WCAG 2.5.3 Label in Name).'
|
|
33
|
+
);
|
|
34
|
+
});
|
|
25
35
|
if (asLinks)
|
|
26
36
|
return /* @__PURE__ */ React.createElement(
|
|
27
37
|
"nav",
|
|
@@ -37,14 +47,37 @@ const Tabs = React.forwardRef(function Tabs2(props, ref) {
|
|
|
37
47
|
t.label,
|
|
38
48
|
t.count != null ? /* @__PURE__ */ React.createElement("span", { key: "c", className: "aura-tab__count" }, t.count) : null
|
|
39
49
|
];
|
|
40
|
-
|
|
50
|
+
const own = omit(t.tabProps || {}, [
|
|
51
|
+
"type",
|
|
52
|
+
"disabled",
|
|
53
|
+
"form",
|
|
54
|
+
"formAction",
|
|
55
|
+
"formEncType",
|
|
56
|
+
"formMethod",
|
|
57
|
+
"formNoValidate",
|
|
58
|
+
"formTarget",
|
|
59
|
+
"name",
|
|
60
|
+
"value"
|
|
61
|
+
]);
|
|
62
|
+
return t.disabled ? /* @__PURE__ */ React.createElement(
|
|
63
|
+
"span",
|
|
64
|
+
{
|
|
65
|
+
...omit(own, ["onClick"]),
|
|
66
|
+
key: t.id,
|
|
67
|
+
className: cx("aura-tab is-disabled", own.className),
|
|
68
|
+
"aria-disabled": true
|
|
69
|
+
},
|
|
70
|
+
inner
|
|
71
|
+
) : /* @__PURE__ */ React.createElement(
|
|
41
72
|
Link,
|
|
42
73
|
{
|
|
74
|
+
...own,
|
|
43
75
|
key: t.id,
|
|
44
76
|
href: t.href,
|
|
45
|
-
className: cx("aura-tab", on && "is-active"),
|
|
77
|
+
className: cx("aura-tab", on && "is-active", own.className),
|
|
46
78
|
"aria-current": on ? "page" : void 0,
|
|
47
79
|
onClick: function(e) {
|
|
80
|
+
if (own.onClick) own.onClick(e);
|
|
48
81
|
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
|
|
49
82
|
st[1](t.id);
|
|
50
83
|
}
|
|
@@ -58,19 +91,28 @@ const Tabs = React.forwardRef(function Tabs2(props, ref) {
|
|
|
58
91
|
return !t2.disabled;
|
|
59
92
|
});
|
|
60
93
|
const t = enabled[(i + enabled.length) % enabled.length];
|
|
61
|
-
|
|
94
|
+
if (manual) setFocusId(t.id);
|
|
95
|
+
else st[1](t.id);
|
|
62
96
|
if (refs.current[t.id]) refs.current[t.id].focus();
|
|
63
97
|
}
|
|
98
|
+
const stop = manual && focusId && items.filter(function(t) {
|
|
99
|
+
return t.id === focusId && !t.disabled;
|
|
100
|
+
})[0] || current;
|
|
64
101
|
return /* @__PURE__ */ React.createElement("div", { ref, className: cx("aura-tabs", props.className) }, /* @__PURE__ */ React.createElement(
|
|
65
102
|
"div",
|
|
66
103
|
{
|
|
67
104
|
role: "tablist",
|
|
68
105
|
"aria-label": props.label,
|
|
69
106
|
className: "aura-tabs__list",
|
|
107
|
+
onBlur: manual ? function(e) {
|
|
108
|
+
if (!e.currentTarget.contains(e.relatedTarget)) setFocusId(null);
|
|
109
|
+
} : void 0,
|
|
70
110
|
onKeyDown: function(e) {
|
|
71
111
|
const enabled = items.filter(function(t) {
|
|
72
112
|
return !t.disabled;
|
|
73
|
-
}),
|
|
113
|
+
}), focused = enabled.filter(function(t) {
|
|
114
|
+
return refs.current[t.id] === e.target;
|
|
115
|
+
})[0], i = enabled.indexOf(focused || stop);
|
|
74
116
|
if (e.key === "ArrowRight") {
|
|
75
117
|
e.preventDefault();
|
|
76
118
|
go(i + 1);
|
|
@@ -88,22 +130,31 @@ const Tabs = React.forwardRef(function Tabs2(props, ref) {
|
|
|
88
130
|
},
|
|
89
131
|
items.map(function(t) {
|
|
90
132
|
const on = current && t.id === current.id;
|
|
133
|
+
const own = t.tabProps || {};
|
|
91
134
|
return /* @__PURE__ */ React.createElement(
|
|
92
135
|
"button",
|
|
93
136
|
{
|
|
137
|
+
...own,
|
|
94
138
|
key: t.id,
|
|
95
139
|
type: "button",
|
|
96
140
|
role: "tab",
|
|
97
141
|
id: base + "-tab-" + t.id,
|
|
98
142
|
"aria-selected": on,
|
|
99
143
|
"aria-controls": base + "-panel-" + t.id,
|
|
100
|
-
tabIndex:
|
|
144
|
+
tabIndex: stop && t.id === stop.id ? 0 : -1,
|
|
101
145
|
disabled: t.disabled,
|
|
102
146
|
ref: function(el) {
|
|
103
147
|
refs.current[t.id] = el;
|
|
104
148
|
},
|
|
105
|
-
className: cx("aura-tab", on && "is-active"),
|
|
106
|
-
|
|
149
|
+
className: cx("aura-tab", on && "is-active", own.className),
|
|
150
|
+
onFocus: manual ? function(e) {
|
|
151
|
+
if (own.onFocus) own.onFocus(e);
|
|
152
|
+
setFocusId(t.id);
|
|
153
|
+
} : own.onFocus,
|
|
154
|
+
onClick: function(e) {
|
|
155
|
+
if (own.onClick) own.onClick(e);
|
|
156
|
+
if (e.defaultPrevented) return;
|
|
157
|
+
if (manual && current && t.id === current.id) return;
|
|
107
158
|
st[1](t.id);
|
|
108
159
|
}
|
|
109
160
|
},
|
|
@@ -112,7 +163,26 @@ const Tabs = React.forwardRef(function Tabs2(props, ref) {
|
|
|
112
163
|
t.count != null ? /* @__PURE__ */ React.createElement("span", { className: "aura-tab__count" }, t.count) : null
|
|
113
164
|
);
|
|
114
165
|
})
|
|
115
|
-
),
|
|
166
|
+
), props.keepMounted ? (
|
|
167
|
+
/* 5.9: every panel stays in the DOM (same node across switches); the inactive ones are hidden. */
|
|
168
|
+
items.map(function(t) {
|
|
169
|
+
if (t.content === void 0) return null;
|
|
170
|
+
const on = current && t.id === current.id;
|
|
171
|
+
return /* @__PURE__ */ React.createElement(
|
|
172
|
+
"div",
|
|
173
|
+
{
|
|
174
|
+
key: t.id,
|
|
175
|
+
role: "tabpanel",
|
|
176
|
+
id: base + "-panel-" + t.id,
|
|
177
|
+
"aria-labelledby": base + "-tab-" + t.id,
|
|
178
|
+
tabIndex: 0,
|
|
179
|
+
hidden: !on,
|
|
180
|
+
className: "aura-tabs__panel"
|
|
181
|
+
},
|
|
182
|
+
t.content
|
|
183
|
+
);
|
|
184
|
+
})
|
|
185
|
+
) : current && current.content !== void 0 ? /* @__PURE__ */ React.createElement(
|
|
116
186
|
"div",
|
|
117
187
|
{
|
|
118
188
|
role: "tabpanel",
|
package/dist/esm/Tag.js
CHANGED
|
@@ -3,6 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import { Icon } from "./Icon.js";
|
|
4
4
|
import { cx, omit } from "./internal.js";
|
|
5
5
|
import { useStrings } from "./locale.js";
|
|
6
|
+
import { IconCheck, IconX } from "./icons.js";
|
|
6
7
|
const Tag = React.forwardRef(function Tag2(props, ref) {
|
|
7
8
|
const t = useStrings();
|
|
8
9
|
const selectable = props.onClick != null || props.selected != null;
|
|
@@ -22,7 +23,7 @@ const Tag = React.forwardRef(function Tag2(props, ref) {
|
|
|
22
23
|
disabled: props.disabled,
|
|
23
24
|
className: cx("aura-tag is-selectable", props.selected && "is-selected", props.className)
|
|
24
25
|
},
|
|
25
|
-
props.selected ? /* @__PURE__ */ React.createElement(Icon, { name:
|
|
26
|
+
props.selected ? /* @__PURE__ */ React.createElement(Icon, { name: /* @__PURE__ */ React.createElement(IconCheck, null), size: 14 }) : inner[0],
|
|
26
27
|
inner[1]
|
|
27
28
|
);
|
|
28
29
|
}
|
|
@@ -34,7 +35,7 @@ const Tag = React.forwardRef(function Tag2(props, ref) {
|
|
|
34
35
|
"aria-label": props.removeLabel || t.remove(typeof props.children === "string" ? props.children : ""),
|
|
35
36
|
onClick: props.onRemove
|
|
36
37
|
},
|
|
37
|
-
/* @__PURE__ */ React.createElement(Icon, { name:
|
|
38
|
+
/* @__PURE__ */ React.createElement(Icon, { name: /* @__PURE__ */ React.createElement(IconX, null), size: 12 })
|
|
38
39
|
) : null);
|
|
39
40
|
});
|
|
40
41
|
export {
|
package/dist/esm/TimePicker.js
CHANGED
|
@@ -5,6 +5,7 @@ import { cx, uid, useMaybeControlled, useMounted, useIsoLayoutEffect, useMergedR
|
|
|
5
5
|
import { useStrings } from "./locale.js";
|
|
6
6
|
import { Icon } from "./Icon.js";
|
|
7
7
|
import { Field } from "./Field.js";
|
|
8
|
+
import { IconCheck, IconChevronDown, IconClock, IconX } from "./icons.js";
|
|
8
9
|
function pad(n) {
|
|
9
10
|
return (n < 10 ? "0" : "") + n;
|
|
10
11
|
}
|
|
@@ -220,7 +221,7 @@ const TimePicker = React.forwardRef(function TimePicker2(props, ref) {
|
|
|
220
221
|
}
|
|
221
222
|
},
|
|
222
223
|
/* @__PURE__ */ React.createElement("span", { className: "aura-combo__label" }, s),
|
|
223
|
-
sel ? /* @__PURE__ */ React.createElement(Icon, { name:
|
|
224
|
+
sel ? /* @__PURE__ */ React.createElement(Icon, { name: /* @__PURE__ */ React.createElement(IconCheck, null), className: "aura-combo__check" }) : null
|
|
224
225
|
);
|
|
225
226
|
}))),
|
|
226
227
|
document.body
|
|
@@ -237,7 +238,7 @@ const TimePicker = React.forwardRef(function TimePicker2(props, ref) {
|
|
|
237
238
|
disabled: props.disabled,
|
|
238
239
|
className: props.className
|
|
239
240
|
},
|
|
240
|
-
/* @__PURE__ */ React.createElement("div", { ref: boxRef, className: cx("aura-input aura-combo aura-time has-icon", open && "is-open") }, /* @__PURE__ */ React.createElement(Icon, { name:
|
|
241
|
+
/* @__PURE__ */ React.createElement("div", { ref: boxRef, className: cx("aura-input aura-combo aura-time has-icon", open && "is-open") }, /* @__PURE__ */ React.createElement(Icon, { name: /* @__PURE__ */ React.createElement(IconClock, null), className: "aura-input__icon" }), /* @__PURE__ */ React.createElement(
|
|
241
242
|
"input",
|
|
242
243
|
{
|
|
243
244
|
ref: inputMerged,
|
|
@@ -290,7 +291,7 @@ const TimePicker = React.forwardRef(function TimePicker2(props, ref) {
|
|
|
290
291
|
if (inputRef.current) inputRef.current.focus();
|
|
291
292
|
}
|
|
292
293
|
},
|
|
293
|
-
/* @__PURE__ */ React.createElement(Icon, { name:
|
|
294
|
+
/* @__PURE__ */ React.createElement(Icon, { name: /* @__PURE__ */ React.createElement(IconX, null) })
|
|
294
295
|
) : null, /* @__PURE__ */ React.createElement(
|
|
295
296
|
"button",
|
|
296
297
|
{
|
|
@@ -309,7 +310,7 @@ const TimePicker = React.forwardRef(function TimePicker2(props, ref) {
|
|
|
309
310
|
}
|
|
310
311
|
}
|
|
311
312
|
},
|
|
312
|
-
/* @__PURE__ */ React.createElement(Icon, { name:
|
|
313
|
+
/* @__PURE__ */ React.createElement(Icon, { name: /* @__PURE__ */ React.createElement(IconChevronDown, null) })
|
|
313
314
|
)),
|
|
314
315
|
list
|
|
315
316
|
);
|
package/dist/esm/Toaster.js
CHANGED
|
@@ -6,6 +6,7 @@ import { IconButton } from "./IconButton.js";
|
|
|
6
6
|
import { cx, plainClick, useIsoLayoutEffect, useMounted } from "./internal.js";
|
|
7
7
|
import { useLinkComponent, useStrings } from "./locale.js";
|
|
8
8
|
import { createPortal } from "react-dom";
|
|
9
|
+
import { IconInfo, IconLoaderCircle, IconX } from "./icons.js";
|
|
9
10
|
const MAX_VISIBLE = 3;
|
|
10
11
|
const toastState = {
|
|
11
12
|
list: [],
|
|
@@ -179,7 +180,7 @@ function ToastItem(props) {
|
|
|
179
180
|
/* @__PURE__ */ React.createElement(
|
|
180
181
|
Icon,
|
|
181
182
|
{
|
|
182
|
-
name: t.loading ?
|
|
183
|
+
name: t.loading ? /* @__PURE__ */ React.createElement(IconLoaderCircle, null) : React.createElement(ALERT_ICON[t.tone] || IconInfo),
|
|
183
184
|
className: cx("aura-toast__icon", t.loading && "aura-spin")
|
|
184
185
|
}
|
|
185
186
|
),
|
|
@@ -213,7 +214,7 @@ function ToastItem(props) {
|
|
|
213
214
|
/* @__PURE__ */ React.createElement(
|
|
214
215
|
IconButton,
|
|
215
216
|
{
|
|
216
|
-
icon:
|
|
217
|
+
icon: /* @__PURE__ */ React.createElement(IconX, null),
|
|
217
218
|
label: str.dismissToast,
|
|
218
219
|
className: "aura-toast__close",
|
|
219
220
|
onClick: function() {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function cx() {
|
|
2
|
+
return Array.prototype.filter.call(arguments, Boolean).join(" ");
|
|
3
|
+
}
|
|
4
|
+
function omit(src, keys) {
|
|
5
|
+
const out = {};
|
|
6
|
+
for (const k in src)
|
|
7
|
+
if (Object.prototype.hasOwnProperty.call(src, k) && keys.indexOf(k) < 0)
|
|
8
|
+
out[k] = src[k];
|
|
9
|
+
return out;
|
|
10
|
+
}
|
|
11
|
+
const TONES = ["neutral", "accent", "success", "warning", "danger"];
|
|
12
|
+
function tone(t) {
|
|
13
|
+
return TONES.indexOf(t) >= 0 ? t : "neutral";
|
|
14
|
+
}
|
|
15
|
+
const warned = {};
|
|
16
|
+
function devWarnOnce(key, message) {
|
|
17
|
+
if (warned[key]) return;
|
|
18
|
+
let dev = false;
|
|
19
|
+
try {
|
|
20
|
+
dev = true;
|
|
21
|
+
} catch (e) {
|
|
22
|
+
dev = false;
|
|
23
|
+
}
|
|
24
|
+
if (!dev) return;
|
|
25
|
+
warned[key] = true;
|
|
26
|
+
console.warn("[AURA] " + message);
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
cx,
|
|
30
|
+
devWarnOnce,
|
|
31
|
+
omit,
|
|
32
|
+
tone
|
|
33
|
+
};
|
package/dist/esm/colorScheme.js
CHANGED
|
@@ -3,6 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import { useStrings } from "./locale.js";
|
|
4
4
|
import { IconButton } from "./IconButton.js";
|
|
5
5
|
import { DropdownMenu } from "./DropdownMenu.js";
|
|
6
|
+
import { IconMoon, IconSun } from "./icons.js";
|
|
6
7
|
import { DEFAULT_KEY, SCHEMES, EVENT, valid, colorSchemeScript } from "./colorSchemeScript.js";
|
|
7
8
|
function ColorSchemeScript(props) {
|
|
8
9
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -86,7 +87,13 @@ function ColorSchemeToggle(props) {
|
|
|
86
87
|
DropdownMenu,
|
|
87
88
|
{
|
|
88
89
|
label,
|
|
89
|
-
trigger: /* @__PURE__ */ React.createElement(
|
|
90
|
+
trigger: /* @__PURE__ */ React.createElement(
|
|
91
|
+
IconButton,
|
|
92
|
+
{
|
|
93
|
+
icon: cs.resolved === "dark" ? /* @__PURE__ */ React.createElement(IconMoon, null) : /* @__PURE__ */ React.createElement(IconSun, null),
|
|
94
|
+
label: label + ": " + names[cs.scheme]
|
|
95
|
+
}
|
|
96
|
+
),
|
|
90
97
|
items: SCHEMES.map(function(s) {
|
|
91
98
|
return {
|
|
92
99
|
label: names[s],
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Icon } from "./Icon.js";
|
|
4
|
+
import { cx, omit, tone as badgeTone } from "./classes.js";
|
|
5
|
+
import { toneFor } from "./status.js";
|
|
6
|
+
import {
|
|
7
|
+
IconBan,
|
|
8
|
+
IconCircle,
|
|
9
|
+
IconCircleAlert,
|
|
10
|
+
IconCircleCheck,
|
|
11
|
+
IconCircleDotDashed,
|
|
12
|
+
IconInbox,
|
|
13
|
+
IconInfo,
|
|
14
|
+
IconTriangleAlert
|
|
15
|
+
} from "./icons.js";
|
|
16
|
+
const h = React.createElement;
|
|
17
|
+
const ALERT_ICON = {
|
|
18
|
+
info: IconInfo,
|
|
19
|
+
success: IconCircleCheck,
|
|
20
|
+
warning: IconTriangleAlert,
|
|
21
|
+
danger: IconCircleAlert
|
|
22
|
+
};
|
|
23
|
+
function alertElement(props, ref, close) {
|
|
24
|
+
const tone = props.tone || "info";
|
|
25
|
+
const rest = omit(props, ["tone", "title", "children", "action", "onDismiss", "className", "role", "icon"]);
|
|
26
|
+
return /* @__PURE__ */ React.createElement(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
...rest,
|
|
30
|
+
ref,
|
|
31
|
+
className: cx("aura-alert", "aura-alert--" + tone, props.className),
|
|
32
|
+
role: props.role || (tone === "danger" || tone === "warning" ? "alert" : "status")
|
|
33
|
+
},
|
|
34
|
+
/* @__PURE__ */ React.createElement(Icon, { name: props.icon || h(ALERT_ICON[tone]), className: "aura-alert__icon" }),
|
|
35
|
+
/* @__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),
|
|
36
|
+
close
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function cardElement(props, ref) {
|
|
40
|
+
const creative = props.variant === "creative";
|
|
41
|
+
const rest = omit(props, [
|
|
42
|
+
"title",
|
|
43
|
+
"description",
|
|
44
|
+
"actions",
|
|
45
|
+
"footer",
|
|
46
|
+
"children",
|
|
47
|
+
"variant",
|
|
48
|
+
"headingLevel",
|
|
49
|
+
"interactive",
|
|
50
|
+
"as",
|
|
51
|
+
"className",
|
|
52
|
+
"titleId"
|
|
53
|
+
]);
|
|
54
|
+
return h(
|
|
55
|
+
props.as || "section",
|
|
56
|
+
Object.assign({}, rest, {
|
|
57
|
+
ref,
|
|
58
|
+
className: cx(
|
|
59
|
+
"aura-card",
|
|
60
|
+
creative && "aura-card--creative",
|
|
61
|
+
props.interactive && "is-interactive",
|
|
62
|
+
props.className
|
|
63
|
+
),
|
|
64
|
+
/* A titled card is labelled by its title; otherwise the caller's aria-labelledby stays (5.8). */
|
|
65
|
+
"aria-labelledby": props.title && props.titleId ? props.titleId : props["aria-labelledby"]
|
|
66
|
+
}),
|
|
67
|
+
props.title || props.actions ? /* @__PURE__ */ React.createElement("div", { className: "aura-card__head" }, /* @__PURE__ */ React.createElement("div", { className: "aura-card__heading" }, props.title ? h("h" + (props.headingLevel || 3), { className: "aura-card__title", id: props.titleId }, props.title) : null, props.description ? /* @__PURE__ */ React.createElement("p", { className: "aura-card__desc" }, props.description) : null), props.actions ? /* @__PURE__ */ React.createElement("div", { className: "aura-card__actions" }, props.actions) : null) : null,
|
|
68
|
+
props.children ? /* @__PURE__ */ React.createElement("div", { className: "aura-card__body" }, props.children) : null,
|
|
69
|
+
props.footer ? /* @__PURE__ */ React.createElement("div", { className: "aura-card__foot" }, props.footer) : null
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
const PILL_ICON = {
|
|
73
|
+
neutral: IconCircle,
|
|
74
|
+
progress: IconCircleDotDashed,
|
|
75
|
+
ready: IconCircleCheck,
|
|
76
|
+
warning: IconTriangleAlert,
|
|
77
|
+
blocked: IconBan
|
|
78
|
+
};
|
|
79
|
+
function statusPillElement(props, ref) {
|
|
80
|
+
const tone = props.tone || toneFor(props.children);
|
|
81
|
+
const rest = omit(props, ["tone", "className", "children"]);
|
|
82
|
+
return /* @__PURE__ */ React.createElement("span", { ...rest, ref, className: cx("aura-pill", "aura-pill--" + tone, props.className) }, /* @__PURE__ */ React.createElement(Icon, { name: h(PILL_ICON[tone] || IconCircle), size: 12 }), props.children);
|
|
83
|
+
}
|
|
84
|
+
function badgeElement(props, ref) {
|
|
85
|
+
const rest = omit(props, ["tone", "variant", "icon", "className", "children"]);
|
|
86
|
+
return /* @__PURE__ */ React.createElement(
|
|
87
|
+
"span",
|
|
88
|
+
{
|
|
89
|
+
...rest,
|
|
90
|
+
ref,
|
|
91
|
+
className: cx(
|
|
92
|
+
"aura-badge",
|
|
93
|
+
"aura-badge--" + badgeTone(props.tone),
|
|
94
|
+
props.variant === "solid" && "is-solid",
|
|
95
|
+
props.variant === "outline" && "is-outline",
|
|
96
|
+
props.className
|
|
97
|
+
)
|
|
98
|
+
},
|
|
99
|
+
props.icon ? /* @__PURE__ */ React.createElement(Icon, { name: props.icon, size: 12 }) : null,
|
|
100
|
+
props.children
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
function emptyStateElement(props, ref) {
|
|
104
|
+
const HT = "h" + (props.headingLevel || 3);
|
|
105
|
+
return /* @__PURE__ */ React.createElement(
|
|
106
|
+
"div",
|
|
107
|
+
{
|
|
108
|
+
ref,
|
|
109
|
+
className: cx("aura-empty", props.size === "sm" && "is-sm", props.bordered && "is-bordered", props.className)
|
|
110
|
+
},
|
|
111
|
+
/* @__PURE__ */ React.createElement("span", { className: "aura-empty__icon", "aria-hidden": true }, /* @__PURE__ */ React.createElement(Icon, { name: props.icon || /* @__PURE__ */ React.createElement(IconInbox, null), size: props.size === "sm" ? "md" : "lg" })),
|
|
112
|
+
/* @__PURE__ */ React.createElement(HT, { className: "aura-empty__title" }, props.title),
|
|
113
|
+
props.description ? /* @__PURE__ */ React.createElement("p", { className: "aura-empty__text" }, props.description) : null,
|
|
114
|
+
props.action ? /* @__PURE__ */ React.createElement("div", { className: "aura-empty__action" }, props.action) : null
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
function buttonClass(opts = {}) {
|
|
118
|
+
return cx(
|
|
119
|
+
"aura-btn",
|
|
120
|
+
"aura-btn--" + (opts.variant || "primary"),
|
|
121
|
+
opts.size === "sm" && "aura-btn--sm",
|
|
122
|
+
opts.fullWidth && "aura-btn--full",
|
|
123
|
+
opts.loading && "is-loading",
|
|
124
|
+
opts.className
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
function ServerAlert(props) {
|
|
128
|
+
return alertElement(props, void 0, null);
|
|
129
|
+
}
|
|
130
|
+
function ServerCard(props) {
|
|
131
|
+
return cardElement(props, void 0);
|
|
132
|
+
}
|
|
133
|
+
function ServerStatusPill(props) {
|
|
134
|
+
return statusPillElement(props, void 0);
|
|
135
|
+
}
|
|
136
|
+
function ServerBadge(props) {
|
|
137
|
+
return badgeElement(props, void 0);
|
|
138
|
+
}
|
|
139
|
+
function ServerEmptyState(props) {
|
|
140
|
+
return emptyStateElement(props, void 0);
|
|
141
|
+
}
|
|
142
|
+
export {
|
|
143
|
+
ALERT_ICON,
|
|
144
|
+
ServerAlert,
|
|
145
|
+
ServerBadge,
|
|
146
|
+
ServerCard,
|
|
147
|
+
ServerEmptyState,
|
|
148
|
+
ServerStatusPill,
|
|
149
|
+
alertElement,
|
|
150
|
+
badgeElement,
|
|
151
|
+
buttonClass,
|
|
152
|
+
cardElement,
|
|
153
|
+
emptyStateElement,
|
|
154
|
+
statusPillElement
|
|
155
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cx } from "./classes.js";
|
|
3
|
+
const h = React.createElement;
|
|
4
|
+
const SIZES = { sm: 16, md: 20, lg: 24 };
|
|
5
|
+
function iconSize(size) {
|
|
6
|
+
return SIZES[size] || size || 16;
|
|
7
|
+
}
|
|
8
|
+
function iconSvg(shapes, props, ref) {
|
|
9
|
+
const size = iconSize(props.size);
|
|
10
|
+
const a11y = props.label ? { role: "img", "aria-label": props.label } : { "aria-hidden": true, focusable: "false" };
|
|
11
|
+
return /* @__PURE__ */ React.createElement(
|
|
12
|
+
"svg",
|
|
13
|
+
{
|
|
14
|
+
ref,
|
|
15
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
16
|
+
width: size,
|
|
17
|
+
height: size,
|
|
18
|
+
viewBox: "0 0 24 24",
|
|
19
|
+
fill: "none",
|
|
20
|
+
stroke: "currentColor",
|
|
21
|
+
strokeWidth: props.strokeWidth || 2,
|
|
22
|
+
strokeLinecap: "round",
|
|
23
|
+
strokeLinejoin: "round",
|
|
24
|
+
className: cx("aura-icon", props.className),
|
|
25
|
+
...a11y
|
|
26
|
+
},
|
|
27
|
+
shapes.map(function(s, i) {
|
|
28
|
+
const attrs = { key: i };
|
|
29
|
+
for (const k in s[1]) attrs[k === "stroke-width" ? "strokeWidth" : k] = s[1][k];
|
|
30
|
+
return h(s[0], attrs);
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function defineIcon(name, shapes) {
|
|
35
|
+
const C = React.forwardRef(function AuraIcon(props, ref) {
|
|
36
|
+
return iconSvg(shapes, props, ref);
|
|
37
|
+
});
|
|
38
|
+
C.displayName = "Icon" + name.split("-").map(function(p) {
|
|
39
|
+
return p.charAt(0).toUpperCase() + p.slice(1);
|
|
40
|
+
}).join("");
|
|
41
|
+
return Object.assign(C, { auraShapes: shapes, iconName: name });
|
|
42
|
+
}
|
|
43
|
+
function shapesOf(el) {
|
|
44
|
+
if (!React.isValidElement(el)) return null;
|
|
45
|
+
const t = el.type;
|
|
46
|
+
return typeof t !== "string" && t && t.auraShapes || null;
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
defineIcon,
|
|
50
|
+
iconSize,
|
|
51
|
+
iconSvg,
|
|
52
|
+
shapesOf
|
|
53
|
+
};
|