@jirawatpyk/aura-react 5.8.0 → 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.
Files changed (63) hide show
  1. package/README.md +27 -0
  2. package/dist/aura.bundle.js +1485 -1085
  3. package/dist/cjs/index.cjs +1485 -1085
  4. package/dist/esm/Accordion.js +2 -1
  5. package/dist/esm/Alert.js +2 -1
  6. package/dist/esm/AppShell.js +2 -1
  7. package/dist/esm/Breadcrumb.js +2 -1
  8. package/dist/esm/Button.js +2 -1
  9. package/dist/esm/Checkbox.js +2 -1
  10. package/dist/esm/Combobox.js +7 -6
  11. package/dist/esm/Command.js +3 -2
  12. package/dist/esm/DataTable.js +35 -13
  13. package/dist/esm/DatePicker.js +8 -7
  14. package/dist/esm/Dialog.js +38 -5
  15. package/dist/esm/Field.js +2 -1
  16. package/dist/esm/FileUpload.js +4 -3
  17. package/dist/esm/FilterBar.js +3 -2
  18. package/dist/esm/FormErrorSummary.js +2 -1
  19. package/dist/esm/Icon.js +50 -31
  20. package/dist/esm/Menu.js +2 -1
  21. package/dist/esm/NumberField.js +3 -2
  22. package/dist/esm/Pagination.js +3 -2
  23. package/dist/esm/PasswordField.js +2 -1
  24. package/dist/esm/Popover.js +2 -1
  25. package/dist/esm/RadioGroup.js +2 -1
  26. package/dist/esm/Select.js +4 -3
  27. package/dist/esm/SideNav.js +3 -2
  28. package/dist/esm/Stat.js +8 -1
  29. package/dist/esm/Stepper.js +2 -1
  30. package/dist/esm/Tabs.js +79 -9
  31. package/dist/esm/Tag.js +3 -2
  32. package/dist/esm/TimePicker.js +5 -4
  33. package/dist/esm/Toaster.js +3 -2
  34. package/dist/esm/classes.js +14 -1
  35. package/dist/esm/colorScheme.js +8 -1
  36. package/dist/esm/display.js +22 -12
  37. package/dist/esm/iconSvg.js +53 -0
  38. package/dist/esm/icons.js +531 -0
  39. package/dist/esm/index.js +2 -1
  40. package/dist/esm/internal.js +1 -14
  41. package/dist/esm/locale.js +7 -0
  42. package/dist/esm/strings.js +4 -245
  43. package/dist/esm/strings.sv.js +127 -0
  44. package/dist/esm/strings.th.js +127 -0
  45. package/dist/icons/index.cjs +613 -0
  46. package/dist/icons/index.d.cts +106 -0
  47. package/dist/icons/index.d.ts +106 -0
  48. package/dist/index.d.cts +44 -2
  49. package/dist/index.d.ts +44 -2
  50. package/dist/locales/sv.cjs +149 -0
  51. package/dist/locales/sv.d.cts +96 -0
  52. package/dist/locales/sv.d.ts +96 -0
  53. package/dist/locales/th.cjs +149 -0
  54. package/dist/locales/th.d.cts +96 -0
  55. package/dist/locales/th.d.ts +96 -0
  56. package/dist/server/index.cjs +445 -314
  57. package/dist/server/index.d.cts +24 -0
  58. package/dist/server/index.d.ts +24 -0
  59. package/dist/server/index.js +445 -314
  60. package/dist/styles.css +1 -0
  61. package/dist/styles.layer.css +1 -0
  62. package/package.json +35 -3
  63. package/scripts/aura-icons-codemod.mjs +345 -0
@@ -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: "check", className: "aura-combo__check" }) : null
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: "clock", className: "aura-input__icon" }), /* @__PURE__ */ React.createElement(
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: "x" })
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: "chevron-down" })
313
+ /* @__PURE__ */ React.createElement(Icon, { name: /* @__PURE__ */ React.createElement(IconChevronDown, null) })
313
314
  )),
