@majoo-ui/react 2.3.0 → 2.4.2

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 (85) hide show
  1. package/components/alertDialog/AlertDialog.esm.js +28 -15
  2. package/components/alertDialog/locale.esm.js +20 -0
  3. package/components/chart/lineChart/LineChart.esm.js +4 -0
  4. package/components/datePicker/DatePicker.esm.js +19 -6
  5. package/components/datePicker/DatePickerMulti.esm.js +5 -3
  6. package/components/datePicker/InputDatePicker.esm.js +14 -12
  7. package/components/datePicker/components/Calendar.esm.js +17 -23
  8. package/components/datePicker/components/CalendarMulti.esm.js +4 -7
  9. package/components/datePicker/components/CalendarTimePicker.esm.js +62 -29
  10. package/components/datePicker/components/MobileCalendar.esm.js +35 -18
  11. package/components/datePicker/locale.esm.js +92 -0
  12. package/components/devicePreview/DevicePreview.esm.js +4 -0
  13. package/components/form/components/InputCombobox/InputCombobox.esm.js +3 -0
  14. package/components/form/components/InputCreatable/InputCreatable.esm.js +16 -8
  15. package/components/form/components/InputCreatable/locale.esm.js +20 -0
  16. package/components/form/components/InputDateRange/InputDateRange.esm.js +15 -11
  17. package/components/form/components/InputDateRange/locale.esm.js +15 -0
  18. package/components/form/components/InputOTP/InputOTP.esm.js +9 -6
  19. package/components/form/components/InputOTP/locale.esm.js +15 -0
  20. package/components/form/components/InputResourceList/InputResourceList.esm.js +8 -11
  21. package/components/form/components/InputResourceList/locale.esm.js +27 -0
  22. package/components/form/components/InputSearchbox/InputSearchbox.esm.js +15 -6
  23. package/components/form/components/InputSearchbox/locale.esm.js +16 -0
  24. package/components/form/components/InputSelect/InputSelect.esm.js +13 -14
  25. package/components/form/components/InputSelect/locale.esm.js +23 -0
  26. package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +32 -23
  27. package/components/form/components/InputSelectCheck/locale.esm.js +30 -0
  28. package/components/form/components/InputSignature/InputSignature.esm.js +7 -8
  29. package/components/form/components/InputSignature/SignatureModal.esm.js +3 -3
  30. package/components/form/components/InputSignature/locale.esm.js +27 -0
  31. package/components/image/Image.esm.js +15 -9
  32. package/components/image/locale.esm.js +15 -0
  33. package/components/mapPicker/InputMapPicker.esm.js +5 -0
  34. package/components/pageDialog/PageDialog.esm.js +4 -0
  35. package/components/periodSelect/PeriodSelect.esm.js +11 -12
  36. package/components/periodSelect/locale.esm.js +25 -0
  37. package/components/tagList/TagList.esm.js +6 -7
  38. package/components/tagList/locale.esm.js +22 -0
  39. package/components/toast/context/ToastProvider.esm.js +13 -9
  40. package/components/toast/context/locale.esm.js +20 -0
  41. package/config/locale/LocaleContext.esm.js +29 -0
  42. package/config/locale/useLocaleText.esm.js +30 -0
  43. package/index.esm.css +4 -4
  44. package/index.esm.js +14 -0
  45. package/majoo-provider/MajooProvider.esm.js +29 -5
  46. package/package.json +1 -1
  47. package/src/components/alertDialog/locale.d.ts +10 -0
  48. package/src/components/datePicker/DatePickerMulti.d.ts +2 -1
  49. package/src/components/datePicker/InputDatePicker.d.ts +13 -2
  50. package/src/components/datePicker/components/Calendar.d.ts +12 -1
  51. package/src/components/datePicker/components/CalendarMulti.d.ts +6 -1
  52. package/src/components/datePicker/components/CalendarTimePicker.d.ts +6 -1
  53. package/src/components/datePicker/components/MobileCalendar.d.ts +1 -1
  54. package/src/components/datePicker/index.d.ts +2 -0
  55. package/src/components/datePicker/locale.d.ts +45 -0
  56. package/src/components/form/components/InputCreatable/locale.d.ts +13 -0
  57. package/src/components/form/components/InputDateRange/InputDateRange.d.ts +16 -1
  58. package/src/components/form/components/InputDateRange/index.d.ts +2 -0
  59. package/src/components/form/components/InputDateRange/locale.d.ts +10 -0
  60. package/src/components/form/components/InputOTP/InputOTP.d.ts +7 -1
  61. package/src/components/form/components/InputOTP/index.d.ts +2 -0
  62. package/src/components/form/components/InputOTP/locale.d.ts +10 -0
  63. package/src/components/form/components/InputResourceList/InputResourceList.d.ts +8 -1
  64. package/src/components/form/components/InputResourceList/locale.d.ts +17 -0
  65. package/src/components/form/components/InputSearchbox/locale.d.ts +11 -0
  66. package/src/components/form/components/InputSelect/index.d.ts +2 -0
  67. package/src/components/form/components/InputSelect/locale.d.ts +15 -0
  68. package/src/components/form/components/InputSelectCheck/locale.d.ts +20 -0
  69. package/src/components/form/components/InputSignature/InputSignature.d.ts +7 -1
  70. package/src/components/form/components/InputSignature/SignatureModal.d.ts +2 -1
  71. package/src/components/form/components/InputSignature/index.d.ts +2 -0
  72. package/src/components/form/components/InputSignature/locale.d.ts +16 -0
  73. package/src/components/form/components/index.d.ts +8 -0
  74. package/src/components/image/index.d.ts +2 -0
  75. package/src/components/image/locale.d.ts +10 -0
  76. package/src/components/periodSelect/PeriodSelect.d.ts +14 -3
  77. package/src/components/periodSelect/index.d.ts +2 -0
  78. package/src/components/periodSelect/locale.d.ts +15 -0
  79. package/src/components/tagList/TagList.d.ts +8 -2
  80. package/src/components/tagList/index.d.ts +2 -0
  81. package/src/components/tagList/locale.d.ts +13 -0
  82. package/src/components/toast/context/locale.d.ts +11 -0
  83. package/src/config/locale/LocaleContext.d.ts +13 -0
  84. package/src/config/locale/LocaleTextContext.d.ts +28 -0
  85. package/src/config/locale/useLocaleText.d.ts +10 -0
