@jirawatpyk/aura-react 5.7.2 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/Alert.js CHANGED
@@ -1,27 +1,14 @@
1
1
  'use client';
2
2
  import * as React from "react";
3
- import { Icon } from "./Icon.js";
4
3
  import { IconButton } from "./IconButton.js";
5
- import { cx } from "./internal.js";
4
+ import { alertElement } from "./display.js";
6
5
  import { useStrings } from "./locale.js";
7
- const ALERT_ICON = {
8
- info: "info",
9
- success: "circle-check",
10
- warning: "triangle-alert",
11
- danger: "circle-alert"
12
- };
6
+ import { ALERT_ICON } from "./display.js";
13
7
  const Alert = React.forwardRef(function Alert2(props, ref) {
14
8
  const t = useStrings();
15
- const tone = props.tone || "info";
16
- return /* @__PURE__ */ React.createElement(
17
- "div",
18
- {
19
- ref,
20
- className: cx("aura-alert", "aura-alert--" + tone, props.className),
21
- role: tone === "danger" || tone === "warning" ? "alert" : "status"
22
- },
23
- /* @__PURE__ */ React.createElement(Icon, { name: ALERT_ICON[tone], className: "aura-alert__icon" }),
24
- /* @__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),
9
+ return alertElement(
10
+ props,
11
+ ref,
25
12
  props.onDismiss ? /* @__PURE__ */ React.createElement(IconButton, { icon: "x", label: t.dismiss, className: "aura-alert__close", onClick: props.onDismiss }) : null
26
13
  );
27
14
  });
package/dist/esm/Badge.js CHANGED
@@ -1,25 +1,8 @@
1
1
  'use client';
2
2
  import * as React from "react";
3
- import { Icon } from "./Icon.js";
4
- import { cx, omit, tone } from "./internal.js";
3
+ import { badgeElement } from "./display.js";
5
4
  const Badge = React.forwardRef(function Badge2(props, ref) {
6
- const rest = omit(props, ["tone", "variant", "icon", "className", "children"]);
7
- return /* @__PURE__ */ React.createElement(
8
- "span",
9
- {
10
- ...rest,
11
- ref,
12
- className: cx(
13
- "aura-badge",
14
- "aura-badge--" + tone(props.tone),
15
- props.variant === "solid" && "is-solid",
16
- props.variant === "outline" && "is-outline",
17
- props.className
18
- )
19
- },
20
- props.icon ? /* @__PURE__ */ React.createElement(Icon, { name: props.icon, size: 12 }) : null,
21
- props.children
22
- );
5
+ return badgeElement(props, ref);
23
6
  });
