@saykit/react 0.6.1 → 0.8.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/README.md +1 -1
- package/dist/index.d.mts +62 -10
- package/dist/index.mjs +12 -0
- package/dist/index.server.mjs +12 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ function App() {
|
|
|
23
23
|
return (
|
|
24
24
|
<SayProvider locale="fr" messages={fr}>
|
|
25
25
|
<Say>Hello, {name}!</Say>
|
|
26
|
-
<Say.Plural _={count} one=
|
|
26
|
+
<Say.Plural _={count} one={<>{count} item</>} other={<>{count} items</>} />
|
|
27
27
|
</SayProvider>
|
|
28
28
|
);
|
|
29
29
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from "react";
|
|
2
|
-
import { Disallow, Named, NumeralOptions, SelectOptions } from "saykit";
|
|
2
|
+
import { DateTimeOptions, Disallow, Named, NumberOptions, NumeralOptions, SelectOptions } from "saykit";
|
|
3
3
|
//#region src/types.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* What a message is allowed to contain. On top of everything React renders, a
|
|
@@ -35,7 +35,7 @@ declare namespace Say {
|
|
|
35
35
|
* <Say.Plural
|
|
36
36
|
* _={count}
|
|
37
37
|
* one="You have 1 item"
|
|
38
|
-
* other=
|
|
38
|
+
* other={<>You have {count} items</>}
|
|
39
39
|
* />
|
|
40
40
|
* ```
|
|
41
41
|
*
|
|
@@ -46,7 +46,7 @@ declare namespace Say {
|
|
|
46
46
|
*/
|
|
47
47
|
function Plural(props: {
|
|
48
48
|
_: number | Named<number>;
|
|
49
|
-
} & PropsWithJSXSafeKeys<Disallow<NumeralOptions
|
|
49
|
+
} & PropsWithJSXSafeKeys<Disallow<NumeralOptions<ReactNode>, 'id' | 'context'>>): ReactNode;
|
|
50
50
|
/**
|
|
51
51
|
* Define an ordinal message (e.g. "1st", "2nd", "3rd").
|
|
52
52
|
*
|
|
@@ -54,10 +54,10 @@ declare namespace Say {
|
|
|
54
54
|
* ```tsx
|
|
55
55
|
* <Say.Ordinal
|
|
56
56
|
* _={position}
|
|
57
|
-
* 1=
|
|
58
|
-
* 2=
|
|
59
|
-
* 3=
|
|
60
|
-
* other=
|
|
57
|
+
* 1={<>{position}st</>}
|
|
58
|
+
* 2={<>{position}nd</>}
|
|
59
|
+
* 3={<>{position}rd</>}
|
|
60
|
+
* other={<>{position}th</>}
|
|
61
61
|
* />
|
|
62
62
|
* ```
|
|
63
63
|
*
|
|
@@ -68,7 +68,7 @@ declare namespace Say {
|
|
|
68
68
|
*/
|
|
69
69
|
function Ordinal(props: {
|
|
70
70
|
_: number | Named<number>;
|
|
71
|
-
} & PropsWithJSXSafeKeys<Disallow<NumeralOptions
|
|
71
|
+
} & PropsWithJSXSafeKeys<Disallow<NumeralOptions<ReactNode>, 'id' | 'context'>>): ReactNode;
|
|
72
72
|
/**
|
|
73
73
|
* Define a select message, useful for handling gender, status, or other categories.
|
|
74
74
|
*
|
|
@@ -88,8 +88,60 @@ declare namespace Say {
|
|
|
88
88
|
* @remark This is a macro and must be used with the relevant saykit plugin
|
|
89
89
|
*/
|
|
90
90
|
function Select(props: {
|
|
91
|
-
_: string | Named<string>;
|
|
92
|
-
} & PropsWithJSXSafeKeys<Disallow<SelectOptions
|
|
91
|
+
_: string | number | Named<string | number>;
|
|
92
|
+
} & PropsWithJSXSafeKeys<Disallow<SelectOptions<ReactNode>, 'id' | 'context'>>): ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* Format a number the way the active locale writes one.
|
|
95
|
+
*
|
|
96
|
+
* Unlike `Say.Plural`, `Say.Ordinal`, and `Say.Select`, this is a fragment
|
|
97
|
+
* rather than a whole message, and is normally written inside one.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```tsx
|
|
101
|
+
* <Say>You have <Say.Number _={items.length} /> items</Say>
|
|
102
|
+
* <Say>Battery at <Say.Number _={level} style="percent" /></Say>
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @param props._ Number to format
|
|
106
|
+
* @param props.style Formatting style, either a named style or a literal number pattern
|
|
107
|
+
* @returns The formatted number, as a React node
|
|
108
|
+
* @remark This is a macro and must be used with the relevant saykit plugin
|
|
109
|
+
*/
|
|
110
|
+
function Number(props: {
|
|
111
|
+
_: number | Named<number>;
|
|
112
|
+
} & Disallow<NumberOptions, 'id' | 'context'>): ReactNode;
|
|
113
|
+
/**
|
|
114
|
+
* Format the date portion of a value the way the active locale writes one.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```tsx
|
|
118
|
+
* <Say>Published <Say.Date _={post.publishedAt} style="medium" /></Say>
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @param props._ Date to format
|
|
122
|
+
* @param props.style Formatting style
|
|
123
|
+
* @returns The formatted date, as a React node
|
|
124
|
+
* @remark This is a macro and must be used with the relevant saykit plugin
|
|
125
|
+
*/
|
|
126
|
+
function Date(props: {
|
|
127
|
+
_: globalThis.Date | number | Named<globalThis.Date | number>;
|
|
128
|
+
} & Disallow<DateTimeOptions, 'id' | 'context'>): ReactNode;
|
|
129
|
+
/**
|
|
130
|
+
* Format the time portion of a value the way the active locale writes one.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```tsx
|
|
134
|
+
* <Say>Doors open at <Say.Time _={opensAt} style="short" /></Say>
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* @param props._ Date to format
|
|
138
|
+
* @param props.style Formatting style
|
|
139
|
+
* @returns The formatted time, as a React node
|
|
140
|
+
* @remark This is a macro and must be used with the relevant saykit plugin
|
|
141
|
+
*/
|
|
142
|
+
function Time(props: {
|
|
143
|
+
_: globalThis.Date | number | Named<globalThis.Date | number>;
|
|
144
|
+
} & Disallow<DateTimeOptions, 'id' | 'context'>): ReactNode;
|
|
93
145
|
}
|
|
94
146
|
//#endregion
|
|
95
147
|
export { Say };
|
package/dist/index.mjs
CHANGED
|
@@ -101,6 +101,18 @@ function Say(props) {
|
|
|
101
101
|
throw new Error("'Say.Select' is a macro and must be used with the relevant saykit plugin");
|
|
102
102
|
}
|
|
103
103
|
_Say.Select = Select;
|
|
104
|
+
function Number(props) {
|
|
105
|
+
throw new Error("'Say.Number' is a macro and must be used with the relevant saykit plugin");
|
|
106
|
+
}
|
|
107
|
+
_Say.Number = Number;
|
|
108
|
+
function Date(props) {
|
|
109
|
+
throw new Error("'Say.Date' is a macro and must be used with the relevant saykit plugin");
|
|
110
|
+
}
|
|
111
|
+
_Say.Date = Date;
|
|
112
|
+
function Time(props) {
|
|
113
|
+
throw new Error("'Say.Time' is a macro and must be used with the relevant saykit plugin");
|
|
114
|
+
}
|
|
115
|
+
_Say.Time = Time;
|
|
104
116
|
})(Say || (Say = {}));
|
|
105
117
|
//#endregion
|
|
106
118
|
export { Say };
|
package/dist/index.server.mjs
CHANGED
|
@@ -101,6 +101,18 @@ function Say(props) {
|
|
|
101
101
|
throw new Error("'Say.Select' is a macro and must be used with the relevant saykit plugin");
|
|
102
102
|
}
|
|
103
103
|
_Say.Select = Select;
|
|
104
|
+
function Number(props) {
|
|
105
|
+
throw new Error("'Say.Number' is a macro and must be used with the relevant saykit plugin");
|
|
106
|
+
}
|
|
107
|
+
_Say.Number = Number;
|
|
108
|
+
function Date(props) {
|
|
109
|
+
throw new Error("'Say.Date' is a macro and must be used with the relevant saykit plugin");
|
|
110
|
+
}
|
|
111
|
+
_Say.Date = Date;
|
|
112
|
+
function Time(props) {
|
|
113
|
+
throw new Error("'Say.Time' is a macro and must be used with the relevant saykit plugin");
|
|
114
|
+
}
|
|
115
|
+
_Say.Time = Time;
|
|
104
116
|
})(Say || (Say = {}));
|
|
105
117
|
//#endregion
|
|
106
118
|
export { Say };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saykit/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "React integration for saykit, i18n hooks and components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"jsdom": "^29.1.1",
|
|
53
53
|
"react": "^19.2.8",
|
|
54
54
|
"react-dom": "^19.2.8",
|
|
55
|
-
"saykit": "^0.
|
|
55
|
+
"saykit": "^0.8.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"react": "*",
|