314
315
  list
315
316
  );
@@ -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 ? "loader-circle" : ALERT_ICON[t.tone] || "info",
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: "x",
217
+ icon: /* @__PURE__ */ React.createElement(IconX, null),
217
218
  label: str.dismissToast,
218
219
  className: "aura-toast__close",
219
220
  onClick: function() {
@@ -1,4 +1,3 @@
1
- 'use client';
2
1
  function cx() {
3
2
  return Array.prototype.filter.call(arguments, Boolean).join(" ");
4
3
  }
@@ -13,8 +12,22 @@ const TONES = ["neutral", "accent", "success", "warning", "danger"];
13
12
  function tone(t) {
14
13
  return TONES.indexOf(t) >= 0 ? t : "neutral";
15
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
+ }
16
28
  export {
17
29
  cx,
30
+ devWarnOnce,
18
31
  omit,
19
32
  tone
20
33
  };
@@ -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(IconButton, { icon: cs.resolved === "dark" ? "moon" : "sun", label: label + ": " + names[cs.scheme] }),
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],
@@ -3,12 +3,22 @@ import * as React from "react";
3
3
  import { Icon } from "./Icon.js";
4
4
  import { cx, omit, tone as badgeTone } from "./classes.js";
5
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";
6
16
  const h = React.createElement;
7
17
  const ALERT_ICON = {
8
- info: "info",
9
- success: "circle-check",
10
- warning: "triangle-alert",
11
- danger: "circle-alert"
18
+ info: IconInfo,
19
+ success: IconCircleCheck,
20
+ warning: IconTriangleAlert,
21
+ danger: IconCircleAlert
12
22
  };
13
23
  function alertElement(props, ref, close) {
14
24
  const tone = props.tone || "info";
@@ -21,7 +31,7 @@ function alertElement(props, ref, close) {
21
31
  className: cx("aura-alert", "aura-alert--" + tone, props.className),
22
32
  role: props.role || (tone === "danger" || tone === "warning" ? "alert" : "status")
23
33
  },
24
- /* @__PURE__ */ React.createElement(Icon, { name: props.icon || ALERT_ICON[tone], className: "aura-alert__icon" }),
34
+ /* @__PURE__ */ React.createElement(Icon, { name: props.icon || h(ALERT_ICON[tone]), className: "aura-alert__icon" }),
25
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),
26
36
  close
27
37
  );
@@ -60,16 +70,16 @@ function cardElement(props, ref) {
60
70
  );
61
71
  }
62
72
  const PILL_ICON = {
63
- neutral: "circle",
64
- progress: "circle-dot-dashed",
65
- ready: "circle-check",
66
- warning: "triangle-alert",
67
- blocked: "ban"
73
+ neutral: IconCircle,
74
+ progress: IconCircleDotDashed,
75
+ ready: IconCircleCheck,
76
+ warning: IconTriangleAlert,
77
+ blocked: IconBan
68
78
  };
69
79
  function statusPillElement(props, ref) {
70
80
  const tone = props.tone || toneFor(props.children);
71
81
  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);
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);
73
83
  }
74
84
  function badgeElement(props, ref) {
75
85
  const rest = omit(props, ["tone", "variant", "icon", "className", "children"]);
@@ -98,7 +108,7 @@ function emptyStateElement(props, ref) {
98
108
  ref,
99
109
  className: cx("aura-empty", props.size === "sm" && "is-sm", props.bordered && "is-bordered", props.className)
100
110
  },
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" })),
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" })),
102
112
  /* @__PURE__ */ React.createElement(HT, { className: "aura-empty__title" }, props.title),
103
113
  props.description ? /* @__PURE__ */ React.createElement("p", { className: "aura-empty__text" }, props.description) : null,
104
114
  props.action ? /* @__PURE__ */ React.createElement("div", { className: "aura-empty__action" }, props.action) : null
@@ -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
+ };