@simplix-react-ui-kits/site-core 0.1.0 → 0.1.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/README.md +4 -3
- package/dist/account/index.d.ts +1 -1
- package/dist/account/index.js +3 -3
- package/dist/action/index.d.ts +59 -3
- package/dist/action/index.js +82 -0
- package/dist/action/index.js.map +1 -1
- package/dist/checkout/index.d.ts +1 -1
- package/dist/checkout/index.js +1 -1
- package/dist/{chunk-BJUU2WTX.js → chunk-EELJOGWB.js} +12 -5
- package/dist/chunk-EELJOGWB.js.map +1 -0
- package/dist/{chunk-7K476KMZ.js → chunk-EOTYGKKM.js} +3 -3
- package/dist/{chunk-7K476KMZ.js.map → chunk-EOTYGKKM.js.map} +1 -1
- package/dist/{chunk-FKC262N4.js → chunk-EWBTUSZY.js} +9 -3
- package/dist/chunk-EWBTUSZY.js.map +1 -0
- package/dist/{chunk-5TFLOQT6.js → chunk-HRRP6HMF.js} +10 -5
- package/dist/chunk-HRRP6HMF.js.map +1 -0
- package/dist/{chunk-4KFQ26JW.js → chunk-HZGBIIGN.js} +27 -6
- package/dist/chunk-HZGBIIGN.js.map +1 -0
- package/dist/{chunk-JJQJFRBI.js → chunk-OWQVRM4W.js} +3 -3
- package/dist/{chunk-JJQJFRBI.js.map → chunk-OWQVRM4W.js.map} +1 -1
- package/dist/{chunk-6S23FFBB.js → chunk-TGG4ZKPG.js} +3 -3
- package/dist/{chunk-6S23FFBB.js.map → chunk-TGG4ZKPG.js.map} +1 -1
- package/dist/{chunk-JVMJF5JJ.js → chunk-UF2MDCWB.js} +5 -5
- package/dist/chunk-UF2MDCWB.js.map +1 -0
- package/dist/{chunk-EG6GE3YS.js → chunk-YXASVWY7.js} +3 -3
- package/dist/{chunk-EG6GE3YS.js.map → chunk-YXASVWY7.js.map} +1 -1
- package/dist/content/index.d.ts +95 -0
- package/dist/content/index.js +85 -0
- package/dist/content/index.js.map +1 -0
- package/dist/form/index.d.ts +229 -8
- package/dist/form/index.js +150 -10
- package/dist/form/index.js.map +1 -1
- package/dist/help/index.d.ts +1 -1
- package/dist/help/index.js +6 -6
- package/dist/install/index.d.ts +1 -1
- package/dist/install/index.js +4 -4
- package/dist/legal/index.d.ts +2 -2
- package/dist/legal/index.js +5 -5
- package/dist/link/index.d.ts +14 -1
- package/dist/link/index.js +8 -1
- package/dist/link/index.js.map +1 -1
- package/dist/marketing/index.d.ts +1 -1
- package/dist/page/index.d.ts +2 -2
- package/dist/page/index.js +4 -4
- package/dist/pricing/index.d.ts +1 -1
- package/dist/pricing/index.js +2 -2
- package/dist/shell/index.d.ts +1 -1
- package/dist/{site-action-B79fuwMb.d.ts → site-action-CPpf8JZl.d.ts} +1 -1
- package/dist/{site-page-Dl0A5T1N.d.ts → site-page-DKcjqh9y.d.ts} +7 -2
- package/package.json +10 -3
- package/src/action/action-tile.style.ts +63 -0
- package/src/action/action-tile.tsx +83 -0
- package/src/action/index.ts +11 -0
- package/src/content/content.style.ts +72 -0
- package/src/content/content.tsx +124 -0
- package/src/content/index.ts +12 -0
- package/src/form/choices.style.ts +16 -0
- package/src/form/choices.tsx +28 -5
- package/src/form/country-field.tsx +61 -0
- package/src/form/date-time.style.ts +26 -0
- package/src/form/date-time.tsx +123 -0
- package/src/form/dialog.style.ts +4 -2
- package/src/form/errors.tsx +16 -4
- package/src/form/form.style.ts +8 -0
- package/src/form/index.ts +11 -1
- package/src/form/phone-field.tsx +98 -0
- package/src/form/select.style.ts +6 -1
- package/src/form/select.tsx +13 -3
- package/src/form/signature.style.ts +20 -0
- package/src/form/signature.tsx +46 -0
- package/src/link/index.ts +1 -0
- package/src/link/mounted-href.ts +16 -0
- package/src/page/site-page.style.ts +13 -4
- package/src/page/site-page.tsx +8 -3
- package/src/styles/designs/base.css +121 -4
- package/templates/app-shell.hbs +5 -4
- package/dist/chunk-4KFQ26JW.js.map +0 -1
- package/dist/chunk-5TFLOQT6.js.map +0 -1
- package/dist/chunk-BJUU2WTX.js.map +0 -1
- package/dist/chunk-FKC262N4.js.map +0 -1
- package/dist/chunk-JVMJF5JJ.js.map +0 -1
- package/src/account/account.test.tsx +0 -186
- package/src/action/site-action.test.tsx +0 -154
- package/src/auth/auth.test.tsx +0 -132
- package/src/checkout/checkout.test.tsx +0 -187
- package/src/form/choices-field.test.tsx +0 -20
- package/src/form/errors.test.tsx +0 -49
- package/src/form/form.test.tsx +0 -275
- package/src/form/question-focus.test.ts +0 -182
- package/src/form/slider.test.tsx +0 -148
- package/src/form/typed-text.test.ts +0 -52
- package/src/help/article.test.tsx +0 -189
- package/src/help/help.test.tsx +0 -215
- package/src/help/screen-sketch.test.tsx +0 -59
- package/src/install/install.test.tsx +0 -177
- package/src/legal/legal.test.tsx +0 -161
- package/src/legal/policy.test.tsx +0 -137
- package/src/legal/refund.test.tsx +0 -148
- package/src/link/routes-in-page.test.ts +0 -26
- package/src/link/site-link.test.ts +0 -10
- package/src/marketing/marketing.test.tsx +0 -221
- package/src/page/site-failure.test.tsx +0 -65
- package/src/page/site-page.test.tsx +0 -109
- package/src/page/site-read.test.tsx +0 -41
- package/src/pricing/pack-card.test.tsx +0 -107
- package/src/pricing/pricing.test.tsx +0 -261
- package/src/shell/refusal-page.test.ts +0 -19
- package/src/shell/site-scheme-param.test.ts +0 -53
- package/src/shell/site-scheme-switch.test.ts +0 -80
- package/src/shell/site-scheme.test.ts +0 -149
- package/src/shell/site-shell.test.tsx +0 -401
- package/src/testing/markup.ts +0 -65
package/dist/page/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { a as SiteBreadcrumb, b as SiteBreadcrumbProps, S as SiteBreadcrumbStep, c as SitePage, d as SitePageHead, e as SitePageHeadProps, f as SitePageProps, g as SiteSection, h as SiteSectionProps } from '../site-page-
|
|
1
|
+
export { a as SiteBreadcrumb, b as SiteBreadcrumbProps, S as SiteBreadcrumbStep, c as SitePage, d as SitePageHead, e as SitePageHeadProps, f as SitePageProps, g as SiteSection, h as SiteSectionProps } from '../site-page-DKcjqh9y.js';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode, MouseEvent } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { e as SiteActionState, S as SiteActionSpec } from '../site-action-CPpf8JZl.js';
|
|
5
5
|
|
|
6
6
|
/** How a {@link SiteChip} reads: plain, the accent, or a state that went well, needs care or failed. */
|
|
7
7
|
type SiteChipTone = "neutral" | "accent" | "good" | "warn" | "bad" | "voice";
|
package/dist/page/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { SiteBreadcrumb, SitePage, SitePageHead, SiteSection } from '../chunk-
|
|
2
|
-
import { SiteCaption } from '../chunk-
|
|
3
|
-
export { SiteBadge, SiteCaption, SiteChip, SiteLive, SiteSpinner, SiteTextAction } from '../chunk-
|
|
4
|
-
import '../chunk-
|
|
1
|
+
export { SiteBreadcrumb, SitePage, SitePageHead, SiteSection } from '../chunk-UF2MDCWB.js';
|
|
2
|
+
import { SiteCaption } from '../chunk-EOTYGKKM.js';
|
|
3
|
+
export { SiteBadge, SiteCaption, SiteChip, SiteLive, SiteSpinner, SiteTextAction } from '../chunk-EOTYGKKM.js';
|
|
4
|
+
import '../chunk-EELJOGWB.js';
|
|
5
5
|
import { SiteAction } from '../chunk-47HQIB4J.js';
|
|
6
6
|
import '../chunk-MR5ZALXA.js';
|
|
7
7
|
import { defineSlotStyle, slotAttributes } from '@simplix-react/ui/design';
|
package/dist/pricing/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { S as SiteActionSpec,
|
|
3
|
+
import { S as SiteActionSpec, a as SiteReason } from '../site-action-CPpf8JZl.js';
|
|
4
4
|
|
|
5
5
|
/** Props for {@link OfferRow}. */
|
|
6
6
|
interface OfferRowProps {
|
package/dist/pricing/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { QuotaMeter } from '../chunk-
|
|
1
|
+
import { QuotaMeter } from '../chunk-OWQVRM4W.js';
|
|
2
2
|
import { siteSpacerStyle } from '../chunk-6T2QH62E.js';
|
|
3
3
|
import { radioKeyTarget } from '../chunk-J2R7XPUR.js';
|
|
4
|
-
import { siteCaptionStyle, SITE_CARD, siteSectionHeadingStyle, siteSectionLedeStyle } from '../chunk-
|
|
4
|
+
import { siteCaptionStyle, SITE_CARD, siteSectionHeadingStyle, siteSectionLedeStyle } from '../chunk-EELJOGWB.js';
|
|
5
5
|
import { SiteAction } from '../chunk-47HQIB4J.js';
|
|
6
6
|
import '../chunk-MR5ZALXA.js';
|
|
7
7
|
import { useId, useRef } from 'react';
|
package/dist/shell/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, RefObject, MouseEvent, ComponentType } from 'react';
|
|
3
3
|
import { a as SiteLinkComponent } from '../site-link-BitGv4gj.js';
|
|
4
|
-
import { S as SiteActionSpec } from '../site-action-
|
|
4
|
+
import { S as SiteActionSpec } from '../site-action-CPpf8JZl.js';
|
|
5
5
|
|
|
6
6
|
/** Props for {@link SiteWindow}. */
|
|
7
7
|
interface SiteWindowProps {
|
|
@@ -104,4 +104,4 @@ declare function useRefusal(disabled: boolean, reason: SiteReason | undefined, d
|
|
|
104
104
|
*/
|
|
105
105
|
declare function SiteAction({ id, label, href, onSelect, tone, disabled: refused, reason: refusedFor, pending, icon, pressed, name, describedBy, size, block, submit, narrow, elementId, field }: SiteActionProps): react.JSX.Element;
|
|
106
106
|
|
|
107
|
-
export { type SiteActionSpec as S,
|
|
107
|
+
export { type SiteActionSpec as S, type SiteReason as a, SiteAction as b, type SiteActionBase as c, type SiteActionProps as d, type SiteActionState as e, type SiteActionTone as f, type SiteRefusal as g, useRefusal as u };
|
|
@@ -9,10 +9,15 @@ interface SitePageProps {
|
|
|
9
9
|
* centres a page that says a step is finished; `page` is every other page.
|
|
10
10
|
*/
|
|
11
11
|
readonly rhythm?: "page" | "spaced" | "open" | "steps" | "done";
|
|
12
|
+
/**
|
|
13
|
+
* How wide the column grows: `wide` for a page of sections, `medium` or `narrow` for a page that
|
|
14
|
+
* stays one column of fields or rows on every window (a form, a flow made for a phone).
|
|
15
|
+
*/
|
|
16
|
+
readonly width?: "wide" | "medium" | "narrow";
|
|
12
17
|
readonly children: ReactNode;
|
|
13
18
|
}
|
|
14
|
-
/** The page column: centred, as wide as the wide tier
|
|
15
|
-
declare function SitePage({ rhythm, children }: SitePageProps): react.JSX.Element;
|
|
19
|
+
/** The page column: centred, as wide as its tier at most (the wide tier unless told), its regions one gap apart. */
|
|
20
|
+
declare function SitePage({ rhythm, width, children }: SitePageProps): react.JSX.Element;
|
|
16
21
|
/** Props for {@link SitePageHead}. */
|
|
17
22
|
interface SitePageHeadProps {
|
|
18
23
|
readonly title: ReactNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplix-react-ui-kits/site-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Web site UI kit parts shared by every site design: the site shell, page column and pricing parts, each element marked with the slot a design draws",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -35,6 +35,11 @@
|
|
|
35
35
|
"types": "./src/checkout/index.ts",
|
|
36
36
|
"import": "./dist/checkout/index.js"
|
|
37
37
|
},
|
|
38
|
+
"./content": {
|
|
39
|
+
"source": "./src/content/index.ts",
|
|
40
|
+
"types": "./src/content/index.ts",
|
|
41
|
+
"import": "./dist/content/index.js"
|
|
42
|
+
},
|
|
38
43
|
"./form": {
|
|
39
44
|
"source": "./src/form/index.ts",
|
|
40
45
|
"types": "./src/form/index.ts",
|
|
@@ -90,10 +95,12 @@
|
|
|
90
95
|
"src",
|
|
91
96
|
"templates",
|
|
92
97
|
"scripts",
|
|
93
|
-
"regions.json"
|
|
98
|
+
"regions.json",
|
|
99
|
+
"!src/**/__tests__",
|
|
100
|
+
"!src/testing"
|
|
94
101
|
],
|
|
95
102
|
"dependencies": {
|
|
96
|
-
"simplix-react": "0.3.
|
|
103
|
+
"simplix-react": "0.3.13"
|
|
97
104
|
},
|
|
98
105
|
"peerDependencies": {
|
|
99
106
|
"react": ">=18.0.0",
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { defineSlotStyle } from "@simplix-react/ui/design";
|
|
2
|
+
|
|
3
|
+
/** Tiles one under the other. */
|
|
4
|
+
export const siteActionTilesStyle = defineSlotStyle({
|
|
5
|
+
slot: "site-action-tiles",
|
|
6
|
+
base: "flex min-w-0 flex-col gap-2.5",
|
|
7
|
+
variants: {},
|
|
8
|
+
defaultVariants: {},
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/** A choice that goes on at once, pressed as a whole: on the accent's soft ground once it was made. */
|
|
12
|
+
export const siteActionTileStyle = defineSlotStyle({
|
|
13
|
+
slot: "site-action-tile",
|
|
14
|
+
base:
|
|
15
|
+
"flex w-full min-w-0 cursor-pointer items-center gap-3 rounded-(--site-radius-lg) border px-3.5 py-3 text-left font-(family-name:--site-font-sans) text-(--site-ink) outline-none transition-colors duration-(--site-duration-fast) ease-(--site-ease) focus-visible:shadow-[var(--site-focus-ring)] disabled:cursor-not-allowed disabled:opacity-(--site-dim)",
|
|
16
|
+
variants: {
|
|
17
|
+
pressed: {
|
|
18
|
+
true: "border-(--site-accent) bg-(--site-accent-soft)",
|
|
19
|
+
false: "border-(--site-line) bg-(--site-surface) hover:border-(--site-control-line)",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: { pressed: false },
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
/** The glyph before a tile's words. */
|
|
26
|
+
export const siteActionTileIconStyle = defineSlotStyle({
|
|
27
|
+
slot: "site-action-tile-icon",
|
|
28
|
+
base: "inline-grid shrink-0 place-items-center text-(--site-accent-text) [&_svg]:size-6",
|
|
29
|
+
variants: {},
|
|
30
|
+
defaultVariants: {},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/** A tile's title over what it is for. */
|
|
34
|
+
export const siteActionTileWordsStyle = defineSlotStyle({
|
|
35
|
+
slot: "site-action-tile-words",
|
|
36
|
+
base: "flex min-w-0 flex-1 flex-col gap-0.5",
|
|
37
|
+
variants: {},
|
|
38
|
+
defaultVariants: {},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
/** A tile's title. */
|
|
42
|
+
export const siteActionTileTitleStyle = defineSlotStyle({
|
|
43
|
+
slot: "site-action-tile-title",
|
|
44
|
+
base: "min-w-0 text-(length:--site-fs-body-pane) leading-(--site-lh-body-pane) font-(--site-fw-strong)",
|
|
45
|
+
variants: {},
|
|
46
|
+
defaultVariants: {},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/** What a tile is for, muted. */
|
|
50
|
+
export const siteActionTileBodyStyle = defineSlotStyle({
|
|
51
|
+
slot: "site-action-tile-body",
|
|
52
|
+
base: "min-w-0 text-(length:--site-fs-caption) leading-(--site-lh-caption) font-(--site-fw-caption) text-(--site-ink-muted)",
|
|
53
|
+
variants: {},
|
|
54
|
+
defaultVariants: {},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/** The glyph at a tile's end that says it leads on. */
|
|
58
|
+
export const siteActionTileTrailStyle = defineSlotStyle({
|
|
59
|
+
slot: "site-action-tile-trail",
|
|
60
|
+
base: "inline-grid shrink-0 place-items-center text-(--site-ink-muted) [&_svg]:size-5",
|
|
61
|
+
variants: {},
|
|
62
|
+
defaultVariants: {},
|
|
63
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { slotAttributes } from "@simplix-react/ui/design";
|
|
3
|
+
|
|
4
|
+
import { useRefusal, type SiteReason } from "./site-action";
|
|
5
|
+
import {
|
|
6
|
+
siteActionTileBodyStyle,
|
|
7
|
+
siteActionTileIconStyle,
|
|
8
|
+
siteActionTileStyle,
|
|
9
|
+
siteActionTilesStyle,
|
|
10
|
+
siteActionTileTitleStyle,
|
|
11
|
+
siteActionTileTrailStyle,
|
|
12
|
+
siteActionTileWordsStyle,
|
|
13
|
+
} from "./action-tile.style";
|
|
14
|
+
|
|
15
|
+
/** Props for {@link SiteActionTile}. */
|
|
16
|
+
export interface SiteActionTileProps {
|
|
17
|
+
/** A stable name among the tiles of one list. */
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly title: ReactNode;
|
|
20
|
+
/** What the choice is for, under the title. */
|
|
21
|
+
readonly body?: ReactNode;
|
|
22
|
+
/** A glyph before the words, which the product draws. */
|
|
23
|
+
readonly icon?: ReactNode;
|
|
24
|
+
/** The glyph at the end that says the tile leads on (a chevron), which the product draws. */
|
|
25
|
+
readonly trail?: ReactNode;
|
|
26
|
+
readonly onSelect: () => void;
|
|
27
|
+
/** The choice was made on an earlier pass through the step: the tile says it is the one. */
|
|
28
|
+
readonly pressed?: boolean;
|
|
29
|
+
/** The tile cannot be pressed now; give `reason` with it. */
|
|
30
|
+
readonly disabled?: boolean;
|
|
31
|
+
/** Why it cannot be pressed now, drawn for a screen reader unless `describedBy` names a line. */
|
|
32
|
+
readonly reason?: SiteReason;
|
|
33
|
+
/** The id of the line on the page that says why the tile waits. */
|
|
34
|
+
readonly describedBy?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A choice that goes on at once: a tile pressed as a whole, with its glyph, its title and what it
|
|
39
|
+
* is for (a kind of visit, whether the host's number is known). A choice held until a later save
|
|
40
|
+
* is a radio card instead.
|
|
41
|
+
*/
|
|
42
|
+
export function SiteActionTile({ id, title, body, icon, trail, onSelect, pressed, disabled = false, reason, describedBy }: SiteActionTileProps) {
|
|
43
|
+
const refusal = useRefusal(disabled, reason, describedBy);
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<button
|
|
47
|
+
{...slotAttributes(siteActionTileStyle, { pressed: pressed === true })}
|
|
48
|
+
data-action={id}
|
|
49
|
+
type="button"
|
|
50
|
+
disabled={disabled}
|
|
51
|
+
aria-pressed={pressed}
|
|
52
|
+
aria-describedby={refusal.describedBy}
|
|
53
|
+
onClick={onSelect}
|
|
54
|
+
>
|
|
55
|
+
{icon !== undefined ? (
|
|
56
|
+
<span {...slotAttributes(siteActionTileIconStyle, {})} aria-hidden="true">
|
|
57
|
+
{icon}
|
|
58
|
+
</span>
|
|
59
|
+
) : null}
|
|
60
|
+
<span {...slotAttributes(siteActionTileWordsStyle, {})}>
|
|
61
|
+
<span {...slotAttributes(siteActionTileTitleStyle, {})}>{title}</span>
|
|
62
|
+
{body !== undefined ? <span {...slotAttributes(siteActionTileBodyStyle, {})}>{body}</span> : null}
|
|
63
|
+
</span>
|
|
64
|
+
{trail !== undefined ? (
|
|
65
|
+
<span {...slotAttributes(siteActionTileTrailStyle, {})} aria-hidden="true">
|
|
66
|
+
{trail}
|
|
67
|
+
</span>
|
|
68
|
+
) : null}
|
|
69
|
+
</button>
|
|
70
|
+
{refusal.hidden}
|
|
71
|
+
</>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Props for {@link SiteActionTiles}. */
|
|
76
|
+
export interface SiteActionTilesProps {
|
|
77
|
+
readonly children: ReactNode;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Tiles one under the other. */
|
|
81
|
+
export function SiteActionTiles({ children }: SiteActionTilesProps) {
|
|
82
|
+
return <div {...slotAttributes(siteActionTilesStyle, {})}>{children}</div>;
|
|
83
|
+
}
|
package/src/action/index.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
export { SiteAction, useRefusal } from "./site-action";
|
|
2
2
|
export type { SiteActionBase, SiteActionProps, SiteActionSpec, SiteActionState, SiteActionTone, SiteReason, SiteRefusal } from "./site-action";
|
|
3
3
|
export { siteActionReasonStyle, siteActionStyle } from "./site-action.style";
|
|
4
|
+
export { SiteActionTile, SiteActionTiles } from "./action-tile";
|
|
5
|
+
export type { SiteActionTileProps, SiteActionTilesProps } from "./action-tile";
|
|
6
|
+
export {
|
|
7
|
+
siteActionTileBodyStyle,
|
|
8
|
+
siteActionTileIconStyle,
|
|
9
|
+
siteActionTileStyle,
|
|
10
|
+
siteActionTilesStyle,
|
|
11
|
+
siteActionTileTitleStyle,
|
|
12
|
+
siteActionTileTrailStyle,
|
|
13
|
+
siteActionTileWordsStyle,
|
|
14
|
+
} from "./action-tile.style";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { defineSlotStyle } from "@simplix-react/ui/design";
|
|
2
|
+
|
|
3
|
+
/** A formatted body a person wrote (the words of a document, a course's description), in the reading size. */
|
|
4
|
+
export const siteContentBodyStyle = defineSlotStyle({
|
|
5
|
+
slot: "site-content-body",
|
|
6
|
+
base: "min-w-0 text-(length:--site-fs-notes) leading-(--site-lh-notes) font-(--site-fw-base) text-(--site-ink)",
|
|
7
|
+
variants: {},
|
|
8
|
+
defaultVariants: {},
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/** A frame a long body scrolls inside: `sm` holds a notice of a few paragraphs, `md` a document. */
|
|
12
|
+
export const siteScrollFrameStyle = defineSlotStyle({
|
|
13
|
+
slot: "site-scroll-frame",
|
|
14
|
+
base:
|
|
15
|
+
"min-w-0 overflow-y-auto rounded-(--site-radius-md) border border-(--site-line) bg-(--site-surface) px-3 py-2.5 outline-none focus-visible:shadow-[var(--site-focus-ring)]",
|
|
16
|
+
variants: {
|
|
17
|
+
size: {
|
|
18
|
+
sm: "max-h-60",
|
|
19
|
+
md: "max-h-80",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: { size: "md" },
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
/** The frame of a video or an embedded page. */
|
|
26
|
+
export const siteMediaStyle = defineSlotStyle({
|
|
27
|
+
slot: "site-media",
|
|
28
|
+
base: "min-w-0 overflow-hidden rounded-(--site-radius-md) border border-(--site-line) bg-(--site-surface)",
|
|
29
|
+
variants: {},
|
|
30
|
+
defaultVariants: {},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/** The place of a video that cannot be played: the player's 16:9 frame on the sunken ground, the mark in its middle. */
|
|
34
|
+
export const siteMediaFailedStyle = defineSlotStyle({
|
|
35
|
+
slot: "site-media-failed",
|
|
36
|
+
base:
|
|
37
|
+
"flex aspect-video min-w-0 items-center justify-center rounded-(--site-radius-md) border border-(--site-line) bg-(--site-surface-sunken) text-(--site-ink-muted) [&_svg]:size-8",
|
|
38
|
+
variants: {},
|
|
39
|
+
defaultVariants: {},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/** How far a video or a course was seen: the bar, then its words. */
|
|
43
|
+
export const siteMediaProgressStyle = defineSlotStyle({
|
|
44
|
+
slot: "site-media-progress",
|
|
45
|
+
base: "flex min-w-0 items-center gap-3",
|
|
46
|
+
variants: {},
|
|
47
|
+
defaultVariants: {},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
/** The track of {@link siteMediaProgressStyle}. */
|
|
51
|
+
export const siteMediaProgressTrackStyle = defineSlotStyle({
|
|
52
|
+
slot: "site-media-progress-track",
|
|
53
|
+
base: "relative h-1.5 min-w-0 flex-1 overflow-hidden rounded-(--site-radius-full) bg-(--site-surface-sunken)",
|
|
54
|
+
variants: {},
|
|
55
|
+
defaultVariants: {},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/** The seen share of the track. */
|
|
59
|
+
export const siteMediaProgressFillStyle = defineSlotStyle({
|
|
60
|
+
slot: "site-media-progress-fill",
|
|
61
|
+
base: "absolute inset-y-0 left-0 rounded-(--site-radius-full) bg-(--site-accent) transition-[width] duration-(--site-duration-base) ease-(--site-ease)",
|
|
62
|
+
variants: {},
|
|
63
|
+
defaultVariants: {},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
/** The words beside the track ("Progress 40%"). */
|
|
67
|
+
export const siteMediaProgressLabelStyle = defineSlotStyle({
|
|
68
|
+
slot: "site-media-progress-label",
|
|
69
|
+
base: "shrink-0 text-(length:--site-fs-caption) leading-(--site-lh-caption) font-(--site-fw-caption) text-(--site-ink-muted)",
|
|
70
|
+
variants: {},
|
|
71
|
+
defaultVariants: {},
|
|
72
|
+
});
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
import { MediaEmbed } from "@simplix-react/ui";
|
|
3
|
+
import { slotAttributes } from "@simplix-react/ui/design";
|
|
4
|
+
import { PlateViewer } from "@simplix-react/ui/plate-viewer";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
siteContentBodyStyle,
|
|
8
|
+
siteMediaFailedStyle,
|
|
9
|
+
siteMediaProgressFillStyle,
|
|
10
|
+
siteMediaProgressLabelStyle,
|
|
11
|
+
siteMediaProgressStyle,
|
|
12
|
+
siteMediaProgressTrackStyle,
|
|
13
|
+
siteMediaStyle,
|
|
14
|
+
siteScrollFrameStyle,
|
|
15
|
+
} from "./content.style";
|
|
16
|
+
|
|
17
|
+
/** Props for {@link SiteContentBody}. */
|
|
18
|
+
export interface SiteContentBodyProps {
|
|
19
|
+
/** The body as it was saved: the editor's serialized value, plain text, or a parsed value. */
|
|
20
|
+
readonly value: ComponentProps<typeof PlateViewer>["value"];
|
|
21
|
+
/** The plugin set of the editor the body was written with, where it is not the default. */
|
|
22
|
+
readonly variant?: ComponentProps<typeof PlateViewer>["variant"];
|
|
23
|
+
/** What stands in the body's place while there is none. */
|
|
24
|
+
readonly empty?: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A formatted body a person wrote, read on a site page: the framework's viewer (its headings, lists,
|
|
29
|
+
* links and tables) in the site's reading size. A value of plain text is one paragraph per line.
|
|
30
|
+
*/
|
|
31
|
+
export function SiteContentBody({ value, variant, empty }: SiteContentBodyProps) {
|
|
32
|
+
const none = value === null || value === undefined || value === "";
|
|
33
|
+
return <div {...slotAttributes(siteContentBodyStyle, {})}>{none ? empty : <PlateViewer value={value} variant={variant} />}</div>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Props for {@link SiteScrollFrame}. */
|
|
37
|
+
export interface SiteScrollFrameProps {
|
|
38
|
+
/** The frame's accessible name: it is a region the keyboard reaches, so it says what it holds. */
|
|
39
|
+
readonly label: string;
|
|
40
|
+
/** `sm` for a notice of a few paragraphs, `md` for a document. */
|
|
41
|
+
readonly size?: "sm" | "md";
|
|
42
|
+
readonly children: ReactNode;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A frame a long body scrolls inside instead of stretching the page (the words of a pledge above
|
|
47
|
+
* its signature). It is a named region with a tab stop, so a reader on the keyboard can scroll it.
|
|
48
|
+
*/
|
|
49
|
+
export function SiteScrollFrame({ label, size, children }: SiteScrollFrameProps) {
|
|
50
|
+
return (
|
|
51
|
+
<div {...slotAttributes(siteScrollFrameStyle, { size })} role="region" aria-label={label} tabIndex={0}>
|
|
52
|
+
{children}
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Props for {@link SiteMedia}. */
|
|
58
|
+
export interface SiteMediaProps {
|
|
59
|
+
/** `video` plays a file the product serves; `frame` embeds another player or a document viewer. */
|
|
60
|
+
readonly kind: "video" | "frame";
|
|
61
|
+
readonly src: string;
|
|
62
|
+
/** The accessible title of an embedded frame. */
|
|
63
|
+
readonly title?: string;
|
|
64
|
+
/** Called when a `video` has played to its end. */
|
|
65
|
+
readonly onEnded?: () => void;
|
|
66
|
+
/** Draws a `frame` at 16:9, as an embedded video player is. */
|
|
67
|
+
readonly widescreen?: boolean;
|
|
68
|
+
/** The height of a `frame` that is not widescreen, in CSS pixels (a document viewer). */
|
|
69
|
+
readonly height?: number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** A video or an embedded page in a site frame: the framework's media part, which plays and reports. */
|
|
73
|
+
export function SiteMedia({ kind, src, title, onEnded, widescreen, height }: SiteMediaProps) {
|
|
74
|
+
return (
|
|
75
|
+
<div {...slotAttributes(siteMediaStyle, {})}>
|
|
76
|
+
<MediaEmbed kind={kind} src={src} title={title} onEnded={onEnded} widescreen={widescreen} height={height} />
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Props for {@link SiteMediaFailed}. */
|
|
82
|
+
export interface SiteMediaFailedProps {
|
|
83
|
+
/** What the frame says to a screen reader ("The video cannot be played"). */
|
|
84
|
+
readonly label: string;
|
|
85
|
+
/** The glyph in the middle of the frame, which the product draws. */
|
|
86
|
+
readonly mark: ReactNode;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The place of a video that cannot be played: the player's frame with a mark in it. What happened
|
|
91
|
+
* and the way on (a retry) are said by a notice under it.
|
|
92
|
+
*/
|
|
93
|
+
export function SiteMediaFailed({ label, mark }: SiteMediaFailedProps) {
|
|
94
|
+
return (
|
|
95
|
+
<div {...slotAttributes(siteMediaFailedStyle, {})} role="img" aria-label={label}>
|
|
96
|
+
{mark}
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** The width of the seen share, held between none and all of the track. */
|
|
102
|
+
export function mediaProgressWidth(percent: number): string {
|
|
103
|
+
return `${Math.min(100, Math.max(0, Number.isFinite(percent) ? percent : 0))}%`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Props for {@link SiteMediaProgress}. */
|
|
107
|
+
export interface SiteMediaProgressProps {
|
|
108
|
+
/** How far it was seen, from 0 to 100. */
|
|
109
|
+
readonly percent: number;
|
|
110
|
+
/** The words beside the bar, which also name it ("Progress 40%"). */
|
|
111
|
+
readonly label: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** How far a video or a course was seen: a progress bar and its words beside it. */
|
|
115
|
+
export function SiteMediaProgress({ percent, label }: SiteMediaProgressProps) {
|
|
116
|
+
return (
|
|
117
|
+
<div {...slotAttributes(siteMediaProgressStyle, {})}>
|
|
118
|
+
<div {...slotAttributes(siteMediaProgressTrackStyle, {})} role="progressbar" aria-valuemin={0} aria-valuemax={100} aria-valuenow={percent} aria-label={label}>
|
|
119
|
+
<i {...slotAttributes(siteMediaProgressFillStyle, {})} style={{ width: mediaProgressWidth(percent) }} />
|
|
120
|
+
</div>
|
|
121
|
+
<span {...slotAttributes(siteMediaProgressLabelStyle, {})}>{label}</span>
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { mediaProgressWidth, SiteContentBody, SiteMedia, SiteMediaFailed, SiteMediaProgress, SiteScrollFrame } from "./content";
|
|
2
|
+
export type { SiteContentBodyProps, SiteMediaFailedProps, SiteMediaProgressProps, SiteMediaProps, SiteScrollFrameProps } from "./content";
|
|
3
|
+
export {
|
|
4
|
+
siteContentBodyStyle,
|
|
5
|
+
siteMediaFailedStyle,
|
|
6
|
+
siteMediaProgressFillStyle,
|
|
7
|
+
siteMediaProgressLabelStyle,
|
|
8
|
+
siteMediaProgressStyle,
|
|
9
|
+
siteMediaProgressTrackStyle,
|
|
10
|
+
siteMediaStyle,
|
|
11
|
+
siteScrollFrameStyle,
|
|
12
|
+
} from "./content.style";
|
|
@@ -16,6 +16,22 @@ export const siteCheckLabelStyle = defineSlotStyle({
|
|
|
16
16
|
defaultVariants: {},
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
+
/** A checkbox and the line under its words. */
|
|
20
|
+
export const siteCheckGroupStyle = defineSlotStyle({
|
|
21
|
+
slot: "site-checkbox-group",
|
|
22
|
+
base: "flex min-w-0 flex-col items-start gap-0.5",
|
|
23
|
+
variants: {},
|
|
24
|
+
defaultVariants: {},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
/** The line under a checkbox's words, which starts where the words start. */
|
|
28
|
+
export const siteCheckNoteStyle = defineSlotStyle({
|
|
29
|
+
slot: "site-checkbox-note",
|
|
30
|
+
base: "block min-w-0 pl-6 text-(length:--site-fs-caption) leading-(--site-lh-caption) font-(--site-fw-caption) text-(--site-ink-muted)",
|
|
31
|
+
variants: {},
|
|
32
|
+
defaultVariants: {},
|
|
33
|
+
});
|
|
34
|
+
|
|
19
35
|
/** The word before a consent the next step needs ("Required"), drawn for the eye only. */
|
|
20
36
|
export const siteCheckBadgeStyle = defineSlotStyle({
|
|
21
37
|
slot: "site-checkbox-badge",
|
package/src/form/choices.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useRef, type KeyboardEvent, type ReactNode } from "react";
|
|
1
|
+
import { useId, useRef, type KeyboardEvent, type ReactNode } from "react";
|
|
2
2
|
import { Checkbox, Switch } from "@simplix-react/ui";
|
|
3
3
|
import { partAttributes, slotAttributes } from "@simplix-react/ui/design";
|
|
4
4
|
|
|
5
5
|
import { radioKeyTarget, radioTabStop } from "./radio-keys";
|
|
6
6
|
|
|
7
|
-
import { siteRadioTitleStyle, siteRadioCardsStyle, siteCheckboxStyle, siteCheckLabelStyle, siteRadioDotStyle, siteRadioMarkStyle, siteToggleRowStyle, siteRadioBodyStyle, siteCheckBadgeStyle, siteToggleStyle, siteRadioCardStyle, siteRadioTextStyle, siteCheckStyle } from "./choices.style";
|
|
7
|
+
import { siteRadioTitleStyle, siteRadioCardsStyle, siteCheckboxStyle, siteCheckGroupStyle, siteCheckNoteStyle, siteCheckLabelStyle, siteRadioDotStyle, siteRadioMarkStyle, siteToggleRowStyle, siteRadioBodyStyle, siteCheckBadgeStyle, siteToggleStyle, siteRadioCardStyle, siteRadioTextStyle, siteCheckStyle } from "./choices.style";
|
|
8
8
|
|
|
9
9
|
/** Props for {@link SiteCheckbox}. */
|
|
10
10
|
export interface SiteCheckboxProps {
|
|
@@ -17,6 +17,11 @@ export interface SiteCheckboxProps {
|
|
|
17
17
|
readonly disabled?: boolean;
|
|
18
18
|
/** The id of the line that says why the box cannot be changed now; give it with `disabled`. */
|
|
19
19
|
readonly describedBy?: string;
|
|
20
|
+
/**
|
|
21
|
+
* A line under the words that says what checking the box does ("The time you agree is recorded").
|
|
22
|
+
* It describes the box and is no part of its name; it is drawn only with `label`.
|
|
23
|
+
*/
|
|
24
|
+
readonly note?: ReactNode;
|
|
20
25
|
/**
|
|
21
26
|
* The step cannot go ahead without it: the box reports `aria-required`, and `badge` is drawn
|
|
22
27
|
* before the words for the eye only ("Required"), so a screen reader never hears it glued to the
|
|
@@ -35,7 +40,10 @@ export interface SiteCheckboxProps {
|
|
|
35
40
|
* A box that is checked, unchecked or mixed, with its words beside it. The box is the framework's
|
|
36
41
|
* checkbox (its keyboard and state), drawn in the site design.
|
|
37
42
|
*/
|
|
38
|
-
export function SiteCheckbox({ checked, onCheckedChange, label, name, disabled = false, describedBy, required = false, badge, field }: SiteCheckboxProps) {
|
|
43
|
+
export function SiteCheckbox({ checked, onCheckedChange, label, name, disabled = false, describedBy, note, required = false, badge, field }: SiteCheckboxProps) {
|
|
44
|
+
const noteId = useId();
|
|
45
|
+
const noted = label !== undefined && note !== undefined;
|
|
46
|
+
const described = [describedBy, noted ? noteId : undefined].filter(Boolean).join(" ");
|
|
39
47
|
// The framework box is a button, which a form does not post; the field travels in a hidden input
|
|
40
48
|
// for exactly as long as the box is checked.
|
|
41
49
|
const posted = field && checked === true ? <input type="hidden" name={field.name} value={field.value} /> : null;
|
|
@@ -48,7 +56,7 @@ export function SiteCheckbox({ checked, onCheckedChange, label, name, disabled =
|
|
|
48
56
|
required={required}
|
|
49
57
|
aria-required={required || undefined}
|
|
50
58
|
aria-label={label === undefined ? name : undefined}
|
|
51
|
-
aria-describedby={
|
|
59
|
+
aria-describedby={described === "" ? undefined : described}
|
|
52
60
|
/>
|
|
53
61
|
);
|
|
54
62
|
if (label === undefined)
|
|
@@ -60,7 +68,7 @@ export function SiteCheckbox({ checked, onCheckedChange, label, name, disabled =
|
|
|
60
68
|
) : (
|
|
61
69
|
box
|
|
62
70
|
);
|
|
63
|
-
|
|
71
|
+
const row = (
|
|
64
72
|
<label {...slotAttributes(siteCheckStyle, {})}>
|
|
65
73
|
{box}
|
|
66
74
|
{posted}
|
|
@@ -75,6 +83,15 @@ export function SiteCheckbox({ checked, onCheckedChange, label, name, disabled =
|
|
|
75
83
|
</span>
|
|
76
84
|
</label>
|
|
77
85
|
);
|
|
86
|
+
if (!noted) return row;
|
|
87
|
+
return (
|
|
88
|
+
<div {...slotAttributes(siteCheckGroupStyle, {})}>
|
|
89
|
+
{row}
|
|
90
|
+
<span {...slotAttributes(siteCheckNoteStyle, {})} id={noteId}>
|
|
91
|
+
{note}
|
|
92
|
+
</span>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
78
95
|
}
|
|
79
96
|
|
|
80
97
|
/** Props for {@link SiteSwitch}. */
|
|
@@ -117,6 +134,11 @@ export interface RadioCardOption<T extends string> {
|
|
|
117
134
|
readonly body?: ReactNode;
|
|
118
135
|
/** Beside the title, such as a `SiteChip` saying it is the default. */
|
|
119
136
|
readonly badge?: ReactNode;
|
|
137
|
+
/**
|
|
138
|
+
* The card's accessible name, where its title is a picture: the picture is drawn alone, and the
|
|
139
|
+
* words that say what it shows are read without being drawn beside it.
|
|
140
|
+
*/
|
|
141
|
+
readonly name?: string;
|
|
120
142
|
readonly disabled?: boolean;
|
|
121
143
|
}
|
|
122
144
|
|
|
@@ -154,6 +176,7 @@ export function RadioCards<T extends string>({ label, value, options, onValueCha
|
|
|
154
176
|
type="button"
|
|
155
177
|
role="radio"
|
|
156
178
|
aria-checked={checked}
|
|
179
|
+
aria-label={option.name}
|
|
157
180
|
data-value={option.value}
|
|
158
181
|
tabIndex={option.value === stop ? 0 : -1}
|
|
159
182
|
disabled={option.disabled === true}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { countryFromTimezone, useCountryOptions, type CountryOption } from "@simplix-react/ui";
|
|
3
|
+
|
|
4
|
+
import { SiteAction } from "../action/site-action";
|
|
5
|
+
|
|
6
|
+
import { FieldInline } from "./fields";
|
|
7
|
+
import { SiteSelect, type SiteSelectOption } from "./select";
|
|
8
|
+
|
|
9
|
+
/** The countries as the options of a select: each by its code, under its name in the reader's language. */
|
|
10
|
+
export function countrySelectOptions(countries: readonly Pick<CountryOption, "code" | "localName">[]): SiteSelectOption<string>[] {
|
|
11
|
+
return countries.map((country) => ({ value: country.code, label: country.localName }));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The country of the time zone the browser reports, or undefined where the zone names none. */
|
|
15
|
+
export function countryOfBrowserZone(): string | undefined {
|
|
16
|
+
return countryFromTimezone(Intl.DateTimeFormat().resolvedOptions().timeZone);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Props for {@link SiteCountryControl}. */
|
|
20
|
+
export interface SiteCountryControlProps {
|
|
21
|
+
/** The countries to choose from. */
|
|
22
|
+
readonly countries: readonly Pick<CountryOption, "code" | "localName">[];
|
|
23
|
+
/** ISO 3166-1 alpha-2 code of the chosen country, or `null`. */
|
|
24
|
+
readonly value: string | null;
|
|
25
|
+
readonly onValueChange: (code: string) => void;
|
|
26
|
+
/** The select's accessible name; the field's visible name stands over it in a `FormField as="group"`. */
|
|
27
|
+
readonly label: string;
|
|
28
|
+
readonly placeholder?: string;
|
|
29
|
+
readonly disabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Offers the country of the reader's time zone beside the select: the action's accessible name
|
|
32
|
+
* and its glyph, which the product draws. Left out, the field is the select alone.
|
|
33
|
+
*/
|
|
34
|
+
readonly detect?: { readonly name: string; readonly glyph: ReactNode };
|
|
35
|
+
/** The country the detect action chooses; `undefined` where it cannot tell, and the action is then left out. */
|
|
36
|
+
readonly detected?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A country chosen from a list, with the way to take the one the reader's time zone names. */
|
|
40
|
+
export function SiteCountryControl({ countries, value, onValueChange, label, placeholder, disabled = false, detect, detected }: SiteCountryControlProps) {
|
|
41
|
+
const select = <SiteSelect label={label} placeholder={placeholder} value={value} options={countrySelectOptions(countries)} onValueChange={onValueChange} disabled={disabled} block />;
|
|
42
|
+
if (detect === undefined || detected === undefined || disabled) return select;
|
|
43
|
+
return (
|
|
44
|
+
<FieldInline>
|
|
45
|
+
{select}
|
|
46
|
+
<SiteAction id="detectCountry" label={detect.glyph} name={detect.name} tone="secondary" onSelect={() => onValueChange(detected)} />
|
|
47
|
+
</FieldInline>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Props for {@link SiteCountryField}. */
|
|
52
|
+
export type SiteCountryFieldProps = Omit<SiteCountryControlProps, "countries" | "detected">;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A country kept as its ISO 3166-1 alpha-2 code: the framework's list of countries, named in the
|
|
56
|
+
* reader's language, drawn as a site select.
|
|
57
|
+
*/
|
|
58
|
+
export function SiteCountryField(props: SiteCountryFieldProps) {
|
|
59
|
+
const countries = useCountryOptions();
|
|
60
|
+
return <SiteCountryControl {...props} countries={countries} detected={props.detect === undefined ? undefined : countryOfBrowserZone()} />;
|
|
61
|
+
}
|