@jirawatpyk/aura-react 4.20.0 → 5.0.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 CHANGED
@@ -9,11 +9,11 @@ AURA Design System components as a real React package — ES modules, TypeScript
9
9
  One HTML file, no install — the packages are on npmjs, so jsDelivr serves them:
10
10
 
11
11
  ```html
12
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jirawatpyk/aura-tokens@4/aura.css" />
13
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jirawatpyk/aura-react@4/dist/styles.css" />
12
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jirawatpyk/aura-tokens@5/aura.css" />
13
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jirawatpyk/aura-react@5/dist/styles.css" />
14
14
  <script src="https://cdn.jsdelivr.net/npm/react@18/umd/react.production.min.js"></script>
15
15
  <script src="https://cdn.jsdelivr.net/npm/react-dom@18/umd/react-dom.production.min.js"></script>
16
- <script src="https://cdn.jsdelivr.net/npm/@jirawatpyk/aura-react@4/dist/aura.bundle.js"></script>
16
+ <script src="https://cdn.jsdelivr.net/npm/@jirawatpyk/aura-react@5/dist/aura.bundle.js"></script>
17
17
 
18
18
  <div id="root"></div>
19
19
  <script>
@@ -100,7 +100,7 @@ export function Providers({ children, locale }: { children: React.ReactNode; loc
100
100
  // app/layout.tsx (a Server Component): <body><Providers locale="th">{children}</Providers></body>
101
101
  ```
102
102
 
103
- `linkComponent` is used by Button `href`, Breadcrumb, Tabs and Menu items with `href`, BottomNav, Pagination `getHref` (page numbers and, since 4.17, the previous / next arrows), Stat `href`, SideNav and DataTable row/pager links. Each of them also takes its own `linkComponent`, which wins over the provider's. Pass `getHref` from a client component (it's a function too). The Next.js starter does all of this, and CI clicks every AURA link in it to check none triggers a full page load. Only `th` shows Buddhist-era years; `en` and `sv` are Gregorian (`sv` weeks start Monday). **Without a provider, components are English with Gregorian dates** — wrap Thai apps in `<AuraProvider locale="th">`. For dates in your own components use `useFormatDate()` — it follows the provider (`const fmt = useFormatDate(); fmt(iso, { format: 'long' })`). Plain `formatDate()` from the package root has no provider to read and stays Thai unless you pass `locale` (until 5.0); the one in `@jirawatpyk/aura-react/server` defaults to English and Gregorian. Values are always Gregorian ISO dates.
103
+ `linkComponent` is used by Button `href`, Breadcrumb, Tabs and Menu items with `href`, BottomNav, Pagination `getHref` (page numbers and, since 4.17, the previous / next arrows), Stat `href`, SideNav and DataTable row/pager links. Each of them also takes its own `linkComponent`, which wins over the provider's. Pass `getHref` from a client component (it's a function too). The Next.js starter does all of this, and CI clicks every AURA link in it to check none triggers a full page load. Only `th` shows Buddhist-era years; `en` and `sv` are Gregorian (`sv` weeks start Monday). **Without a provider, components are English with Gregorian dates** — wrap Thai apps in `<AuraProvider locale="th">`. For dates in your own components use `useFormatDate()` — it follows the provider (`const fmt = useFormatDate(); fmt(iso, { format: 'long' })`). Plain `formatDate()` has no provider to read: since 5.0 it is English and Gregorian unless you pass `locale`, the same function from the package root and from `@jirawatpyk/aura-react/server`. Values are always Gregorian ISO dates.
104
104
 
105
105
  ## Compact density
106
106
 