@@ -0,0 +1,11 @@
1
+ export interface InputSearchboxLocaleText {
2
+ /** The `placeholder` prop still wins. */
3
+ placeholder: string;
4
+ }
5
+ export declare const defaultInputSearchboxLocaleText: InputSearchboxLocaleText;
6
+ /**
7
+ * Resolves the search box texts. Precedence: the search box's own `localeText`, then `MajooProvider`'s
8
+ * `localeText.inputSearchbox`, then the app's `MajooUI/inputSearchbox` translations, then the Indonesian
9
+ * defaults.
10
+ */
11
+ export declare const useInputSearchboxLocaleText: (localeText?: Partial<InputSearchboxLocaleText>) => InputSearchboxLocaleText;
@@ -1,2 +1,4 @@
1
1
  export { default as InputSelect } from './InputSelect';
2
2
  export * from './InputSelect';
3
+ export type { InputSelectLocaleText } from './locale';
4
+ export { defaultInputSelectLocaleText } from './locale';
@@ -0,0 +1,15 @@
1
+ export interface InputSelectLocaleText {
2
+ /** Shown while nothing is selected, and as the mobile dialog title. The `placeholder` prop still wins. */
3
+ placeholder: string;
4
+ /** The `searchPlaceholder` prop still wins. */
5
+ searchPlaceholder: string;
6
+ /** Shown when no option matches. The `emptyDataMessage` prop still wins. */
7
+ emptyDataText: string;
8
+ }
9
+ export declare const defaultInputSelectLocaleText: InputSelectLocaleText;
10
+ /**
11
+ * Resolves the select texts. Precedence: the select's own `localeText`, then `MajooProvider`'s
12
+ * `localeText.inputSelect`, then the app's `MajooUI/inputSelect` translations, then the Indonesian
13
+ * defaults.
14
+ */
15
+ export declare const useInputSelectLocaleText: (localeText?: Partial<InputSelectLocaleText>) => InputSelectLocaleText;
@@ -0,0 +1,20 @@
1
+ export interface InputSelectCheckLocaleText {
2
+ /** The `placeholder` prop still wins. */
3
+ placeholder: string;
4
+ /** The `selectAllLabel` prop still wins. */
5
+ selectAllLabel: string;
6
+ /** Toggle that expands or collapses the selected tags. */
7
+ showAllButton: string;
8
+ showLessButton: string;
9
+ /** Follows the number of selected items. The `labelCounter` prop still wins. */
10
+ counterLabel: string;
11
+ /** Shown when no option matches. The `textEmptyItem` prop still wins. */
12
+ emptyDataText: string;
13
+ }
14
+ export declare const defaultInputSelectCheckLocaleText: InputSelectCheckLocaleText;
15
+ /**
16
+ * Resolves the multi-select texts. Precedence: the select's own `localeText`, then `MajooProvider`'s
17
+ * `localeText.inputSelectCheck`, then the app's `MajooUI/inputSelectCheck` translations, then the
18
+ * Indonesian defaults.
19
+ */
20
+ export declare const useInputSelectCheckLocaleText: (localeText?: Partial<InputSelectCheckLocaleText>, locale?: string) => InputSelectCheckLocaleText;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { CSS } from '@stitches/react';
3
+ import { InputSignatureLocaleText } from './locale';
3
4
  interface InputSignatureProps {
4
5
  onChange?: (value: string) => void;
5
6
  title?: string;
@@ -7,6 +8,11 @@ interface InputSignatureProps {
7
8
  disabled?: boolean;
8
9
  css?: CSS;
9
10
  isMobile?: boolean;
11
+ /**
12
+ * Texts of this input. Keys left unset fall back to `MajooProvider`'s `localeText.inputSignature`,
13
+ * then the Indonesian defaults.
14
+ */
15
+ localeText?: Partial<InputSignatureLocaleText>;
10
16
  }
11
- export declare function InputSignature({ title, onChange, defaultValue, disabled, css, isMobile, }: InputSignatureProps): JSX.Element;
17
+ export declare function InputSignature({ title, onChange, defaultValue, disabled, css, isMobile, localeText, }: InputSignatureProps): JSX.Element;
12
18
  export default InputSignature;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
+ import type { InputSignatureLocaleText } from './locale';
2
3
  interface SignatureModalProps {
3
- t: any;
4
+ text: InputSignatureLocaleText;
4
5
  open?: boolean;
5
6
  onOpenChange?: (open: boolean) => void;
6
7
  onSave?: (signature: string) => void;
@@ -1,2 +1,4 @@
1
1
  export { default as InputSignature } from './InputSignature';
2
2
  export * from './InputSignature';
3
+ export type { InputSignatureLocaleText } from './locale';
4
+ export { defaultInputSignatureLocaleText } from './locale';
@@ -0,0 +1,16 @@
1
+ export interface InputSignatureLocaleText {
2
+ /** Text inside the empty signature box. */
3
+ placeholder: string;
4
+ /** Modal title before and after a signature is drawn. The `title` prop still wins. */
5
+ addTitle: string;
6
+ editTitle: string;
7
+ cancelButton: string;
8
+ saveButton: string;
9
+ }
10
+ export declare const defaultInputSignatureLocaleText: InputSignatureLocaleText;
11
+ /**
12
+ * Resolves the signature input texts. Precedence: the input's own `localeText`, then `MajooProvider`'s
13
+ * `localeText.inputSignature`, then the app's `MajooUI/inputSignature` translations, then the Indonesian
14
+ * defaults.
15
+ */
16
+ export declare const useInputSignatureLocaleText: (localeText?: Partial<InputSignatureLocaleText>) => InputSignatureLocaleText;
@@ -14,12 +14,20 @@ export { default as InputTags } from './InputTags/InputTags';
14
14
  export { default as InputSwitch } from './InputSwitch/InputSwitch';
15
15
  export { default as InputSwitchWithImage } from './InputSwitch/InputSwitchWithImage';
16
16
  export { default as InputSearchbox } from './InputSearchbox/InputSearchbox';
17
+ export type { InputSearchboxLocaleText } from './InputSearchbox/locale';
18
+ export { defaultInputSearchboxLocaleText } from './InputSearchbox/locale';
17
19
  export { default as InputSelect } from './InputSelect/InputSelect';
18
20
  export * from './InputSelect';
19
21
  export { default as InputSelectCheck } from './InputSelectCheck/InputSelectCheck';
22
+ export type { InputSelectCheckLocaleText } from './InputSelectCheck/locale';
23
+ export { defaultInputSelectCheckLocaleText } from './InputSelectCheck/locale';
20
24
  export { default as InputSelectTag } from './InputSelectTag/InputSelectTag';
21
25
  export { default as InputCreatable } from './InputCreatable/InputCreatable';
26
+ export type { InputCreatableLocaleText } from './InputCreatable/locale';
27
+ export { defaultInputCreatableLocaleText } from './InputCreatable/locale';
22
28
  export { default as InputResourceList } from './InputResourceList/InputResourceList';
29
+ export type { InputResourceListLocaleText } from './InputResourceList/locale';
30
+ export { defaultInputResourceListLocaleText } from './InputResourceList/locale';
23
31
  export * from './InputCombobox';
24
32
  export * from './InputOTP';
25
33
  export * from './InputCounter';
@@ -1,2 +1,4 @@
1
1
  export { default as Image } from './Image';
2
2
  export * from './Image';
3
+ export type { ImageLocaleText } from './locale';
4
+ export { defaultImageLocaleText } from './locale';
@@ -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 its default
57
- * (`Hari`, `Minggu`, `Bulan`), which already goes through i18n.
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;
@@ -1,2 +1,4 @@
1
1
  export { default as PeriodSelect } from './PeriodSelect';
2
2
  export * from './PeriodSelect';
3
+ export type { PeriodSelectLocaleText } from './locale';
4
+ export { defaultPeriodSelectLocaleText } from './locale';
@@ -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;
@@ -1 +1,3 @@
1
1
  export { default as TagList } from './TagList';
2
+ export type { TagListLocaleText } from './locale';
3
+ export { defaultTagListLocaleText } from './locale';
@@ -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;