entasis 0.13.5 → 0.13.7

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 (76) hide show
  1. package/dist/components/Address/Address.svelte +44 -0
  2. package/dist/components/Address/Address.svelte.d.ts +4 -0
  3. package/dist/components/Address/address.d.ts +99 -0
  4. package/dist/components/Address/address.google.d.ts +89 -0
  5. package/dist/components/Address/address.google.fixtures.json +808 -0
  6. package/dist/components/Address/address.google.js +184 -0
  7. package/dist/components/Address/address.js +109 -0
  8. package/dist/components/Address/address.mcp.d.ts +1 -0
  9. package/dist/components/Address/address.mcp.js +100 -0
  10. package/dist/components/Address/address.props.d.ts +26 -0
  11. package/dist/components/Address/address.props.js +1 -0
  12. package/dist/components/Address/address.provider.d.ts +19 -0
  13. package/dist/components/Address/address.provider.js +69 -0
  14. package/dist/components/Address/address.theme.d.ts +63 -0
  15. package/dist/components/Address/address.theme.js +42 -0
  16. package/dist/components/Address/index.d.ts +6 -0
  17. package/dist/components/Address/index.js +5 -0
  18. package/dist/components/Form/AddressInput/AddressInput.svelte +482 -0
  19. package/dist/components/Form/AddressInput/AddressInput.svelte.d.ts +4 -0
  20. package/dist/components/Form/AddressInput/addressInput.mcp.d.ts +1 -0
  21. package/dist/components/Form/AddressInput/addressInput.mcp.js +110 -0
  22. package/dist/components/Form/AddressInput/addressInput.props.d.ts +72 -0
  23. package/dist/components/Form/AddressInput/addressInput.props.js +1 -0
  24. package/dist/components/Form/AddressInput/addressInput.theme.d.ts +63 -0
  25. package/dist/components/Form/AddressInput/addressInput.theme.js +55 -0
  26. package/dist/components/Form/AddressInput/index.d.ts +3 -0
  27. package/dist/components/Form/AddressInput/index.js +2 -0
  28. package/dist/components/Form/Field/field.d.ts +5 -2
  29. package/dist/components/Form/Field/field.state.svelte.js +4 -0
  30. package/dist/components/Form/Field/index.d.ts +1 -1
  31. package/dist/components/Form/Field/schemas.js +8 -0
  32. package/dist/components/Form/Form/FormInputRenderer.svelte +6 -0
  33. package/dist/components/Form/Form/form.d.ts +6 -0
  34. package/dist/components/Form/Form/form.mcp.d.ts +1 -1
  35. package/dist/components/Form/Form/form.mcp.js +1 -1
  36. package/dist/components/Form/Form/form.state.svelte.d.ts +142 -11
  37. package/dist/components/Form/Form/form.state.svelte.js +2 -0
  38. package/dist/components/Form/Form/visibility.d.ts +186 -20
  39. package/dist/components/Form/MultiStepForm/multiStepForm.state.svelte.d.ts +136 -0
  40. package/dist/components/Form/SignatureInput/SignatureInput.svelte +327 -0
  41. package/dist/components/Form/SignatureInput/SignatureInput.svelte.d.ts +4 -0
  42. package/dist/components/Form/SignatureInput/index.d.ts +4 -0
  43. package/dist/components/Form/SignatureInput/index.js +2 -0
  44. package/dist/components/Form/SignatureInput/signatureInput.mcp.d.ts +1 -0
  45. package/dist/components/Form/SignatureInput/signatureInput.mcp.js +74 -0
  46. package/dist/components/Form/SignatureInput/signatureInput.props.d.ts +29 -0
  47. package/dist/components/Form/SignatureInput/signatureInput.props.js +1 -0
  48. package/dist/components/Form/SignatureInput/signatureInput.strokes.d.ts +77 -0
  49. package/dist/components/Form/SignatureInput/signatureInput.strokes.js +149 -0
  50. package/dist/components/Form/SignatureInput/signatureInput.theme.d.ts +99 -0
  51. package/dist/components/Form/SignatureInput/signatureInput.theme.js +70 -0
  52. package/dist/components/Sidebar/Sidebar.svelte +1 -1
  53. package/dist/components/Sidebar/SidebarMenuItem.svelte +59 -15
  54. package/dist/components/Sidebar/SidebarMenuSubItem.svelte +43 -12
  55. package/dist/components/Sidebar/SidebarMenuText.svelte +60 -0
  56. package/dist/components/Sidebar/SidebarMenuText.svelte.d.ts +18 -0
  57. package/dist/components/Sidebar/sidebar.mcp.d.ts +1 -1
  58. package/dist/components/Sidebar/sidebar.mcp.js +53 -0
  59. package/dist/components/Sidebar/sidebar.props.d.ts +31 -0
  60. package/dist/components/Sidebar/sidebar.theme.d.ts +99 -0
  61. package/dist/components/Sidebar/sidebar.theme.js +100 -9
  62. package/dist/generated/componentAliases.d.ts +3 -0
  63. package/dist/generated/componentAliases.js +3 -0
  64. package/dist/generated/componentContract.d.ts +46 -1
  65. package/dist/generated/componentContract.js +113 -0
  66. package/dist/generated/componentMcpRegistry.js +6 -0
  67. package/dist/i18n/ar.js +18 -0
  68. package/dist/i18n/de.js +18 -0
  69. package/dist/i18n/en.d.ts +18 -0
  70. package/dist/i18n/en.js +18 -0
  71. package/dist/i18n/es.js +18 -0
  72. package/dist/i18n/fr.js +18 -0
  73. package/dist/i18n/ja.js +18 -0
  74. package/dist/i18n/pt.js +18 -0
  75. package/dist/i18n/zh.js +18 -0
  76. package/package.json +25 -1
