From 4fac809c9b3bad38f5b0a1e9dd3e477856bf1c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=BDdila?= Date: Thu, 19 Dec 2024 09:56:17 +0100 Subject: [PATCH] Added clearListOnPick and keepListOpen options; improved UX (#73) * implemented `clearListOnPick` option * implemented `keepListOpen` * improved UX * fixed react events * fixed UX * changed styles for picked item in the list * improved UX --- deno.lock | 56 +++++++++++ examples/react/main.tsx | 52 +++++++++- examples/react/style.css | 4 + index.html | 6 +- src/FeatureItem.svelte | 46 ++++++++- src/GeocodingControl.svelte | 188 ++++++++++++++++++++++------------- src/leaflet-controller.ts | 6 +- src/maplibregl-controller.ts | 6 +- src/openlayers-controller.ts | 8 +- src/react.ts | 12 ++- src/types.ts | 16 ++- 11 files changed, 315 insertions(+), 85 deletions(-) create mode 100644 deno.lock diff --git a/deno.lock b/deno.lock new file mode 100644 index 0000000..7056642 --- /dev/null +++ b/deno.lock @@ -0,0 +1,56 @@ +{ + "version": "4", + "redirects": { + "https://cdn.skypack.dev/chroma-js": "https://cdn.skypack.dev/new/chroma-js@v3.1.2/dist=es2019", + "https://cdn.skypack.dev/new/chroma-js@v3.1.2/dist=es2019": "https://cdn.skypack.dev/error/build:chroma-js@v3.1.2-QwkMr4VCpNO0CLkbGUyZ" + }, + "remote": { + "https://cdn.skypack.dev/error/build:chroma-js@v3.1.2-QwkMr4VCpNO0CLkbGUyZ": "97aee30af87a5f6905a6af1a3eb1ed523426de337cf7d92ed3604a6b289eca8b" + }, + "workspace": { + "packageJson": { + "dependencies": [ + "npm:@maptiler/sdk@^2.5.0", + "npm:@sveltejs/package@^2.3.7", + "npm:@sveltejs/vite-plugin-svelte@^3.1.2", + "npm:@tsconfig/svelte@^5.0.4", + "npm:@turf/bbox@^7.1.0", + "npm:@turf/clone@^7.1.0", + "npm:@turf/difference@^7.1.0", + "npm:@turf/flatten@^7.1.0", + "npm:@turf/union@^7.1.0", + "npm:@types/geojson@^7946.0.15", + "npm:@types/leaflet@^1.9.15", + "npm:@types/node@^22.10.1", + "npm:@types/react-dom@^19.0.2", + "npm:@types/react@^19.0.1", + "npm:concurrently@^9.1.0", + "npm:dotenv@^16.4.7", + "npm:eslint-plugin-svelte@^2.46.1", + "npm:eslint@^9.16.0", + "npm:esm-env@^1.2.1", + "npm:geo-coordinates-parser@^1.7.4", + "npm:globals@^15.13.0", + "npm:husky@^9.1.7", + "npm:leaflet@^1.9.4", + "npm:lint-staged@^15.2.11", + "npm:maplibre-gl@^4.7.1", + "npm:ol@10.3", + "npm:prettier-plugin-organize-imports@^4.1.0", + "npm:prettier-plugin-svelte@^3.3.2", + "npm:prettier@^3.4.2", + "npm:react-dom@19", + "npm:react@19", + "npm:replace-in-file@^8.2.0", + "npm:sass@^1.82.0", + "npm:svelte-check@^4.1.1", + "npm:svelte-preprocess@^6.0.3", + "npm:svelte@^4.2.19", + "npm:tslib@^2.8.1", + "npm:typescript-eslint@^8.18.0", + "npm:typescript@^5.7.2", + "npm:vite@^5.4.11" + ] + } + } +} diff --git a/examples/react/main.tsx b/examples/react/main.tsx index 29d6315..9b0fe6a 100644 --- a/examples/react/main.tsx +++ b/examples/react/main.tsx @@ -31,11 +31,19 @@ function App() { const consoleRef = useRef(null); - const [collapsed, setCollapsed] = useState(false); + const [collapsed, setCollapsed] = useState(false); const [reverse, setReverse] = useState("never"); - const [clearOnBlur, setClearOnBlur] = useState(false); + const [clearOnBlur, setClearOnBlur] = useState(false); + + const [clearListOnPick, setClearListOnPick] = useState(false); + + const [keepListOpen, setKeepListOpen] = useState(false); + + const [flyToSelected, setFlyToSelected] = useState(false); + + const [selectFirst, setSelectFirst] = useState(true); const map = useRef(null); @@ -105,8 +113,12 @@ function App() { onReverseToggle={(data) => log("reverseToggle", data)} onResponse={(data) => log("response", data)} clearOnBlur={clearOnBlur} + clearListOnPick={clearListOnPick} + keepListOpen={keepListOpen} iconsBaseUrl="/icons/" enableReverse={reverse} + flyToSelected={flyToSelected} + selectFirst={selectFirst} /> )} @@ -128,6 +140,42 @@ function App() { Clear on blur + + + + + + + +