24
7
  export {
25
8
  Badge
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
  import * as React from "react";
3
- import { cx, omit } from "./internal.js";
3
+ import { omit } from "./internal.js";
4
+ import { buttonClass } from "./display.js";
4
5
  import { Icon } from "./Icon.js";
5
6
  import { useLinkComponent } from "./locale.js";
6
7
  function ButtonLink(props, ref, Link) {
@@ -28,13 +29,12 @@ function ButtonLink(props, ref, Link) {
28
29
  role: disabled ? "link" : void 0,
29
30
  "aria-disabled": disabled || void 0,
30
31
  tabIndex: disabled ? -1 : props.tabIndex,
31
- className: cx(
32
- "aura-btn",
33
- "aura-btn--" + variant,
34
- props.size === "sm" && "aura-btn--sm",
35
- props.fullWidth && "aura-btn--full",
36
- props.className
37
- ),
32
+ className: buttonClass({
33
+ variant,
34
+ size: props.size,
35
+ fullWidth: props.fullWidth,
36
+ className: props.className
37
+ }),
38
38
  onClick: disabled ? void 0 : props.onClick
39
39
  },
40
40
  props.icon ? /* @__PURE__ */ React.createElement(Icon, { name: props.icon }) : null,
@@ -69,14 +69,13 @@ const Button = React.forwardRef(
69
69
  ...rest,
70
70
  ref,
71
71
  type: props.type || "button",
72
- className: cx(
73
- "aura-btn",
74
- "aura-btn--" + variant,
75
- props.size === "sm" && "aura-btn--sm",
76
- props.fullWidth && "aura-btn--full",
77
- loading && "is-loading",
78
- props.className
79
- ),
72
+ className: buttonClass({
73
+ variant,
74
+ size: props.size,
75
+ fullWidth: props.fullWidth,
76
+ loading,
77
+ className: props.className
78
+ }),
80
79
  "aria-busy": loading || void 0,
81
80
  "aria-disabled": loading || void 0,
82
81
  onClick: loading ? function(e) {
package/dist/esm/Card.js CHANGED
@@ -1,25 +1,8 @@
1
1
  'use client';
2
2
  import * as React from "react";
3
- import { cx } from "./internal.js";
4
- const h = React.createElement;
3
+ import { cardElement } from "./display.js";
5
4
  const Card = React.forwardRef(function Card2(props, ref) {
6
- const creative = props.variant === "creative";
7
- return h(
8
- props.as || "section",
9
- {
10
- ref,
11
- className: cx(
12
- "aura-card",
13
- creative && "aura-card--creative",
14
- props.interactive && "is-interactive",
15
- props.className
16
- ),
17
- "aria-labelledby": props.title && props.titleId ? props.titleId : void 0
18
- },
19
- 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,
20
- props.children ? /* @__PURE__ */ React.createElement("div", { className: "aura-card__body" }, props.children) : null,
21
- props.footer ? /* @__PURE__ */ React.createElement("div", { className: "aura-card__foot" }, props.footer) : null
22
- );
5
+ return cardElement(props, ref);
23
6
  });
24
7
  export {
25
8
  Card
@@ -1,21 +1,8 @@
1
1
  'use client';
2
2
  import * as React from "react";
3
- import { Icon } from "./Icon.js";
4
- import { cx } from "./internal.js";
5
- const h = React.createElement;
3
+ import { emptyStateElement } from "./display.js";
6
4
  const EmptyState = React.forwardRef(function EmptyState2(props, ref) {
7
- const HT = "h" + (props.headingLevel || 3);
8
- return /* @__PURE__ */ React.createElement(
9
- "div",
10
- {
11
- ref,
12
- className: cx("aura-empty", props.size === "sm" && "is-sm", props.bordered && "is-bordered", props.className)
13
- },
14
- /* @__PURE__ */ React.createElement("span", { className: "aura-empty__icon", "aria-hidden": true }, /* @__PURE__ */ React.createElement(Icon, { name: props.icon || "inbox", size: props.size === "sm" ? "md" : "lg" })),
15
- /* @__PURE__ */ React.createElement(HT, { className: "aura-empty__title" }, props.title),
16
- props.description ? /* @__PURE__ */ React.createElement("p", { className: "aura-empty__text" }, props.description) : null,
17
- props.action ? /* @__PURE__ */ React.createElement("div", { className: "aura-empty__action" }, props.action) : null
18
- );
5
+ return emptyStateElement(props, ref);
19
6
  });
20
7
  export {
21
8
  EmptyState
@@ -37,14 +37,50 @@ const FormErrorSummary = React.forwardRef(
37
37
  const auto = uid(), id = props.id || auto;
38
38
  const list = items(props.errors);
39
39
  const box = React.useRef(null);
40
+ const keyed = props.focusKey !== void 0;
41
+ const lastKey = React.useRef(null), armed = React.useRef(false), hadErrors = React.useRef(false);
42
+ const has = list.length > 0;
40
43
  React.useEffect(
41
44
  function() {
42
- const has = list.length > 0;
43
- if (has && box.current) box.current.focus();
45
+ const appeared = has && !hadErrors.current;
46
+ hadErrors.current = has;
47
+ if (!keyed) {
48
+ lastKey.current = null;
49
+ if (appeared && box.current) box.current.focus();
50
+ return;
51
+ }
52
+ if (!lastKey.current) {
53
+ lastKey.current = { v: props.focusKey };
54
+ armed.current = has;
55
+ } else if (!Object.is(lastKey.current.v, props.focusKey)) {
56
+ lastKey.current = { v: props.focusKey };
57
+ armed.current = true;
58
+ }
59
+ if (armed.current && has && box.current) {
60
+ armed.current = false;
61
+ box.current.focus();
62
+ }
44
63
  },
45
- /* focus when errors first appear, and again whenever focusKey changes (each submit) */
46
64
  // eslint-disable-next-line react-hooks/exhaustive-deps
47
- [list.length > 0, props.focusKey]
65
+ [has, props.focusKey, keyed]
66
+ );
67
+ React.useEffect(
68
+ function() {
69
+ if (!keyed) return;
70
+ function disarm() {
71
+ armed.current = false;
72
+ }
73
+ const events = ["input", "change", "keydown", "pointerdown"];
74
+ events.forEach(function(n) {
75
+ document.addEventListener(n, disarm, true);
76
+ });
77
+ return function() {
78
+ events.forEach(function(n) {
79
+ document.removeEventListener(n, disarm, true);
80
+ });
81
+ };
82
+ },
83
+ [keyed]
48
84
  );
49
85
  if (!list.length) return null;
50
86
  return /* @__PURE__ */ React.createElement(
package/dist/esm/Icon.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import * as React from "react";
3
- import { cx } from "./internal.js";
3
+ import { cx } from "./classes.js";
4
4
  const h = React.createElement;
5
5
  const 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" }]], "sun": [["circle", { "cx": "12", "cy": "12", "r": "4" }], ["path", { "d": "M12 2v2" }], ["path", { "d": "M12 20v2" }], ["path", { "d": "m4.93 4.93 1.41 1.41" }], ["path", { "d": "m17.66 17.66 1.41 1.41" }], ["path", { "d": "M2 12h2" }], ["path", { "d": "M20 12h2" }], ["path", { "d": "m6.34 17.66-1.41 1.41" }], ["path", { "d": "m19.07 4.93-1.41 1.41" }]], "moon": [["path", { "d": "M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401" }]], "monitor": [["rect", { "width": "20", "height": "14", "x": "2", "y": "3", "rx": "2" }], ["line", { "x1": "8", "x2": "16", "y1": "21", "y2": "21" }], ["line", { "x1": "12", "x2": "12", "y1": "17", "y2": "21" }]], "panel-left-close": [["rect", { "width": "18", "height": "18", "x": "3", "y": "3", "rx": "2" }], ["path", { "d": "M9 3v18" }], ["path", { "d": "m16 15-3-3 3-3" }]], "panel-left-open": [["rect", { "width": "18", "height": "18", "x": "3", "y": "3", "rx": "2" }], ["path", { "d": "M9 3v18" }], ["path", { "d": "m14 9 3 3-3 3" }]], "server": [["rect", { "width": "20", "height": "8", "x": "2", "y": "2", "rx": "2", "ry": "2" }], ["rect", { "width": "20", "height": "8", "x": "2", "y": "14", "rx": "2", "ry": "2" }], ["line", { "x1": "6", "x2": "6.01", "y1": "6", "y2": "6" }], ["line", { "x1": "6", "x2": "6.01", "y1": "18", "y2": "18" }]], "globe": [["circle", { "cx": "12", "cy": "12", "r": "10" }], ["path", { "d": "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20" }], ["path", { "d": "M2 12h20" }]], "activity": [["path", { "d": "M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2" }]], "shield-alert": [["path", { "d": "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z" }], ["path", { "d": "M12 8v4" }], ["path", { "d": "M12 16h.01" }]], "phone": [["path", { "d": "M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384" }]], "wrench": [["path", { "d": "M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z" }]] };
6
6
  const SIZES = { sm: 16, md: 20, lg: 24 };
@@ -1,23 +1,13 @@
1
1
  'use client';
2
2
  import * as React from "react";
3
- import { cx } from "./internal.js";
4
- import { Icon } from "./Icon.js";
5
- const TONE_ICON = {
6
- neutral: "circle",
7
- progress: "circle-dot-dashed",
8
- ready: "circle-check",
9
- warning: "triangle-alert",
10
- blocked: "ban"
11
- };
12
- import { toneFor } from "./status.js";
13
- import { toneFor as toneFor2, statusTone, TONE_ORDER } from "./status.js";
3
+ import { statusPillElement } from "./display.js";
4
+ import { toneFor, statusTone, TONE_ORDER } from "./status.js";
14
5
  const StatusPill = React.forwardRef(function StatusPill2(props, ref) {
15
- const tone = props.tone || toneFor(props.children);
16
- return /* @__PURE__ */ React.createElement("span", { ref, className: cx("aura-pill", "aura-pill--" + tone, props.className) }, /* @__PURE__ */ React.createElement(Icon, { name: TONE_ICON[tone] || "circle", size: 12 }), props.children);
6
+ return statusPillElement(props, ref);
17
7
  });
18
8
  export {
19
9
  StatusPill,
20
10
  TONE_ORDER,
21
11
  statusTone,
22
- toneFor2 as toneFor
12
+ toneFor
23
13
  };
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("table", { ref, className: cx("aura-tbl", className), ...rest }, caption != null ? /* @__PURE__ */ React.createElement("caption", { id: capId, className: cx("aura-tbl__caption", captionHidden && "aura-sr-only") }, caption) : null, children)
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
- return React.createElement(tag, Object.assign({ ref, className: cx(cls, className) }, rest));
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
- return /* @__PURE__ */ React.createElement("tr", { ref, className: cx("aura-tbl__row", className), ...rest });
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
- return /* @__PURE__ */ React.createElement("th", { ref, scope: scope || "col", className: cellClass("aura-tbl__th", props), ...rest });
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
- return /* @__PURE__ */ React.createElement("td", { ref, className: cellClass("aura-tbl__td", props), ...rest });
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,
@@ -0,0 +1,20 @@
1
+ 'use client';
2
+ function cx() {
3
+ return Array.prototype.filter.call(arguments, Boolean).join(" ");
4
+ }
5
+ function omit(src, keys) {
6
+ const out = {};
7
+ for (const k in src)
8
+ if (Object.prototype.hasOwnProperty.call(src, k) && keys.indexOf(k) < 0)
9
+ out[k] = src[k];
10
+ return out;
11
+ }
12
+ const TONES = ["neutral", "accent", "success", "warning", "danger"];
13
+ function tone(t) {
14
+ return TONES.indexOf(t) >= 0 ? t : "neutral";
15
+ }
16
+ export {
17
+ cx,
18
+ omit,
19
+ tone
20
+ };
@@ -0,0 +1,145 @@
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
+ const h = React.createElement;
7
+ const ALERT_ICON = {
8
+ info: "info",
9
+ success: "circle-check",
10
+ warning: "triangle-alert",
11
+ danger: "circle-alert"
12
+ };
13
+ function alertElement(props, ref, close) {
14
+ const tone = props.tone || "info";
15
+ const rest = omit(props, ["tone", "title", "children", "action", "onDismiss", "className", "role", "icon"]);
16
+ return /* @__PURE__ */ React.createElement(
17
+ "div",
18
+ {
19
+ ...rest,
20
+ ref,
21
+ className: cx("aura-alert", "aura-alert--" + tone, props.className),
22
+ role: props.role || (tone === "danger" || tone === "warning" ? "alert" : "status")
23
+ },
24
+ /* @__PURE__ */ React.createElement(Icon, { name: props.icon || 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
+ close
27
+ );
28
+ }
29
+ function cardElement(props, ref) {
30
+ const creative = props.variant === "creative";
31
+ const rest = omit(props, [
32
+ "title",
33
+ "description",
34
+ "actions",
35
+ "footer",
36
+ "children",
37
+ "variant",
38
+ "headingLevel",
39
+ "interactive",
40
+ "as",
41
+ "className",
42
+ "titleId"
43
+ ]);
44
+ return h(
45
+ props.as || "section",
46
+ Object.assign({}, rest, {
47
+ ref,
48
+ className: cx(
49
+ "aura-card",
50
+ creative && "aura-card--creative",
51
+ props.interactive && "is-interactive",
52
+ props.className
53
+ ),
54
+ /* A titled card is labelled by its title; otherwise the caller's aria-labelledby stays (5.8). */
55
+ "aria-labelledby": props.title && props.titleId ? props.titleId : props["aria-labelledby"]
56
+ }),
57
+ 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,
58
+ props.children ? /* @__PURE__ */ React.createElement("div", { className: "aura-card__body" }, props.children) : null,
59
+ props.footer ? /* @__PURE__ */ React.createElement("div", { className: "aura-card__foot" }, props.footer) : null
60
+ );
61
+ }
62
+ const PILL_ICON = {
63
+ neutral: "circle",
64
+ progress: "circle-dot-dashed",
65
+ ready: "circle-check",
66
+ warning: "triangle-alert",
67
+ blocked: "ban"
68
+ };
69
+ function statusPillElement(props, ref) {
70
+ const tone = props.tone || toneFor(props.children);
71
+ const rest = omit(props, ["tone", "className", "children"]);
72
+ return /* @__PURE__ */ React.createElement("span", { ...rest, ref, className: cx("aura-pill", "aura-pill--" + tone, props.className) }, /* @__PURE__ */ React.createElement(Icon, { name: PILL_ICON[tone] || "circle", size: 12 }), props.children);
73
+ }
74
+ function badgeElement(props, ref) {
75
+ const rest = omit(props, ["tone", "variant", "icon", "className", "children"]);
76
+ return /* @__PURE__ */ React.createElement(
77
+ "span",
78
+ {
79
+ ...rest,
80
+ ref,
81
+ className: cx(
82
+ "aura-badge",
83
+ "aura-badge--" + badgeTone(props.tone),
84
+ props.variant === "solid" && "is-solid",
85
+ props.variant === "outline" && "is-outline",
86
+ props.className
87
+ )
88
+ },
89
+ props.icon ? /* @__PURE__ */ React.createElement(Icon, { name: props.icon, size: 12 }) : null,
90
+ props.children
91
+ );
92
+ }
93
+ function emptyStateElement(props, ref) {
94
+ const HT = "h" + (props.headingLevel || 3);
95
+ return /* @__PURE__ */ React.createElement(
96
+ "div",
97
+ {
98
+ ref,
99
+ className: cx("aura-empty", props.size === "sm" && "is-sm", props.bordered && "is-bordered", props.className)
100
+ },
101
+ /* @__PURE__ */ React.createElement("span", { className: "aura-empty__icon", "aria-hidden": true }, /* @__PURE__ */ React.createElement(Icon, { name: props.icon || "inbox", size: props.size === "sm" ? "md" : "lg" })),
102
+ /* @__PURE__ */ React.createElement(HT, { className: "aura-empty__title" }, props.title),
103
+ props.description ? /* @__PURE__ */ React.createElement("p", { className: "aura-empty__text" }, props.description) : null,
104
+ props.action ? /* @__PURE__ */ React.createElement("div", { className: "aura-empty__action" }, props.action) : null
105
+ );
106
+ }
107
+ function buttonClass(opts = {}) {
108
+ return cx(
109
+ "aura-btn",
110
+ "aura-btn--" + (opts.variant || "primary"),
111
+ opts.size === "sm" && "aura-btn--sm",
112
+ opts.fullWidth && "aura-btn--full",
113
+ opts.loading && "is-loading",
114
+ opts.className
115
+ );
116
+ }
117
+ function ServerAlert(props) {
118
+ return alertElement(props, void 0, null);
119
+ }
120
+ function ServerCard(props) {
121
+ return cardElement(props, void 0);
122
+ }
123
+ function ServerStatusPill(props) {
124
+ return statusPillElement(props, void 0);
125
+ }
126
+ function ServerBadge(props) {
127
+ return badgeElement(props, void 0);
128
+ }
129
+ function ServerEmptyState(props) {
130
+ return emptyStateElement(props, void 0);
131
+ }
132
+ export {
133
+ ALERT_ICON,
134
+ ServerAlert,
135
+ ServerBadge,
136
+ ServerCard,
137
+ ServerEmptyState,
138
+ ServerStatusPill,
139
+ alertElement,
140
+ badgeElement,
141
+ buttonClass,
142
+ cardElement,
143
+ emptyStateElement,
144
+ statusPillElement
145
+ };
package/dist/esm/index.js CHANGED
@@ -25,6 +25,7 @@ import { Tooltip } from "./Tooltip.js";
25
25
  import { Dialog, Drawer } from "./Dialog.js";
26
26
  import { DataTable } from "./DataTable.js";
27
27
  import { Card } from "./Card.js";
28
+ import { buttonClass } from "./display.js";
28
29
  import { Tabs } from "./Tabs.js";
29
30
  import { SideNav } from "./SideNav.js";
30
31
  import { Breadcrumb } from "./Breadcrumb.js";
@@ -127,6 +128,7 @@ export {
127
128
  Tr,
128
129
  scale as brandScale,
129
130
  breakpoints,
131
+ buttonClass,
130
132
  colorSchemeScript,
131
133
  defaultFilter as comboboxFilter,
132
134
  contrast,