@@ -0,0 +1,44 @@
1
+ <script lang="ts">
2
+ import Slot from '../Slot/Slot.svelte';
3
+ import { useI18n } from '../../i18n/context.svelte.js';
4
+ import { formatAddress } from './address.js';
5
+ import type { AddressProps } from './address.props.js';
6
+ import { useAddressTheme } from './address.theme.js';
7
+
8
+ let {
9
+ address,
10
+ fields,
11
+ layout = 'block',
12
+ size = 'normal',
13
+ empty,
14
+ ref = $bindable(null),
15
+ class: className,
16
+ theme,
17
+ ...rest
18
+ }: AddressProps = $props();
19
+
20
+ const t = $derived(useI18n());
21
+ const classes = $derived(useAddressTheme(theme));
22
+ // The country is named in the active locale when the value only carries its code.
23
+ const lines = $derived(formatAddress(address, { fields, locale: t.locale }));
24
+ </script>
25
+
26
+ <address
27
+ bind:this={ref}
28
+ data-slot="address"
29
+ data-layout={layout}
30
+ data-empty={lines.length === 0 ? 'true' : undefined}
31
+ class={classes.root({ size, layout, className })}
32
+ {...rest}
33
+ >
34
+ {#each lines as line, index (index)}
35
+ <span data-slot="address-line" class={classes.line({ layout })}
36
+ >{line}{#if layout === 'inline' && index < lines.length - 1},
37
+ {/if}</span
38
+ >
39
+ {:else}
40
+ {#if empty}
41
+ <Slot as="span" render={empty} class={classes.empty()} />
42
+ {/if}
43
+ {/each}
44
+ </address>
@@ -0,0 +1,4 @@
1
+ import type { AddressProps } from './address.props.js';
2
+ declare const Address: import("svelte").Component<AddressProps, {}, "ref">;
3
+ type Address = ReturnType<typeof Address>;
4
+ export default Address;
@@ -0,0 +1,99 @@
1
+ /**
2
+ * A postal address as entasis stores, edits and displays it, the order its lines take in each
3
+ * country, and the provider contract an address search plugs into.
4
+ */
5
+ /** A part of an address a field can show and edit. */
6
+ export type AddressField = 'line1' | 'line2' | 'postalCode' | 'city' | 'region' | 'country';
7
+ /** Every address part, in the order a form usually asks for them. */
8
+ export declare const ADDRESS_FIELDS: readonly AddressField[];
9
+ export type AddressLocation = {
10
+ lat: number;
11
+ lng: number;
12
+ };
13
+ /**
14
+ * A postal address. Every part is optional: a field shows and fills the parts it asks for, and
15
+ * a provider fills what it knows.
16
+ */
17
+ export type Address = {
18
+ /** Street line: the number and the street, in the country's order ("12 Rue de Rivoli"). */
19
+ line1?: string | null;
20
+ /** Second line: apartment, suite, building, floor. */
21
+ line2?: string | null;
22
+ postalCode?: string | null;
23
+ /** City, town or postal town. */
24
+ city?: string | null;
25
+ /** State, province or region (first administrative level). */
26
+ region?: string | null;
27
+ /** Country name, as the provider or the field wrote it. */
28
+ country?: string | null;
29
+ /** ISO 3166-1 alpha-2 country code ("FR"). It decides the line order. */
30
+ countryCode?: string | null;
31
+ /** Street number alone, when a provider resolved it. Cleared by a manual edit of `line1`. */
32
+ streetNumber?: string | null;
33
+ /** Street name alone, when a provider resolved it. Cleared by a manual edit of `line1`. */
34
+ street?: string | null;
35
+ /** The provider's own one-line address. Cleared by any manual edit. */
36
+ formatted?: string | null;
37
+ /** The provider's place id. Cleared by any manual edit. */
38
+ placeId?: string | null;
39
+ /** Coordinates of the place. Cleared by any manual edit. */
40
+ location?: AddressLocation | null;
41
+ };
42
+ /** One search suggestion. */
43
+ export type AddressSuggestion = {
44
+ /** Provider id passed back to `resolve`. */
45
+ id: string;
46
+ /** Main text: the street line or the place name. */
47
+ label: string;
48
+ /** Secondary text: the city, region and country. */
49
+ description?: string;
50
+ };
51
+ /** What an address search sends with each call. */
52
+ export type AddressProviderRequest = {
53
+ /** Aborted when a newer query replaces this one, or the field is destroyed. */
54
+ signal?: AbortSignal;
55
+ /**
56
+ * One id per search, from the first keystroke to the chosen suggestion. Providers that bill
57
+ * by session (Google Places) group the calls under it.
58
+ */
59
+ session: string;
60
+ /** BCP 47 language the results should be written in: the active I18n locale. */
61
+ language?: string;
62
+ /** ISO 3166-1 alpha-2 codes the search is limited to. */
63
+ countries?: readonly string[];
64
+ };
65
+ /**
66
+ * An address search: suggestions for typed text, and the full address for a chosen suggestion.
67
+ * `createGooglePlacesProvider` is one; any service can implement it.
68
+ */
69
+ export type AddressProvider = {
70
+ search: (query: string, request: AddressProviderRequest) => Promise<AddressSuggestion[]>;
71
+ resolve: (id: string, request: AddressProviderRequest) => Promise<Address | null>;
72
+ };
73
+ /** True when no part a person reads (lines, postal code, city, region, country) is filled. */
74
+ export declare function isAddressEmpty(address: Address | null | undefined): boolean;
75
+ /** The street line for a number and a street, in the order `countryCode` writes them. */
76
+ export declare function composeStreetLine(streetNumber: string | null | undefined, street: string | null | undefined, countryCode?: string | null): string | null;
77
+ export type FormatAddressOptions = {
78
+ /** Parts to include, in any order. Defaults to every part. */
79
+ fields?: readonly AddressField[];
80
+ /**
81
+ * Locale the country name is written in when only `countryCode` is set. Defaults to the
82
+ * runtime's locale.
83
+ */
84
+ locale?: string;
85
+ };
86
+ /** The country name for `address`: its own `country`, or `countryCode` written in `locale`. */
87
+ export declare function addressCountryName(address: Address, locale?: string): string;
88
+ /**
89
+ * The lines of an address as the country writes them: street lines, then the locality line
90
+ * (postal code and city, in the country's order, with the region where it belongs), then the
91
+ * country. Empty parts and empty lines are left out.
92
+ */
93
+ export declare function formatAddress(address: Address | null | undefined, { fields, locale }?: FormatAddressOptions): string[];
94
+ /** The address on one line, its lines joined by ", ". */
95
+ export declare const formatAddressLine: (address: Address | null | undefined, options?: FormatAddressOptions) => string;
96
+ /** ISO 3166-1 alpha-2 codes of every country and territory a postal address can be in. */
97
+ export declare const COUNTRY_CODES: readonly string[];
98
+ /** The name of the country `code` in `locale`, or the code itself when Intl cannot name it. */
99
+ export declare function countryName(code: string, locale?: string): string;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Google Places (Places API "New", REST) as an `AddressProvider`. No SDK is loaded: the search
3
+ * and the place details are two `fetch` calls, grouped under the field's session token so
4
+ * Google bills one autocomplete session per chosen address.
5
+ */
6
+ import type { Address, AddressProvider } from './address.js';
7
+ /** One entry of a Place's `addressComponents`. */
8
+ export type GooglePlaceAddressComponent = {
9
+ longText?: string;
10
+ shortText?: string;
11
+ types?: string[];
12
+ languageCode?: string;
13
+ };
14
+ /** The Place fields `parseGooglePlace` reads. */
15
+ export type GooglePlace = {
16
+ id?: string;
17
+ formattedAddress?: string;
18
+ addressComponents?: GooglePlaceAddressComponent[];
19
+ location?: {
20
+ latitude?: number;
21
+ longitude?: number;
22
+ };
23
+ };
24
+ export type GooglePlacesProviderOptions = {
25
+ /**
26
+ * Browser API key, sent as `X-Goog-Api-Key`. Restrict it to your sites and to Places API
27
+ * (New) in the Google Cloud console. Omit it when `endpoint` is your own proxy that adds the
28
+ * key on the server.
29
+ */
30
+ apiKey?: string;
31
+ /**
32
+ * Base URL of the Places API, or of a proxy that forwards `POST {endpoint}/places:autocomplete`
33
+ * and `GET {endpoint}/places/{id}` to it. Defaults to `https://places.googleapis.com/v1`.
34
+ */
35
+ endpoint?: string;
36
+ /** Language of the results when the field does not pass one. */
37
+ language?: string;
38
+ /** CLDR region code that biases the results and formats them ("fr"). */
39
+ region?: string;
40
+ /**
41
+ * Primary place types the search is limited to (up to 5). Defaults to addresses only
42
+ * (`street_address`, `premise`, `subpremise`, `route`), so shops and landmarks stay out;
43
+ * pass `[]` to search every place.
44
+ */
45
+ types?: readonly string[];
46
+ /** Fetch implementation, for a server or a test. Defaults to the global `fetch`. */
47
+ fetch?: typeof fetch;
48
+ };
49
+ /**
50
+ * An `Address` from a Google Place: the street line in the country's order, the postal town
51
+ * or the nearest locality as the city, the first administrative level as the region (its short
52
+ * form in the United States, Canada and Australia, where it is written "CA" or "NSW").
53
+ */
54
+ export declare function parseGooglePlace(place: GooglePlace): Address;
55
+ /** A Places request that failed, with its HTTP status. */
56
+ export declare class GooglePlacesError extends Error {
57
+ readonly status: number;
58
+ constructor(status: number, message: string);
59
+ }
60
+ /**
61
+ * An `AddressProvider` backed by Google Places (Places API "New"). Pass a browser `apiKey`, or an
62
+ * `endpoint` on your server that adds the key, so it never reaches the page.
63
+ */
64
+ export declare function createGooglePlacesProvider(options?: GooglePlacesProviderOptions): AddressProvider;
65
+ export type GooglePlacesProxyOptions = {
66
+ /** Server-side Places API (New) key. It stays on the server: the page never sees it. */
67
+ apiKey: string | undefined;
68
+ /** Fetch implementation. Defaults to the global `fetch`. */
69
+ fetch?: typeof fetch;
70
+ };
71
+ type ProxyEvent = {
72
+ request: Request;
73
+ };
74
+ /**
75
+ * Server handlers for the route `AddressInput` searches through by default
76
+ * (`/api/places/[...path]`): they forward the two Places calls to Google with the server's key.
77
+ * Nothing else passes: any other path or method answers 404, so the route is not an open proxy.
78
+ *
79
+ * ```ts
80
+ * // src/routes/api/places/[...path]/+server.ts
81
+ * import { createGooglePlacesProxy } from './index.ts';
82
+ * export const { GET, POST } = createGooglePlacesProxy({ apiKey: GOOGLE_PLACE_API_KEY });
83
+ * ```
84
+ */
85
+ export declare function createGooglePlacesProxy({ apiKey, fetch: fetchImpl }: GooglePlacesProxyOptions): {
86
+ POST: ({ request }: ProxyEvent) => Promise<Response>;
87
+ GET: ({ request }: ProxyEvent) => Promise<Response>;
88
+ };
89
+ export {};