@open-pioneer/search 1.0.0 → 1.2.0-dev.20251128143231
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/CHANGELOG.md +29 -0
- package/README.md +8 -0
- package/Search.js +10 -13
- package/Search.js.map +1 -1
- package/SearchApiImpl.d.ts +2 -1
- package/SearchApiImpl.js +6 -1
- package/SearchApiImpl.js.map +1 -1
- package/api.d.ts +6 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @open-pioneer/search
|
|
2
2
|
|
|
3
|
+
## 1.2.0-dev.20251128143231
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1b5632a: Provide a search API method to programmatically set the serach value input without triggering any search actions. See README for Details.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 279ca67: Use `workspace:*` instead of `workspace:^` for local package references as default. This ensures that trails packages from this repository are always referenced with their exact version to avoid potential issues with version mismatches. If a project specifically wants to use other versions for some trails packages, a pnpm override can be used to force other versions.
|
|
12
|
+
- Updated dependencies [279ca67]
|
|
13
|
+
- @open-pioneer/map@1.2.0-dev.20251128143231
|
|
14
|
+
|
|
15
|
+
## 1.1.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 10338fa: Update OpenLayers to 10.7.0
|
|
20
|
+
- a8b8a36: Update trails core packages to 4.3.0
|
|
21
|
+
- 10338fa: Update Chakra to 3.29.0
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [fce7fa9]
|
|
26
|
+
- Updated dependencies [10338fa]
|
|
27
|
+
- Updated dependencies [a8b8a36]
|
|
28
|
+
- Updated dependencies [10338fa]
|
|
29
|
+
- Updated dependencies [c38b619]
|
|
30
|
+
- @open-pioneer/map@1.1.0
|
|
31
|
+
|
|
3
32
|
## 1.0.0
|
|
4
33
|
|
|
5
34
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -61,6 +61,7 @@ import { Search, SearchClearEvent, SearchSelectEvent } from "@open-pioneer/searc
|
|
|
61
61
|
The search API allows programmatic access to the search component.
|
|
62
62
|
|
|
63
63
|
Currently, the search API provides a method to clear the search input field.
|
|
64
|
+
Additionally, it provides a method for setting the search input value programmatically without triggering any actions.
|
|
64
65
|
To receive the API, listen to the `onReady` event which provides the `SearchApi` as a parameter once the search component is ready to use:
|
|
65
66
|
|
|
66
67
|
```tsx
|
|
@@ -98,6 +99,13 @@ function onSearchCleared(clearEvent: SearchClearEvent) {
|
|
|
98
99
|
>
|
|
99
100
|
reset search input
|
|
100
101
|
</Button>
|
|
102
|
+
<Button
|
|
103
|
+
onClick={() => {
|
|
104
|
+
searchApiRef.current?.setInputValue("Münster"); // use the API to set the search input value
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
set search input
|
|
108
|
+
</Button>
|
|
101
109
|
```
|
|
102
110
|
|
|
103
111
|
### Positioning the search bar
|
package/Search.js
CHANGED
|
@@ -5,7 +5,7 @@ import { useMapModelValue } from '@open-pioneer/map';
|
|
|
5
5
|
import { useCommonComponentProps, useEvent } from '@open-pioneer/react-utils';
|
|
6
6
|
import { Select } from 'chakra-react-select';
|
|
7
7
|
import { useIntl } from './_virtual/_virtual-pioneer-module_react-hooks.js';
|
|
8
|
-
import { useRef, useState, useEffect, useReducer,
|
|
8
|
+
import { useRef, useState, useEffect, useReducer, useMemo } from 'react';
|
|
9
9
|
import { GroupComp, ClearIndicator, IndicatorsContainer, ValueContainer, LoadingMessage, NoOptionsMessage, HighlightOption, SingleValue, Input, MenuComp } from './CustomComponents.js';
|
|
10
10
|
import { SearchController } from './SearchController.js';
|
|
11
11
|
import { SearchApiImpl } from './SearchApiImpl.js';
|
|
@@ -64,7 +64,7 @@ const Search = (props) => {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
);
|
|
67
|
-
useSearchApi(onReady, onDisposed, clearInput);
|
|
67
|
+
useSearchApi(onReady, onDisposed, clearInput, onInputChanged);
|
|
68
68
|
const selectRef = useRef(null);
|
|
69
69
|
return /* @__PURE__ */ jsxs(Box, { ...containerProps, children: [
|
|
70
70
|
/* @__PURE__ */ jsx(
|
|
@@ -268,16 +268,13 @@ function useSearchState(controller) {
|
|
|
268
268
|
}
|
|
269
269
|
});
|
|
270
270
|
});
|
|
271
|
-
const onResultConfirmed =
|
|
271
|
+
const onResultConfirmed = useEvent((option) => {
|
|
272
272
|
dispatch({ kind: "select-option", option });
|
|
273
|
-
}
|
|
274
|
-
const onInputChanged =
|
|
275
|
-
(newValue)
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
},
|
|
279
|
-
[startSearch]
|
|
280
|
-
);
|
|
273
|
+
});
|
|
274
|
+
const onInputChanged = useEvent((newValue) => {
|
|
275
|
+
dispatch({ kind: "input", query: newValue });
|
|
276
|
+
startSearch(newValue);
|
|
277
|
+
});
|
|
281
278
|
return {
|
|
282
279
|
input: state.query,
|
|
283
280
|
search: state.search,
|
|
@@ -314,10 +311,10 @@ function mapSuggestions(suggestions) {
|
|
|
314
311
|
);
|
|
315
312
|
return options;
|
|
316
313
|
}
|
|
317
|
-
function useSearchApi(onReady, onDisposed, clearInput) {
|
|
314
|
+
function useSearchApi(onReady, onDisposed, clearInput, setInputValue) {
|
|
318
315
|
const apiRef = useRef(null);
|
|
319
316
|
if (!apiRef.current) {
|
|
320
|
-
apiRef.current = new SearchApiImpl(clearInput);
|
|
317
|
+
apiRef.current = new SearchApiImpl(clearInput, setInputValue);
|
|
321
318
|
}
|
|
322
319
|
const api = apiRef.current;
|
|
323
320
|
const readyTrigger = useEvent(() => {
|
package/Search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Search.js","sources":["Search.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Box, chakra, Portal, useToken } from \"@chakra-ui/react\";\nimport { createLogger, isAbortError } from \"@open-pioneer/core\";\nimport { MapModel, MapModelProps, useMapModelValue } from \"@open-pioneer/map\";\nimport { CommonComponentProps, useCommonComponentProps, useEvent } from \"@open-pioneer/react-utils\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport {\n ActionMeta,\n AriaLiveMessages,\n AriaOnChange,\n AriaOnFocus,\n ChakraStylesConfig,\n InputActionMeta,\n Select,\n SelectInstance,\n Props as SelectProps,\n SingleValue\n} from \"chakra-react-select\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { FC, useCallback, useEffect, useMemo, useReducer, useRef, useState } from \"react\";\nimport {\n ClearIndicator,\n GroupComp,\n HighlightOption,\n IndicatorsContainer,\n Input,\n LoadingMessage,\n MenuComp,\n NoOptionsMessage,\n SingleValue as SingleValueComp,\n ValueContainer\n} from \"./CustomComponents\";\nimport { SearchController, SuggestionGroup } from \"./SearchController\";\nimport {\n SearchClearEvent,\n SearchApi,\n SearchDisposedEvent,\n SearchReadyEvent,\n SearchResult,\n SearchSelectEvent,\n SearchSource,\n SearchClearTrigger\n} from \"./api\";\nimport { SearchApiImpl } from \"./SearchApiImpl\";\n\nconst LOG = createLogger(\"search:Search\");\n\nexport interface SearchOption {\n /** Unique value for this option. */\n value: string;\n\n /** Display text shown in menu. */\n label: string;\n\n /** Search source that returned the suggestion. */\n source: SearchSource;\n\n /** The raw result from the search source. */\n result: SearchResult;\n}\n\nexport interface SearchGroupOption {\n /** Display text shown in menu. */\n label: string;\n\n /** Set of options that belong to this group. */\n options: SearchOption[];\n}\n\n/**\n * Properties supported by the {@link Search} component.\n */\nexport interface SearchProps extends CommonComponentProps, MapModelProps {\n /**\n * Data sources to be searched on.\n */\n sources: SearchSource[];\n\n /**\n * Typing delay (in milliseconds) before the async search query starts after the user types in the search term.\n * Defaults to `200`.\n */\n searchTypingDelay?: number;\n\n /**\n * The maximum number of results shown per group.\n * Defaults to `5`.\n */\n maxResultsPerGroup?: number;\n\n /**\n * The placeholder text shown in the search input field when it is empty.\n * Defaults to a generic (and localized) hint.\n */\n placeholder?: string;\n\n /**\n * This event handler will be called when the user selects a search result.\n */\n onSelect?: (event: SearchSelectEvent) => void;\n\n /**\n * This event handler will be called when the user clears the search input.\n */\n onClear?: (event: SearchClearEvent) => void;\n\n /**\n * Callback that is triggered once when the search is initialized.\n * The search API can be accessed by the `api` property of the {@link SearchReadyEvent}.\n */\n onReady?: (event: SearchReadyEvent) => void;\n\n /**\n * Callback that is triggered once when the search is disposed and unmounted.\n */\n onDisposed?: (event: SearchDisposedEvent) => void;\n}\n\n/**\n * A component that allows the user to search a given set of {@link SearchSource | SearchSources}.\n */\nexport const Search: FC<SearchProps> = (props) => {\n const {\n sources,\n searchTypingDelay,\n maxResultsPerGroup,\n onSelect,\n onClear,\n onReady,\n onDisposed\n } = props;\n const { containerProps } = useCommonComponentProps(\"search\", props);\n const map = useMapModelValue(props);\n const intl = useIntl();\n const controller = useController(sources, searchTypingDelay, maxResultsPerGroup, map);\n const { input, search, selectedOption, onInputChanged, onResultConfirmed } =\n useSearchState(controller);\n\n const chakraStyles = useChakraStyles();\n const ariaMessages = useAriaMessages(intl);\n const components = useCustomComponents();\n\n const portalDiv = useRef<HTMLDivElement>(null);\n\n const handleInputChange = useEvent((newValue: string, actionMeta: InputActionMeta) => {\n // Only update the input if the user actually typed something.\n // This keeps the input content if the user focuses another element or if the menu is closed.\n if (actionMeta.action === \"input-change\") {\n onInputChanged(newValue);\n }\n });\n\n const clearInput = useEvent((trigger: SearchClearTrigger) => {\n // Updates the input field\n onInputChanged(\"\");\n\n // the next two lines are a workaround for the open bug in react-select regarding the\n // cursor not being shown after clearing, although the component is focussed:\n // https://github.com/JedWatson/react-select/issues/3871\n if (trigger === \"user\") {\n selectRef.current?.blur();\n selectRef.current?.focus();\n }\n\n onClear?.({ trigger: trigger });\n });\n\n const handleSelectChange = useEvent(\n (value: SingleValue<SearchOption>, actionMeta: ActionMeta<SearchOption>) => {\n switch (actionMeta.action) {\n case \"select-option\":\n if (value) {\n // Updates the input field with the option label\n onResultConfirmed(value);\n onSelect?.({\n source: value.source,\n result: value.result\n });\n }\n break;\n case \"clear\":\n clearInput(\"user\");\n break;\n default:\n LOG.debug(`Unhandled action type '${actionMeta.action}'.`);\n break;\n }\n }\n );\n\n useSearchApi(onReady, onDisposed, clearInput);\n\n const selectRef = useRef<SelectInstance<SearchOption, false, SearchGroupOption>>(null);\n return (\n <Box {...containerProps}>\n <Select<SearchOption, false, SearchGroupOption>\n className=\"search-component\"\n classNamePrefix=\"react-select\"\n ref={selectRef}\n inputValue={input}\n onInputChange={handleInputChange}\n aria-label={intl.formatMessage({ id: \"ariaLabel.search\" })}\n ariaLiveMessages={ariaMessages}\n selectedOptionStyle=\"color\"\n selectedOptionColorPalette=\"colorPalette\"\n chakraStyles={chakraStyles}\n isClearable={true}\n placeholder={props.placeholder ?? intl.formatMessage({ id: \"searchPlaceholder\" })}\n closeMenuOnSelect={true}\n isLoading={search.kind === \"loading\"}\n options={search.kind === \"ready\" ? search.results : undefined}\n filterOption={() => true} // always show all options (don't filter based on input text)\n tabSelectsValue={false}\n components={components}\n onChange={handleSelectChange}\n value={selectedOption}\n menuPortalTarget={portalDiv.current}\n />\n <Portal>\n <chakra.div ref={portalDiv} className=\"search-component-menu\" />\n </Portal>\n </Box>\n );\n};\n\n/**\n * Provides custom aria messages for the select component.\n */\nfunction useAriaMessages(\n intl: PackageIntl\n): AriaLiveMessages<SearchOption, false, SearchGroupOption> {\n return useMemo(() => {\n /**\n * Method to create Aria-String for focus-Event\n */\n const onFocus: AriaOnFocus<SearchOption> = () => {\n //no aria string for focus-events because in some screen readers (NVDA) and browsers (Chrome) updating the aria string causes the instructions to be read out again each time a select option is focused\n return \"\";\n };\n\n /**\n * Method to create Aria-String for value-change-Event\n */\n const onChange: AriaOnChange<SearchOption, boolean> = () => {\n //no aria string for change-events because in some screen readers (NVDA) and browsers (Chrome) updating the aria string causes the instructions to be read out again each time a select option is focused\n return \"\";\n };\n\n /**\n * Method to create Aria-String for instruction\n */\n const guidance = () => {\n return `${intl.formatMessage({ id: \"ariaLabel.instructions\" })}`;\n };\n\n /**\n * Method to create Aria-String for result length\n */\n const onFilter = () => {\n return \"\";\n };\n\n return {\n onFocus,\n onChange,\n guidance,\n onFilter\n };\n }, [intl]);\n}\n\n/**\n * Customizes the inner components used by the select component.\n */\nfunction useCustomComponents(): SelectProps<SearchOption, false, SearchGroupOption>[\"components\"] {\n return useMemo(() => {\n return {\n Menu: MenuComp,\n Input: Input,\n SingleValue: SingleValueComp,\n Option: HighlightOption,\n NoOptionsMessage: NoOptionsMessage,\n LoadingMessage: LoadingMessage,\n ValueContainer: ValueContainer,\n IndicatorsContainer: IndicatorsContainer,\n ClearIndicator: ClearIndicator,\n Group: GroupComp\n };\n }, []);\n}\n\n/**\n * Customizes components styles within the select component.\n */\nfunction useChakraStyles() {\n const [groupHeadingBg, focussedItemBg, selectedItemBg] = useToken(\"colors\", [\n \"colorPalette.100\",\n \"colorPalette.50\",\n \"colorPalette.500\"\n ]);\n return useMemo(() => {\n const chakraStyles: ChakraStylesConfig<SearchOption, false, SearchGroupOption> = {\n control: (provided) => ({\n ...provided,\n paddingInline: 0\n }),\n inputContainer: (provided) => ({\n ...provided,\n gridTemplateAreas: \"'area area area'\",\n display: \"grid\"\n }),\n indicatorsContainer: (provided) => ({\n ...provided,\n // pointerEvents none can sneak in via chakra theme from <Select />\n pointerEvents: \"auto\"\n }),\n input: (provided) => ({\n ...provided,\n gridArea: \"area\"\n }),\n groupHeading: (provided) => ({\n ...provided,\n backgroundColor: groupHeadingBg,\n padding: \"8px 12px\",\n // make Header look like normal options:\n fontSize: \"inherit\",\n fontWeight: \"inherit\"\n }),\n option: (provided) => ({\n ...provided,\n backgroundColor: \"inherit\",\n _highlighted: {\n backgroundColor: focussedItemBg\n },\n _selected: {\n // Prevent white on white\n backgroundColor: selectedItemBg\n }\n }),\n dropdownIndicator: (provided) => ({\n ...provided,\n display: \"none\" // always hide\n })\n };\n return chakraStyles;\n }, [groupHeadingBg, focussedItemBg, selectedItemBg]);\n}\n\n/**\n * Creates a controller to search on the given sources.\n */\nfunction useController(\n sources: SearchSource[],\n searchTypingDelay: number | undefined,\n maxResultsPerGroup: number | undefined,\n map: MapModel\n) {\n const [controller, setController] = useState<SearchController | undefined>(undefined);\n useEffect(() => {\n const controller = new SearchController(map, sources);\n setController(controller);\n return () => {\n controller.destroy();\n setController(undefined);\n };\n }, [map, sources]);\n\n useEffect(() => {\n if (controller) {\n controller.searchTypingDelay = searchTypingDelay;\n }\n }, [controller, searchTypingDelay]);\n useEffect(() => {\n if (controller) {\n controller.maxResultsPerSource = maxResultsPerGroup;\n }\n }, [controller, maxResultsPerGroup]);\n return controller;\n}\n\ntype SearchResultsReady = {\n kind: \"ready\";\n results: SearchGroupOption[];\n};\n\ntype SearchResultsLoading = {\n kind: \"loading\";\n};\n\ntype SearchResultsState = SearchResultsReady | SearchResultsLoading;\n\n/**\n * Keeps track of the current input text, active searches and their results.\n *\n * NOTE: it would be great to merge this state handling with the search controller\n * in a future revision.\n */\nfunction useSearchState(controller: SearchController | undefined) {\n interface FullSearchState {\n query: string;\n selectedOption: SearchOption | null;\n search: SearchResultsState;\n }\n\n type Action =\n | { kind: \"input\"; query: string }\n | { kind: \"select-option\"; option: SearchOption }\n | { kind: \"load-results\" }\n | { kind: \"accept-results\"; results: SearchGroupOption[] };\n\n const [state, dispatch] = useReducer(\n (current: FullSearchState, action: Action): FullSearchState => {\n switch (action.kind) {\n case \"input\":\n return {\n ...current,\n query: action.query,\n selectedOption: null\n };\n case \"select-option\":\n return {\n ...current,\n selectedOption: action.option,\n query: action.option.label\n };\n case \"load-results\":\n return {\n ...current,\n search: {\n kind: \"loading\"\n }\n };\n case \"accept-results\":\n return {\n ...current,\n search: {\n kind: \"ready\",\n results: action.results\n }\n };\n }\n },\n undefined,\n (): FullSearchState => ({\n query: \"\",\n selectedOption: null,\n search: {\n kind: \"ready\",\n results: []\n }\n })\n );\n\n // Stores the promise for the current search.\n // Any results from outdated searches are ignored.\n const currentSearch = useRef<Promise<unknown>>(undefined);\n const startSearch = useEvent((query: string) => {\n if (!controller) {\n currentSearch.current = undefined;\n dispatch({ kind: \"accept-results\", results: [] });\n return;\n }\n\n LOG.isDebug() && LOG.debug(`Starting new search for query ${JSON.stringify(query)}.`);\n dispatch({ kind: \"load-results\" });\n const promise = (currentSearch.current = search(controller, query).then((results) => {\n // Check if this job is still current\n if (currentSearch.current === promise) {\n dispatch({ kind: \"accept-results\", results });\n }\n }));\n });\n\n // Called when the user confirms a search result\n const onResultConfirmed = useCallback((option: SearchOption) => {\n // Do not start a new search when the user confirms a result\n dispatch({ kind: \"select-option\", option });\n }, []);\n\n // Called when a user types into the input field\n const onInputChanged = useCallback(\n (newValue: string) => {\n // Trigger a new search if the user changes the query by typing\n dispatch({ kind: \"input\", query: newValue });\n startSearch(newValue);\n },\n [startSearch]\n );\n\n return {\n input: state.query,\n search: state.search,\n selectedOption: state.selectedOption,\n onResultConfirmed,\n onInputChanged\n };\n}\n\nasync function search(controller: SearchController, query: string): Promise<SearchGroupOption[]> {\n let suggestions: SuggestionGroup[];\n try {\n suggestions = await controller.search(query);\n } catch (error) {\n if (!isAbortError(error)) {\n LOG.error(`Search failed`, error);\n }\n suggestions = [];\n }\n return mapSuggestions(suggestions);\n}\n\nfunction mapSuggestions(suggestions: SuggestionGroup[]): SearchGroupOption[] {\n const options = suggestions.map(\n (group, groupIndex): SearchGroupOption => ({\n label: group.label,\n options: group.results.map((suggestion): SearchOption => {\n return {\n value: `${groupIndex}-${suggestion.id}`,\n label: suggestion.label,\n source: group.source,\n result: suggestion\n };\n })\n })\n );\n return options;\n}\n\n// Note: `clearInput` must be stable because only the initial value is used to construct the API instance at this time.\nfunction useSearchApi(\n onReady: ((event: SearchReadyEvent) => void) | undefined,\n onDisposed: ((event: SearchDisposedEvent) => void) | undefined,\n clearInput: (trigger: SearchClearTrigger) => void\n) {\n const apiRef = useRef<SearchApi>(null);\n if (!apiRef.current) {\n apiRef.current = new SearchApiImpl(clearInput);\n }\n\n const api = apiRef.current;\n\n const readyTrigger = useEvent(() => {\n onReady?.({\n api\n });\n });\n\n const disposeTrigger = useEvent(() => {\n onDisposed?.({});\n });\n\n // Trigger ready / dispose on mount / unmount, but if the callbacks change.\n // useEvent() returns a stable function reference.\n useEffect(() => {\n readyTrigger();\n return disposeTrigger;\n }, [readyTrigger, disposeTrigger]);\n}\n"],"names":["search","SingleValueComp","controller"],"mappings":";;;;;;;;;;;;AA8CA,MAAM,GAAA,GAAM,aAAa,eAAe,CAAA;AA4EjC,MAAM,MAAA,GAA0B,CAAC,KAAA,KAAU;AAC9C,EAAA,MAAM;AAAA,IACF,OAAA;AAAA,IACA,iBAAA;AAAA,IACA,kBAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACJ,GAAI,KAAA;AACJ,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,uBAAA,CAAwB,UAAU,KAAK,CAAA;AAClE,EAAA,MAAM,GAAA,GAAM,iBAAiB,KAAK,CAAA;AAClC,EAAA,MAAM,OAAO,OAAA,EAAQ;AACrB,EAAA,MAAM,UAAA,GAAa,aAAA,CAAc,OAAA,EAAS,iBAAA,EAAmB,oBAAoB,GAAG,CAAA;AACpF,EAAA,MAAM,EAAE,OAAO,MAAA,EAAAA,OAAAA,EAAQ,gBAAgB,cAAA,EAAgB,iBAAA,EAAkB,GACrE,cAAA,CAAe,UAAU,CAAA;AAE7B,EAAA,MAAM,eAAe,eAAA,EAAgB;AACrC,EAAA,MAAM,YAAA,GAAe,gBAAgB,IAAI,CAAA;AACzC,EAAA,MAAM,aAAa,mBAAA,EAAoB;AAEvC,EAAA,MAAM,SAAA,GAAY,OAAuB,IAAI,CAAA;AAE7C,EAAA,MAAM,iBAAA,GAAoB,QAAA,C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,YAAA,CACL,OAAA,EACA,UAAA,EACA,UAAA,EACF;AACE,EAAA,MAAM,MAAA,GAAS,OAAkB,IAAI,CAAA;AACrC,EAAA,IAAI,CAAC,OAAO,OAAA,EAAS;AACjB,IAAA,MAAA,CAAO,OAAA,GAAU,IAAI,aAAA,CAAc,UAAU,CAAA;AAAA,EACjD;AAEA,EAAA,MAAM,MAAM,MAAA,CAAO,OAAA;AAEnB,EAAA,MAAM,YAAA,GAAe,SAAS,MAAM;AAChC,IAAA,OAAA,GAAU;AAAA,MACN;AAAA,KACH,CAAA;AAAA,EACL,CAAC,CAAA;AAED,EAAA,MAAM,cAAA,GAAiB,SAAS,MAAM;AAClC,IAAA,UAAA,GAAa,EAAE,CAAA;AAAA,EACnB,CAAC,CAAA;AAID,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,YAAA,EAAa;AACb,IAAA,OAAO,cAAA;AAAA,EACX,CAAA,EAAG,CAAC,YAAA,EAAc,cAAc,CAAC,CAAA;AACrC;;;;"}
|
|
1
|
+
{"version":3,"file":"Search.js","sources":["Search.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Box, chakra, Portal, useToken } from \"@chakra-ui/react\";\nimport { createLogger, isAbortError } from \"@open-pioneer/core\";\nimport { MapModel, MapModelProps, useMapModelValue } from \"@open-pioneer/map\";\nimport { CommonComponentProps, useCommonComponentProps, useEvent } from \"@open-pioneer/react-utils\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport {\n ActionMeta,\n AriaLiveMessages,\n AriaOnChange,\n AriaOnFocus,\n ChakraStylesConfig,\n InputActionMeta,\n Select,\n SelectInstance,\n Props as SelectProps,\n SingleValue\n} from \"chakra-react-select\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { FC, useEffect, useMemo, useReducer, useRef, useState } from \"react\";\nimport {\n ClearIndicator,\n GroupComp,\n HighlightOption,\n IndicatorsContainer,\n Input,\n LoadingMessage,\n MenuComp,\n NoOptionsMessage,\n SingleValue as SingleValueComp,\n ValueContainer\n} from \"./CustomComponents\";\nimport { SearchController, SuggestionGroup } from \"./SearchController\";\nimport {\n SearchClearEvent,\n SearchApi,\n SearchDisposedEvent,\n SearchReadyEvent,\n SearchResult,\n SearchSelectEvent,\n SearchSource,\n SearchClearTrigger\n} from \"./api\";\nimport { SearchApiImpl } from \"./SearchApiImpl\";\n\nconst LOG = createLogger(\"search:Search\");\n\nexport interface SearchOption {\n /** Unique value for this option. */\n value: string;\n\n /** Display text shown in menu. */\n label: string;\n\n /** Search source that returned the suggestion. */\n source: SearchSource;\n\n /** The raw result from the search source. */\n result: SearchResult;\n}\n\nexport interface SearchGroupOption {\n /** Display text shown in menu. */\n label: string;\n\n /** Set of options that belong to this group. */\n options: SearchOption[];\n}\n\n/**\n * Properties supported by the {@link Search} component.\n */\nexport interface SearchProps extends CommonComponentProps, MapModelProps {\n /**\n * Data sources to be searched on.\n */\n sources: SearchSource[];\n\n /**\n * Typing delay (in milliseconds) before the async search query starts after the user types in the search term.\n * Defaults to `200`.\n */\n searchTypingDelay?: number;\n\n /**\n * The maximum number of results shown per group.\n * Defaults to `5`.\n */\n maxResultsPerGroup?: number;\n\n /**\n * The placeholder text shown in the search input field when it is empty.\n * Defaults to a generic (and localized) hint.\n */\n placeholder?: string;\n\n /**\n * This event handler will be called when the user selects a search result.\n */\n onSelect?: (event: SearchSelectEvent) => void;\n\n /**\n * This event handler will be called when the user clears the search input.\n */\n onClear?: (event: SearchClearEvent) => void;\n\n /**\n * Callback that is triggered once when the search is initialized.\n * The search API can be accessed by the `api` property of the {@link SearchReadyEvent}.\n */\n onReady?: (event: SearchReadyEvent) => void;\n\n /**\n * Callback that is triggered once when the search is disposed and unmounted.\n */\n onDisposed?: (event: SearchDisposedEvent) => void;\n}\n\n/**\n * A component that allows the user to search a given set of {@link SearchSource | SearchSources}.\n */\nexport const Search: FC<SearchProps> = (props) => {\n const {\n sources,\n searchTypingDelay,\n maxResultsPerGroup,\n onSelect,\n onClear,\n onReady,\n onDisposed\n } = props;\n const { containerProps } = useCommonComponentProps(\"search\", props);\n const map = useMapModelValue(props);\n const intl = useIntl();\n const controller = useController(sources, searchTypingDelay, maxResultsPerGroup, map);\n const { input, search, selectedOption, onInputChanged, onResultConfirmed } =\n useSearchState(controller);\n\n const chakraStyles = useChakraStyles();\n const ariaMessages = useAriaMessages(intl);\n const components = useCustomComponents();\n\n const portalDiv = useRef<HTMLDivElement>(null);\n\n const handleInputChange = useEvent((newValue: string, actionMeta: InputActionMeta) => {\n // Only update the input if the user actually typed something.\n // This keeps the input content if the user focuses another element or if the menu is closed.\n if (actionMeta.action === \"input-change\") {\n onInputChanged(newValue);\n }\n });\n\n const clearInput = useEvent((trigger: SearchClearTrigger) => {\n // Updates the input field\n onInputChanged(\"\");\n\n // the next two lines are a workaround for the open bug in react-select regarding the\n // cursor not being shown after clearing, although the component is focussed:\n // https://github.com/JedWatson/react-select/issues/3871\n if (trigger === \"user\") {\n selectRef.current?.blur();\n selectRef.current?.focus();\n }\n\n onClear?.({ trigger: trigger });\n });\n\n const handleSelectChange = useEvent(\n (value: SingleValue<SearchOption>, actionMeta: ActionMeta<SearchOption>) => {\n switch (actionMeta.action) {\n case \"select-option\":\n if (value) {\n // Updates the input field with the option label\n onResultConfirmed(value);\n onSelect?.({\n source: value.source,\n result: value.result\n });\n }\n break;\n case \"clear\":\n clearInput(\"user\");\n break;\n default:\n LOG.debug(`Unhandled action type '${actionMeta.action}'.`);\n break;\n }\n }\n );\n\n useSearchApi(onReady, onDisposed, clearInput, onInputChanged);\n\n const selectRef = useRef<SelectInstance<SearchOption, false, SearchGroupOption>>(null);\n return (\n <Box {...containerProps}>\n <Select<SearchOption, false, SearchGroupOption>\n className=\"search-component\"\n classNamePrefix=\"react-select\"\n ref={selectRef}\n inputValue={input}\n onInputChange={handleInputChange}\n aria-label={intl.formatMessage({ id: \"ariaLabel.search\" })}\n ariaLiveMessages={ariaMessages}\n selectedOptionStyle=\"color\"\n selectedOptionColorPalette=\"colorPalette\"\n chakraStyles={chakraStyles}\n isClearable={true}\n placeholder={props.placeholder ?? intl.formatMessage({ id: \"searchPlaceholder\" })}\n closeMenuOnSelect={true}\n isLoading={search.kind === \"loading\"}\n options={search.kind === \"ready\" ? search.results : undefined}\n filterOption={() => true} // always show all options (don't filter based on input text)\n tabSelectsValue={false}\n components={components}\n onChange={handleSelectChange}\n value={selectedOption}\n menuPortalTarget={portalDiv.current}\n />\n <Portal>\n <chakra.div ref={portalDiv} className=\"search-component-menu\" />\n </Portal>\n </Box>\n );\n};\n\n/**\n * Provides custom aria messages for the select component.\n */\nfunction useAriaMessages(\n intl: PackageIntl\n): AriaLiveMessages<SearchOption, false, SearchGroupOption> {\n return useMemo(() => {\n /**\n * Method to create Aria-String for focus-Event\n */\n const onFocus: AriaOnFocus<SearchOption> = () => {\n //no aria string for focus-events because in some screen readers (NVDA) and browsers (Chrome) updating the aria string causes the instructions to be read out again each time a select option is focused\n return \"\";\n };\n\n /**\n * Method to create Aria-String for value-change-Event\n */\n const onChange: AriaOnChange<SearchOption, boolean> = () => {\n //no aria string for change-events because in some screen readers (NVDA) and browsers (Chrome) updating the aria string causes the instructions to be read out again each time a select option is focused\n return \"\";\n };\n\n /**\n * Method to create Aria-String for instruction\n */\n const guidance = () => {\n return `${intl.formatMessage({ id: \"ariaLabel.instructions\" })}`;\n };\n\n /**\n * Method to create Aria-String for result length\n */\n const onFilter = () => {\n return \"\";\n };\n\n return {\n onFocus,\n onChange,\n guidance,\n onFilter\n };\n }, [intl]);\n}\n\n/**\n * Customizes the inner components used by the select component.\n */\nfunction useCustomComponents(): SelectProps<SearchOption, false, SearchGroupOption>[\"components\"] {\n return useMemo(() => {\n return {\n Menu: MenuComp,\n Input: Input,\n SingleValue: SingleValueComp,\n Option: HighlightOption,\n NoOptionsMessage: NoOptionsMessage,\n LoadingMessage: LoadingMessage,\n ValueContainer: ValueContainer,\n IndicatorsContainer: IndicatorsContainer,\n ClearIndicator: ClearIndicator,\n Group: GroupComp\n };\n }, []);\n}\n\n/**\n * Customizes components styles within the select component.\n */\nfunction useChakraStyles() {\n const [groupHeadingBg, focussedItemBg, selectedItemBg] = useToken(\"colors\", [\n \"colorPalette.100\",\n \"colorPalette.50\",\n \"colorPalette.500\"\n ]);\n return useMemo(() => {\n const chakraStyles: ChakraStylesConfig<SearchOption, false, SearchGroupOption> = {\n control: (provided) => ({\n ...provided,\n paddingInline: 0\n }),\n inputContainer: (provided) => ({\n ...provided,\n gridTemplateAreas: \"'area area area'\",\n display: \"grid\"\n }),\n indicatorsContainer: (provided) => ({\n ...provided,\n // pointerEvents none can sneak in via chakra theme from <Select />\n pointerEvents: \"auto\"\n }),\n input: (provided) => ({\n ...provided,\n gridArea: \"area\"\n }),\n groupHeading: (provided) => ({\n ...provided,\n backgroundColor: groupHeadingBg,\n padding: \"8px 12px\",\n // make Header look like normal options:\n fontSize: \"inherit\",\n fontWeight: \"inherit\"\n }),\n option: (provided) => ({\n ...provided,\n backgroundColor: \"inherit\",\n _highlighted: {\n backgroundColor: focussedItemBg\n },\n _selected: {\n // Prevent white on white\n backgroundColor: selectedItemBg\n }\n }),\n dropdownIndicator: (provided) => ({\n ...provided,\n display: \"none\" // always hide\n })\n };\n return chakraStyles;\n }, [groupHeadingBg, focussedItemBg, selectedItemBg]);\n}\n\n/**\n * Creates a controller to search on the given sources.\n */\nfunction useController(\n sources: SearchSource[],\n searchTypingDelay: number | undefined,\n maxResultsPerGroup: number | undefined,\n map: MapModel\n) {\n const [controller, setController] = useState<SearchController | undefined>(undefined);\n useEffect(() => {\n const controller = new SearchController(map, sources);\n setController(controller);\n return () => {\n controller.destroy();\n setController(undefined);\n };\n }, [map, sources]);\n\n useEffect(() => {\n if (controller) {\n controller.searchTypingDelay = searchTypingDelay;\n }\n }, [controller, searchTypingDelay]);\n useEffect(() => {\n if (controller) {\n controller.maxResultsPerSource = maxResultsPerGroup;\n }\n }, [controller, maxResultsPerGroup]);\n return controller;\n}\n\ntype SearchResultsReady = {\n kind: \"ready\";\n results: SearchGroupOption[];\n};\n\ntype SearchResultsLoading = {\n kind: \"loading\";\n};\n\ntype SearchResultsState = SearchResultsReady | SearchResultsLoading;\n\n/**\n * Keeps track of the current input text, active searches and their results.\n *\n * Event handlers returned by this hook are stable references.\n *\n * NOTE: it would be great to merge this state handling with the search controller\n * in a future revision.\n */\nfunction useSearchState(controller: SearchController | undefined) {\n interface FullSearchState {\n query: string;\n selectedOption: SearchOption | null;\n search: SearchResultsState;\n }\n\n type Action =\n | { kind: \"input\"; query: string }\n | { kind: \"select-option\"; option: SearchOption }\n | { kind: \"load-results\" }\n | { kind: \"accept-results\"; results: SearchGroupOption[] };\n\n const [state, dispatch] = useReducer(\n (current: FullSearchState, action: Action): FullSearchState => {\n switch (action.kind) {\n case \"input\":\n return {\n ...current,\n query: action.query,\n selectedOption: null\n };\n case \"select-option\":\n return {\n ...current,\n selectedOption: action.option,\n query: action.option.label\n };\n case \"load-results\":\n return {\n ...current,\n search: {\n kind: \"loading\"\n }\n };\n case \"accept-results\":\n return {\n ...current,\n search: {\n kind: \"ready\",\n results: action.results\n }\n };\n }\n },\n undefined,\n (): FullSearchState => ({\n query: \"\",\n selectedOption: null,\n search: {\n kind: \"ready\",\n results: []\n }\n })\n );\n\n // Stores the promise for the current search.\n // Any results from outdated searches are ignored.\n const currentSearch = useRef<Promise<unknown>>(undefined);\n const startSearch = useEvent((query: string) => {\n if (!controller) {\n currentSearch.current = undefined;\n dispatch({ kind: \"accept-results\", results: [] });\n return;\n }\n\n LOG.isDebug() && LOG.debug(`Starting new search for query ${JSON.stringify(query)}.`);\n dispatch({ kind: \"load-results\" });\n const promise = (currentSearch.current = search(controller, query).then((results) => {\n // Check if this job is still current\n if (currentSearch.current === promise) {\n dispatch({ kind: \"accept-results\", results });\n }\n }));\n });\n\n // Called when the user confirms a search result\n const onResultConfirmed = useEvent((option: SearchOption) => {\n // Do not start a new search when the user confirms a result\n dispatch({ kind: \"select-option\", option });\n });\n\n // Called when a user types into the input field\n const onInputChanged = useEvent((newValue: string) => {\n // Trigger a new search if the user changes the query by typing\n dispatch({ kind: \"input\", query: newValue });\n startSearch(newValue);\n });\n\n return {\n input: state.query,\n search: state.search,\n selectedOption: state.selectedOption,\n onResultConfirmed,\n onInputChanged\n };\n}\n\nasync function search(controller: SearchController, query: string): Promise<SearchGroupOption[]> {\n let suggestions: SuggestionGroup[];\n try {\n suggestions = await controller.search(query);\n } catch (error) {\n if (!isAbortError(error)) {\n LOG.error(`Search failed`, error);\n }\n suggestions = [];\n }\n return mapSuggestions(suggestions);\n}\n\nfunction mapSuggestions(suggestions: SuggestionGroup[]): SearchGroupOption[] {\n const options = suggestions.map(\n (group, groupIndex): SearchGroupOption => ({\n label: group.label,\n options: group.results.map((suggestion): SearchOption => {\n return {\n value: `${groupIndex}-${suggestion.id}`,\n label: suggestion.label,\n source: group.source,\n result: suggestion\n };\n })\n })\n );\n return options;\n}\n\n// Note: `clearInput` and `setInputValue` must be stable because only the initial value is used to construct the API instance at this time.\nfunction useSearchApi(\n onReady: ((event: SearchReadyEvent) => void) | undefined,\n onDisposed: ((event: SearchDisposedEvent) => void) | undefined,\n clearInput: (trigger: SearchClearTrigger) => void,\n setInputValue: (newValue: string) => void\n) {\n const apiRef = useRef<SearchApi>(null);\n if (!apiRef.current) {\n apiRef.current = new SearchApiImpl(clearInput, setInputValue);\n }\n\n const api = apiRef.current;\n\n const readyTrigger = useEvent(() => {\n onReady?.({\n api\n });\n });\n\n const disposeTrigger = useEvent(() => {\n onDisposed?.({});\n });\n\n // Trigger ready / dispose on mount / unmount, but if the callbacks change.\n // useEvent() returns a stable function reference.\n useEffect(() => {\n readyTrigger();\n return disposeTrigger;\n }, [readyTrigger, disposeTrigger]);\n}\n"],"names":["search","SingleValueComp","controller"],"mappings":";;;;;;;;;;;;AA8CA,MAAM,GAAA,GAAM,aAAa,eAAe,CAAA;AA4EjC,MAAM,M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EACnB,CAAC,CAAA;AAID,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,YAAA,EAAa;AACb,IAAA,OAAO,cAAA;AAAA,EACX,CAAA,EAAG,CAAC,YAAA,EAAc,cAAc,CAAC,CAAA;AACrC;;;;"}
|
package/SearchApiImpl.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SearchApi, SearchClearTrigger } from "./api";
|
|
2
2
|
export declare class SearchApiImpl implements SearchApi {
|
|
3
3
|
#private;
|
|
4
|
-
constructor(clearInput: (trigger: SearchClearTrigger) => void);
|
|
4
|
+
constructor(clearInput: (trigger: SearchClearTrigger) => void, setInputValue: (newValue: string) => void);
|
|
5
5
|
resetInput(): void;
|
|
6
|
+
setInputValue(inputValue: string): void;
|
|
6
7
|
}
|
package/SearchApiImpl.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
class SearchApiImpl {
|
|
2
2
|
#clearInput;
|
|
3
|
-
|
|
3
|
+
#setInputValue;
|
|
4
|
+
constructor(clearInput, setInputValue) {
|
|
4
5
|
this.#clearInput = clearInput;
|
|
6
|
+
this.#setInputValue = setInputValue;
|
|
5
7
|
}
|
|
6
8
|
resetInput() {
|
|
7
9
|
this.#clearInput("api-reset");
|
|
8
10
|
}
|
|
11
|
+
setInputValue(inputValue) {
|
|
12
|
+
this.#setInputValue(inputValue);
|
|
13
|
+
}
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
export { SearchApiImpl };
|
package/SearchApiImpl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchApiImpl.js","sources":["SearchApiImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { SearchApi, SearchClearTrigger } from \"./api\";\n\nexport class SearchApiImpl implements SearchApi {\n #clearInput: (trigger: SearchClearTrigger) => void;\n constructor(clearInput: (trigger: SearchClearTrigger) => void) {\n this.#clearInput = clearInput;\n }\n\n resetInput() {\n this.#clearInput(\"api-reset\");\n }\n}\n"],"names":[],"mappings":"AAIO,MAAM,aAAA,CAAmC;AAAA,EAC5C,WAAA;AAAA,EACA,
|
|
1
|
+
{"version":3,"file":"SearchApiImpl.js","sources":["SearchApiImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { SearchApi, SearchClearTrigger } from \"./api\";\n\nexport class SearchApiImpl implements SearchApi {\n #clearInput: (trigger: SearchClearTrigger) => void;\n #setInputValue: (newValue: string) => void;\n\n constructor(\n clearInput: (trigger: SearchClearTrigger) => void,\n setInputValue: (newValue: string) => void\n ) {\n this.#clearInput = clearInput;\n this.#setInputValue = setInputValue;\n }\n\n resetInput() {\n this.#clearInput(\"api-reset\");\n }\n\n setInputValue(inputValue: string) {\n this.#setInputValue(inputValue);\n }\n}\n"],"names":[],"mappings":"AAIO,MAAM,aAAA,CAAmC;AAAA,EAC5C,WAAA;AAAA,EACA,cAAA;AAAA,EAEA,WAAA,CACI,YACA,aAAA,EACF;AACE,IAAA,IAAA,CAAK,WAAA,GAAc,UAAA;AACnB,IAAA,IAAA,CAAK,cAAA,GAAiB,aAAA;AAAA,EAC1B;AAAA,EAEA,UAAA,GAAa;AACT,IAAA,IAAA,CAAK,YAAY,WAAW,CAAA;AAAA,EAChC;AAAA,EAEA,cAAc,UAAA,EAAoB;AAC9B,IAAA,IAAA,CAAK,eAAe,UAAU,CAAA;AAAA,EAClC;AACJ;;;;"}
|
package/api.d.ts
CHANGED
|
@@ -114,6 +114,12 @@ export interface SearchApi {
|
|
|
114
114
|
* Clears the search input field.
|
|
115
115
|
*/
|
|
116
116
|
resetInput(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Sets the search input field to the given value.
|
|
119
|
+
* The search is not automatically triggered when setting the input value.
|
|
120
|
+
* @param inputValue The value to be set in the search input field.
|
|
121
|
+
*/
|
|
122
|
+
setInputValue(inputValue: string): void;
|
|
117
123
|
}
|
|
118
124
|
/**
|
|
119
125
|
* Event that indicates that the Search component is initialized.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/search",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.2.0-dev.20251128143231",
|
|
5
5
|
"description": "This package provides a UI component to perform a search on given search sources.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
"directory": "src/packages/search"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@chakra-ui/react": "^3.
|
|
18
|
-
"@open-pioneer/chakra-snippets": "^4.
|
|
19
|
-
"@open-pioneer/core": "^4.
|
|
20
|
-
"@open-pioneer/react-utils": "^4.
|
|
21
|
-
"@open-pioneer/runtime": "^4.
|
|
22
|
-
"chakra-react-select": "^6.1.
|
|
17
|
+
"@chakra-ui/react": "^3.29.0",
|
|
18
|
+
"@open-pioneer/chakra-snippets": "^4.3.0",
|
|
19
|
+
"@open-pioneer/core": "^4.3.0",
|
|
20
|
+
"@open-pioneer/react-utils": "^4.3.0",
|
|
21
|
+
"@open-pioneer/runtime": "^4.3.0",
|
|
22
|
+
"chakra-react-select": "^6.1.1",
|
|
23
23
|
"classnames": "^2.5.1",
|
|
24
|
-
"ol": "^10.
|
|
24
|
+
"ol": "^10.7.0",
|
|
25
25
|
"react": "^19.2.0",
|
|
26
26
|
"react-icons": "^5.5.0",
|
|
27
|
-
"@open-pioneer/map": "
|
|
27
|
+
"@open-pioneer/map": "1.2.0-dev.20251128143231"
|
|
28
28
|
},
|
|
29
29
|
"exports": {
|
|
30
30
|
"./package.json": "./package.json",
|