web_lib

Common web application libraries
git clone https://radroots.dev/git/web_lib.git
Log | Files | Refs | LICENSE

commit 3894e0fb26f6bac138c4c6a674ca9975e5583685
parent 8ba64946e771e7916caa68dc9a6cf03b56fc703c
Author: triesap <137732411+triesap@users.noreply.github.com>
Date:   Fri,  4 Apr 2025 04:43:17 +0000

apps-lib: refactor to match `@radroots/util`, temporarily removes features/views

Diffstat:
Mapps-lib/src/lib/components/button/button-label-dashed.svelte | 2+-
Mapps-lib/src/lib/components/button/button-label-glyph.svelte | 4++--
Mapps-lib/src/lib/components/button/button-layout-pair.svelte | 9+++++----
Mapps-lib/src/lib/components/button/button-layout.svelte | 11++---------
Mapps-lib/src/lib/components/button/button-round.svelte | 4++--
Mapps-lib/src/lib/components/button/button-simple-glyph.svelte | 7++-----
Mapps-lib/src/lib/components/button/button-simple.svelte | 3++-
Mapps-lib/src/lib/components/button/glyph-button-simple.svelte | 3+--
Mapps-lib/src/lib/components/button/glyph-button.svelte | 3++-
Mapps-lib/src/lib/components/carousel/carousel-flow-item.svelte | 3++-
Mapps-lib/src/lib/components/carousel/carousel-flow.svelte | 4++--
Mapps-lib/src/lib/components/carousel/carousel-item.svelte | 3++-
Mapps-lib/src/lib/components/carousel/carousel.svelte | 4++--
Mapps-lib/src/lib/components/envelope/map-location-select-envelope.svelte | 15+++++++++------
Mapps-lib/src/lib/components/form/entry-line-idb.svelte | 10++++++----
Mapps-lib/src/lib/components/form/entry-line.svelte | 10++++++----
Mapps-lib/src/lib/components/form/entry-multiline.svelte | 4++--
Mapps-lib/src/lib/components/form/entry-select.svelte | 10++++++++--
Mapps-lib/src/lib/components/form/entry-wrap.svelte | 8++------
Mapps-lib/src/lib/components/form/form-entry-input.svelte | 4++--
Mapps-lib/src/lib/components/form/form-entry-price.svelte | 2+-
Mapps-lib/src/lib/components/form/form-entry-quantity.svelte | 10++++++++--
Mapps-lib/src/lib/components/form/form-entry-select-input.svelte | 13+++++++++----
Mapps-lib/src/lib/components/form/form-entry-select.svelte | 10++++++----
Mapps-lib/src/lib/components/form/form-entry-textarea.svelte | 8++++++--
Mapps-lib/src/lib/components/form/form-line-ledger-select.svelte | 12+++++++-----
Mapps-lib/src/lib/components/form/form-line-ledger.svelte | 10+++++++---
Mapps-lib/src/lib/components/form/form-review-display.svelte | 9++-------
Mapps-lib/src/lib/components/form/trade_field_display_kv.svelte | 9++-------
Mapps-lib/src/lib/components/glyph/glyph-circle.svelte | 4++--
Mapps-lib/src/lib/components/glyph/glyph.svelte | 3++-
Mapps-lib/src/lib/components/label/label-display.svelte | 3++-
Mapps-lib/src/lib/components/layout/layout-page.svelte | 3++-
Mapps-lib/src/lib/components/layout/layout-trellis-line.svelte | 8++------
Mapps-lib/src/lib/components/layout/layout-trellis.svelte | 3++-
Mapps-lib/src/lib/components/layout/layout-view.svelte | 10++++++++--
Mapps-lib/src/lib/components/lib/fade.svelte | 3++-
Mapps-lib/src/lib/components/lib/image-blob.svelte | 2+-
Mapps-lib/src/lib/components/lib/image-path.svelte | 3++-
Mapps-lib/src/lib/components/lib/input-value.svelte | 8++------
Mapps-lib/src/lib/components/lib/input.svelte | 9++-------
Mapps-lib/src/lib/components/lib/label-swap.svelte | 8++------
Mapps-lib/src/lib/components/lib/load-symbol-white.svelte | 2+-
Mapps-lib/src/lib/components/lib/load-symbol.svelte | 2+-
Mapps-lib/src/lib/components/lib/select-menu.svelte | 3++-
Mapps-lib/src/lib/components/lib/select.svelte | 4++--
Mapps-lib/src/lib/components/lib/text-area.svelte | 3+--
Mapps-lib/src/lib/components/lib/toast.svelte | 9++++-----
Mapps-lib/src/lib/components/lib/wrap-border.svelte | 3++-
Mapps-lib/src/lib/components/map/map-marker-area-display.svelte | 3+--
Mapps-lib/src/lib/components/map/map-marker-area.svelte | 3+--
Mapps-lib/src/lib/components/map/map.svelte | 4++--
Mapps-lib/src/lib/components/navigation/page-header.svelte | 9+++++++--
Mapps-lib/src/lib/components/navigation/page-toolbar.svelte | 10++++++++--
Mapps-lib/src/lib/components/trellis/trellis-default-label.svelte | 3++-
Mapps-lib/src/lib/components/trellis/trellis-end.svelte | 3+--
Mapps-lib/src/lib/components/trellis/trellis-input.svelte | 8++------
Mapps-lib/src/lib/components/trellis/trellis-offset.svelte | 11+++++++----
Mapps-lib/src/lib/components/trellis/trellis-row-display-value.svelte | 8++------
Mapps-lib/src/lib/components/trellis/trellis-row-label.svelte | 8++------
Mapps-lib/src/lib/components/trellis/trellis-select.svelte | 2+-
Mapps-lib/src/lib/components/trellis/trellis-title.svelte | 4++--
Mapps-lib/src/lib/components/trellis/trellis-touch.svelte | 3++-
Mapps-lib/src/lib/components/trellis/trellis.svelte | 2+-
Mapps-lib/src/lib/components/upload/image-upload-add-photo.svelte | 7++-----
Mapps-lib/src/lib/components/upload/image-upload-simple.svelte | 8+++++---
Mapps-lib/src/lib/features/farm/farms-add-casli-map.svelte | 4++--
Mapps-lib/src/lib/features/farm/farms-display-li-el.svelte | 19+++++++++++++------
Mapps-lib/src/lib/features/farm/farms-products-review-card.svelte | 9+++++++--
Dapps-lib/src/lib/features/search/search-result-container.svelte | 21---------------------
Dapps-lib/src/lib/features/search/search-result-display.svelte | 228-------------------------------------------------------------------------------
Mapps-lib/src/lib/index.ts | 15++++++---------
Mapps-lib/src/lib/store/app.ts | 3++-
Mapps-lib/src/lib/store/client.ts | 2+-
Mapps-lib/src/lib/types/component.ts | 251++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Aapps-lib/src/lib/types/interface.ts | 210+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aapps-lib/src/lib/types/lib.ts | 20++++++++++++++++++++
Dapps-lib/src/lib/types/view.ts | 24------------------------
Aapps-lib/src/lib/types/view/farm.ts | 26++++++++++++++++++++++++++
Aapps-lib/src/lib/types/view/lib.ts | 12++++++++++++
Aapps-lib/src/lib/types/view/profile.ts | 14++++++++++++++
Aapps-lib/src/lib/util/component.ts | 46++++++++++++++++++++++++++++++++++++++++++++++
Mapps-lib/src/lib/util/lib.ts | 6+++---
Dapps-lib/src/lib/view/farms-add.svelte | 224-------------------------------------------------------------------------------
Dapps-lib/src/lib/view/farms-products-add.svelte | 659-------------------------------------------------------------------------------
Dapps-lib/src/lib/view/farms-products-view.svelte | 56--------------------------------------------------------
Dapps-lib/src/lib/view/farms-view.svelte | 268-------------------------------------------------------------------------------
Dapps-lib/src/lib/view/farms.svelte | 96-------------------------------------------------------------------------------
Mapps-lib/src/lib/view/home.svelte | 14++------------
Mapps-lib/src/lib/view/profile.svelte | 4++--
Dapps-lib/src/lib/view/search.svelte | 117-------------------------------------------------------------------------------
Mapps-lib/src/lib/view/settings.svelte | 4++--
92 files changed, 818 insertions(+), 1927 deletions(-)

