shelving 1.243.0 → 1.244.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/package.json +1 -1
- package/schema/ColorSchema.d.ts +5 -3
- package/schema/ColorSchema.js +6 -4
- package/schema/CurrencyCodeSchema.d.ts +3 -3
- package/schema/CurrencyCodeSchema.js +3 -3
- package/schema/EmailSchema.d.ts +11 -2
- package/schema/EmailSchema.js +6 -4
- package/schema/PasswordSchema.d.ts +6 -12
- package/schema/PasswordSchema.js +7 -6
- package/schema/PhoneSchema.d.ts +5 -3
- package/schema/PhoneSchema.js +7 -5
- package/schema/SlugSchema.d.ts +8 -1
- package/schema/SlugSchema.js +2 -2
- package/schema/URISchema.d.ts +5 -3
- package/schema/URISchema.js +6 -4
- package/schema/URLSchema.d.ts +5 -3
- package/schema/URLSchema.js +6 -4
- package/schema/UUIDSchema.d.ts +10 -2
- package/schema/UUIDSchema.js +4 -3
- package/ui/block/Card.js +1 -1
- package/ui/block/Card.tsx +3 -1
- package/ui/block/Prose.js +2 -2
- package/ui/block/Prose.tsx +25 -25
- package/ui/block/Table.d.ts +4 -3
- package/ui/block/Table.js +3 -2
- package/ui/block/Table.md +1 -0
- package/ui/block/Table.module.css +1 -0
- package/ui/block/Table.tsx +5 -3
- package/ui/dialog/Dialog.js +1 -1
- package/ui/dialog/Dialog.tsx +2 -2
- package/ui/dialog/Modal.js +2 -1
- package/ui/dialog/Modal.tsx +2 -1
- package/ui/docs/DocumentationPage.js +1 -1
- package/ui/docs/DocumentationPage.tsx +5 -5
- package/ui/form/ButtonInput.js +2 -2
- package/ui/form/ButtonInput.tsx +7 -2
- package/ui/form/CheckboxInput.js +2 -2
- package/ui/form/CheckboxInput.tsx +8 -3
- package/ui/form/DateInput.js +2 -2
- package/ui/form/DateInput.tsx +2 -2
- package/ui/form/Field.js +2 -2
- package/ui/form/Field.tsx +4 -4
- package/ui/form/Form.js +2 -1
- package/ui/form/Form.tsx +3 -2
- package/ui/form/Input.d.ts +1 -1
- package/ui/form/Input.js +4 -4
- package/ui/form/Input.tsx +4 -4
- package/ui/form/NumberInput.js +2 -2
- package/ui/form/NumberInput.tsx +2 -2
- package/ui/form/OutputInput.js +2 -2
- package/ui/form/OutputInput.tsx +5 -2
- package/ui/form/Popover.js +3 -2
- package/ui/form/Popover.tsx +3 -2
- package/ui/form/Progress.js +3 -3
- package/ui/form/Progress.tsx +15 -5
- package/ui/form/RadioInput.js +2 -2
- package/ui/form/RadioInput.tsx +10 -3
- package/ui/form/SelectInput.js +2 -2
- package/ui/form/SelectInput.tsx +4 -4
- package/ui/form/TextInput.js +3 -3
- package/ui/form/TextInput.tsx +3 -3
- package/ui/layout/CenteredLayout.js +2 -2
- package/ui/layout/CenteredLayout.tsx +3 -3
- package/ui/layout/SidebarLayout.js +5 -5
- package/ui/layout/SidebarLayout.tsx +16 -7
- package/ui/misc/Loading.js +2 -1
- package/ui/misc/Loading.tsx +10 -3
- package/ui/notice/Message.js +2 -2
- package/ui/notice/Message.tsx +2 -2
package/package.json
CHANGED
package/schema/ColorSchema.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { StringSchema, type StringSchemaOptions } from "./StringSchema.js";
|
|
|
4
4
|
*
|
|
5
5
|
* @see https://dhoulb.github.io/shelving/schema/ColorSchema/ColorSchemaOptions
|
|
6
6
|
*/
|
|
7
|
-
export interface ColorSchemaOptions extends Omit<StringSchemaOptions, "
|
|
7
|
+
export interface ColorSchemaOptions extends Omit<StringSchemaOptions, "min" | "match" | "rows"> {
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Schema that defines a valid color hex string, e.g. `#00CCFF`
|
|
@@ -19,12 +19,14 @@ export declare class ColorSchema extends StringSchema {
|
|
|
19
19
|
/**
|
|
20
20
|
* Create a new `ColorSchema`.
|
|
21
21
|
*
|
|
22
|
-
* @param options Options for the schema (inherits `StringSchema` options except `
|
|
22
|
+
* @param options Options for the schema (inherits `StringSchema` options except `min`, `match`, and `rows`, which are fixed for hex colors).
|
|
23
23
|
* @param options.one Singular noun describing one value, used in error messages (defaults to `"color"`).
|
|
24
24
|
* @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Color"`).
|
|
25
25
|
* @param options.value Default hex value used when the input is `undefined` (defaults to `"#000000"`).
|
|
26
|
+
* @param options.input HTML `<input />` `type=""` hint (defaults to `"color"`).
|
|
27
|
+
* @param options.max Maximum allowed character length (defaults to `7`).
|
|
26
28
|
*/
|
|
27
|
-
constructor({ one, title, value, ...options }: ColorSchemaOptions);
|
|
29
|
+
constructor({ one, title, value, input, max, ...options }: ColorSchemaOptions);
|
|
28
30
|
/**
|
|
29
31
|
* Sanitize the string into a `#RRGGBB` hex color.
|
|
30
32
|
*
|
package/schema/ColorSchema.js
CHANGED
|
@@ -15,20 +15,22 @@ export class ColorSchema extends StringSchema {
|
|
|
15
15
|
/**
|
|
16
16
|
* Create a new `ColorSchema`.
|
|
17
17
|
*
|
|
18
|
-
* @param options Options for the schema (inherits `StringSchema` options except `
|
|
18
|
+
* @param options Options for the schema (inherits `StringSchema` options except `min`, `match`, and `rows`, which are fixed for hex colors).
|
|
19
19
|
* @param options.one Singular noun describing one value, used in error messages (defaults to `"color"`).
|
|
20
20
|
* @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Color"`).
|
|
21
21
|
* @param options.value Default hex value used when the input is `undefined` (defaults to `"#000000"`).
|
|
22
|
+
* @param options.input HTML `<input />` `type=""` hint (defaults to `"color"`).
|
|
23
|
+
* @param options.max Maximum allowed character length (defaults to `7`).
|
|
22
24
|
*/
|
|
23
|
-
constructor({ one = "color", title = "Color", value = "#000000", ...options }) {
|
|
25
|
+
constructor({ one = "color", title = "Color", value = "#000000", input = "color", max = 7, ...options }) {
|
|
24
26
|
super({
|
|
25
27
|
one,
|
|
26
28
|
title,
|
|
27
29
|
value,
|
|
28
30
|
...options,
|
|
29
|
-
input
|
|
31
|
+
input,
|
|
32
|
+
max,
|
|
30
33
|
min: 1,
|
|
31
|
-
max: 7,
|
|
32
34
|
rows: 1,
|
|
33
35
|
match: COLOR_REGEXP,
|
|
34
36
|
});
|
|
@@ -9,7 +9,7 @@ import { StringSchema } from "./StringSchema.js";
|
|
|
9
9
|
*
|
|
10
10
|
* @see https://dhoulb.github.io/shelving/schema/CurrencyCodeSchema/CurrencyCodeSchemaOptions
|
|
11
11
|
*/
|
|
12
|
-
export interface CurrencyCodeSchemaOptions extends Omit<StringSchemaOptions, "
|
|
12
|
+
export interface CurrencyCodeSchemaOptions extends Omit<StringSchemaOptions, "min" | "match" | "rows"> {
|
|
13
13
|
currencies?: ImmutableArray<CurrencyCode>;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
@@ -32,11 +32,11 @@ export declare class CurrencyCodeSchema extends StringSchema {
|
|
|
32
32
|
/**
|
|
33
33
|
* Create a new `CurrencyCodeSchema`.
|
|
34
34
|
*
|
|
35
|
-
* @param options Options for the schema (`currencies`, plus base `StringSchemaOptions` except `
|
|
35
|
+
* @param options Options for the schema (`currencies`, plus base `StringSchemaOptions` except `min`/`match`/`rows`).
|
|
36
36
|
* @example new CurrencyCodeSchema({ currencies: ["GBP", "USD"] })
|
|
37
37
|
* @see https://dhoulb.github.io/shelving/schema/CurrencyCodeSchema/CurrencyCodeSchema
|
|
38
38
|
*/
|
|
39
|
-
constructor({ one, title, currencies, ...options }: CurrencyCodeSchemaOptions);
|
|
39
|
+
constructor({ one, title, currencies, max, ...options }: CurrencyCodeSchemaOptions);
|
|
40
40
|
/**
|
|
41
41
|
* Sanitize an input string down to uppercase `A-Z` letters.
|
|
42
42
|
*
|
|
@@ -21,17 +21,17 @@ export class CurrencyCodeSchema extends StringSchema {
|
|
|
21
21
|
/**
|
|
22
22
|
* Create a new `CurrencyCodeSchema`.
|
|
23
23
|
*
|
|
24
|
-
* @param options Options for the schema (`currencies`, plus base `StringSchemaOptions` except `
|
|
24
|
+
* @param options Options for the schema (`currencies`, plus base `StringSchemaOptions` except `min`/`match`/`rows`).
|
|
25
25
|
* @example new CurrencyCodeSchema({ currencies: ["GBP", "USD"] })
|
|
26
26
|
* @see https://dhoulb.github.io/shelving/schema/CurrencyCodeSchema/CurrencyCodeSchema
|
|
27
27
|
*/
|
|
28
|
-
constructor({ one = "currency", title = "Currency", currencies = CURRENCY_CODES, ...options }) {
|
|
28
|
+
constructor({ one = "currency", title = "Currency", currencies = CURRENCY_CODES, max = 3, ...options }) {
|
|
29
29
|
super({
|
|
30
30
|
one,
|
|
31
31
|
title,
|
|
32
32
|
...options,
|
|
33
|
+
max, // Valid currency code is 3 uppercase letters.
|
|
33
34
|
min: 3,
|
|
34
|
-
max: 3, // Valid currency code is 3 uppercase letters.
|
|
35
35
|
rows: 1,
|
|
36
36
|
case: "upper",
|
|
37
37
|
match: /^[A-Z]{3}$/, // Valid currency code is 3 uppercase letters.
|
package/schema/EmailSchema.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { StringSchemaOptions } from "./StringSchema.js";
|
|
2
2
|
import { StringSchema } from "./StringSchema.js";
|
|
3
|
+
/**
|
|
4
|
+
* Options for an `EmailSchema`.
|
|
5
|
+
*
|
|
6
|
+
* @see https://dhoulb.github.io/shelving/schema/EmailSchema/EmailSchemaOptions
|
|
7
|
+
*/
|
|
8
|
+
export interface EmailSchemaOptions extends Omit<StringSchemaOptions, "min" | "match" | "rows"> {
|
|
9
|
+
}
|
|
3
10
|
/**
|
|
4
11
|
* Schema that defines a valid email address.
|
|
5
12
|
*
|
|
@@ -24,11 +31,13 @@ export declare class EmailSchema extends StringSchema {
|
|
|
24
31
|
/**
|
|
25
32
|
* Create a new `EmailSchema`.
|
|
26
33
|
*
|
|
27
|
-
* @param options Options for the schema (inherits `StringSchema` options except `
|
|
34
|
+
* @param options Options for the schema (inherits `StringSchema` options except `min`, `match`, and `rows`, which are fixed for emails).
|
|
28
35
|
* @param options.one Singular noun describing one value, used in error messages (defaults to `"email address"`).
|
|
29
36
|
* @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Email"`).
|
|
37
|
+
* @param options.input HTML `<input />` `type=""` hint (defaults to `"email"`).
|
|
38
|
+
* @param options.max Maximum allowed character length (defaults to `254`).
|
|
30
39
|
*/
|
|
31
|
-
constructor({ one, title, ...options }:
|
|
40
|
+
constructor({ one, title, input, max, ...options }: EmailSchemaOptions);
|
|
32
41
|
/**
|
|
33
42
|
* Sanitize the string into a valid email address.
|
|
34
43
|
*
|
package/schema/EmailSchema.js
CHANGED
|
@@ -26,18 +26,20 @@ export class EmailSchema extends StringSchema {
|
|
|
26
26
|
/**
|
|
27
27
|
* Create a new `EmailSchema`.
|
|
28
28
|
*
|
|
29
|
-
* @param options Options for the schema (inherits `StringSchema` options except `
|
|
29
|
+
* @param options Options for the schema (inherits `StringSchema` options except `min`, `match`, and `rows`, which are fixed for emails).
|
|
30
30
|
* @param options.one Singular noun describing one value, used in error messages (defaults to `"email address"`).
|
|
31
31
|
* @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Email"`).
|
|
32
|
+
* @param options.input HTML `<input />` `type=""` hint (defaults to `"email"`).
|
|
33
|
+
* @param options.max Maximum allowed character length (defaults to `254`).
|
|
32
34
|
*/
|
|
33
|
-
constructor({ one = "email address", title = "Email", ...options }) {
|
|
35
|
+
constructor({ one = "email address", title = "Email", input = "email", max = 254, ...options }) {
|
|
34
36
|
super({
|
|
35
37
|
one,
|
|
36
38
|
title,
|
|
37
39
|
...options,
|
|
38
|
-
input
|
|
40
|
+
input,
|
|
41
|
+
max,
|
|
39
42
|
min: 1,
|
|
40
|
-
max: 254,
|
|
41
43
|
rows: 1,
|
|
42
44
|
match: R_MATCH,
|
|
43
45
|
});
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import { StringSchema, type StringSchemaOptions } from "./StringSchema.js";
|
|
2
|
-
/**
|
|
3
|
-
* Options for a `PasswordSchema`.
|
|
4
|
-
*
|
|
5
|
-
* @see https://dhoulb.github.io/shelving/schema/PasswordSchema/PasswordSchemaOptions
|
|
6
|
-
*/
|
|
7
|
-
export interface PasswordSchemaOptions extends Omit<StringSchemaOptions, "input"> {
|
|
8
|
-
}
|
|
9
2
|
/**
|
|
10
3
|
* Schema that defines a valid password string.
|
|
11
4
|
*
|
|
12
|
-
* -
|
|
5
|
+
* - Defaults the `<input />` hint to `"password"`, but a caller can override it (e.g. `"text"` for a show-password toggle).
|
|
13
6
|
* - Never formats the value for display (`format()` always returns `""`).
|
|
14
7
|
*
|
|
15
8
|
* @example new PasswordSchema({}).validate("hunter2"); // Returns "hunter2"
|
|
@@ -19,12 +12,13 @@ export declare class PasswordSchema extends StringSchema {
|
|
|
19
12
|
/**
|
|
20
13
|
* Create a new `PasswordSchema`.
|
|
21
14
|
*
|
|
22
|
-
* @param options Options for the schema (inherits `StringSchema` options
|
|
15
|
+
* @param options Options for the schema (inherits all `StringSchema` options).
|
|
23
16
|
* @param options.one Singular noun describing one value, used in error messages (defaults to `"password"`).
|
|
24
17
|
* @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Password"`).
|
|
25
18
|
* @param options.min Minimum allowed character length (defaults to `6`).
|
|
19
|
+
* @param options.input HTML `<input />` `type=""` hint (defaults to `"password"`).
|
|
26
20
|
*/
|
|
27
|
-
constructor({ one, title, min, ...options }?:
|
|
21
|
+
constructor({ one, title, min, input, ...options }?: StringSchemaOptions);
|
|
28
22
|
/**
|
|
29
23
|
* Format a password value for display (always returns `""`).
|
|
30
24
|
*
|
|
@@ -37,9 +31,9 @@ export declare class PasswordSchema extends StringSchema {
|
|
|
37
31
|
format(): string;
|
|
38
32
|
}
|
|
39
33
|
/**
|
|
40
|
-
* Sugar instance of [`
|
|
34
|
+
* Sugar instance of [`PasswordSchema`](/schema/PasswordSchema) for a password string. Equivalent to `new PasswordSchema({})`.
|
|
41
35
|
*
|
|
42
36
|
* @example PASSWORD.validate("hunter2"); // Returns "hunter2"
|
|
43
37
|
* @see https://dhoulb.github.io/shelving/schema/PasswordSchema/PASSWORD
|
|
44
38
|
*/
|
|
45
|
-
export declare const PASSWORD:
|
|
39
|
+
export declare const PASSWORD: PasswordSchema;
|
package/schema/PasswordSchema.js
CHANGED
|
@@ -2,7 +2,7 @@ import { StringSchema } from "./StringSchema.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Schema that defines a valid password string.
|
|
4
4
|
*
|
|
5
|
-
* -
|
|
5
|
+
* - Defaults the `<input />` hint to `"password"`, but a caller can override it (e.g. `"text"` for a show-password toggle).
|
|
6
6
|
* - Never formats the value for display (`format()` always returns `""`).
|
|
7
7
|
*
|
|
8
8
|
* @example new PasswordSchema({}).validate("hunter2"); // Returns "hunter2"
|
|
@@ -12,13 +12,14 @@ export class PasswordSchema extends StringSchema {
|
|
|
12
12
|
/**
|
|
13
13
|
* Create a new `PasswordSchema`.
|
|
14
14
|
*
|
|
15
|
-
* @param options Options for the schema (inherits `StringSchema` options
|
|
15
|
+
* @param options Options for the schema (inherits all `StringSchema` options).
|
|
16
16
|
* @param options.one Singular noun describing one value, used in error messages (defaults to `"password"`).
|
|
17
17
|
* @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Password"`).
|
|
18
18
|
* @param options.min Minimum allowed character length (defaults to `6`).
|
|
19
|
+
* @param options.input HTML `<input />` `type=""` hint (defaults to `"password"`).
|
|
19
20
|
*/
|
|
20
|
-
constructor({ one = "password", title = "Password", min = 6, ...options } = {}) {
|
|
21
|
-
super({ one, title, min, ...options
|
|
21
|
+
constructor({ one = "password", title = "Password", min = 6, input = "password", ...options } = {}) {
|
|
22
|
+
super({ one, title, min, input, ...options });
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* Format a password value for display (always returns `""`).
|
|
@@ -34,9 +35,9 @@ export class PasswordSchema extends StringSchema {
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
|
-
* Sugar instance of [`
|
|
38
|
+
* Sugar instance of [`PasswordSchema`](/schema/PasswordSchema) for a password string. Equivalent to `new PasswordSchema({})`.
|
|
38
39
|
*
|
|
39
40
|
* @example PASSWORD.validate("hunter2"); // Returns "hunter2"
|
|
40
41
|
* @see https://dhoulb.github.io/shelving/schema/PasswordSchema/PASSWORD
|
|
41
42
|
*/
|
|
42
|
-
export const PASSWORD = new
|
|
43
|
+
export const PASSWORD = new PasswordSchema({});
|
package/schema/PhoneSchema.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { StringSchema } from "./StringSchema.js";
|
|
|
5
5
|
*
|
|
6
6
|
* @see https://dhoulb.github.io/shelving/schema/PhoneSchema/PhoneSchemaOptions
|
|
7
7
|
*/
|
|
8
|
-
export interface PhoneSchemaOptions extends Omit<StringSchemaOptions, "
|
|
8
|
+
export interface PhoneSchemaOptions extends Omit<StringSchemaOptions, "min" | "match" | "rows"> {
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Schema that defines a valid phone number.
|
|
@@ -20,11 +20,13 @@ export declare class PhoneSchema extends StringSchema {
|
|
|
20
20
|
/**
|
|
21
21
|
* Create a new `PhoneSchema`.
|
|
22
22
|
*
|
|
23
|
-
* @param options Options for the schema (inherits `StringSchema` options except `
|
|
23
|
+
* @param options Options for the schema (inherits `StringSchema` options except `min`, `match`, and `rows`, which are fixed for phone numbers).
|
|
24
24
|
* @param options.one Singular noun describing one value, used in error messages (defaults to `"phone number"`).
|
|
25
25
|
* @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Phone"`).
|
|
26
|
+
* @param options.input HTML `<input />` `type=""` hint (defaults to `"tel"`).
|
|
27
|
+
* @param options.max Maximum allowed character length (defaults to `16`).
|
|
26
28
|
*/
|
|
27
|
-
constructor({ one, title, ...options }: PhoneSchemaOptions);
|
|
29
|
+
constructor({ one, title, input, max, ...options }: PhoneSchemaOptions);
|
|
28
30
|
/**
|
|
29
31
|
* Sanitize the string into a valid E.164 phone number.
|
|
30
32
|
*
|
package/schema/PhoneSchema.js
CHANGED
|
@@ -13,19 +13,21 @@ export class PhoneSchema extends StringSchema {
|
|
|
13
13
|
/**
|
|
14
14
|
* Create a new `PhoneSchema`.
|
|
15
15
|
*
|
|
16
|
-
* @param options Options for the schema (inherits `StringSchema` options except `
|
|
16
|
+
* @param options Options for the schema (inherits `StringSchema` options except `min`, `match`, and `rows`, which are fixed for phone numbers).
|
|
17
17
|
* @param options.one Singular noun describing one value, used in error messages (defaults to `"phone number"`).
|
|
18
18
|
* @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Phone"`).
|
|
19
|
+
* @param options.input HTML `<input />` `type=""` hint (defaults to `"tel"`).
|
|
20
|
+
* @param options.max Maximum allowed character length (defaults to `16`).
|
|
19
21
|
*/
|
|
20
|
-
constructor({ one = "phone number", title = "Phone", ...options }) {
|
|
22
|
+
constructor({ one = "phone number", title = "Phone", input = "tel", max = 16, ...options }) {
|
|
21
23
|
super({
|
|
22
24
|
one,
|
|
23
25
|
title,
|
|
24
26
|
...options,
|
|
25
|
-
input
|
|
26
|
-
min: 1,
|
|
27
|
+
input,
|
|
27
28
|
// Valid phone number is 16 digits or fewer (15 numerals with a leading `+` plus).
|
|
28
|
-
max
|
|
29
|
+
max,
|
|
30
|
+
min: 1,
|
|
29
31
|
rows: 1,
|
|
30
32
|
// Valid phone number is max 16 digits made up of:
|
|
31
33
|
// - Country code (`+` plus character and 1-3 digits, e.g. `+44` or `+1`).
|
package/schema/SlugSchema.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { StringSchema, type StringSchemaOptions } from "./StringSchema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for a `SlugSchema`.
|
|
4
|
+
*
|
|
5
|
+
* @see https://dhoulb.github.io/shelving/schema/SlugSchema/SlugSchemaOptions
|
|
6
|
+
*/
|
|
7
|
+
export interface SlugSchemaOptions extends Omit<StringSchemaOptions, "min" | "rows"> {
|
|
8
|
+
}
|
|
2
9
|
/**
|
|
3
10
|
* Schema that defines a valid slug, e.g. `this-is-a-slug`.
|
|
4
11
|
*
|
|
@@ -17,7 +24,7 @@ export declare class SlugSchema extends StringSchema {
|
|
|
17
24
|
*
|
|
18
25
|
* @param options Options for the schema (inherited string options like `one`, `title`, `value`).
|
|
19
26
|
*/
|
|
20
|
-
constructor(
|
|
27
|
+
constructor({ max, ...options }: SlugSchemaOptions);
|
|
21
28
|
/**
|
|
22
29
|
* Sanitize a string before validation by converting it into a slug.
|
|
23
30
|
*
|
package/schema/SlugSchema.js
CHANGED
|
@@ -19,11 +19,11 @@ export class SlugSchema extends StringSchema {
|
|
|
19
19
|
*
|
|
20
20
|
* @param options Options for the schema (inherited string options like `one`, `title`, `value`).
|
|
21
21
|
*/
|
|
22
|
-
constructor(options) {
|
|
22
|
+
constructor({ max = 32, ...options }) {
|
|
23
23
|
super({
|
|
24
24
|
...options,
|
|
25
|
+
max,
|
|
25
26
|
min: 1,
|
|
26
|
-
max: 32,
|
|
27
27
|
rows: 1,
|
|
28
28
|
});
|
|
29
29
|
}
|
package/schema/URISchema.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { StringSchema } from "./StringSchema.js";
|
|
|
8
8
|
*
|
|
9
9
|
* @see https://dhoulb.github.io/shelving/schema/URISchema/URISchemaOptions
|
|
10
10
|
*/
|
|
11
|
-
export interface URISchemaOptions extends Omit<StringSchemaOptions, "
|
|
11
|
+
export interface URISchemaOptions extends Omit<StringSchemaOptions, "min" | "rows"> {
|
|
12
12
|
readonly schemes?: URISchemes | undefined;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
@@ -28,9 +28,11 @@ export declare class URISchema extends StringSchema {
|
|
|
28
28
|
/**
|
|
29
29
|
* Create a new `URISchema`.
|
|
30
30
|
*
|
|
31
|
-
* @param options Options for the schema (`schemes`, plus inherited string options like `one`, `title`, `value`).
|
|
31
|
+
* @param options Options for the schema (`schemes`, plus inherited string options like `one`, `title`, `value`, `input`, `max`).
|
|
32
|
+
* @param options.input HTML `<input />` `type=""` hint (defaults to `"url"`).
|
|
33
|
+
* @param options.max Maximum allowed character length (defaults to `512`).
|
|
32
34
|
*/
|
|
33
|
-
constructor({ one, title, schemes, ...options }: URISchemaOptions);
|
|
35
|
+
constructor({ one, title, schemes, input, max, ...options }: URISchemaOptions);
|
|
34
36
|
/**
|
|
35
37
|
* Validate an unknown input value and return a normalised absolute URI string.
|
|
36
38
|
*
|
package/schema/URISchema.js
CHANGED
|
@@ -20,16 +20,18 @@ export class URISchema extends StringSchema {
|
|
|
20
20
|
/**
|
|
21
21
|
* Create a new `URISchema`.
|
|
22
22
|
*
|
|
23
|
-
* @param options Options for the schema (`schemes`, plus inherited string options like `one`, `title`, `value`).
|
|
23
|
+
* @param options Options for the schema (`schemes`, plus inherited string options like `one`, `title`, `value`, `input`, `max`).
|
|
24
|
+
* @param options.input HTML `<input />` `type=""` hint (defaults to `"url"`).
|
|
25
|
+
* @param options.max Maximum allowed character length (defaults to `512`).
|
|
24
26
|
*/
|
|
25
|
-
constructor({ one = "URI", title = "URI", schemes = HTTP_SCHEMES, ...options }) {
|
|
27
|
+
constructor({ one = "URI", title = "URI", schemes = HTTP_SCHEMES, input = "url", max = 512, ...options }) {
|
|
26
28
|
super({
|
|
27
29
|
one,
|
|
28
30
|
title,
|
|
29
31
|
...options,
|
|
30
|
-
input
|
|
32
|
+
input,
|
|
33
|
+
max,
|
|
31
34
|
min: 1,
|
|
32
|
-
max: 512,
|
|
33
35
|
rows: 1,
|
|
34
36
|
});
|
|
35
37
|
this.schemes = schemes;
|
package/schema/URLSchema.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { StringSchema } from "./StringSchema.js";
|
|
|
10
10
|
*
|
|
11
11
|
* @see https://dhoulb.github.io/shelving/schema/URLSchema/URLSchemaOptions
|
|
12
12
|
*/
|
|
13
|
-
export interface URLSchemaOptions extends Omit<StringSchemaOptions, "
|
|
13
|
+
export interface URLSchemaOptions extends Omit<StringSchemaOptions, "min" | "rows"> {
|
|
14
14
|
readonly base?: URL | URLString | undefined;
|
|
15
15
|
readonly schemes?: URISchemes | undefined;
|
|
16
16
|
}
|
|
@@ -33,9 +33,11 @@ export declare class URLSchema extends StringSchema {
|
|
|
33
33
|
/**
|
|
34
34
|
* Create a new `URLSchema`.
|
|
35
35
|
*
|
|
36
|
-
* @param options Options for the schema (`base`, `schemes`, plus inherited string options like `one`, `title`, `value`).
|
|
36
|
+
* @param options Options for the schema (`base`, `schemes`, plus inherited string options like `one`, `title`, `value`, `input`, `max`).
|
|
37
|
+
* @param options.input HTML `<input />` `type=""` hint (defaults to `"url"`).
|
|
38
|
+
* @param options.max Maximum allowed character length (defaults to `512`).
|
|
37
39
|
*/
|
|
38
|
-
constructor({ one, title, base, schemes, ...options }: URLSchemaOptions);
|
|
40
|
+
constructor({ one, title, base, schemes, input, max, ...options }: URLSchemaOptions);
|
|
39
41
|
/**
|
|
40
42
|
* Validate an unknown input value and return a normalised absolute URL string.
|
|
41
43
|
*
|
package/schema/URLSchema.js
CHANGED
|
@@ -23,16 +23,18 @@ export class URLSchema extends StringSchema {
|
|
|
23
23
|
/**
|
|
24
24
|
* Create a new `URLSchema`.
|
|
25
25
|
*
|
|
26
|
-
* @param options Options for the schema (`base`, `schemes`, plus inherited string options like `one`, `title`, `value`).
|
|
26
|
+
* @param options Options for the schema (`base`, `schemes`, plus inherited string options like `one`, `title`, `value`, `input`, `max`).
|
|
27
|
+
* @param options.input HTML `<input />` `type=""` hint (defaults to `"url"`).
|
|
28
|
+
* @param options.max Maximum allowed character length (defaults to `512`).
|
|
27
29
|
*/
|
|
28
|
-
constructor({ one = "URL", title = "URL", base, schemes = HTTP_SCHEMES, ...options }) {
|
|
30
|
+
constructor({ one = "URL", title = "URL", base, schemes = HTTP_SCHEMES, input = "url", max = 512, ...options }) {
|
|
29
31
|
super({
|
|
30
32
|
one,
|
|
31
33
|
title,
|
|
32
34
|
...options,
|
|
33
|
-
input
|
|
35
|
+
input,
|
|
36
|
+
max,
|
|
34
37
|
min: 1,
|
|
35
|
-
max: 512,
|
|
36
38
|
rows: 1,
|
|
37
39
|
});
|
|
38
40
|
this.base = getURL(base)?.href;
|
package/schema/UUIDSchema.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { StringSchema, type StringSchemaOptions } from "./StringSchema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for a `UUIDSchema`.
|
|
4
|
+
*
|
|
5
|
+
* @see https://dhoulb.github.io/shelving/schema/UUIDSchema/UUIDSchemaOptions
|
|
6
|
+
*/
|
|
7
|
+
export interface UUIDSchemaOptions extends Omit<StringSchemaOptions, "min" | "match" | "rows"> {
|
|
8
|
+
}
|
|
2
9
|
/**
|
|
3
10
|
* Schema that defines a valid UUID string (versions 1-5). Defaults to any-version validation.
|
|
4
11
|
*
|
|
@@ -14,9 +21,10 @@ export declare class UUIDSchema extends StringSchema {
|
|
|
14
21
|
/**
|
|
15
22
|
* Create a new `UUIDSchema`.
|
|
16
23
|
*
|
|
17
|
-
* @param options Options for the schema (inherited string options like `one`, `title`, `value`).
|
|
24
|
+
* @param options Options for the schema (inherited string options like `one`, `title`, `value`, `input`, `max`).
|
|
25
|
+
* @param options.max Maximum allowed character length (defaults to `36`).
|
|
18
26
|
*/
|
|
19
|
-
constructor({ one, title, ...rest }?:
|
|
27
|
+
constructor({ one, title, max, ...rest }?: UUIDSchemaOptions);
|
|
20
28
|
/**
|
|
21
29
|
* Sanitize a string before validation by normalising it into a canonical UUID.
|
|
22
30
|
*
|
package/schema/UUIDSchema.js
CHANGED
|
@@ -16,15 +16,16 @@ export class UUIDSchema extends StringSchema {
|
|
|
16
16
|
/**
|
|
17
17
|
* Create a new `UUIDSchema`.
|
|
18
18
|
*
|
|
19
|
-
* @param options Options for the schema (inherited string options like `one`, `title`, `value`).
|
|
19
|
+
* @param options Options for the schema (inherited string options like `one`, `title`, `value`, `input`, `max`).
|
|
20
|
+
* @param options.max Maximum allowed character length (defaults to `36`).
|
|
20
21
|
*/
|
|
21
|
-
constructor({ one = "UUID", title = "UUID", ...rest } = {}) {
|
|
22
|
+
constructor({ one = "UUID", title = "UUID", max = 36, ...rest } = {}) {
|
|
22
23
|
super({
|
|
23
24
|
one,
|
|
24
25
|
title,
|
|
25
26
|
...rest,
|
|
27
|
+
max, // 36 chars including hyphens (which get stripped by sanitize for appearances).
|
|
26
28
|
min: 32,
|
|
27
|
-
max: 36, // 36 chars including hyphens (which get stripped by sanitize for appearances).
|
|
28
29
|
rows: 1,
|
|
29
30
|
});
|
|
30
31
|
}
|
package/ui/block/Card.js
CHANGED
|
@@ -21,6 +21,6 @@ import CARD_CSS from "./Card.module.css";
|
|
|
21
21
|
* @see https://dhoulb.github.io/shelving/ui/block/Card/Card
|
|
22
22
|
*/
|
|
23
23
|
export function Card({ children, href, onClick, title = "Open", ...props }) {
|
|
24
|
-
const overlay = (href || onClick) && _jsx(Clickable, { title: title, href: href, onClick: onClick, ...props, className: CARD_CSS
|
|
24
|
+
const overlay = (href || onClick) && (_jsx(Clickable, { title: title, href: href, onClick: onClick, ...props, className: getModuleClass(CARD_CSS, "overlay") }));
|
|
25
25
|
return (_jsxs("article", { className: getClass(getModuleClass(CARD_CSS, "card"), getStatusClass(props), getColorClass(props), getPaddingClass(props), getSpaceClass(props), getTypographyClass(props), getWidthClass(props)), children: [overlay, overlay ? _jsx("div", { children: children }) : children] }));
|
|
26
26
|
}
|
package/ui/block/Card.tsx
CHANGED
|
@@ -36,7 +36,9 @@ export interface CardProps
|
|
|
36
36
|
* @see https://dhoulb.github.io/shelving/ui/block/Card/Card
|
|
37
37
|
*/
|
|
38
38
|
export function Card({ children, href, onClick, title = "Open", ...props }: CardProps): ReactElement {
|
|
39
|
-
const overlay = (href || onClick) &&
|
|
39
|
+
const overlay = (href || onClick) && (
|
|
40
|
+
<Clickable title={title} href={href} onClick={onClick} {...props} className={getModuleClass(CARD_CSS, "overlay")} />
|
|
41
|
+
);
|
|
40
42
|
return (
|
|
41
43
|
<article
|
|
42
44
|
className={getClass(
|
package/ui/block/Prose.js
CHANGED
|
@@ -9,7 +9,7 @@ import SMALL_CSS from "../inline/Small.module.css";
|
|
|
9
9
|
import STRONG_CSS from "../inline/Strong.module.css";
|
|
10
10
|
import SUBSCRIPT_CSS from "../inline/Subscript.module.css";
|
|
11
11
|
import SUPERSCRIPT_CSS from "../inline/Superscript.module.css";
|
|
12
|
-
import { getClass } from "../util/css.js";
|
|
12
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
13
13
|
import ADDRESS_CSS from "./Address.module.css";
|
|
14
14
|
import BLOCKQUOTE_CSS from "./Blockquote.module.css";
|
|
15
15
|
import CAPTION_CSS from "./Caption.module.css";
|
|
@@ -25,7 +25,7 @@ import SUBHEADING_CSS from "./Subheading.module.css";
|
|
|
25
25
|
import TABLE_CSS from "./Table.module.css";
|
|
26
26
|
import TITLE_CSS from "./Title.module.css";
|
|
27
27
|
// Combine the `.prose` class from every block and inline component's CSS module into a single string.
|
|
28
|
-
const PROSE_STYLES = getClass(PARAGRAPH_CSS
|
|
28
|
+
const PROSE_STYLES = getClass(getModuleClass(PARAGRAPH_CSS, "prose"), getModuleClass(HEADING_CSS, "prose"), getModuleClass(SUBHEADING_CSS, "prose"), getModuleClass(ADDRESS_CSS, "prose"), getModuleClass(BLOCKQUOTE_CSS, "prose"), getModuleClass(SECTION_CSS, "prose"), getModuleClass(CODE_CSS, "prose"), getModuleClass(DEFINITIONS_CSS, "prose"), getModuleClass(DELETED_CSS, "prose"), getModuleClass(EMPHASIS_CSS, "prose"), getModuleClass(IMAGE_CSS, "prose"), getModuleClass(INSERTED_CSS, "prose"), getModuleClass(CAPTION_CSS, "prose"), getModuleClass(LIST_CSS, "prose"), getModuleClass(TITLE_CSS, "prose"), getModuleClass(LINK_CSS, "prose"), getModuleClass(MARK_CSS, "prose"), getModuleClass(PREFORMATTED_CSS, "prose"), getModuleClass(SMALL_CSS, "prose"), getModuleClass(STRONG_CSS, "prose"), getModuleClass(SUBSCRIPT_CSS, "prose"), getModuleClass(SUPERSCRIPT_CSS, "prose"), getModuleClass(TABLE_CSS, "prose"), getModuleClass(DIVIDER_CSS, "prose"));
|
|
29
29
|
/**
|
|
30
30
|
* A section of longform text containing lots of `<p>` or `<ul>` style elements.
|
|
31
31
|
* - Applies the prose variant of every block and inline component so nested content picks up the right longform spacing and typography.
|
package/ui/block/Prose.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import SMALL_CSS from "../inline/Small.module.css";
|
|
|
9
9
|
import STRONG_CSS from "../inline/Strong.module.css";
|
|
10
10
|
import SUBSCRIPT_CSS from "../inline/Subscript.module.css";
|
|
11
11
|
import SUPERSCRIPT_CSS from "../inline/Superscript.module.css";
|
|
12
|
-
import { getClass } from "../util/css.js";
|
|
12
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
13
13
|
import type { OptionalChildProps } from "../util/props.js";
|
|
14
14
|
import ADDRESS_CSS from "./Address.module.css";
|
|
15
15
|
import BLOCKQUOTE_CSS from "./Blockquote.module.css";
|
|
@@ -28,30 +28,30 @@ import TITLE_CSS from "./Title.module.css";
|
|
|
28
28
|
|
|
29
29
|
// Combine the `.prose` class from every block and inline component's CSS module into a single string.
|
|
30
30
|
const PROSE_STYLES = getClass(
|
|
31
|
-
PARAGRAPH_CSS
|
|
32
|
-
HEADING_CSS
|
|
33
|
-
SUBHEADING_CSS
|
|
34
|
-
ADDRESS_CSS
|
|
35
|
-
BLOCKQUOTE_CSS
|
|
36
|
-
SECTION_CSS
|
|
37
|
-
CODE_CSS
|
|
38
|
-
DEFINITIONS_CSS
|
|
39
|
-
DELETED_CSS
|
|
40
|
-
EMPHASIS_CSS
|
|
41
|
-
IMAGE_CSS
|
|
42
|
-
INSERTED_CSS
|
|
43
|
-
CAPTION_CSS
|
|
44
|
-
LIST_CSS
|
|
45
|
-
TITLE_CSS
|
|
46
|
-
LINK_CSS
|
|
47
|
-
MARK_CSS
|
|
48
|
-
PREFORMATTED_CSS
|
|
49
|
-
SMALL_CSS
|
|
50
|
-
STRONG_CSS
|
|
51
|
-
SUBSCRIPT_CSS
|
|
52
|
-
SUPERSCRIPT_CSS
|
|
53
|
-
TABLE_CSS
|
|
54
|
-
DIVIDER_CSS
|
|
31
|
+
getModuleClass(PARAGRAPH_CSS, "prose"),
|
|
32
|
+
getModuleClass(HEADING_CSS, "prose"),
|
|
33
|
+
getModuleClass(SUBHEADING_CSS, "prose"),
|
|
34
|
+
getModuleClass(ADDRESS_CSS, "prose"),
|
|
35
|
+
getModuleClass(BLOCKQUOTE_CSS, "prose"),
|
|
36
|
+
getModuleClass(SECTION_CSS, "prose"),
|
|
37
|
+
getModuleClass(CODE_CSS, "prose"),
|
|
38
|
+
getModuleClass(DEFINITIONS_CSS, "prose"),
|
|
39
|
+
getModuleClass(DELETED_CSS, "prose"),
|
|
40
|
+
getModuleClass(EMPHASIS_CSS, "prose"),
|
|
41
|
+
getModuleClass(IMAGE_CSS, "prose"),
|
|
42
|
+
getModuleClass(INSERTED_CSS, "prose"),
|
|
43
|
+
getModuleClass(CAPTION_CSS, "prose"),
|
|
44
|
+
getModuleClass(LIST_CSS, "prose"),
|
|
45
|
+
getModuleClass(TITLE_CSS, "prose"),
|
|
46
|
+
getModuleClass(LINK_CSS, "prose"),
|
|
47
|
+
getModuleClass(MARK_CSS, "prose"),
|
|
48
|
+
getModuleClass(PREFORMATTED_CSS, "prose"),
|
|
49
|
+
getModuleClass(SMALL_CSS, "prose"),
|
|
50
|
+
getModuleClass(STRONG_CSS, "prose"),
|
|
51
|
+
getModuleClass(SUBSCRIPT_CSS, "prose"),
|
|
52
|
+
getModuleClass(SUPERSCRIPT_CSS, "prose"),
|
|
53
|
+
getModuleClass(TABLE_CSS, "prose"),
|
|
54
|
+
getModuleClass(DIVIDER_CSS, "prose"),
|
|
55
55
|
);
|
|
56
56
|
|
|
57
57
|
/**
|
package/ui/block/Table.d.ts
CHANGED
|
@@ -2,13 +2,14 @@ import type { ReactElement } from "react";
|
|
|
2
2
|
import { type ColorVariants } from "../style/Color.js";
|
|
3
3
|
import { type SpaceVariants } from "../style/Space.js";
|
|
4
4
|
import { type TypographyVariants } from "../style/Typography.js";
|
|
5
|
+
import { type WidthVariants } from "../style/Width.js";
|
|
5
6
|
import type { ChildProps } from "../util/props.js";
|
|
6
7
|
/**
|
|
7
|
-
* Props for `Table` — colour, space, and
|
|
8
|
+
* Props for `Table` — colour, space, typography, and width variants plus `children`.
|
|
8
9
|
*
|
|
9
10
|
* @see https://dhoulb.github.io/shelving/ui/block/Table/TableProps
|
|
10
11
|
*/
|
|
11
|
-
export interface TableProps extends ColorVariants, SpaceVariants, TypographyVariants, ChildProps {
|
|
12
|
+
export interface TableProps extends ColorVariants, SpaceVariants, TypographyVariants, WidthVariants, ChildProps {
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* Table block — rendered as `<table>`.
|
|
@@ -16,7 +17,7 @@ export interface TableProps extends ColorVariants, SpaceVariants, TypographyVari
|
|
|
16
17
|
* - `<th>` / `<td>` cells draw the borders (the `<table>` element itself has none); override their weight via the `--table-border` / `--table-stroke` hooks.
|
|
17
18
|
*
|
|
18
19
|
* @kind component
|
|
19
|
-
* @param props Colour, space, and
|
|
20
|
+
* @param props Colour, space, typography, and width variants plus `children`.
|
|
20
21
|
* @returns Rendered `<table>` element.
|
|
21
22
|
* @example <Table><tbody><tr><td>Cell</td></tr></tbody></Table>
|
|
22
23
|
* @see https://dhoulb.github.io/shelving/ui/block/Table/Table
|