@g9tm/lynxcontrols 1.4.7 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/anchor/context.d.ts +15 -0
- package/dist/anchor/context.d.ts.map +1 -0
- package/dist/anchor/context.jsx +10 -0
- package/dist/anchor/context.jsx.map +1 -0
- package/dist/anchor/hooks.d.ts +72 -0
- package/dist/anchor/hooks.d.ts.map +1 -0
- package/dist/anchor/hooks.jsx +147 -0
- package/dist/anchor/hooks.jsx.map +1 -0
- package/dist/anchor/index.d.ts +6 -0
- package/dist/anchor/index.d.ts.map +1 -0
- package/dist/anchor/index.jsx +5 -0
- package/dist/anchor/measure.d.ts +22 -0
- package/dist/anchor/measure.d.ts.map +1 -0
- package/dist/anchor/measure.jsx +110 -0
- package/dist/anchor/measure.jsx.map +1 -0
- package/dist/anchor/registry.d.ts +108 -0
- package/dist/anchor/registry.d.ts.map +1 -0
- package/dist/anchor/registry.jsx +142 -0
- package/dist/anchor/registry.jsx.map +1 -0
- package/dist/anchor/scroll.d.ts +34 -0
- package/dist/anchor/scroll.d.ts.map +1 -0
- package/dist/anchor/scroll.jsx +255 -0
- package/dist/anchor/scroll.jsx.map +1 -0
- package/dist/base/control.d.ts +10 -3
- package/dist/base/control.d.ts.map +1 -1
- package/dist/base/control.jsx +17 -2
- package/dist/base/control.jsx.map +1 -1
- package/dist/base/index.d.ts +1 -1
- package/dist/base/index.d.ts.map +1 -1
- package/dist/base/index.jsx +1 -1
- package/dist/base/pressable.d.ts.map +1 -1
- package/dist/base/pressable.jsx +7 -1
- package/dist/base/pressable.jsx.map +1 -1
- package/dist/base/selection-item.d.ts +9 -1
- package/dist/base/selection-item.d.ts.map +1 -1
- package/dist/base/selection-item.jsx +10 -1
- package/dist/base/selection-item.jsx.map +1 -1
- package/dist/button/button.css +20 -0
- package/dist/button/button.css.map +1 -1
- package/dist/button/button.d.ts.map +1 -1
- package/dist/button/button.jsx +11 -1
- package/dist/button/button.jsx.map +1 -1
- package/dist/button/header-action-button.d.ts +5 -0
- package/dist/button/header-action-button.d.ts.map +1 -1
- package/dist/button/header-action-button.jsx +16 -2
- package/dist/button/header-action-button.jsx.map +1 -1
- package/dist/button/icon-button.d.ts.map +1 -1
- package/dist/button/icon-button.jsx +11 -1
- package/dist/button/icon-button.jsx.map +1 -1
- package/dist/button/nav-card.d.ts.map +1 -1
- package/dist/button/nav-card.jsx +10 -1
- package/dist/button/nav-card.jsx.map +1 -1
- package/dist/button/vertical-icon-text-button.d.ts.map +1 -1
- package/dist/button/vertical-icon-text-button.jsx +10 -1
- package/dist/button/vertical-icon-text-button.jsx.map +1 -1
- package/dist/button/visuals.d.ts.map +1 -1
- package/dist/button/visuals.jsx +1 -1
- package/dist/button/visuals.jsx.map +1 -1
- package/dist/expander/expander.d.ts.map +1 -1
- package/dist/expander/expander.jsx +14 -1
- package/dist/expander/expander.jsx.map +1 -1
- package/dist/fields/editor.d.ts.map +1 -1
- package/dist/fields/editor.jsx +18 -2
- package/dist/fields/editor.jsx.map +1 -1
- package/dist/fields/fields.css +21 -0
- package/dist/fields/fields.css.map +1 -1
- package/dist/fields/index.d.ts +1 -1
- package/dist/fields/index.d.ts.map +1 -1
- package/dist/fields/index.jsx +1 -1
- package/dist/fields/outlined-field.d.ts +33 -1
- package/dist/fields/outlined-field.d.ts.map +1 -1
- package/dist/fields/outlined-field.jsx +43 -5
- package/dist/fields/outlined-field.jsx.map +1 -1
- package/dist/fields/text-entry.d.ts.map +1 -1
- package/dist/fields/text-entry.jsx +18 -2
- package/dist/fields/text-entry.jsx.map +1 -1
- package/dist/guide/guide.css +453 -0
- package/dist/guide/guide.css.map +1 -0
- package/dist/guide/index.d.ts +5 -0
- package/dist/guide/index.d.ts.map +1 -0
- package/dist/guide/index.jsx +4 -0
- package/dist/guide/journey.d.ts +46 -0
- package/dist/guide/journey.d.ts.map +1 -0
- package/dist/guide/journey.jsx +464 -0
- package/dist/guide/journey.jsx.map +1 -0
- package/dist/guide/placement.d.ts +44 -0
- package/dist/guide/placement.d.ts.map +1 -0
- package/dist/guide/placement.jsx +119 -0
- package/dist/guide/placement.jsx.map +1 -0
- package/dist/guide/service.d.ts +85 -0
- package/dist/guide/service.d.ts.map +1 -0
- package/dist/guide/service.jsx +620 -0
- package/dist/guide/service.jsx.map +1 -0
- package/dist/guide/settings.d.ts +50 -0
- package/dist/guide/settings.d.ts.map +1 -0
- package/dist/guide/settings.jsx +60 -0
- package/dist/guide/settings.jsx.map +1 -0
- package/dist/host/host.d.ts +5 -1
- package/dist/host/host.d.ts.map +1 -1
- package/dist/host/host.jsx +12 -0
- package/dist/host/host.jsx.map +1 -1
- package/dist/host/layers.d.ts +3 -1
- package/dist/host/layers.d.ts.map +1 -1
- package/dist/host/layers.jsx +4 -2
- package/dist/host/layers.jsx.map +1 -1
- package/dist/host/registry.d.ts +3 -0
- package/dist/host/registry.d.ts.map +1 -1
- package/dist/host/registry.jsx.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/pickers/combo-box.d.ts +8 -0
- package/dist/pickers/combo-box.d.ts.map +1 -1
- package/dist/pickers/combo-box.jsx +51 -9
- package/dist/pickers/combo-box.jsx.map +1 -1
- package/dist/pickers/date-time-picker.d.ts +2 -2
- package/dist/pickers/date-time-picker.d.ts.map +1 -1
- package/dist/pickers/date-time-picker.jsx +4 -3
- package/dist/pickers/date-time-picker.jsx.map +1 -1
- package/dist/pickers/date-time.d.ts +5 -2
- package/dist/pickers/date-time.d.ts.map +1 -1
- package/dist/pickers/date-time.jsx +1 -1
- package/dist/pickers/date-time.jsx.map +1 -1
- package/dist/pickers/picker-sheet.d.ts +6 -2
- package/dist/pickers/picker-sheet.d.ts.map +1 -1
- package/dist/pickers/picker-sheet.jsx +2 -3
- package/dist/pickers/picker-sheet.jsx.map +1 -1
- package/dist/pickers/picker.d.ts.map +1 -1
- package/dist/pickers/picker.jsx +3 -2
- package/dist/pickers/picker.jsx.map +1 -1
- package/dist/pickers/pickers.css +27 -0
- package/dist/pickers/pickers.css.map +1 -1
- package/dist/pickers/timespan-picker.d.ts.map +1 -1
- package/dist/pickers/timespan-picker.jsx +3 -2
- package/dist/pickers/timespan-picker.jsx.map +1 -1
- package/dist/pickers/trigger.d.ts +3 -1
- package/dist/pickers/trigger.d.ts.map +1 -1
- package/dist/pickers/trigger.jsx +6 -1
- package/dist/pickers/trigger.jsx.map +1 -1
- package/dist/provider/contexts.d.ts +3 -0
- package/dist/provider/contexts.d.ts.map +1 -1
- package/dist/provider/contexts.jsx.map +1 -1
- package/dist/provider/provider.d.ts.map +1 -1
- package/dist/provider/provider.jsx +24 -17
- package/dist/provider/provider.jsx.map +1 -1
- package/dist/provider/settings.d.ts +16 -0
- package/dist/provider/settings.d.ts.map +1 -1
- package/dist/provider/settings.jsx +7 -3
- package/dist/provider/settings.jsx.map +1 -1
- package/dist/provider/theme.css +4 -0
- package/dist/provider/theme.css.map +1 -1
- package/dist/range-slider/math.d.ts +14 -4
- package/dist/range-slider/math.d.ts.map +1 -1
- package/dist/range-slider/math.jsx +16 -4
- package/dist/range-slider/math.jsx.map +1 -1
- package/dist/range-slider/range-slider.css +17 -0
- package/dist/range-slider/range-slider.css.map +1 -1
- package/dist/range-slider/range-slider.d.ts +11 -0
- package/dist/range-slider/range-slider.d.ts.map +1 -1
- package/dist/range-slider/range-slider.jsx +35 -13
- package/dist/range-slider/range-slider.jsx.map +1 -1
- package/dist/route/hooks.d.ts +34 -0
- package/dist/route/hooks.d.ts.map +1 -0
- package/dist/route/hooks.jsx +147 -0
- package/dist/route/hooks.jsx.map +1 -0
- package/dist/route/index.d.ts +3 -0
- package/dist/route/index.d.ts.map +1 -0
- package/dist/route/index.jsx +2 -0
- package/dist/route/router.d.ts +201 -0
- package/dist/route/router.d.ts.map +1 -0
- package/dist/route/router.jsx +810 -0
- package/dist/route/router.jsx.map +1 -0
- package/dist/selection/index.d.ts +2 -1
- package/dist/selection/index.d.ts.map +1 -1
- package/dist/selection/index.jsx +2 -1
- package/dist/selection/selection-sheet.d.ts +3 -1
- package/dist/selection/selection-sheet.d.ts.map +1 -1
- package/dist/selection/selection-sheet.jsx +57 -8
- package/dist/selection/selection-sheet.jsx.map +1 -1
- package/dist/selection/selection.css +7 -0
- package/dist/selection/selection.css.map +1 -1
- package/dist/selection/window.d.ts +29 -0
- package/dist/selection/window.d.ts.map +1 -0
- package/dist/selection/window.jsx +24 -0
- package/dist/selection/window.jsx.map +1 -0
- package/dist/sheet/frame.d.ts +3 -1
- package/dist/sheet/frame.d.ts.map +1 -1
- package/dist/sheet/frame.jsx +72 -26
- package/dist/sheet/frame.jsx.map +1 -1
- package/dist/sheet/header.d.ts.map +1 -1
- package/dist/sheet/header.jsx +3 -1
- package/dist/sheet/header.jsx.map +1 -1
- package/dist/sheet/index.d.ts +1 -1
- package/dist/sheet/index.d.ts.map +1 -1
- package/dist/sheet/index.jsx +1 -1
- package/dist/sheet/options.d.ts +30 -0
- package/dist/sheet/options.d.ts.map +1 -1
- package/dist/sheet/options.jsx +2 -1
- package/dist/sheet/options.jsx.map +1 -1
- package/dist/sheet/service.d.ts +13 -0
- package/dist/sheet/service.d.ts.map +1 -1
- package/dist/sheet/service.jsx +27 -4
- package/dist/sheet/service.jsx.map +1 -1
- package/dist/sheet/sheet.css +9 -0
- package/dist/sheet/sheet.css.map +1 -1
- package/dist/sheet/sizing.d.ts +2 -0
- package/dist/sheet/sizing.d.ts.map +1 -1
- package/dist/sheet/sizing.jsx +2 -1
- package/dist/sheet/sizing.jsx.map +1 -1
- package/dist/tabs/tab-view.d.ts +14 -0
- package/dist/tabs/tab-view.d.ts.map +1 -1
- package/dist/tabs/tab-view.jsx +59 -3
- package/dist/tabs/tab-view.jsx.map +1 -1
- package/dist/toggle/checkbox.d.ts.map +1 -1
- package/dist/toggle/checkbox.jsx +15 -1
- package/dist/toggle/checkbox.jsx.map +1 -1
- package/dist/toggle/chip-group.d.ts +9 -1
- package/dist/toggle/chip-group.d.ts.map +1 -1
- package/dist/toggle/chip-group.jsx +63 -13
- package/dist/toggle/chip-group.jsx.map +1 -1
- package/dist/toggle/switch.d.ts +1 -1
- package/dist/toggle/switch.d.ts.map +1 -1
- package/dist/toggle/switch.jsx +18 -3
- package/dist/toggle/switch.jsx.map +1 -1
- package/dist/toggle/toggle.css +20 -0
- package/dist/toggle/toggle.css.map +1 -1
- package/package.json +17 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host/registry.jsx","sources":["../../src/host/registry.ts"],"sourcesContent":["import type { G9Capabilities } from '@g9tm/lynxcontrols-foundation';\nimport { G9Error } from '@g9tm/lynxcontrols-foundation';\nimport type { G9BackStack } from './back';\nimport type { G9LayerItem, G9LayerStore, G9OverlayLayer } from './layers';\nimport type { G9HostReadiness } from './readiness';\n\n/** Safe-area insets of a host, with the bottom inset that also reserves the page's own tab bar. */\nexport interface G9HostInsets {\n readonly top: number;\n readonly end: number;\n readonly bottom: number;\n readonly start: number;\n /** MAUI `BottomSafeAreaWithTabBar`: `bottom` unless the host's `computeBottomSafeAreaWithTabBar` adds a bar. */\n readonly bottomWithTabBar: number;\n}\n\n/**\n * Feature controllers later packages attach to a host (sheets, popups, toasts). Augment this interface to type them:\n * `declare module '@g9tm/lynxcontrols/host' { interface G9HostFeatures { sheets: G9SheetsController } }`.\n */\n// biome-ignore lint/suspicious/noEmptyInterface: augmentation point for later work packages\nexport interface G9HostFeatures {}\n\n/** A feature key: a declared {@link G9HostFeatures} key, or any string for untyped use. */\nexport type G9HostFeatureKey = keyof G9HostFeatures | (string & {});\ntype FeatureValue<K> = K extends keyof G9HostFeatures ? G9HostFeatures[K] : unknown;\n\n/**\n * One mounted `G9Host`, as code outside the component tree sees it (MAUI `IG9OverlayHost` plus the page's back and\n * readiness): the layers to mount into, the back stack, the insets, the services of its provider.\n */\nexport interface G9HostHandle {\n /** Unique per mounted host. */\n readonly id: string;\n /** The nearest enclosing host, or `null`. */\n readonly parent: G9HostHandle | null;\n /** The services of the provider this host lives in. */\n readonly services: G9Capabilities;\n /** The overlay layers (MAUI `OverlayLayer` = `sheets`, `ToastLayer` = `feedback`, `DevLayer` = `floating`). */\n readonly layers: G9LayerStore;\n /** Shorthand for `layers.register`. */\n registerLayerItem(layer: G9OverlayLayer, item: G9LayerItem): () => void;\n /** Shorthand for `layers.remove`. */\n removeLayerItem(layer: G9OverlayLayer, key: string): boolean;\n /** The host's back handlers. */\n readonly back: G9BackStack;\n /** Current insets (MAUI `Page.TopSafeAreaInset` and friends). */\n getInsets(): G9HostInsets;\n /** The page-loading cover and ready signal. */\n readonly readiness: G9HostReadiness;\n /** Attaches a feature controller; returns its detach function. Attaching a key twice throws. */\n attachFeature<K extends G9HostFeatureKey>(key: K, value: FeatureValue<K>): () => void;\n /** The attached feature, or `undefined`. */\n getFeature<K extends G9HostFeatureKey>(key: K): FeatureValue<K> | undefined;\n /** `true` once the host unmounted; a released handle refuses new layer items. */\n readonly released: boolean;\n /**\n * Transforms the page content (the sheets' backdrop-card recede, MAUI `BackdropHost`): `scale` and `translateY`\n * with a transition of `durationMs`; `null` restores it. The backdrop colour shows around the scaled page.\n */\n setContentEffect(effect: G9HostContentEffect | null): void;\n /** The current content effect (`null` = identity). */\n getContentEffect(): G9HostContentEffect | null;\n}\n\n/** A transform of the page content (see {@link G9HostHandle.setContentEffect}). */\nexport interface G9HostContentEffect {\n readonly scale: number;\n readonly translateY: number;\n readonly durationMs: number;\n /** Colour shown around the receded page. */\n readonly backdropColor?: string;\n}\n\n/** Listener of {@link G9HostRegistry.subscribe}. */\nexport type G9HostListener = (host: G9HostHandle | null) => void;\n\n/**\n * Finds the host for code that is not a component (MAUI `G9OverlayHosts`): view models, services, startup hooks.\n *\n * **Which host is active.** The registry is a most-recent-first stack of mounted hosts. A host is *on screen* while its\n * `active` prop is `true` (the default). The active host is the most recently activated host that is on screen —\n * except that a host never outranks a mounted, on-screen host nested inside it (the nested one is drawn on top of its\n * parent's content). When no host is on screen, the most recently registered one is active (app start, tab switch).\n * Unmounting a host removes it synchronously; the host beneath becomes active again. There is no \"last page\" leak.\n */\nexport interface G9HostRegistry {\n /** The active host, or `null` (MAUI `TryGetCurrent`): before the first host mounts and after the last unmounts. */\n active(): G9HostHandle | null;\n /** The active host, or throws `G9Error('host-missing')` (MAUI `GetCurrent`). For user-gesture code only. */\n require(): G9HostHandle;\n /**\n * Called when the active host changes (MAUI `CurrentChanged`), with the new host or `null`. Not called when a host\n * merely re-asserts what is already active. Returns an unsubscribe function.\n */\n subscribe(listener: G9HostListener): () => void;\n /** Number of mounted hosts. */\n readonly size: number;\n}\n\ninterface Slot {\n readonly host: G9HostHandle;\n onScreen: boolean;\n}\n\nconst slots: Slot[] = [];\nconst listeners = new Set<G9HostListener>();\n\nfunction isDescendant(host: G9HostHandle, ancestor: G9HostHandle): boolean {\n for (let p = host.parent; p; p = p.parent) if (p === ancestor) return true;\n return false;\n}\n\nfunction resolve(): G9HostHandle | null {\n const onScreen = slots.filter((slot) => slot.onScreen);\n let current = onScreen[0]?.host ?? slots[0]?.host ?? null;\n if (!current || onScreen.length === 0) return current;\n for (;;) {\n const parent: G9HostHandle = current;\n const nested = onScreen.find((slot) => isDescendant(slot.host, parent));\n if (!nested) return current;\n current = nested.host;\n }\n}\n\nfunction mutate(change: () => void): void {\n const before = resolve();\n change();\n const after = resolve();\n if (before === after) return;\n let failure: { error: unknown } | null = null;\n for (const listener of Array.from(listeners)) {\n if (!listeners.has(listener)) continue;\n try {\n listener(after);\n } catch (error) {\n failure ??= { error };\n }\n }\n if (failure) throw failure.error;\n}\n\nconst indexOf = (host: G9HostHandle) => slots.findIndex((slot) => slot.host === host);\n\n/** The process-wide host registry (the only mutable module-level state in the library, plan/specs/03 §6). */\nexport const g9Hosts: G9HostRegistry = {\n active: resolve,\n require() {\n const host = resolve();\n if (!host) {\n throw new G9Error(\n 'host-missing',\n 'No G9Host is mounted. Wrap the page in <G9Host> inside <G9Provider>; during startup or teardown use ' +\n 'g9Hosts.active() and handle null.',\n );\n }\n return host;\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n get size() {\n return slots.length;\n },\n};\n\n/**\n * Registry mutators used by `G9Host` (not exported from the package). `activate` puts a host on top and on screen;\n * `register` adds it below every on-screen host without displacing one; `markOffScreen` keeps the entry; `remove`\n * forgets it.\n */\nexport const hostRegistry = {\n activate(host: G9HostHandle): void {\n mutate(() => {\n const index = indexOf(host);\n if (index >= 0) slots.splice(index, 1);\n slots.unshift({ host, onScreen: true });\n });\n },\n register(host: G9HostHandle): void {\n mutate(() => {\n if (indexOf(host) >= 0) return;\n let index = 0;\n slots.forEach((slot, i) => {\n if (slot.onScreen) index = i + 1;\n });\n slots.splice(index, 0, { host, onScreen: false });\n });\n },\n markOffScreen(host: G9HostHandle): void {\n mutate(() => {\n const slot = slots[indexOf(host)];\n if (slot) slot.onScreen = false;\n });\n },\n remove(host: G9HostHandle): void {\n mutate(() => {\n const index = indexOf(host);\n if (index >= 0) slots.splice(index, 1);\n });\n },\n};\n"],"names":["slots","listeners","Set","isDescendant","host","ancestor","p","resolve","_ref","_slots_","onScreen","slot","current","parent","nested","mutate","change","before","after","failure","listener","Array","error","indexOf","g9Hosts","G9Error","hostRegistry","index","i"],"mappings":";AAyGA,MAAMA,QAAgB,EAAE;AACxB,MAAMC,YAAY,IAAIC;AAEtB,SAASC,aAAaC,IAAkB,EAAEC,QAAsB;IAC9D,IAAK,IAAIC,IAAIF,KAAK,MAAM,EAAEE,GAAGA,IAAIA,EAAE,MAAM,CAAE,IAAIA,MAAMD,UAAU,OAAO;IACtE,OAAO;AACT;AAEA,SAASE;QAEOC,MAAAA;QAAAA,YAAqBC;IADnC,MAAMC,WAAWV,MAAM,MAAM,CAAC,CAACW,OAASA,KAAK,QAAQ;IACrD,IAAIC,UAAU,QAAAJ,CAAAA,OAAAA,QAAAA,CAAAA,QAAAA,QAAAA,CAAAA,aAAAA,QAAQ,CAAC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,CAAC2B,OAAO;YACpC3B,MAAM,OAAO,CAAC;gBAAEI;gBAAM,UAAU;YAAK;QACvC;IACF;IACA,UAASA,IAAkB;QACzBW,OAAO;YACL,IAAIQ,QAAQnB,SAAS,GAAG;YACxB,IAAIuB,QAAQ;YACZ3B,MAAM,OAAO,CAAC,CAACW,MAAMiB;gBACnB,IAAIjB,KAAK,QAAQ,EAAEgB,QAAQC,IAAI;YACjC;YACA5B,MAAM,MAAM,CAAC2B,OAAO,GAAG;gBAAEvB;gBAAM,UAAU;YAAM;QACjD;IACF;IACA,eAAcA,IAAkB;QAC9BW,OAAO;YACL,MAAMJ,OAAOX,KAAK,CAACuB,QAAQnB,MAAM;YACjC,IAAIO,MAAMA,KAAK,QAAQ,GAAG;QAC5B;IACF;IACA,QAAOP,IAAkB;QACvBW,OAAO;YACL,MAAMY,QAAQJ,QAAQnB;YACtB,IAAIuB,SAAS,GAAG3B,MAAM,MAAM,CAAC2B,OAAO;QACtC;IACF;AACF"}
|
|
1
|
+
{"version":3,"file":"host/registry.jsx","sources":["../../src/host/registry.ts"],"sourcesContent":["import type { G9Capabilities } from '@g9tm/lynxcontrols-foundation';\nimport { G9Error } from '@g9tm/lynxcontrols-foundation';\nimport type { G9AnchorRegistry } from '../anchor/registry';\nimport type { G9BackStack } from './back';\nimport type { G9LayerItem, G9LayerStore, G9OverlayLayer } from './layers';\nimport type { G9HostReadiness } from './readiness';\n\n/** Safe-area insets of a host, with the bottom inset that also reserves the page's own tab bar. */\nexport interface G9HostInsets {\n readonly top: number;\n readonly end: number;\n readonly bottom: number;\n readonly start: number;\n /** MAUI `BottomSafeAreaWithTabBar`: `bottom` unless the host's `computeBottomSafeAreaWithTabBar` adds a bar. */\n readonly bottomWithTabBar: number;\n}\n\n/**\n * Feature controllers later packages attach to a host (sheets, popups, toasts). Augment this interface to type them:\n * `declare module '@g9tm/lynxcontrols/host' { interface G9HostFeatures { sheets: G9SheetsController } }`.\n */\n// biome-ignore lint/suspicious/noEmptyInterface: augmentation point for later work packages\nexport interface G9HostFeatures {}\n\n/** A feature key: a declared {@link G9HostFeatures} key, or any string for untyped use. */\nexport type G9HostFeatureKey = keyof G9HostFeatures | (string & {});\ntype FeatureValue<K> = K extends keyof G9HostFeatures ? G9HostFeatures[K] : unknown;\n\n/**\n * One mounted `G9Host`, as code outside the component tree sees it (MAUI `IG9OverlayHost` plus the page's back and\n * readiness): the layers to mount into, the back stack, the insets, the services of its provider.\n */\nexport interface G9HostHandle {\n /** Unique per mounted host. */\n readonly id: string;\n /** The nearest enclosing host, or `null`. */\n readonly parent: G9HostHandle | null;\n /** The services of the provider this host lives in. */\n readonly services: G9Capabilities;\n /** The provider's anchors (every control a guide or an automation can reach). */\n readonly anchors: G9AnchorRegistry;\n /** The overlay layers (MAUI `OverlayLayer` = `sheets`, `ToastLayer` = `feedback`, `DevLayer` = `floating`). */\n readonly layers: G9LayerStore;\n /** Shorthand for `layers.register`. */\n registerLayerItem(layer: G9OverlayLayer, item: G9LayerItem): () => void;\n /** Shorthand for `layers.remove`. */\n removeLayerItem(layer: G9OverlayLayer, key: string): boolean;\n /** The host's back handlers. */\n readonly back: G9BackStack;\n /** Current insets (MAUI `Page.TopSafeAreaInset` and friends). */\n getInsets(): G9HostInsets;\n /** The page-loading cover and ready signal. */\n readonly readiness: G9HostReadiness;\n /** Attaches a feature controller; returns its detach function. Attaching a key twice throws. */\n attachFeature<K extends G9HostFeatureKey>(key: K, value: FeatureValue<K>): () => void;\n /** The attached feature, or `undefined`. */\n getFeature<K extends G9HostFeatureKey>(key: K): FeatureValue<K> | undefined;\n /** `true` once the host unmounted; a released handle refuses new layer items. */\n readonly released: boolean;\n /**\n * Transforms the page content (the sheets' backdrop-card recede, MAUI `BackdropHost`): `scale` and `translateY`\n * with a transition of `durationMs`; `null` restores it. The backdrop colour shows around the scaled page.\n */\n setContentEffect(effect: G9HostContentEffect | null): void;\n /** The current content effect (`null` = identity). */\n getContentEffect(): G9HostContentEffect | null;\n}\n\n/** A transform of the page content (see {@link G9HostHandle.setContentEffect}). */\nexport interface G9HostContentEffect {\n readonly scale: number;\n readonly translateY: number;\n readonly durationMs: number;\n /** Colour shown around the receded page. */\n readonly backdropColor?: string;\n}\n\n/** Listener of {@link G9HostRegistry.subscribe}. */\nexport type G9HostListener = (host: G9HostHandle | null) => void;\n\n/**\n * Finds the host for code that is not a component (MAUI `G9OverlayHosts`): view models, services, startup hooks.\n *\n * **Which host is active.** The registry is a most-recent-first stack of mounted hosts. A host is *on screen* while its\n * `active` prop is `true` (the default). The active host is the most recently activated host that is on screen —\n * except that a host never outranks a mounted, on-screen host nested inside it (the nested one is drawn on top of its\n * parent's content). When no host is on screen, the most recently registered one is active (app start, tab switch).\n * Unmounting a host removes it synchronously; the host beneath becomes active again. There is no \"last page\" leak.\n */\nexport interface G9HostRegistry {\n /** The active host, or `null` (MAUI `TryGetCurrent`): before the first host mounts and after the last unmounts. */\n active(): G9HostHandle | null;\n /** The active host, or throws `G9Error('host-missing')` (MAUI `GetCurrent`). For user-gesture code only. */\n require(): G9HostHandle;\n /**\n * Called when the active host changes (MAUI `CurrentChanged`), with the new host or `null`. Not called when a host\n * merely re-asserts what is already active. Returns an unsubscribe function.\n */\n subscribe(listener: G9HostListener): () => void;\n /** Number of mounted hosts. */\n readonly size: number;\n}\n\ninterface Slot {\n readonly host: G9HostHandle;\n onScreen: boolean;\n}\n\nconst slots: Slot[] = [];\nconst listeners = new Set<G9HostListener>();\n\nfunction isDescendant(host: G9HostHandle, ancestor: G9HostHandle): boolean {\n for (let p = host.parent; p; p = p.parent) if (p === ancestor) return true;\n return false;\n}\n\nfunction resolve(): G9HostHandle | null {\n const onScreen = slots.filter((slot) => slot.onScreen);\n let current = onScreen[0]?.host ?? slots[0]?.host ?? null;\n if (!current || onScreen.length === 0) return current;\n for (;;) {\n const parent: G9HostHandle = current;\n const nested = onScreen.find((slot) => isDescendant(slot.host, parent));\n if (!nested) return current;\n current = nested.host;\n }\n}\n\nfunction mutate(change: () => void): void {\n const before = resolve();\n change();\n const after = resolve();\n if (before === after) return;\n let failure: { error: unknown } | null = null;\n for (const listener of Array.from(listeners)) {\n if (!listeners.has(listener)) continue;\n try {\n listener(after);\n } catch (error) {\n failure ??= { error };\n }\n }\n if (failure) throw failure.error;\n}\n\nconst indexOf = (host: G9HostHandle) => slots.findIndex((slot) => slot.host === host);\n\n/** The process-wide host registry (the only mutable module-level state in the library, plan/specs/03 §6). */\nexport const g9Hosts: G9HostRegistry = {\n active: resolve,\n require() {\n const host = resolve();\n if (!host) {\n throw new G9Error(\n 'host-missing',\n 'No G9Host is mounted. Wrap the page in <G9Host> inside <G9Provider>; during startup or teardown use ' +\n 'g9Hosts.active() and handle null.',\n );\n }\n return host;\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n get size() {\n return slots.length;\n },\n};\n\n/**\n * Registry mutators used by `G9Host` (not exported from the package). `activate` puts a host on top and on screen;\n * `register` adds it below every on-screen host without displacing one; `markOffScreen` keeps the entry; `remove`\n * forgets it.\n */\nexport const hostRegistry = {\n activate(host: G9HostHandle): void {\n mutate(() => {\n const index = indexOf(host);\n if (index >= 0) slots.splice(index, 1);\n slots.unshift({ host, onScreen: true });\n });\n },\n register(host: G9HostHandle): void {\n mutate(() => {\n if (indexOf(host) >= 0) return;\n let index = 0;\n slots.forEach((slot, i) => {\n if (slot.onScreen) index = i + 1;\n });\n slots.splice(index, 0, { host, onScreen: false });\n });\n },\n markOffScreen(host: G9HostHandle): void {\n mutate(() => {\n const slot = slots[indexOf(host)];\n if (slot) slot.onScreen = false;\n });\n },\n remove(host: G9HostHandle): void {\n mutate(() => {\n const index = indexOf(host);\n if (index >= 0) slots.splice(index, 1);\n });\n },\n};\n"],"names":["slots","listeners","Set","isDescendant","host","ancestor","p","resolve","_ref","_slots_","onScreen","slot","current","parent","nested","mutate","change","before","after","failure","listener","Array","error","indexOf","g9Hosts","G9Error","hostRegistry","index","i"],"mappings":";AA4GA,MAAMA,QAAgB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AAKP;AAGzE,MAAMoB,UAA0B;IACrC,QAAQjB;IACR;QACE,MAAMH,OAAOG;QACb,IAAI,CAACH,MACH,MAAM,IAAIqB,QACR,gBACA;QAIJ,OAAOrB;IACT;IACA,WAAUgB,QAAQ;QAChBnB,UAAU,GAAG,CAACmB;QACd,OAAO;YACLnB,UAAU,MAAM,CAACmB;QACnB;IACF;IACA,IAAI;QACF,OAAOpB,MAAM,MAAM;IACrB;AACF;AAOO,MAAM0B,eAAe;IAC1B,UAAStB,IAAkB;QACzBW,OAAO;YACL,MAAMY,QAAQJ,QAAQnB;YACtB,IAAIuB,SAAS,GAAG3B,MAAM,MAAM,CAAC2B,OAAO;YACpC3B,MAAM,OAAO,CAAC;gBAAEI;gBAAM,UAAU;YAAK;QACvC;IACF;IACA,UAASA,IAAkB;QACzBW,OAAO;YACL,IAAIQ,QAAQnB,SAAS,GAAG;YACxB,IAAIuB,QAAQ;YACZ3B,MAAM,OAAO,CAAC,CAACW,MAAMiB;gBACnB,IAAIjB,KAAK,QAAQ,EAAEgB,QAAQC,IAAI;YACjC;YACA5B,MAAM,MAAM,CAAC2B,OAAO,GAAG;gBAAEvB;gBAAM,UAAU;YAAM;QACjD;IACF;IACA,eAAcA,IAAkB;QAC9BW,OAAO;YACL,MAAMJ,OAAOX,KAAK,CAACuB,QAAQnB,MAAM;YACjC,IAAIO,MAAMA,KAAK,QAAQ,GAAG;QAC5B;IACF;IACA,QAAOP,IAAkB;QACvBW,OAAO;YACL,MAAMY,QAAQJ,QAAQnB;YACtB,IAAIuB,SAAS,GAAG3B,MAAM,MAAM,CAAC2B,OAAO;QACtC;IACF;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type * from './anchor/index.js';
|
|
1
2
|
export type * from './base/index.js';
|
|
2
3
|
export type * from './button/index.js';
|
|
3
4
|
export type * from './cascade/index.js';
|
|
@@ -6,6 +7,7 @@ export type * from './display/index.js';
|
|
|
6
7
|
export type * from './edge-panel/index.js';
|
|
7
8
|
export type * from './expander/index.js';
|
|
8
9
|
export type * from './fields/index.js';
|
|
10
|
+
export type * from './guide/index.js';
|
|
9
11
|
export type * from './host/index.js';
|
|
10
12
|
export type * from './icon/index.js';
|
|
11
13
|
export type * from './pickers/index.js';
|
|
@@ -13,6 +15,7 @@ export type * from './plus-button/index.js';
|
|
|
13
15
|
export type * from './popup/index.js';
|
|
14
16
|
export type * from './provider/index.js';
|
|
15
17
|
export type * from './range-slider/index.js';
|
|
18
|
+
export type * from './route/index.js';
|
|
16
19
|
export type * from './selection/index.js';
|
|
17
20
|
export type * from './sheet/index.js';
|
|
18
21
|
export type * from './swipe/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,mBAAmB,QAAQ,CAAC;AAC5B,mBAAmB,UAAU,CAAC;AAC9B,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,UAAU,CAAC;AAC9B,mBAAmB,QAAQ,CAAC;AAC5B,mBAAmB,QAAQ,CAAC;AAC5B,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,aAAa,CAAC;AACjC,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,QAAQ,CAAC;AAC5B,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,mBAAmB,UAAU,CAAC;AAC9B,mBAAmB,QAAQ,CAAC;AAC5B,mBAAmB,UAAU,CAAC;AAC9B,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,UAAU,CAAC;AAC9B,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,QAAQ,CAAC;AAC5B,mBAAmB,QAAQ,CAAC;AAC5B,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,aAAa,CAAC;AACjC,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,QAAQ,CAAC;AAC5B,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,UAAU,CAAC"}
|
|
@@ -27,7 +27,15 @@ export interface G9ComboBoxProps<T extends G9SelectionItem = G9SelectionItem> ex
|
|
|
27
27
|
readonly clearButton?: boolean;
|
|
28
28
|
/** Direction of the value/chips and the sheet rows (MAUI `ValueTextDirection`). Default follows the culture. */
|
|
29
29
|
readonly valueTextDirection?: G9TextInputDirection;
|
|
30
|
+
/**
|
|
31
|
+
* How a multi-select field draws its chosen items (MAUI 1.4.10 `ChipStyle`): `'filled'` (default — primary chips) or
|
|
32
|
+
* `'tonal'` — light pills (SurfaceContainerLow, an OutlineVariant hairline, TextPrimary 14) each with its own «×» that
|
|
33
|
+
* removes that one item without opening the sheet. Pair with `clearButton={false}` to keep the trailing glyph (AgriPad).
|
|
34
|
+
*/
|
|
35
|
+
readonly chipStyle?: G9ComboBoxChipStyle;
|
|
30
36
|
}
|
|
37
|
+
/** MAUI `G9ComboBoxChipStyle`. */
|
|
38
|
+
export type G9ComboBoxChipStyle = 'filled' | 'tonal';
|
|
31
39
|
/** Two key lists hold the same keys in the same order. */
|
|
32
40
|
export declare function sameSelectionKeys(a: ReadonlyArray<string>, b: ReadonlyArray<string>): boolean;
|
|
33
41
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combo-box.d.ts","sourceRoot":"","sources":["../../src/pickers/combo-box.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"combo-box.d.ts","sourceRoot":"","sources":["../../src/pickers/combo-box.tsx"],"names":[],"mappings":"AACA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAgD,KAAK,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACxH,OAAO,EAAE,KAAK,SAAS,EAAU,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,KAAK,eAAe,EAA+B,MAAM,wBAAwB,CAAC;AAM3F,OAAO,EACL,KAAK,kBAAkB,EAMxB,MAAM,WAAW,CAAC;AAEnB,yEAAyE;AACzE,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,mCAAmC;AACnC,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe,CAAE,SAAQ,kBAAkB;IACtG,sGAAsG;IACtG,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACjC,iHAAiH;IACjH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IACtE,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACxC,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC/C,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACzF,4DAA4D;IAC5D,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,kGAAkG;IAClG,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,2GAA2G;IAC3G,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,gHAAgH;IAChH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,oBAAoB,CAAC;IACnD;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,mBAAmB,CAAC;CAC1C;AAED,kCAAkC;AAClC,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,OAAO,CAAC;AAErD,0DAA0D;AAC1D,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,OAAO,CAE7F;AAGD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,SAAS,CAwI5G"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { resolveRestingPlaceholder } from "../fields/outlined-field.jsx";
|
|
1
2
|
import "./pickers.css";
|
|
2
3
|
import { G9StringKey, buildSolidOrGradient, fillToCss } from "@g9tm/lynxcontrols-foundation";
|
|
3
4
|
import { useRef } from "@lynx-js/react";
|
|
4
5
|
import { g9RowStyle } from "../base/control.jsx";
|
|
5
|
-
import { selectionKey } from "../base/selection-item.jsx";
|
|
6
|
+
import { isAvatarImage, selectionKey } from "../base/selection-item.jsx";
|
|
6
7
|
import { useControllableState } from "../base/use-controllable-state.jsx";
|
|
8
|
+
import { G9IconSlot, hasIconSlot } from "../icon/slot.jsx";
|
|
7
9
|
import { useG9Direction, useG9Settings, useG9Strings, useG9Theme } from "../provider/hooks.jsx";
|
|
8
10
|
import { showSelectionSheet } from "../selection/selection-sheet.jsx";
|
|
9
11
|
import { useG9Sheets } from "../sheet/service.jsx";
|
|
@@ -14,7 +16,7 @@ function sameSelectionKeys(a, b) {
|
|
|
14
16
|
}
|
|
15
17
|
const sameKeys = sameSelectionKeys;
|
|
16
18
|
function G9ComboBox(props) {
|
|
17
|
-
var _props_defaultValue, _props_defaultValues,
|
|
19
|
+
var _props_defaultValue, _props_defaultValues, _resolveRestingPlaceholder;
|
|
18
20
|
const sheets = useG9Sheets();
|
|
19
21
|
const glyphs = useG9Settings().glyphs;
|
|
20
22
|
const strings = useG9Strings();
|
|
@@ -55,6 +57,13 @@ function G9ComboBox(props) {
|
|
|
55
57
|
if (multiple) setKeys([], []);
|
|
56
58
|
else setKey(null, null);
|
|
57
59
|
};
|
|
60
|
+
const removeOne = (item)=>{
|
|
61
|
+
if (blocked) return;
|
|
62
|
+
const k = selectionKey(item);
|
|
63
|
+
const next = latest.current.keys.filter((x)=>x !== k);
|
|
64
|
+
if (next.length !== latest.current.keys.length) setKeys(next, byKey(next));
|
|
65
|
+
};
|
|
66
|
+
const tonal = 'tonal' === props.chipStyle;
|
|
58
67
|
const onOpen = ()=>open(async (isCurrent)=>{
|
|
59
68
|
var _ref, _p_label, _p_emptyStateText;
|
|
60
69
|
var _p_sheetTitle;
|
|
@@ -103,27 +112,60 @@ function G9ComboBox(props) {
|
|
|
103
112
|
} : null}>
|
|
104
113
|
<view className={`g9-combo__value ${dir}`} style={row}>
|
|
105
114
|
{multiple && hasValue ? <view className="g9-combo__chips" style={row}>
|
|
106
|
-
{selected.slice(0, g9ComboMaxChips).map((item)
|
|
115
|
+
{selected.slice(0, g9ComboMaxChips).map((item)=>tonal ? <TonalChip key={selectionKey(item)} item={item} row={row} rtl={'rtl' === valueDirection(props.valueTextDirection, culture)} removable={!blocked} onRemove={()=>removeOne(item)}/> : <view key={selectionKey(item)} className="g9-combo__chip" style={{
|
|
107
116
|
...row,
|
|
108
117
|
background: fillToCss(buildSolidOrGradient(primary, true))
|
|
109
118
|
}}>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
119
|
+
<SelectionValueIcon item={item} color="var(--g9-on-primary)" inChip/>
|
|
120
|
+
<text className="g9-combo__chip-text" text-maxline="1">
|
|
121
|
+
{item.text}
|
|
122
|
+
</text>
|
|
123
|
+
</view>)}
|
|
115
124
|
{selected.length > g9ComboMaxChips ? <view className="g9-combo__chip g9-combo__chip--more">
|
|
116
125
|
<text className="g9-combo__chip-text">{`+${selected.length - g9ComboMaxChips}`}</text>
|
|
117
126
|
</view> : null}
|
|
118
127
|
</view> : [
|
|
119
128
|
hasValue ? <SelectionValueIcon key="i" item={selected[0]}/> : null,
|
|
120
129
|
<text key="t" className={`g9-picker__text${hasValue ? '' : ' g9-picker__text--placeholder'}`} text-maxline="1">
|
|
121
|
-
{hasValue ? selected[0].text :
|
|
130
|
+
{hasValue ? selected[0].text : null != (_resolveRestingPlaceholder = resolveRestingPlaceholder(props)) ? _resolveRestingPlaceholder : ''}
|
|
122
131
|
</text>
|
|
123
132
|
]}
|
|
124
133
|
</view>
|
|
125
134
|
</PickerField>;
|
|
126
135
|
}
|
|
136
|
+
function TonalChip(props) {
|
|
137
|
+
var _item_emoji, _item_iconPath, _item_iconImage, _item_iconTintColor;
|
|
138
|
+
const glyphs = useG9Settings().glyphs;
|
|
139
|
+
const { item } = props;
|
|
140
|
+
const icon = {
|
|
141
|
+
emoji: null != (_item_emoji = item.emoji) ? _item_emoji : null,
|
|
142
|
+
icon: item.icon,
|
|
143
|
+
imagePath: null != (_item_iconPath = item.iconPath) ? _item_iconPath : null,
|
|
144
|
+
image: null != (_item_iconImage = item.iconImage) ? _item_iconImage : null
|
|
145
|
+
};
|
|
146
|
+
return <view className="g9-combo__tonal" style={{
|
|
147
|
+
...props.row,
|
|
148
|
+
...props.rtl ? {
|
|
149
|
+
paddingRight: '10px',
|
|
150
|
+
paddingLeft: '6px',
|
|
151
|
+
marginLeft: '4px'
|
|
152
|
+
} : {
|
|
153
|
+
paddingLeft: '10px',
|
|
154
|
+
paddingRight: '6px',
|
|
155
|
+
marginRight: '4px'
|
|
156
|
+
}
|
|
157
|
+
}}>
|
|
158
|
+
{!isAvatarImage(item) && hasIconSlot(icon) ? <G9IconSlot {...icon} size={14} color={null != (_item_iconTintColor = item.iconTintColor) ? _item_iconTintColor : 'var(--g9-on-surface-variant)'}/> : null}
|
|
159
|
+
<text className="g9-combo__tonal-text" text-maxline="1">
|
|
160
|
+
{item.text}
|
|
161
|
+
</text>
|
|
162
|
+
<view className="g9-combo__tonal-close" accessibility-element={true} accessibility-traits="button" accessibility-label={item.text} {...props.removable ? {
|
|
163
|
+
catchtap: props.onRemove
|
|
164
|
+
} : {}}>
|
|
165
|
+
<G9IconSlot icon={glyphs.clear} size={16} color="var(--g9-text-tertiary)"/>
|
|
166
|
+
</view>
|
|
167
|
+
</view>;
|
|
168
|
+
}
|
|
127
169
|
export { G9ComboBox, g9ComboMaxChips, sameSelectionKeys };
|
|
128
170
|
|
|
129
171
|
//# sourceMappingURL=combo-box.jsx.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickers/combo-box.jsx","sources":["../../src/pickers/combo-box.tsx"],"sourcesContent":["import './pickers.css';\nimport { buildSolidOrGradient, fillToCss, G9StringKey, type G9TextInputDirection } from '@g9tm/lynxcontrols-foundation';\nimport { type ReactNode, useRef } from '@lynx-js/react';\nimport { g9RowStyle } from '../base/control';\nimport { type G9SelectionItem, selectionKey } from '../base/selection-item';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { useG9Direction, useG9Settings, useG9Strings, useG9Theme } from '../provider/hooks';\nimport { showSelectionSheet } from '../selection/selection-sheet';\nimport { useG9Sheets } from '../sheet/service';\nimport {\n type G9PickerFieldProps,\n PickerField,\n SelectionValueIcon,\n usePickerOpen,\n valueDirection,\n valueDirectionClass,\n} from './trigger';\n\n/** Chips shown in the box before the `+N` overflow chip (MAUI combo). */\nexport const g9ComboMaxChips = 2;\n\n/** Props of {@link G9ComboBox}. */\nexport interface G9ComboBoxProps<T extends G9SelectionItem = G9SelectionItem> extends G9PickerFieldProps {\n /** The rows (MAUI `ItemsSource`). Disabled items are left out except selected ones (shown dimmed). */\n readonly items: ReadonlyArray<T>;\n /** Multi-selection (MAUI `AllowMultipleSelection`): `values` instead of `value`, Done commits. Default false. */\n readonly allowMultiple?: boolean;\n /** Single mode: the selected key (MAUI `SelectedItem`). */\n readonly value?: string | null;\n readonly defaultValue?: string | null;\n readonly onValueChange?: (key: string | null, item: T | null) => void;\n /** Multi mode: the selected keys, in list order (MAUI `SelectedItems`). */\n readonly values?: ReadonlyArray<string>;\n readonly defaultValues?: ReadonlyArray<string>;\n readonly onValuesChange?: (keys: ReadonlyArray<string>, items: ReadonlyArray<T>) => void;\n /** Sheet title; default the label, else the placeholder. */\n readonly sheetTitle?: string | null;\n /** Text when the search finds nothing (MAUI `EmptyStateText`, default localized \"No results\"). */\n readonly emptyStateText?: string | null;\n /** A × in the trailing slot clears the selection while there is one (MAUI `ClearButton`). Default true. */\n readonly clearButton?: boolean;\n /** Direction of the value/chips and the sheet rows (MAUI `ValueTextDirection`). Default follows the culture. */\n readonly valueTextDirection?: G9TextInputDirection;\n}\n\n/** Two key lists hold the same keys in the same order. */\nexport function sameSelectionKeys(a: ReadonlyArray<string>, b: ReadonlyArray<string>): boolean {\n return a.length === b.length && a.every((k, i) => k === b[i]);\n}\nconst sameKeys = sameSelectionKeys;\n\n/**\n * Searchable single or multi selection in an outlined box (MAUI `G9ComboBox`). The sheet always has search. Single:\n * only a pick writes the value; a dismissal leaves it. Multi: Done commits, and so does dismissing a sheet whose\n * selection changed; an untouched dismissal writes nothing. The box shows the value (icon or swatch + text), or up\n * to two chips and a `+N` chip; with `clearButton` the trailing search glyph becomes × while there is a value and a\n * tap on it clears without opening. A result that arrives after the field unmounted, or after a newer open, is\n * dropped.\n */\nexport function G9ComboBox<T extends G9SelectionItem = G9SelectionItem>(props: G9ComboBoxProps<T>): ReactNode {\n const sheets = useG9Sheets();\n const glyphs = useG9Settings().glyphs;\n const strings = useG9Strings();\n const culture = useG9Direction();\n const primary = useG9Theme().palette.Primary;\n const open = usePickerOpen();\n const multiple = props.allowMultiple === true;\n const byKey = (keys: ReadonlyArray<string>) =>\n keys.map((k) => props.items.find((i) => selectionKey(i) === k)).filter((i): i is T => i !== undefined);\n const [key, setKey] = useControllableState<string | null, [T | null]>({\n value: props.value,\n defaultValue: props.defaultValue ?? null,\n onChange: props.onValueChange,\n name: 'G9ComboBox.value',\n });\n const [keys, setKeys] = useControllableState<ReadonlyArray<string>, [ReadonlyArray<T>]>({\n value: props.values,\n defaultValue: props.defaultValues ?? [],\n onChange: props.onValuesChange,\n name: 'G9ComboBox.values',\n equals: sameKeys,\n });\n const latest = useRef({ props, key, keys });\n latest.current = { props, key, keys };\n\n const selected = multiple ? byKey(keys) : byKey(key === null ? [] : [key]);\n const hasValue = selected.length > 0;\n const blocked = props.disabled === true || props.readOnly === true;\n\n const clear = () => {\n if (multiple) setKeys([], []);\n else setKey(null, null);\n };\n\n const onOpen = () =>\n open(async (isCurrent) => {\n const { props: p, key: k, keys: ks } = latest.current;\n const current = p.allowMultiple ? ks : k === null ? [] : [k];\n const picked = current\n .map((c) => p.items.find((i) => selectionKey(i) === c))\n .filter((i): i is T => i !== undefined);\n const items = p.items.filter((i) => i.isEnabled !== false || picked.includes(i));\n if (items.length === 0) return;\n const result = await showSelectionSheet(sheets, {\n title: p.sheetTitle?.trim() ? p.sheetTitle : (p.label ?? p.placeholder ?? ''),\n items,\n selectedItems: picked,\n allowMultiple: p.allowMultiple === true,\n closeOnSingleSelection: p.allowMultiple !== true,\n showSearch: true,\n emptyText: p.emptyStateText ?? strings.get(G9StringKey.NoResults),\n ...(p.valueTextDirection ? { itemTextDirection: p.valueTextDirection } : {}),\n });\n if (!isCurrent()) return;\n if (p.allowMultiple) {\n if (!result.wasAccepted && !result.selectionChanged) return;\n const next = result.items.map(selectionKey);\n if (sameKeys(next, latest.current.keys)) return;\n setKeys(next, result.items);\n } else if (result.wasAccepted) {\n const item = result.items[0] ?? null;\n setKey(item ? selectionKey(item) : null, item);\n }\n });\n\n const showClear = props.clearButton !== false && hasValue && !blocked;\n const dir = valueDirectionClass(props.valueTextDirection, culture);\n const row = g9RowStyle(valueDirection(props.valueTextDirection, culture));\n return (\n <PickerField\n field={{ trailingIcon: glyphs.search, ...props }}\n hasValue={hasValue}\n onOpen={onOpen}\n trailingAffordance={\n showClear\n ? { icon: glyphs.clear, signature: 'clear', label: strings.get(G9StringKey.Clear), onPress: clear }\n : null\n }\n >\n <view className={`g9-combo__value ${dir}`} style={row}>\n {multiple && hasValue ? (\n <view className=\"g9-combo__chips\" style={row}>\n {selected.slice(0, g9ComboMaxChips).map((item) => (\n // MAUI G9Colors.BuildSolidOrGradient(palette.Primary, useGradient: true).\n <view\n key={selectionKey(item)}\n className=\"g9-combo__chip\"\n style={{ ...row, background: fillToCss(buildSolidOrGradient(primary, true)) }}\n >\n <SelectionValueIcon item={item} color=\"var(--g9-on-primary)\" />\n <text className=\"g9-combo__chip-text\" text-maxline=\"1\">\n {item.text}\n </text>\n </view>\n ))}\n {selected.length > g9ComboMaxChips ? (\n <view className=\"g9-combo__chip g9-combo__chip--more\">\n <text className=\"g9-combo__chip-text\">{`+${selected.length - g9ComboMaxChips}`}</text>\n </view>\n ) : null}\n </view>\n ) : (\n [\n hasValue ? <SelectionValueIcon key=\"i\" item={selected[0] as T} /> : null,\n <text\n key=\"t\"\n className={`g9-picker__text${hasValue ? '' : ' g9-picker__text--placeholder'}`}\n text-maxline=\"1\"\n >\n {hasValue ? (selected[0] as T).text : props.label ? '' : (props.placeholder ?? '')}\n </text>,\n ]\n )}\n </view>\n </PickerField>\n );\n}\n"],"names":["g9ComboMaxChips","sameSelectionKeys","a","b","k","i","sameKeys","G9ComboBox","props","_props_defaultValue","_props_defaultValues","_props_placeholder","sheets","useG9Sheets","glyphs","useG9Settings","strings","useG9Strings","culture","useG9Direction","primary","useG9Theme","open","usePickerOpen","multiple","byKey","keys","selectionKey","undefined","key","setKey","useControllableState","setKeys","latest","useRef","selected","hasValue","blocked","clear","onOpen","isCurrent","_ref","_p_emptyStateText","_p_sheetTitle","p","ks","current","picked","c","items","result","showSelectionSheet","G9StringKey","next","_result_items_","item","showClear","dir","valueDirectionClass","row","g9RowStyle","valueDirection","PickerField","view","fillToCss","buildSolidOrGradient","SelectionValueIcon","text"],"mappings":";;;;;;;;;;AAmBO,MAAMA,kBAAkB;AA2BxB,SAASC,kBAAkBC,CAAwB,EAAEC,CAAwB;IAClF,OAAOD,EAAE,MAAM,KAAKC,EAAE,MAAM,IAAID,EAAE,KAAK,CAAC,CAACE,GAAGC,IAAMD,MAAMD,CAAC,CAACE,EAAE;AAC9D;AACA,MAAMC,WAAWL;AAUV,SAASM,WAAwDC,KAAyB;QAY/EC,qBAMAC,sBA4FsDC;IA7GtE,MAAMC,SAASC;IACf,MAAMC,SAASC,gBAAgB,MAAM;IACrC,MAAMC,UAAUC;IAChB,MAAMC,UAAUC;IAChB,MAAMC,UAAUC,aAAa,OAAO,CAAC,OAAO;IAC5C,MAAMC,OAAOC;IACb,MAAMC,WAAWhB,AAAwB,SAAxBA,MAAM,aAAa;IACpC,MAAMiB,QAAQ,CAACC,OACbA,KAAK,GAAG,CAAC,CAACtB,IAAMI,MAAM,KAAK,CAAC,IAAI,CAAC,CAACH,IAAMsB,aAAatB,OAAOD,IAAI,MAAM,CAAC,CAACC,IAAcA,AAAMuB,WAANvB;IACxF,MAAM,CAACwB,KAAKC,OAAO,GAAGC,qBAAgD;Q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iC,EAC9E,aAAa,IACd;cACC,CAACA,WAAYD,QAAQ,CAAC,EAAE,CAAO,IAAI,GAAG3B,MAAM,KAAK,GAAG,KAAK,QAACG,CAAAA,qBAAAA,MAAM,WAAW,AAAD,IAAhBA,qBAAqB,GAAI;YACrF,EAAEwD;KACH,CACD;MACJ,EAAEJ,KAAK;IACT,EAAED;AAEN"}
|
|
1
|
+
{"version":3,"file":"pickers/combo-box.jsx","sources":["../../src/pickers/combo-box.tsx"],"sourcesContent":["import { resolveRestingPlaceholder } from '../fields/outlined-field';\nimport './pickers.css';\nimport { buildSolidOrGradient, fillToCss, G9StringKey, type G9TextInputDirection } from '@g9tm/lynxcontrols-foundation';\nimport { type ReactNode, useRef } from '@lynx-js/react';\nimport { g9RowStyle } from '../base/control';\nimport { type G9SelectionItem, isAvatarImage, selectionKey } from '../base/selection-item';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { G9IconSlot, hasIconSlot } from '../icon/slot';\nimport { useG9Direction, useG9Settings, useG9Strings, useG9Theme } from '../provider/hooks';\nimport { showSelectionSheet } from '../selection/selection-sheet';\nimport { useG9Sheets } from '../sheet/service';\nimport {\n type G9PickerFieldProps,\n PickerField,\n SelectionValueIcon,\n usePickerOpen,\n valueDirection,\n valueDirectionClass,\n} from './trigger';\n\n/** Chips shown in the box before the `+N` overflow chip (MAUI combo). */\nexport const g9ComboMaxChips = 2;\n\n/** Props of {@link G9ComboBox}. */\nexport interface G9ComboBoxProps<T extends G9SelectionItem = G9SelectionItem> extends G9PickerFieldProps {\n /** The rows (MAUI `ItemsSource`). Disabled items are left out except selected ones (shown dimmed). */\n readonly items: ReadonlyArray<T>;\n /** Multi-selection (MAUI `AllowMultipleSelection`): `values` instead of `value`, Done commits. Default false. */\n readonly allowMultiple?: boolean;\n /** Single mode: the selected key (MAUI `SelectedItem`). */\n readonly value?: string | null;\n readonly defaultValue?: string | null;\n readonly onValueChange?: (key: string | null, item: T | null) => void;\n /** Multi mode: the selected keys, in list order (MAUI `SelectedItems`). */\n readonly values?: ReadonlyArray<string>;\n readonly defaultValues?: ReadonlyArray<string>;\n readonly onValuesChange?: (keys: ReadonlyArray<string>, items: ReadonlyArray<T>) => void;\n /** Sheet title; default the label, else the placeholder. */\n readonly sheetTitle?: string | null;\n /** Text when the search finds nothing (MAUI `EmptyStateText`, default localized \"No results\"). */\n readonly emptyStateText?: string | null;\n /** A × in the trailing slot clears the selection while there is one (MAUI `ClearButton`). Default true. */\n readonly clearButton?: boolean;\n /** Direction of the value/chips and the sheet rows (MAUI `ValueTextDirection`). Default follows the culture. */\n readonly valueTextDirection?: G9TextInputDirection;\n /**\n * How a multi-select field draws its chosen items (MAUI 1.4.10 `ChipStyle`): `'filled'` (default — primary chips) or\n * `'tonal'` — light pills (SurfaceContainerLow, an OutlineVariant hairline, TextPrimary 14) each with its own «×» that\n * removes that one item without opening the sheet. Pair with `clearButton={false}` to keep the trailing glyph (AgriPad).\n */\n readonly chipStyle?: G9ComboBoxChipStyle;\n}\n\n/** MAUI `G9ComboBoxChipStyle`. */\nexport type G9ComboBoxChipStyle = 'filled' | 'tonal';\n\n/** Two key lists hold the same keys in the same order. */\nexport function sameSelectionKeys(a: ReadonlyArray<string>, b: ReadonlyArray<string>): boolean {\n return a.length === b.length && a.every((k, i) => k === b[i]);\n}\nconst sameKeys = sameSelectionKeys;\n\n/**\n * Searchable single or multi selection in an outlined box (MAUI `G9ComboBox`). The sheet always has search. Single:\n * only a pick writes the value; a dismissal leaves it. Multi: Done commits, and so does dismissing a sheet whose\n * selection changed; an untouched dismissal writes nothing. The box shows the value (icon or swatch + text), or up\n * to two chips and a `+N` chip; with `clearButton` the trailing search glyph becomes × while there is a value and a\n * tap on it clears without opening. A result that arrives after the field unmounted, or after a newer open, is\n * dropped.\n */\nexport function G9ComboBox<T extends G9SelectionItem = G9SelectionItem>(props: G9ComboBoxProps<T>): ReactNode {\n const sheets = useG9Sheets();\n const glyphs = useG9Settings().glyphs;\n const strings = useG9Strings();\n const culture = useG9Direction();\n const primary = useG9Theme().palette.Primary;\n const open = usePickerOpen();\n const multiple = props.allowMultiple === true;\n const byKey = (keys: ReadonlyArray<string>) =>\n keys.map((k) => props.items.find((i) => selectionKey(i) === k)).filter((i): i is T => i !== undefined);\n const [key, setKey] = useControllableState<string | null, [T | null]>({\n value: props.value,\n defaultValue: props.defaultValue ?? null,\n onChange: props.onValueChange,\n name: 'G9ComboBox.value',\n });\n const [keys, setKeys] = useControllableState<ReadonlyArray<string>, [ReadonlyArray<T>]>({\n value: props.values,\n defaultValue: props.defaultValues ?? [],\n onChange: props.onValuesChange,\n name: 'G9ComboBox.values',\n equals: sameKeys,\n });\n const latest = useRef({ props, key, keys });\n latest.current = { props, key, keys };\n\n const selected = multiple ? byKey(keys) : byKey(key === null ? [] : [key]);\n const hasValue = selected.length > 0;\n const blocked = props.disabled === true || props.readOnly === true;\n\n const clear = () => {\n if (multiple) setKeys([], []);\n else setKey(null, null);\n };\n // A tonal chip's «×» (MAUI RemoveSelected): one item out, the sheet stays closed (catchtap keeps the box's tap away).\n const removeOne = (item: T) => {\n if (blocked) return;\n const k = selectionKey(item);\n const next = latest.current.keys.filter((x) => x !== k);\n if (next.length !== latest.current.keys.length) setKeys(next, byKey(next));\n };\n const tonal = props.chipStyle === 'tonal';\n\n const onOpen = () =>\n open(async (isCurrent) => {\n const { props: p, key: k, keys: ks } = latest.current;\n const current = p.allowMultiple ? ks : k === null ? [] : [k];\n const picked = current\n .map((c) => p.items.find((i) => selectionKey(i) === c))\n .filter((i): i is T => i !== undefined);\n const items = p.items.filter((i) => i.isEnabled !== false || picked.includes(i));\n if (items.length === 0) return;\n const result = await showSelectionSheet(sheets, {\n title: p.sheetTitle?.trim() ? p.sheetTitle : (p.label ?? p.placeholder ?? ''),\n items,\n selectedItems: picked,\n allowMultiple: p.allowMultiple === true,\n closeOnSingleSelection: p.allowMultiple !== true,\n showSearch: true,\n emptyText: p.emptyStateText ?? strings.get(G9StringKey.NoResults),\n ...(p.valueTextDirection ? { itemTextDirection: p.valueTextDirection } : {}),\n });\n if (!isCurrent()) return;\n if (p.allowMultiple) {\n if (!result.wasAccepted && !result.selectionChanged) return;\n const next = result.items.map(selectionKey);\n if (sameKeys(next, latest.current.keys)) return;\n setKeys(next, result.items);\n } else if (result.wasAccepted) {\n const item = result.items[0] ?? null;\n setKey(item ? selectionKey(item) : null, item);\n }\n });\n\n const showClear = props.clearButton !== false && hasValue && !blocked;\n const dir = valueDirectionClass(props.valueTextDirection, culture);\n const row = g9RowStyle(valueDirection(props.valueTextDirection, culture));\n return (\n <PickerField\n field={{ trailingIcon: glyphs.search, ...props }}\n hasValue={hasValue}\n onOpen={onOpen}\n trailingAffordance={\n showClear\n ? { icon: glyphs.clear, signature: 'clear', label: strings.get(G9StringKey.Clear), onPress: clear }\n : null\n }\n >\n <view className={`g9-combo__value ${dir}`} style={row}>\n {multiple && hasValue ? (\n <view className=\"g9-combo__chips\" style={row}>\n {selected.slice(0, g9ComboMaxChips).map((item) =>\n tonal ? (\n <TonalChip\n key={selectionKey(item)}\n item={item}\n row={row}\n rtl={valueDirection(props.valueTextDirection, culture) === 'rtl'}\n removable={!blocked}\n onRemove={() => removeOne(item)}\n />\n ) : (\n // MAUI G9Colors.BuildSolidOrGradient(palette.Primary, useGradient: true).\n <view\n key={selectionKey(item)}\n className=\"g9-combo__chip\"\n style={{ ...row, background: fillToCss(buildSolidOrGradient(primary, true)) }}\n >\n <SelectionValueIcon item={item} color=\"var(--g9-on-primary)\" inChip />\n <text className=\"g9-combo__chip-text\" text-maxline=\"1\">\n {item.text}\n </text>\n </view>\n ),\n )}\n {selected.length > g9ComboMaxChips ? (\n <view className=\"g9-combo__chip g9-combo__chip--more\">\n <text className=\"g9-combo__chip-text\">{`+${selected.length - g9ComboMaxChips}`}</text>\n </view>\n ) : null}\n </view>\n ) : (\n [\n hasValue ? <SelectionValueIcon key=\"i\" item={selected[0] as T} /> : null,\n <text\n key=\"t\"\n className={`g9-picker__text${hasValue ? '' : ' g9-picker__text--placeholder'}`}\n text-maxline=\"1\"\n >\n {hasValue ? (selected[0] as T).text : (resolveRestingPlaceholder(props) ?? '')}\n </text>,\n ]\n )}\n </view>\n </PickerField>\n );\n}\n\n/**\n * A `chipStyle: 'tonal'` chip (MAUI 1.4.10 `CreateTonalChip`): 34 high, fully rounded, SurfaceContainerLow on a 1 px\n * OutlineVariant hairline, padding 10 at the start and 6 at the end, 4 after it; an icon (never an avatar) at 14, the text\n * in TextPrimary 14, then a 24 px «×» (TextTertiary 16) that removes this item. Only the «×» takes the tap — the rest of\n * the chip lets it through to the field, which opens the sheet.\n */\nfunction TonalChip(props: {\n readonly item: G9SelectionItem;\n readonly row: ReturnType<typeof g9RowStyle>;\n readonly rtl: boolean;\n readonly removable: boolean;\n readonly onRemove: () => void;\n}): ReactNode {\n const glyphs = useG9Settings().glyphs;\n const { item } = props;\n const icon = {\n emoji: item.emoji ?? null,\n icon: item.icon,\n imagePath: item.iconPath ?? null,\n image: item.iconImage ?? null,\n };\n return (\n // Physical sides from the row's direction (a row never relies on CSS `direction` — Lynxtron ignores it).\n <view\n className=\"g9-combo__tonal\"\n style={{\n ...props.row,\n ...(props.rtl\n ? { paddingRight: '10px', paddingLeft: '6px', marginLeft: '4px' }\n : { paddingLeft: '10px', paddingRight: '6px', marginRight: '4px' }),\n }}\n >\n {!isAvatarImage(item) && hasIconSlot(icon) ? (\n <G9IconSlot {...icon} size={14} color={item.iconTintColor ?? 'var(--g9-on-surface-variant)'} />\n ) : null}\n <text className=\"g9-combo__tonal-text\" text-maxline=\"1\">\n {item.text}\n </text>\n <view\n className=\"g9-combo__tonal-close\"\n accessibility-element={true}\n accessibility-traits=\"button\"\n accessibility-label={item.text}\n {...(props.removable ? { catchtap: props.onRemove } : {})}\n >\n <G9IconSlot icon={glyphs.clear} size={16} color=\"var(--g9-text-tertiary)\" />\n </view>\n </view>\n );\n}\n"],"names":["g9ComboMaxChips","sameSelectionKeys","a","b","k","i","sameKeys","G9ComboBox","props","_props_defaultValue","_props_defaultValues","_resolveRestingPlaceholder","sheets","useG9Sheets","glyphs","useG9Settings","strings","useG9Strings","culture","useG9Direction","primary","useG9Theme","open","usePickerOpen","multiple","byKey","keys","selectionKey","undefined","key","setKey","useControllableState","setKeys","latest","useRef","selected","hasValue","blocked","clear","removeOne","item","next","x","tonal","onOpen","isCurrent","_ref","_p_emptyStateText","_p_sheetTitle","p","ks","current","picked","c","items","result","showSelectionSheet","G9StringKey","_result_items_","showClear","dir","valueDirectionClass","row","g9RowStyle","valueDirection","PickerField","view","TonalChip","fillToCss","buildSolidOrGradient","SelectionValueIcon","text","_item_emoji","_item_iconPath","_item_iconImage","_item_iconTintColor","icon","isAvatarImage","hasIconSlot","G9IconSlot"],"mappings":";;;;;;;;;;;;AAqBO,MAAMA,kBAAkB;AAoCxB,SAASC,kBAAkBC,CAAwB,EAAEC,CAAwB;IAClF,OAAOD,EAAE,MAAM,KAAKC,EAAE,MAAM,IAAID,EAAE,KAAK,CAAC,CAACE,GAAGC,IAAMD,MAAMD,CAAC,CAACE,EAAE;AAC9D;AACA,MAAMC,WAAWL;AAUV,SAASM,WAAwDC,KAAyB;QAY/EC,qBAMAC,sBA+GmCC;IAhInD,MAAMC,SAASC;IACf,MAAMC,SAASC,gBAAgB,MAAM;IACrC,MAAMC,UAAUC;IAChB,MAAMC,UAAUC;IAChB,MAAMC,UAAUC,aAAa,OAAO,CAAC,OAAO;IAC5C,MAAMC,OAAOC;IACb,MAAMC,WAAWhB,AAAwB,SAAxBA,MAAM,aAAa;IACpC,MAAMiB,QAAQ,CAACC,OACbA,KAAK,GAAG,CAAC,CAACtB,IAAMI,MAAM,KAAK,CAAC,IAAI,CAAC,CAACH,IAAMsB,aAAatB,OAAOD,IAAI,MAAM,CAAC,CAACC,IAAcA,AAAMuB,WAANvB;IACxF,MAAM,CAACwB,KAAKC,OAAO,GAAGC,qBAAgD;QACpE,OAAOvB,MAAM,KAAK;QAClB,cAAc,QAAAC,CAAAA,sBAAAA,MAAM,YAAY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cAAcrC,SAASsC,YAAYF,SAClCG,YAAY,GAAGH,IAAI,EAAE,MAAM,IAAI,OAAO,QAAAD,CAAAA,sBAAAA,KAAK,aAAa,AAAD,IAAjBA,sBAAsB,oCAC3D,KAAK;MACT,CAACJ,KAAK,UAAU,uBAAuB,aAAa,IAAI;QACtD,CAAC/B,KAAK,IAAI,CAAC;MACb,EAAE+B,KAAK;MACP,CAACL,KACC,UAAU,wBACV,uBAAuB,MACvB,qBAAqB,SACrB,qBAAqB1B,KAAK,IAAI,GAC7B,GAAIhC,MAAM,SAAS,GAAG;QAAE,UAAUA,MAAM,QAAQ;IAAC,IAAI,CAAC,CAAC,EACzD;QACC,CAACuE,WAAW,MAAMjE,OAAO,KAAK,EAAE,MAAM,IAAI,MAAM,2BAA4B;MAC9E,EAAEoD,KAAK;IACT,EAAEA;AAEN"}
|
|
@@ -2,8 +2,8 @@ import './pickers.css';
|
|
|
2
2
|
import { type G9CalendarSystem, type G9Culture, G9DateTimeDisplayFormat, G9DateTimePickerMode, type G9LocalDate, type G9LocalDateTime } from '@g9tm/lynxcontrols-foundation';
|
|
3
3
|
import { type ReactNode } from '@lynx-js/react';
|
|
4
4
|
import { type G9PickerFieldProps } from './trigger.js';
|
|
5
|
-
/** Years the year window grows by at an edge (MAUI `YearWindowStep
|
|
6
|
-
export declare const g9YearWindowStep =
|
|
5
|
+
/** Years the year window grows by at an edge (MAUI `YearWindowStep`: 12 since 1.4.11, was 25). */
|
|
6
|
+
export declare const g9YearWindowStep = 12;
|
|
7
7
|
/** Props of {@link G9DateTimePicker}. */
|
|
8
8
|
export interface G9DateTimePickerProps extends G9PickerFieldProps {
|
|
9
9
|
/** The value, always Gregorian (MAUI `SelectedDateTime`); `null` = none. Controlled with `onValueChange`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-time-picker.d.ts","sourceRoot":"","sources":["../../src/pickers/date-time-picker.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"date-time-picker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IAC7G,QAAQ,CAAC,QAAQ,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC5C,wDAAwD;IACxD,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;CAChE;AAED,UAAU,cAAc;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,eAAe,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,eAAe,GAAG,IAAI,CAAC;QAAC,GAAG,EAAE,eAAe,GAAG,IAAI,CAAA;KAAE,CAAC;IAC9E,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,MAAM,CAAC;IACpD,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,4GAA4G;AAC5G,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CA8GlE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,CA6ExE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveRestingPlaceholder } from "../fields/outlined-field.jsx";
|
|
1
2
|
import "./pickers.css";
|
|
2
3
|
import { G9DateTimeDisplayFormat, G9DateTimePickerMode, G9StringKey, daysInMonth, formatColor, localDateTimeFromDate, withAlpha } from "@g9tm/lynxcontrols-foundation";
|
|
3
4
|
import { useRef, useState } from "@lynx-js/react";
|
|
@@ -11,7 +12,7 @@ import { asDateTime, clampPickerValue, composePickerValue, dayWheelItems, format
|
|
|
11
12
|
import { PickerSheetHeader, showPickerSheet } from "./picker-sheet.jsx";
|
|
12
13
|
import { PickerField, usePickerOpen } from "./trigger.jsx";
|
|
13
14
|
import { G9WheelColumn } from "./wheel-column.jsx";
|
|
14
|
-
const g9YearWindowStep =
|
|
15
|
+
const g9YearWindowStep = 12;
|
|
15
16
|
function DateTimeSheetBody(props) {
|
|
16
17
|
const strings = useG9Strings();
|
|
17
18
|
const palette = useG9Theme().palette;
|
|
@@ -88,7 +89,7 @@ function DateTimeSheetBody(props) {
|
|
|
88
89
|
</view>;
|
|
89
90
|
}
|
|
90
91
|
function G9DateTimePicker(props) {
|
|
91
|
-
var _props_defaultValue, _props_mode,
|
|
92
|
+
var _props_defaultValue, _props_mode, _resolveRestingPlaceholder;
|
|
92
93
|
const sheets = useG9Sheets();
|
|
93
94
|
const culture = useG9Culture();
|
|
94
95
|
const strings = useG9Strings();
|
|
@@ -141,7 +142,7 @@ function G9DateTimePicker(props) {
|
|
|
141
142
|
...props
|
|
142
143
|
}} hasValue={null !== value} onOpen={onOpen}>
|
|
143
144
|
<text className={`g9-picker__text${value ? '' : ' g9-picker__text--placeholder'}`} text-maxline="1">
|
|
144
|
-
{value ? format(value) :
|
|
145
|
+
{value ? format(value) : null != (_resolveRestingPlaceholder = resolveRestingPlaceholder(props)) ? _resolveRestingPlaceholder : ''}
|
|
145
146
|
</text>
|
|
146
147
|
</PickerField>;
|
|
147
148
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickers/date-time-picker.jsx","sources":["../../src/pickers/date-time-picker.tsx"],"sourcesContent":["import './pickers.css';\nimport {\n daysInMonth,\n formatColor,\n type G9CalendarSystem,\n type G9Culture,\n G9DateTimeDisplayFormat,\n G9DateTimePickerMode,\n type G9LocalDate,\n type G9LocalDateTime,\n G9StringKey,\n localDateTimeFromDate,\n withAlpha,\n} from '@g9tm/lynxcontrols-foundation';\nimport { type ReactNode, useRef, useState } from '@lynx-js/react';\nimport { g9RowStyle } from '../base/control';\nimport { useG9Press } from '../base/press';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { G9IconSlot } from '../icon/slot';\nimport { useG9Culture, useG9Service, useG9Settings, useG9Strings, useG9Theme } from '../provider/hooks';\nimport { useG9Sheets } from '../sheet/service';\nimport {\n asDateTime,\n clampPickerValue,\n composePickerValue,\n dayWheelItems,\n formatPickerValue,\n hourWheelItems,\n minuteWheelItems,\n monthWheelItems,\n normalizePickerBounds,\n pickerParts,\n resolvePickerCalendar,\n yearWheelItems,\n yearWindow,\n} from './date-time';\nimport { PickerSheetHeader, showPickerSheet } from './picker-sheet';\nimport { type G9PickerFieldProps, PickerField, usePickerOpen } from './trigger';\nimport { G9WheelColumn } from './wheel-column';\n\n/** Years the year window grows by at an edge (MAUI `YearWindowStep`). */\nexport const g9YearWindowStep = 25;\n\n/** Props of {@link G9DateTimePicker}. */\nexport interface G9DateTimePickerProps extends G9PickerFieldProps {\n /** The value, always Gregorian (MAUI `SelectedDateTime`); `null` = none. Controlled with `onValueChange`. */\n readonly value?: G9LocalDateTime | null;\n readonly defaultValue?: G9LocalDateTime | null;\n readonly onValueChange?: (value: G9LocalDateTime | null) => void;\n /** Default `'date'`. */\n readonly mode?: G9DateTimePickerMode;\n /** Default `'shortDate'`. */\n readonly displayFormat?: G9DateTimeDisplayFormat;\n /** Text of the `'custom'` format (MAUI `FormattedDisplayText`). */\n readonly formattedDisplayText?: string | null;\n readonly minDate?: G9LocalDate | null;\n readonly maxDate?: G9LocalDate | null;\n /** Hours 0–23 instead of 12-hour AM/PM. Default false. */\n readonly twentyFourHourDisplay?: boolean;\n /**\n * Default true (MAUI `RestoreOnCancel`): Cancel or a dismissal puts back the value the picker had when it opened if\n * it changed meanwhile. False leaves the current value.\n */\n readonly restoreOnCancel?: boolean;\n /** The Today / Now chip. Default true. */\n readonly showTodayButton?: boolean;\n /** Calendar override; default Persian for `fa`, else Gregorian (follows the language, not the direction). */\n readonly calendar?: G9CalendarSystem | null;\n /** Done confirmed a value (MAUI `DateTimeSelected`). */\n readonly onDateTimeSelected?: (value: G9LocalDateTime) => void;\n}\n\ninterface SheetBodyProps {\n readonly title: string;\n readonly initial: G9LocalDateTime;\n readonly now: () => G9LocalDateTime;\n readonly mode: G9DateTimePickerMode;\n readonly calendar: G9CalendarSystem;\n readonly culture: G9Culture;\n readonly bounds: { min: G9LocalDateTime | null; max: G9LocalDateTime | null };\n readonly twentyFourHour: boolean;\n readonly showToday: boolean;\n readonly format: (value: G9LocalDateTime) => string;\n readonly done: (value: G9LocalDateTime) => void;\n readonly cancel: () => void;\n}\n\n/** The drum sheet body (MAUI `G9DateTimePickerSheet`): header, live preview, Today/Now chip, the wheels. */\nexport function DateTimeSheetBody(props: SheetBodyProps): ReactNode {\n const strings = useG9Strings();\n const palette = useG9Theme().palette;\n const glyphs = useG9Settings().glyphs;\n const { calendar, culture, bounds, mode } = props;\n const [value, setValueState] = useState(() => clampPickerValue(props.initial, bounds, calendar));\n // The latest value, written synchronously: a wheel that settles and a Done tap (or a second wheel) can arrive before\n // the re-render binds handlers that close over the new state. Reading the render's `value` there returned the old\n // one, and a second wheel overwrote the first (seen on the Windows CI agent, Azure builds 539/541).\n const latest = useRef(value);\n const setValue = (next: G9LocalDateTime) => {\n latest.current = next;\n setValueState(next);\n };\n const partsOf = (v: G9LocalDateTime) => ({ ...pickerParts(v, calendar), hour: v.hour, minute: v.minute });\n const parts = partsOf(value);\n const minYear = bounds.min ? pickerParts(bounds.min, calendar).year : null;\n const maxYear = bounds.max ? pickerParts(bounds.max, calendar).year : null;\n const [years, setYears] = useState(() => yearWindow(parts.year, minYear, maxYear));\n // A value outside the window (Today, a clamp) rebuilds it around the value.\n const window_ = parts.year < years.from || parts.year > years.to ? yearWindow(parts.year, minYear, maxYear) : years;\n const change = (patch: Partial<typeof parts>) =>\n setValue(composePickerValue({ ...partsOf(latest.current), ...patch }, calendar, bounds));\n const grow = (edge: 'start' | 'end') =>\n setYears((w) =>\n edge === 'end'\n ? { from: w.from, to: Math.min(maxYear ?? 9999, 9999, w.to + g9YearWindowStep) }\n : { from: Math.max(minYear ?? 1, 1, w.from - g9YearWindowStep), to: w.to },\n );\n const today = useG9Press(\n () => {\n const now = props.now();\n setValue(clampPickerValue(mode === G9DateTimePickerMode.Date ? asDateTime(now) : now, bounds, calendar));\n },\n { source: 'G9DateTimePicker', guardMs: 0 },\n );\n const showDate = mode !== G9DateTimePickerMode.Time;\n const showTime = mode !== G9DateTimePickerMode.Date;\n return (\n <view className=\"g9-picker-sheet\">\n <PickerSheetHeader title={props.title} onCancel={props.cancel} onDone={() => props.done(latest.current)} />\n <text className=\"g9-picker-sheet__preview\" text-maxline=\"1\">\n {props.format(value)}\n </text>\n {props.showToday ? (\n // MAUI CreateTodayChip: a 14 dp calendar and 12 bold Primary text, 6 apart, in a pill of Primary 8 % with a\n // Primary 30 % stroke.\n <view\n className=\"g9-picker-sheet__today\"\n accessibility-element={true}\n accessibility-traits=\"button\"\n bindtap={today}\n style={{\n ...g9RowStyle(culture.direction),\n backgroundColor: formatColor(withAlpha(palette.Primary, 0.08)),\n borderColor: formatColor(withAlpha(palette.Primary, 0.3)),\n }}\n >\n <G9IconSlot icon={glyphs.calendarToday} size={14} color={palette.Primary} />\n <text className=\"g9-picker-sheet__today-text\">\n {strings.get(mode === G9DateTimePickerMode.Time ? G9StringKey.Now : G9StringKey.Today)}\n </text>\n </view>\n ) : null}\n <view className={`g9-picker-sheet__wheels g9-dir-${culture.direction}`}>\n {showDate ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Day)}\n items={dayWheelItems(daysInMonth(calendar, parts.year, parts.month), culture)}\n value={parts.day}\n onValueChange={(day) => change({ day })}\n />\n ) : null}\n {showDate ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Month)}\n weight={1.7}\n items={monthWheelItems(calendar, culture)}\n value={parts.month}\n onValueChange={(month) => change({ month })}\n />\n ) : null}\n {showDate ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Year)}\n items={yearWheelItems(window_.from, window_.to, culture)}\n value={parts.year}\n onValueChange={(year) => change({ year })}\n onNearEdge={grow}\n />\n ) : null}\n {showTime ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Hour)}\n items={hourWheelItems(props.twentyFourHour, culture)}\n value={parts.hour}\n onValueChange={(hour) => change({ hour })}\n />\n ) : null}\n {showTime ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Minute)}\n items={minuteWheelItems(culture)}\n value={parts.minute}\n onValueChange={(minute) => change({ minute })}\n />\n ) : null}\n </view>\n </view>\n );\n}\n\n/**\n * Date, time or date-time in an outlined box (MAUI `G9DateTimePicker`): a tap opens the drum sheet (Cancel, title,\n * Done, live preview, Today/Now, day/month/year and hour/minute wheels). The calendar follows the language (`fa` →\n * Persian) unless `calendar` is set; the value stays Gregorian. Min/max clamp the drums (they roll onto the clamped\n * value); a day past the month's end clamps to its last day. Done writes the value and fires `onDateTimeSelected`;\n * Cancel and dismissals write nothing (see `restoreOnCancel`). Must be inside a `G9Host`.\n */\nexport function G9DateTimePicker(props: G9DateTimePickerProps): ReactNode {\n const sheets = useG9Sheets();\n const culture = useG9Culture();\n const strings = useG9Strings();\n const glyphs = useG9Settings().glyphs;\n const clock = useG9Service('clock');\n const open = usePickerOpen();\n const [value, setValue] = useControllableState<G9LocalDateTime | null>({\n value: props.value,\n defaultValue: props.defaultValue ?? null,\n onChange: props.onValueChange,\n name: 'G9DateTimePicker.value',\n });\n const latest = useRef({ props, value });\n latest.current = { props, value };\n const mode = props.mode ?? G9DateTimePickerMode.Date;\n const calendar = resolvePickerCalendar(culture, props.calendar);\n const format = (v: G9LocalDateTime) =>\n formatPickerValue(v, culture, {\n mode,\n displayFormat: props.displayFormat ?? G9DateTimeDisplayFormat.ShortDate,\n twentyFourHour: props.twentyFourHourDisplay === true,\n calendar,\n customText: props.formattedDisplayText ?? null,\n });\n\n const onOpen = () =>\n open(async (isCurrent) => {\n const previous = latest.current.value;\n const p = latest.current.props;\n const now = () => localDateTimeFromDate(new Date(clock.now()));\n const title = p.label?.trim()\n ? p.label\n : strings.get(\n mode === G9DateTimePickerMode.Time\n ? G9StringKey.SelectTime\n : mode === G9DateTimePickerMode.DateTime\n ? G9StringKey.SelectDateTime\n : G9StringKey.SelectDate,\n );\n const bounds = normalizePickerBounds(p.minDate, p.maxDate, calendar);\n const result = await showPickerSheet<G9LocalDateTime>(sheets, ({ done, cancel }) => (\n <DateTimeSheetBody\n title={title}\n initial={previous ?? now()}\n now={now}\n mode={mode}\n calendar={calendar}\n culture={culture}\n bounds={bounds}\n twentyFourHour={p.twentyFourHourDisplay === true}\n showToday={p.showTodayButton !== false}\n format={format}\n done={done}\n cancel={cancel}\n />\n ));\n if (!isCurrent()) return;\n if (result) {\n setValue(result);\n latest.current.props.onDateTimeSelected?.(result);\n } else if (latest.current.props.restoreOnCancel !== false && latest.current.value !== previous) {\n setValue(previous);\n }\n });\n\n return (\n <PickerField\n field={{ trailingIcon: mode === G9DateTimePickerMode.Time ? glyphs.clock : glyphs.calendar, ...props }}\n hasValue={value !== null}\n onOpen={onOpen}\n >\n <text className={`g9-picker__text${value ? '' : ' g9-picker__text--placeholder'}`} text-maxline=\"1\">\n {value ? format(value) : props.label ? '' : (props.placeholder ?? '')}\n </text>\n </PickerField>\n );\n}\n"],"names":["g9YearWindowStep","DateTimeSheetBody","props","strings","useG9Strings","palette","useG9Theme","glyphs","useG9Settings","calendar","culture","bounds","mode","value","setValueState","useState","clampPickerValue","latest","useRef","setValue","next","partsOf","v","pickerParts","parts","minYear","maxYear","years","setYears","yearWindow","window_","change","patch","composePickerValue","grow","edge","w","Math","today","useG9Press","now","G9DateTimePickerMode","asDateTime","showDate","showTime","view","PickerSheetHeader","text","g9RowStyle","formatColor","withAlpha","G9IconSlot","G9StringKey","G9WheelColumn","dayWheelItems","daysInMonth","day","monthWheelItems","month","yearWheelItems","year","hourWheelItems","hour","minuteWheelItems","minute","G9DateTimePicker","_props_defaultValue","_props_mode","_props_placeholder","sheets","useG9Sheets","useG9Culture","clock","useG9Service","open","usePickerOpen","useControllableState","resolvePickerCalendar","format","_props_displayFormat","_props_formattedDisplayText","formatPickerValue","G9DateTimeDisplayFormat","onOpen","isCurrent","_p_label","previous","p","localDateTimeFromDate","Date","title","normalizePickerBounds","result","showPickerSheet","done","cancel","_latest_current_props","PickerField"],"mappings":";;;;;;;;;;;;;AAyCO,MAAMA,mBAAmB;AA+CzB,SAASC,kBAAkBC,KAAqB;IACrD,MAAMC,UAAUC;IAChB,MAAMC,UAAUC,aAAa,OAAO;IACpC,MAAMC,SAASC,gBAAgB,MAAM;IACrC,MAAM,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGV;IAC5C,MAAM,CAACW,OAAOC,cAAc,GAAGC,SAAS,IAAMC,iBAAiBd,MAAM,OAAO,EAAES,QAAQF;IAItF,MAAMQ,SAASC,OAAOL;IACtB,MAAMM,WAAW,CAACC;QAChBH,OAAO,OAAO,GAAGG;QACjBN,cAAcM;IAChB;IACA,MAAMC,UAAU,CAACC,IAAwB;YAAE,GAAGC,YAAYD,GAAGb,SAAS;YAAE,MAAMa,EAAE,IAAI;YAAE,QAAQA,EAAE,MAAM;QAAC;IACvG,MAAME,QAAQH,QAAQR;IACtB,MAAMY,UAAUd,OAAO,GAAG,GAAGY,YAAYZ,OAAO,GAAG,EAAEF,UAAU,IAAI,GAAG;IACtE,MAAMiB,UAAUf,OAAO,GAAG,GAAGY,YAAYZ,OAAO,GAAG,EAAEF,UAAU,IAAI,GAAG;IACtE,MAAM,CAACkB,OAAOC,SAAS,GAAGb,SAAS,IAAMc,WAAWL,MAAM,IAAI,EAAEC,SAASC;IAEzE,MAAMI,UAAUN,MAAM,IAAI,GAAGG,MAAM,IAAI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qB,IAAI,GAAGlC,OAAO,KAAK,GAAGA,OAAO,QAAQ;QAAE,GAAGL,KAAK;IAAC,GACrG,UAAUW,AAAU,SAAVA,OACV,QAAQsE,QACT;MACC,CAACpC,KAAK,WAAW,CAAC,eAAe,EAAElC,QAAQ,KAAK,iCAAiC,EAAE,aAAa,IAAI;QAClG,CAACA,QAAQiE,OAAOjE,SAASX,MAAM,KAAK,GAAG,KAAK,QAACkE,CAAAA,qBAAAA,MAAM,WAAW,AAAD,IAAhBA,qBAAqB,GAAI;MACxE,EAAErB,KAAK;IACT,EAAEkD;AAEN"}
|
|
1
|
+
{"version":3,"file":"pickers/date-time-picker.jsx","sources":["../../src/pickers/date-time-picker.tsx"],"sourcesContent":["import { resolveRestingPlaceholder } from '../fields/outlined-field';\nimport './pickers.css';\nimport {\n daysInMonth,\n formatColor,\n type G9CalendarSystem,\n type G9Culture,\n G9DateTimeDisplayFormat,\n G9DateTimePickerMode,\n type G9LocalDate,\n type G9LocalDateTime,\n G9StringKey,\n localDateTimeFromDate,\n withAlpha,\n} from '@g9tm/lynxcontrols-foundation';\nimport { type ReactNode, useRef, useState } from '@lynx-js/react';\nimport { g9RowStyle } from '../base/control';\nimport { useG9Press } from '../base/press';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { G9IconSlot } from '../icon/slot';\nimport { useG9Culture, useG9Service, useG9Settings, useG9Strings, useG9Theme } from '../provider/hooks';\nimport { useG9Sheets } from '../sheet/service';\nimport {\n asDateTime,\n clampPickerValue,\n composePickerValue,\n dayWheelItems,\n formatPickerValue,\n hourWheelItems,\n minuteWheelItems,\n monthWheelItems,\n normalizePickerBounds,\n pickerParts,\n resolvePickerCalendar,\n yearWheelItems,\n yearWindow,\n} from './date-time';\nimport { PickerSheetHeader, showPickerSheet } from './picker-sheet';\nimport { type G9PickerFieldProps, PickerField, usePickerOpen } from './trigger';\nimport { G9WheelColumn } from './wheel-column';\n\n/** Years the year window grows by at an edge (MAUI `YearWindowStep`: 12 since 1.4.11, was 25). */\nexport const g9YearWindowStep = 12;\n\n/** Props of {@link G9DateTimePicker}. */\nexport interface G9DateTimePickerProps extends G9PickerFieldProps {\n /** The value, always Gregorian (MAUI `SelectedDateTime`); `null` = none. Controlled with `onValueChange`. */\n readonly value?: G9LocalDateTime | null;\n readonly defaultValue?: G9LocalDateTime | null;\n readonly onValueChange?: (value: G9LocalDateTime | null) => void;\n /** Default `'date'`. */\n readonly mode?: G9DateTimePickerMode;\n /** Default `'shortDate'`. */\n readonly displayFormat?: G9DateTimeDisplayFormat;\n /** Text of the `'custom'` format (MAUI `FormattedDisplayText`). */\n readonly formattedDisplayText?: string | null;\n readonly minDate?: G9LocalDate | null;\n readonly maxDate?: G9LocalDate | null;\n /** Hours 0–23 instead of 12-hour AM/PM. Default false. */\n readonly twentyFourHourDisplay?: boolean;\n /**\n * Default true (MAUI `RestoreOnCancel`): Cancel or a dismissal puts back the value the picker had when it opened if\n * it changed meanwhile. False leaves the current value.\n */\n readonly restoreOnCancel?: boolean;\n /** The Today / Now chip. Default true. */\n readonly showTodayButton?: boolean;\n /** Calendar override; default Persian for `fa`, else Gregorian (follows the language, not the direction). */\n readonly calendar?: G9CalendarSystem | null;\n /** Done confirmed a value (MAUI `DateTimeSelected`). */\n readonly onDateTimeSelected?: (value: G9LocalDateTime) => void;\n}\n\ninterface SheetBodyProps {\n readonly title: string;\n readonly initial: G9LocalDateTime;\n readonly now: () => G9LocalDateTime;\n readonly mode: G9DateTimePickerMode;\n readonly calendar: G9CalendarSystem;\n readonly culture: G9Culture;\n readonly bounds: { min: G9LocalDateTime | null; max: G9LocalDateTime | null };\n readonly twentyFourHour: boolean;\n readonly showToday: boolean;\n readonly format: (value: G9LocalDateTime) => string;\n readonly done: (value: G9LocalDateTime) => void;\n readonly cancel: () => void;\n}\n\n/** The drum sheet body (MAUI `G9DateTimePickerSheet`): header, live preview, Today/Now chip, the wheels. */\nexport function DateTimeSheetBody(props: SheetBodyProps): ReactNode {\n const strings = useG9Strings();\n const palette = useG9Theme().palette;\n const glyphs = useG9Settings().glyphs;\n const { calendar, culture, bounds, mode } = props;\n const [value, setValueState] = useState(() => clampPickerValue(props.initial, bounds, calendar));\n // The latest value, written synchronously: a wheel that settles and a Done tap (or a second wheel) can arrive before\n // the re-render binds handlers that close over the new state. Reading the render's `value` there returned the old\n // one, and a second wheel overwrote the first (seen on the Windows CI agent, Azure builds 539/541).\n const latest = useRef(value);\n const setValue = (next: G9LocalDateTime) => {\n latest.current = next;\n setValueState(next);\n };\n const partsOf = (v: G9LocalDateTime) => ({ ...pickerParts(v, calendar), hour: v.hour, minute: v.minute });\n const parts = partsOf(value);\n const minYear = bounds.min ? pickerParts(bounds.min, calendar).year : null;\n const maxYear = bounds.max ? pickerParts(bounds.max, calendar).year : null;\n const [years, setYears] = useState(() => yearWindow(parts.year, minYear, maxYear));\n // A value outside the window (Today, a clamp) rebuilds it around the value.\n const window_ = parts.year < years.from || parts.year > years.to ? yearWindow(parts.year, minYear, maxYear) : years;\n const change = (patch: Partial<typeof parts>) =>\n setValue(composePickerValue({ ...partsOf(latest.current), ...patch }, calendar, bounds));\n const grow = (edge: 'start' | 'end') =>\n setYears((w) =>\n edge === 'end'\n ? { from: w.from, to: Math.min(maxYear ?? 9999, 9999, w.to + g9YearWindowStep) }\n : { from: Math.max(minYear ?? 1, 1, w.from - g9YearWindowStep), to: w.to },\n );\n const today = useG9Press(\n () => {\n const now = props.now();\n setValue(clampPickerValue(mode === G9DateTimePickerMode.Date ? asDateTime(now) : now, bounds, calendar));\n },\n { source: 'G9DateTimePicker', guardMs: 0 },\n );\n const showDate = mode !== G9DateTimePickerMode.Time;\n const showTime = mode !== G9DateTimePickerMode.Date;\n return (\n <view className=\"g9-picker-sheet\">\n <PickerSheetHeader title={props.title} onCancel={props.cancel} onDone={() => props.done(latest.current)} />\n <text className=\"g9-picker-sheet__preview\" text-maxline=\"1\">\n {props.format(value)}\n </text>\n {props.showToday ? (\n // MAUI CreateTodayChip: a 14 dp calendar and 12 bold Primary text, 6 apart, in a pill of Primary 8 % with a\n // Primary 30 % stroke.\n <view\n className=\"g9-picker-sheet__today\"\n accessibility-element={true}\n accessibility-traits=\"button\"\n bindtap={today}\n style={{\n ...g9RowStyle(culture.direction),\n backgroundColor: formatColor(withAlpha(palette.Primary, 0.08)),\n borderColor: formatColor(withAlpha(palette.Primary, 0.3)),\n }}\n >\n <G9IconSlot icon={glyphs.calendarToday} size={14} color={palette.Primary} />\n <text className=\"g9-picker-sheet__today-text\">\n {strings.get(mode === G9DateTimePickerMode.Time ? G9StringKey.Now : G9StringKey.Today)}\n </text>\n </view>\n ) : null}\n <view className={`g9-picker-sheet__wheels g9-dir-${culture.direction}`}>\n {showDate ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Day)}\n items={dayWheelItems(daysInMonth(calendar, parts.year, parts.month), culture)}\n value={parts.day}\n onValueChange={(day) => change({ day })}\n />\n ) : null}\n {showDate ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Month)}\n weight={1.7}\n items={monthWheelItems(calendar, culture)}\n value={parts.month}\n onValueChange={(month) => change({ month })}\n />\n ) : null}\n {showDate ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Year)}\n items={yearWheelItems(window_.from, window_.to, culture)}\n value={parts.year}\n onValueChange={(year) => change({ year })}\n onNearEdge={grow}\n />\n ) : null}\n {showTime ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Hour)}\n items={hourWheelItems(props.twentyFourHour, culture)}\n value={parts.hour}\n onValueChange={(hour) => change({ hour })}\n />\n ) : null}\n {showTime ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Minute)}\n items={minuteWheelItems(culture)}\n value={parts.minute}\n onValueChange={(minute) => change({ minute })}\n />\n ) : null}\n </view>\n </view>\n );\n}\n\n/**\n * Date, time or date-time in an outlined box (MAUI `G9DateTimePicker`): a tap opens the drum sheet (Cancel, title,\n * Done, live preview, Today/Now, day/month/year and hour/minute wheels). The calendar follows the language (`fa` →\n * Persian) unless `calendar` is set; the value stays Gregorian. Min/max clamp the drums (they roll onto the clamped\n * value); a day past the month's end clamps to its last day. Done writes the value and fires `onDateTimeSelected`;\n * Cancel and dismissals write nothing (see `restoreOnCancel`). Must be inside a `G9Host`.\n */\nexport function G9DateTimePicker(props: G9DateTimePickerProps): ReactNode {\n const sheets = useG9Sheets();\n const culture = useG9Culture();\n const strings = useG9Strings();\n const glyphs = useG9Settings().glyphs;\n const clock = useG9Service('clock');\n const open = usePickerOpen();\n const [value, setValue] = useControllableState<G9LocalDateTime | null>({\n value: props.value,\n defaultValue: props.defaultValue ?? null,\n onChange: props.onValueChange,\n name: 'G9DateTimePicker.value',\n });\n const latest = useRef({ props, value });\n latest.current = { props, value };\n const mode = props.mode ?? G9DateTimePickerMode.Date;\n const calendar = resolvePickerCalendar(culture, props.calendar);\n const format = (v: G9LocalDateTime) =>\n formatPickerValue(v, culture, {\n mode,\n displayFormat: props.displayFormat ?? G9DateTimeDisplayFormat.ShortDate,\n twentyFourHour: props.twentyFourHourDisplay === true,\n calendar,\n customText: props.formattedDisplayText ?? null,\n });\n\n const onOpen = () =>\n open(async (isCurrent) => {\n const previous = latest.current.value;\n const p = latest.current.props;\n const now = () => localDateTimeFromDate(new Date(clock.now()));\n const title = p.label?.trim()\n ? p.label\n : strings.get(\n mode === G9DateTimePickerMode.Time\n ? G9StringKey.SelectTime\n : mode === G9DateTimePickerMode.DateTime\n ? G9StringKey.SelectDateTime\n : G9StringKey.SelectDate,\n );\n const bounds = normalizePickerBounds(p.minDate, p.maxDate, calendar);\n const result = await showPickerSheet<G9LocalDateTime>(sheets, ({ done, cancel }) => (\n <DateTimeSheetBody\n title={title}\n initial={previous ?? now()}\n now={now}\n mode={mode}\n calendar={calendar}\n culture={culture}\n bounds={bounds}\n twentyFourHour={p.twentyFourHourDisplay === true}\n showToday={p.showTodayButton !== false}\n format={format}\n done={done}\n cancel={cancel}\n />\n ));\n if (!isCurrent()) return;\n if (result) {\n setValue(result);\n latest.current.props.onDateTimeSelected?.(result);\n } else if (latest.current.props.restoreOnCancel !== false && latest.current.value !== previous) {\n setValue(previous);\n }\n });\n\n return (\n <PickerField\n field={{ trailingIcon: mode === G9DateTimePickerMode.Time ? glyphs.clock : glyphs.calendar, ...props }}\n hasValue={value !== null}\n onOpen={onOpen}\n >\n <text className={`g9-picker__text${value ? '' : ' g9-picker__text--placeholder'}`} text-maxline=\"1\">\n {value ? format(value) : (resolveRestingPlaceholder(props) ?? '')}\n </text>\n </PickerField>\n );\n}\n"],"names":["g9YearWindowStep","DateTimeSheetBody","props","strings","useG9Strings","palette","useG9Theme","glyphs","useG9Settings","calendar","culture","bounds","mode","value","setValueState","useState","clampPickerValue","latest","useRef","setValue","next","partsOf","v","pickerParts","parts","minYear","maxYear","years","setYears","yearWindow","window_","change","patch","composePickerValue","grow","edge","w","Math","today","useG9Press","now","G9DateTimePickerMode","asDateTime","showDate","showTime","view","PickerSheetHeader","text","g9RowStyle","formatColor","withAlpha","G9IconSlot","G9StringKey","G9WheelColumn","dayWheelItems","daysInMonth","day","monthWheelItems","month","yearWheelItems","year","hourWheelItems","hour","minuteWheelItems","minute","G9DateTimePicker","_props_defaultValue","_props_mode","_resolveRestingPlaceholder","sheets","useG9Sheets","useG9Culture","clock","useG9Service","open","usePickerOpen","useControllableState","resolvePickerCalendar","format","_props_displayFormat","_props_formattedDisplayText","formatPickerValue","G9DateTimeDisplayFormat","onOpen","isCurrent","_p_label","previous","p","localDateTimeFromDate","Date","title","normalizePickerBounds","result","showPickerSheet","done","cancel","_latest_current_props","PickerField"],"mappings":";;;;;;;;;;;;;;AA0CO,MAAMA,mBAAmB;AA+CzB,SAASC,kBAAkBC,KAAqB;IACrD,MAAMC,UAAUC;IAChB,MAAMC,UAAUC,aAAa,OAAO;IACpC,MAAMC,SAASC,gBAAgB,MAAM;IACrC,MAAM,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGV;IAC5C,MAAM,CAACW,OAAOC,cAA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,QAAAA,WAAAA,WAAY9C,OACrB,KAAKA,KACL,MAAM5B,MACN,UAAUH,UACV,SAASC,SACT,QAAQC,QACR,gBAAgB4E,AAA4B,SAA5BA,EAAE,qBAAqB,EACvC,WAAWA,AAAsB,UAAtBA,EAAE,eAAe,EAC5B,QAAQT,QACR,MAAMgB,MACN,QAAQC;YAGZ,IAAI,CAACX,aAAa;YAClB,IAAIQ,QAAQ;oBAEVI,0CAAAA;gBADA7E,SAASyE;wBACTI,CAAAA,2CAAAA,AAAAA,CAAAA,wBAAAA,OAAO,OAAO,CAAC,KAAK,AAAD,EAAE,kBAAkB,AAAD,KAAtCA,yCAAAA,IAAAA,CAAAA,uBAA0CJ;YAC5C,OAAO,IAAI3E,AAAyC,UAAzCA,OAAO,OAAO,CAAC,KAAK,CAAC,eAAe,IAAcA,OAAO,OAAO,CAAC,KAAK,KAAKqE,UACpFnE,SAASmE;QAEb;IAEF,QACGW,YACC,OAAO;QAAE,cAAcrF,SAAS6B,qBAAqB,IAAI,GAAGlC,OAAO,KAAK,GAAGA,OAAO,QAAQ;QAAE,GAAGL,KAAK;IAAC,GACrG,UAAUW,AAAU,SAAVA,OACV,QAAQsE,QACT;MACC,CAACpC,KAAK,WAAW,CAAC,eAAe,EAAElC,QAAQ,KAAK,iCAAiC,EAAE,aAAa,IAAI;QAClG,CAACA,QAAQiE,OAAOjE,SAAS,QAACuD,CAAAA,6BAAAA,0BAA0BlE,MAAK,IAA/BkE,6BAAoC,GAAI;MACpE,EAAErB,KAAK;IACT,EAAEkD;AAEN"}
|
|
@@ -4,8 +4,11 @@ export interface G9WheelItem<V extends string | number = number> {
|
|
|
4
4
|
readonly value: V;
|
|
5
5
|
readonly text: string;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Year rows are a window of at most ±12 years around the selection (MAUI `YearWindowRadius`; 50 until 1.4.11, when the
|
|
9
|
+
* picker began to open pre-built: every row is paid for in the tap-to-open time, and the window grows at both edges).
|
|
10
|
+
*/
|
|
11
|
+
export declare const g9YearWindowRadius = 12;
|
|
9
12
|
/** The calendar a picker shows: the explicit one, else Persian for a `fa` culture, else Gregorian (MAUI rule). */
|
|
10
13
|
export declare function resolvePickerCalendar(culture: G9Culture, calendar?: G9CalendarSystem | null): G9CalendarSystem;
|
|
11
14
|
/** A date-time with its time part (a plain date reads as midnight). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-time.d.ts","sourceRoot":"","sources":["../../src/pickers/date-time.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,uBAAuB,EACvB,oBAAoB,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EAOrB,MAAM,+BAA+B,CAAC;AAKvC,2DAA2D;AAC3D,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM;IAC7D,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED
|
|
1
|
+
{"version":3,"file":"date-time.d.ts","sourceRoot":"","sources":["../../src/pickers/date-time.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,uBAAuB,EACvB,oBAAoB,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EAOrB,MAAM,+BAA+B,CAAC;AAKvC,2DAA2D;AAC3D,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM;IAC7D,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,kHAAkH;AAClH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,gBAAgB,GA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6BrH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { G9DateTimeDisplayFormat, G9DateTimePickerMode, clampToPersianRange, compareLocal, daysInMonth, formatLocalDateTime, fromCalendarDate, getMonthNames, isPersianLanguage, isSupportedByPersianCalendar, localDateTime, toCalendarDate, toNativeDigits } from "@g9tm/lynxcontrols-foundation";
|
|
2
|
-
const g9YearWindowRadius =
|
|
2
|
+
const g9YearWindowRadius = 12;
|
|
3
3
|
function resolvePickerCalendar(culture, calendar) {
|
|
4
4
|
if (calendar) return calendar;
|
|
5
5
|
return isPersianLanguage(culture) ? 'persian' : 'gregorian';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickers/date-time.jsx","sources":["../../src/pickers/date-time.ts"],"sourcesContent":["import {\n clampToPersianRange,\n compareLocal,\n daysInMonth,\n formatLocalDateTime,\n fromCalendarDate,\n type G9CalendarSystem,\n type G9Culture,\n G9DateTimeDisplayFormat,\n G9DateTimePickerMode,\n type G9LocalDate,\n type G9LocalDateTime,\n getMonthNames,\n isPersianLanguage,\n isSupportedByPersianCalendar,\n localDateTime,\n toCalendarDate,\n toNativeDigits,\n} from '@g9tm/lynxcontrols-foundation';\n\n// Date math and text of the date/time picker (MAUI `G9DateTimePicker` + `G9DateTimePickerSheet`), Intl-free: every\n// calendar step goes through the foundation calendar functions.\n\n/** One wheel row: the value it stands for and its text. */\nexport interface G9WheelItem<V extends string | number = number> {\n readonly value: V;\n readonly text: string;\n}\n\n/** Year rows are a window of at most ±50 years around the selection (MAUI `YearWindowRadius`). */\nexport const g9YearWindowRadius = 50;\n\n/** The calendar a picker shows: the explicit one, else Persian for a `fa` culture, else Gregorian (MAUI rule). */\nexport function resolvePickerCalendar(culture: G9Culture, calendar?: G9CalendarSystem | null): G9CalendarSystem {\n if (calendar) return calendar;\n return isPersianLanguage(culture) ? 'persian' : 'gregorian';\n}\n\n/** A date-time with its time part (a plain date reads as midnight). */\nexport function asDateTime(value: G9LocalDate): G9LocalDateTime {\n const t = value as Partial<G9LocalDateTime>;\n return localDateTime(\n value.year,\n value.month,\n value.day,\n t.hour ?? 0,\n t.minute ?? 0,\n t.second ?? 0,\n t.millisecond ?? 0,\n );\n}\n\n/**\n * Min/max for a calendar: Persian bounds are pulled into the range the Persian calendar supports (from 0622-03-22),\n * and an inverted pair is swapped.\n */\nexport function normalizePickerBounds(\n min: G9LocalDate | null | undefined,\n max: G9LocalDate | null | undefined,\n calendar: G9CalendarSystem,\n): { min: G9LocalDateTime | null; max: G9LocalDateTime | null } {\n let lo = min ? asDateTime(min) : null;\n let hi = max ? asDateTime(max) : null;\n if (calendar === 'persian') {\n lo = lo ? clampToPersianRange(lo) : null;\n hi = hi ? clampToPersianRange(hi) : null;\n }\n if (lo && hi && compareDateTime(lo, hi) > 0) [lo, hi] = [hi, lo];\n return { min: lo, max: hi };\n}\n\n/** Orders two date-times (date first, then time). */\nexport function compareDateTime(a: G9LocalDateTime, b: G9LocalDateTime): number {\n const d = compareLocal(a, b);\n if (d !== 0) return d;\n return (\n a.hour * 3_600_000 +\n a.minute * 60_000 +\n a.second * 1000 +\n a.millisecond -\n (b.hour * 3_600_000 + b.minute * 60_000 + b.second * 1000 + b.millisecond)\n );\n}\n\n/** Clamps a value into `[min, max]` (either bound optional) and, for Persian, into the supported range. */\nexport function clampPickerValue(\n value: G9LocalDateTime,\n bounds: { min: G9LocalDateTime | null; max: G9LocalDateTime | null },\n calendar: G9CalendarSystem,\n): G9LocalDateTime {\n let v = calendar === 'persian' ? clampToPersianRange(value) : value;\n if (bounds.min && compareDateTime(v, bounds.min) < 0) v = bounds.min;\n if (bounds.max && compareDateTime(v, bounds.max) > 0) v = bounds.max;\n return v;\n}\n\n/** The value's parts in the picker calendar (what the day/month/year wheels show). */\nexport function pickerParts(\n value: G9LocalDateTime,\n calendar: G9CalendarSystem,\n): {\n year: number;\n month: number;\n day: number;\n} {\n const c = toCalendarDate(value, calendar);\n return { year: c.year, month: c.month, day: c.day };\n}\n\n/**\n * Builds the value from wheel parts: the day is clamped to the month's length (31 Farvardin → 30 Mehr, 29 Feb → 28\n * in a common year, Esfand 30 → 29), then the result is clamped to the bounds.\n */\nexport function composePickerValue(\n parts: { year: number; month: number; day: number; hour: number; minute: number },\n calendar: G9CalendarSystem,\n bounds: { min: G9LocalDateTime | null; max: G9LocalDateTime | null },\n): G9LocalDateTime {\n const day = Math.min(parts.day, daysInMonth(calendar, parts.year, parts.month));\n const date = fromCalendarDate({ calendar, year: parts.year, month: parts.month, day });\n return clampPickerValue(localDateTime(date.year, date.month, date.day, parts.hour, parts.minute), bounds, calendar);\n}\n\nconst digits = (culture: G9Culture, n: number, width: number) =>\n toNativeDigits(String(n).padStart(width, '0'), culture.numberingSystem);\n\n/** Day rows 1…count (two digits, native numerals). */\nexport function dayWheelItems(count: number, culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: count }, (_, i) => ({ value: i + 1, text: digits(culture, i + 1, 2) }));\n}\n\n/** Month rows with the calendar's month names. */\nexport function monthWheelItems(calendar: G9CalendarSystem, culture: G9Culture): G9WheelItem[] {\n return getMonthNames(calendar, culture).map((text, i) => ({ value: i + 1, text }));\n}\n\n/**\n * The year window (MAUI `BuildYears`): ±{@link g9YearWindowRadius} around `year`, inside the bounds' years (and the\n * calendar's 1…9999 range).\n */\nexport function yearWindow(year: number, minYear: number | null, maxYear: number | null): { from: number; to: number } {\n const lo = Math.max(1, minYear ?? 1);\n const hi = Math.min(9999, maxYear ?? 9999);\n return { from: Math.max(lo, year - g9YearWindowRadius), to: Math.min(hi, year + g9YearWindowRadius) };\n}\n\n/** Year rows `from…to` (four digits, native numerals). */\nexport function yearWheelItems(from: number, to: number, culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: Math.max(0, to - from + 1) }, (_, i) => ({\n value: from + i,\n text: digits(culture, from + i, 4),\n }));\n}\n\n/** Hour rows 0…23: `HH`, or `hh tt` in 12-hour display (MAUI `BuildHours`). */\nexport function hourWheelItems(twentyFourHour: boolean, culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: 24 }, (_, h) => ({\n value: h,\n text: formatLocalDateTime(localDateTime(2000, 1, 1, h), twentyFourHour ? 'HH' : 'hh tt', culture, {\n calendar: 'gregorian',\n }),\n }));\n}\n\n/** Minute rows 0…59. */\nexport function minuteWheelItems(culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: 60 }, (_, m) => ({ value: m, text: digits(culture, m, 2) }));\n}\n\n/** Options of {@link formatPickerValue}. */\nexport interface G9PickerFormatOptions {\n readonly mode?: G9DateTimePickerMode;\n readonly displayFormat?: G9DateTimeDisplayFormat;\n readonly twentyFourHour?: boolean;\n readonly calendar?: G9CalendarSystem | null;\n /** Text of the `'custom'` format (MAUI `FormattedDisplayText`); blank falls back to the short date. */\n readonly customText?: string | null;\n}\n\n/**\n * The trigger and preview text (MAUI `FormatValue`). Gregorian: short `d MMM yyyy`, long `MMMM d, yyyy`, time\n * `HH:mm`/`hh:mm tt`, short date-time `d MMM yyyy, HH:mm`, long date-time `MMMM d, yyyy, hh:mm tt`. Persian:\n * `dd MMMM yyyy` and `{date}، {time}` (a date the Persian calendar cannot hold is written Gregorian). The `'time'`\n * mode always shows the time; `'custom'` shows `customText`.\n */\nexport function formatPickerValue(value: G9LocalDate, culture: G9Culture, options: G9PickerFormatOptions = {}): string {\n const format = options.displayFormat ?? G9DateTimeDisplayFormat.ShortDate;\n if (format === G9DateTimeDisplayFormat.Custom && options.customText && options.customText.trim() !== '') {\n return options.customText;\n }\n const v = asDateTime(value);\n const time = options.twentyFourHour ? 'HH:mm' : 'hh:mm tt';\n const calendar = resolvePickerCalendar(culture, options.calendar);\n const effective = options.mode === G9DateTimePickerMode.Time ? G9DateTimeDisplayFormat.TimeOnly : format;\n if (calendar === 'persian' && isSupportedByPersianCalendar(v)) {\n const fmt = (p: string) => formatLocalDateTime(v, p, culture, { calendar: 'persian' });\n const date = fmt('dd MMMM yyyy');\n if (effective === G9DateTimeDisplayFormat.TimeOnly) return fmt(time);\n if (effective === G9DateTimeDisplayFormat.ShortDateTime || effective === G9DateTimeDisplayFormat.LongDateTime) {\n return `${date}، ${fmt(time)}`;\n }\n return date;\n }\n const pattern =\n effective === G9DateTimeDisplayFormat.LongDate\n ? 'MMMM d, yyyy'\n : effective === G9DateTimeDisplayFormat.TimeOnly\n ? time\n : effective === G9DateTimeDisplayFormat.ShortDateTime\n ? 'd MMM yyyy, HH:mm'\n : effective === G9DateTimeDisplayFormat.LongDateTime\n ? 'MMMM d, yyyy, hh:mm tt'\n : 'd MMM yyyy';\n return formatLocalDateTime(v, pattern, culture, { calendar: 'gregorian' });\n}\n"],"names":["g9YearWindowRadius","resolvePickerCalendar","culture","calendar","isPersianLanguage","asDateTime","value","_t_hour","_t_minute","_t_second","_t_millisecond","t","localDateTime","normalizePickerBounds","min","max","lo","hi","clampToPersianRange","compareDateTime","a","b","d","compareLocal","clampPickerValue","bounds","v","pickerParts","c","toCalendarDate","composePickerValue","parts","day","Math","daysInMonth","date","fromCalendarDate","digits","n","width","toNativeDigits","String","dayWheelItems","count","Array","_","i","monthWheelItems","getMonthNames","text","yearWindow","year","minYear","maxYear","yearWheelItems","from","to","hourWheelItems","twentyFourHour","h","formatLocalDateTime","minuteWheelItems","m","formatPickerValue","options","_options_displayFormat","format","G9DateTimeDisplayFormat","time","effective","G9DateTimePickerMode","isSupportedByPersianCalendar","fmt","p","pattern"],"mappings":";AA8BO,MAAMA,qBAAqB;AAG3B,SAASC,sBAAsBC,OAAkB,EAAEC,QAAkC;IAC1F,IAAIA,UAAU,OAAOA;IACrB,OAAOC,kBAAkBF,WAAW,YAAY;AAClD;AAGO,SAASG,WAAWC,KAAkB;QAMzCC,SACAC,WACAC,WACAC;IARF,MAAMC,IAAIL;IACV,OAAOM,cACLN,MAAM,IAAI,EACVA,MAAM,KAAK,EACXA,MAAM,GAAG,UACTC,CAAAA,UAAAA,EAAE,IAAI,AAAD,IAALA,UAAU,WACVC,CAAAA,YAAAA,EAAE,MAAM,AAAD,IAAPA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E,MAAMK,YAAYL,QAAQ,IAAI,KAAKM,qBAAqB,IAAI,GAAGH,wBAAwB,QAAQ,GAAGD;IAClG,IAAI/D,AAAa,cAAbA,YAA0BoE,6BAA6B7C,IAAI;QAC7D,MAAM8C,MAAM,CAACC,IAAcb,oBAAoBlC,GAAG+C,GAAGvE,SAAS;gBAAE,UAAU;YAAU;QACpF,MAAMiC,OAAOqC,IAAI;QACjB,IAAIH,cAAcF,wBAAwB,QAAQ,EAAE,OAAOK,IAAIJ;QAC/D,IAAIC,cAAcF,wBAAwB,aAAa,IAAIE,cAAcF,wBAAwB,YAAY,EAC3G,OAAO,GAAGhC,KAAK,EAAE,EAAEqC,IAAIJ,OAAO;QAEhC,OAAOjC;IACT;IACA,MAAMuC,UACJL,cAAcF,wBAAwB,QAAQ,GAC1C,iBACAE,cAAcF,wBAAwB,QAAQ,GAC5CC,OACAC,cAAcF,wBAAwB,aAAa,GACjD,sBACAE,cAAcF,wBAAwB,YAAY,GAChD,2BACA;IACZ,OAAOP,oBAAoBlC,GAAGgD,SAASxE,SAAS;QAAE,UAAU;IAAY;AAC1E"}
|
|
1
|
+
{"version":3,"file":"pickers/date-time.jsx","sources":["../../src/pickers/date-time.ts"],"sourcesContent":["import {\n clampToPersianRange,\n compareLocal,\n daysInMonth,\n formatLocalDateTime,\n fromCalendarDate,\n type G9CalendarSystem,\n type G9Culture,\n G9DateTimeDisplayFormat,\n G9DateTimePickerMode,\n type G9LocalDate,\n type G9LocalDateTime,\n getMonthNames,\n isPersianLanguage,\n isSupportedByPersianCalendar,\n localDateTime,\n toCalendarDate,\n toNativeDigits,\n} from '@g9tm/lynxcontrols-foundation';\n\n// Date math and text of the date/time picker (MAUI `G9DateTimePicker` + `G9DateTimePickerSheet`), Intl-free: every\n// calendar step goes through the foundation calendar functions.\n\n/** One wheel row: the value it stands for and its text. */\nexport interface G9WheelItem<V extends string | number = number> {\n readonly value: V;\n readonly text: string;\n}\n\n/**\n * Year rows are a window of at most ±12 years around the selection (MAUI `YearWindowRadius`; 50 until 1.4.11, when the\n * picker began to open pre-built: every row is paid for in the tap-to-open time, and the window grows at both edges).\n */\nexport const g9YearWindowRadius = 12;\n\n/** The calendar a picker shows: the explicit one, else Persian for a `fa` culture, else Gregorian (MAUI rule). */\nexport function resolvePickerCalendar(culture: G9Culture, calendar?: G9CalendarSystem | null): G9CalendarSystem {\n if (calendar) return calendar;\n return isPersianLanguage(culture) ? 'persian' : 'gregorian';\n}\n\n/** A date-time with its time part (a plain date reads as midnight). */\nexport function asDateTime(value: G9LocalDate): G9LocalDateTime {\n const t = value as Partial<G9LocalDateTime>;\n return localDateTime(\n value.year,\n value.month,\n value.day,\n t.hour ?? 0,\n t.minute ?? 0,\n t.second ?? 0,\n t.millisecond ?? 0,\n );\n}\n\n/**\n * Min/max for a calendar: Persian bounds are pulled into the range the Persian calendar supports (from 0622-03-22),\n * and an inverted pair is swapped.\n */\nexport function normalizePickerBounds(\n min: G9LocalDate | null | undefined,\n max: G9LocalDate | null | undefined,\n calendar: G9CalendarSystem,\n): { min: G9LocalDateTime | null; max: G9LocalDateTime | null } {\n let lo = min ? asDateTime(min) : null;\n let hi = max ? asDateTime(max) : null;\n if (calendar === 'persian') {\n lo = lo ? clampToPersianRange(lo) : null;\n hi = hi ? clampToPersianRange(hi) : null;\n }\n if (lo && hi && compareDateTime(lo, hi) > 0) [lo, hi] = [hi, lo];\n return { min: lo, max: hi };\n}\n\n/** Orders two date-times (date first, then time). */\nexport function compareDateTime(a: G9LocalDateTime, b: G9LocalDateTime): number {\n const d = compareLocal(a, b);\n if (d !== 0) return d;\n return (\n a.hour * 3_600_000 +\n a.minute * 60_000 +\n a.second * 1000 +\n a.millisecond -\n (b.hour * 3_600_000 + b.minute * 60_000 + b.second * 1000 + b.millisecond)\n );\n}\n\n/** Clamps a value into `[min, max]` (either bound optional) and, for Persian, into the supported range. */\nexport function clampPickerValue(\n value: G9LocalDateTime,\n bounds: { min: G9LocalDateTime | null; max: G9LocalDateTime | null },\n calendar: G9CalendarSystem,\n): G9LocalDateTime {\n let v = calendar === 'persian' ? clampToPersianRange(value) : value;\n if (bounds.min && compareDateTime(v, bounds.min) < 0) v = bounds.min;\n if (bounds.max && compareDateTime(v, bounds.max) > 0) v = bounds.max;\n return v;\n}\n\n/** The value's parts in the picker calendar (what the day/month/year wheels show). */\nexport function pickerParts(\n value: G9LocalDateTime,\n calendar: G9CalendarSystem,\n): {\n year: number;\n month: number;\n day: number;\n} {\n const c = toCalendarDate(value, calendar);\n return { year: c.year, month: c.month, day: c.day };\n}\n\n/**\n * Builds the value from wheel parts: the day is clamped to the month's length (31 Farvardin → 30 Mehr, 29 Feb → 28\n * in a common year, Esfand 30 → 29), then the result is clamped to the bounds.\n */\nexport function composePickerValue(\n parts: { year: number; month: number; day: number; hour: number; minute: number },\n calendar: G9CalendarSystem,\n bounds: { min: G9LocalDateTime | null; max: G9LocalDateTime | null },\n): G9LocalDateTime {\n const day = Math.min(parts.day, daysInMonth(calendar, parts.year, parts.month));\n const date = fromCalendarDate({ calendar, year: parts.year, month: parts.month, day });\n return clampPickerValue(localDateTime(date.year, date.month, date.day, parts.hour, parts.minute), bounds, calendar);\n}\n\nconst digits = (culture: G9Culture, n: number, width: number) =>\n toNativeDigits(String(n).padStart(width, '0'), culture.numberingSystem);\n\n/** Day rows 1…count (two digits, native numerals). */\nexport function dayWheelItems(count: number, culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: count }, (_, i) => ({ value: i + 1, text: digits(culture, i + 1, 2) }));\n}\n\n/** Month rows with the calendar's month names. */\nexport function monthWheelItems(calendar: G9CalendarSystem, culture: G9Culture): G9WheelItem[] {\n return getMonthNames(calendar, culture).map((text, i) => ({ value: i + 1, text }));\n}\n\n/**\n * The year window (MAUI `BuildYears`): ±{@link g9YearWindowRadius} around `year`, inside the bounds' years (and the\n * calendar's 1…9999 range).\n */\nexport function yearWindow(year: number, minYear: number | null, maxYear: number | null): { from: number; to: number } {\n const lo = Math.max(1, minYear ?? 1);\n const hi = Math.min(9999, maxYear ?? 9999);\n return { from: Math.max(lo, year - g9YearWindowRadius), to: Math.min(hi, year + g9YearWindowRadius) };\n}\n\n/** Year rows `from…to` (four digits, native numerals). */\nexport function yearWheelItems(from: number, to: number, culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: Math.max(0, to - from + 1) }, (_, i) => ({\n value: from + i,\n text: digits(culture, from + i, 4),\n }));\n}\n\n/** Hour rows 0…23: `HH`, or `hh tt` in 12-hour display (MAUI `BuildHours`). */\nexport function hourWheelItems(twentyFourHour: boolean, culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: 24 }, (_, h) => ({\n value: h,\n text: formatLocalDateTime(localDateTime(2000, 1, 1, h), twentyFourHour ? 'HH' : 'hh tt', culture, {\n calendar: 'gregorian',\n }),\n }));\n}\n\n/** Minute rows 0…59. */\nexport function minuteWheelItems(culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: 60 }, (_, m) => ({ value: m, text: digits(culture, m, 2) }));\n}\n\n/** Options of {@link formatPickerValue}. */\nexport interface G9PickerFormatOptions {\n readonly mode?: G9DateTimePickerMode;\n readonly displayFormat?: G9DateTimeDisplayFormat;\n readonly twentyFourHour?: boolean;\n readonly calendar?: G9CalendarSystem | null;\n /** Text of the `'custom'` format (MAUI `FormattedDisplayText`); blank falls back to the short date. */\n readonly customText?: string | null;\n}\n\n/**\n * The trigger and preview text (MAUI `FormatValue`). Gregorian: short `d MMM yyyy`, long `MMMM d, yyyy`, time\n * `HH:mm`/`hh:mm tt`, short date-time `d MMM yyyy, HH:mm`, long date-time `MMMM d, yyyy, hh:mm tt`. Persian:\n * `dd MMMM yyyy` and `{date}، {time}` (a date the Persian calendar cannot hold is written Gregorian). The `'time'`\n * mode always shows the time; `'custom'` shows `customText`.\n */\nexport function formatPickerValue(value: G9LocalDate, culture: G9Culture, options: G9PickerFormatOptions = {}): string {\n const format = options.displayFormat ?? G9DateTimeDisplayFormat.ShortDate;\n if (format === G9DateTimeDisplayFormat.Custom && options.customText && options.customText.trim() !== '') {\n return options.customText;\n }\n const v = asDateTime(value);\n const time = options.twentyFourHour ? 'HH:mm' : 'hh:mm tt';\n const calendar = resolvePickerCalendar(culture, options.calendar);\n const effective = options.mode === G9DateTimePickerMode.Time ? G9DateTimeDisplayFormat.TimeOnly : format;\n if (calendar === 'persian' && isSupportedByPersianCalendar(v)) {\n const fmt = (p: string) => formatLocalDateTime(v, p, culture, { calendar: 'persian' });\n const date = fmt('dd MMMM yyyy');\n if (effective === G9DateTimeDisplayFormat.TimeOnly) return fmt(time);\n if (effective === G9DateTimeDisplayFormat.ShortDateTime || effective === G9DateTimeDisplayFormat.LongDateTime) {\n return `${date}، ${fmt(time)}`;\n }\n return date;\n }\n const pattern =\n effective === G9DateTimeDisplayFormat.LongDate\n ? 'MMMM d, yyyy'\n : effective === G9DateTimeDisplayFormat.TimeOnly\n ? time\n : effective === G9DateTimeDisplayFormat.ShortDateTime\n ? 'd MMM yyyy, HH:mm'\n : effective === G9DateTimeDisplayFormat.LongDateTime\n ? 'MMMM d, yyyy, hh:mm tt'\n : 'd MMM yyyy';\n return formatLocalDateTime(v, pattern, culture, { calendar: 'gregorian' });\n}\n"],"names":["g9YearWindowRadius","resolvePickerCalendar","culture","calendar","isPersianLanguage","asDateTime","value","_t_hour","_t_minute","_t_second","_t_millisecond","t","localDateTime","normalizePickerBounds","min","max","lo","hi","clampToPersianRange","compareDateTime","a","b","d","compareLocal","clampPickerValue","bounds","v","pickerParts","c","toCalendarDate","composePickerValue","parts","day","Math","daysInMonth","date","fromCalendarDate","digits","n","width","toNativeDigits","String","dayWheelItems","count","Array","_","i","monthWheelItems","getMonthNames","text","yearWindow","year","minYear","maxYear","yearWheelItems","from","to","hourWheelItems","twentyFourHour","h","formatLocalDateTime","minuteWheelItems","m","formatPickerValue","options","_options_displayFormat","format","G9DateTimeDisplayFormat","time","effective","G9DateTimePickerMode","isSupportedByPersianCalendar","fmt","p","pattern"],"mappings":";AAiCO,MAAMA,qBAAqB;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done returned, or `null` for Cancel, any dismissal, or a throttled open.
|
|
12
|
-
*
|
|
11
|
+
* resolves the value Done returned, or `null` for Cancel, any dismissal, or a throttled open.
|
|
12
|
+
*
|
|
13
|
+
* ⛔ PRE-BUILT (MAUI 1.4.11): the body is built on the tap and opens finished — no spinner, and nothing waits on the
|
|
14
|
+
* open motion. It used to be a factory shown behind a spinner until the sheet had opened plus 369 ms: the only sheet of
|
|
15
|
+
* the suite that visibly «loaded» (MAUI's field report 2026-11-08, Samsung A24: the spinner stayed for seconds). What made
|
|
16
|
+
* an eager build costly is gone with the ±12-year window (`g9YearWindowRadius`).
|
|
13
17
|
*/
|
|
14
18
|
export declare function showPickerSheet<T>(sheets: G9SheetService, body: (props: G9PickerSheetBodyProps<T>) => ReactNode): Promise<T | null>;
|
|
15
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picker-sheet.d.ts","sourceRoot":"","sources":["../../src/pickers/picker-sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAMhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,wFAAwF;AACxF,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED
|
|
1
|
+
{"version":3,"file":"picker-sheet.d.ts","sourceRoot":"","sources":["../../src/pickers/picker-sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAMhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,wFAAwF;AACxF,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,CAAC,EACrC,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,CAAC,CAAC,KAAK,SAAS,GACpD,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAiBnB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;CAC7B,GAAG,SAAS,CAwBZ"}
|