web_lib

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

commit 64d9bdfe425ba34a65c05d70854a639b62b0efa2
parent d6f7c31053d69cb5d76042ca3466c0e802990b84
Author: triesap <137732411+triesap@users.noreply.github.com>
Date:   Thu, 13 Feb 2025 11:32:46 +0000

utils: edit app layout keys, resolve types, utils

Diffstat:
Mutils/src/app/lib.ts | 31+++++++++++++++++++++++++++----
Mutils/src/app/types/app.ts | 9+++++++--
Mutils/src/app/types/resolve.ts | 2+-
Mutils/src/app/util.ts | 15++++++++++++++-
4 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/utils/src/app/lib.ts b/utils/src/app/lib.ts @@ -3,25 +3,48 @@ import type { AppLayoutKey } from "$root"; type ConfigWindow = { layout: Record<AppLayoutKey, { h: number; + w?: number; }>; debounce: { search: number; } }; +/* +{ + xs: 0, + sm: 640, + md: 768, + lg: 1024, + xl: 1280, + "2xl": 1536 + }; +*/ export const cfg_app: ConfigWindow = { layout: { ios0: { - h: 600 + h: 600, + w: 300, }, ios1: { - h: 750 + h: 750, + w: 350, }, webm0: { - h: 600 + h: 600, + w: 300, }, webm1: { - h: 750 + h: 750, + w: 800, + }, + web_mobile: { + h: 600, + w: 300, + }, + web_desktop: { + h: 600, + w: 300, } }, debounce: { diff --git a/utils/src/app/types/app.ts b/utils/src/app/types/app.ts @@ -5,11 +5,14 @@ export type ThemeLayer = 0 | 1 | 2; export type AppConfigType = `farmer` | `personal` export type AppLayoutKeyIOS = `ios0` | `ios1`; -export type AppLayoutKeyWeb = `webm0` | `webm1`; -export type AppLayoutKey = AppLayoutKeyIOS | AppLayoutKeyWeb; +export type AppLayoutKeyWeb = `web_mobile` | `web_desktop`; +export type AppLayoutKeyWebPwa = `webm0` | `webm1`; + +export type AppLayoutKey = AppLayoutKeyIOS | AppLayoutKeyWeb | AppLayoutKeyWebPwa; export type AppLayoutIOS<T extends string> = `${T}_${AppLayoutKeyIOS}`; export type AppLayoutWeb<T extends string> = `${T}_${AppLayoutKeyWeb}`; +export type AppLayoutWebPwa<T extends string> = `${T}_${AppLayoutKeyWeb}`; export type AppLayoutKeyHeight = | `lo_bottom_button` @@ -23,9 +26,11 @@ export type AppLayoutKeyWidth = export type AppHeightsResponsiveIOS = AppLayoutIOS<AppLayoutKeyHeight>; export type AppHeightsResponsiveWeb = AppLayoutWeb<AppLayoutKeyHeight>; +export type AppHeightsResponsiveWebPwa = AppLayoutWebPwa<AppLayoutKeyHeight>; export type AppWidthsResponsiveIOS = AppLayoutIOS<AppLayoutKeyWidth>; export type AppWidthsResponsiveWeb = AppLayoutWeb<AppLayoutKeyWidth>; +export type AppWidthsResponsiveWebPwa = AppLayoutWebPwa<AppLayoutKeyHeight>; export type CallbackPromiseFigureResult<Ti, Tr> = (value: Ti) => Promise<Tr | undefined>; export type CallbackPromiseFull<Ti, Tr> = (value: Ti) => Promise<Tr>; diff --git a/utils/src/app/types/resolve.ts b/utils/src/app/types/resolve.ts @@ -8,7 +8,7 @@ export type ResolveEnumPayment_Period = 'biweekly' | 'hourly' | 'monthly' | 'wee export type ResolveEnumPayment_Status = 'confirmed' | 'pending'; export type ResolveEnumQuantity_Unit = 'g' | 'kg' | 'lb' | 'ton'; export type ResolveEnumWorker_Type = 'contractor' | 'laborer'; -export type ResolveAccountInfo = { id: string, created_at: string, updated_at: string, role: ResolveEnumAccount_Role, auth_ref: { credential: ResolveEnumAuth_Credential, email: { id: string, created_at: string, updated_at: string, address: string } }, profiles?: Array<{ id: string, created_at: string, updated_at: string, name: string, display_name?: string | null, primary: boolean, about?: string | null, emails: Array<{ id: string, created_at: string, updated_at: string, address: string }>, profile_photos?: Array<{ id: string, created_at: string, updated_at: string, primary: boolean, title?: string | null, description?: string | null, media_image: { id: string, created_at: string, updated_at: string, url: string } }> | null, nostr_keys: Array<{ id: string, created_at: string, updated_at: string, public_key: string }> }> | null, farms?: Array<{ id: string, created_at: string, updated_at: string, name: string, area?: number | null, area_unit: ResolveEnumArea_Unit, geolocation: { id: string, created_at: string, updated_at: string, point: { type: string, coordinates: Array<number> }, polygon?: { type: string, coordinates: Array<Array<Array<number>>> } | null, address: { id: string, created_at: string, updated_at: string, primary: string, admin: string, country: string } }, farm_products?: Array<{ id: string, created_at: string, updated_at: string, name: string, farm_lot_products?: Array<{ id: string }> | null }> | null, farm_lots?: Array<{ id: string, created_at: string, updated_at: string, name?: string | null, area?: number | null, area_unit: ResolveEnumArea_Unit, geolocation: { id: string, created_at: string, updated_at: string, point: { type: string, coordinates: Array<number> }, polygon?: { type: string, coordinates: Array<Array<Array<number>>> } | null, address: { id: string, created_at: string, updated_at: string, primary: string, admin: string, country: string } }, farm_lot_products?: Array<{ id: string, created_at: string, updated_at: string, area_planted?: number | null, area_planted_unit: ResolveEnumArea_Unit, date_planted?: string | null, days_to_maturity?: number | null, farm_product: { id: string, created_at: string, updated_at: string, name: string, farm_lot_products?: Array<{ id: string }> | null }, farm_trade_products?: Array<{ id: string, created_at: string, updated_at: string, title: string, description: string, process?: string | null, trade_product_prices?: Array<{ id: string, created_at: string, updated_at: string, amount: number, currency: string, quantity_amount?: number | null, quantity_unit: ResolveEnumQuantity_Unit, quantity_label?: string | null }> | null, trade_product_quantitys?: Array<{ id: string, created_at: string, updated_at: string, amount?: number | null, unit: ResolveEnumQuantity_Unit, label?: string | null }> | null }> | null, farm_lot_harvests?: Array<{ id: string, created_at: string, updated_at: string, quantity_harvested: number, quantity_harvested_unit: ResolveEnumQuantity_Unit }> | null }> | null }> | null }> | null }; +export type ResolveAccountInfo = { id: string, created_at: string, updated_at: string, role: ResolveEnumAccount_Role, username: string, auth_ref: { credential: ResolveEnumAuth_Credential, email: { id: string, created_at: string, updated_at: string, address: string } }, profiles?: Array<{ id: string, created_at: string, updated_at: string, name: string, display_name?: string | null, primary: boolean, about?: string | null, emails: Array<{ id: string, created_at: string, updated_at: string, address: string }>, profile_photos?: Array<{ id: string, created_at: string, updated_at: string, primary: boolean, title?: string | null, description?: string | null, media_image: { id: string, created_at: string, updated_at: string, url: string } }> | null, nostr_keys: Array<{ id: string, created_at: string, updated_at: string, public_key: string }> }> | null, farms?: Array<{ id: string, created_at: string, updated_at: string, name: string, area?: number | null, area_unit: ResolveEnumArea_Unit, geolocation: { id: string, created_at: string, updated_at: string, point: { type: string, coordinates: Array<number> }, polygon?: { type: string, coordinates: Array<Array<Array<number>>> } | null, address: { id: string, created_at: string, updated_at: string, primary: string, admin: string, country: string } }, farm_products?: Array<{ id: string, created_at: string, updated_at: string, name: string, farm_lot_products?: Array<{ id: string }> | null }> | null, farm_lots?: Array<{ id: string, created_at: string, updated_at: string, name?: string | null, area?: number | null, area_unit: ResolveEnumArea_Unit, geolocation: { id: string, created_at: string, updated_at: string, point: { type: string, coordinates: Array<number> }, polygon?: { type: string, coordinates: Array<Array<Array<number>>> } | null, address: { id: string, created_at: string, updated_at: string, primary: string, admin: string, country: string } }, farm_lot_products?: Array<{ id: string, created_at: string, updated_at: string, area_planted?: number | null, area_planted_unit: ResolveEnumArea_Unit, date_planted?: string | null, days_to_maturity?: number | null, farm_product: { id: string, created_at: string, updated_at: string, name: string, farm_lot_products?: Array<{ id: string }> | null }, farm_trade_products?: Array<{ id: string, created_at: string, updated_at: string, title: string, description: string, process?: string | null, trade_product_prices?: Array<{ id: string, created_at: string, updated_at: string, amount: number, currency: string, quantity_amount?: number | null, quantity_unit: ResolveEnumQuantity_Unit, quantity_label?: string | null }> | null, trade_product_quantitys?: Array<{ id: string, created_at: string, updated_at: string, amount?: number | null, unit: ResolveEnumQuantity_Unit, label?: string | null }> | null }> | null, farm_lot_harvests?: Array<{ id: string, created_at: string, updated_at: string, quantity_harvested: number, quantity_harvested_unit: ResolveEnumQuantity_Unit }> | null }> | null }> | null }> | null }; export type ResolveAuthRefInfo = { credential: ResolveEnumAuth_Credential, email: { id: string, created_at: string, updated_at: string, address: string } }; export type ResolveEmailInfo = { id: string, created_at: string, updated_at: string, address: string }; export type ResolveProfileInfo = { id: string, created_at: string, updated_at: string, name: string, display_name?: string | null, primary: boolean, about?: string | null, emails: Array<{ id: string, created_at: string, updated_at: string, address: string }>, profile_photos?: Array<{ id: string, created_at: string, updated_at: string, primary: boolean, title?: string | null, description?: string | null, media_image: { id: string, created_at: string, updated_at: string, url: string } }> | null, nostr_keys: Array<{ id: string, created_at: string, updated_at: string, public_key: string }> }; diff --git a/utils/src/app/util.ts b/utils/src/app/util.ts @@ -1,4 +1,4 @@ -import type { AppLayoutKey, AppLayoutKeyIOS, AppLayoutKeyWeb, LabelFieldKind, NavigationParamTuple, ThemeLayer } from "$root"; +import type { AppLayoutKey, AppLayoutKeyIOS, AppLayoutKeyWeb, AppLayoutKeyWebPwa, LabelFieldKind, NavigationParamTuple, ThemeLayer } from "$root"; export const fmt_cl = (classes?: string): string => { return classes ? classes : ``; @@ -10,6 +10,8 @@ export const get_layout = (val: string | false): AppLayoutKey => { case `ios1`: case `webm0`: case `webm1`: + case `web_mobile`: + case `web_desktop`: return val; default: return `ios0`; @@ -28,6 +30,17 @@ export const get_ios_layout = (val: string | false): AppLayoutKeyIOS => { export const get_web_layout = (val: string | false): AppLayoutKeyWeb => { switch (val) { + case `web_mobile`: + case `web_desktop`: + return val; + default: + return `web_desktop`; + }; +}; + + +export const get_web_pwa_layout = (val: string | false): AppLayoutKeyWebPwa => { + switch (val) { case `webm0`: case `webm1`: return val;