diff --git a/apps-lib/src/lib/components/button/button-label-dashed.svelte b/apps-lib/src/lib/components/button/button-label-dashed.svelte @@ -1,5 +1,5 @@ <script lang="ts"> - import type { ICb } from "@radroots/util"; + import { type ICb } from "$root"; let { basis, diff --git a/apps-lib/src/lib/components/button/button-label-glyph.svelte b/apps-lib/src/lib/components/button/button-label-glyph.svelte @@ -1,6 +1,6 @@ <script lang="ts"> - import { Glyph } from "$root"; - import { type GlyphKey, type ICb } from "@radroots/util"; + import { Glyph, type ICb } from "$root"; + import { type GlyphKey } from "@radroots/util"; import type { Snippet } from "svelte"; let { diff --git a/apps-lib/src/lib/components/button/button-layout-pair.svelte b/apps-lib/src/lib/components/button/button-layout-pair.svelte @@ -1,11 +1,12 @@ <script lang="ts"> - import { app_lo, ButtonLayout, Empty } from "$root"; import { - fmt_cl, - type CallbackPromise, + app_lo, + ButtonLayout, + Empty, type IClOpt, type IDisabledOpt, - } from "@radroots/util"; + } from "$root"; + import { fmt_cl, type CallbackPromise } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/button/button-layout.svelte b/apps-lib/src/lib/components/button/button-layout.svelte @@ -1,13 +1,6 @@ <script lang="ts"> - import { app_lo } from "$lib/store/app"; - import { - fmt_cl, - parse_layer, - type CallbackPromise, - type IClOpt, - type IDisabledOpt, - type ILyOpt, - } from "@radroots/util"; + import { app_lo, type IClOpt, type IDisabledOpt, type ILyOpt } from "$root"; + import { fmt_cl, parse_layer, type CallbackPromise } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/button/button-round.svelte b/apps-lib/src/lib/components/button/button-round.svelte @@ -1,6 +1,6 @@ <script lang="ts"> - import { LoadSymbol } from "$root"; - import { fmt_cl, type IButtonRound } from "@radroots/util"; + import { LoadSymbol, type IButtonRound } from "$root"; + import { fmt_cl } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/button/button-simple-glyph.svelte b/apps-lib/src/lib/components/button/button-simple-glyph.svelte @@ -1,9 +1,6 @@ <script lang="ts"> - import { - parse_layer, - type CallbackPromise, - type ILyOpt, - } from "@radroots/util"; + import { type ILyOpt } from "$root"; + import { parse_layer, type CallbackPromise } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/button/button-simple.svelte b/apps-lib/src/lib/components/button/button-simple.svelte @@ -1,5 +1,6 @@ <script lang="ts"> - import { parse_layer, type IButtonSimple } from "@radroots/util"; + import { type IButtonSimple } from "$root"; + import { parse_layer } from "@radroots/util"; let { basis }: { basis: IButtonSimple } = $props(); diff --git a/apps-lib/src/lib/components/button/glyph-button-simple.svelte b/apps-lib/src/lib/components/button/glyph-button-simple.svelte @@ -1,10 +1,9 @@ <script lang="ts"> - import { Glyph } from "$root"; + import { Glyph, type IClOpt } from "$root"; import { fmt_cl, type CallbackPromise, type GlyphKey, - type IClOpt, } from "@radroots/util"; let { diff --git a/apps-lib/src/lib/components/button/glyph-button.svelte b/apps-lib/src/lib/components/button/glyph-button.svelte @@ -1,5 +1,6 @@ <script lang="ts"> - import { fmt_cl, glyph_style_map, type IGlyph } from "@radroots/util"; + import { glyph_style_map, type IGlyph } from "$root"; + import { fmt_cl } from "@radroots/util"; let { basis }: { basis: IGlyph } = $props(); const styles = $derived( diff --git a/apps-lib/src/lib/components/carousel/carousel-flow-item.svelte b/apps-lib/src/lib/components/carousel/carousel-flow-item.svelte @@ -1,5 +1,6 @@ <script lang="ts"> - import { fmt_cl, type IClOpt } from "@radroots/util"; + import { type IClOpt } from "$root"; + import { fmt_cl } from "@radroots/util"; import type { Snippet } from "svelte"; let { diff --git a/apps-lib/src/lib/components/carousel/carousel-flow.svelte b/apps-lib/src/lib/components/carousel/carousel-flow.svelte @@ -1,7 +1,7 @@ <script lang="ts"> import { browser } from "$app/environment"; - import { handle_err } from "$root"; - import { fmt_cl, type IClOpt } from "@radroots/util"; + import { handle_err, type IClOpt } from "$root"; + import { fmt_cl } from "@radroots/util"; import { onDestroy, onMount, type Snippet } from "svelte"; let { diff --git a/apps-lib/src/lib/components/carousel/carousel-item.svelte b/apps-lib/src/lib/components/carousel/carousel-item.svelte @@ -1,5 +1,6 @@ <script lang="ts"> - import { fmt_cl, type IBasisOpt, type IClOpt } from "@radroots/util"; + import { type IBasisOpt, type IClOpt } from "$root"; + import { fmt_cl } from "@radroots/util"; import type { Snippet } from "svelte"; let { diff --git a/apps-lib/src/lib/components/carousel/carousel.svelte b/apps-lib/src/lib/components/carousel/carousel.svelte @@ -1,6 +1,6 @@ <script lang="ts"> - import { casl_i } from "$root"; - import { fmt_cl, type IBasisOpt, type IClOpt } from "@radroots/util"; + import { casl_i, type IBasisOpt, type IClOpt } from "$root"; + import { fmt_cl } from "@radroots/util"; import type { Snippet } from "svelte"; let { diff --git a/apps-lib/src/lib/components/envelope/map-location-select-envelope.svelte b/apps-lib/src/lib/components/envelope/map-location-select-envelope.svelte @@ -1,13 +1,17 @@ <script lang="ts"> - import { ButtonSimple, EnvelopeLowerFull, Map, MapMarkerArea } from "$root"; import { - type CallbackPromiseGeneric, - type GeocoderReverseResult, - type GeolocationPoint, + ButtonSimple, + EnvelopeLowerFull, + Map, + MapMarkerArea, type LcGeocodeCallback, - type ResolveFarmInfo, + } from "$root"; + import { cfg_map, parse_geol_point_tup, + type CallbackPromiseGeneric, + type GeocoderReverseResult, + type GeolocationPoint, } from "@radroots/util"; let { @@ -16,7 +20,6 @@ map_geoc = $bindable(undefined), }: { basis: { - farm_info: ResolveFarmInfo; visible: boolean; lc_geocode: LcGeocodeCallback; lc_submit: CallbackPromiseGeneric<{ diff --git a/apps-lib/src/lib/components/form/entry-line-idb.svelte b/apps-lib/src/lib/components/form/entry-line-idb.svelte @@ -1,10 +1,12 @@ <script lang="ts"> - import { EntryWrap, Glyph, Input, LoadSymbol } from "$root"; import { - parse_layer, + EntryWrap, + Glyph, + Input, + LoadSymbol, type IEntryLineIdb, - type LoadingDimension, - } from "@radroots/util"; + } from "$root"; + import { parse_layer, type LoadingDimension } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/form/entry-line.svelte b/apps-lib/src/lib/components/form/entry-line.svelte @@ -1,10 +1,12 @@ <script lang="ts"> - import { EntryWrap, Glyph, InputValue, LoadSymbol } from "$root"; import { - parse_layer, + EntryWrap, + Glyph, + InputValue, + LoadSymbol, type IEntryLine, - type LoadingDimension, - } from "@radroots/util"; + } from "$root"; + import { parse_layer, type LoadingDimension } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/form/entry-multiline.svelte b/apps-lib/src/lib/components/form/entry-multiline.svelte @@ -1,6 +1,6 @@ <script lang="ts"> - import { Glyph, TextArea } from "$root"; - import { fmt_cl, parse_layer, type IEntryMultiLine } from "@radroots/util"; + import { Glyph, TextArea, type IEntryMultiLine } from "$root"; + import { fmt_cl, parse_layer } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/form/entry-select.svelte b/apps-lib/src/lib/components/form/entry-select.svelte @@ -1,6 +1,12 @@ <script lang="ts"> - import { EntryWrap, Glyph, LoadSymbol, Select } from "$root"; - import { fmt_cl, parse_layer, type IEntrySelect } from "@radroots/util"; + import { + EntryWrap, + Glyph, + LoadSymbol, + Select, + type IEntrySelect, + } from "$root"; + import { fmt_cl, parse_layer } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/form/entry-wrap.svelte b/apps-lib/src/lib/components/form/entry-wrap.svelte @@ -1,10 +1,6 @@ <script lang="ts"> - import { - fmt_cl, - parse_layer, - type IBasisOpt, - type IEntryWrap, - } from "@radroots/util"; + import { type IBasisOpt, type IEntryWrap } from "$root"; + import { fmt_cl, parse_layer } from "@radroots/util"; import type { Snippet } from "svelte"; let { diff --git a/apps-lib/src/lib/components/form/form-entry-input.svelte b/apps-lib/src/lib/components/form/form-entry-input.svelte @@ -1,6 +1,6 @@ <script lang="ts"> - import { EntryLine, fmt_id, LayoutTrellisLine } from "$root"; - import type { FormField, IIdOpt } from "@radroots/util"; + import { EntryLine, fmt_id, LayoutTrellisLine, type IIdOpt } from "$root"; + import { type FormField } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/form/form-entry-price.svelte b/apps-lib/src/lib/components/form/form-entry-price.svelte @@ -7,6 +7,7 @@ lib_fmt_price, lib_parse_currency_marker, Select, + type IIdOpt, } from "$root"; import { fiat_currencies, @@ -15,7 +16,6 @@ type ElementCallbackValue, type I18nTranslateFunction, type I18nTranslateLocale, - type IIdOpt, } from "@radroots/util"; let { diff --git a/apps-lib/src/lib/components/form/form-entry-quantity.svelte b/apps-lib/src/lib/components/form/form-entry-quantity.svelte @@ -1,11 +1,17 @@ <script lang="ts"> - import { EntryWrap, fmt_id, Input, LayoutTrellisLine, Select } from "$root"; + import { + EntryWrap, + fmt_id, + Input, + LayoutTrellisLine, + Select, + type IIdOpt, + } from "$root"; import { form_fields, mass_units, type ElementCallbackValue, type I18nTranslateFunction, - type IIdOpt, } from "@radroots/util"; let { diff --git a/apps-lib/src/lib/components/form/form-entry-select-input.svelte b/apps-lib/src/lib/components/form/form-entry-select-input.svelte @@ -1,11 +1,16 @@ <script lang="ts"> - import { EntryLine, EntrySelect, fmt_id, LayoutTrellisLine } from "$root"; + import { + EntryLine, + EntrySelect, + fmt_id, + LayoutTrellisLine, + type ISelectCallback, + type ISelectOption, + } from "$root"; import { type CallbackPromiseGeneric, - type ElementCallbackSelect, type FormField, type I18nTranslateFunction, - type ISelectOption, } from "@radroots/util"; let { @@ -17,7 +22,7 @@ basis: { id: string; visible_input: boolean; - callback_select: ElementCallbackSelect; + callback_select: ISelectCallback; callback_visible: CallbackPromiseGeneric<boolean>; select_entries: ISelectOption<string>[]; input_placeholder?: string; diff --git a/apps-lib/src/lib/components/form/form-entry-select.svelte b/apps-lib/src/lib/components/form/form-entry-select.svelte @@ -1,11 +1,13 @@ <script lang="ts"> - import { EntrySelect, fmt_id, LayoutTrellisLine } from "$root"; import { - type ElementCallbackSelect, + EntrySelect, + fmt_id, + LayoutTrellisLine, type IClOpt, type IIdOpt, + type ISelectCallback, type ISelectOption, - } from "@radroots/util"; + } from "$root"; let { basis, @@ -13,7 +15,7 @@ }: { basis: IIdOpt & IClOpt & { - callback?: ElementCallbackSelect; + callback?: ISelectCallback; entries: ISelectOption<string>[]; entry_label?: string; }; diff --git a/apps-lib/src/lib/components/form/form-entry-textarea.svelte b/apps-lib/src/lib/components/form/form-entry-textarea.svelte @@ -1,9 +1,13 @@ <script lang="ts"> - import { EntryMultiline, LayoutTrellisLine, fmt_id } from "$root"; + import { + EntryMultiline, + LayoutTrellisLine, + fmt_id, + type IIdOpt, + } from "$root"; import { type ElementCallbackValueKeydown, type FormField, - type IIdOpt, } from "@radroots/util"; let { diff --git a/apps-lib/src/lib/components/form/form-line-ledger-select.svelte b/apps-lib/src/lib/components/form/form-line-ledger-select.svelte @@ -1,11 +1,13 @@ <script lang="ts"> - import { fmt_id, Input, Select } from "$root"; import { - type ElementCallbackSelect, - type ElementCallbackValueKeydown, + fmt_id, + Input, + Select, type IIdOpt, + type ISelectCallback, type ISelectOption, - } from "@radroots/util"; + } from "$root"; + import { type ElementCallbackValueKeydown } from "@radroots/util"; let { basis, @@ -23,7 +25,7 @@ }; select: { entries: ISelectOption<string>[]; - callback?: ElementCallbackSelect; + callback?: ISelectCallback; }; }; value_input?: string; diff --git a/apps-lib/src/lib/components/form/form-line-ledger.svelte b/apps-lib/src/lib/components/form/form-line-ledger.svelte @@ -1,10 +1,14 @@ <script lang="ts"> - import { fmt_id, Input, SelectMenu } from "$root"; import { - type ElementCallbackValueKeydown, - type FormField, + fmt_id, + Input, + SelectMenu, type IIdOpt, type ISelectOption, + } from "$root"; + import { + type ElementCallbackValueKeydown, + type FormField, } from "@radroots/util"; import FormLineLedgerLabelSelectLabel from "./form-line-ledger-label-select-label.svelte"; diff --git a/apps-lib/src/lib/components/form/form-review-display.svelte b/apps-lib/src/lib/components/form/form-review-display.svelte @@ -1,11 +1,6 @@ <script lang="ts"> - import { Glyph } from "$root"; - import { - fmt_cl, - type CallbackPromise, - type IClOpt, - type IClOptWrap, - } from "@radroots/util"; + import { Glyph, type IClOpt, type IClOptWrap } from "$root"; + import { fmt_cl, type CallbackPromise } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/form/trade_field_display_kv.svelte b/apps-lib/src/lib/components/form/trade_field_display_kv.svelte @@ -1,11 +1,6 @@ <script lang="ts"> - import { fmt_id, Glyph, idb } from "$root"; - import { - el_focus, - fmt_cl, - type CallbackPromise, - type IClOpt, - } from "@radroots/util"; + import { fmt_id, Glyph, idb, type IClOpt } from "$root"; + import { el_focus, fmt_cl, type CallbackPromise } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/glyph/glyph-circle.svelte b/apps-lib/src/lib/components/glyph/glyph-circle.svelte @@ -1,6 +1,6 @@ <script lang="ts"> - import { GlyphButton } from "$root"; - import { type IGlyphCircle, fmt_cl, glyph_style_map } from "@radroots/util"; + import { GlyphButton, glyph_style_map, type IGlyphCircle } from "$root"; + import { fmt_cl } from "@radroots/util"; let { basis }: { basis: IGlyphCircle } = $props(); diff --git a/apps-lib/src/lib/components/glyph/glyph.svelte b/apps-lib/src/lib/components/glyph/glyph.svelte @@ -1,5 +1,6 @@ <script lang="ts"> - import { fmt_cl, glyph_style_map, type IGlyph } from "@radroots/util"; + import { glyph_style_map, type IGlyph } from "$root"; + import { fmt_cl } from "@radroots/util"; let { basis }: { basis: IGlyph } = $props(); diff --git a/apps-lib/src/lib/components/label/label-display.svelte b/apps-lib/src/lib/components/label/label-display.svelte @@ -1,5 +1,6 @@ <script lang="ts"> - import { fmt_cl, parse_layer, type ILabelDisplay } from "@radroots/util"; + import { type ILabelDisplay } from "$root"; + import { fmt_cl, parse_layer } from "@radroots/util"; let { basis }: { basis: ILabelDisplay } = $props(); diff --git a/apps-lib/src/lib/components/layout/layout-page.svelte b/apps-lib/src/lib/components/layout/layout-page.svelte @@ -1,5 +1,6 @@ <script lang="ts"> - import { fmt_cl, type IBasisOpt, type IClOpt } from "@radroots/util"; + import { type IBasisOpt, type IClOpt } from "$root"; + import { fmt_cl } from "@radroots/util"; import type { Snippet } from "svelte"; let { diff --git a/apps-lib/src/lib/components/layout/layout-trellis-line.svelte b/apps-lib/src/lib/components/layout/layout-trellis-line.svelte @@ -1,10 +1,6 @@ <script lang="ts"> - import { Glyph } from "$root"; - import { - fmt_cl, - type IBasisOpt, - type ILayoutTrellisLine, - } from "@radroots/util"; + import { Glyph, type IBasisOpt, type ILayoutTrellisLine } from "$root"; + import { fmt_cl } from "@radroots/util"; import type { Snippet } from "svelte"; import { fade } from "svelte/transition"; diff --git a/apps-lib/src/lib/components/layout/layout-trellis.svelte b/apps-lib/src/lib/components/layout/layout-trellis.svelte @@ -1,5 +1,6 @@ <script lang="ts"> - import { fmt_cl, type IBasisOpt, type IClOpt } from "@radroots/util"; + import { type IBasisOpt, type IClOpt } from "$root"; + import { fmt_cl } from "@radroots/util"; import type { Snippet } from "svelte"; let { diff --git a/apps-lib/src/lib/components/layout/layout-view.svelte b/apps-lib/src/lib/components/layout/layout-view.svelte @@ -1,6 +1,12 @@ <script lang="ts"> - import { nav_blur, ph_blur, tabs_blur } from "$root"; - import { fmt_cl, type IBasisOpt, type IClOpt } from "@radroots/util"; + import { + nav_blur, + ph_blur, + tabs_blur, + type IBasisOpt, + type IClOpt, + } from "$root"; + import { fmt_cl } from "@radroots/util"; import { onDestroy, onMount, type Snippet } from "svelte"; let { diff --git a/apps-lib/src/lib/components/lib/fade.svelte b/apps-lib/src/lib/components/lib/fade.svelte @@ -1,5 +1,6 @@ <script lang="ts"> - import { fmt_cl, type IBasisOpt, type IClOpt } from "@radroots/util"; + import { type IBasisOpt, type IClOpt } from "$root"; + import { fmt_cl } from "@radroots/util"; import type { Snippet } from "svelte"; import { fade, type FadeParams } from "svelte/transition"; diff --git a/apps-lib/src/lib/components/lib/image-blob.svelte b/apps-lib/src/lib/components/lib/image-blob.svelte @@ -1,5 +1,5 @@ <script lang="ts"> - import { type IImageBlob } from "@radroots/util"; + import { type IImageBlob } from "$root"; import { onDestroy, onMount } from "svelte"; let { basis }: { basis: IImageBlob } = $props(); diff --git a/apps-lib/src/lib/components/lib/image-path.svelte b/apps-lib/src/lib/components/lib/image-path.svelte @@ -1,5 +1,6 @@ <script lang="ts"> - import { fmt_cl, type IImagePath } from "@radroots/util"; + import { type IImagePath } from "$root"; + import { fmt_cl } from "@radroots/util"; import { onMount } from "svelte"; let { basis }: { basis: IImagePath } = $props(); diff --git a/apps-lib/src/lib/components/lib/input-value.svelte b/apps-lib/src/lib/components/lib/input-value.svelte @@ -1,10 +1,6 @@ <script lang="ts"> - import { - type IInputValue, - fmt_cl, - parse_layer, - value_constrain, - } from "@radroots/util"; + import { type IInputValue } from "$root"; + import { fmt_cl, parse_layer, value_constrain } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/lib/input.svelte b/apps-lib/src/lib/components/lib/input.svelte @@ -1,12 +1,7 @@ <script lang="ts"> import { browser } from "$app/environment"; - import { idb } from "$root"; - import { - type IInput, - fmt_cl, - parse_layer, - value_constrain, - } from "@radroots/util"; + import { idb, type IInput } from "$root"; + import { fmt_cl, parse_layer, value_constrain } from "@radroots/util"; import { onMount } from "svelte"; let { diff --git a/apps-lib/src/lib/components/lib/label-swap.svelte b/apps-lib/src/lib/components/lib/label-swap.svelte @@ -1,10 +1,6 @@ <script lang="ts"> - import { - fmt_cl, - parse_layer, - type ILabelSwap, - type ILyOpt, - } from "@radroots/util"; + import { type ILabelSwap, type ILyOpt } from "$root"; + import { fmt_cl, parse_layer } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/lib/load-symbol-white.svelte b/apps-lib/src/lib/components/lib/load-symbol-white.svelte @@ -1,5 +1,5 @@ <script lang="ts"> - import { loading_style_map, type ILoadSymbol } from "@radroots/util"; + import { loading_style_map, type ILoadSymbol } from "$root"; let { basis = undefined, diff --git a/apps-lib/src/lib/components/lib/load-symbol.svelte b/apps-lib/src/lib/components/lib/load-symbol.svelte @@ -1,5 +1,5 @@ <script lang="ts"> - import { type ILoadSymbol, loading_style_map } from "@radroots/util"; + import { type ILoadSymbol, loading_style_map } from "$root"; let { basis = undefined, diff --git a/apps-lib/src/lib/components/lib/select-menu.svelte b/apps-lib/src/lib/components/lib/select-menu.svelte @@ -1,5 +1,6 @@ <script lang="ts"> - import { fmt_cl, parse_layer, type ISelect } from "@radroots/util"; + import { type ISelect } from "$root"; + import { fmt_cl, parse_layer } from "@radroots/util"; import type { Snippet } from "svelte"; let { diff --git a/apps-lib/src/lib/components/lib/select.svelte b/apps-lib/src/lib/components/lib/select.svelte @@ -1,7 +1,7 @@ <script lang="ts"> import { browser } from "$app/environment"; - import { Glyph, handle_err, idb } from "$root"; - import { fmt_cl, parse_layer, type ISelect } from "@radroots/util"; + import { Glyph, handle_err, idb, type ISelect } from "$root"; + import { fmt_cl, parse_layer } from "@radroots/util"; import { onMount } from "svelte"; let { diff --git a/apps-lib/src/lib/components/lib/text-area.svelte b/apps-lib/src/lib/components/lib/text-area.svelte @@ -1,8 +1,7 @@ <script lang="ts"> import { browser } from "$app/environment"; - import { handle_err, idb } from "$root"; + import { handle_err, idb, type ITextArea } from "$root"; import { - type ITextArea, fmt_cl, fmt_textarea_value, parse_layer, diff --git a/apps-lib/src/lib/components/lib/toast.svelte b/apps-lib/src/lib/components/lib/toast.svelte @@ -1,14 +1,13 @@ <script lang="ts"> - import { app_lo } from "$root"; import { - fmt_cl, - get_layout_default, - parse_layer, + app_lo, toast_layout_map, toast_style_map, type IToast, type IToastKind, - } from "@radroots/util"; + } from "$root"; + + import { fmt_cl, get_layout_default, parse_layer } from "@radroots/util"; let { basis }: { basis: IToast } = $props(); diff --git a/apps-lib/src/lib/components/lib/wrap-border.svelte b/apps-lib/src/lib/components/lib/wrap-border.svelte @@ -1,5 +1,6 @@ <script lang="ts"> - import { fmt_cl, type IClOpt } from "@radroots/util"; + import { type IClOpt } from "$root"; + import { fmt_cl } from "@radroots/util"; import type { Snippet } from "svelte"; let { diff --git a/apps-lib/src/lib/components/map/map-marker-area-display.svelte b/apps-lib/src/lib/components/map/map-marker-area-display.svelte @@ -1,6 +1,5 @@ <script lang="ts"> - import { Fade, Glyph } from "$root"; - import type { IBasisOpt } from "@radroots/util"; + import { Fade, Glyph, type IBasisOpt } from "$root"; let { basis = undefined, diff --git a/apps-lib/src/lib/components/map/map-marker-area.svelte b/apps-lib/src/lib/components/map/map-marker-area.svelte @@ -1,9 +1,8 @@ <script lang="ts"> - import { MapMarkerAreaDisplay } from "$root"; + import { MapMarkerAreaDisplay, type IMapMarkerArea } from "$root"; import { type GeocoderReverseResult, type GeolocationPoint, - type IMapMarkerArea, } from "@radroots/util"; import { Marker, Popup } from "svelte-maplibre"; diff --git a/apps-lib/src/lib/components/map/map.svelte b/apps-lib/src/lib/components/map/map.svelte @@ -1,6 +1,6 @@ <script lang="ts"> - import { app_thc } from "$lib/store/app"; - import { cfg_map, fmt_cl, type IClOpt } from "@radroots/util"; + import { app_thc, type IClOpt } from "$root"; + import { cfg_map, fmt_cl } from "@radroots/util"; import type { Snippet } from "svelte"; import { MapLibre } from "svelte-maplibre"; diff --git a/apps-lib/src/lib/components/navigation/page-header.svelte b/apps-lib/src/lib/components/navigation/page-header.svelte @@ -1,6 +1,11 @@ <script lang="ts"> - import { app_lo, callback_route, Empty, ph_blur } from "$root"; - import type { IPageHeader } from "@radroots/util"; + import { + app_lo, + callback_route, + Empty, + ph_blur, + type IPageHeader, + } from "$root"; import type { Snippet } from "svelte"; import { fade } from "svelte/transition"; diff --git a/apps-lib/src/lib/components/navigation/page-toolbar.svelte b/apps-lib/src/lib/components/navigation/page-toolbar.svelte @@ -1,7 +1,13 @@ <script lang="ts"> import { goto } from "$app/navigation"; - import { app_lo, Glyph, LogoCircleSm, PageHeader } from "$root"; - import type { IBasisOpt, IPageToolbar } from "@radroots/util"; + import { + app_lo, + Glyph, + LogoCircleSm, + PageHeader, + type IBasisOpt, + type IPageToolbar, + } from "$root"; import type { Snippet } from "svelte"; import LogoLetters from "../lib/logo-letters.svelte"; diff --git a/apps-lib/src/lib/components/trellis/trellis-default-label.svelte b/apps-lib/src/lib/components/trellis/trellis-default-label.svelte @@ -1,6 +1,7 @@ <script lang="ts"> + import { type ITrellisDefaultLabel } from "$root"; import type { ThemeLayer } from "@radroots/theme"; - import { fmt_cl, type ITrellisDefaultLabel } from "@radroots/util"; + import { fmt_cl } from "@radroots/util"; let { layer, diff --git a/apps-lib/src/lib/components/trellis/trellis-end.svelte b/apps-lib/src/lib/components/trellis/trellis-end.svelte @@ -1,7 +1,6 @@ <script lang="ts"> - import { Glyph } from "$root"; + import { Glyph, type ITrellisBasisTouchEnd } from "$root"; import type { ThemeLayer } from "@radroots/theme"; - import { type ITrellisBasisTouchEnd } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/trellis/trellis-input.svelte b/apps-lib/src/lib/components/trellis/trellis-input.svelte @@ -1,11 +1,7 @@ <script lang="ts"> - import { Glyph, Input, LoadSymbol } from "$root"; + import { Glyph, Input, LoadSymbol, type ITrellisBasisInput } from "$root"; import type { ThemeLayer } from "@radroots/theme"; - import { - fmt_cl, - fmt_trellis, - type ITrellisBasisInput, - } from "@radroots/util"; + import { fmt_cl, fmt_trellis } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/trellis/trellis-offset.svelte b/apps-lib/src/lib/components/trellis/trellis-offset.svelte @@ -1,11 +1,14 @@ <script lang="ts"> - import { Empty, Glyph, GlyphCircle, LoadSymbol } from "$root"; - import type { ThemeLayer } from "@radroots/theme"; import { - fmt_cl, + Empty, + Glyph, + GlyphCircle, + LoadSymbol, type ITrellisBasisOffset, type ITrellisBasisOffsetMod, - } from "@radroots/util"; + } from "$root"; + import type { ThemeLayer } from "@radroots/theme"; + import { fmt_cl } from "@radroots/util"; let { basis = undefined, diff --git a/apps-lib/src/lib/components/trellis/trellis-row-display-value.svelte b/apps-lib/src/lib/components/trellis/trellis-row-display-value.svelte @@ -1,11 +1,7 @@ <script lang="ts"> - import { Glyph } from "$root"; + import { Glyph, type ITrellisKindDisplayValue } from "$root"; import type { ThemeLayer } from "@radroots/theme"; - import { - fmt_cl, - get_label_classes_kind, - type ITrellisKindDisplayValue, - } from "@radroots/util"; + import { fmt_cl, get_label_classes_kind } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/trellis/trellis-row-label.svelte b/apps-lib/src/lib/components/trellis/trellis-row-label.svelte @@ -1,11 +1,7 @@ <script lang="ts"> - import { GlyphButton } from "$root"; + import { GlyphButton, type ILabelTupFields } from "$root"; import type { ThemeLayer } from "@radroots/theme"; - import { - fmt_cl, - get_label_classes_kind, - type ILabelTupFields, - } from "@radroots/util"; + import { fmt_cl, get_label_classes_kind } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/trellis/trellis-select.svelte b/apps-lib/src/lib/components/trellis/trellis-select.svelte @@ -6,9 +6,9 @@ TrellisLine, TrellisRowDisplayValue, TrellisRowLabel, + type ITrellisBasisSelect, } from "$root"; import type { ThemeLayer } from "@radroots/theme"; - import type { ITrellisBasisSelect } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/trellis/trellis-title.svelte b/apps-lib/src/lib/components/trellis/trellis-title.svelte @@ -1,7 +1,7 @@ <script lang="ts"> - import { Empty, Glyph, LabelSwap } from "$root"; + import { Empty, Glyph, LabelSwap, type ITrellisTitle } from "$root"; import type { ThemeLayer } from "@radroots/theme"; - import { type ITrellisTitle, fmt_cl } from "@radroots/util"; + import { fmt_cl } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/trellis/trellis-touch.svelte b/apps-lib/src/lib/components/trellis/trellis-touch.svelte @@ -4,8 +4,9 @@ TrellisLine, TrellisRowDisplayValue, TrellisRowLabel, + type ITrellisBasisTouch, } from "$root"; - import type { ITrellisBasisTouch, ThemeLayer } from "@radroots/util"; + import type { ThemeLayer } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/trellis/trellis.svelte b/apps-lib/src/lib/components/trellis/trellis.svelte @@ -7,12 +7,12 @@ TrellisSelect, TrellisTitle, TrellisTouch, + type ITrellis, } from "$root"; import { fmt_cl, parse_layer, type I18nTranslateFunction, - type ITrellis, } from "@radroots/util"; import type { Snippet } from "svelte"; diff --git a/apps-lib/src/lib/components/upload/image-upload-add-photo.svelte b/apps-lib/src/lib/components/upload/image-upload-add-photo.svelte @@ -1,9 +1,6 @@ <script lang="ts"> - import { Glyph, LoadSymbol } from "$root"; - import { - type I18nTranslateFunction, - type LcPhotoAddCallback, - } from "@radroots/util"; + import { Glyph, LoadSymbol, type LcPhotoAddCallback } from "$root"; + import { type I18nTranslateFunction } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/components/upload/image-upload-simple.svelte b/apps-lib/src/lib/components/upload/image-upload-simple.svelte @@ -1,9 +1,11 @@ <script lang="ts"> - import { Glyph, ImagePath, ImageUploadButtonsAspect } from "$root"; import { - list_assign, + Glyph, + ImagePath, + ImageUploadButtonsAspect, type LcPhotoAddMultipleCallback, - } from "@radroots/util"; + } from "$root"; + import { list_assign } from "@radroots/util"; let { basis, diff --git a/apps-lib/src/lib/features/farm/farms-add-casli-map.svelte b/apps-lib/src/lib/features/farm/farms-add-casli-map.svelte @@ -6,12 +6,12 @@ WrapBorder, app_lo, handle_err, + type LcGeocodeCallback, + type LcGeocodeCurrentCallback, } from "$root"; import { type GeocoderReverseResult, type GeolocationPoint, - type LcGeocodeCallback, - type LcGeocodeCurrentCallback, } from "@radroots/util"; import { onMount } from "svelte"; diff --git a/apps-lib/src/lib/features/farm/farms-display-li-el.svelte b/apps-lib/src/lib/features/farm/farms-display-li-el.svelte @@ -1,17 +1,17 @@ <script lang="ts"> - import { Map, MapMarkerArea } from "$root"; + import { Map, MapMarkerArea, type LcGeocodeCallback } from "$root"; import { + fmt_geolocation_address, geol_lat_fmt, geol_lng_fmt, - lib_address_fmt, parse_geom_point_tup, parse_tup_geop_point, type CallbackPromiseGeneric, + type GeolocationAddress, type GeolocationPointTuple, + type GeometryPoint, type I18nTranslateFunction, type I18nTranslateLocale, - type LcGeocodeCallback, - type ResolveFarmInfo, } from "@radroots/util"; import { onMount } from "svelte"; @@ -22,7 +22,14 @@ ls, locale, }: { - basis: ResolveFarmInfo; + basis: { + id: string; + name: string; + geolocation?: { + point: GeometryPoint; + address: GeolocationAddress; + }; + }; lc_geocode: LcGeocodeCallback; lc_handle_farm_view: CallbackPromiseGeneric<string>; ls: I18nTranslateFunction; @@ -45,7 +52,7 @@ const farm_addr_fmt = $derived( basis.geolocation?.address - ? lib_address_fmt(basis.geolocation.address) + ? fmt_geolocation_address(basis.geolocation.address) : ``, ); diff --git a/apps-lib/src/lib/features/farm/farms-products-review-card.svelte b/apps-lib/src/lib/features/farm/farms-products-review-card.svelte @@ -1,10 +1,15 @@ <script lang="ts"> - import { app_lo, Glyph, ImagePath, lib_parse_currency_marker } from "$root"; + import { + app_lo, + Glyph, + ImagePath, + lib_parse_currency_marker, + type IViewFarmsProductsAddSubmission, + } from "$root"; import { ascii, type I18nTranslateFunction, type I18nTranslateLocale, - type IViewFarmsProductsAddSubmission, } from "@radroots/util"; let { diff --git a/apps-lib/src/lib/features/search/search-result-container.svelte b/apps-lib/src/lib/features/search/search-result-container.svelte @@ -1,21 +0,0 @@ -<script lang="ts"> - import type { ICb } from "@radroots/util"; - import type { Snippet } from "svelte"; - - let { - basis, - children, - }: { - basis: ICb; - children: Snippet; - } = $props(); -</script> - -<button - onclick={async () => { - await basis.callback(); - }} - class={`group flex flex-row h-[4rem] w-full px-4 justify-between items-center bg-layer-1-surface round-24 layer-1-active-surface el-re`} -> - {@render children()} -</button> diff --git a/apps-lib/src/lib/features/search/search-result-display.svelte b/apps-lib/src/lib/features/search/search-result-display.svelte @@ -1,228 +0,0 @@ -<script lang="ts"> - import { Glyph, SearchResultContainer } from "$root"; - import { - ascii, - type CallbackPromiseGeneric, - type I18nTranslateFunction, - type ResolveGeolocationInfo, - type ResolveProfileInfo, - type SearchServiceResult, - } from "@radroots/util"; - - let { - basis, - ls, - }: { - basis: { - result: SearchServiceResult; - lc_handle_search_geolocation: CallbackPromiseGeneric<ResolveGeolocationInfo>; - lc_handle_search_profile: CallbackPromiseGeneric<ResolveProfileInfo>; - lc_handle_search_nostr_relay: CallbackPromiseGeneric<{ - id: string; - }>; - }; - ls: I18nTranslateFunction; - } = $props(); -</script> - -{#if `location_gcs` in basis.result && basis.result.location_gcs.id} - <SearchResultContainer - basis={{ - callback: async () => { - await basis.lc_handle_search_geolocation( - basis.result.location_gcs, - ); - }, - }} - > - <div class={`flex flex-row gap-4 justify-start items-center`}> - <div - class={`flex flex-row h-[1.5rem] w-[1.5rem] justify-center items-center bg-stone-500 round-24`} - > - <Glyph - basis={{ - classes: `text-white`, - dim: `xs`, - - key: `compass`, - }} - /> - </div> - <div class={`flex flex-row gap-1 justify-start items-center`}> - <div - class={`flex flex-row h-[1.2rem] px-2 justify-center items-center bg-stone-600 rounded-md`} - > - <p - class={`font-sans font-[900] text-[0.7rem] text-white uppercase`} - > - {`${$ls(`common.location`)}`} - </p> - </div> - <p - class={`font-sans font-[700] text-layer-0-glyph/30 -translate-y-[1px]`} - > - {ascii.bullet} - </p> - - {#if basis.result.location_gcs.kind === `farm_land`} - <div - class={`flex flex-row h-[1.2rem] px-2 justify-center items-center bg-lime-500 rounded-md`} - > - <p - class={`font-sans font-[900] text-[0.7rem] text-white uppercase`} - > - {`${$ls(`common.farm_land`)}`} - </p> - </div> - {/if} - </div> - </div> - <div - class={`flex flex-row flex-grow pl-4 pr-2 justify-end items-center overflow-hidden`} - > - {#if basis.result.location_gcs.label} - <p - class={`font-sand font-[500] text-[0.9rem] text-layer-0-glyph`} - > - {`${basis.result.location_gcs.label}`} - </p> - {:else} - <p - class={`font-sand font-[500] text-[0.9rem] text-layer-0-glyph truncate`} - > - {`${basis.result.location_gcs.gc_name}, ${basis.result.location_gcs.gc_admin1_id}`} - </p> - {/if} - </div> - </SearchResultContainer> -{:else if `nostr_profile` in basis && basis.result.nostr_profile.id} - <SearchResultContainer - basis={{ - callback: async () => { - await basis.lc_handle_search_profile( - basis.result.nostr_profile, - ); - }, - }} - > - <div class={`flex flex-row gap-4 justify-start items-center`}> - <div - class={`flex flex-row h-[1.5rem] w-[1.5rem] justify-center items-center bg-blue-400 round-24`} - > - <Glyph - basis={{ - classes: `text-white`, - dim: `xs`, - - key: `user`, - }} - /> - </div> - <div class={`flex flex-row gap-1 justify-start items-center`}> - <div - class={`flex flex-row h-[1.2rem] px-2 justify-center items-center bg-stone-600 rounded-md`} - > - <p - class={`font-sans font-[900] text-[0.7rem] text-white uppercase`} - > - {`${$ls(`common.profile`)}`} - </p> - </div> - <p - class={`font-sans font-[700] text-layer-0-glyph/30 -translate-y-[1px]`} - > - {ascii.bullet} - </p> - <div - class={`flex flex-row h-[1.2rem] px-2 justify-center items-center bg-purple-400 rounded-md`} - > - <p - class={`font-sans font-[900] text-[0.7rem] text-white uppercase`} - > - {#if basis.result.result_k === `name`} - {`${$ls(`common.name`)}`} - {:else} - {`@todo`} - {/if} - </p> - </div> - </div> - </div> - <div - class={`flex flex-row flex-grow pl-4 pr-2 justify-end items-center overflow-hidden`} - > - {#if basis.result.nostr_profile.name} - <p - class={`font-sand font-[500] text-[0.9rem] text-layer-0-glyph tracking-wide truncate`} - > - {#if basis.result.result_k === `name`} - {`${basis.result.nostr_profile.name}`} - {:else if basis.result.result_v} - {`${basis.result.result_v}`} - {:else} - {`@todo`} - {/if} - </p> - {/if} - </div> - </SearchResultContainer> -{:else if `nostr_relay` in basis && basis.result.nostr_relay.id} - <SearchResultContainer - basis={{ - callback: async () => { - await basis.lc_handle_search_nostr_relay( - basis.result.nostr_relay, - ); - }, - }} - > - <div class={`flex flex-row gap-4 justify-start items-center`}> - <div - class={`flex flex-row h-[1.5rem] w-[1.5rem] justify-center items-center bg-blue-400 round-24`} - > - <Glyph - basis={{ - classes: `text-white`, - dim: `xs`, - - key: `user`, - }} - /> - </div> - <div class={`flex flex-row gap-1 justify-start items-center`}> - <div - class={`flex flex-row h-[1.2rem] px-2 justify-center items-center bg-stone-600 rounded-md`} - > - <p - class={`font-sans font-[900] text-[0.7rem] text-white uppercase`} - > - {`${$ls(`common.relay`)}`} - </p> - </div> - <p - class={`font-sans font-[700] text-layer-0-glyph/30 -translate-y-[1px]`} - > - {ascii.bullet} - </p> - <div - class={`flex flex-row h-[1.2rem] px-2 justify-center items-center bg-yellow-400 rounded-md`} - > - <p - class={`font-sans font-[900] text-[0.7rem] text-white uppercase`} - > - {`${$ls(`common.url`)}`} - </p> - </div> - </div> - </div> - <div - class={`flex flex-row flex-grow pr-2 justify-end items-center overflow-hidden`} - > - <p - class={`font-sand font-[500] text-[0.9rem] text-layer-0-glyph tracking-wide truncate`} - > - {`${basis.result.nostr_relay.url}`} - </p> - </div> - </SearchResultContainer> -{/if} diff --git a/apps-lib/src/lib/index.ts b/apps-lib/src/lib/index.ts @@ -89,29 +89,26 @@ export { default as FarmsAddCasliDetail } from "./features/farm/farms-add-casli- export { default as FarmsAddCasliMap } from "./features/farm/farms-add-casli-map.svelte" export { default as FarmsDisplayLiEl } from "./features/farm/farms-display-li-el.svelte" export { default as FarmsProductsReviewCard } from "./features/farm/farms-products-review-card.svelte" -export { default as SearchResultContainer } from "./features/search/search-result-container.svelte" -export { default as SearchResultDisplay } from "./features/search/search-result-display.svelte" export * from "./store/app.js" export * from "./store/client.js" export * from "./store/component.js" export * from "./store/layout.js" export * from "./store/ndk.js" export * from "./types/component.js" -export * from "./types/view.js" +export * from "./types/interface.js" +export * from "./types/lib.js" +export * from "./types/view/farm.js" +export * from "./types/view/lib.js" +export * from "./types/view/profile.js" export * from "./util/carousel.js" export * from "./util/casl.js" +export * from "./util/component.js" export * from "./util/idb.js" export * from "./util/lib.js" export * from "./util/service/nostr-sync.js" export * from "./util/view.js" -export { default as FarmsAdd } from "./view/farms-add.svelte" -export { default as FarmsProductsAdd } from "./view/farms-products-add.svelte" -export { default as FarmsProductsView } from "./view/farms-products-view.svelte" -export { default as FarmsView } from "./view/farms-view.svelte" -export { default as Farms } from "./view/farms.svelte" export { default as Home } from "./view/home.svelte" export { default as Notifications } from "./view/notifications.svelte" export { default as ProfileEdit } from "./view/profile-edit.svelte" export { default as Profile } from "./view/profile.svelte" -export { default as Search } from "./view/search.svelte" export { default as Settings } from "./view/settings.svelte" diff --git a/apps-lib/src/lib/store/app.ts b/apps-lib/src/lib/store/app.ts @@ -1,5 +1,6 @@ +import { type IToast } from "$root"; import type { ColorMode, ThemeKey } from "@radroots/theme"; -import type { AppConfigType, AppLayoutKey, BrowserPlatformInfo, IToast } from "@radroots/util"; +import type { AppConfigType, AppLayoutKey, BrowserPlatformInfo } from "@radroots/util"; import { writable } from "svelte/store"; export const app_lo = writable<AppLayoutKey>(); diff --git a/apps-lib/src/lib/store/client.ts b/apps-lib/src/lib/store/client.ts @@ -1,4 +1,4 @@ -import type { NavigationPreviousParam, NavigationRouteParamField, NavigationRouteParamId, NavigationRouteParamLat, NavigationRouteParamLng, NavigationRouteParamNostrPublicKey, NavigationRouteParamRef } from "@radroots/util"; +import type { NavigationPreviousParam, NavigationRouteParamField, NavigationRouteParamId, NavigationRouteParamLat, NavigationRouteParamLng, NavigationRouteParamNostrPublicKey, NavigationRouteParamRef } from "$root"; import { writable } from "svelte/store"; import { queryParam, queryParameters } from "sveltekit-search-params"; diff --git a/apps-lib/src/lib/types/component.ts b/apps-lib/src/lib/types/component.ts @@ -1,7 +1,253 @@ -import { type GeometryScreenPositionHorizontal, type ICb, type IDisabledOpt, type IGlyphKey, type ILoadingOpt } from "@radroots/util"; +import type { CallbackRoute, ICb, ICbG, ICbGOpt, ICbOpt, IClOpt, IDisabledOpt, IEntryWrap, IGl, IGlOpt, IGlyphKey, IIdGOpt, IIdOpt, ILabel, ILabelOpt, ILabelTup, ILoadingOpt, ILy, ILyOpt, INavigationRoutePreventRouteNav, LcGeocodeCallback, NavigationRouteParamKey } from "$root"; +import type { CallbackPromise, CallbackPromiseGeneric, ElementCallbackMount, ElementCallbackValue, ElementCallbackValueBlur, ElementCallbackValueKeydown, FormField, GeometryGlyphDimension, GeometryScreenPosition, GeometryScreenPositionHorizontal, GlyphKey, GlyphWeight, NavigationParamTuple } from "@radroots/util"; export type IButtonNavRound = ICb & IDisabledOpt & ILoadingOpt & IGlyphKey; export type IFloatPage = { posx: Omit<GeometryScreenPositionHorizontal, "center">; -} -\ No newline at end of file +} +export type IToastKind = `simple`; + +export type IToast = IClOpt & + ILabel & IGlOpt & ILyOpt & { + styles?: IToastKind[]; + position?: GeometryScreenPosition; + }; + +export type IGlyph = ICbOpt & IIdOpt & ILyOpt & IClOpt & { + weight?: GlyphWeight; + key: GlyphKey; + dim?: GeometryGlyphDimension; +}; + +export type IInput<T extends string> = IIdGOpt<T> & IClOpt & ILyOpt & IDisabledOpt & { + placeholder?: string; + label?: string; + hidden?: boolean; + validate?: RegExp; + sync?: boolean; + field?: FormField; + field_constrain?: boolean; + callback?: ElementCallbackValue, + callback_keydown?: ElementCallbackValueKeydown<HTMLInputElement>, + callback_blur?: ElementCallbackValueBlur<HTMLInputElement>; + callback_focus?: ElementCallbackValueBlur<HTMLInputElement>; + callback_mount?: ElementCallbackMount<HTMLInputElement>; +}; + +export type IInputValue<T extends string> = Omit<IInput<T>, `id` | `sync`>; + +export type ISelectOption<T extends string> = IDisabledOpt & { + value: T; + label: string; +}; + +export type ISelectCallback = CallbackPromiseGeneric<ISelectOption<string>> + +export type ISelect = IIdOpt & IClOpt & ILyOpt & { + callback?: ISelectCallback; + sync?: boolean; + sync_init?: boolean; + options: { group?: string | true; entries: ISelectOption<string>[] }[]; + show_arrows?: 'l' | 'r'; +}; + +export type ITextArea = IIdOpt & IClOpt & ILyOpt & { + placeholder?: string; + label?: string; + hidden?: boolean; + validate?: RegExp; + sync?: true; + field?: FormField; + field_constrain?: boolean; + callback?: ElementCallbackValue, + callback_keydown?: ElementCallbackValueKeydown<HTMLTextAreaElement>, + callback_blur?: ElementCallbackValueBlur<HTMLTextAreaElement>; + callback_focus?: ElementCallbackValueBlur<HTMLTextAreaElement>; + callback_mount?: ElementCallbackMount<HTMLTextAreaElement>; +}; + +export type INavigationRoute<T extends string> = { + route: T | [T, NavigationParamTuple<NavigationRouteParamKey>[]]; +}; + +export type IPageToolbar<T extends string> = ICbOpt & { + header?: IPageHeader<T>; +}; + +export type IPageHeader<T extends string> = { + label: string; + callback_route?: CallbackRoute<T>; +}; + +export type IGlyphCircle = { + classes_wrap: string; + glyph: IGlyph +}; + +export type ITrellis = ILy & + IClOpt & + ITrellisStyles & { + id?: string; + view?: string; + title?: ITrellisTitle; + description?: ITrellisDescription; + default_el?: ITrellisDefault; + list?: (ITrellisKind | undefined)[]; + hide_offset?: true; + }; + +export type ITrellisStyles = { + hide_rounded?: boolean; + hide_border_top?: boolean; + hide_border_bottom?: boolean; + set_title_background?: boolean; + set_default_background?: boolean; +}; + +export type ITrellisTitle = ICbOpt & + IClOpt & { + mod?: ITrellisBasisOffsetMod, + value: string | true; + link?: ICbOpt & + IClOpt & + IGlOpt & ILabelOpt; + }; + +export type ITrellisDescription = string | true; + +export type ITrellisBasisOffsetModKey = 'sm' | 'glyph'; +export type ITrellisBasisOffsetMod = ITrellisBasisOffsetModKey | (({ glyph: IGlyph } | { glyph_circle: IGlyphCircle }) & { + loading?: boolean; +}); + +export type ITrellisDefault = { + labels?: ITrellisDefaultLabel[]; + show_title?: boolean; +}; + +export type ITrellisDefaultLabel = ICbOpt & { + label: string; + classes?: string; +}; + +export type ITrellisKind = ( + | ITrellisKindTouch + | ITrellisKindInput + | ITrellisKindSelect +); + +export type ITrellisBasis = { + loading?: boolean; + hide_active?: boolean; + hide_field?: boolean; + offset?: ITrellisBasisOffset; + full_rounded?: boolean; +}; + +export type ITrellisBasisOffset = ICbGOpt<MouseEvent> & + IClOpt & { + mod?: ITrellisBasisOffsetMod; + classes?: string; + hide_space?: boolean; + hide_offset?: boolean; + }; + +export type ITrellisKindDisplay = { + display?: ITrellisKindDisplayValue; +} +export type ITrellisKindDisplayValue = ICbGOpt<MouseEvent> & ILoadingOpt & + (ITrellisKindDisplayValueIcon | ILabel); + + +export type ITrellisKindDisplayValueIcon = { + icon: { + classes?: string; + key: GlyphKey; + }; +}; +export type ITrellisKindTouch = ITrellisBasis & { + touch: ITrellisBasisTouch; +}; + +export type ITrellisBasisTouch = ICbGOpt<MouseEvent> & + ILabelTup & ITrellisKindDisplay & { + end?: ITrellisBasisTouchEnd; + }; + +export type ITrellisKindInput = ITrellisBasis & { + input: ITrellisBasisInput; +}; + +export type ITrellisBasisInput = { + basis: IInput<string>; + line_label?: { + classes?: string; + value: string; + }; + action?: { + visible: boolean; + loading?: boolean; + callback?: CallbackPromise; + glyph?: IGlyph + }; +}; + +export type ITrellisKindSelect = ITrellisBasis & { + select: ITrellisBasisSelect; +}; + +export type ITrellisBasisSelect = ICbGOpt<MouseEvent> & + ILabelTup & ITrellisKindDisplay & ILoadingOpt & { + end?: ITrellisBasisTouchEnd; + el: ISelect & { value: string; }; + }; + +export type ITrellisBasisTouchEnd = ICbGOpt<MouseEvent> & IGl; + +export type INavBasisPrev = IClOpt & ICbG< + HTMLLabelElement | null +> & IGlOpt & ILabelOpt & IDisabledOpt & { + loading?: boolean; +}; +export type INavBasisOption = IClOpt & ICbG< + HTMLLabelElement | null +> & IGlOpt & ILabelOpt & IDisabledOpt & { + loading?: boolean; +}; +export type INavBasis<T extends string> = { + prev: ICbOpt & ILoadingOpt & INavigationRoute<T> & INavigationRoutePreventRouteNav & { + label?: string; + kind?: 'arrow' + }; + title?: ICbOpt & ILabel; + option?: INavBasisOption; +}; + +export type IEntrySelect = ILoadingOpt & { + wrap: IEntryWrap; + el: ISelect; + hide_arrows?: boolean; +}; + +export type IButtonSimple = ILyOpt & { + label: string; + callback: CallbackPromise; + allow_propogation?: boolean; +}; + +export type IMapMarkerArea = { + show_display?: boolean; + no_drag?: boolean; + lc_geocode: LcGeocodeCallback; +} + +export type ILayoutTrellisLine = ILabelOpt & + IClOpt & { + notify?: IClOpt & + ICb & + ILabelOpt & + IGlOpt & { + glyph_first?: boolean; + }; + }; diff --git a/apps-lib/src/lib/types/interface.ts b/apps-lib/src/lib/types/interface.ts @@ -0,0 +1,210 @@ +import type { IGlyph, IInput, IInputValue, ITextArea } from "$root"; +import type { CallbackPromise, CallbackPromiseGeneric, EntryStyle, GlyphKey, LayerGlyphBasisKind, LoadingBlades, LoadingDimension, SvelteTransitionConfig, ThemeLayer } from "@radroots/util"; + +export type IDisabled = { + disabled: boolean | never; +}; + +export type IDisabledOpt = Partial<IDisabled>; + +export type IBasisOpt<T extends object> = T | undefined; + +export type IBasis<T> = { + basis: T; +}; + +export type ICb = { + callback: CallbackPromise | never; +}; + +export type ICbOpt = Partial<ICb>; + +export type ICbG<T> = { + callback: CallbackPromiseGeneric<T> | never; +}; + +export type ICbGOpt<T> = Partial<ICbG<T>>; + +export type ICl = { + classes: string | never; +}; + +export type IClOpt = Partial<ICl>; + +export type IClWrap = { + classes_wr: string | never; +}; + +export type IClOptWrap = Partial<IClWrap>; + +export type IId = { + id: string | never; +}; + +export type IIdOpt = Partial<IId>; + +export type IGl = { + glyph: IGlyph | never; +}; + +export type IGlOpt = Partial<IGl>; + +export type IGlyphKey = { + glyph: GlyphKey +}; + +export type ILy = { + layer: ThemeLayer | never; +}; + +export type ILyOpt = Partial<ILy>; + +export type ILableFieldsSwap = { + toggle: boolean; + on: IClOpt & { + value: string; + }, + off: IClOpt & { + value: string; + }, +}; + +export type ILabelSwap = { + swap: ILableFieldsSwap; +} + +export type ILabelTupFields = { + left?: ILableFields[]; + right?: ILableFields[]; +}; + +export type ILabelTup = { + label: ILabelTupFields; +}; + +export type ILableFields = & { + classes_wrap?: string + classes?: string; + kind?: LayerGlyphBasisKind; + hide_truncate?: boolean; + hide_active?: boolean; +} & ( + ({ + value: string; + } | ILabelSwap) + | IGl + ); + +export type ILabel = { + label: ILableFields; +}; + +export type ILabelOpt = Partial<ILabel>; + +export type ILoadSymbol = IClOpt & { + color?: 'white'; + blades?: LoadingBlades; + dim?: LoadingDimension; +}; + +export type IIdG<T extends string> = { + id: T | never; +}; + +export type IIdGOpt<T extends string> = Partial<IIdG<T>>; + +export type IIdWrap = { + id_wrap: string | never; +}; + +export type IIdWrapOpt = Partial<IIdWrap>; + +export type ILabelValue = { + label: IClOpt & { + value: string; + }; +}; + +export type ILabelDisplay = IIdWrapOpt & IClOpt & ILabelValue & ILyOpt & { + style?: EntryStyle; +}; + + +export type ILoading = { + loading: boolean | never; +}; + +export type ILoadingOpt = Partial<ILoading>; + +export type IEntryWrap = IClOpt & IIdOpt & ILyOpt & { + style?: EntryStyle; + style_a?: true; + no_pad?: true; + fade?: { + in?: SvelteTransitionConfig; + out?: SvelteTransitionConfig; + }; +} + +export type IEntryLine = ILoadingOpt & { + wrap?: IEntryWrap; + el: IInputValue<string>; + notify_inline?: { + glyph: GlyphKey | IGlyph; + }; +}; + +export type IEntryLineIdb = ILoadingOpt & { + wrap?: IEntryWrap; + el: IInput<string>; + notify_inline?: { + glyph: GlyphKey | IGlyph; + }; +}; + +export type IEntryMultiLine = { + wrap?: IEntryWrap; + el: ITextArea; + notify_inline?: { + glyph: GlyphKey | IGlyph; + }; +} + +export type IEnvelopeLower = { + visible: boolean; + close: CallbackPromise; + full_cover?: boolean; + label_close?: string | true; +}; + +export type IButtonRound = IClOpt & ILoadingOpt & { + label: string; + callback: CallbackPromise; +}; + +export type INavigationRoutePreventRouteNav = { + prevent_route?: { + callback: CallbackPromise; + }; +}; + +export type INavigationRoutePreventRoute = { + prevent_route: CallbackPromise; +}; + +export type IImageBlob = IIdOpt & { + data: Uint8Array | undefined; + alt?: string; +}; + +export type IImagePath = IClOpt & + ICbGOpt< + MouseEvent & { + currentTarget: EventTarget & HTMLImageElement; + } + > & + IIdOpt & { + path?: string; + alt?: string; + }; + diff --git a/apps-lib/src/lib/types/lib.ts b/apps-lib/src/lib/types/lib.ts @@ -0,0 +1,20 @@ +import type { INavigationRoute } from "$root"; +import type { CallbackPromise, CallbackPromiseFull, CallbackPromiseResult, GeocoderReverseResult, GeolocationPoint, IClientGeolocationPosition, NavigationParamTuple } from "@radroots/util"; + +export type CallbackRoute<T extends string> = CallbackPromise | INavigationRoute<T>; + +export type NavigationRouteParamId = `id`; +export type NavigationRouteParamField = `field`; +export type NavigationRouteParamRef = `ref`; +export type NavigationRouteParamLat = `lat`; +export type NavigationRouteParamLng = `lng`; +export type NavigationRouteParamNostrPublicKey = `key_nostr`; +export type NavigationRouteParamKey = NavigationRouteParamId | NavigationRouteParamField | NavigationRouteParamRef | NavigationRouteParamLat | NavigationRouteParamLng | NavigationRouteParamNostrPublicKey; +export type NavigationPreviousParam<T extends string> = { route: T, label?: string; params?: NavigationParamTuple<NavigationRouteParamKey>[] } + +export type LcGuiAlertCallback = CallbackPromiseFull<string, boolean>; +export type LcGuiConfirmCallback = CallbackPromiseFull<string | { message: string; ok?: string; cancel?: string }, boolean>; +export type LcGeocodeCurrentCallback = CallbackPromiseResult<IClientGeolocationPosition>; +export type LcGeocodeCallback = CallbackPromiseFull<GeolocationPoint, GeocoderReverseResult | undefined>; +export type LcPhotoAddCallback = CallbackPromiseResult<string>; +export type LcPhotoAddMultipleCallback = CallbackPromiseResult<string[]>; diff --git a/apps-lib/src/lib/types/view.ts b/apps-lib/src/lib/types/view.ts @@ -1,24 +0,0 @@ -import type { CallbackPromiseGeneric } from "@radroots/util"; - -export type IViewProfileData = { - public_key: string; - name?: string; - display_name?: string; - about?: string; - picture?: string; -}; - -export type ViewProfileEditFieldKey = `name` | `display_name` | `about`; - -export type IViewProfileEditData = { - public_key: string; - field: ViewProfileEditFieldKey; -}; - -export type IViewOnMount<TypeCallbackParam> = { - lc_on_mount: CallbackPromiseGeneric<TypeCallbackParam>; -}; - -export type IViewOnDestroy<TypeCallbackParam> = { - lc_on_destroy: CallbackPromiseGeneric<TypeCallbackParam>; -}; diff --git a/apps-lib/src/lib/types/view/farm.ts b/apps-lib/src/lib/types/view/farm.ts @@ -0,0 +1,26 @@ +import type { GeolocationAddress, GeolocationPoint } from "@radroots/util"; + +export type IViewFarmsProductsAddSubmission = { + product: string; + process: string; + description: string; + price_amount: number; + price_currency: string; + price_quantity_unit: string; + photos: string[]; + quantity_amount: number; + quantity_unit: string; + quantity_label: string; + geolocation_point: GeolocationPoint; + geolocation_address: GeolocationAddress; +}; + +export type IViewFarmsAddSubmission = { + farm_name: string; + farm_area: number; + farm_area_unit: string; + farm_contact_name: string; + geolocation_point: GeolocationPoint; + geolocation_address: GeolocationAddress; +}; + diff --git a/apps-lib/src/lib/types/view/lib.ts b/apps-lib/src/lib/types/view/lib.ts @@ -0,0 +1,12 @@ +import type { CallbackPromiseGeneric } from "@radroots/util"; + +export type IHomeViewData = {}; + + +export type IViewOnMount<TypeCallbackParam> = { + lc_on_mount: CallbackPromiseGeneric<TypeCallbackParam>; +}; + +export type IViewOnDestroy<TypeCallbackParam> = { + lc_on_destroy: CallbackPromiseGeneric<TypeCallbackParam>; +}; diff --git a/apps-lib/src/lib/types/view/profile.ts b/apps-lib/src/lib/types/view/profile.ts @@ -0,0 +1,14 @@ +export type IViewProfileData = { + public_key: string; + name?: string; + display_name?: string; + about?: string; + picture?: string; +}; + +export type ViewProfileEditFieldKey = `name` | `display_name` | `about`; + +export type IViewProfileEditData = { + public_key: string; + field: ViewProfileEditFieldKey; +}; diff --git a/apps-lib/src/lib/util/component.ts b/apps-lib/src/lib/util/component.ts @@ -0,0 +1,45 @@ +import type { IToastKind } from "$lib/types/component"; +import type { AppLayoutKey, GeometryGlyphDimension, LoadingDimension } from "@radroots/util"; + +export const glyph_style_map: Map<GeometryGlyphDimension, { gl_1: number; dim_1?: number; }> = new Map([ + ["xs--", { gl_1: 12 }], + ["xs-", { gl_1: 12, dim_1: 17 }], + ["xs", { gl_1: 15, dim_1: 18 }], + ["xs+", { gl_1: 18, dim_1: 20 }], + ["sm-", { gl_1: 19, dim_1: 22 }], + ["sm", { gl_1: 20, dim_1: 24 }], + ["sm+", { gl_1: 21 }], + ["md-", { gl_1: 23 }], + ["md", { gl_1: 24 }], + ["md+", { gl_1: 26 }], + ["lg-", { gl_1: 27 }], + ["lg", { gl_1: 28 }], + ["xl", { gl_1: 30 }], + ["xl+", { gl_1: 40 }], +]); + +export const loading_style_map: Map<LoadingDimension, { dim_1: number; gl_2: number }> = new Map([ + ["glyph-send-button", { dim_1: 20, gl_2: 20 }], + ["xs", { dim_1: 12, gl_2: 12 }], + ["sm", { dim_1: 16, gl_2: 16 }], + ["md", { dim_1: 20, gl_2: 20 }], + ["lg", { dim_1: 28, gl_2: 28 }], + ["xl", { dim_1: 36, gl_2: 36 }], +]); + +export const toast_layout_map: Map<AppLayoutKey, string> = new Map([ + [`ios0`, `pt-8`], + [`ios1`, `pt-16`], + [`webm0`, `pt-8`], + [`webm1`, `pt-16`], +]); + +export const toast_style_map: Map<IToastKind, { inner: string; outer: string }> = new Map([ + [ + `simple`, + { + inner: `justify-center`, + outer: `min-h-toast_min w-full px-4 rounded-2xl shadow-sm`, + }, + ], +]); +\ No newline at end of file diff --git a/apps-lib/src/lib/util/lib.ts b/apps-lib/src/lib/util/lib.ts @@ -1,9 +1,9 @@ import { browser } from "$app/environment"; import { goto } from "$app/navigation"; import { page } from "$app/state"; -import { win_h, win_w } from "$root"; +import { win_h, win_w, type CallbackRoute } from "$root"; import type { ColorMode, ThemeKey } from "@radroots/theme"; -import { encode_route, fmt_geometry_point_coords, fmt_price, parse_currency_marker, type CallbackRoute, type GeometryPoint, type IErrorCatchCallback } from "@radroots/util"; +import { encode_route, fmt_geometry_point_coords, fmt_price, parse_currency_marker, type GeometryPoint, type IErrorCatchCallback } from "@radroots/util"; import { get } from "svelte/store"; export const get_store = get; @@ -48,7 +48,7 @@ export const callback_route = async <T extends string>(callback_route: CallbackR if (`route` in callback_route) { if (typeof callback_route.route === `string`) return void await goto(callback_route.route); else return void await goto( - encode_route( + encode_route<string>( callback_route.route[0], callback_route.route[1], ), diff --git a/apps-lib/src/lib/view/farms-add.svelte b/apps-lib/src/lib/view/farms-add.svelte @@ -1,224 +0,0 @@ -<script lang="ts"> - import LayoutBottomButton from "$lib/components/layout/layout-bottom-button.svelte"; - import Fade from "$lib/components/lib/fade.svelte"; - import { - app_platform, - ButtonLayoutPair, - Carousel, - casl_dec, - casl_i, - casl_inc, - casl_init, - FarmsAddCasliDetail, - FarmsAddCasliMap, - Glyph, - handle_err, - LayoutView, - PageToolbar, - } from "$root"; - import { - geol_lat_fmt, - geol_lng_fmt, - parse_float, - parse_geocode_address, - vs_view_farms_add_submission, - type CallbackPromiseGeneric, - type CallbackRoute, - type GeocoderReverseResult, - type GeolocationAddress, - type GeolocationPoint, - type I18nTranslateFunction, - type I18nTranslateLocale, - type IViewFarmsAddSubmission, - type LcGeocodeCallback, - type LcGeocodeCurrentCallback, - type LcGuiAlertCallback, - } from "@radroots/util"; - import { onMount } from "svelte"; - - let { - basis, - ls, - locale, - }: { - basis: { - callback_route?: CallbackRoute<string>; - lc_gui_alert: LcGuiAlertCallback; - lc_geop_current: LcGeocodeCurrentCallback; - lc_geocode: LcGeocodeCallback; - lc_submit: CallbackPromiseGeneric<{ - data_s: IViewFarmsAddSubmission; - }>; - }; - ls: I18nTranslateFunction; - locale: I18nTranslateLocale; - } = $props(); - - let loading = $state(false); - - let map_geop: GeolocationPoint = $state({ lat: 0, lng: 0 }); - let map_geoc: GeocoderReverseResult | undefined = $state(undefined); - - let val_farmname = $state(``); - let val_farmcontact = $state(``); - let val_farmarea = $state(``); - let val_farmarea_unit = $state(`ac`); - - const disabled_submit = $derived($casl_i === 1 && !val_farmname); - - onMount(async () => { - try { - casl_init(0, 2); - } catch (e) { - handle_err(e, `on_mount`); - } - }); - - const farm_geop_lat = $derived( - map_geop ? geol_lat_fmt(map_geop.lat, `dms`, $locale, 3) : ``, - ); - - const farm_geop_lng = $derived( - map_geop ? geol_lng_fmt(map_geop.lng, `dms`, $locale, 3) : ``, - ); - - const farm_geolocation_address: GeolocationAddress | undefined = $derived( - parse_geocode_address(map_geoc), - ); - - const handle_continue_0 = async (): Promise<void> => { - await casl_inc(); - }; - - const handle_continue_1 = async (): Promise<void> => { - if (!map_geop) - return void basis.lc_gui_alert(`No farm location provided.`); //@todo - if (!farm_geolocation_address) - return void basis.lc_gui_alert(`No farm address provided.`); //@todo - - const vp_obj_submit = vs_view_farms_add_submission.safeParse({ - farm_name: val_farmname, - farm_area: parse_float(val_farmarea), - farm_area_unit: val_farmarea_unit, - farm_contact_name: val_farmcontact, - geolocation_point: map_geop, - geolocation_address: farm_geolocation_address, - } satisfies IViewFarmsAddSubmission); - - if (!vp_obj_submit.success) { - return void basis.lc_gui_alert( - `Please correct the following errors: ${vp_obj_submit.error}`, - ); //@todo - } - loading = true; - await basis.lc_submit({ data_s: vp_obj_submit.data }); - loading = false; - }; - - const handle_continue = async (): Promise<void> => { - switch ($casl_i) { - case 0: - return await handle_continue_0(); - case 1: - return await handle_continue_1(); - } - }; - - const handle_back = async (): Promise<void> => { - switch ($casl_i) { - default: - return await casl_dec(); - } - }; -</script> - -<LayoutView> - <PageToolbar - basis={{ - header: { - label: `Farm / Add`, - callback_route: basis.callback_route, - }, - }} - > - {#snippet header_option()} - {#if $casl_i > 0} - <Fade> - <button - class={`flex flex-row pr-3 justify-center items-center`} - onclick={async () => { - await handle_back(); - }} - > - <p - class={`font-sans font-[600] text-lg text-layer-0-glyph`} - > - {`${$ls(`common.back`)}`} - </p> - </button> - </Fade> - {/if} - <button - class={`flex flex-row justify-center items-center`} - onclick={async () => { - await handle_continue(); - }} - > - <p class={`font-sans font-[600] text-lg text-layer-0-glyph-hl`}> - {`${$ls(`common.details`)}`} - </p> - <Glyph - basis={{ - classes: `text-layer-0-glyph-hl`, - dim: `md`, - key: `caret-right`, - }} - /> - </button> - {/snippet} - </PageToolbar> - <Carousel> - <FarmsAddCasliMap - bind:map_geop - bind:map_geoc - {farm_geop_lat} - {farm_geop_lng} - basis={{ - lc_geocode: basis.lc_geocode, - lc_geop_current: basis.lc_geop_current, - }} - /> - <FarmsAddCasliDetail - bind:val_farmname - bind:val_farmcontact - bind:val_farmarea - bind:val_farmarea_unit - {farm_geop_lat} - {farm_geop_lng} - {ls} - /> - </Carousel> -</LayoutView> -{#if $app_platform?.browser !== `safari`} - <LayoutBottomButton> - <ButtonLayoutPair - basis={{ - continue: { - label: `${$ls(`common.continue`)}`, - disabled: disabled_submit, - callback: handle_continue, - }, - back: { - label: `${$ls(`common.back`)}`, - visible: $casl_i > 0, - callback: handle_back, - }, - }} - /> - </LayoutBottomButton> -{/if} -<!--<div - class={`absolute bottom-lo_bottom_button_${$app_lo} left-0 flex flex-row w-full gap-1 justify-center items-center`} - > - - </div>--> diff --git a/apps-lib/src/lib/view/farms-products-add.svelte b/apps-lib/src/lib/view/farms-products-add.svelte @@ -1,659 +0,0 @@ -<script lang="ts"> - import { - ButtonHorizontalPairSlide, - ButtonRound, - Carousel, - CarouselItem, - casl_i, - casl_imax, - casl_inc, - casl_init, - FarmsProductsReviewCard, - fmt_id, - FormEntryPrice, - FormEntryQuantity, - FormEntrySelect, - FormEntrySelectInput, - FormEntryTextarea, - handle_err, - idb, - ImageUploadSimple, - LayoutBottomButton, - LayoutView, - lib_fmt_geometry_point_coords, - MapLocationSelectEnvelope, - MarkerIndexedView, - PageToolbar, - } from "$root"; - import { - el_id, - fmt_geocode_address, - fmt_geolocation_address, - form_fields, - obj_keys_maxnum, - parse_float, - parse_geocode_address, - parse_geolocation_address, - parse_geolocation_point, - parse_geop_point, - parse_int, - parse_trade_key, - sleep, - str_trunc, - trade, - trade_keys, - vs_view_farms_products_add_submission, - type CallbackPromiseFull, - type CallbackPromiseGeneric, - type CallbackRoute, - type GeocoderReverseResult, - type GeolocationAddress, - type GeolocationPoint, - type I18nTranslateFunction, - type I18nTranslateLocale, - type ISelectOption, - type IViewBasis, - type IViewFarmsProductsAddSubmission, - type LcGeocodeCallback, - type LcGeocodeCurrentCallback, - type LcGuiAlertCallback, - type LcGuiConfirmCallback, - type LcPhotoAddMultipleCallback, - type ResolveFarmInfo, - type ResolveGeolocationInfo, - } from "@radroots/util"; - import { onMount } from "svelte"; - - const casl_param: Record< - "default", - { - index_map: Record<number, { label_desc: string }>; - } - > = { - default: { - index_map: { - 0: { - label_desc: `Add product information`, - }, - 1: { - label_desc: `Upload images`, - }, - 2: { - label_desc: `Product Price`, - }, - 3: { - label_desc: `Add Location`, - }, - 4: { - label_desc: `Review`, - }, - }, - }, - }; - - let { - basis, - ls, - locale, - }: { - basis: IViewBasis<{ - data: ResolveFarmInfo; - callback_route?: CallbackRoute<string>; - lc_gui_alert: LcGuiAlertCallback; - lc_gui_confirm: LcGuiConfirmCallback; - lc_geocode: LcGeocodeCallback; - lc_handle_farm_lot_add: CallbackPromiseGeneric<string>; - lc_handle_photo_add: LcPhotoAddMultipleCallback; - lc_handle_photo_envelope_edit: CallbackPromiseGeneric<number>; - lc_img_bin: CallbackPromiseFull<string, Uint8Array | undefined>; - lc_handle_tradepr_key_toggle: CallbackPromiseFull<boolean, string>; - lc_geop_current: LcGeocodeCurrentCallback; - lc_submit: CallbackPromiseGeneric<{ - data_s: IViewFarmsProductsAddSubmission; - farm_id: string; - farm_lot_id?: string; - geolocation_id?: string; - }>; - }>; - ls: I18nTranslateFunction; - locale: I18nTranslateLocale; - } = $props(); - - let loading_submit = $state(false); - - let data_s: IViewFarmsProductsAddSubmission | undefined = $state(undefined); - - let photo_paths = $state([]); - - let toggle_opt_addexisting = $state(false); - - let product_key_sel = $state(`cacao`); - let product_key_sel_input = $state(``); - let product_key_sel_toggle = $state(false); - - let product_process_sel = $state(`raw`); - let product_process_sel_input = $state(``); - let product_process_sel_toggle = $state(false); - - let product_description_input = $state(`cool description`); - - let product_location_sel = $state(``); - let product_location_map_toggle = $state(false); - - let product_price_cur_sel = $state(`usd`); - let product_price_input = $state(`4.50`); - let product_price_qty_unit_sel = $state(`lb`); - - let product_quantity_input = $state(`60`); - let product_quantity_unit_sel = $state(`kg`); - let product_quantity_label_sel = $state(`bag`); - - let tradepr_lgc_map_point: GeolocationPoint | undefined = $state(undefined); - let tradepr_lgc_map_geoc: GeocoderReverseResult | undefined = - $state(undefined); - - const tradepr_key_parsed = $derived(parse_trade_key(product_key_sel)); - - const product_process_list = $derived( - tradepr_key_parsed ? trade.key[tradepr_key_parsed].process : [], - ); - - const list_farm_geolocations: ResolveGeolocationInfo[] = $derived( - [ - basis.data?.geolocation ? basis.data?.geolocation : undefined, - ...(basis.data?.farm_lots?.length - ? [...basis.data?.farm_lots.map((i) => i.geolocation)] - : []), - ].filter((i) => typeof i !== `undefined`), - ); - - const product_farm_lot_id: string | undefined = $derived( - product_location_sel === `*map-location` || - !basis.data?.farm_lots?.length - ? undefined - : basis.data?.farm_lots.find( - (i) => i.geolocation.id === product_location_sel, - )?.id || undefined, - ); - - const product_geolocation_id: string | undefined = $derived( - product_location_sel === `*map-location` - ? undefined - : list_farm_geolocations.find((i) => i.id === product_location_sel) - ?.id || undefined, - ); - - const product_geolocation: ResolveGeolocationInfo | undefined = $derived( - list_farm_geolocations.find((i) => i.id === product_location_sel) || - undefined, - ); - - const product_geolocation_point: GeolocationPoint | undefined = $derived( - product_location_sel === `*map-location` - ? tradepr_lgc_map_point - : parse_geolocation_point(product_geolocation?.point) || undefined, - ); - - const product_geolocation_address: GeolocationAddress | undefined = - $derived( - product_location_sel === `*map-location` - ? parse_geocode_address(tradepr_lgc_map_geoc) - : parse_geolocation_address(product_geolocation?.address) || - undefined, - ); - - const entries_farm_location: ISelectOption<string>[] = $derived( - basis.data?.geolocation - ? [ - { - value: basis.data.geolocation.id, - label: - fmt_geolocation_address( - basis.data.geolocation.address, - ) || - lib_fmt_geometry_point_coords( - $locale, - basis.data.geolocation.point, - ) || - ``, - }, - ] - : [], - ); - const entries_farm_lots_locations: ISelectOption<string>[] = $derived( - basis.data?.farm_lots?.length - ? basis.data.farm_lots - .filter( - (i) => - i.geolocation.address && - !entries_farm_location - .map((i) => i.value) - .includes(i.geolocation.id), - ) - .map(({ geolocation }) => ({ - value: geolocation.id, - label: `${geolocation.address.primary}, ${geolocation.address.admin}, ${geolocation.address.country}`, - })) - : [], - ); - - onMount(async () => { - try { - casl_init(0, obj_keys_maxnum(casl_param.default.index_map)); - } catch (e) { - handle_err(e, `on_mount`); - } - }); - - const handle_sel_key = async (value: string): Promise<void> => { - el_id(fmt_id(`key_wrap`))?.classList.remove(`layer-1-ring-apply`); - if (value === `*other`) { - await handle_tradepr_key_toggle(true); - } - }; - - const handle_tradepr_key_toggle = async ( - input_visible: boolean, - ): Promise<void> => { - product_key_sel_toggle = input_visible; - if (input_visible) { - product_key_sel_input = ``; - } else { - product_key_sel = ``; - product_key_sel_input = ``; - } - }; - - const handle_sel_process = async (value: string): Promise<void> => { - el_id(fmt_id(`process_wrap`))?.classList.remove(`layer-1-ring-apply`); - if (value === `*choose-product`) { - product_process_sel = ``; - el_id(fmt_id(`key_wrap`))?.classList.add(`layer-1-ring-apply`); - await sleep(1000); - el_id(fmt_id(`key_wrap`))?.classList.remove(`layer-1-ring-apply`); - } - }; - - const handle_product_process_toggle = async ( - input_visible: boolean, - ): Promise<void> => { - product_process_sel_toggle = input_visible; - if (input_visible) { - product_process_sel = ``; - product_process_sel_input = ``; - } - }; - - const handle_product_location_sel_map = async ( - value: string, - ): Promise<void> => { - el_id(fmt_id(`location_wrap`))?.classList.remove(`layer-1-ring-apply`); - if (value === `*map`) { - if (tradepr_lgc_map_point) tradepr_lgc_map_point = undefined; - if (tradepr_lgc_map_geoc) tradepr_lgc_map_geoc = undefined; - const geop = await basis.lc_geop_current(); - if (!geop) { - return void (await basis.lc_gui_alert( - `${$ls(`icu.failure_*`, { value: `${$ls(`icu.reading_*`, { value: `${$ls(`common.location`)}`.toLowerCase() })}` })}`, - )); - } - const geoc = await basis.lc_geocode(geop); - if (geoc) tradepr_lgc_map_geoc = geoc; - tradepr_lgc_map_point = parse_geop_point(geop); - product_location_map_toggle = true; - await sleep(1000); - product_location_sel = ``; - } - }; - - const continue_0 = async (): Promise<void> => { - for (const kv_id of [`key`, `process`, `description`]) { - const val = await idb.get(fmt_id(kv_id)); - if (!val) - return void basis.lc_gui_alert( - `${$ls(`farm.product.validation.${kv_id}.required`)}`, - ); - } - await casl_inc(); - }; - - const continue_1 = async (): Promise<void> => { - if (!photo_paths.length) - return void basis.lc_gui_alert( - `Upload a product photo`, //@todo - ); - await casl_inc(); - }; - - const continue_2 = async (): Promise<void> => { - await casl_inc(); - }; - - const continue_3 = async (): Promise<void> => { - if (!product_geolocation_point || !product_geolocation_address) - return void (await basis.lc_gui_alert( - `Select the product location`, //@todo - )); - const vp_data_s = vs_view_farms_products_add_submission.safeParse({ - product: product_key_sel_input || product_key_sel, - process: product_process_sel_input || product_process_sel, - description: product_description_input, - price_amount: parse_float(product_price_input, 1.0), - price_currency: product_price_cur_sel, - price_quantity_unit: product_price_qty_unit_sel, - quantity_amount: parse_int(product_quantity_input, 1), - quantity_unit: product_quantity_unit_sel, - quantity_label: product_quantity_label_sel, - photos: photo_paths, - geolocation_point: product_geolocation_point, - geolocation_address: product_geolocation_address, - } satisfies IViewFarmsProductsAddSubmission); - if (!vp_data_s.success) { - return void basis.lc_gui_alert( - `Please correct the following errors: ${vp_data_s.error}`, - ); - } - data_s = vp_data_s.data; - await casl_inc(); - }; - - const continue_4 = async (): Promise<void> => { - if (!data_s) return; - loading_submit = true; - await basis.lc_submit({ - data_s, - farm_id: basis.data.id, - farm_lot_id: product_farm_lot_id, - geolocation_id: product_geolocation_id, - }); - loading_submit = false; - }; - - const handle_continue = async (num_i?: number): Promise<void> => { - try { - const num = num_i ?? $casl_i; - switch (num) { - case 0: - return await continue_0(); - case 1: - return await continue_1(); - case 2: - return await continue_2(); - case 3: - return await continue_3(); - case 4: - return await continue_4(); - } - } catch (e) { - await handle_err(e, `handle_continue`); - } - }; -</script> - -<LayoutView basis={{ classes: `` }}> - <PageToolbar - basis={{ - header: { - label: `${`${$ls(`common.farm`)}`} / ${`${$ls(`common.product`)}`}`, - callback_route: basis.callback_route || { route: `/farms` }, - }, - }} - /> - <div class={`flex flex-col w-full pt-4 px-4 justify-center items-center`}> - <div class={`flex flex-row w-full gap-2 justify-center items-center`}> - <ButtonHorizontalPairSlide - bind:toggle={toggle_opt_addexisting} - basis={{ - label_l: `${$ls(`common.create_product`)}`, - label_r: `${$ls(`common.add_from_existing`)}`, - }} - /> - </div> - </div> - {#if !toggle_opt_addexisting} - <LayoutBottomButton> - <ButtonRound - basis={{ - classes: `text-layer-0-glyph bg-layer-1-surface active:bg-layer-1-surface_a`, - loading: loading_submit, - label: - $casl_i === $casl_imax - ? `${$ls(`common.post`)}` - : `${$ls(`common.continue`)}`, - callback: async () => { - handle_continue(); - }, - }} - /> - </LayoutBottomButton> - <div - class={`flex flex-col w-full p-4 gap-4 justify-center items-center`} - > - <div class={`flex flex-row h-2 w-full justify-start items-center`}> - <p - class={`font-sans font-[500] text-sm text-layer-0-glyph/60 capitalize`} - > - {casl_param.default.index_map[$casl_i]?.label_desc} - </p> - </div> - <MarkerIndexedView - basis={{ - index_max: $casl_imax + 1, - index_curr: $casl_i, - callback_index: async (index) => { - casl_i.set(index); - }, - }} - /> - </div> - <Carousel> - <CarouselItem basis={{ classes: `gap-4` }}> - <FormEntrySelectInput - bind:val_sel={product_key_sel} - bind:val_sel_input={product_key_sel_input} - {ls} - basis={{ - id: `key`, - entry_label: `${$ls(`common.product`)}`, - visible_input: product_key_sel_toggle, - input_placeholder: `${$ls(`icu.enter_the_*`, { value: `${$ls(`icu.*_name`, { value: `${$ls(`common.product`)}` })}`.toLowerCase() })}`, - input_field: form_fields.product_key, - callback_visible: handle_tradepr_key_toggle, - callback_select: async ({ value }) => - await handle_sel_key(value), - select_entries: [ - { - value: ``, - label: `${$ls(`icu.choose_*`, { value: `${$ls(`common.product`)}`.toLowerCase() })}`, - disabled: true, - }, - ...trade_keys.map((i) => ({ - value: i, - label: `${$ls(`trade.product.key.${i}.name`)}`, - })), - { - value: `*other`, - label: `${$ls(`common.other`)}`, - }, - ], - }} - /> - <FormEntrySelectInput - bind:val_sel={product_process_sel} - bind:val_sel_input={product_process_sel_input} - {ls} - basis={{ - id: `process`, - entry_label: `${$ls(`common.process`)}`, - visible_input: product_process_sel_toggle, - input_placeholder: `${$ls(`icu.enter_the_*`, { value: `${$ls(`common.process`)}`.toLowerCase() })}`, - input_field: form_fields.product_process, - callback_visible: handle_product_process_toggle, - callback_select: async ({ value }) => - await handle_sel_process(value), - select_entries: product_process_list.length - ? [ - { - value: ``, - label: `${$ls(`icu.choose_*`, { value: `${$ls(`common.process`)}`.toLowerCase() })}`, - disabled: true, - }, - ...product_process_list.map((i) => ({ - value: i, - label: `${$ls(`trade.product.key.${tradepr_key_parsed}.process.${i}`)}`, - })), - { - value: `*other`, - label: `${$ls(`common.other`)}`, - }, - ] - : [ - { - value: ``, - label: `${$ls(`icu.choose_*`, { value: `${$ls(`common.process`)}`.toLowerCase() })}`, - disabled: true, - }, - { - value: `*choose-product`, - label: `${$ls(`icu.choose_*`, { value: `${$ls(`common.product`)}`.toLowerCase() })}`, - }, - ].concat( - product_key_sel === `*other` - ? [ - ...trade.default.process.map( - (i) => ({ - value: i, - label: `${$ls(`trade.product.default.process.${i}`)}`, - }), - ), - { - value: `*other`, - label: `${$ls(`common.other`)}`, - }, - ] - : [], - ), - }} - /> - <FormEntryTextarea - bind:val={product_description_input} - basis={{ - id: `description`, - entry_label: `${$ls(`common.description`)}`, - field: form_fields.product_description, - placeholder: `${$ls(`common.describe_your_product`)}`, - }} - /> - </CarouselItem> - <CarouselItem basis={{ classes: `px-4` }}> - <ImageUploadSimple - bind:photo_paths - basis={{ - lc_handle_photo_add: basis.lc_handle_photo_add, - }} - /> - </CarouselItem> - <CarouselItem basis={{ classes: `gap-4` }}> - <FormEntryPrice - bind:val_input_price={product_price_input} - bind:val_sel_currency={product_price_cur_sel} - bind:val_sel_quantity_unit={product_price_qty_unit_sel} - {ls} - {locale} - basis={{ - id: `price`, - entry_label: `price`, - input_placeholder: `Enter price`, - }} - /> - <FormEntryQuantity - bind:val_input_quantity={product_quantity_input} - bind:val_sel_quantity_unit={product_quantity_unit_sel} - bind:val_sel_quantity_label={product_quantity_label_sel} - {ls} - basis={{ - id: `quantity`, - entry_label: `quantity`, - input_placeholder: `Enter quantity`, - }} - /> - </CarouselItem> - <CarouselItem> - <FormEntrySelect - bind:val={product_location_sel} - basis={{ - id: `location`, - entry_label: `${$ls(`common.location`)}`, - callback: async ({ value }) => - await handle_product_location_sel_map(value), - entries: tradepr_lgc_map_geoc - ? [ - { - value: ``, - label: `${$ls(`icu.choose_*`, { value: `${$ls(`common.location`)}`.toLowerCase() })}`, - disabled: true, - }, - { - value: `*map`, - label: `${$ls(`icu.choose_on_*`, { value: `${$ls(`common.map`)}`.toLowerCase() })}`, - }, - { - value: `*map-location`, - label: `${str_trunc(fmt_geocode_address(tradepr_lgc_map_geoc))} (map)`, - }, - ...entries_farm_location, - ...entries_farm_lots_locations, - ] - : [ - { - value: ``, - label: `${$ls(`icu.choose_*`, { value: `${$ls(`common.location`)}`.toLowerCase() })}`, - disabled: true, - }, - ...entries_farm_location, - ...entries_farm_lots_locations, - { - value: `*map`, - label: `${$ls(`icu.choose_on_*`, { value: `${$ls(`common.map`)}`.toLowerCase() })}`, - }, - ], - }} - /> - </CarouselItem> - <CarouselItem> - <div class={`flex flex-col w-full justify-center items-center`}> - <FarmsProductsReviewCard - basis={{ - data: data_s, - }} - {ls} - {locale} - /> - </div> - </CarouselItem> - </Carousel> - {:else} - <p class={`font-sans font-[400] text-layer-0-glyph`}> - {`Coming soon!`} - </p> - {/if} -</LayoutView> -<MapLocationSelectEnvelope - bind:map_geop={tradepr_lgc_map_point} - bind:map_geoc={tradepr_lgc_map_geoc} - basis={{ - visible: product_location_map_toggle, - farm_info: basis.data, - lc_geocode: basis.lc_geocode, - lc_submit: async ({ map_geoc, map_geop }) => { - try { - if (map_geoc && map_geop) - product_location_sel = `*map-location`; - else product_location_sel = ``; - product_location_map_toggle = false; - } catch (e) { - await handle_err(e, `lc_submit`); - } - }, - }} -/> diff --git a/apps-lib/src/lib/view/farms-products-view.svelte b/apps-lib/src/lib/view/farms-products-view.svelte @@ -1,56 +0,0 @@ -<script lang="ts"> - import { - ButtonLabelDashed, - LayoutPage, - LayoutView, - PageToolbar, - } from "$root"; - import { - type CallbackPromise, - type CallbackRoute, - type I18nTranslateFunction, - type IViewBasis, - type ResolveFarmProductInfo, - } from "@radroots/util"; - - let { - basis, - ls, - }: { - basis: IViewBasis<{ - data: ResolveFarmProductInfo[]; - callback_route?: CallbackRoute<string>; - lc_handle_farm_product_add: CallbackPromise; - }>; - ls: I18nTranslateFunction; - } = $props(); -</script> - -<LayoutView> - <PageToolbar - basis={{ - header: { - label: `${$ls(`common.products`)}`, - callback_route: basis.callback_route || { route: `/farms` }, - }, - }} - /> - <LayoutPage> - {#if basis.data?.length} - {#each basis.data as li} - <div class={`flex flex-row justify-start items-center`}> - {JSON.stringify(li)} - </div> - {/each} - {:else} - <ButtonLabelDashed - basis={{ - label: `Add product`, - callback: async () => { - await basis.lc_handle_farm_product_add(); - }, - }} - /> - {/if} - </LayoutPage> -</LayoutView> diff --git a/apps-lib/src/lib/view/farms-view.svelte b/apps-lib/src/lib/view/farms-view.svelte @@ -1,268 +0,0 @@ -<script lang="ts"> - import Empty from "$lib/components/lib/empty.svelte"; - import { - ButtonSimple, - Glyph, - handle_err, - LayoutPage, - LayoutView, - Map, - MapMarkerArea, - PageToolbar, - } from "$root"; - import { - geol_lat_fmt, - geol_lng_fmt, - lib_address_fmt, - parse_geom_point_tup, - parse_tup_geop_point, - type CallbackPromiseGeneric, - type CallbackRoute, - type GeolocationPointTuple, - type I18nTranslateFunction, - type I18nTranslateLocale, - type IViewBasis, - type LcGeocodeCallback, - type ResolveFarmInfo, - } from "@radroots/util"; - import { onMount } from "svelte"; - - let { - basis, - ls, - locale, - }: { - basis: IViewBasis<{ - data: ResolveFarmInfo; - callback_route?: CallbackRoute<string>; - lc_geocode: LcGeocodeCallback; - lc_handle_farm_lot_add: CallbackPromiseGeneric<string>; - lc_handle_farm_products_view: CallbackPromiseGeneric<string>; - lc_handle_farm_orders_view: CallbackPromiseGeneric<string>; - }>; - ls: I18nTranslateFunction; - locale: I18nTranslateLocale; - } = $props(); - - let map: maplibregl.Map | undefined = $state(undefined); - let map_center: GeolocationPointTuple = $state([0, 0]); - - onMount(async () => { - try { - if (map && basis.data?.geolocation?.point) { - map_center = parse_geom_point_tup(basis.data.geolocation.point); - map.setCenter(map_center); - map.setZoom(12); - } - } catch (e) { - handle_err(e, `on_mount`); - } - }); - - const map_geop = $derived(parse_tup_geop_point(map_center)); - - const info_addr_fmt = $derived( - basis.data?.geolocation?.address - ? lib_address_fmt(basis.data.geolocation.address) - : ``, - ); - - const info_geop_lat = $derived( - basis.data?.geolocation?.point?.coordinates - ? geol_lat_fmt( - basis.data.geolocation.point.coordinates[1], - `dms`, - $locale, - 3, - ) - : ``, - ); - - const info_geop_lng = $derived( - basis.data?.geolocation?.point?.coordinates - ? geol_lng_fmt( - basis.data.geolocation.point.coordinates[0], - `dms`, - $locale, - 3, - ) - : ``, - ); -</script> - -<LayoutView> - <PageToolbar - basis={{ - header: { - label: `${$ls(`common.farms`)} / ${basis.data.name || ``}`, - callback_route: basis.callback_route, - }, - }} - /> - <LayoutPage> - <div - class={`flex flex-row h-[12rem] w-full justify-start items-center`} - > - <div - class={`flex flex-col basis-1/2 h-full p-4 gap-2 justify-start items-center`} - > - <div class={`flex flex-col w-full justify-start items-center`}> - <div - class={`flex flex-row w-full justify-start items-center`} - > - <p - class={`font-sans font-[500] text-lg text-layer-0-glyph`} - > - {info_addr_fmt} - </p> - </div> - <div - class={`flex flex-row w-full justify-start items-center`} - > - <p - class={`font-sans font-[500] text-lg text-layer-0-glyph tracking-tight`} - > - {info_geop_lat && info_geop_lng - ? `${info_geop_lat}, ${info_geop_lng}` - : ``} - </p> - </div> - </div> - </div> - <div - class={`flex flex-col basis-1/2 h-full justify-start items-center`} - > - <div - class={`flex flex-col h-full w-full p-4 gap-4 justify-start items-center bg-layer-1-surface rounded-2xl`} - > - <p - class={`font-sans font-[500] text-sm text-layer-0-glyph`} - > - {`Farm Info`} - </p> - <div - class={`flex flex-col w-full gap-1 justify-start items-center`} - > - <div - class={`flex flex-row w-full gap-4 justify-between items-center`} - > - <p - class={`font-sans font-[400] text-layer-0-glyph`} - > - {`Farm Size:`} - </p> - - {#if basis.data.area && basis.data.area_unit} - <p - class={`font-sans font-[400] text-layer-0-glyph`} - > - {`${basis.data.area} ${basis.data.area_unit}`} - </p> - {:else} - <div - class={`flex flex-row gap-line justify-start items-center`} - > - <p - class={`font-sans font-[400] text-layer-0-glyph_pl`} - > - {`Add`} - </p> - <Glyph - basis={{ - classes: `text-layer-0-glyph_pl`, - dim: `xs`, - key: `caret-right`, - }} - /> - </div> - {/if} - </div> - <div - class={`flex flex-row w-full gap-4 justify-between items-center`} - > - <p - class={`font-sans font-[400] text-layer-0-glyph`} - > - {`Farm Lots:`} - </p> - <p - class={`font-sans font-[400] text-layer-0-glyph`} - > - {`${basis.data.farm_lots?.length || 0}`} - </p> - </div> - <div - class={`flex flex-row w-full gap-4 justify-between items-center`} - > - <p - class={`font-sans font-[400] text-layer-0-glyph`} - > - {`Products:`} - </p> - <p - class={`font-sans font-[400] text-layer-0-glyph`} - > - {`${0}`} - </p> - </div> - <div - class={`flex flex-row w-full gap-4 justify-between items-center`} - > - <p - class={`font-sans font-[400] text-layer-0-glyph`} - > - {`Orders:`} - </p> - <p - class={`font-sans font-[400] text-layer-0-glyph`} - > - {`${0}`} - </p> - </div> - </div> - </div> - </div> - </div> - <div class={`flex flex-col w-full gap-3 justify-center items-center`}> - <ButtonSimple - basis={{ - label: `View Products`, - callback: async () => { - await basis.lc_handle_farm_products_view(basis.data.id); - }, - }} - /> - <ButtonSimple - basis={{ - label: `View Orders`, - callback: async () => { - await basis.lc_handle_farm_orders_view(basis.data.id); - }, - }} - /> - </div> - <div - class={`flex flex-col flex-shrink-0 h-[16rem] w-full justify-center items-center rounded-2xl overflow-hidden`} - > - <Map - bind:map - basis={{ - interactive: false, - }} - > - <MapMarkerArea - {map_geop} - basis={{ - no_drag: true, - lc_geocode: basis.lc_geocode, - }} - /> - </Map> - </div> - <div - class={`flex flex-col h-[12rem] w-full justify-center items-center`} - > - <Empty /> - </div> - </LayoutPage> -</LayoutView> diff --git a/apps-lib/src/lib/view/farms.svelte b/apps-lib/src/lib/view/farms.svelte @@ -1,96 +0,0 @@ -<script lang="ts"> - import { - ButtonLabelDashed, - Fade, - FarmsDisplayLiEl, - GlyphButtonSimple, - handle_err, - idb_init_page, - LayoutPage, - LayoutView, - PageToolbar, - } from "$root"; - import { - type CallbackPromise, - type CallbackPromiseGeneric, - type CallbackRoute, - type I18nTranslateFunction, - type I18nTranslateLocale, - type IViewBasis, - type LcGeocodeCallback, - type ResolveFarmInfo, - } from "@radroots/util"; - import { onMount } from "svelte"; - - let { - basis, - ls, - locale, - }: { - basis: IViewBasis<{ - data?: ResolveFarmInfo[]; - callback_route?: CallbackRoute<string>; - lc_geocode: LcGeocodeCallback; - lc_handle_farm_add: CallbackPromise; - lc_handle_farm_view: CallbackPromiseGeneric<string>; - }>; - ls: I18nTranslateFunction; - locale: I18nTranslateLocale; - } = $props(); - - onMount(async () => { - try { - if (!basis.kv_init_prevent) await idb_init_page(); - } catch (e) { - handle_err(e, `on_mount`); - } - }); -</script> - -<LayoutView> - <PageToolbar - basis={{ - header: { - label: `${$ls(`common.farms`)}`, - callback_route: basis.callback_route, - }, - }} - > - {#snippet header_option()} - {#if basis.data?.length} - <Fade> - <GlyphButtonSimple - basis={{ - label: `${$ls(`icu.add_*`, { value: `${$ls(`common.farm`)}` })}`, - callback: async () => { - await basis.lc_handle_farm_add(); - }, - }} - ></GlyphButtonSimple> - </Fade> - {/if} - {/snippet} - </PageToolbar> - <LayoutPage> - {#if basis.data?.length} - {#each basis.data as li} - <FarmsDisplayLiEl - basis={li} - lc_geocode={basis.lc_geocode} - lc_handle_farm_view={basis.lc_handle_farm_view} - {ls} - {locale} - /> - {/each} - {:else} - <ButtonLabelDashed - basis={{ - label: `Add farm`, - callback: async () => { - await basis.lc_handle_farm_add(); - }, - }} - /> - {/if} - </LayoutPage> -</LayoutView> diff --git a/apps-lib/src/lib/view/home.svelte b/apps-lib/src/lib/view/home.svelte @@ -7,12 +7,12 @@ LayoutView, NavigationTabs, PageToolbar, + type IHomeViewData, } from "$root"; import { type CallbackPromise, type I18nTranslateFunction, type IViewBasis, - type ResolveAccountInfo, } from "@radroots/util"; import { onMount } from "svelte"; @@ -21,7 +21,7 @@ basis, }: { basis: IViewBasis<{ - data?: ResolveAccountInfo; + data: IHomeViewData; lc_handle_farms: CallbackPromise; lc_handle_products: CallbackPromise; }>; @@ -54,16 +54,6 @@ }, }} /> - {#if basis.data?.farms?.length} - <ButtonSimple - basis={{ - label: `${$ls(`common.products`)}`, - callback: async () => { - await basis.lc_handle_products(); - }, - }} - /> - {/if} </LayoutPage> </LayoutView> <NavigationTabs /> diff --git a/apps-lib/src/lib/view/profile.svelte b/apps-lib/src/lib/view/profile.svelte @@ -13,15 +13,15 @@ type IViewOnDestroy, type IViewProfileData, type ViewProfileEditFieldKey, + type LcPhotoAddCallback, } from "$root"; import { ascii, type CallbackPromise, type CallbackPromiseFull, type CallbackPromiseGeneric, - type I18nTranslateFunction, type IViewBasis, - type LcPhotoAddCallback, + type I18nTranslateFunction, } from "@radroots/util"; import { onDestroy, onMount } from "svelte"; diff --git a/apps-lib/src/lib/view/search.svelte b/apps-lib/src/lib/view/search.svelte @@ -1,117 +0,0 @@ -<script lang="ts"> - import { - fmt_id, - Glyph, - handle_err, - idb_init_page, - Input, - LayoutPage, - LayoutView, - NavigationTabs, - PageToolbar, - SearchResultDisplay, - } from "$root"; - import { - cfg_app, - debounce_callback, - SearchService, - type CallbackPromise, - type CallbackPromiseGeneric, - type I18nTranslateFunction, - type IViewBasis, - type IViewSearchData, - type ResolveGeolocationInfo, - type ResolveProfileInfo, - type SearchServiceResult, - } from "@radroots/util"; - import { onMount } from "svelte"; - - let { - basis, - ls, - }: { - basis: IViewBasis<{ - data: IViewSearchData; - lc_handle_back: CallbackPromise; - lc_handle_search_geolocation: CallbackPromiseGeneric<ResolveGeolocationInfo>; - lc_handle_search_profile: CallbackPromiseGeneric<ResolveProfileInfo>; - lc_handle_search_nostr_relay: CallbackPromiseGeneric<{ - id: string; - }>; - }>; - ls: I18nTranslateFunction; - } = $props(); - - $effect(() => { - console.log(JSON.stringify(basis.data, null, 4), `basis.data`); - }); - - let search_service: SearchService | undefined = undefined; - let search_val = $state(``); - let search_results: SearchServiceResult[] = $state([]); - - onMount(async () => { - try { - search_val = ``; - if (!basis.kv_init_prevent) await idb_init_page(); - search_service = new SearchService(basis.data); - } catch (e) { - handle_err(e, `on_mount`); - } - }); - - const handle_search_input = debounce_callback((val: string) => { - console.log(`val `, val); - if (search_service) search_results = search_service.search(val); - }, cfg_app.debounce.search); -</script> - -<LayoutView> - <PageToolbar - basis={{ - header: { label: `${$ls(`common.search`)}` }, - callback: basis.lc_handle_back, - }} - /> - <LayoutPage> - <div - class={`relative flex flex-row w-full justify-center items-center bg-layer-1-surface rounded-2xl`} - > - <Glyph - basis={{ - classes: `absolute left-4 text-layer-0-glyph-shade`, - dim: `sm`, - - key: `magnifying-glass`, - }} - /> - <Input - bind:value={search_val} - basis={{ - id: fmt_id(`search`), - sync: true, - classes: `pl-12 text-layer-0-glyph`, - placeholder: `Enter search query`, - callback: async ({ value }) => handle_search_input(value), - }} - /> - </div> - <div class={`flex flex-col w-full gap-4 justify-center items-center`}> - {#each search_results as li (li.id)} - <SearchResultDisplay - basis={{ - result: li, - lc_handle_search_geolocation: - basis.lc_handle_search_geolocation, - lc_handle_search_profile: - basis.lc_handle_search_profile, - lc_handle_search_nostr_relay: - basis.lc_handle_search_nostr_relay, - }} - {ls} - /> - {/each} - </div> - </LayoutPage> -</LayoutView> -<NavigationTabs /> diff --git a/apps-lib/src/lib/view/settings.svelte b/apps-lib/src/lib/view/settings.svelte @@ -7,13 +7,13 @@ LayoutView, PageToolbar, Trellis, + type ISelectOption, + type ITrellisKind, } from "$root"; import { ascii, type CallbackPromiseGeneric, type I18nTranslateFunction, - type ISelectOption, - type ITrellisKind, type IViewBasis, } from "@radroots/util"; import { onMount } from "svelte";