@dk-address/react 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/dist/address-input.d.ts +31 -30
- package/dist/address-input.js +4 -29
- package/dist/index.d.ts +31 -1
- package/dist/index.js +33 -1
- package/dist/use-address-autosuggest.js +1 -0
- package/dist/use-autosuggest-store.js +1 -0
- package/package.json +3 -3
package/dist/address-input.d.ts
CHANGED
|
@@ -15,9 +15,15 @@ export interface AddressInputProps extends AutosuggestOptions {
|
|
|
15
15
|
loop?: boolean;
|
|
16
16
|
}
|
|
17
17
|
declare function AddressInputRoot({ children, name, required, disabled, readOnly, autoHighlight, loop, ...options }: AddressInputProps): import("react").JSX.Element;
|
|
18
|
+
declare namespace AddressInputRoot {
|
|
19
|
+
var displayName: string;
|
|
20
|
+
}
|
|
18
21
|
export type AddressInputLabelProps = ComponentProps<typeof AutocompleteLabel>;
|
|
19
22
|
/** Names the input. Renders a `label`. */
|
|
20
23
|
declare function Label(props: AddressInputLabelProps): import("react").JSX.Element;
|
|
24
|
+
declare namespace Label {
|
|
25
|
+
var displayName: string;
|
|
26
|
+
}
|
|
21
27
|
export type AddressInputControlProps = ComponentProps<"div">;
|
|
22
28
|
/**
|
|
23
29
|
* Optional box around the input and clear button, for styling them as one field. The popup
|
|
@@ -25,12 +31,21 @@ export type AddressInputControlProps = ComponentProps<"div">;
|
|
|
25
31
|
* Has `data-open` while suggestions show and `data-loading` while searching.
|
|
26
32
|
*/
|
|
27
33
|
declare function Control({ ref, ...props }: AddressInputControlProps): import("react").JSX.Element;
|
|
34
|
+
declare namespace Control {
|
|
35
|
+
var displayName: string;
|
|
36
|
+
}
|
|
28
37
|
export type AddressInputInputProps = ComponentProps<typeof AutocompleteInput>;
|
|
29
38
|
/** The text field. Renders an `input` with the combobox role. */
|
|
30
39
|
declare function Input({ ref, ...props }: AddressInputInputProps): import("react").JSX.Element;
|
|
40
|
+
declare namespace Input {
|
|
41
|
+
var displayName: string;
|
|
42
|
+
}
|
|
31
43
|
export type AddressInputClearProps = ComponentProps<typeof AutocompleteClear>;
|
|
32
44
|
/** Empties the field and keeps focus in it. Renders a `button`. */
|
|
33
45
|
declare function Clear(props: AddressInputClearProps): import("react").JSX.Element;
|
|
46
|
+
declare namespace Clear {
|
|
47
|
+
var displayName: string;
|
|
48
|
+
}
|
|
34
49
|
export type AddressInputPopupProps = ComponentProps<typeof AutocompleteContent>;
|
|
35
50
|
/**
|
|
36
51
|
* The suggestions popup, positioned against `Control` when there is one, otherwise against
|
|
@@ -38,18 +53,30 @@ export type AddressInputPopupProps = ComponentProps<typeof AutocompleteContent>;
|
|
|
38
53
|
* another element; `--anchor-width` and `--available-height` help size it.
|
|
39
54
|
*/
|
|
40
55
|
declare function Popup({ anchor, ...props }: AddressInputPopupProps): import("react").JSX.Element;
|
|
56
|
+
declare namespace Popup {
|
|
57
|
+
var displayName: string;
|
|
58
|
+
}
|
|
41
59
|
export type AddressInputStatusProps = ComponentProps<typeof AutocompleteStatus>;
|
|
42
60
|
/** Announces loading and result counts. Children can be a function of `{ loading, count }`. */
|
|
43
61
|
declare function Status(props: AddressInputStatusProps): import("react").JSX.Element;
|
|
62
|
+
declare namespace Status {
|
|
63
|
+
var displayName: string;
|
|
64
|
+
}
|
|
44
65
|
export type AddressInputEmptyProps = ComponentProps<typeof AutocompleteEmpty>;
|
|
45
66
|
/** Shows when a search finds nothing. Children can be a function of `{ empty, loading, query }`. */
|
|
46
67
|
declare function Empty(props: AddressInputEmptyProps): import("react").JSX.Element;
|
|
68
|
+
declare namespace Empty {
|
|
69
|
+
var displayName: string;
|
|
70
|
+
}
|
|
47
71
|
export type AddressInputListProps = Omit<ComponentProps<typeof AutocompleteList>, "children"> & {
|
|
48
72
|
/** A function of each suggestion, your own items, or nothing for one `Item` per suggestion. */
|
|
49
73
|
children?: ReactNode | ((suggestion: Suggestion, index: number) => ReactNode);
|
|
50
74
|
};
|
|
51
75
|
/** The listbox holding the suggestions. */
|
|
52
76
|
declare function List({ children, ...props }: AddressInputListProps): import("react").JSX.Element;
|
|
77
|
+
declare namespace List {
|
|
78
|
+
var displayName: string;
|
|
79
|
+
}
|
|
53
80
|
export type AddressInputItemProps = Omit<ComponentProps<typeof AutocompleteItem>, "value" | "label"> & {
|
|
54
81
|
suggestion: Suggestion;
|
|
55
82
|
};
|
|
@@ -58,6 +85,9 @@ export type AddressInputItemProps = Omit<ComponentProps<typeof AutocompleteItem>
|
|
|
58
85
|
* suggestion's type and `data-highlighted` while highlighted.
|
|
59
86
|
*/
|
|
60
87
|
declare function Item({ suggestion, children, ...props }: AddressInputItemProps): import("react").JSX.Element;
|
|
88
|
+
declare namespace Item {
|
|
89
|
+
var displayName: string;
|
|
90
|
+
}
|
|
61
91
|
export interface UseAddressInputResult {
|
|
62
92
|
state: AutosuggestState;
|
|
63
93
|
select(suggestion: Suggestion): Promise<void>;
|
|
@@ -67,33 +97,4 @@ export interface UseAddressInputResult {
|
|
|
67
97
|
}
|
|
68
98
|
/** Read the state and act on it from anywhere inside `<AddressInput>`. */
|
|
69
99
|
export declare function useAddressInput(): UseAddressInputResult;
|
|
70
|
-
|
|
71
|
-
* Headless address autosuggest for KDS Adressevælger. Every part takes `className` and
|
|
72
|
-
* `style` (plain, or a function of the part's state) and its element's props.
|
|
73
|
-
*
|
|
74
|
-
* ```tsx
|
|
75
|
-
* <AddressInput onSelect={(selection) => save(selection.details)}>
|
|
76
|
-
* <AddressInput.Label>Address</AddressInput.Label>
|
|
77
|
-
* <AddressInput.Control>
|
|
78
|
-
* <AddressInput.Input />
|
|
79
|
-
* <AddressInput.Clear>×</AddressInput.Clear>
|
|
80
|
-
* </AddressInput.Control>
|
|
81
|
-
* <AddressInput.Popup>
|
|
82
|
-
* <AddressInput.Empty>No addresses found.</AddressInput.Empty>
|
|
83
|
-
* <AddressInput.List />
|
|
84
|
-
* </AddressInput.Popup>
|
|
85
|
-
* </AddressInput>
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
export declare const AddressInput: typeof AddressInputRoot & {
|
|
89
|
-
Label: typeof Label;
|
|
90
|
-
Control: typeof Control;
|
|
91
|
-
Input: typeof Input;
|
|
92
|
-
Clear: typeof Clear;
|
|
93
|
-
Popup: typeof Popup;
|
|
94
|
-
Status: typeof Status;
|
|
95
|
-
Empty: typeof Empty;
|
|
96
|
-
List: typeof List;
|
|
97
|
-
Item: typeof Item;
|
|
98
|
-
};
|
|
99
|
-
export {};
|
|
100
|
+
export { AddressInputRoot, Label as AddressInputLabel, Control as AddressInputControl, Input as AddressInputInput, Clear as AddressInputClear, Popup as AddressInputPopup, Status as AddressInputStatus, Empty as AddressInputEmpty, List as AddressInputList, Item as AddressInputItem, };
|
package/dist/address-input.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
import { Autocomplete, AutocompleteClear, AutocompleteContent, AutocompleteEmpty, AutocompleteInput, AutocompleteItem, AutocompleteLabel, AutocompleteList, AutocompleteStatus, } from "@ui-sdk/react/autocomplete";
|
|
3
4
|
import { createContext, Fragment, use, useCallback, useMemo, useRef, useState, } from "react";
|
|
@@ -163,32 +164,6 @@ Status.displayName = "AddressInput.Status";
|
|
|
163
164
|
Empty.displayName = "AddressInput.Empty";
|
|
164
165
|
List.displayName = "AddressInput.List";
|
|
165
166
|
Item.displayName = "AddressInput.Item";
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
*
|
|
170
|
-
* ```tsx
|
|
171
|
-
* <AddressInput onSelect={(selection) => save(selection.details)}>
|
|
172
|
-
* <AddressInput.Label>Address</AddressInput.Label>
|
|
173
|
-
* <AddressInput.Control>
|
|
174
|
-
* <AddressInput.Input />
|
|
175
|
-
* <AddressInput.Clear>×</AddressInput.Clear>
|
|
176
|
-
* </AddressInput.Control>
|
|
177
|
-
* <AddressInput.Popup>
|
|
178
|
-
* <AddressInput.Empty>No addresses found.</AddressInput.Empty>
|
|
179
|
-
* <AddressInput.List />
|
|
180
|
-
* </AddressInput.Popup>
|
|
181
|
-
* </AddressInput>
|
|
182
|
-
* ```
|
|
183
|
-
*/
|
|
184
|
-
export const AddressInput = Object.assign(AddressInputRoot, {
|
|
185
|
-
Label,
|
|
186
|
-
Control,
|
|
187
|
-
Input,
|
|
188
|
-
Clear,
|
|
189
|
-
Popup,
|
|
190
|
-
Status,
|
|
191
|
-
Empty,
|
|
192
|
-
List,
|
|
193
|
-
Item,
|
|
194
|
-
});
|
|
167
|
+
// One export per part, so a Server Component gets a client reference for each.
|
|
168
|
+
// `index.ts` puts them together as `AddressInput`.
|
|
169
|
+
export { AddressInputRoot, Label as AddressInputLabel, Control as AddressInputControl, Input as AddressInputInput, Clear as AddressInputClear, Popup as AddressInputPopup, Status as AddressInputStatus, Empty as AddressInputEmpty, List as AddressInputList, Item as AddressInputItem, };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
import { AddressInputClear, AddressInputControl, AddressInputEmpty, AddressInputInput, AddressInputItem, AddressInputLabel, AddressInputList, AddressInputPopup, AddressInputRoot, AddressInputStatus } from "./address-input.tsx";
|
|
2
|
+
/**
|
|
3
|
+
* Headless address autosuggest for KDS Adressevælger. Every part takes `className` and
|
|
4
|
+
* `style` (plain, or a function of the part's state) and its element's props.
|
|
5
|
+
*
|
|
6
|
+
* ```tsx
|
|
7
|
+
* <AddressInput onSelect={(selection) => save(selection.details)}>
|
|
8
|
+
* <AddressInput.Label>Address</AddressInput.Label>
|
|
9
|
+
* <AddressInput.Control>
|
|
10
|
+
* <AddressInput.Input />
|
|
11
|
+
* <AddressInput.Clear>×</AddressInput.Clear>
|
|
12
|
+
* </AddressInput.Control>
|
|
13
|
+
* <AddressInput.Popup>
|
|
14
|
+
* <AddressInput.Empty>No addresses found.</AddressInput.Empty>
|
|
15
|
+
* <AddressInput.List />
|
|
16
|
+
* </AddressInput.Popup>
|
|
17
|
+
* </AddressInput>
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const AddressInput: typeof AddressInputRoot & {
|
|
21
|
+
Label: typeof AddressInputLabel;
|
|
22
|
+
Control: typeof AddressInputControl;
|
|
23
|
+
Input: typeof AddressInputInput;
|
|
24
|
+
Clear: typeof AddressInputClear;
|
|
25
|
+
Popup: typeof AddressInputPopup;
|
|
26
|
+
Status: typeof AddressInputStatus;
|
|
27
|
+
Empty: typeof AddressInputEmpty;
|
|
28
|
+
List: typeof AddressInputList;
|
|
29
|
+
Item: typeof AddressInputItem;
|
|
30
|
+
};
|
|
31
|
+
export { useAddressInput, type AddressInputClearProps, type AddressInputControlProps, type AddressInputEmptyProps, type AddressInputInputProps, type AddressInputItemProps, type AddressInputLabelProps, type AddressInputListProps, type AddressInputPopupProps, type AddressInputProps, type AddressInputStatusProps, type UseAddressInputResult, } from "./address-input.tsx";
|
|
2
32
|
export { useAddressAutosuggest, type UseAddressAutosuggestResult, } from "./use-address-autosuggest.ts";
|
|
3
33
|
export { suggestionKey } from "@dk-address/client";
|
|
4
34
|
export type { AccessAddress, Address, SearchKind, Suggestion, SuggestionType, } from "@dk-address/client";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
import { AddressInputClear, AddressInputControl, AddressInputEmpty, AddressInputInput, AddressInputItem, AddressInputLabel, AddressInputList, AddressInputPopup, AddressInputRoot, AddressInputStatus, } from "./address-input.js";
|
|
2
|
+
// Put together outside the "use client" module: there, a Server Component would read
|
|
3
|
+
// `AddressInput.Label` as undefined. Here, each part is a client reference of its own.
|
|
4
|
+
/**
|
|
5
|
+
* Headless address autosuggest for KDS Adressevælger. Every part takes `className` and
|
|
6
|
+
* `style` (plain, or a function of the part's state) and its element's props.
|
|
7
|
+
*
|
|
8
|
+
* ```tsx
|
|
9
|
+
* <AddressInput onSelect={(selection) => save(selection.details)}>
|
|
10
|
+
* <AddressInput.Label>Address</AddressInput.Label>
|
|
11
|
+
* <AddressInput.Control>
|
|
12
|
+
* <AddressInput.Input />
|
|
13
|
+
* <AddressInput.Clear>×</AddressInput.Clear>
|
|
14
|
+
* </AddressInput.Control>
|
|
15
|
+
* <AddressInput.Popup>
|
|
16
|
+
* <AddressInput.Empty>No addresses found.</AddressInput.Empty>
|
|
17
|
+
* <AddressInput.List />
|
|
18
|
+
* </AddressInput.Popup>
|
|
19
|
+
* </AddressInput>
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export const AddressInput = Object.assign(AddressInputRoot, {
|
|
23
|
+
Label: AddressInputLabel,
|
|
24
|
+
Control: AddressInputControl,
|
|
25
|
+
Input: AddressInputInput,
|
|
26
|
+
Clear: AddressInputClear,
|
|
27
|
+
Popup: AddressInputPopup,
|
|
28
|
+
Status: AddressInputStatus,
|
|
29
|
+
Empty: AddressInputEmpty,
|
|
30
|
+
List: AddressInputList,
|
|
31
|
+
Item: AddressInputItem,
|
|
32
|
+
});
|
|
33
|
+
export { useAddressInput, } from "./address-input.js";
|
|
2
34
|
export { useAddressAutosuggest, } from "./use-address-autosuggest.js";
|
|
3
35
|
export { suggestionKey } from "@dk-address/client";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dk-address/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Unstyled React address autocomplete for Danish addresses, built on KDS Adressevælger.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"address",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"test": "vitest run"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@dk-address/client": "0.1.
|
|
46
|
-
"@dk-address/core": "0.1.
|
|
45
|
+
"@dk-address/client": "0.1.1",
|
|
46
|
+
"@dk-address/core": "0.1.1",
|
|
47
47
|
"@ui-sdk/core": "0.1.0-beta.17",
|
|
48
48
|
"@ui-sdk/react": "0.1.0-beta.17"
|
|
49
49
|
},
|