rei-kit 0.1.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/LICENSE +21 -0
- package/README.md +87 -0
- package/dist/app-error-DF9cijE0.js +63 -0
- package/dist/app-error-DF9cijE0.js.map +1 -0
- package/dist/components/BaseButton.vue.d.ts +20 -0
- package/dist/components/BaseInput.vue.d.ts +23 -0
- package/dist/components/BaseSheet.vue.d.ts +32 -0
- package/dist/components/EmptyState.vue.d.ts +19 -0
- package/dist/components/LocaleLinks.vue.d.ts +33 -0
- package/dist/components/PageHeader.vue.d.ts +20 -0
- package/dist/components/SectionHeading.vue.d.ts +26 -0
- package/dist/components/SegmentedControl.vue.d.ts +27 -0
- package/dist/components/SettingsGroup.vue.d.ts +16 -0
- package/dist/components/SettingsRow.vue.d.ts +35 -0
- package/dist/components/SkeletonList.vue.d.ts +8 -0
- package/dist/components/StatCard.vue.d.ts +8 -0
- package/dist/components/ToneDot.vue.d.ts +16 -0
- package/dist/composables/use-debounced-callback.d.ts +23 -0
- package/dist/composables/use-drag-scroll.d.ts +26 -0
- package/dist/composables/use-online.d.ts +18 -0
- package/dist/composables/use-theme.d.ts +23 -0
- package/dist/composables/use-today.d.ts +10 -0
- package/dist/composables/use-visual-viewport.d.ts +29 -0
- package/dist/i18n/runtime.d.ts +53 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +1349 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +27 -0
- package/dist/supabase/index.d.ts +28 -0
- package/dist/supabase.js +100 -0
- package/dist/supabase.js.map +1 -0
- package/dist/tokens.css +139 -0
- package/dist/utils/app-error.d.ts +58 -0
- package/dist/utils/date.d.ts +122 -0
- package/dist/utils/day-label.d.ts +27 -0
- package/dist/utils/download.d.ts +7 -0
- package/dist/utils/format.d.ts +24 -0
- package/dist/utils/haptics.d.ts +9 -0
- package/dist/utils/platform.d.ts +23 -0
- package/dist/utils/redirect.d.ts +41 -0
- package/package.json +98 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** What the user picked. `system` re-reads the browser on every launch. */
|
|
2
|
+
export type LocalePreference<L extends string> = 'system' | L;
|
|
3
|
+
export interface I18nRuntimeOptions<L extends string, Schema> {
|
|
4
|
+
/** Languages the app ships, in no particular order. */
|
|
5
|
+
locales: readonly L[];
|
|
6
|
+
/** The one that is always loaded, and the fallback when a load fails. */
|
|
7
|
+
fallback: L;
|
|
8
|
+
/**
|
|
9
|
+
* BCP 47 tag per locale, for `Intl`.
|
|
10
|
+
*
|
|
11
|
+
* Message lookup only needs the base language, but dates and numbers need a
|
|
12
|
+
* region to be right — `zh` alone would leave the formatter to guess.
|
|
13
|
+
*/
|
|
14
|
+
intlTags: Record<L, string>;
|
|
15
|
+
/** The fallback's messages, bundled. */
|
|
16
|
+
messages: Schema;
|
|
17
|
+
/** The rest, fetched only when they are the one in use. */
|
|
18
|
+
loaders?: Partial<Record<L, () => Promise<{
|
|
19
|
+
default: Schema;
|
|
20
|
+
}>>>;
|
|
21
|
+
/** Where the choice is stored. Namespace it per app. */
|
|
22
|
+
storageKey?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Builds an i18n runtime around an app's own catalogue.
|
|
26
|
+
*
|
|
27
|
+
* A factory rather than a module singleton because the schema is the app's:
|
|
28
|
+
* typing every locale as `typeof en` is what makes a missing key a build error,
|
|
29
|
+
* and this package has no `en` of its own to type against.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* export const { i18n, t, useLocalePreference, loadActiveLocale } =
|
|
34
|
+
* createI18nRuntime({
|
|
35
|
+
* locales: ['en', 'tr'] as const,
|
|
36
|
+
* fallback: 'en',
|
|
37
|
+
* intlTags: { en: 'en-GB', tr: 'tr-TR' },
|
|
38
|
+
* messages: en,
|
|
39
|
+
* loaders: { tr: () => import('./locales/tr') },
|
|
40
|
+
* storageKey: 'myapp-locale',
|
|
41
|
+
* })
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function createI18nRuntime<L extends string, Schema extends Record<string, unknown>>(options: I18nRuntimeOptions<L, Schema>): {
|
|
45
|
+
i18n: import('vue-i18n').I18n<{}, {}, {}, string, true>;
|
|
46
|
+
/** `t` for code outside a component. Tracks the locale inside a computed. */
|
|
47
|
+
t: (key: string, named?: Record<string, unknown>) => string;
|
|
48
|
+
activeLocale: import('vue').ComputedRef<L>;
|
|
49
|
+
intlLocale: import('vue').ComputedRef<Record<L, string>[L]>;
|
|
50
|
+
ensureMessages: (locale: L) => Promise<void>;
|
|
51
|
+
loadActiveLocale: () => Promise<void>;
|
|
52
|
+
useLocalePreference: () => import('vue').WritableComputedRef<LocalePreference<L>, LocalePreference<L>>;
|
|
53
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* rei-kit — the layer every app starts from.
|
|
3
|
+
*
|
|
4
|
+
* Everything here is free of any backend, router or i18n choice. Components
|
|
5
|
+
* take strings rather than calling a translator, and utilities take the clock
|
|
6
|
+
* rather than reading it, so nothing in this package can force a decision on
|
|
7
|
+
* the app that installs it.
|
|
8
|
+
*
|
|
9
|
+
* @see https://github.com/ramazandogna/rei-kit
|
|
10
|
+
*/
|
|
11
|
+
export declare const VERSION = "0.0.0";
|
|
12
|
+
export { addDays, eachDayOfYear, fromDateKey, lastNDays, leadingBlanks, startOfWeek, toDateKey, todayKey, } from './utils/date';
|
|
13
|
+
export type { WeekStart } from './utils/date';
|
|
14
|
+
export { formatDate, setFormatLocale } from './utils/format';
|
|
15
|
+
export { relativeDayLabel } from './utils/day-label';
|
|
16
|
+
export type { DayLabels } from './utils/day-label';
|
|
17
|
+
export { downloadJson } from './utils/download';
|
|
18
|
+
export { safeRedirect } from './utils/redirect';
|
|
19
|
+
export type { QueryValue } from './utils/redirect';
|
|
20
|
+
export { tapFeedback } from './utils/haptics';
|
|
21
|
+
export { isApplePortable, isInstalled, needsIosInstall } from './utils/platform';
|
|
22
|
+
export { AppError, registerErrorMapper, toAppError } from './utils/app-error';
|
|
23
|
+
export type { AppErrorKind, ErrorMapper } from './utils/app-error';
|
|
24
|
+
export { applyTheme, isThemePreference, readStoredTheme, setThemeStorageKey, useTheme, } from './composables/use-theme';
|
|
25
|
+
export type { ThemePreference } from './composables/use-theme';
|
|
26
|
+
export { useToday } from './composables/use-today';
|
|
27
|
+
export { useOnline } from './composables/use-online';
|
|
28
|
+
export { useDebouncedCallback } from './composables/use-debounced-callback';
|
|
29
|
+
export { useDragScroll } from './composables/use-drag-scroll';
|
|
30
|
+
export { useVisualViewport } from './composables/use-visual-viewport';
|
|
31
|
+
export type { VisualViewportRect } from './composables/use-visual-viewport';
|
|
32
|
+
export { default as BaseButton } from './components/BaseButton.vue';
|
|
33
|
+
export { default as BaseInput } from './components/BaseInput.vue';
|
|
34
|
+
export { default as BaseSheet } from './components/BaseSheet.vue';
|
|
35
|
+
export { default as EmptyState } from './components/EmptyState.vue';
|
|
36
|
+
export { default as PageHeader } from './components/PageHeader.vue';
|
|
37
|
+
export { default as SectionHeading } from './components/SectionHeading.vue';
|
|
38
|
+
export { default as SegmentedControl } from './components/SegmentedControl.vue';
|
|
39
|
+
export { default as SettingsGroup } from './components/SettingsGroup.vue';
|
|
40
|
+
export { default as SettingsRow } from './components/SettingsRow.vue';
|
|
41
|
+
export { default as SkeletonList } from './components/SkeletonList.vue';
|
|
42
|
+
export { default as StatCard } from './components/StatCard.vue';
|
|
43
|
+
export { default as ToneDot } from './components/ToneDot.vue';
|
|
44
|
+
export type { Tone } from './components/SectionHeading.vue';
|
|
45
|
+
export { default as LocaleLinks } from './components/LocaleLinks.vue';
|
|
46
|
+
export { createI18nRuntime } from './i18n/runtime';
|
|
47
|
+
export type { I18nRuntimeOptions, LocalePreference } from './i18n/runtime';
|