@sesamehr/react-design-system 2.1.0 → 3.1.0-beta.1
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/dist/Feedback/StatusBadge/StatusBadge.d.ts +1 -0
- package/dist/Feedback/StatusBadge/index.d.ts +9 -4
- package/dist/Locale/LocaleProvider/LocaleProvider.d.ts +13 -1
- package/dist/Locale/index.d.ts +2 -0
- package/dist/Locale/messages.d.ts +28 -0
- package/dist/Locale/useTranslate.d.ts +36 -0
- package/dist/main.d.ts +4 -2
- package/dist/react-design-system.css +1 -1
- package/dist/react-design-system.js +8763 -8694
- package/dist/react-design-system.umd.cjs +46 -46
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StatusBadgeVariants } from './index.ts';
|
|
2
2
|
export interface StatusBadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
/** Which tone the dot takes. The wording is yours — pass it as children. */
|
|
3
4
|
status?: StatusBadgeVariants['status'];
|
|
4
5
|
dataTestid: string;
|
|
5
6
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { VariantProps } from 'class-variance-authority';
|
|
2
2
|
export { StatusBadge, type StatusBadgeProps } from './StatusBadge.tsx';
|
|
3
|
+
/**
|
|
4
|
+
* Class names, not utilities: the declarations live in `StatusBadge.module.css`
|
|
5
|
+
* behind `@apply`. See `Button/index.ts` for why.
|
|
6
|
+
*
|
|
7
|
+
* The statuses are tones rather than states — `warning`, not `pending` — because
|
|
8
|
+
* the wording is the consumer's and only the colour is ours. A payroll run that
|
|
9
|
+
* is "Pendiente" and a document that is "Awaiting review" are the same badge.
|
|
10
|
+
*/
|
|
3
11
|
export declare const statusBadgeVariants: (props?: ({
|
|
4
|
-
status?: "
|
|
5
|
-
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
6
|
-
export declare const indicatorVariants: (props?: ({
|
|
7
|
-
status?: "paused" | "active" | "draft" | "completed" | "scheduled" | "deleted" | null | undefined;
|
|
12
|
+
status?: "success" | "error" | "info" | "warning" | "neutral" | null | undefined;
|
|
8
13
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
9
14
|
export type StatusBadgeVariants = VariantProps<typeof statusBadgeVariants>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Translate } from '../useTranslate.ts';
|
|
1
2
|
export interface LocaleProviderProps {
|
|
2
3
|
/**
|
|
3
4
|
* A BCP-47 language tag. Bare tags are fine — `es` is as valid as `es-ES`,
|
|
@@ -8,10 +9,21 @@ export interface LocaleProviderProps {
|
|
|
8
9
|
* separately from their browser settings, or the two will disagree.
|
|
9
10
|
*/
|
|
10
11
|
locale?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Your i18n's `t`. `react-i18next`'s fits as-is, because this is the shape it
|
|
14
|
+
* already has.
|
|
15
|
+
*
|
|
16
|
+
* The design system carries no i18n of its own; it declares the keys in
|
|
17
|
+
* `en.ts` and this resolves them. Left out, every label renders its English
|
|
18
|
+
* source, which keeps a component renderable in isolation but is not a
|
|
19
|
+
* translation: a Spanish application that never passes this gets English
|
|
20
|
+
* `aria-label`s.
|
|
21
|
+
*/
|
|
22
|
+
t?: Translate;
|
|
11
23
|
children?: React.ReactNode;
|
|
12
24
|
}
|
|
13
25
|
/** LocaleProvider — mirrors `@sesame/orxata-core` LocaleProvider. */
|
|
14
26
|
export declare const LocaleProvider: {
|
|
15
|
-
({ locale, children }: LocaleProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
({ locale, t, children, }: LocaleProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
16
28
|
displayName: string;
|
|
17
29
|
};
|
package/dist/Locale/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { LocaleProvider } from './LocaleProvider/LocaleProvider.tsx';
|
|
2
2
|
export type { LocaleProviderProps } from './LocaleProvider/LocaleProvider.tsx';
|
|
3
3
|
export { LocaleContext, normalizeLocale, useLocale } from './useLocale.ts';
|
|
4
|
+
export { TranslateContext, useTranslate, type Translate, } from './useTranslate.ts';
|
|
5
|
+
export { english, orxataMessages, type MessageKey, type Messages, } from './messages.ts';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every key the design system asks its `t` for.
|
|
3
|
+
*
|
|
4
|
+
* A plain `string`, not a union of the 29 key names. Deriving that union meant a
|
|
5
|
+
* generated file per package plus the script and CI job to keep them honest —
|
|
6
|
+
* ~240 lines to protect call sites we write once per component, in this
|
|
7
|
+
* repository, and which the components' own tests already cover: a mistyped key
|
|
8
|
+
* renders the key instead of its text, and every one of them is asserted by a
|
|
9
|
+
* `getByText` or a `getByRole(..., { name })` somewhere.
|
|
10
|
+
*
|
|
11
|
+
* It bought a consumer nothing either, once `orxataMessages` replaced the
|
|
12
|
+
* `messages` override prop — nobody outside this package writes a key any more.
|
|
13
|
+
*/
|
|
14
|
+
export type MessageKey = string;
|
|
15
|
+
/** A catalogue: keys to strings. A pulled locale may be missing some. */
|
|
16
|
+
export type Messages = Record<MessageKey, string>;
|
|
17
|
+
/** Ready for `i18next`, placeholders already in its own `{{name}}` spelling. */
|
|
18
|
+
export declare const orxataMessages: Record<string, Partial<Messages>>;
|
|
19
|
+
/**
|
|
20
|
+
* The English source — `translations/en.json`, which is authored rather than
|
|
21
|
+
* pulled and therefore holds every key.
|
|
22
|
+
*
|
|
23
|
+
* Deliberately taken *before* `toI18next`: this is what `useTranslate` falls back
|
|
24
|
+
* to with no `t` injected, and it fills `{name}` blanks itself. Handing it the
|
|
25
|
+
* doubled spelling would leave `Remove {{label}}` matching on the inner braces
|
|
26
|
+
* and rendering `Remove {Ana}`.
|
|
27
|
+
*/
|
|
28
|
+
export declare const english: Partial<Messages>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { MessageKey } from './messages.ts';
|
|
2
|
+
/**
|
|
3
|
+
* What the design system asks an application's i18n for.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately the shape `react-i18next`'s `t` already has, so the common case
|
|
6
|
+
* is passing it straight through — `t={t}` — with no adapter. `key` is narrowed
|
|
7
|
+
* to `MessageKey` for callers inside this package; a `t` that takes `string` is
|
|
8
|
+
* assignable to it, which is what makes theirs fit without a cast.
|
|
9
|
+
*/
|
|
10
|
+
export type Translate = (key: MessageKey, params?: Record<string, string | number>) => string;
|
|
11
|
+
export declare const TranslateContext: import('react').Context<Translate | undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* The `t` a design-system component calls.
|
|
14
|
+
*
|
|
15
|
+
* **This package carries no i18n.** It declares the keys it needs and ships the
|
|
16
|
+
* translations for them (`orxataMessages`, already in i18next's `{{name}}`
|
|
17
|
+
* spelling), and the application resolves them with the i18n it already has:
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* Object.entries(orxataMessages).forEach(([locale, messages]) =>
|
|
21
|
+
* i18n.addResourceBundle(locale, 'translation', messages, true, false)
|
|
22
|
+
* );
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <OxLocaleProvider locale="es" t={t}>
|
|
27
|
+
* <App />
|
|
28
|
+
* </OxLocaleProvider>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* With no `t` injected, a key reads its English source, with its `{name}` blanks
|
|
32
|
+
* filled — a dictionary lookup, not a fallback chain and not a locale. That is
|
|
33
|
+
* enough to keep a component renderable on its own in a test, and honest about
|
|
34
|
+
* being English rather than a translation.
|
|
35
|
+
*/
|
|
36
|
+
export declare const useTranslate: () => Translate;
|
package/dist/main.d.ts
CHANGED
|
@@ -16,7 +16,9 @@ export { Divider as OxDivider, type DividerProps, } from './Layout/Divider/index
|
|
|
16
16
|
export { Resizable as OxResizable, ResizablePanel as OxResizablePanel, ResizableHandle as OxResizableHandle, } from './Layout/Resizable/index.ts';
|
|
17
17
|
export { Scrollbar as OxScrollbar, useScrollbar, SCROLLBAR_THICKNESS, type ScrollbarProps, type UseScrollbarReturn, } from './Layout/Scrollbar/index.ts';
|
|
18
18
|
export { LocaleProvider as OxLocaleProvider } from './Locale/index.ts';
|
|
19
|
-
export { normalizeLocale, useLocale } from './Locale/index.ts';
|
|
19
|
+
export { normalizeLocale, useLocale, useTranslate, type Translate, } from './Locale/index.ts';
|
|
20
|
+
export { LocaleContext, TranslateContext } from './Locale/index.ts';
|
|
21
|
+
export { english, orxataMessages, type MessageKey, type Messages, } from './Locale/index.ts';
|
|
20
22
|
export { AvatarRounded as OxAvatarRounded, AvatarSkeleton as OxAvatarSkeleton, AvatarSquare as OxAvatarSquare, avatarRoundedVariants, avatarSquareVariants, type AvatarRoundedVariants, type AvatarSize, type AvatarSquareVariants, type AvatarTone, } from './Display/Avatar/index.ts';
|
|
21
23
|
export { AvatarDetails as OxAvatarDetails, type AvatarDetailsAvatar, } from './Display/AvatarDetails/index.ts';
|
|
22
24
|
export { AvatarGroup as OxAvatarGroup, type AvatarItem, } from './Display/AvatarGroup/index.ts';
|
|
@@ -30,7 +32,7 @@ export { ChatBubble as OxChatBubble, chatBubbleVariants, type ChatBubbleDelivery
|
|
|
30
32
|
export { ChatBubbleStatus as OxChatBubbleStatus, chatBubbleStatusVariants, type ChatBubbleStatusVariants, } from './Display/ChatBubble/ChatBubbleStatus/index.ts';
|
|
31
33
|
export { Chip as OxChip, chipVariants, type ChipVariants, } from './Display/Chip/index.ts';
|
|
32
34
|
export { PointMarker as OxPointMarker, pointMarkerVariants, type PointMarkerVariants, } from './Display/PointMarker/index.ts';
|
|
33
|
-
export { StatusBadge as OxStatusBadge, statusBadgeVariants,
|
|
35
|
+
export { StatusBadge as OxStatusBadge, statusBadgeVariants, type StatusBadgeVariants, } from './Feedback/StatusBadge/index.ts';
|
|
34
36
|
export { Bullet as OxBullet, bulletVariants, type BulletVariants, } from './Feedback/Bullet/index.ts';
|
|
35
37
|
export { Loader as OxLoader } from './Feedback/Loader/index.ts';
|
|
36
38
|
export { Progress as OxProgress } from './Feedback/Progress/index.ts';
|