@majoo-ui/react 2.3.0 → 2.4.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/components/alertDialog/AlertDialog.esm.js +28 -15
- package/components/alertDialog/locale.esm.js +20 -0
- package/components/chart/lineChart/LineChart.esm.js +4 -0
- package/components/datePicker/DatePicker.esm.js +16 -6
- package/components/datePicker/DatePickerMulti.esm.js +5 -3
- package/components/datePicker/InputDatePicker.esm.js +14 -12
- package/components/datePicker/components/Calendar.esm.js +17 -23
- package/components/datePicker/components/CalendarMulti.esm.js +4 -7
- package/components/datePicker/components/CalendarTimePicker.esm.js +6 -9
- package/components/datePicker/components/MobileCalendar.esm.js +13 -17
- package/components/datePicker/locale.esm.js +92 -0
- package/components/devicePreview/DevicePreview.esm.js +4 -0
- package/components/form/components/InputCombobox/InputCombobox.esm.js +3 -0
- package/components/form/components/InputCreatable/InputCreatable.esm.js +16 -8
- package/components/form/components/InputCreatable/locale.esm.js +15 -0
- package/components/form/components/InputDateRange/InputDateRange.esm.js +15 -11
- package/components/form/components/InputDateRange/locale.esm.js +15 -0
- package/components/form/components/InputOTP/InputOTP.esm.js +9 -6
- package/components/form/components/InputOTP/locale.esm.js +15 -0
- package/components/form/components/InputResourceList/InputResourceList.esm.js +8 -11
- package/components/form/components/InputResourceList/locale.esm.js +27 -0
- package/components/form/components/InputSearchbox/InputSearchbox.esm.js +15 -6
- package/components/form/components/InputSearchbox/locale.esm.js +16 -0
- package/components/form/components/InputSelect/InputSelect.esm.js +13 -14
- package/components/form/components/InputSelect/locale.esm.js +23 -0
- package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +32 -23
- package/components/form/components/InputSelectCheck/locale.esm.js +30 -0
- package/components/form/components/InputSignature/InputSignature.esm.js +7 -8
- package/components/form/components/InputSignature/SignatureModal.esm.js +3 -3
- package/components/form/components/InputSignature/locale.esm.js +27 -0
- package/components/image/Image.esm.js +15 -9
- package/components/image/locale.esm.js +15 -0
- package/components/mapPicker/InputMapPicker.esm.js +5 -0
- package/components/pageDialog/PageDialog.esm.js +4 -0
- package/components/periodSelect/PeriodSelect.esm.js +11 -12
- package/components/periodSelect/locale.esm.js +25 -0
- package/components/tagList/TagList.esm.js +6 -7
- package/components/tagList/locale.esm.js +22 -0
- package/components/toast/context/ToastProvider.esm.js +13 -9
- package/components/toast/context/locale.esm.js +20 -0
- package/config/locale/LocaleContext.esm.js +29 -0
- package/config/locale/useLocaleText.esm.js +30 -0
- package/index.esm.js +12 -0
- package/majoo-provider/MajooProvider.esm.js +29 -5
- package/package.json +1 -1
- package/src/components/alertDialog/locale.d.ts +10 -0
- package/src/components/datePicker/DatePickerMulti.d.ts +2 -1
- package/src/components/datePicker/InputDatePicker.d.ts +13 -2
- package/src/components/datePicker/components/Calendar.d.ts +12 -1
- package/src/components/datePicker/components/CalendarMulti.d.ts +6 -1
- package/src/components/datePicker/components/CalendarTimePicker.d.ts +4 -1
- package/src/components/datePicker/components/MobileCalendar.d.ts +1 -1
- package/src/components/datePicker/index.d.ts +2 -0
- package/src/components/datePicker/locale.d.ts +45 -0
- package/src/components/form/components/InputCreatable/locale.d.ts +13 -0
- package/src/components/form/components/InputDateRange/InputDateRange.d.ts +16 -1
- package/src/components/form/components/InputDateRange/index.d.ts +2 -0
- package/src/components/form/components/InputDateRange/locale.d.ts +10 -0
- package/src/components/form/components/InputOTP/InputOTP.d.ts +7 -1
- package/src/components/form/components/InputOTP/index.d.ts +2 -0
- package/src/components/form/components/InputOTP/locale.d.ts +10 -0
- package/src/components/form/components/InputResourceList/InputResourceList.d.ts +8 -1
- package/src/components/form/components/InputResourceList/locale.d.ts +17 -0
- package/src/components/form/components/InputSearchbox/locale.d.ts +11 -0
- package/src/components/form/components/InputSelect/index.d.ts +2 -0
- package/src/components/form/components/InputSelect/locale.d.ts +15 -0
- package/src/components/form/components/InputSelectCheck/locale.d.ts +20 -0
- package/src/components/form/components/InputSignature/InputSignature.d.ts +7 -1
- package/src/components/form/components/InputSignature/SignatureModal.d.ts +2 -1
- package/src/components/form/components/InputSignature/index.d.ts +2 -0
- package/src/components/form/components/InputSignature/locale.d.ts +16 -0
- package/src/components/form/components/index.d.ts +4 -0
- package/src/components/image/index.d.ts +2 -0
- package/src/components/image/locale.d.ts +10 -0
- package/src/components/periodSelect/PeriodSelect.d.ts +14 -3
- package/src/components/periodSelect/index.d.ts +2 -0
- package/src/components/periodSelect/locale.d.ts +15 -0
- package/src/components/tagList/TagList.d.ts +8 -2
- package/src/components/tagList/index.d.ts +2 -0
- package/src/components/tagList/locale.d.ts +13 -0
- package/src/components/toast/context/locale.d.ts +11 -0
- package/src/config/locale/LocaleContext.d.ts +13 -0
- package/src/config/locale/LocaleTextContext.d.ts +28 -0
- package/src/config/locale/useLocaleText.d.ts +10 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ImageLocaleText {
|
|
2
|
+
/** Text of the default fallback shown when there is no `src` and no `fallback`. */
|
|
3
|
+
fallbackTitle: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const defaultImageLocaleText: ImageLocaleText;
|
|
6
|
+
/**
|
|
7
|
+
* Resolves the image texts. Precedence: the image's own `localeText`, then `MajooProvider`'s
|
|
8
|
+
* `localeText.image`, then the app's `translation` keys, then the Indonesian defaults.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useImageLocaleText: (localeText?: Partial<ImageLocaleText>) => ImageLocaleText;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CSS } from '../../config/stitches.config';
|
|
3
|
+
import { PeriodSelectLocaleText } from './locale';
|
|
3
4
|
export type PeriodValue = 'day' | 'week' | 'month';
|
|
4
5
|
export interface PeriodSelectProps {
|
|
5
6
|
/**
|
|
@@ -53,12 +54,12 @@ export interface PeriodSelectProps {
|
|
|
53
54
|
*/
|
|
54
55
|
align?: 'start' | 'center' | 'end';
|
|
55
56
|
/**
|
|
56
|
-
* Replaces the label of one or more periods. Anything left out keeps
|
|
57
|
-
*
|
|
57
|
+
* Replaces the label of one or more periods. Anything left out keeps `localeText`'s `dayLabel`,
|
|
58
|
+
* `weekLabel` or `monthLabel`.
|
|
58
59
|
*/
|
|
59
60
|
periodLabels?: Partial<Record<PeriodValue, React.ReactNode>>;
|
|
60
61
|
/**
|
|
61
|
-
* Replaces the submenu heading above the start-day options.
|
|
62
|
+
* Replaces the submenu heading above the start-day options. Wins over `localeText.startWeekLabel`.
|
|
62
63
|
*/
|
|
63
64
|
startWeekLabel?: React.ReactNode;
|
|
64
65
|
/**
|
|
@@ -71,6 +72,16 @@ export interface PeriodSelectProps {
|
|
|
71
72
|
* Additional CSS trigger styles.
|
|
72
73
|
*/
|
|
73
74
|
css?: CSS;
|
|
75
|
+
/**
|
|
76
|
+
* Language of the weekday names. Falls back to `MajooProvider`'s `locale`, then the app's i18next
|
|
77
|
+
* language, then `id`.
|
|
78
|
+
*/
|
|
79
|
+
locale?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Texts of this select. Keys left unset fall back to `MajooProvider`'s `localeText.periodSelect`, then
|
|
82
|
+
* the Indonesian defaults.
|
|
83
|
+
*/
|
|
84
|
+
localeText?: Partial<PeriodSelectLocaleText>;
|
|
74
85
|
}
|
|
75
86
|
export interface WeekRange {
|
|
76
87
|
startDay: number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface PeriodSelectLocaleText {
|
|
3
|
+
dayLabel: ReactNode;
|
|
4
|
+
weekLabel: ReactNode;
|
|
5
|
+
monthLabel: ReactNode;
|
|
6
|
+
/** Submenu heading above the start-day options. */
|
|
7
|
+
startWeekLabel: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const defaultPeriodSelectLocaleText: PeriodSelectLocaleText;
|
|
10
|
+
/**
|
|
11
|
+
* Resolves the period select texts. Precedence: the select's own `localeText`, then `MajooProvider`'s
|
|
12
|
+
* `localeText.periodSelect`, then the app's `MajooUI/periodSelect` translations, then the Indonesian
|
|
13
|
+
* defaults.
|
|
14
|
+
*/
|
|
15
|
+
export declare const usePeriodSelectLocaleText: (localeText?: Partial<PeriodSelectLocaleText>) => PeriodSelectLocaleText;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { TagListLocaleText } from './locale';
|
|
2
3
|
export interface SelectedItem {
|
|
3
4
|
id: string | number;
|
|
4
5
|
name: string;
|
|
@@ -13,9 +14,14 @@ interface TagListProps {
|
|
|
13
14
|
*/
|
|
14
15
|
onRemoveItem?: (SelectedItem: any) => void;
|
|
15
16
|
/**
|
|
16
|
-
* Custom counter label.
|
|
17
|
+
* Custom counter label. Wins over `localeText.counterLabel`.
|
|
17
18
|
*/
|
|
18
19
|
counterLabel?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Texts of this list. Keys left unset fall back to `MajooProvider`'s `localeText.tagList`, then the
|
|
22
|
+
* Indonesian defaults.
|
|
23
|
+
*/
|
|
24
|
+
localeText?: Partial<TagListLocaleText>;
|
|
19
25
|
}
|
|
20
|
-
declare function TagList({ selectedItems, onRemoveItem, counterLabel }: TagListProps): JSX.Element;
|
|
26
|
+
declare function TagList({ selectedItems, onRemoveItem, counterLabel, localeText }: TagListProps): JSX.Element;
|
|
21
27
|
export default TagList;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface TagListLocaleText {
|
|
2
|
+
/** Toggle that expands or collapses the tags beyond the first five. */
|
|
3
|
+
showAllButton: string;
|
|
4
|
+
showLessButton: string;
|
|
5
|
+
/** Follows the number of selected items. The `counterLabel` prop still wins. */
|
|
6
|
+
counterLabel: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const defaultTagListLocaleText: TagListLocaleText;
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the tag list texts. Precedence: the list's own `localeText`, then `MajooProvider`'s
|
|
11
|
+
* `localeText.tagList`, then the app's `MajooUI/inputSelectCheck` translations, then the Indonesian defaults.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useTagListLocaleText: (localeText?: Partial<TagListLocaleText>) => TagListLocaleText;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ToastLocaleText {
|
|
2
|
+
/** Toast that replaces any other while the browser is offline. */
|
|
3
|
+
offlineTitle: string;
|
|
4
|
+
offlineDescription: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const defaultToastLocaleText: ToastLocaleText;
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the toast texts. Precedence: `ToastProvider`'s own `localeText`, then `MajooProvider`'s
|
|
9
|
+
* `localeText.toast`, then the app's `MajooUI/toast` translations, then the Indonesian defaults.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useToastLocaleText: (localeText?: Partial<ToastLocaleText>) => ToastLocaleText;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/** Languages the components format dates for. */
|
|
3
|
+
export type MajooLocale = 'id' | 'en';
|
|
4
|
+
export declare const DEFAULT_LOCALE: MajooLocale;
|
|
5
|
+
/** The app's language, supplied once through `MajooProvider`'s `locale`. */
|
|
6
|
+
export declare const LocaleContext: React.Context<string | undefined>;
|
|
7
|
+
/** Reduces a tag such as `en-US` to its language; an unsupported language falls back to `id`. */
|
|
8
|
+
export declare const normalizeLocale: (locale?: string | null) => MajooLocale;
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the language. Precedence: the component's own `locale`, then `MajooProvider`'s `locale`,
|
|
11
|
+
* then the app's i18next language, then `id`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useLocale: (locale?: string) => MajooLocale;
|
|
@@ -1,10 +1,38 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import type { AlertDialogLocaleText } from '../../components/alertDialog/locale';
|
|
3
|
+
import type { DatePickerLocaleText } from '../../components/datePicker/locale';
|
|
4
|
+
import type { InputCreatableLocaleText } from '../../components/form/components/InputCreatable/locale';
|
|
5
|
+
import type { InputDateRangeLocaleText } from '../../components/form/components/InputDateRange/locale';
|
|
6
|
+
import type { InputOtpLocaleText } from '../../components/form/components/InputOTP/locale';
|
|
7
|
+
import type { InputResourceListLocaleText } from '../../components/form/components/InputResourceList/locale';
|
|
8
|
+
import type { InputSearchboxLocaleText } from '../../components/form/components/InputSearchbox/locale';
|
|
9
|
+
import type { InputSelectLocaleText } from '../../components/form/components/InputSelect/locale';
|
|
10
|
+
import type { InputSelectCheckLocaleText } from '../../components/form/components/InputSelectCheck/locale';
|
|
11
|
+
import type { InputSignatureLocaleText } from '../../components/form/components/InputSignature/locale';
|
|
12
|
+
import type { ImageLocaleText } from '../../components/image/locale';
|
|
13
|
+
import type { PeriodSelectLocaleText } from '../../components/periodSelect/locale';
|
|
2
14
|
import type { TableLocaleText } from '../../components/table/locale';
|
|
15
|
+
import type { TagListLocaleText } from '../../components/tagList/locale';
|
|
16
|
+
import type { ToastLocaleText } from '../../components/toast/context/locale';
|
|
3
17
|
/**
|
|
4
18
|
* Component texts supplied once for the whole app through `MajooProvider`'s `localeText`.
|
|
5
19
|
* Each component reads its own key; any text left unset keeps the component's default.
|
|
6
20
|
*/
|
|
7
21
|
export interface MajooLocaleText {
|
|
22
|
+
alertDialog?: Partial<AlertDialogLocaleText>;
|
|
23
|
+
datePicker?: Partial<DatePickerLocaleText>;
|
|
24
|
+
image?: Partial<ImageLocaleText>;
|
|
25
|
+
inputCreatable?: Partial<InputCreatableLocaleText>;
|
|
26
|
+
inputDateRange?: Partial<InputDateRangeLocaleText>;
|
|
27
|
+
inputOtp?: Partial<InputOtpLocaleText>;
|
|
28
|
+
inputResourceList?: Partial<InputResourceListLocaleText>;
|
|
29
|
+
inputSearchbox?: Partial<InputSearchboxLocaleText>;
|
|
30
|
+
inputSelect?: Partial<InputSelectLocaleText>;
|
|
31
|
+
inputSelectCheck?: Partial<InputSelectCheckLocaleText>;
|
|
32
|
+
inputSignature?: Partial<InputSignatureLocaleText>;
|
|
33
|
+
periodSelect?: Partial<PeriodSelectLocaleText>;
|
|
8
34
|
table?: Partial<TableLocaleText>;
|
|
35
|
+
tagList?: Partial<TagListLocaleText>;
|
|
36
|
+
toast?: Partial<ToastLocaleText>;
|
|
9
37
|
}
|
|
10
38
|
export declare const LocaleTextContext: React.Context<MajooLocaleText>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MajooLocaleText } from './LocaleTextContext';
|
|
2
|
+
import { MajooLocale } from './LocaleContext';
|
|
3
|
+
/** Later sources win; an `undefined` value never erases an earlier one. */
|
|
4
|
+
export declare const mergeLocaleText: <T extends object>(base: T, ...overrides: (Partial<T> | undefined)[]) => T;
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the flat texts of a component. Precedence: the component's own `localeText`, then
|
|
7
|
+
* `MajooProvider`'s `localeText[key]`, then the app's i18next translations, then the defaults that
|
|
8
|
+
* `fromI18n` falls back to.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useLocaleText: <T extends object>(key: keyof MajooLocaleText, namespaces: string | string[], fromI18n: (t, locale: MajooLocale) => T, localeText?: Partial<T>, locale?: string) => T;
|