@jirawatpyk/aura-react 4.11.0 → 4.12.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
@@ -65,7 +65,7 @@ export default function Root() {
65
65
 
66
66
  ## Components (49)
67
67
 
68
- Actions: Button, IconButton, Menu, DropdownMenu, Tag · Forms: TextField, Textarea, NumberField, Select, RadioGroup, Checkbox, Switch, SegmentedControl, Combobox (one value, or `multiple`), FileUpload (+ `formatBytes`) · Dates & times: DatePicker, DateRangePicker, Calendar, TimePicker (+ `formatDate`, `parseDate`, `parseTime`) · Feedback: Alert, Toaster/`toast()`, Tooltip, StatusPill, Badge, Progress, Skeleton, EmptyState · Overlays: Dialog, Drawer, Popover · Data: DataTable, Stat · Layout: AppShell, Container, Stack, Grid, Accordion, Pagination, Card, Tabs, Stepper, SideNav, Breadcrumb, Avatar, Surface, Icon · Theme: ColorSchemeToggle, ColorSchemeScript, `useColorScheme`, ThemeStyle/`createTheme` · Hooks: `useBreakpoint`, `useResponsive`, `breakpoints`, `useAuraLocale`.
68
+ Actions: Button, IconButton, Menu, DropdownMenu, Tag · Forms: TextField, Textarea, NumberField, Select, RadioGroup, Checkbox, Switch, SegmentedControl, Combobox (one value, or `multiple`), FileUpload (+ `formatBytes`) · Dates & times: DatePicker, DateRangePicker, Calendar, TimePicker (+ `useFormatDate`, `formatDate`, `parseDate`, `parseTime`) · Feedback: Alert, Toaster/`toast()`, Tooltip, StatusPill, Badge, Progress, Skeleton, EmptyState · Overlays: Dialog, Drawer, Popover · Data: DataTable, Stat · Layout: AppShell, Container, Stack, Grid, Accordion, Pagination, Card, Tabs, Stepper, SideNav, Breadcrumb, Avatar, Surface, Icon · Theme: ColorSchemeToggle, ColorSchemeScript, `useColorScheme`, ThemeStyle/`createTheme` · Hooks: `useBreakpoint`, `useResponsive`, `breakpoints`, `useAuraLocale`.
69
69
 
70
70
  ## Router links, Swedish, motion
71
71
 
@@ -74,7 +74,7 @@ import Link from 'next/link';
74
74
  <AuraProvider locale="sv" linkComponent={Link}> {/* th | en | sv */}
75
75
  ```
76
76
 
77
- `linkComponent` is used by Button `href`, Breadcrumb, Pagination `getHref`, Stat `href`, SideNav and DataTable row/pager links. 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">`. `formatDate()` has no provider to read, so it stays Thai unless you pass `locale`. Values are always Gregorian ISO dates.
77
+ `linkComponent` is used by Button `href`, Breadcrumb, Pagination `getHref`, Stat `href`, SideNav and DataTable row/pager links. 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 and stays Thai unless you pass `locale`. Values are always Gregorian ISO dates.
78
78
 
79
79
  Motion: skeleton pulses and indeterminate bars honour `prefers-reduced-motion: reduce` — skeletons stop (a static bar), spinners and progress bars slow to a third.
80
80
 
@@ -110,7 +110,7 @@ Every component forwards `ref` to its real element — fields to the `<input>`/`
110
110
 
111
111
  ## Thai dates
112
112
 
113
- Values are ISO strings (`2026-09-18`); with `locale="th"` display is Thai with Buddhist-era years (`18 ก.ย. 2569`). People can type `18/09/2569`, `18/09/2026`, `2026-09-18` or `18 ก.ย. 2569`. Store ISO, never พ.ศ. `formatDate(iso, { format: 'long' })` → `18 กันยายน 2569`.
113
+ Values are ISO strings (`2026-09-18`); with `locale="th"` display is Thai with Buddhist-era years (`18 ก.ย. 2569`). People can type `18/09/2569`, `18/09/2026`, `2026-09-18` or `18 ก.ย. 2569`. Store ISO, never พ.ศ. In components, `useFormatDate()(iso, { format: 'long' })` → `18 กันยายน 2569` under `locale="th"`, `18 September 2026` under `en`. `parseDate(text)` reads any of these forms in every locale.
114
114
 
115
115
  ## Server rendering
116
116
 
@@ -119,6 +119,7 @@ window.Aura = (() => {
119
119
  useAuraLocale: () => useAuraLocale,
120
120
  useBreakpoint: () => useBreakpoint,
121
121
  useColorScheme: () => useColorScheme,
122
+ useFormatDate: () => useFormatDate,
122
123
  useResponsive: () => useResponsive
123
124
  });
124
125
 
@@ -1582,6 +1583,22 @@ window.Aura = (() => {
1582
1583
  const loc = o.locale || "th";
1583
1584
  return fmt(localeTag(loc, o.calendar || defaultCalendar(loc)), f, d).replace(ERA, "");
1584
1585
  }
1586
+ function useFormatDate() {
1587
+ const ctx = useAuraLocale(), locale = ctx.locale || "en", calendar = ctx.calendar;
1588
+ return React17.useCallback(
1589
+ function(iso, opts) {
1590
+ const o = opts || {}, loc = o.locale || locale;
1591
+ return formatDate(
1592
+ iso,
1593
+ Object.assign({}, o, {
1594
+ locale: loc,
1595
+ calendar: o.calendar || (o.locale ? void 0 : calendar) || defaultCalendar(loc)
1596
+ })
1597
+ );
1598
+ },
1599
+ [locale, calendar]
1600
+ );
1601
+ }
1585
1602
  var MONTHS = null;
1586
1603
  function monthIndex(word) {
1587
1604
  if (!MONTHS) {
@@ -100,6 +100,7 @@ __export(index_exports, {
100
100
  useAuraLocale: () => useAuraLocale,
101
101
  useBreakpoint: () => useBreakpoint,
102
102
  useColorScheme: () => useColorScheme,
103
+ useFormatDate: () => useFormatDate,
103
104
  useResponsive: () => useResponsive
104
105
  });
105
106
  module.exports = __toCommonJS(index_exports);
@@ -1564,6 +1565,22 @@ function formatDate(iso, opts) {
1564
1565
  const loc = o.locale || "th";
1565
1566
  return fmt(localeTag(loc, o.calendar || defaultCalendar(loc)), f, d).replace(ERA, "");
1566
1567
  }
1568
+ function useFormatDate() {
1569
+ const ctx = useAuraLocale(), locale = ctx.locale || "en", calendar = ctx.calendar;
1570
+ return React17.useCallback(
1571
+ function(iso, opts) {
1572
+ const o = opts || {}, loc = o.locale || locale;
1573
+ return formatDate(
1574
+ iso,
1575
+ Object.assign({}, o, {
1576
+ locale: loc,
1577
+ calendar: o.calendar || (o.locale ? void 0 : calendar) || defaultCalendar(loc)
1578
+ })
1579
+ );
1580
+ },
1581
+ [locale, calendar]
1582
+ );
1583
+ }
1567
1584
  var MONTHS = null;
1568
1585
  function monthIndex(word) {
1569
1586
  if (!MONTHS) {
@@ -111,6 +111,22 @@ function formatDate(iso, opts) {
111
111
  const loc = o.locale || "th";
112
112
  return fmt(localeTag(loc, o.calendar || defaultCalendar(loc)), f, d).replace(ERA, "");
113
113
  }
114
+ function useFormatDate() {
115
+ const ctx = useAuraLocale(), locale = ctx.locale || "en", calendar = ctx.calendar;
116
+ return React.useCallback(
117
+ function(iso, opts) {
118
+ const o = opts || {}, loc = o.locale || locale;
119
+ return formatDate(
120
+ iso,
121
+ Object.assign({}, o, {
122
+ locale: loc,
123
+ calendar: o.calendar || (o.locale ? void 0 : calendar) || defaultCalendar(loc)
124
+ })
125
+ );
126
+ },
127
+ [locale, calendar]
128
+ );
129
+ }
114
130
  let MONTHS = null;
115
131
  function monthIndex(word) {
116
132
  if (!MONTHS) {
@@ -708,5 +724,6 @@ export {
708
724
  formatDate,
709
725
  fromISO,
710
726
  parseDate,
711
- toISO
727
+ toISO,
728
+ useFormatDate
712
729
  };
package/dist/esm/index.js CHANGED
@@ -13,7 +13,7 @@ import { Select } from "./Select.js";
13
13
  import { RadioGroup } from "./RadioGroup.js";
14
14
  import { Switch } from "./Switch.js";
15
15
  import { Combobox, defaultFilter } from "./Combobox.js";
16
- import { DatePicker, DateRangePicker, Calendar, formatDate, parseDate } from "./DatePicker.js";
16
+ import { DatePicker, DateRangePicker, Calendar, formatDate, parseDate, useFormatDate } from "./DatePicker.js";
17
17
  import { Alert } from "./Alert.js";
18
18
  import { Toaster, toast } from "./Toaster.js";
19
19
  import { Tooltip } from "./Tooltip.js";
@@ -118,5 +118,6 @@ export {
118
118
  useAuraLocale,
119
119
  useBreakpoint,
120
120
  useColorScheme,
121
+ useFormatDate,
121
122
  useResponsive
122
123
  };
package/dist/index.d.ts CHANGED
@@ -966,6 +966,9 @@ export type FormatDateOptions = DateDisplayOptions & {
966
966
  };
967
967
  /** Format an ISO date for display, e.g. "18 ก.ย. 2569" (th, Buddhist) or "18 Sept 2026" (en, Gregorian). */
968
968
  export declare function formatDate(iso: ISODate | null | undefined, opts?: FormatDateOptions): string;
969
+ /** formatDate bound to the nearest AuraProvider: its locale and calendar (English, Gregorian without one).
970
+ * Options you pass still win. Use it in components; plain formatDate() stays for code outside React. */
971
+ export declare function useFormatDate(): (iso: ISODate | null | undefined, opts?: FormatDateOptions) => string;
969
972
  /** 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'. */
970
973
  export declare function parseDate(text: string | null | undefined): ISODate | null;
971
974
  export declare const Calendar: React$1.ForwardRefExoticComponent<CalendarProps & React$1.RefAttributes<HTMLDivElement>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jirawatpyk/aura-react",
3
- "version": "4.11.0",
3
+ "version": "4.12.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",