@makoai/app-sdk 2.28.0 → 2.29.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
@@ -715,6 +715,73 @@ phone sheet each control takes the full width. The sheet sits at z-index 50,
715
715
  so the Radix popovers of `/components` and `/menu` open above it. Escape
716
716
  closes an open popover first and the sheet on the next press.
717
717
 
718
+ ### Languages: `locale` and `labels` (2.29)
719
+
720
+ One `locale` prop puts a component's own texts in French, German, Italian,
721
+ Spanish, Polish or Portuguese. Pass a BCP 47 tag such as `"fr-CH"`. The SDK
722
+ matches the language part, so `"fr-CH"` reads French. An unknown language
723
+ reads English. The texts live in one table in the SDK (`STRINGS`), never in
724
+ the app. Month names come from `Intl` in the full locale. Counts and footer
725
+ numbers format in it too.
726
+
727
+ `labels` overrides single texts on top of the locale. The explicit props that
728
+ already existed (`allLabel`, `noneLabel`, `formatMany`, `searchPlaceholder`,
729
+ `searchEmpty`, `placeholder`, `emptyText`, `label`, `noun`, `empty`) win over
730
+ both. With no `locale` and no `labels`, every component renders byte for byte
731
+ as 2.28.
732
+
733
+ ```tsx
734
+ const LOCALE = "fr-CH";
735
+ <FilterBar locale={LOCALE} dirty={dirty} onReset={reset}>
736
+ <FilterField label="Période">
737
+ <PeriodPicker locale={LOCALE} value={period} onChange={setPeriod} presets={["7d", "28d", "mtd", "ytd"]} />
738
+ </FilterField>
739
+ <FilterField label="Marché">
740
+ <MultiSelect locale={LOCALE} options={MARKETS} value={markets} onChange={setMarkets} />
741
+ </FilterField>
742
+ </FilterBar>
743
+ <DataTable locale={LOCALE} rows={rows} columns={COLUMNS} labels={{ exportCsv: "Exporter" }} />
744
+ ```
745
+
746
+ The components and their `labels` keys:
747
+
748
+ - **PeriodPicker** (`PeriodPickerLabels`): `time` (the trigger's name when
749
+ `label` is unset), `previous`, `next`, `menu`, `week`, `month`, `quarter`,
750
+ `year`, `custom`, `presets` (the presets tab), `inProgress`,
751
+ `inProgressTitle`, `from`, `to`, `apply`, `quarterLabel(q, year)` ("T4
752
+ 2026" in French), `lastDays(n)`, `mtd`, `qtd`, `ytd`. The period reads
753
+ "nov. 2026" in fr-CH and "16.–22. Nov 2026" in de-CH.
754
+ - **FilterBar** (`FilterBarLabels`): `filters` (chip, sheet title, aria-label),
755
+ `reset`, `resetTitle`, `done`.
756
+ - **MultiSelect, FilterItems** (`/ui`) and **FilterMenu, FilterMenuItems**
757
+ (`/menu`) (`FilterLabels`): `all`, `none`, `many(n)`, `only`, `search`,
758
+ `noMatch`, `groupAll(label)` ("Bots (tout)", FilterMenu's group row).
759
+ `allLabel` is optional on FilterMenu now.
760
+ - **Combobox** (`ComboboxLabels`): `placeholder`, `search`, `empty`.
761
+ - **DataTable**: the `DataTableLabels` keys. A locale also formats the
762
+ footer's numbers and names the rows ("1–50 sur 312 lignes") while `noun` is
763
+ unset. `dataTableLabels(locale, labels)` returns the full set.
764
+
765
+ `localeStrings(section, locale, labels)` returns one section for your own
766
+ controls: `localeStrings("filterBar", "de-CH").reset` is "Zurücksetzen".
767
+
768
+ **Rolling presets.** `presets` on PeriodPicker adds a first tab of windows
769
+ that end today: `"7d"`, `"28d"`, `"90d"`, `"365d"` (any `"<N>d"`) and `"mtd"`,
770
+ `"qtd"`, `"ytd"` (month, quarter and year to date). A pick emits
771
+ `presetPeriod(id)`: `{ unit: "custom", from, to: today, preset: "28d" }`. The
772
+ trigger reads the preset's name ("28 derniers jours"). ‹ from a to-date
773
+ preset goes to the whole unit before it; from N days, to the N days before.
774
+
775
+ A preset keeps rolling only if the URL holds its id, not its dates. Write
776
+ `period=28d` for a preset and keep `from=&to=` for everything else, so every
777
+ existing link still opens the same range:
778
+
779
+ ```tsx
780
+ const period = presetPeriod(params.get("period")) ?? rangePeriod(params.get("from"), params.get("to"));
781
+ const onChange = (p: Period) =>
782
+ update(p.preset ? { period: p.preset, from: null, to: null } : { period: null, from: p.from, to: p.to });
783
+ ```
784
+
718
785
  ### Country colours: `COUNTRY_COLORS`, `COUNTRY_ORDER` (2.27)
719
786
 
720
787
  A market has one colour in every app. Keys are lowercase codes.
@@ -908,7 +975,9 @@ const COLUMNS: DataTableColumn<Customer>[] = [
908
975
  values (null, "", NaN) sort last both ways. `sticky` (pin the first column),
909
976
  `sortable: false`, `hint` (header hover text), `csv` (`false` to leave a
910
977
  column out, a function for a readable cell such as a level name). Numeric
911
- strings ("1.25", "-10") sort as numbers.
978
+ strings ("1.25", "-10") sort as numbers. `sortDescFirst` (2.29, TanStack
979
+ Table's name) sets the first click's direction: `sortDescFirst: false` on a
980
+ "Renewal (d)" column sorts soonest first. The next click flips it.
912
981
  - **Widths: no layout shift.** The table uses `table-layout: fixed` and a
913
982
  `<colgroup>`, so a column's width never depends on the rows on screen.
914
983
  Sorting, filtering, paging, the empty state and loading all keep the same
@@ -7,11 +7,14 @@
7
7
  // Mako thin props (2.28): `count` per option (muted, right-aligned, never
8
8
  // searched, never in the trigger), `keywords` per option, `icon` in the trigger.
9
9
  // Search matches the label and keywords only, never the value or the count.
10
+ // 2.29: `locale` and `labels` translate the placeholder, search and empty
11
+ // texts, and `locale` formats the counts.
10
12
 
11
13
  import * as React from "react"
12
14
  import { CheckIcon, ChevronsUpDownIcon } from "lucide-react"
13
15
  import { defaultFilter } from "cmdk"
14
16
  import { cn } from "../menu/utils"
17
+ import { localeStrings, type ComboboxLabels } from "../locale.js"
15
18
  import { Button } from "./button"
16
19
  import {
17
20
  Command,
@@ -32,8 +35,8 @@ export type ComboboxOption<V extends string = string> = {
32
35
  keywords?: string[]
33
36
  }
34
37
 
35
- const formatCount = (n: number | string) =>
36
- typeof n === "number" ? n.toLocaleString("en-US") : n
38
+ const formatCount = (n: number | string, locale = "en-US") =>
39
+ typeof n === "number" ? n.toLocaleString(locale) : n
37
40
 
38
41
  // The item's value is the option value (unique); its keywords hold the label
39
42
  // first, so the search scores the label and keywords and never the value.
@@ -44,9 +47,11 @@ function Combobox<V extends string = string>({
44
47
  options,
45
48
  value,
46
49
  onChange,
47
- placeholder = "Select...",
48
- searchPlaceholder = "Search...",
49
- emptyText = "No results found.",
50
+ placeholder: placeholderProp,
51
+ searchPlaceholder: searchProp,
52
+ emptyText: emptyProp,
53
+ locale,
54
+ labels,
50
55
  icon,
51
56
  disabled,
52
57
  className,
@@ -59,12 +64,20 @@ function Combobox<V extends string = string>({
59
64
  placeholder?: string
60
65
  searchPlaceholder?: string
61
66
  emptyText?: React.ReactNode
67
+ /** Mako thin prop (2.29): BCP 47 tag, e.g. "fr-CH": the three texts in that language. Default English. */
68
+ locale?: string
69
+ /** Mako thin prop (2.29): override single texts on top of the locale. The explicit props win. */
70
+ labels?: Partial<ComboboxLabels>
62
71
  icon?: React.ReactNode
63
72
  disabled?: boolean
64
73
  className?: string
65
74
  contentClassName?: string
66
75
  "aria-label"?: string
67
76
  }) {
77
+ const L = localeStrings("combobox", locale, labels)
78
+ const placeholder = placeholderProp ?? L.placeholder
79
+ const searchPlaceholder = searchProp ?? L.search
80
+ const emptyText = emptyProp ?? L.empty
68
81
  const [open, setOpen] = React.useState(false)
69
82
  const items = options.map((o) =>
70
83
  typeof o === "string" ? { value: o, label: o } : o
@@ -115,7 +128,7 @@ function Combobox<V extends string = string>({
115
128
  data-slot="combobox-count"
116
129
  className="text-xs text-muted-foreground tabular-nums"
117
130
  >
118
- {formatCount(o.count)}
131
+ {formatCount(o.count, locale)}
119
132
  </span>
120
133
  )}
121
134
  <CheckIcon
@@ -13,8 +13,10 @@
13
13
  // every width. Two changes from the reference: the sheet sits at z-50 (scrim
14
14
  // z-49), so the SDK's Radix popovers (z-50, portalled after it) open above it;
15
15
  // and Escape leaves the sheet open when a popover inside it took the key.
16
+ // 2.29: `locale` and `labels` translate Filters, Reset and Done.
16
17
  import * as React from "react"
17
18
  import { createPortal } from "react-dom"
19
+ import { localeStrings, type FilterBarLabels } from "../locale.js"
18
20
  import { cn } from "../menu/utils"
19
21
 
20
22
  type Entry = { dirty: boolean; reset: () => void }
@@ -50,13 +52,20 @@ function FilterBar({
50
52
  children,
51
53
  dirty,
52
54
  onReset,
55
+ locale,
56
+ labels,
53
57
  className,
54
58
  }: {
55
59
  children: React.ReactNode
56
60
  dirty: boolean
57
61
  onReset: () => void
62
+ /** Mako thin prop (2.29): BCP 47 tag, e.g. "fr-CH": Filters, Reset and Done in that language. Default English. */
63
+ locale?: string
64
+ /** Mako thin prop (2.29): override single texts on top of the locale. */
65
+ labels?: Partial<FilterBarLabels>
58
66
  className?: string
59
67
  }) {
68
+ const L = localeStrings("filterBar", locale, labels)
60
69
  const { setSlot, entries } = React.useContext(FilterCtx)
61
70
  const active = (dirty ? 1 : 0) + Object.values(entries).filter(e => e.dirty).length
62
71
  const [sheet, setSheet] = React.useState(false)
@@ -84,7 +93,7 @@ function FilterBar({
84
93
  onClick={() => setSheet(!sheet)}
85
94
  className="inline-flex h-[34px] items-center gap-2 rounded-[8px] border border-border bg-card px-3 text-sm font-medium shadow-[0_1px_2px_rgb(0_0_0/.05)]"
86
95
  >
87
- Filters{" "}
96
+ {L.filters}{" "}
88
97
  {active > 0 && (
89
98
  <span
90
99
  data-slot="filter-count"
@@ -109,7 +118,7 @@ function FilterBar({
109
118
  data-slot="filter-bar"
110
119
  data-open={sheet || undefined}
111
120
  role="group"
112
- aria-label="Filters"
121
+ aria-label={L.filters}
113
122
  className={cn(
114
123
  "group/fb flex flex-wrap items-end gap-x-3 gap-y-2.5",
115
124
  sheet
@@ -122,14 +131,14 @@ function FilterBar({
122
131
  data-slot="filter-sheet-head"
123
132
  className="hidden items-center justify-between border-b border-border pt-3 pb-2 font-semibold max-[769px]:group-data-[open]/fb:flex"
124
133
  >
125
- <span>Filters</span>
134
+ <span>{L.filters}</span>
126
135
  <button
127
136
  type="button"
128
137
  data-slot="filter-done"
129
138
  onClick={() => setSheet(false)}
130
139
  className="h-8 rounded-[8px] border-0 bg-brand px-4 font-semibold text-white"
131
140
  >
132
- Done
141
+ {L.done}
133
142
  </button>
134
143
  </div>
135
144
  {children}
@@ -139,13 +148,13 @@ function FilterBar({
139
148
  data-slot="filter-reset"
140
149
  disabled={active === 0}
141
150
  onClick={reset}
142
- title="Back to the default filters"
151
+ title={L.resetTitle}
143
152
  className="inline-flex h-[34px] items-center gap-1.5 self-end rounded-[8px] border border-border bg-card px-3 text-sm font-medium text-foreground enabled:hover:bg-accent disabled:cursor-default disabled:bg-transparent disabled:text-muted-foreground disabled:opacity-60 max-[769px]:self-start"
144
153
  >
145
154
  <svg width="14" height="14" viewBox="0 0 24 24" aria-hidden>
146
155
  <path d="M3 12a9 9 0 1 0 3-6.7L3 8M3 3v5h5" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
147
156
  </svg>
148
- Reset
157
+ {L.reset}
149
158
  </button>
150
159
  </div>
151
160
  </>
@@ -6,6 +6,8 @@
6
6
  // never an app copy. TypeScript source: the app's Vite compiles it, and the
7
7
  // app's CSS imports "@makoai/app-sdk/tailwind.css" so Tailwind sees it.
8
8
  // One house component sits beside them: the page filter bar (filter-bar.tsx).
9
+ // 2.29: `locale` + `labels` on PeriodPicker, FilterBar, Combobox and FilterMenu
10
+ // read the SDK's one strings table (../locale.js).
9
11
  export * from "./alert";
10
12
  export * from "./avatar";
11
13
  export * from "./badge";
@@ -17,7 +19,8 @@ export * from "./filter-bar";
17
19
  export * from "./input";
18
20
  export * from "./label";
19
21
  export * from "./period-picker";
20
- export { clipToday, isCurrent, periodLabel, periodOf, shift, todayIso, type Period, type Unit } from "./period";
22
+ export { clipToday, isCurrent, periodLabel, periodOf, presetLabel, presetPeriod, shift, todayIso, type Period, type PeriodPreset, type Unit } from "./period"
23
+ export { LOCALES, STRINGS, localeLang, localeStrings, type ComboboxLabels, type FilterBarLabels, type FilterLabels, type LocaleLang, type PeriodPickerLabels } from "../locale.js";
21
24
  export * from "./popover";
22
25
  export * from "./progress";
23
26
  export * from "./select";
@@ -7,11 +7,17 @@
7
7
  // and its `.pp` styles. The app's hand-rolled popover became the stock
8
8
  // shadcn Popover (./popover): it portals the menu, moves focus into it on
9
9
  // open and back to the trigger on close.
10
+ //
11
+ // 2.29: `locale` translates every fixed text (from the SDK's strings table,
12
+ // ../locale.js) and the month names (Intl); `labels` overrides single
13
+ // strings; `presets` adds a tab of rolling windows. Without them the output
14
+ // is byte-identical to 2.28.
10
15
  import * as React from "react"
11
16
  import { closePopovers } from "../ui.js"
17
+ import { localeStrings, type PeriodPickerLabels } from "../locale.js"
12
18
  import { cn } from "../menu/utils"
13
19
  import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from "./popover"
14
- import { UNIT_LABEL, addDays, isCurrent, periodLabel, periodOf, shift, todayIso, type Period, type Unit } from "./period"
20
+ import { addDays, isCurrent, periodLabel, periodOf, presetPeriod, shift, todayIso, type Period, type PeriodPreset, type Unit } from "./period"
15
21
 
16
22
  const RECENT: Record<Unit, number> = { week: 12, month: 12, quarter: 8, year: 4 }
17
23
 
@@ -25,14 +31,28 @@ export interface PeriodPickerProps {
25
31
  /** Earliest and latest day a period may reach. Default: no limit back, today forward. */
26
32
  min?: string
27
33
  max?: string
28
- /** The trigger's screen-reader name, read as "<label>: Nov 2026". */
34
+ /** The trigger's screen-reader name, read as "<label>: Nov 2026". Default "Time" (`labels.time`). */
29
35
  label?: string
36
+ /** Mako thin prop (2.29): BCP 47 tag, e.g. "fr-CH". Translates every text and the month names. Default English. */
37
+ locale?: string
38
+ /** Mako thin prop (2.29): override single texts on top of the locale, e.g. `{ apply: "OK" }`. */
39
+ labels?: Partial<PeriodPickerLabels>
40
+ /**
41
+ * Mako thin prop (2.29): rolling windows in their own tab, first: "7d", "28d", "90d" (the last N days),
42
+ * "mtd", "qtd", "ytd" (month, quarter, year to date). A pick emits `presetPeriod(id)`: a custom range
43
+ * ending today with `preset: id`. Default none.
44
+ */
45
+ presets?: readonly PeriodPreset[]
30
46
  /** Mako thin prop (2.27): classes on the stepper's frame, e.g. `w-full` in a phone sheet. */
31
47
  className?: string
32
48
  }
33
49
 
34
50
  /** The house date filter: ‹ Nov 2026 › with the period in progress tinted. */
35
- export function PeriodPicker({ value, onChange, units = ["month", "quarter", "year"], custom = "month", min, max, label = "Time", className }: PeriodPickerProps) {
51
+ export function PeriodPicker({ value, onChange, units = ["month", "quarter", "year"], custom = "month", min, max, label: labelProp, locale, labels, presets, className }: PeriodPickerProps) {
52
+ const L = localeStrings("period", locale, labels)
53
+ const label = labelProp ?? L.time
54
+ const text = periodLabel(value, locale)
55
+ const wide = !!(locale || presets?.length)
36
56
  const today = todayIso()
37
57
  const hi = max ?? today
38
58
  const [open, setOpen] = React.useState(false)
@@ -57,22 +77,22 @@ export function PeriodPicker({ value, onChange, units = ["month", "quarter", "ye
57
77
  className,
58
78
  )}
59
79
  >
60
- <button type="button" data-slot="period-picker-prev" className={cn(step, "rounded-l-[7px]")} aria-label="Previous period" disabled={!okPrev} onClick={() => onChange(prev)}>‹</button>
80
+ <button type="button" data-slot="period-picker-prev" className={cn(step, "rounded-l-[7px]")} aria-label={L.previous} disabled={!okPrev} onClick={() => onChange(prev)}>‹</button>
61
81
  <PopoverTrigger asChild>
62
82
  <button
63
83
  type="button"
64
84
  data-slot="period-picker-trigger"
65
85
  data-current={current || undefined}
66
86
  className="inline-flex min-w-[156px] cursor-pointer items-center gap-2 border-x border-border bg-transparent py-0 pr-[10px] pl-3 font-medium text-inherit focus-visible:outline-none data-[current]:bg-[color-mix(in_srgb,var(--brand)_10%,transparent)] data-[current]:text-brand"
67
- aria-label={`${label}: ${periodLabel(value)}`}
68
- title={current ? "In progress: the numbers are not final yet" : undefined}
87
+ aria-label={`${label}: ${text}`}
88
+ title={current ? L.inProgressTitle : undefined}
69
89
  >
70
90
  {current && <span className="size-[7px] flex-none rounded-full bg-brand shadow-[0_0_0_3px_color-mix(in_srgb,var(--brand)_22%,transparent)]" aria-hidden />}
71
- <span className="flex-1 whitespace-nowrap text-left tabular-nums">{periodLabel(value)}</span>
91
+ <span className="flex-1 whitespace-nowrap text-left tabular-nums">{text}</span>
72
92
  <svg className={cn("flex-none text-muted-foreground transition-transform duration-150", open && "rotate-180")} width="12" height="12" viewBox="0 0 24 24" aria-hidden><path d="m6 9 6 6 6-6" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" /></svg>
73
93
  </button>
74
94
  </PopoverTrigger>
75
- <button type="button" data-slot="period-picker-next" className={cn(step, "rounded-r-[7px]")} aria-label="Next period" disabled={!okNext} onClick={() => onChange(next)}>›</button>
95
+ <button type="button" data-slot="period-picker-next" className={cn(step, "rounded-r-[7px]")} aria-label={L.next} disabled={!okNext} onClick={() => onChange(next)}>›</button>
76
96
  </div>
77
97
  </PopoverAnchor>
78
98
  <PopoverContent
@@ -80,26 +100,34 @@ export function PeriodPicker({ value, onChange, units = ["month", "quarter", "ye
80
100
  // The app's menu sat 6px under the frame's inner edge, flush with its inner left.
81
101
  sideOffset={5}
82
102
  alignOffset={1}
83
- aria-label="Pick a period"
84
- className="z-[70] grid w-[320px] max-w-[calc(100vw-24px)] gap-[10px] rounded-[10px] p-[10px] shadow-[0_12px_28px_-8px_rgb(0_0_0/0.22)]"
103
+ aria-label={L.menu}
104
+ className={cn(
105
+ "z-[70] grid w-[320px] max-w-[calc(100vw-24px)] gap-[10px] rounded-[10px] p-[10px] shadow-[0_12px_28px_-8px_rgb(0_0_0/0.22)]",
106
+ // Longer tab names ("Personnalisé") or a sixth tab: the menu grows to fit its tabs,
107
+ // and on a phone too narrow for them the tab row scrolls.
108
+ wide && "w-max min-w-[320px] grid-cols-[minmax(0,1fr)]",
109
+ )}
85
110
  // The arrows sit outside the menu but inside the stepper: they step the period and leave it open.
86
111
  onInteractOutside={e => { if (ref.current?.contains(e.target as Node)) e.preventDefault() }}
87
112
  >
88
- <PickerMenu value={value} units={units} custom={custom} min={min} max={hi} today={today}
113
+ <PickerMenu value={value} units={units} custom={custom} min={min} max={hi} today={today} L={L} locale={locale} presets={presets} wide={wide}
89
114
  onPick={p => { onChange(p); setOpen(false) }} />
90
115
  </PopoverContent>
91
116
  </Popover>
92
117
  )
93
118
  }
94
119
 
95
- function PickerMenu({ value, units, custom, min, max, today, onPick }: {
120
+ function PickerMenu({ value, units, custom, min, max, today, L, locale, presets, wide, onPick }: {
96
121
  value: Period; units: Unit[]; custom: "month" | "day" | false; min?: string; max: string; today: string; onPick: (p: Period) => void
122
+ L: PeriodPickerLabels; locale?: string; presets?: readonly PeriodPreset[]; wide: boolean
97
123
  }) {
98
- const [tab, setTab] = React.useState<Unit | "custom">(value.unit === "custom" && !custom ? units[0] : value.unit)
124
+ const rolling = presets?.length ? presets : null
125
+ const [tab, setTab] = React.useState<Unit | "custom" | "presets">(
126
+ rolling && value.preset && rolling.includes(value.preset) ? "presets" : value.unit === "custom" && !custom ? units[0] : value.unit)
99
127
  const asMonth = custom === "month"
100
128
  const [from, setFrom] = React.useState(asMonth ? value.from.slice(0, 7) : value.from)
101
129
  const [to, setTo] = React.useState(asMonth ? value.to.slice(0, 7) : value.to)
102
- const list = tab === "custom" ? [] : (() => {
130
+ const list = tab === "custom" ? [] : tab === "presets" ? (rolling ?? []).flatMap(id => presetPeriod(id, today) ?? []) : (() => {
103
131
  const out: Period[] = []
104
132
  let p = periodOf(tab, max)
105
133
  for (let i = 0; i < RECENT[tab] && (!min || p.to >= min); i++, p = shift(p, -1)) out.push(p)
@@ -119,33 +147,35 @@ function PickerMenu({ value, units, custom, min, max, today, onPick }: {
119
147
  const input = "h-8 rounded-[6px] border border-border bg-card px-2 text-[14px] text-foreground [font:inherit]"
120
148
  return (
121
149
  <>
122
- {units.length + (custom ? 1 : 0) > 1 && <div data-slot="period-picker-tabs" className="flex gap-[2px] rounded-[8px] bg-muted p-[3px]" role="tablist">
123
- {units.map(u => <button key={u} type="button" role="tab" aria-selected={tab === u} className={tabClass(tab === u)} onClick={() => setTab(u)}>{UNIT_LABEL[u]}</button>)}
124
- {custom && <button type="button" role="tab" aria-selected={tab === "custom"} className={tabClass(tab === "custom")} onClick={() => setTab("custom")}>Custom</button>}
150
+ {units.length + (custom ? 1 : 0) + (rolling ? 1 : 0) > 1 && <div data-slot="period-picker-tabs" className={cn("flex gap-[2px] rounded-[8px] bg-muted p-[3px]", wide && "overflow-x-auto")} role="tablist">
151
+ {rolling && <button type="button" role="tab" aria-selected={tab === "presets"} className={tabClass(tab === "presets")} onClick={() => setTab("presets")}>{L.presets}</button>}
152
+ {units.map(u => <button key={u} type="button" role="tab" aria-selected={tab === u} className={tabClass(tab === u)} onClick={() => setTab(u)}>{L[u]}</button>)}
153
+ {custom && <button type="button" role="tab" aria-selected={tab === "custom"} className={tabClass(tab === "custom")} onClick={() => setTab("custom")}>{L.custom}</button>}
125
154
  </div>}
126
155
  {tab !== "custom" ? (
127
156
  <div data-slot="period-picker-grid" className={cn("grid gap-1", tab === "month" ? "grid-cols-3" : "grid-cols-2")}>
128
157
  {list.map(p => {
129
- const on = value.unit === p.unit && value.from === p.from
130
- const live = isCurrent(p, today)
158
+ const on = p.preset ? value.preset === p.preset : value.unit === p.unit && value.from === p.from && !value.preset
159
+ // Every preset runs to today: "in progress" under each would say nothing.
160
+ const live = !p.preset && isCurrent(p, today)
131
161
  return (
132
- <button key={p.from} type="button" data-current={live || undefined}
162
+ <button key={p.preset ?? p.from} type="button" data-current={live || undefined}
133
163
  className={cn(
134
164
  "grid cursor-pointer justify-items-center rounded-[6px] border border-transparent bg-transparent px-[6px] py-[7px] text-[13px] text-inherit tabular-nums",
135
165
  live && "text-brand",
136
166
  on ? "border-brand bg-[color-mix(in_srgb,var(--brand)_8%,transparent)] font-semibold" : "hover:bg-accent",
137
167
  )}
138
168
  onClick={() => onPick(p)}>
139
- {periodLabel(p)}{live && <small className="text-[10px] font-normal text-muted-foreground">in progress</small>}
169
+ {periodLabel(p, locale)}{live && <small className="text-[10px] font-normal text-muted-foreground">{L.inProgress}</small>}
140
170
  </button>
141
171
  )
142
172
  })}
143
173
  </div>
144
174
  ) : (
145
175
  <form data-slot="period-picker-custom" className="grid grid-cols-2 gap-2" onSubmit={e => { e.preventDefault(); if (r) onPick(r) }}>
146
- <label className="grid gap-1 text-[12px] text-muted-foreground">From<input className={input} type={asMonth ? "month" : "date"} value={from} min={min ? (asMonth ? min.slice(0, 7) : min) : undefined} max={asMonth ? max.slice(0, 7) : max} onChange={e => setFrom(e.target.value)} /></label>
147
- <label className="grid gap-1 text-[12px] text-muted-foreground">To<input className={input} type={asMonth ? "month" : "date"} value={to} min={from || undefined} max={asMonth ? max.slice(0, 7) : max} onChange={e => setTo(e.target.value)} /></label>
148
- <button type="submit" className="col-span-full h-8 cursor-pointer rounded-[6px] border-0 bg-brand font-semibold text-white disabled:cursor-default disabled:opacity-45" disabled={!r}>Apply</button>
176
+ <label className="grid gap-1 text-[12px] text-muted-foreground">{L.from}<input className={input} type={asMonth ? "month" : "date"} value={from} min={min ? (asMonth ? min.slice(0, 7) : min) : undefined} max={asMonth ? max.slice(0, 7) : max} onChange={e => setFrom(e.target.value)} /></label>
177
+ <label className="grid gap-1 text-[12px] text-muted-foreground">{L.to}<input className={input} type={asMonth ? "month" : "date"} value={to} min={from || undefined} max={asMonth ? max.slice(0, 7) : max} onChange={e => setTo(e.target.value)} /></label>
178
+ <button type="submit" className="col-span-full h-8 cursor-pointer rounded-[6px] border-0 bg-brand font-semibold text-white disabled:cursor-default disabled:opacity-45" disabled={!r}>{L.apply}</button>
149
179
  </form>
150
180
  )}
151
181
  </>
@@ -1,10 +1,15 @@
1
1
  // Periods for the date filters (2.27): a week, month, quarter or year, or a
2
2
  // custom range. Dates are ISO 'YYYY-MM-DD' strings in UTC, both ends
3
- // inclusive. Pure functions only, no imports. Ported 1:1 from the workspace's
4
- // apps/attrition-por-cohorte/src/ui/period.ts.
3
+ // inclusive. Pure functions only. Ported 1:1 from the workspace's
4
+ // apps/attrition-por-cohorte/src/ui/period.ts. 2.29: localized labels
5
+ // (`periodLabel(p, locale)`) and rolling presets (`presetPeriod`).
6
+ import { localeStrings } from "../locale.js";
5
7
 
6
8
  export type Unit = "week" | "month" | "quarter" | "year";
7
- export type Period = { unit: Unit | "custom"; from: string; to: string };
9
+ /** A rolling preset (2.29): the last N days ("28d") or month, quarter, year to date. All end today. */
10
+ export type PeriodPreset = `${number}d` | "mtd" | "qtd" | "ytd";
11
+ /** `preset` (2.29) marks a range picked as a rolling preset: write it to the URL as `period=28d`. */
12
+ export type Period = { unit: Unit | "custom"; from: string; to: string; preset?: PeriodPreset };
8
13
 
9
14
  const d = (iso: string) => new Date(iso + "T00:00:00Z");
10
15
  const iso = (x: Date) => x.toISOString().slice(0, 10);
@@ -46,6 +51,9 @@ const wholeMonths = (p: Period) => p.from.slice(8) === "01" && addDays(p.to, 1).
46
51
 
47
52
  /** The period k steps later (k < 0: earlier). A custom range moves by its own length. */
48
53
  export function shift(p: Period, k: number): Period {
54
+ // Month, quarter or year to date steps to the whole unit before (or after) it.
55
+ const toDate = p.preset && TO_DATE[p.preset as keyof typeof TO_DATE];
56
+ if (toDate) return shift(periodOf(toDate, p.from), k);
49
57
  if (p.unit === "week") return periodOf("week", addDays(p.from, 7 * k));
50
58
  if (p.unit !== "custom") return periodOf(p.unit, addMonths(p.from, stepMonths[p.unit] * k));
51
59
  if (wholeMonths(p)) {
@@ -65,8 +73,14 @@ const MON = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct
65
73
  const day = (s: string, withYear = true) => `${Number(s.slice(8))} ${MON[Number(s.slice(5, 7)) - 1]}${withYear ? ` ${s.slice(0, 4)}` : ""}`;
66
74
  const month = (s: string, withYear = true) => `${MON[Number(s.slice(5, 7)) - 1]}${withYear ? ` ${s.slice(0, 4)}` : ""}`;
67
75
 
68
- /** "Nov 2026", "Q4 2026", "2026", "17–23 Nov 2026", "Sep – Nov 2026". */
69
- export function periodLabel(p: Period): string {
76
+ /**
77
+ * "Nov 2026", "Q4 2026", "2026", "17–23 Nov 2026", "Sep – Nov 2026".
78
+ * With a `locale` (2.29) the month names come from Intl in that language
79
+ * ("nov. 2026", "16.–22. Nov 2026"). A preset reads as its name: "Last 28 days", "28 derniers jours".
80
+ */
81
+ export function periodLabel(p: Period, locale?: string): string {
82
+ if (p.preset) return presetLabel(p.preset, locale);
83
+ if (locale) return localLabel(p, locale);
70
84
  if (p.unit === "year") return p.from.slice(0, 4);
71
85
  if (p.unit === "quarter") return `Q${Math.floor(Number(p.from.slice(5, 7)) / 3) + 1} ${p.from.slice(0, 4)}`;
72
86
  if (p.unit === "month") return month(p.from);
@@ -81,3 +95,38 @@ export function periodLabel(p: Period): string {
81
95
  }
82
96
 
83
97
  export const UNIT_LABEL: Record<Unit, string> = { week: "Week", month: "Month", quarter: "Quarter", year: "Year" };
98
+
99
+ const TO_DATE = { mtd: "month", qtd: "quarter", ytd: "year" } as const;
100
+
101
+ /** A preset's dates on `today`: `presetPeriod("28d")` is the 28 days ending today. Null for an unknown id. */
102
+ export function presetPeriod(id: string | null | undefined, today = todayIso()): Period | null {
103
+ const days = /^([1-9]\d{0,3})d$/.exec(id ?? "");
104
+ const unit = TO_DATE[id as keyof typeof TO_DATE];
105
+ if (!days && !unit) return null;
106
+ const from = days ? addDays(today, 1 - Number(days[1])) : startOf(unit, today);
107
+ return { unit: "custom", from, to: today, preset: id as PeriodPreset };
108
+ }
109
+
110
+ /** A preset's name: "Last 28 days", "Month to date"; localized with `locale`. */
111
+ export function presetLabel(id: PeriodPreset, locale?: string, labels?: { lastDays?: (n: number) => string; mtd?: string; qtd?: string; ytd?: string }): string {
112
+ const L = localeStrings("period", locale, labels);
113
+ return /^\d+d$/.test(id) ? L.lastDays(Number(id.slice(0, -1))) : L[id as "mtd" | "qtd" | "ytd"];
114
+ }
115
+
116
+ function localLabel(p: Period, locale: string): string {
117
+ const fmt = new Intl.DateTimeFormat(locale, { month: "short", timeZone: "UTC" });
118
+ const de = /^de\b/i.test(locale);
119
+ const mon = (s: string, withYear = true) => `${fmt.format(d(s))}${withYear ? ` ${s.slice(0, 4)}` : ""}`;
120
+ const dd = (s: string) => `${Number(s.slice(8))}${de ? "." : ""}`;
121
+ const dayL = (s: string, withYear = true) => `${dd(s)} ${mon(s, withYear)}`;
122
+ if (p.unit === "year") return p.from.slice(0, 4);
123
+ if (p.unit === "quarter") return localeStrings("period", locale).quarterLabel(Math.floor(Number(p.from.slice(5, 7)) / 3) + 1, p.from.slice(0, 4));
124
+ if (p.unit === "month") return mon(p.from);
125
+ const sameYear = p.from.slice(0, 4) === p.to.slice(0, 4);
126
+ if (p.unit === "custom" && wholeMonths(p)) {
127
+ const last = addDays(p.to, 1 - Number(p.to.slice(8)));
128
+ return last === p.from ? mon(p.from) : `${mon(p.from, !sameYear)} – ${mon(last)}`;
129
+ }
130
+ const sameMonth = sameYear && p.from.slice(5, 7) === p.to.slice(5, 7);
131
+ return sameMonth ? `${dd(p.from)}–${dayL(p.to)}` : `${dayL(p.from, !sameYear)} – ${dayL(p.to)}`;
132
+ }
package/index.js CHANGED
@@ -38,7 +38,7 @@ import {
38
38
  * in a page (or this export) says which SDK a deployed app actually runs.
39
39
  * Kept in step with package.json by snapshot.test.mjs.
40
40
  */
41
- export const SDK_VERSION = "2.28.0";
41
+ export const SDK_VERSION = "2.29.0";
42
42
  if (typeof window !== "undefined") {
43
43
  try {
44
44
  window.__MAKO_APP_SDK__ = SDK_VERSION;
package/locale.d.ts ADDED
@@ -0,0 +1,122 @@
1
+ // @makoai/app-sdk strings table (2.29). Re-exported from "@makoai/app-sdk/ui" and "/components".
2
+
3
+ /** The languages the SDK ships strings for. */
4
+ export type LocaleLang = "en" | "fr" | "de" | "it" | "es" | "pl" | "pt";
5
+ export const LOCALES: readonly LocaleLang[];
6
+ /** "fr-CH" → "fr". An unknown language or no locale → "en". */
7
+ export function localeLang(locale?: string | null): LocaleLang;
8
+
9
+ /** Every fixed text of PeriodPicker. Override any with `labels`. */
10
+ export interface PeriodPickerLabels {
11
+ /** The trigger's screen-reader name when `label` is not set. Default "Time". */
12
+ time: string;
13
+ /** The ‹ button's aria-label. Default "Previous period". */
14
+ previous: string;
15
+ /** The › button's aria-label. Default "Next period". */
16
+ next: string;
17
+ /** The menu's aria-label. Default "Pick a period". */
18
+ menu: string;
19
+ /** The unit tabs. Default "Week", "Month", "Quarter", "Year", "Custom". */
20
+ week: string;
21
+ month: string;
22
+ quarter: string;
23
+ year: string;
24
+ custom: string;
25
+ /** The tab of the `presets`. Default "Shortcuts". */
26
+ presets: string;
27
+ /** Under the period in progress in the grid. Default "in progress". */
28
+ inProgress: string;
29
+ /** The trigger's hover title on the period in progress. Default "In progress: the numbers are not final yet". */
30
+ inProgressTitle: string;
31
+ /** The custom range's fields and button. Default "From", "To", "Apply". */
32
+ from: string;
33
+ to: string;
34
+ apply: string;
35
+ /** A quarter, used only with `locale`. Default `Q4 2026`; French `T4 2026`. */
36
+ quarterLabel: (quarter: number, year: string) => string;
37
+ /** A rolling preset. Default `Last 28 days`. */
38
+ lastDays: (n: number) => string;
39
+ /** The to-date presets. Default "Month to date", "Quarter to date", "Year to date". */
40
+ mtd: string;
41
+ qtd: string;
42
+ ytd: string;
43
+ }
44
+
45
+ /** Every fixed text of FilterBar. */
46
+ export interface FilterBarLabels {
47
+ /** The phone chip, the sheet's title and the bar's aria-label. Default "Filters". */
48
+ filters: string;
49
+ /** Default "Reset". */
50
+ reset: string;
51
+ /** Reset's hover title. Default "Back to the default filters". */
52
+ resetTitle: string;
53
+ /** The sheet's close button. Default "Done". */
54
+ done: string;
55
+ }
56
+
57
+ /** Every fixed text of MultiSelect, FilterItems and FilterMenu. Explicit props (`allLabel`, `noneLabel`, `formatMany`, `searchPlaceholder`, `searchEmpty`) win. */
58
+ export interface FilterLabels {
59
+ /** The first row and the trigger under All. Default "All". */
60
+ all: string;
61
+ /** The trigger while nothing is ticked. Default "None". */
62
+ none: string;
63
+ /** The trigger for several values. Default `3 selected`. */
64
+ many: (n: number) => string;
65
+ /** The hover action that picks one row alone. Default "Only". */
66
+ only: string;
67
+ /** The search input's placeholder and name. Default "Search". */
68
+ search: string;
69
+ /** Shown when no row matches. Default "No match". */
70
+ noMatch: string;
71
+ /** FilterMenu: a group's own first row. Default `All Pages`. */
72
+ groupAll: (label: string) => string;
73
+ }
74
+
75
+ /** Every fixed text of Combobox. Explicit props (`placeholder`, `searchPlaceholder`, `emptyText`) win. */
76
+ export interface ComboboxLabels {
77
+ /** Default "Select...". */
78
+ placeholder: string;
79
+ /** Default "Search...". */
80
+ search: string;
81
+ /** Default "No results found.". */
82
+ empty: string;
83
+ }
84
+
85
+ /** A non-English DataTable set: plain strings, plus `rows` (the default noun) and `of` ("51–100 of 312"). */
86
+ export interface DataTableLocaleStrings {
87
+ rows: string;
88
+ of: string;
89
+ empty: string;
90
+ page: (page: number, pageCount: number) => string;
91
+ perPage: (size: number) => string;
92
+ rowsPerPage: string;
93
+ first: string;
94
+ previous: string;
95
+ next: string;
96
+ last: string;
97
+ sortHint: (label: string) => string;
98
+ exportCsv: string;
99
+ exportTitle: string;
100
+ exportFailed: string;
101
+ expand: string;
102
+ collapse: string;
103
+ info: (label: string) => string;
104
+ }
105
+
106
+ export interface LocaleStrings {
107
+ period: PeriodPickerLabels;
108
+ filterBar: FilterBarLabels;
109
+ filter: FilterLabels;
110
+ combobox: ComboboxLabels;
111
+ /** Absent in en: DataTable's English set is DATA_TABLE_LABELS. */
112
+ dataTable?: DataTableLocaleStrings;
113
+ }
114
+ /** The one strings table, by language. */
115
+ export const STRINGS: Readonly<Record<LocaleLang, LocaleStrings>>;
116
+ /** One section for a locale, with `labels` on top. */
117
+ export function localeStrings<K extends "period" | "filterBar" | "filter" | "combobox">(
118
+ section: K,
119
+ locale?: string | null,
120
+ labels?: Partial<LocaleStrings[K]> | null,
121
+ ): LocaleStrings[K];
122
+ export function localeStrings(section: "dataTable", locale?: string | null, labels?: null): DataTableLocaleStrings | Record<string, never>;
package/locale.js ADDED
@@ -0,0 +1,178 @@
1
+ // The SDK's one strings table (2.29): every fixed text the filters and the
2
+ // table write themselves, in the 7 RealAdvisor languages. A component takes
3
+ // `locale` (BCP 47, "fr-CH") and matches on the language part; `labels`
4
+ // overrides single strings on top. No `locale`: English, exactly as before.
5
+ // Plain data and pure functions, no imports, so ui.js and the TSX share it.
6
+
7
+ export const LOCALES = ["en", "fr", "de", "it", "es", "pl", "pt"];
8
+
9
+ /** "fr-CH" → "fr". An unknown language or no locale → "en". */
10
+ export function localeLang(locale) {
11
+ const lang = String(locale ?? "").toLowerCase().split(/[-_]/)[0];
12
+ return LOCALES.includes(lang) ? lang : "en";
13
+ }
14
+
15
+ const en = {
16
+ period: {
17
+ time: "Time", previous: "Previous period", next: "Next period", menu: "Pick a period",
18
+ week: "Week", month: "Month", quarter: "Quarter", year: "Year", custom: "Custom", presets: "Shortcuts",
19
+ inProgress: "in progress", inProgressTitle: "In progress: the numbers are not final yet",
20
+ from: "From", to: "To", apply: "Apply",
21
+ quarterLabel: (q, y) => `Q${q} ${y}`,
22
+ lastDays: n => `Last ${n} days`, mtd: "Month to date", qtd: "Quarter to date", ytd: "Year to date",
23
+ },
24
+ filterBar: { filters: "Filters", reset: "Reset", resetTitle: "Back to the default filters", done: "Done" },
25
+ filter: { all: "All", none: "None", many: n => `${n} selected`, only: "Only", search: "Search", noMatch: "No match", groupAll: label => `All ${label}` },
26
+ combobox: { placeholder: "Select...", search: "Search...", empty: "No results found." },
27
+ // DataTable's English set is DATA_TABLE_LABELS in ui.js (its range is JSX).
28
+ };
29
+
30
+ const fr = {
31
+ period: {
32
+ time: "Période", previous: "Période précédente", next: "Période suivante", menu: "Choisir une période",
33
+ week: "Semaine", month: "Mois", quarter: "Trimestre", year: "Année", custom: "Personnalisé", presets: "Raccourcis",
34
+ inProgress: "en cours", inProgressTitle: "En cours : les chiffres ne sont pas encore définitifs",
35
+ from: "Du", to: "Au", apply: "Appliquer",
36
+ quarterLabel: (q, y) => `T${q} ${y}`,
37
+ lastDays: n => `${n} derniers jours`, mtd: "Ce mois-ci", qtd: "Ce trimestre", ytd: "Cette année",
38
+ },
39
+ filterBar: { filters: "Filtres", reset: "Réinitialiser", resetTitle: "Revenir aux filtres par défaut", done: "Terminé" },
40
+ filter: { all: "Tous", none: "Aucun", many: n => `${n} sélectionnés`, only: "Seulement", search: "Rechercher", noMatch: "Aucun résultat", groupAll: label => `${label} (tout)` },
41
+ combobox: { placeholder: "Choisir…", search: "Rechercher…", empty: "Aucun résultat." },
42
+ dataTable: {
43
+ rows: "lignes", of: "sur", empty: "Aucune ligne pour ces filtres.",
44
+ page: (p, n) => `Page ${p} sur ${n}`, perPage: s => `${s} par page`, rowsPerPage: "Lignes par page",
45
+ first: "Première page", previous: "Page précédente", next: "Page suivante", last: "Dernière page",
46
+ sortHint: l => `${l} · cliquer pour trier`, exportCsv: "Exporter en CSV",
47
+ exportTitle: "Exporter toutes les lignes de toutes les pages, dans l'ordre du tri",
48
+ exportFailed: "Le navigateur a bloqué le téléchargement. Ouvrez l'app dans un nouvel onglet et exportez à nouveau.",
49
+ expand: "Afficher le détail", collapse: "Masquer le détail", info: l => `À propos de ${l}`,
50
+ },
51
+ };
52
+
53
+ const de = {
54
+ period: {
55
+ time: "Zeitraum", previous: "Vorheriger Zeitraum", next: "Nächster Zeitraum", menu: "Zeitraum wählen",
56
+ week: "Woche", month: "Monat", quarter: "Quartal", year: "Jahr", custom: "Individuell", presets: "Schnellwahl",
57
+ inProgress: "laufend", inProgressTitle: "Laufend: die Zahlen sind noch nicht endgültig",
58
+ from: "Von", to: "Bis", apply: "Anwenden",
59
+ quarterLabel: (q, y) => `Q${q} ${y}`,
60
+ lastDays: n => `Letzte ${n} Tage`, mtd: "Dieser Monat", qtd: "Dieses Quartal", ytd: "Dieses Jahr",
61
+ },
62
+ filterBar: { filters: "Filter", reset: "Zurücksetzen", resetTitle: "Zurück zu den Standardfiltern", done: "Fertig" },
63
+ filter: { all: "Alle", none: "Keine", many: n => `${n} ausgewählt`, only: "Nur", search: "Suchen", noMatch: "Keine Treffer", groupAll: label => `${label} (alle)` },
64
+ combobox: { placeholder: "Auswählen…", search: "Suchen…", empty: "Keine Ergebnisse." },
65
+ dataTable: {
66
+ rows: "Zeilen", of: "von", empty: "Keine Zeilen für diese Filter.",
67
+ page: (p, n) => `Seite ${p} von ${n}`, perPage: s => `${s} pro Seite`, rowsPerPage: "Zeilen pro Seite",
68
+ first: "Erste Seite", previous: "Vorherige Seite", next: "Nächste Seite", last: "Letzte Seite",
69
+ sortHint: l => `${l} · klicken zum Sortieren`, exportCsv: "CSV exportieren",
70
+ exportTitle: "Alle Zeilen aller Seiten exportieren, in der aktuellen Sortierung",
71
+ exportFailed: "Der Browser hat den Download blockiert. Öffnen Sie die App in einem neuen Tab und exportieren Sie erneut.",
72
+ expand: "Details anzeigen", collapse: "Details ausblenden", info: l => `Info zu ${l}`,
73
+ },
74
+ };
75
+
76
+ const it = {
77
+ period: {
78
+ time: "Periodo", previous: "Periodo precedente", next: "Periodo successivo", menu: "Scegli un periodo",
79
+ week: "Settimana", month: "Mese", quarter: "Trimestre", year: "Anno", custom: "Personalizzato", presets: "Scorciatoie",
80
+ inProgress: "in corso", inProgressTitle: "In corso: i numeri non sono ancora definitivi",
81
+ from: "Da", to: "A", apply: "Applica",
82
+ quarterLabel: (q, y) => `T${q} ${y}`,
83
+ lastDays: n => `Ultimi ${n} giorni`, mtd: "Questo mese", qtd: "Questo trimestre", ytd: "Quest'anno",
84
+ },
85
+ filterBar: { filters: "Filtri", reset: "Reimposta", resetTitle: "Torna ai filtri predefiniti", done: "Fatto" },
86
+ filter: { all: "Tutti", none: "Nessuno", many: n => `${n} selezionati`, only: "Solo", search: "Cerca", noMatch: "Nessun risultato", groupAll: label => `${label} (tutti)` },
87
+ combobox: { placeholder: "Seleziona…", search: "Cerca…", empty: "Nessun risultato." },
88
+ dataTable: {
89
+ rows: "righe", of: "di", empty: "Nessuna riga per questi filtri.",
90
+ page: (p, n) => `Pagina ${p} di ${n}`, perPage: s => `${s} per pagina`, rowsPerPage: "Righe per pagina",
91
+ first: "Prima pagina", previous: "Pagina precedente", next: "Pagina successiva", last: "Ultima pagina",
92
+ sortHint: l => `${l} · clicca per ordinare`, exportCsv: "Esporta CSV",
93
+ exportTitle: "Esporta tutte le righe di tutte le pagine, nell'ordine attuale",
94
+ exportFailed: "Il browser ha bloccato il download. Apri l'app in una nuova scheda ed esporta di nuovo.",
95
+ expand: "Mostra dettagli", collapse: "Nascondi dettagli", info: l => `Info su ${l}`,
96
+ },
97
+ };
98
+
99
+ const es = {
100
+ period: {
101
+ time: "Periodo", previous: "Periodo anterior", next: "Periodo siguiente", menu: "Elegir un periodo",
102
+ week: "Semana", month: "Mes", quarter: "Trimestre", year: "Año", custom: "Personalizado", presets: "Atajos",
103
+ inProgress: "en curso", inProgressTitle: "En curso: las cifras aún no son definitivas",
104
+ from: "Desde", to: "Hasta", apply: "Aplicar",
105
+ quarterLabel: (q, y) => `T${q} ${y}`,
106
+ lastDays: n => `Últimos ${n} días`, mtd: "Este mes", qtd: "Este trimestre", ytd: "Este año",
107
+ },
108
+ filterBar: { filters: "Filtros", reset: "Restablecer", resetTitle: "Volver a los filtros por defecto", done: "Listo" },
109
+ filter: { all: "Todos", none: "Ninguno", many: n => `${n} seleccionados`, only: "Solo", search: "Buscar", noMatch: "Sin resultados", groupAll: label => `${label} (todo)` },
110
+ combobox: { placeholder: "Seleccionar…", search: "Buscar…", empty: "Sin resultados." },
111
+ dataTable: {
112
+ rows: "filas", of: "de", empty: "Ninguna fila con estos filtros.",
113
+ page: (p, n) => `Página ${p} de ${n}`, perPage: s => `${s} por página`, rowsPerPage: "Filas por página",
114
+ first: "Primera página", previous: "Página anterior", next: "Página siguiente", last: "Última página",
115
+ sortHint: l => `${l} · clic para ordenar`, exportCsv: "Exportar CSV",
116
+ exportTitle: "Exportar todas las filas de todas las páginas, en el orden actual",
117
+ exportFailed: "El navegador bloqueó la descarga. Abre la app en una pestaña nueva y exporta de nuevo.",
118
+ expand: "Ver detalles", collapse: "Ocultar detalles", info: l => `Acerca de ${l}`,
119
+ },
120
+ };
121
+
122
+ const pl = {
123
+ period: {
124
+ time: "Okres", previous: "Poprzedni okres", next: "Następny okres", menu: "Wybierz okres",
125
+ week: "Tydzień", month: "Miesiąc", quarter: "Kwartał", year: "Rok", custom: "Własny", presets: "Skróty",
126
+ inProgress: "w toku", inProgressTitle: "W toku: liczby nie są jeszcze ostateczne",
127
+ from: "Od", to: "Do", apply: "Zastosuj",
128
+ quarterLabel: (q, y) => `Q${q} ${y}`,
129
+ lastDays: n => `Ostatnie ${n} dni`, mtd: "Ten miesiąc", qtd: "Ten kwartał", ytd: "Ten rok",
130
+ },
131
+ filterBar: { filters: "Filtry", reset: "Resetuj", resetTitle: "Przywróć domyślne filtry", done: "Gotowe" },
132
+ filter: { all: "Wszystkie", none: "Brak", many: n => `Wybrano: ${n}`, only: "Tylko", search: "Szukaj", noMatch: "Brak wyników", groupAll: label => `${label} (wszystko)` },
133
+ combobox: { placeholder: "Wybierz…", search: "Szukaj…", empty: "Brak wyników." },
134
+ dataTable: {
135
+ rows: "wierszy", of: "z", empty: "Brak wierszy dla tych filtrów.",
136
+ page: (p, n) => `Strona ${p} z ${n}`, perPage: s => `${s} na stronę`, rowsPerPage: "Wierszy na stronę",
137
+ first: "Pierwsza strona", previous: "Poprzednia strona", next: "Następna strona", last: "Ostatnia strona",
138
+ sortHint: l => `${l} · kliknij, aby sortować`, exportCsv: "Eksportuj CSV",
139
+ exportTitle: "Eksportuj wszystkie wiersze ze wszystkich stron, w bieżącej kolejności",
140
+ exportFailed: "Przeglądarka zablokowała pobieranie. Otwórz aplikację w nowej karcie i wyeksportuj ponownie.",
141
+ expand: "Pokaż szczegóły", collapse: "Ukryj szczegóły", info: l => `Informacje: ${l}`,
142
+ },
143
+ };
144
+
145
+ const pt = {
146
+ period: {
147
+ time: "Período", previous: "Período anterior", next: "Período seguinte", menu: "Escolher um período",
148
+ week: "Semana", month: "Mês", quarter: "Trimestre", year: "Ano", custom: "Personalizado", presets: "Atalhos",
149
+ inProgress: "em curso", inProgressTitle: "Em curso: os números ainda não são definitivos",
150
+ from: "De", to: "Até", apply: "Aplicar",
151
+ quarterLabel: (q, y) => `T${q} ${y}`,
152
+ lastDays: n => `Últimos ${n} dias`, mtd: "Este mês", qtd: "Este trimestre", ytd: "Este ano",
153
+ },
154
+ filterBar: { filters: "Filtros", reset: "Repor", resetTitle: "Voltar aos filtros predefinidos", done: "Concluído" },
155
+ filter: { all: "Todos", none: "Nenhum", many: n => `${n} selecionados`, only: "Apenas", search: "Procurar", noMatch: "Sem resultados", groupAll: label => `${label} (tudo)` },
156
+ combobox: { placeholder: "Selecionar…", search: "Procurar…", empty: "Sem resultados." },
157
+ dataTable: {
158
+ rows: "linhas", of: "de", empty: "Nenhuma linha com estes filtros.",
159
+ page: (p, n) => `Página ${p} de ${n}`, perPage: s => `${s} por página`, rowsPerPage: "Linhas por página",
160
+ first: "Primeira página", previous: "Página anterior", next: "Página seguinte", last: "Última página",
161
+ sortHint: l => `${l} · clique para ordenar`, exportCsv: "Exportar CSV",
162
+ exportTitle: "Exportar todas as linhas de todas as páginas, pela ordem atual",
163
+ exportFailed: "O navegador bloqueou a transferência. Abra a app num novo separador e exporte de novo.",
164
+ expand: "Ver detalhes", collapse: "Ocultar detalhes", info: l => `Sobre ${l}`,
165
+ },
166
+ };
167
+
168
+ /** Every language's strings, by section: period, filterBar, filter, combobox, dataTable (not in en). */
169
+ export const STRINGS = { en, fr, de, it, es, pl, pt };
170
+
171
+ /**
172
+ * One section's strings for a locale, with `labels` on top. No locale and no
173
+ * labels returns the English object itself.
174
+ */
175
+ export function localeStrings(section, locale, labels) {
176
+ const base = STRINGS[localeLang(locale)][section] ?? en[section] ?? {};
177
+ return labels ? { ...base, ...labels } : base;
178
+ }
@@ -10,6 +10,9 @@
10
10
  // The selection model is the kit's (2.20, `filter*` in ui-core.js): a
11
11
  // selection is a list of leaf values, [] means All, and "nothing ticked" is
12
12
  // a draft that emits nothing until the next tick.
13
+ //
14
+ // 2.29: `locale` and `labels` translate All, None, Only, "All <group>" and
15
+ // "N selected" from the SDK's strings table (../locale.js).
13
16
  import * as React from "react";
14
17
  import { ChevronDown, ChevronRight } from "lucide-react";
15
18
  import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui";
@@ -25,6 +28,7 @@ import {
25
28
  filterToggleAll,
26
29
  type FilterTick,
27
30
  } from "../ui.js";
31
+ import { localeStrings, type FilterLabels } from "../locale.js";
28
32
  import { Checkbox } from "./checkbox";
29
33
  import {
30
34
  DropdownMenu,
@@ -63,8 +67,12 @@ export interface FilterMenuItemsProps {
63
67
  selected?: readonly string[];
64
68
  value?: readonly string[];
65
69
  onChange: (selected: string[]) => void;
66
- /** The first row ("All traffic"). */
67
- allLabel: string;
70
+ /** The first row ("All traffic"). Default "All" (`labels.all`). */
71
+ allLabel?: string;
72
+ /** Mako thin prop (2.29): BCP 47 tag, e.g. "fr-CH": All, None, Only, "All <group>", "N selected" in that language. Default English. */
73
+ locale?: string;
74
+ /** Mako thin prop (2.29): override single texts on top of the locale. The explicit props win. */
75
+ labels?: Partial<FilterLabels>;
68
76
  /** What All emits: [] (default) or every leaf value (false). */
69
77
  emptyMeansAll?: boolean;
70
78
  /** The "nothing ticked" draft, when the owner shows it (FilterMenu's trigger). Uncontrolled otherwise. */
@@ -86,6 +94,11 @@ export interface FilterMenuItemsProps {
86
94
  */
87
95
  export function FilterMenuItems(props: FilterMenuItemsProps) {
88
96
  const { options, drill, emptyMeansAll = true } = props;
97
+ const L = localeStrings("filter", props.locale, props.labels);
98
+ const allLabel = props.allLabel ?? L.all;
99
+ // English keeps 2.28's two text nodes ("All ", label); a locale writes one string.
100
+ const translated = props.locale != null || props.labels?.groupAll != null;
101
+ const groupAllText = (label: string) => (translated ? L.groupAll(label) : <>All {label}</>);
89
102
  const selected = filterNormalize(options, props.selected ?? props.value ?? []);
90
103
  const [ownNone, setOwnNone] = React.useState(false);
91
104
  const none = props.none ?? ownNone;
@@ -109,7 +122,7 @@ export function FilterMenuItems(props: FilterMenuItemsProps) {
109
122
  const onlyButton = (node: FilterMenuOption) =>
110
123
  empty(node) ? null : (
111
124
  <span role="button" tabIndex={-1} className="mk-fm-only" onClick={only(node)} onPointerUp={e => e.stopPropagation()}>
112
- Only
125
+ {L.only}
113
126
  </span>
114
127
  );
115
128
 
@@ -144,7 +157,7 @@ export function FilterMenuItems(props: FilterMenuItemsProps) {
144
157
  <span
145
158
  role="checkbox"
146
159
  aria-checked={st === "on" ? true : st === "mixed" ? "mixed" : false}
147
- aria-label={`All ${node.label}`}
160
+ aria-label={L.groupAll(node.label)}
148
161
  aria-disabled={empty(node) || undefined}
149
162
  className="flex"
150
163
  onClick={e => {
@@ -169,7 +182,7 @@ export function FilterMenuItems(props: FilterMenuItemsProps) {
169
182
  }}
170
183
  >
171
184
  <Tick state={st} />
172
- <span className="flex-1">All {node.label}</span>
185
+ <span className="flex-1">{groupAllText(node.label)}</span>
173
186
  </DropdownMenuPrimitive.CheckboxItem>
174
187
  );
175
188
 
@@ -235,7 +248,7 @@ export function FilterMenuItems(props: FilterMenuItemsProps) {
235
248
  }}
236
249
  >
237
250
  <Tick state={allSt} />
238
- <span className="flex-1">{props.allLabel}</span>
251
+ <span className="flex-1">{allLabel}</span>
239
252
  </DropdownMenuPrimitive.CheckboxItem>
240
253
  <DropdownMenuSeparator />
241
254
  {level(options)}
@@ -268,10 +281,13 @@ export interface FilterMenuProps extends Omit<FilterMenuItemsProps, "none" | "on
268
281
 
269
282
  /** The filter dropdown: the kit's trigger (`mk-ms-trigger`) over FilterMenuItems. */
270
283
  export function FilterMenu(props: FilterMenuProps) {
271
- const { options, allLabel, noneLabel = "None" } = props;
284
+ const { options } = props;
285
+ const L = localeStrings("filter", props.locale, props.labels);
286
+ const allLabel = props.allLabel ?? L.all;
287
+ const noneLabel = props.noneLabel ?? L.none;
272
288
  const selected = filterNormalize(options, props.selected ?? props.value ?? []);
273
289
  const [none, setNone] = React.useState(false);
274
- const text = none ? noneLabel : (props.summary ?? filterText(options, selected, allLabel, props.formatMany));
290
+ const text = none ? noneLabel : (props.summary ?? filterText(options, selected, allLabel, props.formatMany ?? L.many));
275
291
  const probes = [...(props.sizeTo ?? [allLabel, ...options.map(o => o.label)]), ...(props.probes ?? [])];
276
292
  return (
277
293
  <DropdownMenu
@@ -302,6 +318,8 @@ export function FilterMenu(props: FilterMenuProps) {
302
318
  selected={selected}
303
319
  onChange={props.onChange}
304
320
  allLabel={allLabel}
321
+ locale={props.locale}
322
+ labels={props.labels}
305
323
  emptyMeansAll={props.emptyMeansAll}
306
324
  none={none}
307
325
  onNoneChange={setNone}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makoai/app-sdk",
3
- "version": "2.28.0",
3
+ "version": "2.29.0",
4
4
  "description": "Mako app SDK: data bindings (useQuery/useDuckDB), URL state, theme, and the house dashboard kit (/ui).",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -76,6 +76,8 @@
76
76
  "ui.js",
77
77
  "ui-core.js",
78
78
  "ui.d.ts",
79
+ "locale.js",
80
+ "locale.d.ts",
79
81
  "ui.css",
80
82
  "tailwind.css",
81
83
  "menu/",
package/ui-core.js CHANGED
@@ -144,9 +144,11 @@ export function compareValues(a, b) {
144
144
 
145
145
  /**
146
146
  * The direction a column sorts in on its first click: numbers largest first
147
- * (`num: true`), text A→Z.
147
+ * (`num: true`), text A→Z. `sortDescFirst` (2.29, TanStack's name) overrides
148
+ * it: false sorts a number or date column smallest (soonest) first.
148
149
  */
149
150
  export function firstSortDir(column) {
151
+ if (column?.sortDescFirst != null) return column.sortDescFirst ? "desc" : "asc";
150
152
  return column?.num ? "desc" : "asc";
151
153
  }
152
154
 
package/ui.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import type * as React from "react";
2
+ import type { FilterLabels } from "./locale.js";
3
+
4
+ export * from "./locale.js";
2
5
 
3
6
  /** ok | warn | bad (or green | amber | red), plus loading and neutral. */
4
7
  export type Tone =
@@ -110,6 +113,13 @@ export interface FilterItemsProps<V extends string = string> {
110
113
  searchPlaceholder?: string;
111
114
  /** Shown when no row matches. Default "No match". */
112
115
  searchEmpty?: string;
116
+ /**
117
+ * BCP 47 tag (2.29), e.g. "fr-CH": All, Only, Search and No match in that
118
+ * language, from the SDK's strings table; counts format in it. Default English.
119
+ */
120
+ locale?: string;
121
+ /** Override single texts on top of the locale (2.29). The explicit props win. */
122
+ labels?: Partial<FilterLabels>;
113
123
  className?: string;
114
124
  "aria-label"?: string;
115
125
  }
@@ -161,6 +171,10 @@ export interface MultiSelectProps<V extends string = string> {
161
171
  searchPlaceholder?: string;
162
172
  /** Default "No match". */
163
173
  searchEmpty?: string;
174
+ /** BCP 47 tag (2.29), e.g. "fr-CH": All, None, "N selected", Only, Search and No match in that language. Default English. */
175
+ locale?: string;
176
+ /** Override single texts on top of the locale (2.29). The explicit props win. */
177
+ labels?: Partial<FilterLabels>;
164
178
  className?: string;
165
179
  "aria-label"?: string;
166
180
  }
@@ -408,6 +422,12 @@ export interface DataTableColumn<R = any> {
408
422
  sticky?: boolean;
409
423
  /** Default true. */
410
424
  sortable?: boolean;
425
+ /**
426
+ * The first click's direction (2.29, TanStack Table's name). Default: true
427
+ * for `num` columns (largest first), false otherwise (A→Z). `false` on a
428
+ * days-to-renewal column sorts soonest first. The next click flips it.
429
+ */
430
+ sortDescFirst?: boolean;
411
431
  /** Header hover text, e.g. the column's definition. */
412
432
  hint?: string;
413
433
  /**
@@ -489,6 +509,8 @@ export interface DataTableLabels {
489
509
  export type DataTableExpanded = true | Record<string, boolean>;
490
510
  /** The English defaults of `DataTableLabels`. */
491
511
  export const DATA_TABLE_LABELS: DataTableLabels;
512
+ /** The labels a DataTable uses for a locale (2.29), `labels` on top. */
513
+ export function dataTableLabels(locale?: string, labels?: Partial<DataTableLabels>): DataTableLabels;
492
514
  export interface DataTableProps<R = any> {
493
515
  /** Default [] (renders the empty state while loading). */
494
516
  rows?: readonly R[];
@@ -533,6 +555,12 @@ export interface DataTableProps<R = any> {
533
555
  * English default (`DATA_TABLE_LABELS`). The README has a full French set.
534
556
  */
535
557
  labels?: Partial<DataTableLabels>;
558
+ /**
559
+ * BCP 47 tag (2.29), e.g. "fr-CH": every text above in that language from
560
+ * the SDK's strings table, the footer's numbers formatted in it, and the
561
+ * default `noun` translated ("lignes"). `labels` and `noun` win. Default English.
562
+ */
563
+ locale?: string;
536
564
  /** Fill the parent's height; the body scrolls inside the card. */
537
565
  fill?: boolean;
538
566
  /** Body scroll height when not `fill`. Default 70vh. */
@@ -606,7 +634,7 @@ export function columnLayout(columns: readonly Pick<DataTableColumn, "id" | "num
606
634
  /** A sorted copy: stable, by `value(row)`, empty values (null, "", NaN) last both ways. */
607
635
  export function sortRows<R>(rows: readonly R[], columns: readonly DataTableColumn<R>[], sort: DataTableSort | null | undefined): R[];
608
636
  /** The sort after a header click: same column flips; a new one starts desc for `num`, else asc. */
609
- export function nextSort(sort: DataTableSort | null | undefined, column: Pick<DataTableColumn, "id" | "num">): DataTableSort;
637
+ export function nextSort(sort: DataTableSort | null | undefined, column: Pick<DataTableColumn, "id" | "num" | "sortDescFirst">): DataTableSort;
610
638
  /** Compare two cell values ascending: numbers, bigints, dates and two numeric strings by value; text A→Z. */
611
639
  export function compareValues(a: unknown, b: unknown): number;
612
640
  /** Paging math, 1-based and clamped: rows `start` (inclusive) to `end` (exclusive). */
package/ui.js CHANGED
@@ -53,7 +53,9 @@ import {
53
53
  tooltipSeriesRows,
54
54
  tooltipValueState,
55
55
  } from "./ui-core.js";
56
+ import { localeLang, localeStrings } from "./locale.js";
56
57
 
58
+ export { LOCALES, STRINGS, localeLang, localeStrings } from "./locale.js";
57
59
  export { formatDate, formatTime, toDayKey, toInstant } from "./time.js";
58
60
  export {
59
61
  closePopovers,
@@ -588,6 +590,26 @@ export const DATA_TABLE_LABELS = {
588
590
  collapse: () => "Hide details",
589
591
  info: label => `About ${label}`,
590
592
  };
593
+ /**
594
+ * DataTable's texts for a locale (2.29), `labels` on top. No locale and no
595
+ * labels: DATA_TABLE_LABELS itself. A locale also formats the footer's
596
+ * numbers ("1 234" in fr-CH) and names the rows ("lignes") when `noun` is unset.
597
+ */
598
+ export function dataTableLabels(locale, labels) {
599
+ const T = localeLang(locale) === "en" ? null : localeStrings("dataTable", locale);
600
+ const base = { ...DATA_TABLE_LABELS, rows: "rows" };
601
+ if (T) {
602
+ const n = x => x.toLocaleString(locale);
603
+ Object.assign(base, T, {
604
+ range: (from, to, total, noun) => [h("b", { key: "r" }, `${n(from)}–${n(to)}`), ` ${T.of} `, h("b", { key: "t" }, n(total)), ` ${noun}`],
605
+ none: noun => `0 ${noun}`,
606
+ expand: () => T.expand,
607
+ collapse: () => T.collapse,
608
+ });
609
+ delete base.of;
610
+ }
611
+ return labels ? { ...base, ...labels } : base;
612
+ }
591
613
  // A click on a link, button or field inside a row is that control's, not the row's.
592
614
  const INTERACTIVE = "a,button,input,select,textarea,label,[role=button]";
593
615
 
@@ -633,9 +655,10 @@ export function DataTable({
633
655
  defaultPageSize = 50,
634
656
  onPageSizeChange,
635
657
  pageSizes = [25, 50, 100],
636
- noun = "rows",
658
+ noun: nounProp,
637
659
  empty: emptyProp,
638
660
  labels: labelsProp,
661
+ locale,
639
662
  fill = false,
640
663
  maxHeight,
641
664
  onRowClick,
@@ -656,8 +679,9 @@ export function DataTable({
656
679
  className,
657
680
  style,
658
681
  }) {
659
- const L = labelsProp ? { ...DATA_TABLE_LABELS, ...labelsProp } : DATA_TABLE_LABELS;
682
+ const L = dataTableLabels(locale, labelsProp);
660
683
  const empty = emptyProp ?? L.empty;
684
+ const noun = nounProp ?? L.rows;
661
685
  const [sort, setSort] = useControlled(sortProp, defaultSort, onSortChange);
662
686
  const [rawPage, setRawPage] = useControlled(pageProp, 1, onPageChange);
663
687
  const [pageSize, setPageSize] = useControlled(pageSizeProp, defaultPageSize, onPageSizeChange);
@@ -1066,17 +1090,23 @@ export function FilterItems({
1066
1090
  value: valueProp,
1067
1091
  selected: selectedProp,
1068
1092
  onChange,
1069
- allLabel = "All",
1093
+ allLabel: allLabelProp,
1070
1094
  emptyMeansAll = true,
1071
1095
  showOnly = false,
1072
1096
  none: noneProp,
1073
1097
  onNoneChange,
1074
1098
  searchable = false,
1075
- searchPlaceholder = "Search",
1076
- searchEmpty = "No match",
1099
+ searchPlaceholder: searchPlaceholderProp,
1100
+ searchEmpty: searchEmptyProp,
1101
+ locale,
1102
+ labels,
1077
1103
  className,
1078
1104
  "aria-label": ariaLabel,
1079
1105
  }) {
1106
+ const L = localeStrings("filter", locale, labels);
1107
+ const allLabel = allLabelProp ?? L.all;
1108
+ const searchPlaceholder = searchPlaceholderProp ?? L.search;
1109
+ const searchEmpty = searchEmptyProp ?? L.noMatch;
1080
1110
  const value = valueProp ?? selectedProp;
1081
1111
  const tree = options.map(toNode);
1082
1112
  const leaves = filterLeaves(tree);
@@ -1191,8 +1221,8 @@ export function FilterItems({
1191
1221
  h(Checkbox, { checked: asChecked(tick) }),
1192
1222
  dot(node),
1193
1223
  h("span", { className: "mk-ms-label" }, node.label),
1194
- node.count != null && h("span", { className: "mk-ms-count" }, typeof node.count === "number" ? fmtCount(node.count) : node.count),
1195
- showOnly && filterLeavesOf(node).length > 0 && h("button", { type: "button", className: "mk-ms-only", tabIndex: -1, onClick: only(node) }, "Only"),
1224
+ node.count != null && h("span", { className: "mk-ms-count" }, typeof node.count === "number" ? (locale ? node.count.toLocaleString(locale) : fmtCount(node.count)) : node.count),
1225
+ showOnly && filterLeavesOf(node).length > 0 && h("button", { type: "button", className: "mk-ms-only", tabIndex: -1, onClick: only(node) }, L.only),
1196
1226
  );
1197
1227
  return group ? [el, ...node.children.flatMap(c => row(c, depth + 1))] : [el];
1198
1228
  };
@@ -1290,8 +1320,8 @@ export function MultiSelect({
1290
1320
  value: valueProp,
1291
1321
  selected: selectedProp,
1292
1322
  onChange,
1293
- allLabel = "All",
1294
- noneLabel = "None",
1323
+ allLabel: allLabelProp,
1324
+ noneLabel: noneLabelProp,
1295
1325
  emptyMeansAll = true,
1296
1326
  showOnly = false,
1297
1327
  formatMany,
@@ -1302,11 +1332,16 @@ export function MultiSelect({
1302
1332
  searchable = false,
1303
1333
  searchPlaceholder,
1304
1334
  searchEmpty,
1335
+ locale,
1336
+ labels,
1305
1337
  className,
1306
1338
  triggerClassName,
1307
1339
  label,
1308
1340
  "aria-label": ariaLabelProp,
1309
1341
  }) {
1342
+ const L = localeStrings("filter", locale, labels);
1343
+ const allLabel = allLabelProp ?? L.all;
1344
+ const noneLabel = noneLabelProp ?? L.none;
1310
1345
  const value = valueProp ?? selectedProp;
1311
1346
  const ariaLabel = ariaLabelProp ?? label;
1312
1347
  const [open, setOpen] = React.useState(false);
@@ -1318,7 +1353,7 @@ export function MultiSelect({
1318
1353
  }, [open]);
1319
1354
  const tree = options.map(toNode);
1320
1355
  const selected = filterNormalize(tree, value ?? []);
1321
- const many = formatMany ?? (n => `${n} selected`);
1356
+ const many = formatMany ?? L.many;
1322
1357
  const text = none ? noneLabel : (summary ?? filterText(tree, selected, allLabel, many));
1323
1358
  const sizes = [...(sizeTo ?? [allLabel, ...tree.map(o => o.label), many(filterLeaves(tree).length), noneLabel]), ...probes];
1324
1359
  const single = selected.length ? filterPickedNode(tree, selected) : null;
@@ -1367,6 +1402,8 @@ export function MultiSelect({
1367
1402
  showOnly,
1368
1403
  none,
1369
1404
  onNoneChange: setNone,
1405
+ locale,
1406
+ labels,
1370
1407
  "aria-label": ariaLabel,
1371
1408
  ...(searchable ? { searchable, searchPlaceholder, searchEmpty } : null),
1372
1409
  }),