@versini/ui-types 0.0.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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.d.ts +348 -0
  3. package/package.json +27 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Arno Versini
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,348 @@
1
+ import React$1 from 'react';
2
+
3
+ declare namespace SpacingTypes {
4
+ export type Types =
5
+ | undefined
6
+ | string
7
+ | number
8
+ | {
9
+ b?: number;
10
+ l?: number;
11
+ r?: number;
12
+ t?: number;
13
+ };
14
+
15
+ export type Props = {
16
+ spacing?: Types;
17
+ };
18
+ }
19
+
20
+ type CommonButtonProps = {
21
+ /**
22
+ * CSS class(es) to add to the main component wrapper.
23
+ */
24
+ className?: string;
25
+ /**
26
+ * The type of focus for the Button. This will change the color
27
+ * of the focus ring around the Button.
28
+ */
29
+ focusMode?: "dark" | "light" | "system" | "alt-system";
30
+ /**
31
+ * Whether or not the Button is full width.
32
+ * @default false
33
+ */
34
+ fullWidth?: boolean;
35
+ /**
36
+ * The mode of Button. This will change the color of the Button.
37
+ */
38
+ mode?: "dark" | "light" | "system" | "alt-system";
39
+ /**
40
+ * Whether or not to render the Button with a border.
41
+ * @default false
42
+ */
43
+ noBorder?: boolean;
44
+ /**
45
+ * Whether or not to render the Button with a hack for Safari click.
46
+ * @default false
47
+ */
48
+ noInternalClick?: boolean;
49
+ /**
50
+ * Whether or not to render the Button with styles or not.
51
+ * @default false
52
+ */
53
+ raw?: boolean;
54
+ /**
55
+ * The size of the Button.
56
+ */
57
+ size?: "small" | "medium" | "large";
58
+ } & SpacingTypes.Props;
59
+
60
+ declare namespace ButtonTypes {
61
+ export type Props = {
62
+ /**
63
+ * The text to render in the button.
64
+ */
65
+ children: React.ReactNode;
66
+ /**
67
+ * Whether or not the Button is disabled.
68
+ * @default false
69
+ */
70
+ disabled?: boolean;
71
+ /**
72
+ * Whether or not to truncate the text automatically. The text will truncate
73
+ * only if this prop is not set AND the text is longer than the Component. For the
74
+ * text to be longer than the Component, the Component must have a fixed width, potentially
75
+ * set by the parent component or its own className prop.
76
+ * @default false
77
+ */
78
+ noTruncate?: boolean;
79
+ /**
80
+ * Handler to call when the Button is clicked.
81
+ */
82
+ onClick?: React.MouseEventHandler<HTMLButtonElement>;
83
+ /**
84
+ * The variant style of the Button.
85
+ */
86
+ variant?: "primary" | "secondary" | "danger";
87
+ } & CommonButtonProps &
88
+ React.ButtonHTMLAttributes<HTMLButtonElement>;
89
+ }
90
+
91
+ declare namespace ButtonLinkTypes {
92
+ export type Props = {
93
+ /**
94
+ * Whether or not to add an icon indicating that the link
95
+ * opens in a new window.
96
+ * @default false
97
+ */
98
+ noNewWindowIcon?: boolean;
99
+ /**
100
+ * A string that is the result of parsing the href HTML attribute
101
+ * relative to the document, containing a valid URL of a linked resource.
102
+ */
103
+ href?: string;
104
+ /**
105
+ * A string that reflects the target HTML attribute, indicating where
106
+ * to display the linked resource.
107
+ * @default _self
108
+ */
109
+ target?: "_blank" | "_self" | "_parent" | "_top";
110
+ } & ButtonTypes.Props &
111
+ React.AnchorHTMLAttributes<HTMLAnchorElement>;
112
+ }
113
+
114
+ declare namespace ButtonIconTypes {
115
+ export type Props = {
116
+ /**
117
+ * The icon to render in the button.
118
+ */
119
+ children: React.ReactNode;
120
+ /**
121
+ * Cell content alignment.
122
+ * @default "center"
123
+ */
124
+ align?: "left" | "right" | "center";
125
+ /**
126
+ * The label to use as aria-label.
127
+ */
128
+ label?: string;
129
+ /**
130
+ * The label to show to the left of the icon.
131
+ */
132
+ labelLeft?: string;
133
+ /**
134
+ * The label to show to the right of the icon.
135
+ */
136
+ labelRight?: string;
137
+ /**
138
+ * Option to make the Button transparent.
139
+ */
140
+ noBackground?: boolean;
141
+ } & CommonButtonProps &
142
+ React.ButtonHTMLAttributes<HTMLButtonElement>;
143
+ }
144
+
145
+ declare namespace ButtonSortTypes {
146
+ export type Props = {
147
+ /**
148
+ * Prop to signal if the Button is active.
149
+ */
150
+ active?: boolean;
151
+ } & ButtonIconTypes.Props &
152
+ React.ButtonHTMLAttributes<HTMLButtonElement>;
153
+ }
154
+
155
+ declare namespace CardTypes {
156
+ export type Props = {
157
+ /**
158
+ * The children to render.
159
+ */
160
+ children: React$1.ReactNode;
161
+ /**
162
+ * If the header prop is not provided, the Card must be
163
+ * described via aria-labelledby.
164
+ */
165
+ "aria-labelledby"?: string;
166
+ /**
167
+ * CSS class(es) to add to the body.
168
+ */
169
+ bodyClassName?: string;
170
+ /**
171
+ * CSS class(es) to add to the main component wrapper.
172
+ */
173
+ className?: string;
174
+ /**
175
+ * If true, the card will be smaller.
176
+ */
177
+ compact?: boolean;
178
+ /**
179
+ * The content to render in the footer.
180
+ */
181
+ footer?: React$1.ReactNode;
182
+ /**
183
+ * CSS class(es) to add to the footer.
184
+ */
185
+ footerClassName?: string;
186
+ /**
187
+ * The content to render in the header.
188
+ */
189
+ header?: React$1.ReactNode;
190
+ /**
191
+ * CSS class(es) to add to the header.
192
+ */
193
+ headerClassName?: string;
194
+ /**
195
+ * The mode of Card. This will change the color of the Card.
196
+ */
197
+ mode?: "darker" | "dark" | "light" | "system" | "alt-system";
198
+ /**
199
+ * Whether or not to render the Card with a border.
200
+ * @default false
201
+ */
202
+ noBorder?: boolean;
203
+ } & SpacingTypes.Props;
204
+
205
+ export type HeaderProps = {
206
+ className: string;
207
+ content: React$1.ReactNode;
208
+
209
+ id?: string;
210
+ userAriaLabelledby?: string;
211
+ };
212
+ }
213
+
214
+ declare namespace LiveRegionTypes {
215
+ export type SetTimeoutResult = ReturnType<typeof setTimeout> | null;
216
+ export type Action =
217
+ | Record<string, never>
218
+ | {
219
+ type: "SET_ANNOUNCEMENT" | "CLEAR_ANNOUNCEMENT";
220
+ payload?: string | React.ReactNode;
221
+ };
222
+
223
+ export type State = {
224
+ announcement: string | React.ReactNode;
225
+ };
226
+
227
+ export type PolitenessByRole = {
228
+ [key: string]: any;
229
+ };
230
+
231
+ export type ClearAnnouncementProps = {
232
+ dispatch: React.Dispatch<Action>;
233
+ onAnnouncementClear?: () => void;
234
+ };
235
+
236
+ export type AnnounceProps = {
237
+ children: React.ReactNode;
238
+ clearAnnouncementTimeoutRef: React.MutableRefObject<SetTimeoutResult>;
239
+ dispatch: React.Dispatch<Action>;
240
+ clearAnnouncementDelay?: number;
241
+ onAnnouncementClear?: () => void;
242
+ };
243
+
244
+ export type ConditionallyDelayAnnouncementProps = {
245
+ announcementTimeoutRef: React.MutableRefObject<SetTimeoutResult>;
246
+ children: React.ReactNode;
247
+ clearAnnouncementTimeoutRef: React.MutableRefObject<SetTimeoutResult>;
248
+ dispatch: React.Dispatch<Action>;
249
+ announcementDelay?: number;
250
+ clearAnnouncementDelay?: number;
251
+ onAnnouncementClear?: () => void;
252
+ };
253
+
254
+ export type Props = {
255
+ /**
256
+ * The content to be announced by the live region.
257
+ */
258
+ children: React.ReactNode;
259
+ /**
260
+ * The number of milliseconds to wait before announcing the content.
261
+ */
262
+ announcementDelay?: number;
263
+ /**
264
+ * The `className` to apply to the live region.
265
+ */
266
+ className?: string;
267
+ /**
268
+ * The number of milliseconds to wait before clearing the announcement.
269
+ */
270
+ clearAnnouncementDelay?: number;
271
+ /**
272
+ * A callback to be invoked when the announcement is cleared.
273
+ */
274
+ onAnnouncementClear?: () => void;
275
+ /**
276
+ * The `aria-live` politeness level to apply to the live region.
277
+ */
278
+ politeness?: "polite" | "assertive" | "off" | null | undefined;
279
+ /**
280
+ * The `role` to apply to the live region.
281
+ */
282
+ role?: "alert" | "status" | null | undefined;
283
+ /**
284
+ * Whether or not the live region should be visible.
285
+ */
286
+ visible?: boolean;
287
+ };
288
+ }
289
+
290
+ declare namespace ModalTypes {
291
+ export type Options = {
292
+ initialOpen?: boolean;
293
+ onOpenChange?: (open: boolean) => void;
294
+ open?: boolean;
295
+ };
296
+
297
+ export type Context =
298
+ | (ReturnType<Options> & {
299
+ setDescriptionId: React.Dispatch<
300
+ React.SetStateAction<string | undefined>
301
+ >;
302
+ setLabelId: React.Dispatch<React.SetStateAction<string | undefined>>;
303
+ })
304
+ | null;
305
+ }
306
+
307
+ declare namespace SvgIconTypes {
308
+ export type Props = {
309
+ /**
310
+ * The children to render.
311
+ */
312
+ children: React.ReactNode;
313
+ /**
314
+ * The default viewBox to use.
315
+ */
316
+ defaultViewBox: string;
317
+ /**
318
+ * The title to use for the icon. Each icon has a default title,
319
+ * but it can be overridden with this prop.
320
+ */
321
+ title: string;
322
+ /**
323
+ * CSS class(es) to add to the main component wrapper.
324
+ */
325
+ className?: string;
326
+ /**
327
+ * CSS class(es) to add to the main component wrapper.
328
+ */
329
+ defaultClassName?: string;
330
+ /**
331
+ * Update the "fill" property of the SVG.
332
+ * @default "currentColor"
333
+ */
334
+ fill?: string;
335
+ /**
336
+ * Whether or not the icon is semantic (visual and
337
+ * announced to assistive technologies).
338
+ * @default false
339
+ */
340
+ semantic?: boolean;
341
+ /**
342
+ * The viewBox to use. If not provided, the default viewBox will be used.
343
+ */
344
+ viewBox?: string;
345
+ } & SpacingTypes.Props;
346
+ }
347
+
348
+ export { ButtonIconTypes, ButtonLinkTypes, ButtonSortTypes, ButtonTypes, CardTypes, LiveRegionTypes, ModalTypes, SpacingTypes, SvgIconTypes };
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@versini/ui-types",
3
+ "version": "0.0.0",
4
+ "license": "MIT",
5
+ "author": "Arno Versini",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "homepage": "https://github.com/aversini/ui-components",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git@github.com:aversini/ui-components.git"
13
+ },
14
+ "type": "module",
15
+ "main": "dist/index.js",
16
+ "types": "dist/index.d.ts",
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build:check": "tsc",
22
+ "build:types": "tsup",
23
+ "build": "npm-run-all --serial clean build:check build:types",
24
+ "clean": "rimraf dist tmp"
25
+ },
26
+ "gitHead": "950bccb37bca104487c597f8a043ca3382331105"
27
+ }