@jirawatpyk/aura-react 4.4.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.
@@ -0,0 +1,38 @@
1
+ 'use client';
2
+ import * as React from "react";
3
+ import { Menu } from "./Menu.js";
4
+ import { useMergedRef } from "./internal.js";
5
+ const h = React.createElement;
6
+ const DropdownMenu = React.forwardRef(function DropdownMenu2(props, ref) {
7
+ var st = React.useState(null), anchor = st[0], setAnchor = st[1];
8
+ var wrap = React.useRef(null), wrapMerged = useMergedRef(ref, wrap);
9
+ var child = React.Children.only(props.trigger);
10
+ function toggle(e) {
11
+ if (child.props.onClick) child.props.onClick(e);
12
+ var el = wrap.current && (wrap.current.querySelector('button, [role="button"], a') || wrap.current);
13
+ setAnchor(anchor ? null : el);
14
+ }
15
+ function onKeyDown(e) {
16
+ if ((e.key === "ArrowDown" || e.key === "ArrowUp") && !anchor) {
17
+ e.preventDefault();
18
+ setAnchor(wrap.current.querySelector('button, [role="button"], a') || wrap.current);
19
+ }
20
+ }
21
+ return h(
22
+ "span",
23
+ { ref: wrapMerged, className: "aura-dropdown", onKeyDown },
24
+ React.cloneElement(child, { onClick: toggle, "aria-haspopup": "menu", "aria-expanded": anchor ? true : false }),
25
+ anchor ? h(Menu, {
26
+ anchor,
27
+ label: props.label,
28
+ items: props.items,
29
+ onClose: function(restore) {
30
+ setAnchor(null);
31
+ if (restore && anchor.focus) anchor.focus();
32
+ }
33
+ }) : null
34
+ );
35
+ });
36
+ export {
37
+ DropdownMenu
38
+ };
@@ -0,0 +1,173 @@
1
+ 'use client';
2
+ import * as React from "react";
3
+ import { cx, uid, useMaybeControlled, useMergedRef } from "./internal.js";
4
+ import { useStrings } from "./locale.js";
5
+ import { Icon } from "./Icon.js";
6
+ import { IconButton } from "./IconButton.js";
7
+ import { Field } from "./forms.js";
8
+ const h = React.createElement;
9
+ function formatBytes(n) {
10
+ if (n == null) return "";
11
+ if (n < 1024) return n + " B";
12
+ var u = ["KB", "MB", "GB"], i = -1;
13
+ do {
14
+ n /= 1024;
15
+ i++;
16
+ } while (n >= 1024 && i < u.length - 1);
17
+ return (n >= 10 || Math.round(n) === n ? Math.round(n) : n.toFixed(1)) + " " + u[i];
18
+ }
19
+ function matches(file, accept) {
20
+ if (!accept) return true;
21
+ var name = (file.name || "").toLowerCase(), type = (file.type || "").toLowerCase();
22
+ return accept.split(",").some(function(a) {
23
+ a = a.trim().toLowerCase();
24
+ if (!a) return false;
25
+ if (a[0] === ".") return name.slice(-a.length) === a;
26
+ if (a.slice(-2) === "/*") return type.indexOf(a.slice(0, -1)) === 0;
27
+ return type === a;
28
+ });
29
+ }
30
+ function describeAccept(accept, t) {
31
+ if (!accept) return "";
32
+ return accept.split(",").map(function(a) {
33
+ a = a.trim();
34
+ if (a === "image/*") return t.images;
35
+ if (a === "application/pdf") return "PDF";
36
+ return a.replace(/^\./, "").toUpperCase();
37
+ }).filter(function(x, i, arr) {
38
+ return arr.indexOf(x) === i;
39
+ }).join(", ");
40
+ }
41
+ var seq = 0;
42
+ const FileUpload = React.forwardRef(function FileUpload2(props, ref) {
43
+ var t = useStrings();
44
+ var auto = uid(), id = props.id || auto;
45
+ var st = useMaybeControlled(props.value, props.defaultValue || [], props.onChange);
46
+ var items = st[0] || [];
47
+ var dragState = React.useState(false), over = dragState[0];
48
+ var inputRef = React.useRef(null), inputMerged = useMergedRef(ref, inputRef);
49
+ var urls = React.useRef({});
50
+ var maxFiles = props.multiple ? props.maxFiles : 1;
51
+ var note = t.accepts(describeAccept(props.accept, t), props.maxSize ? formatBytes(props.maxSize) : "");
52
+ React.useEffect(function() {
53
+ return function() {
54
+ Object.keys(urls.current).forEach(function(k) {
55
+ URL.revokeObjectURL(urls.current[k]);
56
+ });
57
+ };
58
+ }, []);
59
+ function thumb(it) {
60
+ if (!it.file || !/^image\//.test(it.type || "") || typeof URL === "undefined" || !URL.createObjectURL) return null;
61
+ if (!urls.current[it.id]) urls.current[it.id] = URL.createObjectURL(it.file);
62
+ return urls.current[it.id];
63
+ }
64
+ function add(list) {
65
+ var files = Array.prototype.slice.call(list || []);
66
+ if (!files.length || props.disabled) return;
67
+ var keep = props.multiple ? items.slice() : [];
68
+ var room = maxFiles ? maxFiles - keep.filter(function(i) {
69
+ return !i.error;
70
+ }).length : Infinity;
71
+ files.forEach(function(f) {
72
+ var err = null;
73
+ if (!matches(f, props.accept)) err = t.fileWrongType;
74
+ else if (props.maxSize && f.size > props.maxSize) err = t.fileTooBig(formatBytes(props.maxSize));
75
+ else if (room <= 0) err = t.tooManyFiles(maxFiles);
76
+ else room--;
77
+ keep.push({ id: "f" + ++seq, file: f, name: f.name, size: f.size, type: f.type, status: err ? "error" : "ready", error: err || void 0 });
78
+ });
79
+ st[1](keep);
80
+ }
81
+ function remove(it) {
82
+ if (urls.current[it.id]) {
83
+ URL.revokeObjectURL(urls.current[it.id]);
84
+ delete urls.current[it.id];
85
+ }
86
+ st[1](items.filter(function(x) {
87
+ return x.id !== it.id;
88
+ }));
89
+ if (props.onRemove) props.onRemove(it);
90
+ if (inputRef.current) inputRef.current.focus();
91
+ }
92
+ var error = props.error;
93
+ return h(
94
+ Field,
95
+ { id, label: props.label, hint: props.hint, error, required: props.required, optional: props.optional, disabled: props.disabled, className: props.className },
96
+ h(
97
+ "div",
98
+ {
99
+ className: cx("aura-upload", over && "is-over", props.disabled && "is-disabled", error && "is-invalid"),
100
+ onClick: function(e) {
101
+ if (!props.disabled && e.target !== inputRef.current && inputRef.current) inputRef.current.click();
102
+ },
103
+ onDragOver: function(e) {
104
+ if (props.disabled) return;
105
+ e.preventDefault();
106
+ if (!over) dragState[1](true);
107
+ },
108
+ onDragLeave: function(e) {
109
+ if (!e.currentTarget.contains(e.relatedTarget)) dragState[1](false);
110
+ },
111
+ onDrop: function(e) {
112
+ e.preventDefault();
113
+ dragState[1](false);
114
+ add(e.dataTransfer && e.dataTransfer.files);
115
+ }
116
+ },
117
+ h(Icon, { name: "cloud-upload", size: "lg", className: "aura-upload__icon" }),
118
+ h("span", { className: "aura-upload__text" }, t.dropFiles, " "),
119
+ /* The real input: visually hidden, still the labelled, focusable control (keyboard and screen readers use it). */
120
+ h("input", {
121
+ ref: inputMerged,
122
+ id,
123
+ type: "file",
124
+ className: "aura-upload__input",
125
+ accept: props.accept,
126
+ multiple: !!props.multiple,
127
+ disabled: props.disabled,
128
+ name: props.name,
129
+ required: props.required && !items.some(function(i) {
130
+ return !i.error;
131
+ }),
132
+ "aria-invalid": error ? true : void 0,
133
+ "aria-describedby": [error ? id + "-error" : props.hint ? id + "-hint" : null, note ? id + "-note" : null].filter(Boolean).join(" ") || void 0,
134
+ onChange: function(e) {
135
+ add(e.target.files);
136
+ e.target.value = "";
137
+ }
138
+ }),
139
+ h("span", { className: "aura-upload__browse", "aria-hidden": true }, props.multiple ? t.browse : t.browseOne),
140
+ note ? h("span", { className: "aura-upload__note", id: id + "-note" }, note) : null
141
+ ),
142
+ items.length ? h("ul", { className: "aura-upload__list", "aria-live": "polite" }, items.map(function(it) {
143
+ var src = thumb(it);
144
+ return h(
145
+ "li",
146
+ { key: it.id, className: cx("aura-upload__item", it.error && "is-error") },
147
+ src ? h("img", { className: "aura-upload__thumb", src, alt: "" }) : h("span", { className: "aura-upload__thumb is-icon", "aria-hidden": true }, h(Icon, { name: /^image\//.test(it.type || "") ? "image" : "file", size: "md" })),
148
+ h(
149
+ "span",
150
+ { className: "aura-upload__meta" },
151
+ h("span", { className: "aura-upload__name" }, it.name),
152
+ h(
153
+ "span",
154
+ { className: "aura-upload__sub" },
155
+ it.error ? h(React.Fragment, null, h(Icon, { name: "circle-alert", size: 12 }), it.error) : it.status === "uploading" ? t.uploading + (it.progress != null ? " " + Math.round(it.progress) + "%" : "") : it.status === "done" ? h(React.Fragment, null, h(Icon, { name: "circle-check", size: 12 }), formatBytes(it.size)) : formatBytes(it.size)
156
+ ),
157
+ it.status === "uploading" ? h(
158
+ "span",
159
+ { className: "aura-upload__bar", role: "progressbar", "aria-label": it.name, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": it.progress != null ? Math.round(it.progress) : void 0 },
160
+ h("span", { style: { width: (it.progress || 0) + "%" } })
161
+ ) : null
162
+ ),
163
+ h(IconButton, { icon: "x", label: t.remove(it.name), onClick: function() {
164
+ remove(it);
165
+ } })
166
+ );
167
+ })) : null
168
+ );
169
+ });
170
+ export {
171
+ FileUpload,
172
+ formatBytes
173
+ };
@@ -0,0 +1,35 @@
1
+ 'use client';
2
+ import * as React from "react";
3
+ import { cx } from "./internal.js";
4
+ const h = React.createElement;
5
+ var ICONS = { "check": [["path", { "d": "M20 6 9 17l-5-5" }]], "x": [["path", { "d": "M18 6 6 18" }], ["path", { "d": "m6 6 12 12" }]], "plus": [["path", { "d": "M5 12h14" }], ["path", { "d": "M12 5v14" }]], "minus": [["path", { "d": "M5 12h14" }]], "search": [["path", { "d": "m21 21-4.34-4.34" }], ["circle", { "cx": "11", "cy": "11", "r": "8" }]], "chevron-down": [["path", { "d": "m6 9 6 6 6-6" }]], "chevron-up": [["path", { "d": "m18 15-6-6-6 6" }]], "chevron-left": [["path", { "d": "m15 18-6-6 6-6" }]], "chevron-right": [["path", { "d": "m9 18 6-6-6-6" }]], "arrow-right": [["path", { "d": "M5 12h14" }], ["path", { "d": "m12 5 7 7-7 7" }]], "arrow-up-right": [["path", { "d": "M7 7h10v10" }], ["path", { "d": "M7 17 17 7" }]], "arrow-up-down": [["path", { "d": "m21 16-4 4-4-4" }], ["path", { "d": "M17 20V4" }], ["path", { "d": "m3 8 4-4 4 4" }], ["path", { "d": "M7 4v16" }]], "loader-circle": [["path", { "d": "M21 12a9 9 0 1 1-6.219-8.56" }]], "circle-alert": [["circle", { "cx": "12", "cy": "12", "r": "10" }], ["line", { "x1": "12", "x2": "12", "y1": "8", "y2": "12" }], ["line", { "x1": "12", "x2": "12.01", "y1": "16", "y2": "16" }]], "circle-check": [["circle", { "cx": "12", "cy": "12", "r": "10" }], ["path", { "d": "m16 9-5.5 5.5L8 12" }]], "info": [["circle", { "cx": "12", "cy": "12", "r": "10" }], ["path", { "d": "M12 16v-4" }], ["path", { "d": "M12 8h.01" }]], "triangle-alert": [["path", { "d": "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" }], ["path", { "d": "M12 9v4" }], ["path", { "d": "M12 17h.01" }]], "settings": [["path", { "d": "M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915" }], ["circle", { "cx": "12", "cy": "12", "r": "3" }]], "user": [["path", { "d": "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" }], ["circle", { "cx": "12", "cy": "7", "r": "4" }]], "users": [["path", { "d": "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" }], ["path", { "d": "M16 3.128a4 4 0 0 1 0 7.744" }], ["path", { "d": "M22 21v-2a4 4 0 0 0-3-3.87" }], ["circle", { "cx": "9", "cy": "7", "r": "4" }]], "filter": [["path", { "d": "M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z" }]], "ellipsis": [["circle", { "cx": "12", "cy": "12", "r": "1" }], ["circle", { "cx": "19", "cy": "12", "r": "1" }], ["circle", { "cx": "5", "cy": "12", "r": "1" }]], "external-link": [["path", { "d": "M15 3h6v6" }], ["path", { "d": "M10 14 21 3" }], ["path", { "d": "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }]], "copy": [["rect", { "width": "14", "height": "14", "x": "8", "y": "8", "rx": "2", "ry": "2" }], ["path", { "d": "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" }]], "trash-2": [["path", { "d": "M10 11v6" }], ["path", { "d": "M14 11v6" }], ["path", { "d": "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }], ["path", { "d": "M3 6h18" }], ["path", { "d": "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }]], "pencil": [["path", { "d": "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" }], ["path", { "d": "m15 5 4 4" }]], "download": [["path", { "d": "M12 15V3" }], ["path", { "d": "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }], ["path", { "d": "m7 10 5 5 5-5" }]], "upload": [["path", { "d": "M12 3v12" }], ["path", { "d": "m17 8-5-5-5 5" }], ["path", { "d": "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }]], "calendar": [["path", { "d": "M8 2v3" }], ["path", { "d": "M16 2v3" }], ["rect", { "x": "3", "y": "3", "width": "18", "height": "18", "rx": "2" }], ["path", { "d": "M3 9h18" }]], "bell": [["path", { "d": "M10.268 21a2 2 0 0 0 3.464 0" }], ["path", { "d": "M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326" }]], "menu": [["path", { "d": "M4 5h16" }], ["path", { "d": "M4 12h16" }], ["path", { "d": "M4 19h16" }]], "eye": [["path", { "d": "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" }], ["circle", { "cx": "12", "cy": "12", "r": "3" }]], "log-out": [["path", { "d": "m16 17 5-5-5-5" }], ["path", { "d": "M21 12H9" }], ["path", { "d": "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }]], "circle": [["circle", { "cx": "12", "cy": "12", "r": "10" }]], "circle-dot-dashed": [["path", { "d": "M10.1 2.18a9.93 9.93 0 0 1 3.8 0" }], ["path", { "d": "M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7" }], ["path", { "d": "M21.82 10.1a9.93 9.93 0 0 1 0 3.8" }], ["path", { "d": "M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69" }], ["path", { "d": "M13.9 21.82a9.94 9.94 0 0 1-3.8 0" }], ["path", { "d": "M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7" }], ["path", { "d": "M2.18 13.9a9.93 9.93 0 0 1 0-3.8" }], ["path", { "d": "M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69" }], ["circle", { "cx": "12", "cy": "12", "r": "1" }]], "ban": [["circle", { "cx": "12", "cy": "12", "r": "10" }], ["path", { "d": "M4.929 4.929 19.07 19.071" }]], "arrow-up": [["path", { "d": "m5 12 7-7 7 7" }], ["path", { "d": "M12 19V5" }]], "arrow-down": [["path", { "d": "M12 5v14" }], ["path", { "d": "m19 12-7 7-7-7" }]], "inbox": [["polyline", { "points": "22 12 16 12 14 15 10 15 8 12 2 12" }], ["path", { "d": "M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" }]], "pin": [["path", { "d": "M12 17v5" }], ["path", { "d": "M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z" }]], "pin-off": [["path", { "d": "M12 17v5" }], ["path", { "d": "M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89" }], ["path", { "d": "m2 2 20 20" }], ["path", { "d": "M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11" }]], "eye-off": [["path", { "d": "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49" }], ["path", { "d": "M14.084 14.158a3 3 0 0 1-4.242-4.242" }], ["path", { "d": "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143" }], ["path", { "d": "m2 2 20 20" }]], "columns-3": [["rect", { "width": "18", "height": "18", "x": "3", "y": "3", "rx": "2" }], ["path", { "d": "M9 3v18" }], ["path", { "d": "M15 3v18" }]], "arrow-left": [["path", { "d": "m12 19-7-7 7-7" }], ["path", { "d": "M19 12H5" }]], "rotate-ccw": [["path", { "d": "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }], ["path", { "d": "M3 3v5h5" }]], "house": [["path", { "d": "M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8" }], ["path", { "d": "M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" }]], "layout-dashboard": [["rect", { "width": "7", "height": "9", "x": "3", "y": "3", "rx": "1" }], ["rect", { "width": "7", "height": "5", "x": "14", "y": "3", "rx": "1" }], ["rect", { "width": "7", "height": "9", "x": "14", "y": "12", "rx": "1" }], ["rect", { "width": "7", "height": "5", "x": "3", "y": "16", "rx": "1" }]], "folder": [["path", { "d": "M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" }]], "chart-column": [["path", { "d": "M3 3v16a2 2 0 0 0 2 2h16" }], ["path", { "d": "M18 17V9" }], ["path", { "d": "M13 17V5" }], ["path", { "d": "M8 17v-3" }]], "file-text": [["path", { "d": "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }], ["path", { "d": "M14 2v5a1 1 0 0 0 1 1h5" }], ["path", { "d": "M10 9H8" }], ["path", { "d": "M16 13H8" }], ["path", { "d": "M16 17H8" }]], "mail": [["path", { "d": "m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7" }], ["rect", { "x": "2", "y": "4", "width": "20", "height": "16", "rx": "2" }]], "lock": [["rect", { "width": "18", "height": "11", "x": "3", "y": "11", "rx": "2", "ry": "2" }], ["path", { "d": "M7 11V7a5 5 0 0 1 10 0v4" }]], "clock": [["circle", { "cx": "12", "cy": "12", "r": "10" }], ["path", { "d": "M12 6v6l4 2" }]], "trending-up": [["path", { "d": "M16 7h6v6" }], ["path", { "d": "m22 7-8.5 8.5-5-5L2 17" }]], "trending-down": [["path", { "d": "M16 17h6v-6" }], ["path", { "d": "m22 17-8.5-8.5-5 5L2 7" }]], "image": [["rect", { "width": "18", "height": "18", "x": "3", "y": "3", "rx": "2", "ry": "2" }], ["circle", { "cx": "9", "cy": "9", "r": "2" }], ["path", { "d": "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" }]], "paperclip": [["path", { "d": "m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551" }]], "cloud-upload": [["path", { "d": "M12 13v8" }], ["path", { "d": "M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242" }], ["path", { "d": "m8 17 4-4 4 4" }]], "file": [["path", { "d": "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }], ["path", { "d": "M14 2v5a1 1 0 0 0 1 1h5" }]] };
6
+ var SIZES = { sm: 16, md: 20, lg: 24 };
7
+ const Icon = React.forwardRef(function Icon2(props, ref) {
8
+ var shapes = ICONS[props.name];
9
+ if (!shapes) return null;
10
+ var size = SIZES[props.size] || props.size || 16;
11
+ var a11y = props.label ? { role: "img", "aria-label": props.label } : { "aria-hidden": true, focusable: "false" };
12
+ return h("svg", Object.assign({
13
+ ref,
14
+ xmlns: "http://www.w3.org/2000/svg",
15
+ width: size,
16
+ height: size,
17
+ viewBox: "0 0 24 24",
18
+ fill: "none",
19
+ stroke: "currentColor",
20
+ strokeWidth: props.strokeWidth || 2,
21
+ strokeLinecap: "round",
22
+ strokeLinejoin: "round",
23
+ className: cx("aura-icon", props.className)
24
+ }, a11y), shapes.map(function(s, i) {
25
+ var attrs = { key: i };
26
+ for (var k in s[1]) attrs[k === "stroke-width" ? "strokeWidth" : k] = s[1][k];
27
+ return h(s[0], attrs);
28
+ }));
29
+ });
30
+ const iconNames = Object.keys(ICONS);
31
+ export {
32
+ ICONS,
33
+ Icon,
34
+ iconNames
35
+ };
@@ -0,0 +1,18 @@
1
+ 'use client';
2
+ import * as React from "react";
3
+ import { cx, omit } from "./internal.js";
4
+ import { Icon } from "./Icon.js";
5
+ const h = React.createElement;
6
+ const IconButton = React.forwardRef(function IconButton2(props, ref) {
7
+ var rest = omit(props, ["icon", "label", "className", "size"]);
8
+ return h("button", Object.assign({}, rest, {
9
+ ref,
10
+ type: props.type || "button",
11
+ "aria-label": props.label,
12
+ title: props.label,
13
+ className: cx("aura-icon-btn", props.className)
14
+ }), h(Icon, { name: props.icon, size: props.size || "sm" }));
15
+ });
16
+ export {
17
+ IconButton
18
+ };
@@ -0,0 +1,98 @@
1
+ 'use client';
2
+ import * as React from "react";
3
+ import { createPortal } from "react-dom";
4
+ import { cx, useIsoLayoutEffect, useMounted, useMergedRef } from "./internal.js";
5
+ import { Icon } from "./Icon.js";
6
+ const h = React.createElement;
7
+ const Menu = React.forwardRef(function Menu2(props, ref) {
8
+ var own = React.useRef(null), merged = useMergedRef(ref, own);
9
+ var posState = React.useState(null);
10
+ var pos = posState[0], setPos = posState[1];
11
+ var items = props.items || [];
12
+ var mounted = useMounted();
13
+ useIsoLayoutEffect(function() {
14
+ var a = props.anchor, m = own.current;
15
+ if (!a || !m) return;
16
+ var r = a.getBoundingClientRect(), mh = m.offsetHeight, mw = m.offsetWidth;
17
+ var top = r.bottom + 4;
18
+ if (top + mh > window.innerHeight - 8 && r.top - mh - 4 > 8) top = r.top - mh - 4;
19
+ var left = Math.max(8, Math.min(r.right - mw, window.innerWidth - mw - 8));
20
+ setPos({ top, left });
21
+ }, [props.anchor, mounted]);
22
+ React.useEffect(function() {
23
+ if (!mounted) return;
24
+ var first = own.current && own.current.querySelector('[role^="menuitem"]:not([disabled])');
25
+ if (first && props.autoFocus !== false) first.focus();
26
+ function outside(e) {
27
+ if (own.current && !own.current.contains(e.target) && !(props.anchor && props.anchor.contains(e.target))) props.onClose(false);
28
+ }
29
+ function onScroll(e) {
30
+ if (own.current && !own.current.contains(e.target)) props.onClose(false);
31
+ }
32
+ document.addEventListener("pointerdown", outside, true);
33
+ window.addEventListener("scroll", onScroll, true);
34
+ window.addEventListener("resize", onScroll);
35
+ return function() {
36
+ document.removeEventListener("pointerdown", outside, true);
37
+ window.removeEventListener("scroll", onScroll, true);
38
+ window.removeEventListener("resize", onScroll);
39
+ };
40
+ }, [mounted]);
41
+ function onKeyDown(e) {
42
+ var list = Array.prototype.slice.call(own.current.querySelectorAll('[role^="menuitem"]:not([disabled])'));
43
+ var i = list.indexOf(document.activeElement);
44
+ if (e.key === "ArrowDown") {
45
+ e.preventDefault();
46
+ list[(i + 1) % list.length].focus();
47
+ } else if (e.key === "ArrowUp") {
48
+ e.preventDefault();
49
+ list[(i - 1 + list.length) % list.length].focus();
50
+ } else if (e.key === "Home") {
51
+ e.preventDefault();
52
+ list[0].focus();
53
+ } else if (e.key === "End") {
54
+ e.preventDefault();
55
+ list[list.length - 1].focus();
56
+ } else if (e.key === "Escape") {
57
+ e.preventDefault();
58
+ props.onClose(true);
59
+ } else if (e.key === "Tab") {
60
+ props.onClose(true);
61
+ }
62
+ e.stopPropagation();
63
+ }
64
+ var el = h("div", {
65
+ ref: merged,
66
+ role: "menu",
67
+ "aria-label": props.label,
68
+ className: "aura-menu",
69
+ onKeyDown,
70
+ style: { top: pos ? pos.top : -9999, left: pos ? pos.left : -9999 }
71
+ }, items.map(function(it, i) {
72
+ if (it.separator) return h("div", { key: "s" + i, role: "separator", className: "aura-menu__sep" });
73
+ var isCheck = it.checked !== void 0;
74
+ return h(
75
+ "button",
76
+ {
77
+ key: i,
78
+ type: "button",
79
+ tabIndex: -1,
80
+ disabled: it.disabled,
81
+ role: isCheck ? "menuitemcheckbox" : "menuitem",
82
+ "aria-checked": isCheck ? !!it.checked : void 0,
83
+ className: "aura-menu__item",
84
+ onClick: function() {
85
+ it.onSelect();
86
+ if (!it.keepOpen) props.onClose(true);
87
+ }
88
+ },
89
+ isCheck ? h("span", { className: cx("aura-menu__check", it.checked && "is-on") }, it.checked ? h(Icon, { name: "check", size: 12, strokeWidth: 3 }) : null) : it.icon ? h(Icon, { name: it.icon }) : h("span", { className: "aura-menu__blank" }),
90
+ h("span", { className: "aura-menu__label" }, it.label),
91
+ it.hint ? h("span", { className: "aura-menu__hint" }, it.hint) : null
92
+ );
93
+ }));
94
+ return mounted ? createPortal(el, document.body) : null;
95
+ });
96
+ export {
97
+ Menu
98
+ };
@@ -0,0 +1,45 @@
1
+ 'use client';
2
+ import * as React from "react";
3
+ import { cx } from "./internal.js";
4
+ import { Icon } from "./Icon.js";
5
+ const h = React.createElement;
6
+ const Stat = React.forwardRef(function Stat2(props, ref) {
7
+ var ch = props.change;
8
+ var dir = ch && (ch.direction || "flat");
9
+ var tone = ch && (ch.tone || (dir === "up" ? "positive" : dir === "down" ? "negative" : "neutral"));
10
+ var Tag = props.href ? "a" : props.onClick ? "button" : "div";
11
+ var interactive = Tag !== "div";
12
+ return h(
13
+ Tag,
14
+ {
15
+ ref,
16
+ className: cx("aura-stat", interactive && "is-interactive", props.loading && "is-loading", props.className),
17
+ href: props.href,
18
+ onClick: props.onClick,
19
+ type: Tag === "button" ? "button" : void 0,
20
+ "aria-busy": props.loading || void 0
21
+ },
22
+ h(
23
+ "span",
24
+ { className: "aura-stat__head" },
25
+ h("span", { className: "aura-stat__label" }, props.label),
26
+ props.icon ? h("span", { className: "aura-stat__icon" }, h(Icon, { name: props.icon })) : null
27
+ ),
28
+ props.loading ? h("span", { className: "aura-stat__value" }, h("span", { className: "aura-skel aura-stat__skel" })) : h("span", { className: "aura-stat__value" }, props.value, props.unit ? h("span", { className: "aura-stat__unit" }, props.unit) : null),
29
+ ch && !props.loading || props.caption ? h(
30
+ "span",
31
+ { className: "aura-stat__foot" },
32
+ ch && !props.loading ? h(
33
+ "span",
34
+ { className: cx("aura-stat__change", "is-" + tone) },
35
+ h(Icon, { name: dir === "up" ? "trending-up" : dir === "down" ? "trending-down" : "minus", size: 14 }),
36
+ h("span", null, ch.value)
37
+ ) : null,
38
+ ch && ch.label && !props.loading ? h("span", { className: "aura-stat__caption" }, ch.label) : null,
39
+ props.caption ? h("span", { className: "aura-stat__caption" }, props.caption) : null
40
+ ) : null
41
+ );
42
+ });
43
+ export {
44
+ Stat
45
+ };
@@ -0,0 +1,32 @@
1
+ 'use client';
2
+ import * as React from "react";
3
+ import { cx } from "./internal.js";
4
+ import { Icon } from "./Icon.js";
5
+ const h = React.createElement;
6
+ var TONE_ICON = { neutral: "circle", progress: "circle-dot-dashed", ready: "circle-check", blocked: "ban" };
7
+ var TONE_WORDS = {
8
+ ready: ["ready", "done", "complete", "completed", "approved", "live", "passed"],
9
+ progress: ["in progress", "in review", "review", "syncing", "running", "pending"],
10
+ blocked: ["blocked", "failed", "error", "rejected", "on hold", "cancelled"]
11
+ };
12
+ function toneFor(status) {
13
+ var s = String(status == null ? "" : status).trim().toLowerCase();
14
+ for (var t in TONE_WORDS) if (TONE_WORDS[t].indexOf(s) >= 0) return t;
15
+ return "neutral";
16
+ }
17
+ var TONE_ORDER = { neutral: 0, progress: 1, ready: 2, blocked: 3 };
18
+ const StatusPill = React.forwardRef(function StatusPill2(props, ref) {
19
+ var tone = props.tone || toneFor(props.children);
20
+ return h(
21
+ "span",
22
+ { ref, className: cx("aura-pill", "aura-pill--" + tone, props.className) },
23
+ h(Icon, { name: TONE_ICON[tone] || "circle", size: 12 }),
24
+ props.children
25
+ );
26
+ });
27
+ export {
28
+ StatusPill,
29
+ TONE_ORDER,
30
+ toneFor as statusTone,
31
+ toneFor
32
+ };
@@ -0,0 +1,22 @@
1
+ 'use client';
2
+ import * as React from "react";
3
+ import { cx, omit } from "./internal.js";
4
+ const h = React.createElement;
5
+ const Surface = React.forwardRef(function Surface2(props, ref) {
6
+ var t = props.texture || "mesh";
7
+ var rest = omit(props, ["texture", "className", "children", "as"]);
8
+ return h(props.as || "div", Object.assign({}, rest, {
9
+ ref,
10
+ /* Textures stay light in every theme, so everything on them uses the light tokens. */
11
+ "data-theme": "light",
12
+ className: cx(
13
+ "aura-surface",
14
+ (t === "mesh" || t === "mesh-grain") && "aura-mesh",
15
+ (t === "grain" || t === "mesh-grain") && "aura-grain",
16
+ props.className
17
+ )
18
+ }), props.children);
19
+ });
20
+ export {
21
+ Surface
22
+ };
@@ -0,0 +1,13 @@
1
+ 'use client';
2
+ import * as React from "react";
3
+ import { createTheme } from "./theme.js";
4
+ const h = React.createElement;
5
+ function ThemeStyle(props) {
6
+ var css = React.useMemo(function() {
7
+ return createTheme({ brand: props.brand, signal: props.signal, primary: props.primary, name: props.name }).css(props.selector);
8
+ }, [props.brand, props.signal, props.primary, props.name, props.selector]);
9
+ return h("style", { "data-aura-theme": props.name || props.brand, dangerouslySetInnerHTML: { __html: css } });
10
+ }
11
+ export {
12
+ ThemeStyle
13
+ };