@tabres/react 1.0.52 → 1.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/index.esm.js +1 -1
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/models/index.d.ts +1 -0
  6. package/dist/models/index.esm.js.map +1 -1
  7. package/dist/models/index.js.map +1 -1
  8. package/dist/models/models/index.d.ts +1 -0
  9. package/dist/models/modules/addon/models.d.ts +3 -2
  10. package/dist/models/modules/branch/models.d.ts +2 -1
  11. package/dist/models/modules/category/models.d.ts +2 -1
  12. package/dist/models/modules/localization/models.d.ts +10 -0
  13. package/dist/models/modules/localization/utils.d.ts +22 -0
  14. package/dist/models/modules/menu/models.d.ts +3 -2
  15. package/dist/models/modules/order/models.d.ts +2 -1
  16. package/dist/models/modules/product/models.d.ts +3 -2
  17. package/dist/models/modules/product/utils.d.ts +1 -1
  18. package/dist/modules/addon/models.d.ts +3 -2
  19. package/dist/modules/addon/utils.d.ts +8 -3
  20. package/dist/modules/branch/models.d.ts +2 -1
  21. package/dist/modules/category/models.d.ts +2 -1
  22. package/dist/modules/localization/index.d.ts +2 -0
  23. package/dist/modules/localization/models.d.ts +10 -0
  24. package/dist/modules/localization/utils.d.ts +22 -0
  25. package/dist/modules/localization/utils.test.d.ts +1 -0
  26. package/dist/modules/menu/models.d.ts +3 -2
  27. package/dist/modules/order/models.d.ts +2 -1
  28. package/dist/modules/product/models.d.ts +3 -2
  29. package/dist/modules/product/utils.d.ts +1 -1
  30. package/dist/utils/index.d.ts +1 -0
  31. package/dist/utils/index.esm.js +1 -1
  32. package/dist/utils/index.esm.js.map +1 -1
  33. package/dist/utils/index.js +1 -1
  34. package/dist/utils/index.js.map +1 -1
  35. package/dist/utils/models/index.d.ts +1 -0
  36. package/dist/utils/modules/addon/models.d.ts +3 -2
  37. package/dist/utils/modules/addon/utils.d.ts +8 -3
  38. package/dist/utils/modules/branch/models.d.ts +2 -1
  39. package/dist/utils/modules/category/models.d.ts +2 -1
  40. package/dist/utils/modules/localization/models.d.ts +10 -0
  41. package/dist/utils/modules/localization/utils.d.ts +22 -0
  42. package/dist/utils/modules/menu/models.d.ts +3 -2
  43. package/dist/utils/modules/order/models.d.ts +2 -1
  44. package/dist/utils/modules/product/models.d.ts +3 -2
  45. package/dist/utils/modules/product/utils.d.ts +1 -1
  46. package/dist/utils/utils/index.d.ts +1 -0
  47. package/package.json +1 -1
@@ -11,6 +11,7 @@ export * from "../modules/table/models";
11
11
  export * from "../modules/user/models";
12
12
  export * from "../modules/category/models";
13
13
  export * from "../modules/menu/models";
14
+ export * from "../modules/localization/models";
14
15
  export * from "../modules/video/models";
15
16
  export * from "../modules/pos/models";
16
17
  export * from "../components/PublicMenu/ProductsGridItem/ProductsGridItem.types";