@@ -186,6 +186,14 @@ DataTable with sort and page in the URL (4.17): `onStateChange={({ sort, page })
186
186
  - **Time zone**: `timeZone` on AuraProvider, DatePicker, DateRangePicker and Calendar decides "today" (the marker, `min`/`max="today"`, the first month shown); or pass `today` as an ISO date. `todayIn('Asia/Bangkok')` is exported from the root and `/server`.
187
187
  - **Toasts** queue past three instead of dropping: six in a row all show, in order, three at a time.
188
188
 
189
+ ## Upgrading to 5.0
190
+
191
+ One breaking change: **`formatDate()` from the package root defaults to English and the Gregorian calendar** (`'2026-09-24'` → `24 Sept 2026`), like `@jirawatpyk/aura-react/server` and `useFormatDate()` without a provider — it is now the same function. Before 5.0 it defaulted to Thai with Buddhist-era years (`24 ก.ย. 2569`), and 4.20 warned in development for every call without a `locale`.
192
+
193
+ - Thai output: pass the locale, `formatDate(iso, { locale: 'th' })`, or in components use `useFormatDate()`, which follows `<AuraProvider locale="th">`.
194
+ - Find the calls to change: search for `formatDate(` without `locale` (`git grep -n "formatDate(" | grep -v locale`), or run 4.20 first and read the warning.
195
+ - Components, pickers and `/server` are unchanged. The CDN path is `@5`.
196
+
189
197
  ## Static tables, separators, tooltips, phone tables before hydration (4.20)
190
198
 
191
199
  ```tsx
@@ -201,7 +209,6 @@ DataTable with sort and page in the URL (4.17): `onStateChange={({ sort, page })
201
209
  - **Table** is plain `<table>` markup with DataTable's look: mono header band, hairlines, wrapping text, `numeric` cells right-aligned in tabular figures, a `TFoot` for totals. No sorting, paging or virtual rows — use DataTable for data. If it has to scroll sideways on a phone, its box becomes a focusable region named by the caption.
202
210
  - **Tooltip** `side` also takes `left` and `right`; every side flips when clipped and stays inside the window.
203
211
  - **DataTable on phones before hydration**: `stackBelow` cards and `hideBelow` columns are decided in CSS from the first paint, at any width (up to three distinct `hideBelow` widths per table), and each row is in the HTML once — the cards are the grid's own rows, laid out by a container query. The table sits in a few wrapper `div`s for this; `className` and `ref` go on the outermost. The `.aura-table__card*` classes are gone.
204
- - **`formatDate()` from the package root** warns once in development when called without a `locale`: in 5.0 it becomes English and Gregorian like `/server`. Pass `{ locale: 'th' }` or use `useFormatDate()`.
205
212
 
206
213
  ## Phones and touch
207
214
 
@@ -124,7 +124,7 @@ window.Aura = (() => {
124
124
  contrast: () => contrast,
125
125
  createTheme: () => createTheme,
126
126
  formatBytes: () => formatBytes,
127
- formatDate: () => formatDate2,
127
+ formatDate: () => formatDate,
128
128
  iconNames: () => iconNames,
129
129
  parseDate: () => parseDate,
130
130
  parseTime: () => parseTime,
@@ -1714,7 +1714,7 @@ window.Aura = (() => {
1714
1714
  const o = opts || {}, d = fromISO(iso);
1715
1715
  if (!d) return "";
1716
1716
  const f = typeof o.format === "object" ? o.format : PRESETS[o.format || "short"];
1717
- const loc = o.locale || "th";
1717
+ const loc = o.locale || "en";
1718
1718
  return fmt(localeTag(loc, o.calendar || defaultCalendar(loc)), f, d).replace(ERA, "");
1719
1719
  }
1720
1720
  var MONTHS = null;
@@ -1766,23 +1766,6 @@ window.Aura = (() => {
1766
1766
  }
1767
1767
 
1768
1768
  // src/DatePicker.tsx
1769
- var warnedNoLocale = false;
1770
- function isDev() {
1771
- try {
1772
- return true;
1773
- } catch (e) {
1774
- return false;
1775
- }
1776
- }
1777
- function formatDate2(iso, opts) {
1778
- if (!warnedNoLocale && !(opts && opts.locale) && isDev()) {
1779
- warnedNoLocale = true;
1780
- console.warn(
1781
- "[AURA] formatDate() was called without a locale. It shows Thai with Buddhist-era years today; in 5.0 it will show English with Gregorian years, like '@jirawatpyk/aura-react/server'. Pass { locale: 'th' } to keep Thai, or use useFormatDate() in components."
1782
- );
1783
- }
1784
- return formatDate(iso, opts);
1785
- }
1786
1769
  function useFormatDate() {
1787
1770
  const ctx = useAuraLocale(), locale = ctx.locale || "en", calendar = ctx.calendar;
1788
1771
  return React17.useCallback(
@@ -105,7 +105,7 @@ __export(index_exports, {
105
105
  contrast: () => contrast,
106
106
  createTheme: () => createTheme,
107
107
  formatBytes: () => formatBytes,
108
- formatDate: () => formatDate2,
108
+ formatDate: () => formatDate,
109
109
  iconNames: () => iconNames,
110
110
  parseDate: () => parseDate,
111
111
  parseTime: () => parseTime,
@@ -1696,7 +1696,7 @@ function formatDate(iso, opts) {
1696
1696
  const o = opts || {}, d = fromISO(iso);
1697
1697
  if (!d) return "";
1698
1698
  const f = typeof o.format === "object" ? o.format : PRESETS[o.format || "short"];
1699
- const loc = o.locale || "th";
1699
+ const loc = o.locale || "en";
1700
1700
  return fmt(localeTag(loc, o.calendar || defaultCalendar(loc)), f, d).replace(ERA, "");
1701
1701
  }
1702
1702
  var MONTHS = null;
@@ -1748,23 +1748,6 @@ function todayIn(timeZone) {
1748
1748
  }
1749
1749
 
1750
1750
  // src/DatePicker.tsx
1751
- var warnedNoLocale = false;
1752
- function isDev() {
1753
- try {
1754
- return process.env.NODE_ENV !== "production";
1755
- } catch (e) {
1756
- return false;
1757
- }
1758
- }
1759
- function formatDate2(iso, opts) {
1760
- if (!warnedNoLocale && !(opts && opts.locale) && isDev()) {
1761
- warnedNoLocale = true;
1762
- console.warn(
1763
- "[AURA] formatDate() was called without a locale. It shows Thai with Buddhist-era years today; in 5.0 it will show English with Gregorian years, like '@jirawatpyk/aura-react/server'. Pass { locale: 'th' } to keep Thai, or use useFormatDate() in components."
1764
- );
1765
- }
1766
- return formatDate(iso, opts);
1767
- }
1768
1751
  function useFormatDate() {
1769
1752
  const ctx = useAuraLocale(), locale = ctx.locale || "en", calendar = ctx.calendar;
1770
1753
  return React17.useCallback(
@@ -21,24 +21,7 @@ import {
21
21
  toISO,
22
22
  todayIn
23
23
  } from "./dates.js";
24
- import { parseDate as parseDate2 } from "./dates.js";
25
- let warnedNoLocale = false;
26
- function isDev() {
27
- try {
28
- return true;
29
- } catch (e) {
30
- return false;
31
- }
32
- }
33
- function formatDate(iso, opts) {
34
- if (!warnedNoLocale && !(opts && opts.locale) && isDev()) {
35
- warnedNoLocale = true;
36
- console.warn(
37
- "[AURA] formatDate() was called without a locale. It shows Thai with Buddhist-era years today; in 5.0 it will show English with Gregorian years, like '@jirawatpyk/aura-react/server'. Pass { locale: 'th' } to keep Thai, or use useFormatDate() in components."
38
- );
39
- }
40
- return formatDateBase(iso, opts);
41
- }
24
+ import { formatDate, parseDate as parseDate2 } from "./dates.js";
42
25
  function useFormatDate() {
43
26
  const ctx = useAuraLocale(), locale = ctx.locale || "en", calendar = ctx.calendar;
44
27
  return React.useCallback(
package/dist/esm/dates.js CHANGED
@@ -101,7 +101,7 @@ function formatDate(iso, opts) {
101
101
  const o = opts || {}, d = fromISO(iso);
102
102
  if (!d) return "";
103
103
  const f = typeof o.format === "object" ? o.format : PRESETS[o.format || "short"];
104
- const loc = o.locale || "th";
104
+ const loc = o.locale || "en";
105
105
  return fmt(localeTag(loc, o.calendar || defaultCalendar(loc)), f, d).replace(ERA, "");
106
106
  }
107
107
  let MONTHS = null;
package/dist/index.d.ts CHANGED
@@ -745,7 +745,7 @@ export interface SegmentedControlProps {
745
745
  /** ISO date string, `YYYY-MM-DD` (Gregorian — the era is display only). */
746
746
  export type ISODate = string;
747
747
  export interface DateDisplayOptions {
748
- /** Components: the AuraProvider's locale, else `en`. `formatDate()` (no provider to read): `th` unless given. */
748
+ /** Components: the AuraProvider's locale, else `en`. `formatDate()` (no provider to read): `en` unless given (5.0; `th` before). */
749
749
  locale?: "th" | "en" | "sv" | undefined;
750
750
  /** `buddhist` (พ.ศ.; default for th) or `gregory` (ค.ศ.; default for en and sv). */
751
751
  calendar?: "buddhist" | "gregory" | undefined;
@@ -1227,14 +1227,14 @@ export declare const Combobox: ComboboxComponent;
1227
1227
  export type FormatDateOptions = DateDisplayOptions & {
1228
1228
  format?: "short" | "long" | "numeric" | Intl.DateTimeFormatOptions | undefined;
1229
1229
  };
1230
+ /** Format an ISO date for display: "18 Sept 2026" by default (English, Gregorian — 5.0); `{ locale: 'th' }` gives
1231
+ * "18 ก.ย. 2569" (Buddhist era), `{ locale: 'sv' }` "18 sep. 2026". The same function from the package root and from
1232
+ * `/server`. In components, `useFormatDate()` follows the AuraProvider's locale instead. */
1233
+ export declare function formatDate(iso: ISODate | null | undefined, opts?: FormatDateOptions): string;
1230
1234
  /** Parse typed text: dd/mm/yyyy (Buddhist years ≥ 2400 are converted), d-m-yyyy, d.m.yyyy, yyyy-mm-dd or '18 ก.ย. 2569' / '18 Sep 2026'. */
1231
1235
  export declare function parseDate(text: string | null | undefined): ISODate | null;
1232
1236
  /** Today as an ISO date in an IANA time zone (e.g. `Asia/Bangkok`), or in the runtime's own zone without one. (4.19) */
1233
1237
  export declare function todayIn(timeZone?: string | null): ISODate;
1234
- /** Format an ISO date for display. Without a `locale` it is Thai with Buddhist-era years **until 5.0, which makes it
1235
- * English and Gregorian** like `@jirawatpyk/aura-react/server` and `useFormatDate()`. Pass `{ locale }` (or use
1236
- * `useFormatDate()` in components) so the switch changes nothing for you; a call without one warns once in development. */
1237
- export declare function formatDate(iso: ISODate | null | undefined, opts?: FormatDateOptions): string;
1238
1238
  /** formatDate bound to the nearest AuraProvider: its locale and calendar (English, Gregorian without one).
1239
1239
  * Options you pass still win. Use it in components; plain formatDate() stays for code outside React. */
1240
1240
  export declare function useFormatDate(): (iso: ISODate | null | undefined, opts?: FormatDateOptions) => string;
@@ -27,7 +27,7 @@ __export(server_exports, {
27
27
  contrast: () => contrast,
28
28
  createTheme: () => createTheme,
29
29
  formatBytes: () => formatBytes,
30
- formatDate: () => formatDate2,
30
+ formatDate: () => formatDate,
31
31
  fromISO: () => fromISO,
32
32
  parseDate: () => parseDate,
33
33
  parseTime: () => parseTime,
@@ -73,7 +73,7 @@ function formatDate(iso, opts) {
73
73
  const o = opts || {}, d = fromISO(iso);
74
74
  if (!d) return "";
75
75
  const f = typeof o.format === "object" ? o.format : PRESETS[o.format || "short"];
76
- const loc = o.locale || "th";
76
+ const loc = o.locale || "en";
77
77
  return fmt(localeTag(loc, o.calendar || defaultCalendar(loc)), f, d).replace(ERA, "");
78
78
  }
79
79
  var MONTHS = null;
@@ -796,10 +796,3 @@ function colorSchemeScript(options) {
796
796
 
797
797
  // src/breakpoints.ts
798
798
  var breakpoints = { sm: 640, md: 768, lg: 1024, xl: 1280 };
799
-
800
- // src/server.ts
801
- function formatDate2(iso, opts) {
802
- const o = Object.assign({}, opts);
803
- if (!o.locale) o.locale = "en";
804
- return formatDate(iso, o);
805
- }
@@ -4,7 +4,7 @@ export type StatusTone = "neutral" | "progress" | "ready" | "blocked";
4
4
  /** ISO date string, `YYYY-MM-DD` (Gregorian — the era is display only). */
5
5
  export type ISODate = string;
6
6
  export interface DateDisplayOptions {
7
- /** Components: the AuraProvider's locale, else `en`. `formatDate()` (no provider to read): `th` unless given. */
7
+ /** Components: the AuraProvider's locale, else `en`. `formatDate()` (no provider to read): `en` unless given (5.0; `th` before). */
8
8
  locale?: "th" | "en" | "sv" | undefined;
9
9
  /** `buddhist` (พ.ศ.; default for th) or `gregory` (ค.ศ.; default for en and sv). */
10
10
  calendar?: "buddhist" | "gregory" | undefined;
@@ -42,6 +42,10 @@ export type FormatDateOptions = DateDisplayOptions & {
42
42
  };
43
43
  export declare function toISO(d: Date | null | undefined): ISODate | null;
44
44
  export declare function fromISO(s: ISODate | null | undefined): Date | null;
45
+ /** Format an ISO date for display: "18 Sept 2026" by default (English, Gregorian — 5.0); `{ locale: 'th' }` gives
46
+ * "18 ก.ย. 2569" (Buddhist era), `{ locale: 'sv' }` "18 sep. 2026". The same function from the package root and from
47
+ * `/server`. In components, `useFormatDate()` follows the AuraProvider's locale instead. */
48
+ export declare function formatDate(iso: ISODate | null | undefined, opts?: FormatDateOptions): string;
45
49
  /** Parse typed text: dd/mm/yyyy (Buddhist years ≥ 2400 are converted), d-m-yyyy, d.m.yyyy, yyyy-mm-dd or '18 ก.ย. 2569' / '18 Sep 2026'. */
46
50
  export declare function parseDate(text: string | null | undefined): ISODate | null;
47
51
  /** Today as an ISO date in an IANA time zone (e.g. `Asia/Bangkok`), or in the runtime's own zone without one. (4.19) */
@@ -162,9 +166,6 @@ export declare const breakpoints: {
162
166
  lg: 1024;
163
167
  xl: 1280;
164
168
  };
165
- /** Format an ISO date for display: "24 Sept 2026" by default (English, Gregorian); `{ locale: 'th' }` gives
166
- * "24 ก.ย. 2569", `{ locale: 'sv' }` "24 sep. 2026". Options as in the package root's formatDate. */
167
- export declare function formatDate(iso: ISODate | null | undefined, opts?: FormatDateOptions): string;
168
169
 
169
170
  export {
170
171
  scale as brandScale,
@@ -34,7 +34,7 @@ function formatDate(iso, opts) {
34
34
  const o = opts || {}, d = fromISO(iso);
35
35
  if (!d) return "";
36
36
  const f = typeof o.format === "object" ? o.format : PRESETS[o.format || "short"];
37
- const loc = o.locale || "th";
37
+ const loc = o.locale || "en";
38
38
  return fmt(localeTag(loc, o.calendar || defaultCalendar(loc)), f, d).replace(ERA, "");
39
39
  }
40
40
  var MONTHS = null;
@@ -757,13 +757,6 @@ function colorSchemeScript(options) {
757
757
 
758
758
  // src/breakpoints.ts
759
759
  var breakpoints = { sm: 640, md: 768, lg: 1024, xl: 1280 };
760
-
761
- // src/server.ts
762
- function formatDate2(iso, opts) {
763
- const o = Object.assign({}, opts);
764
- if (!o.locale) o.locale = "en";
765
- return formatDate(iso, o);
766
- }
767
760
  export {
768
761
  STRINGS,
769
762
  scale as brandScale,
@@ -772,7 +765,7 @@ export {
772
765
  contrast,
773
766
  createTheme,
774
767
  formatBytes,
775
- formatDate2 as formatDate,
768
+ formatDate,
776
769
  fromISO,
777
770
  parseDate,
778
771
  parseTime,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jirawatpyk/aura-react",
3
- "version": "4.20.0",
3
+ "version": "5.0.0",
4
4
  "description": "AURA Design System — React components (Enterprise Standard, Human Creative). Thai-first: Buddhist-era dates, Thai collation.",
5
5
  "license": "MIT",
6
6
  "type": "module",