@sevenfold/setto-client 0.15.0 → 0.17.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.
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The control a visitor uses to read the site in their own language.
3
+ *
4
+ * Mounted by `SettoProvider` rather than placed by the agent, and only when
5
+ * the site actually speaks more than one language — so it costs a Norwegian
6
+ * plumber's site nothing, and a site that gains a second language grows the
7
+ * control without anybody editing a header.
8
+ *
9
+ * That decision is worth stating because it is a trade. Auto-mounting means
10
+ * the switcher cannot sit inside a design it knows nothing about, so it sits
11
+ * in a corner instead: quiet, small, and out of the way of whatever the agent
12
+ * built. A site that wants it in its own header can render `<SettoLanguages>`
13
+ * anywhere and pass `inline`, and the floating one stands down.
14
+ *
15
+ * Styling is inline for the same reason the editing chrome's is: this renders
16
+ * inside a page whose stylesheet Setto did not write, and most of these sites
17
+ * ship Tailwind's Preflight, which would otherwise strip a bare `<button>`
18
+ * back to nothing.
19
+ */
20
+ export interface SettoLanguagesProps {
21
+ /** Every language the site speaks, primary first. */
22
+ languages: readonly string[];
23
+ /**
24
+ * Rendered in the flow of the page rather than fixed in a corner.
25
+ *
26
+ * Also tells the auto-mounted copy to stand down, so a site that places its
27
+ * own switcher does not end up with two.
28
+ */
29
+ inline?: boolean;
30
+ }
31
+ export declare function SettoLanguages({ languages, inline }: SettoLanguagesProps): import("react/jsx-runtime").JSX.Element | null;
32
+ /**
33
+ * The floating copy, mounted by the provider.
34
+ *
35
+ * Renders nothing when the site places its own, and nothing when there is only
36
+ * one language to be in.
37
+ */
38
+ export declare function AutoLanguageSwitcher({ languages }: {
39
+ languages: readonly string[];
40
+ }): import("react/jsx-runtime").JSX.Element | null;
package/dist/chrome.d.ts CHANGED
@@ -42,7 +42,7 @@ export interface SettoChromeHandshake {
42
42
  * keeps a chrome bundle that fails to load, or throws while rendering, from
43
43
  * taking the editor down with it.
44
44
  */
45
- mountSlot: (name: string, Component: React.ComponentType) => void;
45
+ mountSlot: (name: string, Component: React.ComponentType<any>) => void;
46
46
  /**
47
47
  * The host's own `useSetto`, callable from the chrome.
48
48
  *
@@ -89,7 +89,7 @@ declare global {
89
89
  * offered nothing — including after it offered something that threw. Callers
90
90
  * render their own version when this is null; every one of them must have one.
91
91
  */
92
- export declare function useSettoChromeSlot(name: string): React.ComponentType | null;
92
+ export declare function useSettoChromeSlot<P extends object = Record<string, never>>(name: string): React.ComponentType<P> | null;
93
93
  /** @deprecated Use `useSettoChromeSlot('admin')`. */
94
- export declare function useSettoAdminChrome(): React.ComponentType | null;
94
+ export declare function useSettoAdminChrome(): React.ComponentType<Record<string, never>> | null;
95
95
  export declare function SettoChrome(): import("react/jsx-runtime").JSX.Element | null;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
+ export { SettoLanguages } from './LanguageSwitcher';
2
+ export { DEFAULT_LANGUAGE, languageName, pickInitialLanguage, siteLanguages, } from './lib/languages';
1
3
  export { SettoProvider, useSetto } from './provider';
2
4
  export { GuestEditProvider, useGuestEdit } from './guest-edit';
3
- export { SettoPreviewBar, isPreviewHost, previewBarState } from './preview-bar';
4
5
  export { SettoChrome, useSettoChromeSlot } from './chrome';
5
6
  export type { SettoChromeHandshake } from './chrome';
6
7
  export { T } from './T';
@@ -12,7 +13,7 @@ export { SettoImage } from './SettoImage';
12
13
  export type { SettoImageProps } from './SettoImage';
13
14
  export { SettoRepeater } from './SettoRepeater';
14
15
  export type { SettoRepeaterProps } from './SettoRepeater';
15
- export { SettoForm, FORM_FIELD_TYPES, FORM_FIELD_TYPE_LABELS, formFieldsPrefix, isFormFieldType, readLocaleFields, settoSubmissionUrl, } from './modules/forms';
16
+ export { SettoForm, FORM_FIELD_TYPES, FORM_FIELD_TYPE_LABELS, fieldTypeHasOptions, fieldTypeHasPlaceholder, formFieldsPrefix, isFormFieldType, readLocaleFields, settoSubmissionUrl, } from './modules/forms';
16
17
  export type { SettoFormProps, SettoFormClassNames, FormFieldProp, FormSettings, FormSubmissionRow, FormValue, FormValues, ResolvedFormField, SubmissionEnvelope, } from './modules/forms';
17
18
  export { SETTO_MODULES } from './modules';
18
19
  export type { SettoModule } from './modules';
@@ -36,9 +37,10 @@ export { BLOCK_REGISTRY, BLOCK_TYPES, nodeChildren } from './block-tree/registry
36
37
  export type { BlockTypeMeta } from './block-tree/registry';
37
38
  export { SETTO_BASE, siteHomeUrl, isAdminRoute, isAdminDeploymentView, adminViewUrl, currentAdminView, isAdminPanelView, adminRedirectUrl, CHECKOUT_INTENT, checkoutIntentUrl, wantsCheckout, withoutCheckoutIntent, } from './lib/urls';
38
39
  export { SettoMark } from './edit-mode/setto-mark';
40
+ export { FloatingPopover } from './edit-mode/floating-popover';
41
+ export type { FieldPatch, FormFieldToolsProps, FormFieldToolsComponent, } from './modules/forms/field-tools';
39
42
  export { isLinkContext } from './lib/link-context';
40
43
  export { useCoarsePointer } from './lib/use-coarse-pointer';
41
44
  export { FAB_SIZE, FAB_INSET } from './edit-mode/constants';
42
45
  export { EMPTY_I18N_STORE_SNAPSHOT } from './lib/i18n-store';
43
46
  export type { I18nStoreSnapshot } from './lib/i18n-store';
44
- export { IN_PROGRESS_STATUSES, isDeploymentInProgress, isDeploymentStale, STALE_PENDING_MS, STALE_BUILDING_MS, fetchInProgressDeploymentId, waitForDeploymentByCommit, useDeploymentStatus, PublishProgressBar, PublishProgressSteps, } from './edit-mode/deployment-status';
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Which languages a site speaks, and which one a visitor is reading.
3
+ *
4
+ * Every Setto site has been Norwegian-only, not because the machinery could
5
+ * not hold more — `I18nStore` has taken a language argument since the
6
+ * beginning and the publish path already serialises one bundle per language —
7
+ * but because nothing ever told a site it had a second one, and nothing gave a
8
+ * visitor a way to ask for it.
9
+ *
10
+ * The choice is deliberately per browser and not per URL. A path prefix
11
+ * (`/en/…`) is the better answer for search engines and the wrong answer for
12
+ * this pipeline today: every site is a single-page app whose routes the agent
13
+ * writes, and quietly doubling every route is not a thing to do to thirteen
14
+ * live sites in one release. Recorded here rather than hidden: when these
15
+ * sites want to be found in two languages, this is the decision to revisit.
16
+ */
17
+ /** Norwegian is the floor: every site has it, and it is what the agent writes. */
18
+ export declare const DEFAULT_LANGUAGE = "no";
19
+ /** «Norsk», or the tag itself when we have no name for it. */
20
+ export declare function languageName(tag: string): string;
21
+ /**
22
+ * The languages this site actually speaks, primary first, no duplicates.
23
+ *
24
+ * A configured list that forgets to include the primary language is a site
25
+ * whose own copy is unreachable, so the primary is inserted rather than
26
+ * trusted.
27
+ */
28
+ export declare function siteLanguages(configured: readonly string[] | undefined, primary?: string): string[];
29
+ /** What this browser last chose here, if anything. */
30
+ export declare function readStoredLanguage(): string | null;
31
+ export declare function storeLanguage(tag: string): void;
32
+ /**
33
+ * The language to open in.
34
+ *
35
+ * Their own previous choice first — it is the only signal that is definitely
36
+ * about this site. Then what the browser asks for, matched on the base tag so
37
+ * `en-GB` finds `en`. Then the site's primary, which is always present.
38
+ *
39
+ * Note what is *not* here: no geolocation, and no guessing from a domain. A
40
+ * Norwegian abroad is still Norwegian, and a site that decides it knows better
41
+ * than `Accept-Language` is a site people fight with.
42
+ */
43
+ export declare function pickInitialLanguage(available: readonly string[], browserLanguages?: readonly string[], stored?: string | null): string;
@@ -0,0 +1,35 @@
1
+ import type { ComponentType } from 'react';
2
+ import type { FormFieldType, ResolvedFormField } from './fields';
3
+ /**
4
+ * The contract between a form on the customer's page and the editing tools
5
+ * Setto serves for it.
6
+ *
7
+ * The tools themselves — the popover, the type picker, the reordering — live
8
+ * in setto-server and arrive at runtime, so changing them is a deploy. What
9
+ * has to stay here is the shape of the conversation between the two, because
10
+ * `SettoForm` applies the patch and it is compiled into the customer's bundle.
11
+ *
12
+ * That makes this the pinned part, and it is deliberately data: adding a field
13
+ * kind means widening `FormFieldType`, but rearranging the panel that sets one
14
+ * costs nothing on this side.
15
+ */
16
+ export interface FieldPatch {
17
+ name?: string;
18
+ type?: FormFieldType;
19
+ required?: boolean;
20
+ label?: string;
21
+ placeholder?: string;
22
+ options?: string;
23
+ }
24
+ export interface FormFieldToolsProps {
25
+ field: ResolvedFormField;
26
+ index: number;
27
+ count: number;
28
+ /** Open the settings popover as soon as the tools mount (a field just added). */
29
+ autoOpen?: boolean;
30
+ onMove: (direction: -1 | 1) => void;
31
+ onRemove: () => void;
32
+ onChange: (patch: FieldPatch) => void;
33
+ }
34
+ /** What the chrome registers under `mountSlot('form-field-tools', …)`. */
35
+ export type FormFieldToolsComponent = ComponentType<FormFieldToolsProps>;
@@ -8,5 +8,5 @@ export declare const formsModule: SettoModule;
8
8
  export { SettoForm } from './SettoForm';
9
9
  export type { SettoFormProps, SettoFormClassNames } from './SettoForm';
10
10
  export type { FormSettings, FormSubmissionRow, FormsApi } from './api';
11
- export { FORM_FIELD_TYPES, FORM_FIELD_TYPE_LABELS, formFieldsPrefix, isFormFieldType, readLocaleFields, settoSubmissionUrl, } from './fields';
11
+ export { FORM_FIELD_TYPES, FORM_FIELD_TYPE_LABELS, fieldTypeHasOptions, fieldTypeHasPlaceholder, formFieldsPrefix, isFormFieldType, readLocaleFields, settoSubmissionUrl, } from './fields';
12
12
  export type { FormFieldProp, FormFieldType, FormValue, FormValues, ResolvedFormField, SubmissionEnvelope, } from './fields';