Skip to content

Commit c567e86

Browse files
authored
Merge pull request #144 from spuxx-dev/feat/browser-types
feat(types): Add new `InputType` and `SelectOption` utility types
2 parents 219f67b + 4a4030e commit c567e86

File tree

6 files changed

+69
-6
lines changed

6 files changed

+69
-6
lines changed

apps/starlight/src/assets/sidebar.ts

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ export const sidebar: StarlightUserConfigWithPlugins['sidebar'] = [
3030
label: 'Styles and Themes',
3131
slug: 'browser-utils/styles-and-themes',
3232
},
33+
{
34+
label: 'Types',
35+
autogenerate: { directory: 'browser-utils/types' },
36+
},
3337
{
3438
label: 'Services',
3539
autogenerate: { directory: 'browser-utils/services' },

apps/starlight/src/content/docs/browser-utils/styles-and-themes.mdx

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ title: 'Styles and Themes'
33
description: '@spuxx/browser-utils provides a set of CSS styles and themes primarily intended for my personal use.'
44
---
55

6-
import TypeDoc from '@docs/browser-utils/types/styles.md';
7-
86
The package provides a set of CSS styles and themes primarily intended for my personal use. You are free to use it in your own projects, but I will not be accepting pull requests or issues requesting changes to this part of the library.
97

108
## Styles
@@ -136,7 +134,4 @@ To do this, you can use the `spx-theme` attribute on the element itself.
136134

137135
## Variables and Types
138136

139-
The library also provides a set of variables and types for use with TypeScript. They can help you use the styles correctly and in a type-safe manner.
140-
They are primarily intended for use with [SolidJS](https://www.solidjs.com/) and my [@spuxx/solid](https://spuxx-dev.github.io/jslibs/browser-utils) library.
141-
142-
<TypeDoc />
137+
The library also provides a set of variables and types for use with TypeScript. They can help you use the styles correctly and in a type-safe manner. You can find them [here](types/styles).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: 'HTML Types'
3+
description: 'A selection of HTML-related utility types for use in browser applications.'
4+
---
5+
6+
import TypeDoc from '@docs/browser-utils/types/html.md';
7+
8+
The package includes a collection of useful TypeScript types that can help with HTML-related use-cases in browser applications.
9+
10+
<TypeDoc />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: 'Style-related Types'
3+
description: 'A selection of style-related utility types for use in browser applications.'
4+
---
5+
6+
import TypeDoc from '@docs/browser-utils/types/styles.md';
7+
8+
The library also provides a set of variables and types for use with TypeScript. They can help you use the styles correctly and in a type-safe manner.
9+
They are primarily intended for use with [SolidJS](https://www.solidjs.com/) and my [@spuxx/solid](https://spuxx-dev.github.io/jslibs/browser-utils) library.
10+
11+
<TypeDoc />

packages/browser-utils/src/main.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export * from './services/config';
66
export * from './services/local-storage';
77
export * from './services/user-agent';
88
export * from './types/styles';
9+
export * from './types/html';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Valid input types according to the HTML specification.
3+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types}
4+
*/
5+
export const InputType = {
6+
button: 'button',
7+
checkbox: 'checkbox',
8+
color: 'color',
9+
date: 'date',
10+
datetimeLocal: 'datetime-local',
11+
email: 'email',
12+
file: 'file',
13+
hidden: 'hidden',
14+
image: 'image',
15+
month: 'month',
16+
number: 'number',
17+
password: 'password',
18+
radio: 'radio',
19+
range: 'range',
20+
reset: 'reset',
21+
search: 'search',
22+
submit: 'submit',
23+
tel: 'tel',
24+
text: 'text',
25+
time: 'time',
26+
url: 'url',
27+
week: 'week',
28+
} as const;
29+
/**
30+
* Valid input types according to the HTML specification.
31+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types}
32+
*/
33+
export type InputType = (typeof InputType)[keyof typeof InputType];
34+
35+
/**
36+
* Represents an `option` element's data. May be used for `select`, `datalist` and similar
37+
* elements.
38+
*/
39+
export interface SelectOption {
40+
value: string;
41+
label: string;
42+
}

0 commit comments

Comments
 (0)