@@ -1,3 +1,4 @@
1
+ import { LocalizedText } from "src/modules/localization/models";
1
2
  export declare enum MenuAddonSelectType {
2
3
  SINGLE = "SINGLE",
3
4
  MULTIPLE = "MULTIPLE"
@@ -12,7 +13,7 @@ export interface MenuAddonOption {
12
13
  * supplied (e.g. addon detached from a branch tax setup).
13
14
  */
14
15
  listingPrice: number;
15
- title: Record<string, string>;
16
+ title: LocalizedText;
16
17
  remove?: boolean;
17
18
  }
18
19
  export interface MenuAddon {
@@ -20,5 +21,5 @@ export interface MenuAddon {
20
21
  selectType: MenuAddonSelectType;
21
22
  options: MenuAddonOption[];
22
23
  businessId?: number;
23
- title: Record<string, string>;
24
+ title: LocalizedText;
24
25
  }
@@ -1,5 +1,10 @@
1
1
  import { MenuAddon, MenuAddonOption } from "./models";
2
- export declare const getAddonTranslation: (addon: MenuAddon, language: string) => string;
3
- export declare const getAddonOptionTranslation: (option: MenuAddonOption, language: string) => string;
2
+ /**
3
+ * An addon's title, or one of its options'.
4
+ *
5
+ * Both sides of an addon carry the same `LocalizedText` shape and fall back the
6
+ * same way, so one resolver serves the group heading ("Size") and the choices
7
+ * under it ("Small", "Large") alike.
8
+ */
9
+ export declare const getAddonTitle: (addon: MenuAddon | MenuAddonOption | null | undefined, language: string) => string;
4
10
  export declare const getOptionTitles: (options: MenuAddonOption[], optionIds: number | number[], language: string) => string;
5
- export declare const getAddonTitle: (addon: MenuAddon, language: string) => string;
@@ -1,3 +1,4 @@
1
+ import { LocalizedText } from "src/modules/localization/models";
1
2
  export type BranchWorkHour = {
2
3
  openAt: string;
3
4
  closeAt: string;
@@ -76,7 +77,7 @@ export type BranchTax = {
76
77
  businessId: number;
77
78
  branchId: number;
78
79
  taxClassId?: number;
79
- name: Record<string, string>;
80
+ name: LocalizedText;
80
81
  rate: number;
81
82
  type: BranchTaxType;
82
83
  isActive: boolean;
@@ -1,3 +1,4 @@
1
+ import { LocalizedText } from "src/modules/localization/models";
1
2
  export interface Category {
2
3
  id: number;
3
4
  businessId: number;
@@ -5,7 +6,7 @@ export interface Category {
5
6
  * Category name keyed by language code, e.g. { en: "Drinks", az: "İçkilər" }.
6
7
  * Mirrors the `name` JSONB column returned by the API
7
8
  */
8
- name: Record<string, string>;
9
+ name: LocalizedText;
9
10
  /** Display order within the business; lower comes first. */
10
11
  position: number;
11
12
  }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A field the business authors once per language, keyed by language code —
3
+ * e.g. `{ en: "Drinks", az: "İçkilər" }`. Category names, addon titles, tax
4
+ * labels and product copy all arrive in this shape.
5
+ *
6
+ * The map travels whole rather than pre-resolved because the public menu is
7
+ * served from one language-agnostic cached payload: the guest switches
8
+ * language locally and every row has to relabel without a refetch.
9
+ */
10
+ export type LocalizedText = Record<string, string>;
@@ -0,0 +1,22 @@
1
+ import { LocalizedText } from "./models";
2
+ /**
3
+ * `source` in `language`, falling back when the business left that language
4
+ * blank.
5
+ *
6
+ * A menu is authored language by language and is rarely finished in all of
7
+ * them — a dish gets its Azerbaijani name today and its English one next week.
8
+ * A name in the wrong language still tells the guest what they are looking at,
9
+ * which an empty row does not, so a missing, null or empty value falls through
10
+ * to the next best language instead of rendering nothing.
11
+ */
12
+ export declare const getLocalizedText: (source: LocalizedText | null | undefined, language?: string) => string;
13
+ /**
14
+ * `source` in `language`, resolved field by field.
15
+ *
16
+ * Product copy arrives as a record per language — `{ name, description }` — and
17
+ * the fields are filled in independently: a dish is named in Turkish long
18
+ * before anyone writes its Turkish description. Falling back on the record as a
19
+ * whole would throw away the translated name the moment the description was
20
+ * blank, so each field falls back on its own.
21
+ */
22
+ export declare const getLocalizedContent: <T extends object>(source: Record<string, T> | null | undefined, language?: string) => T;
@@ -4,6 +4,7 @@ import * as categoryModels from "src/modules/category/models";
4
4
  import * as businessModels from "src/modules/business/models";
5
5
  import * as tableModels from "src/modules/table/models";
6
6
  import * as videoModels from "src/modules/video/models";
7
+ import { LocalizedText } from "src/modules/localization/models";
7
8
  export interface CategoryProductMap extends categoryModels.Category {
8
9
  products: productModels.Product[];
9
10
  }
@@ -30,8 +31,8 @@ export interface MenuDesign {
30
31
  menuPageTextColor: string;
31
32
  createdAt?: string;
32
33
  updatedAt?: string;
33
- headerText?: Record<string, string>;
34
- footerText?: Record<string, string>;
34
+ headerText?: LocalizedText;
35
+ footerText?: LocalizedText;
35
36
  }
36
37
  export interface PublicMenuData {
37
38
  business: businessModels.Business;
@@ -1,5 +1,6 @@
1
1
  import * as customerModels from "../customer/models";
2
2
  import * as productModels from "../product/models";
3
+ import { LocalizedText } from "src/modules/localization/models";
3
4
  export declare enum OrderType {
4
5
  DINE_IN = "DINE_IN",
5
6
  PICK_UP = "PICK_UP",
@@ -178,7 +179,7 @@ export interface CalculatePreviewRequest {
178
179
  }
179
180
  export interface CalculatePreviewTax {
180
181
  branchTaxId: number;
181
- name: Record<string, string>;
182
+ name: LocalizedText;
182
183
  rate: number;
183
184
  type: "percentage" | "fixed";
184
185
  addToListingPrice: boolean;
@@ -1,4 +1,5 @@
1
1
  import { MenuAddon } from "../addon/models";
2
+ import { LocalizedText } from "src/modules/localization/models";
2
3
  export interface LocalizedContent {
3
4
  name: string;
4
5
  description: string;
@@ -13,7 +14,7 @@ export interface ProductVariant {
13
14
  */
14
15
  listingPrice: number;
15
16
  /** Title keyed by language code, e.g. { en: "Large", az: "Böyük" }. */
16
- title: Record<string, string>;
17
+ title: LocalizedText;
17
18
  productId?: number;
18
19
  remove?: boolean;
19
20
  }
@@ -65,7 +66,7 @@ export interface Product {
65
66
  export interface AllergenDetail {
66
67
  code: AllergenCode;
67
68
  /** Label keyed by language code, e.g. `{ en: "Gluten", az: "Qlüten" }`. */
68
- translations: Record<string, string>;
69
+ translations: LocalizedText;
69
70
  }
70
71
  /**
71
72
  * An allergen code as it comes off the wire. Deliberately open: the API owns
@@ -1,5 +1,5 @@
1
- import { AllergenCode, LocalizedContent, Product, ProductVariant, SellUnitType } from "./models";
2
1
  import { MenuAddon } from "src/modules/addon/models";
2
+ import { AllergenCode, LocalizedContent, Product, ProductVariant, SellUnitType } from "./models";
3
3
  export declare const getProductTranslation: (product: Pick<Product, "translations">, language: string) => LocalizedContent;
4
4
  export declare const getProductVariant: (product: Pick<Product, "variants">, variantId: number) => ProductVariant;
5
5
  export declare const getProductVariantTranslation: (variant: ProductVariant, language: string) => string;
@@ -6,5 +6,6 @@ export * from "../modules/feature/utils";
6
6
  export * from "../modules/view/utils";
7
7
  export * from "../modules/category/utils";
8
8
  export * from "../modules/menu/utils";
9
+ export * from "../modules/localization/utils";
9
10
  export * from "../modules/user/utils";
10
11
  export * from "../modules/pos/utils";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tabres/react",
3
- "version": "1.0.52",
3
+ "version": "1.0.53",
4
4
  "description": "React Library by tabres.com",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",