@g9tm/lynxcontrols 1.7.3 → 2.1.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/README.md +12 -5
- package/dist/.tsbuildinfo +1 -1
- package/dist/anchor/context.jsx +0 -2
- package/dist/anchor/hooks.d.ts.map +1 -1
- package/dist/anchor/hooks.jsx +6 -4
- package/dist/anchor/measure.jsx +0 -2
- package/dist/anchor/registry.d.ts +12 -2
- package/dist/anchor/registry.d.ts.map +1 -1
- package/dist/anchor/registry.jsx +11 -3
- package/dist/anchor/scroll.jsx +0 -2
- package/dist/base/control.d.ts +18 -2
- package/dist/base/control.d.ts.map +1 -1
- package/dist/base/control.jsx +16 -9
- package/dist/base/corner-badge.jsx +0 -2
- package/dist/base/disposer.jsx +0 -2
- package/dist/base/index.d.ts +3 -2
- package/dist/base/index.d.ts.map +1 -1
- package/dist/base/index.jsx +3 -2
- package/dist/base/press.css +83 -0
- package/dist/base/press.css.map +1 -0
- package/dist/base/press.d.ts +13 -2
- package/dist/base/press.d.ts.map +1 -1
- package/dist/base/press.jsx +49 -5
- package/dist/base/pressable.d.ts +10 -1
- package/dist/base/pressable.d.ts.map +1 -1
- package/dist/base/pressable.jsx +13 -8
- package/dist/base/selection-item.jsx +0 -2
- package/dist/base/timers.jsx +0 -2
- package/dist/base/tone.d.ts +15 -0
- package/dist/base/tone.d.ts.map +1 -0
- package/dist/base/tone.jsx +71 -0
- package/dist/base/use-controllable-state.jsx +0 -2
- package/dist/base/use-stable-callback.jsx +0 -2
- package/dist/button/button-variants.css +236 -0
- package/dist/button/button-variants.css.map +1 -0
- package/dist/button/button.css +21 -0
- package/dist/button/button.css.map +1 -1
- package/dist/button/button.d.ts +13 -1
- package/dist/button/button.d.ts.map +1 -1
- package/dist/button/button.jsx +51 -38
- package/dist/button/header-action-button.d.ts +1 -0
- package/dist/button/header-action-button.d.ts.map +1 -1
- package/dist/button/header-action-button.jsx +6 -7
- package/dist/button/icon-button.d.ts +11 -1
- package/dist/button/icon-button.d.ts.map +1 -1
- package/dist/button/icon-button.jsx +21 -17
- package/dist/button/nav-card.d.ts +1 -0
- package/dist/button/nav-card.d.ts.map +1 -1
- package/dist/button/nav-card.jsx +6 -7
- package/dist/button/safe-tap.jsx +0 -2
- package/dist/button/safe.jsx +3 -5
- package/dist/button/variant-css.d.ts +8 -0
- package/dist/button/variant-css.d.ts.map +1 -0
- package/dist/button/variant-css.jsx +47 -0
- package/dist/button/vertical-icon-text-button.d.ts.map +1 -1
- package/dist/button/vertical-icon-text-button.jsx +1 -3
- package/dist/button/visuals.d.ts +7 -1
- package/dist/button/visuals.d.ts.map +1 -1
- package/dist/button/visuals.jsx +5 -5
- package/dist/cascade/cascade-panel.jsx +0 -2
- package/dist/cascade/model.jsx +0 -2
- package/dist/commands/commands.css +167 -0
- package/dist/commands/commands.css.map +1 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.jsx +2 -0
- package/dist/commands/keys.d.ts +22 -0
- package/dist/commands/keys.d.ts.map +1 -0
- package/dist/commands/keys.jsx +119 -0
- package/dist/commands/palette.d.ts +62 -0
- package/dist/commands/palette.d.ts.map +1 -0
- package/dist/commands/palette.jsx +175 -0
- package/dist/deferred/deferred-content.jsx +2 -4
- package/dist/deferred/readiness-signal.jsx +0 -2
- package/dist/display/activity-indicator.jsx +0 -2
- package/dist/display/culture-date-time-label.jsx +1 -3
- package/dist/display/extras.css +117 -0
- package/dist/display/extras.css.map +1 -0
- package/dist/display/extras.d.ts +65 -0
- package/dist/display/extras.d.ts.map +1 -0
- package/dist/display/extras.jsx +118 -0
- package/dist/display/figures-index.d.ts +3 -0
- package/dist/display/figures-index.d.ts.map +1 -0
- package/dist/display/figures-index.jsx +2 -0
- package/dist/display/figures.css +249 -0
- package/dist/display/figures.css.map +1 -0
- package/dist/display/figures.d.ts +132 -0
- package/dist/display/figures.d.ts.map +1 -0
- package/dist/display/figures.jsx +223 -0
- package/dist/display/image.css +46 -0
- package/dist/display/image.css.map +1 -0
- package/dist/display/image.d.ts +32 -0
- package/dist/display/image.d.ts.map +1 -0
- package/dist/display/image.jsx +49 -0
- package/dist/display/index.d.ts +6 -0
- package/dist/display/index.d.ts.map +1 -1
- package/dist/display/index.jsx +6 -0
- package/dist/display/keycap.css +32 -0
- package/dist/display/keycap.css.map +1 -0
- package/dist/display/keycap.d.ts +20 -0
- package/dist/display/keycap.d.ts.map +1 -0
- package/dist/display/keycap.jsx +17 -0
- package/dist/display/motion-figures.css +168 -0
- package/dist/display/motion-figures.css.map +1 -0
- package/dist/display/motion-figures.d.ts +155 -0
- package/dist/display/motion-figures.d.ts.map +1 -0
- package/dist/display/motion-figures.jsx +246 -0
- package/dist/display/progress-bar.jsx +1 -3
- package/dist/display/separator.d.ts.map +1 -1
- package/dist/display/separator.jsx +2 -4
- package/dist/display/shimmer.jsx +0 -2
- package/dist/display/skeleton.css +72 -0
- package/dist/display/skeleton.css.map +1 -0
- package/dist/display/status.css +111 -0
- package/dist/display/status.css.map +1 -0
- package/dist/display/status.d.ts +67 -0
- package/dist/display/status.d.ts.map +1 -0
- package/dist/display/status.jsx +117 -0
- package/dist/display/theme-preview.css +244 -0
- package/dist/display/theme-preview.css.map +1 -0
- package/dist/display/theme-preview.d.ts +19 -0
- package/dist/display/theme-preview.d.ts.map +1 -0
- package/dist/display/theme-preview.jsx +89 -0
- package/dist/display/title-with-line.d.ts.map +1 -1
- package/dist/display/title-with-line.jsx +2 -4
- package/dist/edge-panel/edge-panel.jsx +0 -2
- package/dist/edge-panel/helper.jsx +0 -2
- package/dist/edge-panel/types.jsx +0 -2
- package/dist/effects/effects.css +94 -0
- package/dist/effects/effects.css.map +1 -0
- package/dist/effects/effects.d.ts +83 -0
- package/dist/effects/effects.d.ts.map +1 -0
- package/dist/effects/effects.jsx +183 -0
- package/dist/effects/index.d.ts +2 -0
- package/dist/effects/index.d.ts.map +1 -0
- package/dist/effects/index.jsx +1 -0
- package/dist/expander/expander.d.ts +1 -0
- package/dist/expander/expander.d.ts.map +1 -1
- package/dist/expander/expander.jsx +22 -23
- package/dist/fields/dictation.jsx +0 -2
- package/dist/fields/editor.jsx +2 -4
- package/dist/fields/extra-entries.css +133 -0
- package/dist/fields/extra-entries.css.map +1 -0
- package/dist/fields/extra-entries.d.ts +98 -0
- package/dist/fields/extra-entries.d.ts.map +1 -0
- package/dist/fields/extra-entries.jsx +323 -0
- package/dist/fields/fields.css +4 -0
- package/dist/fields/fields.css.map +1 -1
- package/dist/fields/index.d.ts +4 -3
- package/dist/fields/index.d.ts.map +1 -1
- package/dist/fields/index.jsx +1 -0
- package/dist/fields/input-policy.jsx +0 -2
- package/dist/fields/notch.jsx +0 -2
- package/dist/fields/outlined-field.d.ts +9 -0
- package/dist/fields/outlined-field.d.ts.map +1 -1
- package/dist/fields/outlined-field.jsx +10 -8
- package/dist/fields/pin-entry.d.ts.map +1 -1
- package/dist/fields/pin-entry.jsx +11 -13
- package/dist/fields/search-entry.jsx +2 -4
- package/dist/fields/slot-layout.jsx +0 -2
- package/dist/fields/text-entry.jsx +2 -4
- package/dist/fields/use-dictation.jsx +0 -2
- package/dist/fields/use-text-input.d.ts +1 -1
- package/dist/fields/use-text-input.jsx +0 -2
- package/dist/fields/validator.jsx +0 -2
- package/dist/guide/confirm-sheet.jsx +0 -2
- package/dist/guide/journey.jsx +0 -2
- package/dist/guide/placement.jsx +0 -2
- package/dist/guide/service.jsx +0 -2
- package/dist/guide/settings.jsx +0 -2
- package/dist/header/app-bar.d.ts +35 -0
- package/dist/header/app-bar.d.ts.map +1 -0
- package/dist/header/app-bar.jsx +64 -0
- package/dist/header/header.css +79 -0
- package/dist/header/header.css.map +1 -0
- package/dist/header/index.d.ts +2 -0
- package/dist/header/index.d.ts.map +1 -0
- package/dist/header/index.jsx +1 -0
- package/dist/host/back.jsx +0 -2
- package/dist/host/hooks.jsx +0 -2
- package/dist/host/host.css +1 -0
- package/dist/host/host.css.map +1 -1
- package/dist/host/host.d.ts.map +1 -1
- package/dist/host/host.jsx +50 -17
- package/dist/host/keyboard.jsx +0 -2
- package/dist/host/layers.jsx +0 -2
- package/dist/host/page-loading-overlay.jsx +0 -2
- package/dist/host/readiness.jsx +0 -2
- package/dist/host/registry.d.ts +9 -0
- package/dist/host/registry.d.ts.map +1 -1
- package/dist/host/registry.jsx +0 -2
- package/dist/icon/icon.d.ts +16 -0
- package/dist/icon/icon.d.ts.map +1 -1
- package/dist/icon/icon.jsx +53 -14
- package/dist/icon/index.d.ts +1 -1
- package/dist/icon/index.d.ts.map +1 -1
- package/dist/icon/index.jsx +1 -1
- package/dist/icon/slot.jsx +0 -2
- package/dist/icon/swatch.jsx +0 -2
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/layout/containers.d.ts +113 -0
- package/dist/layout/containers.d.ts.map +1 -0
- package/dist/layout/containers.jsx +195 -0
- package/dist/layout/index.d.ts +4 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/index.jsx +3 -0
- package/dist/layout/layout.css +361 -0
- package/dist/layout/layout.css.map +1 -0
- package/dist/layout/scroll-spy.d.ts +18 -0
- package/dist/layout/scroll-spy.d.ts.map +1 -0
- package/dist/layout/scroll-spy.jsx +38 -0
- package/dist/layout/scrollers.d.ts +96 -0
- package/dist/layout/scrollers.d.ts.map +1 -0
- package/dist/layout/scrollers.jsx +208 -0
- package/dist/list/gestures.d.ts +40 -0
- package/dist/list/gestures.d.ts.map +1 -0
- package/dist/list/gestures.jsx +142 -0
- package/dist/list/index.d.ts +4 -0
- package/dist/list/index.d.ts.map +1 -0
- package/dist/list/index.jsx +3 -0
- package/dist/list/list.css +194 -0
- package/dist/list/list.css.map +1 -0
- package/dist/list/rows.d.ts +69 -0
- package/dist/list/rows.d.ts.map +1 -0
- package/dist/list/rows.jsx +105 -0
- package/dist/list/virtual-list.d.ts +94 -0
- package/dist/list/virtual-list.d.ts.map +1 -0
- package/dist/list/virtual-list.jsx +159 -0
- package/dist/orb/hold-button.d.ts +26 -0
- package/dist/orb/hold-button.d.ts.map +1 -0
- package/dist/orb/hold-button.jsx +33 -0
- package/dist/orb/hold.d.ts +36 -0
- package/dist/orb/hold.d.ts.map +1 -0
- package/dist/orb/hold.jsx +76 -0
- package/dist/orb/index.d.ts +5 -0
- package/dist/orb/index.d.ts.map +1 -0
- package/dist/orb/index.jsx +4 -0
- package/dist/orb/model.d.ts +42 -0
- package/dist/orb/model.d.ts.map +1 -0
- package/dist/orb/model.jsx +42 -0
- package/dist/orb/orb.css +81 -0
- package/dist/orb/orb.css.map +1 -0
- package/dist/orb/orb.d.ts +61 -0
- package/dist/orb/orb.d.ts.map +1 -0
- package/dist/orb/orb.jsx +171 -0
- package/dist/pickers/combo-box.jsx +0 -2
- package/dist/pickers/date-time-picker.jsx +0 -2
- package/dist/pickers/date-time.jsx +0 -2
- package/dist/pickers/day-stepper.css +43 -0
- package/dist/pickers/day-stepper.css.map +1 -0
- package/dist/pickers/day-stepper.d.ts +31 -0
- package/dist/pickers/day-stepper.d.ts.map +1 -0
- package/dist/pickers/day-stepper.jsx +60 -0
- package/dist/pickers/index.d.ts +1 -0
- package/dist/pickers/index.d.ts.map +1 -1
- package/dist/pickers/index.jsx +1 -0
- package/dist/pickers/picker-sheet.jsx +0 -2
- package/dist/pickers/picker.d.ts +11 -0
- package/dist/pickers/picker.d.ts.map +1 -1
- package/dist/pickers/picker.jsx +53 -9
- package/dist/pickers/timespan-picker.jsx +0 -2
- package/dist/pickers/timespan.jsx +0 -2
- package/dist/pickers/trigger.jsx +0 -2
- package/dist/pickers/wheel-column.jsx +0 -2
- package/dist/plus-button/model.jsx +0 -2
- package/dist/plus-button/plus-button.jsx +0 -2
- package/dist/popover/index.d.ts +3 -0
- package/dist/popover/index.d.ts.map +1 -0
- package/dist/popover/index.jsx +2 -0
- package/dist/popover/popover.css +183 -0
- package/dist/popover/popover.css.map +1 -0
- package/dist/popover/popover.d.ts +139 -0
- package/dist/popover/popover.d.ts.map +1 -0
- package/dist/popover/popover.jsx +291 -0
- package/dist/popover/position.d.ts +35 -0
- package/dist/popover/position.d.ts.map +1 -0
- package/dist/popover/position.jsx +53 -0
- package/dist/popup/frame.jsx +0 -2
- package/dist/popup/input-form.jsx +0 -2
- package/dist/popup/input.jsx +0 -2
- package/dist/popup/popup-view.jsx +0 -2
- package/dist/popup/queue.jsx +0 -2
- package/dist/popup/service.jsx +0 -2
- package/dist/popup/types.jsx +0 -2
- package/dist/provider/activity.d.ts +13 -0
- package/dist/provider/activity.d.ts.map +1 -0
- package/dist/provider/activity.jsx +55 -0
- package/dist/provider/contexts.d.ts +32 -1
- package/dist/provider/contexts.d.ts.map +1 -1
- package/dist/provider/contexts.jsx +7 -3
- package/dist/provider/global-events.jsx +0 -2
- package/dist/provider/hooks.d.ts +16 -2
- package/dist/provider/hooks.d.ts.map +1 -1
- package/dist/provider/hooks.jsx +35 -7
- package/dist/provider/index.d.ts +4 -2
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.jsx +3 -1
- package/dist/provider/keep-alive.css +19 -0
- package/dist/provider/keep-alive.css.map +1 -0
- package/dist/provider/keep-alive.d.ts +23 -0
- package/dist/provider/keep-alive.d.ts.map +1 -0
- package/dist/provider/keep-alive.jsx +9 -0
- package/dist/provider/provider.css +1 -1
- package/dist/provider/provider.css.map +1 -1
- package/dist/provider/provider.d.ts +13 -1
- package/dist/provider/provider.d.ts.map +1 -1
- package/dist/provider/provider.jsx +128 -15
- package/dist/provider/settings.d.ts +23 -0
- package/dist/provider/settings.d.ts.map +1 -1
- package/dist/provider/settings.jsx +5 -4
- package/dist/provider/theme-css.d.ts +1 -1
- package/dist/provider/theme-css.d.ts.map +1 -1
- package/dist/provider/theme-css.jsx +21 -10
- package/dist/provider/theme-root.d.ts.map +1 -1
- package/dist/provider/theme-root.jsx +7 -5
- package/dist/provider/theme.css +72 -0
- package/dist/provider/theme.css.map +1 -1
- package/dist/range-slider/index.d.ts +1 -0
- package/dist/range-slider/index.d.ts.map +1 -1
- package/dist/range-slider/index.jsx +1 -0
- package/dist/range-slider/math.jsx +0 -2
- package/dist/range-slider/range-slider.css +82 -0
- package/dist/range-slider/range-slider.css.map +1 -1
- package/dist/range-slider/range-slider.jsx +0 -2
- package/dist/range-slider/step-slider.d.ts +18 -0
- package/dist/range-slider/step-slider.d.ts.map +1 -0
- package/dist/range-slider/step-slider.jsx +55 -0
- package/dist/route/hooks.jsx +0 -2
- package/dist/route/router.jsx +0 -2
- package/dist/selection/model.jsx +0 -2
- package/dist/selection/selection-sheet.jsx +0 -2
- package/dist/selection/use-selection-model.jsx +0 -2
- package/dist/selection/window.jsx +0 -2
- package/dist/sheet/backdrop-scope.d.ts +14 -0
- package/dist/sheet/backdrop-scope.d.ts.map +1 -0
- package/dist/sheet/backdrop-scope.jsx +25 -0
- package/dist/sheet/context.d.ts +22 -0
- package/dist/sheet/context.d.ts.map +1 -0
- package/dist/sheet/context.jsx +7 -0
- package/dist/sheet/frame.d.ts +2 -17
- package/dist/sheet/frame.d.ts.map +1 -1
- package/dist/sheet/frame.jsx +23 -19
- package/dist/sheet/gesture.jsx +1 -3
- package/dist/sheet/handoff.jsx +0 -2
- package/dist/sheet/header.jsx +3 -3
- package/dist/sheet/height-memo.jsx +0 -2
- package/dist/sheet/index.d.ts +2 -0
- package/dist/sheet/index.d.ts.map +1 -1
- package/dist/sheet/index.jsx +2 -0
- package/dist/sheet/loadable.jsx +0 -2
- package/dist/sheet/motion.jsx +0 -2
- package/dist/sheet/options.d.ts +17 -0
- package/dist/sheet/options.d.ts.map +1 -1
- package/dist/sheet/options.jsx +2 -3
- package/dist/sheet/panel-frame.css +204 -0
- package/dist/sheet/panel-frame.css.map +1 -0
- package/dist/sheet/panel-frame.d.ts +16 -0
- package/dist/sheet/panel-frame.d.ts.map +1 -0
- package/dist/sheet/panel-frame.jsx +103 -0
- package/dist/sheet/processing.jsx +0 -2
- package/dist/sheet/scroll-indicator.jsx +0 -2
- package/dist/sheet/scroll-region.d.ts +19 -0
- package/dist/sheet/scroll-region.d.ts.map +1 -0
- package/dist/sheet/scroll-region.jsx +58 -0
- package/dist/sheet/service.d.ts.map +1 -1
- package/dist/sheet/service.jsx +23 -9
- package/dist/sheet/sheet.css +33 -0
- package/dist/sheet/sheet.css.map +1 -1
- package/dist/sheet/sheet.jsx +0 -2
- package/dist/sheet/sizing.d.ts +3 -3
- package/dist/sheet/sizing.jsx +0 -2
- package/dist/sheet/stack.jsx +0 -2
- package/dist/shell/index.d.ts +2 -0
- package/dist/shell/index.d.ts.map +1 -0
- package/dist/shell/index.jsx +1 -0
- package/dist/shell/shell.css +342 -0
- package/dist/shell/shell.css.map +1 -0
- package/dist/shell/shell.d.ts +121 -0
- package/dist/shell/shell.d.ts.map +1 -0
- package/dist/shell/shell.jsx +214 -0
- package/dist/survey/index.d.ts +2 -0
- package/dist/survey/index.d.ts.map +1 -0
- package/dist/survey/index.jsx +1 -0
- package/dist/survey/survey.css +204 -0
- package/dist/survey/survey.css.map +1 -0
- package/dist/survey/survey.d.ts +76 -0
- package/dist/survey/survey.d.ts.map +1 -0
- package/dist/survey/survey.jsx +205 -0
- package/dist/swipe/model.jsx +0 -2
- package/dist/swipe/swipe-view.jsx +0 -2
- package/dist/tab-bar/metrics.jsx +20 -22
- package/dist/tab-bar/model.d.ts +2 -0
- package/dist/tab-bar/model.d.ts.map +1 -1
- package/dist/tab-bar/model.jsx +10 -6
- package/dist/tab-bar/tab-bar.css +74 -0
- package/dist/tab-bar/tab-bar.css.map +1 -1
- package/dist/tab-bar/tab-bar.d.ts +7 -0
- package/dist/tab-bar/tab-bar.d.ts.map +1 -1
- package/dist/tab-bar/tab-bar.jsx +51 -17
- package/dist/tabs/model.jsx +0 -2
- package/dist/tabs/tab-view.d.ts +1 -0
- package/dist/tabs/tab-view.d.ts.map +1 -1
- package/dist/tabs/tab-view.jsx +6 -5
- package/dist/tabs/tabs.css +1 -0
- package/dist/tabs/tabs.css.map +1 -1
- package/dist/toast/service.d.ts.map +1 -1
- package/dist/toast/service.jsx +34 -16
- package/dist/toast/store.jsx +0 -2
- package/dist/toggle/checkbox-math.jsx +0 -2
- package/dist/toggle/checkbox.d.ts.map +1 -1
- package/dist/toggle/checkbox.jsx +10 -12
- package/dist/toggle/chip-group.d.ts.map +1 -1
- package/dist/toggle/chip-group.jsx +8 -7
- package/dist/toggle/choice.css +254 -0
- package/dist/toggle/choice.css.map +1 -0
- package/dist/toggle/choice.d.ts +125 -0
- package/dist/toggle/choice.d.ts.map +1 -0
- package/dist/toggle/choice.jsx +367 -0
- package/dist/toggle/index.d.ts +2 -1
- package/dist/toggle/index.d.ts.map +1 -1
- package/dist/toggle/index.jsx +1 -0
- package/dist/toggle/switch.d.ts.map +1 -1
- package/dist/toggle/switch.jsx +8 -11
- package/package.json +126 -16
- package/tailwind/index.d.ts +13 -0
- package/tailwind/index.mjs +87 -0
- package/tailwind/index.test.mjs +24 -0
- package/tailwind/tokens.mjs +98 -0
- package/dist/anchor/context.jsx.map +0 -1
- package/dist/anchor/hooks.jsx.map +0 -1
- package/dist/anchor/measure.jsx.map +0 -1
- package/dist/anchor/registry.jsx.map +0 -1
- package/dist/anchor/scroll.jsx.map +0 -1
- package/dist/base/control.jsx.map +0 -1
- package/dist/base/corner-badge.jsx.map +0 -1
- package/dist/base/disposer.jsx.map +0 -1
- package/dist/base/press.jsx.map +0 -1
- package/dist/base/pressable.jsx.map +0 -1
- package/dist/base/selection-item.jsx.map +0 -1
- package/dist/base/timers.jsx.map +0 -1
- package/dist/base/use-controllable-state.jsx.map +0 -1
- package/dist/base/use-stable-callback.jsx.map +0 -1
- package/dist/button/button.jsx.map +0 -1
- package/dist/button/header-action-button.jsx.map +0 -1
- package/dist/button/icon-button.jsx.map +0 -1
- package/dist/button/nav-card.jsx.map +0 -1
- package/dist/button/safe-tap.jsx.map +0 -1
- package/dist/button/safe.jsx.map +0 -1
- package/dist/button/vertical-icon-text-button.jsx.map +0 -1
- package/dist/button/visuals.jsx.map +0 -1
- package/dist/cascade/cascade-panel.jsx.map +0 -1
- package/dist/cascade/model.jsx.map +0 -1
- package/dist/deferred/deferred-content.jsx.map +0 -1
- package/dist/deferred/readiness-signal.jsx.map +0 -1
- package/dist/display/activity-indicator.jsx.map +0 -1
- package/dist/display/culture-date-time-label.jsx.map +0 -1
- package/dist/display/progress-bar.jsx.map +0 -1
- package/dist/display/separator.jsx.map +0 -1
- package/dist/display/shimmer.jsx.map +0 -1
- package/dist/display/title-with-line.jsx.map +0 -1
- package/dist/edge-panel/edge-panel.jsx.map +0 -1
- package/dist/edge-panel/helper.jsx.map +0 -1
- package/dist/edge-panel/types.jsx.map +0 -1
- package/dist/expander/expander.jsx.map +0 -1
- package/dist/fields/dictation.jsx.map +0 -1
- package/dist/fields/editor.jsx.map +0 -1
- package/dist/fields/input-policy.jsx.map +0 -1
- package/dist/fields/notch.jsx.map +0 -1
- package/dist/fields/outlined-field.jsx.map +0 -1
- package/dist/fields/pin-entry.jsx.map +0 -1
- package/dist/fields/search-entry.jsx.map +0 -1
- package/dist/fields/slot-layout.jsx.map +0 -1
- package/dist/fields/text-entry.jsx.map +0 -1
- package/dist/fields/use-dictation.jsx.map +0 -1
- package/dist/fields/use-text-input.jsx.map +0 -1
- package/dist/fields/validator.jsx.map +0 -1
- package/dist/guide/confirm-sheet.jsx.map +0 -1
- package/dist/guide/journey.jsx.map +0 -1
- package/dist/guide/placement.jsx.map +0 -1
- package/dist/guide/service.jsx.map +0 -1
- package/dist/guide/settings.jsx.map +0 -1
- package/dist/host/back.jsx.map +0 -1
- package/dist/host/hooks.jsx.map +0 -1
- package/dist/host/host.jsx.map +0 -1
- package/dist/host/keyboard.jsx.map +0 -1
- package/dist/host/layers.jsx.map +0 -1
- package/dist/host/page-loading-overlay.jsx.map +0 -1
- package/dist/host/readiness.jsx.map +0 -1
- package/dist/host/registry.jsx.map +0 -1
- package/dist/icon/icon.jsx.map +0 -1
- package/dist/icon/slot.jsx.map +0 -1
- package/dist/icon/swatch.jsx.map +0 -1
- package/dist/pickers/combo-box.jsx.map +0 -1
- package/dist/pickers/date-time-picker.jsx.map +0 -1
- package/dist/pickers/date-time.jsx.map +0 -1
- package/dist/pickers/picker-sheet.jsx.map +0 -1
- package/dist/pickers/picker.jsx.map +0 -1
- package/dist/pickers/timespan-picker.jsx.map +0 -1
- package/dist/pickers/timespan.jsx.map +0 -1
- package/dist/pickers/trigger.jsx.map +0 -1
- package/dist/pickers/wheel-column.jsx.map +0 -1
- package/dist/plus-button/model.jsx.map +0 -1
- package/dist/plus-button/plus-button.jsx.map +0 -1
- package/dist/popup/frame.jsx.map +0 -1
- package/dist/popup/input-form.jsx.map +0 -1
- package/dist/popup/input.jsx.map +0 -1
- package/dist/popup/popup-view.jsx.map +0 -1
- package/dist/popup/queue.jsx.map +0 -1
- package/dist/popup/service.jsx.map +0 -1
- package/dist/popup/types.jsx.map +0 -1
- package/dist/provider/contexts.jsx.map +0 -1
- package/dist/provider/global-events.jsx.map +0 -1
- package/dist/provider/hooks.jsx.map +0 -1
- package/dist/provider/provider.jsx.map +0 -1
- package/dist/provider/settings.jsx.map +0 -1
- package/dist/provider/theme-css.jsx.map +0 -1
- package/dist/provider/theme-root.jsx.map +0 -1
- package/dist/range-slider/math.jsx.map +0 -1
- package/dist/range-slider/range-slider.jsx.map +0 -1
- package/dist/route/hooks.jsx.map +0 -1
- package/dist/route/router.jsx.map +0 -1
- package/dist/selection/model.jsx.map +0 -1
- package/dist/selection/selection-sheet.jsx.map +0 -1
- package/dist/selection/use-selection-model.jsx.map +0 -1
- package/dist/selection/window.jsx.map +0 -1
- package/dist/sheet/frame.jsx.map +0 -1
- package/dist/sheet/gesture.jsx.map +0 -1
- package/dist/sheet/handoff.jsx.map +0 -1
- package/dist/sheet/header.jsx.map +0 -1
- package/dist/sheet/height-memo.jsx.map +0 -1
- package/dist/sheet/loadable.jsx.map +0 -1
- package/dist/sheet/motion.jsx.map +0 -1
- package/dist/sheet/options.jsx.map +0 -1
- package/dist/sheet/processing.jsx.map +0 -1
- package/dist/sheet/scroll-indicator.jsx.map +0 -1
- package/dist/sheet/service.jsx.map +0 -1
- package/dist/sheet/sheet.jsx.map +0 -1
- package/dist/sheet/sizing.jsx.map +0 -1
- package/dist/sheet/stack.jsx.map +0 -1
- package/dist/swipe/model.jsx.map +0 -1
- package/dist/swipe/swipe-view.jsx.map +0 -1
- package/dist/tab-bar/metrics.jsx.map +0 -1
- package/dist/tab-bar/model.jsx.map +0 -1
- package/dist/tab-bar/tab-bar.jsx.map +0 -1
- package/dist/tabs/model.jsx.map +0 -1
- package/dist/tabs/tab-view.jsx.map +0 -1
- package/dist/toast/service.jsx.map +0 -1
- package/dist/toast/store.jsx.map +0 -1
- package/dist/toggle/checkbox-math.jsx.map +0 -1
- package/dist/toggle/checkbox.jsx.map +0 -1
- package/dist/toggle/chip-group.jsx.map +0 -1
- package/dist/toggle/switch.jsx.map +0 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// @g9tm/lynxcontrols/tailwind: a Tailwind preset that speaks the G9 theme. Every colour utility (`bg-surface`,
|
|
2
|
+
// `text-text-secondary`, `border-outline-variant`), radius (`rounded-card`), control height (`h-control-md`) and type
|
|
3
|
+
// role (`text-body`) resolves to the library's CSS variables, which the G9Provider writes on its root — so utility
|
|
4
|
+
// markup (G9Hub: ~14 000 classes) follows the library theme, recipe and live design changes with no React render.
|
|
5
|
+
// Use it on top of `@lynx-js/tailwind-preset`:
|
|
6
|
+
//
|
|
7
|
+
// import lynxPreset from '@lynx-js/tailwind-preset';
|
|
8
|
+
// import { g9TailwindPreset } from '@g9tm/lynxcontrols/tailwind';
|
|
9
|
+
// export default { presets: [lynxPreset, g9TailwindPreset({ aliases: 'hub' })], content: ['./src/**/*.{ts,tsx}'] };
|
|
10
|
+
//
|
|
11
|
+
// Plain Node ESM (it runs in the build, never in the Lynx bundle).
|
|
12
|
+
import { g9TokenColors } from './tokens.mjs';
|
|
13
|
+
|
|
14
|
+
export { g9TokenColors };
|
|
15
|
+
|
|
16
|
+
/** G9Hub's existing colour names → library tokens (the `--g9-*` alias layer, `g9AliasPresets.hub`). */
|
|
17
|
+
export const g9HubColorAliases = Object.freeze({
|
|
18
|
+
bg: 'var(--g9-background)',
|
|
19
|
+
'bg-elev': 'var(--g9-surface-container-low)',
|
|
20
|
+
surface: 'var(--g9-surface)',
|
|
21
|
+
'surface-2': 'var(--g9-surface-container)',
|
|
22
|
+
'surface-3': 'var(--g9-surface-container-high)',
|
|
23
|
+
glass: 'var(--g9-overlay-light)',
|
|
24
|
+
'glass-border': 'var(--g9-outline-variant)',
|
|
25
|
+
border: 'var(--g9-outline-variant)',
|
|
26
|
+
'border-strong': 'var(--g9-outline)',
|
|
27
|
+
text: 'var(--g9-text-primary)',
|
|
28
|
+
'text-2': 'var(--g9-text-secondary)',
|
|
29
|
+
'text-3': 'var(--g9-text-tertiary)',
|
|
30
|
+
accent: 'var(--g9-primary)',
|
|
31
|
+
'accent-contrast': 'var(--g9-on-primary)',
|
|
32
|
+
danger: 'var(--g9-error)',
|
|
33
|
+
success: 'var(--g9-success)',
|
|
34
|
+
warning: 'var(--g9-warning)',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const RADII = ['control', 'field', 'chip', 'card', 'sheet', 'dialog', 'toast', 'pill'];
|
|
38
|
+
const ROLES = ['display', 'title', 'section', 'body', 'label', 'caption', 'price', 'mono'];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The preset. `aliases: 'hub'` adds G9Hub's names (`bg-surface-2`, `text-text-2`…) beside the library's own; give an
|
|
42
|
+
* object for any app's names. `px: true` (default) keeps Tailwind's spacing in px (Lynx has no rem on native).
|
|
43
|
+
*/
|
|
44
|
+
export function g9TailwindPreset(options = {}) {
|
|
45
|
+
const aliases = options.aliases === 'hub' ? g9HubColorAliases : (options.aliases ?? {});
|
|
46
|
+
const colors = {
|
|
47
|
+
transparent: 'transparent',
|
|
48
|
+
current: 'currentColor',
|
|
49
|
+
white: '#FFFFFF',
|
|
50
|
+
black: '#000000',
|
|
51
|
+
...g9TokenColors,
|
|
52
|
+
...aliases,
|
|
53
|
+
};
|
|
54
|
+
const borderRadius = {
|
|
55
|
+
none: '0px',
|
|
56
|
+
sm: '6px',
|
|
57
|
+
DEFAULT: 'var(--g9-radius-control)',
|
|
58
|
+
md: 'var(--g9-radius-control)',
|
|
59
|
+
lg: 'var(--g9-radius-card)',
|
|
60
|
+
xl: 'var(--g9-radius-sheet)',
|
|
61
|
+
full: '9999px',
|
|
62
|
+
};
|
|
63
|
+
for (const r of RADII) borderRadius[r] = `var(--g9-radius-${r})`;
|
|
64
|
+
const fontSize = {};
|
|
65
|
+
for (const role of ROLES)
|
|
66
|
+
fontSize[role] = [`var(--g9-type-${role}-size)`, { lineHeight: `var(--g9-type-${role}-line)` }];
|
|
67
|
+
return {
|
|
68
|
+
theme: {
|
|
69
|
+
extend: {
|
|
70
|
+
colors,
|
|
71
|
+
borderColor: { DEFAULT: 'var(--g9-outline-variant)' },
|
|
72
|
+
borderRadius,
|
|
73
|
+
fontSize,
|
|
74
|
+
height: {
|
|
75
|
+
'control-sm': 'var(--g9-height-sm)',
|
|
76
|
+
'control-md': 'var(--g9-height-md)',
|
|
77
|
+
'control-lg': 'var(--g9-height-lg)',
|
|
78
|
+
touch: 'var(--g9-touch-target)',
|
|
79
|
+
},
|
|
80
|
+
minHeight: { touch: 'var(--g9-touch-target)' },
|
|
81
|
+
minWidth: { touch: 'var(--g9-touch-target)' },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default g9TailwindPreset;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { test } from 'node:test';
|
|
3
|
+
import { g9TailwindPreset, g9TokenColors } from './index.mjs';
|
|
4
|
+
|
|
5
|
+
test('every library colour is a utility name on its variable', () => {
|
|
6
|
+
const c = g9TailwindPreset().theme.extend.colors;
|
|
7
|
+
assert.equal(c['surface-container-high'], 'var(--g9-surface-container-high)');
|
|
8
|
+
assert.equal(c['on-primary'], 'var(--g9-on-primary)');
|
|
9
|
+
assert.ok(Object.keys(g9TokenColors).length > 80);
|
|
10
|
+
assert.equal(c['surface-2'], undefined);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test("G9Hub's names come with aliases: 'hub'", () => {
|
|
14
|
+
const c = g9TailwindPreset({ aliases: 'hub' }).theme.extend.colors;
|
|
15
|
+
assert.equal(c['surface-2'], 'var(--g9-surface-container)');
|
|
16
|
+
assert.equal(c['text-2'], 'var(--g9-text-secondary)');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('radii, type roles and heights follow the shape variables', () => {
|
|
20
|
+
const e = g9TailwindPreset().theme.extend;
|
|
21
|
+
assert.equal(e.borderRadius.card, 'var(--g9-radius-card)');
|
|
22
|
+
assert.deepEqual(e.fontSize.body, ['var(--g9-type-body-size)', { lineHeight: 'var(--g9-type-body-line)' }]);
|
|
23
|
+
assert.equal(e.height['control-md'], 'var(--g9-height-md)');
|
|
24
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Generated from g9ColorTokens: every library colour as a Tailwind name (kebab case) → its CSS variable.
|
|
2
|
+
export const g9TokenColors = Object.freeze({
|
|
3
|
+
primary: 'var(--g9-primary)',
|
|
4
|
+
'on-primary': 'var(--g9-on-primary)',
|
|
5
|
+
'primary-container': 'var(--g9-primary-container)',
|
|
6
|
+
'on-primary-container': 'var(--g9-on-primary-container)',
|
|
7
|
+
'primary-border': 'var(--g9-primary-border)',
|
|
8
|
+
'primary-hover': 'var(--g9-primary-hover)',
|
|
9
|
+
'primary-pressed': 'var(--g9-primary-pressed)',
|
|
10
|
+
secondary: 'var(--g9-secondary)',
|
|
11
|
+
'on-secondary': 'var(--g9-on-secondary)',
|
|
12
|
+
'secondary-container': 'var(--g9-secondary-container)',
|
|
13
|
+
'on-secondary-container': 'var(--g9-on-secondary-container)',
|
|
14
|
+
'secondary-border': 'var(--g9-secondary-border)',
|
|
15
|
+
tertiary: 'var(--g9-tertiary)',
|
|
16
|
+
'on-tertiary': 'var(--g9-on-tertiary)',
|
|
17
|
+
'tertiary-container': 'var(--g9-tertiary-container)',
|
|
18
|
+
'on-tertiary-container': 'var(--g9-on-tertiary-container)',
|
|
19
|
+
'tertiary-border': 'var(--g9-tertiary-border)',
|
|
20
|
+
quaternary: 'var(--g9-quaternary)',
|
|
21
|
+
'on-quaternary': 'var(--g9-on-quaternary)',
|
|
22
|
+
'quaternary-container': 'var(--g9-quaternary-container)',
|
|
23
|
+
'on-quaternary-container': 'var(--g9-on-quaternary-container)',
|
|
24
|
+
'quaternary-border': 'var(--g9-quaternary-border)',
|
|
25
|
+
error: 'var(--g9-error)',
|
|
26
|
+
'on-error': 'var(--g9-on-error)',
|
|
27
|
+
'error-container': 'var(--g9-error-container)',
|
|
28
|
+
'on-error-container': 'var(--g9-on-error-container)',
|
|
29
|
+
'error-border': 'var(--g9-error-border)',
|
|
30
|
+
warning: 'var(--g9-warning)',
|
|
31
|
+
'on-warning': 'var(--g9-on-warning)',
|
|
32
|
+
'warning-container': 'var(--g9-warning-container)',
|
|
33
|
+
'on-warning-container': 'var(--g9-on-warning-container)',
|
|
34
|
+
'warning-border': 'var(--g9-warning-border)',
|
|
35
|
+
success: 'var(--g9-success)',
|
|
36
|
+
'on-success': 'var(--g9-on-success)',
|
|
37
|
+
'success-container': 'var(--g9-success-container)',
|
|
38
|
+
'on-success-container': 'var(--g9-on-success-container)',
|
|
39
|
+
'success-border': 'var(--g9-success-border)',
|
|
40
|
+
info: 'var(--g9-info)',
|
|
41
|
+
'on-info': 'var(--g9-on-info)',
|
|
42
|
+
'info-container': 'var(--g9-info-container)',
|
|
43
|
+
'on-info-container': 'var(--g9-on-info-container)',
|
|
44
|
+
'info-border': 'var(--g9-info-border)',
|
|
45
|
+
outline: 'var(--g9-outline)',
|
|
46
|
+
'outline-variant': 'var(--g9-outline-variant)',
|
|
47
|
+
'outline-border': 'var(--g9-outline-border)',
|
|
48
|
+
background: 'var(--g9-background)',
|
|
49
|
+
'on-background': 'var(--g9-on-background)',
|
|
50
|
+
'background-secondary': 'var(--g9-background-secondary)',
|
|
51
|
+
surface: 'var(--g9-surface)',
|
|
52
|
+
'on-surface': 'var(--g9-on-surface)',
|
|
53
|
+
'surface-variant': 'var(--g9-surface-variant)',
|
|
54
|
+
'on-surface-variant': 'var(--g9-on-surface-variant)',
|
|
55
|
+
'surface-border': 'var(--g9-surface-border)',
|
|
56
|
+
'inverse-surface': 'var(--g9-inverse-surface)',
|
|
57
|
+
'inverse-on-surface': 'var(--g9-inverse-on-surface)',
|
|
58
|
+
'inverse-primary': 'var(--g9-inverse-primary)',
|
|
59
|
+
'surface-container-highest': 'var(--g9-surface-container-highest)',
|
|
60
|
+
'surface-container-high': 'var(--g9-surface-container-high)',
|
|
61
|
+
'surface-container': 'var(--g9-surface-container)',
|
|
62
|
+
'surface-container-low': 'var(--g9-surface-container-low)',
|
|
63
|
+
'surface-container-lowest': 'var(--g9-surface-container-lowest)',
|
|
64
|
+
'surface-bright': 'var(--g9-surface-bright)',
|
|
65
|
+
'surface-dim': 'var(--g9-surface-dim)',
|
|
66
|
+
scrim: 'var(--g9-scrim)',
|
|
67
|
+
'scrim-light': 'var(--g9-scrim-light)',
|
|
68
|
+
overlay: 'var(--g9-overlay)',
|
|
69
|
+
'overlay-light': 'var(--g9-overlay-light)',
|
|
70
|
+
'text-primary': 'var(--g9-text-primary)',
|
|
71
|
+
'text-secondary': 'var(--g9-text-secondary)',
|
|
72
|
+
'text-tertiary': 'var(--g9-text-tertiary)',
|
|
73
|
+
'text-disabled': 'var(--g9-text-disabled)',
|
|
74
|
+
white: 'var(--g9-white)',
|
|
75
|
+
black: 'var(--g9-black)',
|
|
76
|
+
light: 'var(--g9-light)',
|
|
77
|
+
dark: 'var(--g9-dark)',
|
|
78
|
+
divider: 'var(--g9-divider)',
|
|
79
|
+
'divider-strong': 'var(--g9-divider-strong)',
|
|
80
|
+
focus: 'var(--g9-focus)',
|
|
81
|
+
'focus-visible': 'var(--g9-focus-visible)',
|
|
82
|
+
disabled: 'var(--g9-disabled)',
|
|
83
|
+
'disabled-container': 'var(--g9-disabled-container)',
|
|
84
|
+
'card-background': 'var(--g9-card-background)',
|
|
85
|
+
'card-border': 'var(--g9-card-border)',
|
|
86
|
+
'card-elevated': 'var(--g9-card-elevated)',
|
|
87
|
+
default: 'var(--g9-default)',
|
|
88
|
+
'on-default': 'var(--g9-on-default)',
|
|
89
|
+
'default-container': 'var(--g9-default-container)',
|
|
90
|
+
'on-default-container': 'var(--g9-on-default-container)',
|
|
91
|
+
'default-border': 'var(--g9-default-border)',
|
|
92
|
+
'default-hover': 'var(--g9-default-hover)',
|
|
93
|
+
'default-pressed': 'var(--g9-default-pressed)',
|
|
94
|
+
'input-background': 'var(--g9-input-background)',
|
|
95
|
+
'input-border': 'var(--g9-input-border)',
|
|
96
|
+
'input-border-focused': 'var(--g9-input-border-focused)',
|
|
97
|
+
'input-placeholder': 'var(--g9-input-placeholder)',
|
|
98
|
+
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anchor/context.jsx","sources":["../../src/anchor/context.ts"],"sourcesContent":["import { createContext } from '@lynx-js/react';\nimport type { G9AnchorRegistry } from './registry';\n\n/** The provider's anchor registry (`G9Provider` supplies it). */\nexport const G9AnchorRegistryContext = createContext<G9AnchorRegistry | null>(null);\n\n/** The scroller the anchors below sit in. */\nexport const G9ScrollerContext = createContext<string | null>(null);\n\n/** Which overlay layer the anchors below render in (a sheet supplies `sheet` and its handle id). */\nexport interface G9AnchorLayerValue {\n readonly layer: 'page' | 'sheet' | 'popup' | 'floating';\n readonly sheetId?: number;\n}\n\n/** The default layer: the page itself. */\nexport const g9PageAnchorLayer: G9AnchorLayerValue = Object.freeze({ layer: 'page' });\n\n/** The overlay layer the anchors below render in (a sheet provides `sheet` with its handle id). */\nexport const G9AnchorLayerContext = createContext<G9AnchorLayerValue>(g9PageAnchorLayer);\n"],"names":["G9AnchorRegistryContext","createContext","G9ScrollerContext","g9PageAnchorLayer","Object","G9AnchorLayerContext"],"mappings":";AAIO,MAAMA,0BAA0BC,cAAuC;AAGvE,MAAMC,oBAAoBD,cAA6B;AASvD,MAAME,oBAAwCC,OAAO,MAAM,CAAC;IAAE,OAAO;AAAO;AAG5E,MAAMC,uBAAuBJ,cAAkCE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anchor/hooks.jsx","sources":["../../src/anchor/hooks.tsx"],"sourcesContent":["import { type ReactNode, useContext, useEffect, useRef, useState } from '@lynx-js/react';\nimport type { NodesRef } from '@lynx-js/types';\nimport { G9AnchorLayerContext, G9AnchorRegistryContext, G9ScrollerContext } from './context';\nimport type { G9AnchorInfo, G9AnchorKind, G9AnchorRegistry, G9ScrollerSpec } from './registry';\n\n/** A callback ref of a Lynx element. */\nexport type G9AnchorRef = (node: NodesRef | null) => void;\n\n/** An element id a selector can address: every character outside [A-Za-z0-9_-] becomes `_` (a selector reads `.` as a class). */\nexport function g9AnchorDomId(id: string): string {\n return id.replace(/[^A-Za-z0-9_-]/g, '_');\n}\n\n/** The provider's anchor registry, or null outside a provider. */\nexport function useG9AnchorRegistry(): G9AnchorRegistry | null {\n return useContext(G9AnchorRegistryContext);\n}\n\n/** What {@link useG9Anchor} returns. */\nexport interface G9AnchorHandle {\n /** Spread onto the element: its `id` (selector-safe) and the `ref` that binds it. */\n readonly props: { readonly id?: string; readonly ref: G9AnchorRef };\n readonly ref: G9AnchorRef;\n}\n\n/**\n * Registers the element as an anchor while mounted (no id = nothing is registered). `info` may change every render:\n * the registry reads the latest. Pass the element's own `ref` in `options.ref` when it has one; both are called.\n */\nexport function useG9Anchor(\n id: string | null | undefined,\n info: G9AnchorInfo,\n options: { readonly ref?: G9AnchorRef; readonly domId?: string } = {},\n): G9AnchorHandle {\n const registry = useContext(G9AnchorRegistryContext);\n const scrollerId = useContext(G9ScrollerContext);\n const layer = useContext(G9AnchorLayerContext);\n const latest = useRef(info);\n latest.current = info;\n const node = useRef<NodesRef | null>(null);\n const external = useRef(options.ref);\n external.current = options.ref;\n const [ref] = useState(() => {\n const bind: G9AnchorRef = (n) => {\n node.current = n;\n external.current?.(n);\n };\n return bind;\n });\n useEffect(() => {\n if (!registry || !id) return undefined;\n return registry.register(id, () => latest.current, {\n node: () => node.current,\n scrollerId,\n layer: layer.layer,\n ...(layer.sheetId !== undefined ? { sheetId: layer.sheetId } : {}),\n });\n }, [registry, id, scrollerId, layer]);\n return { props: id ? { id: options.domId ?? g9AnchorDomId(id), ref } : { ref }, ref };\n}\n\n/** Props of {@link G9Anchor}. */\nexport interface G9AnchorProps extends Omit<G9AnchorInfo, 'kind'> {\n readonly id: string;\n readonly kind?: G9AnchorKind;\n readonly children?: ReactNode;\n readonly className?: string;\n readonly style?: Record<string, string | number>;\n}\n\n/**\n * Makes any part of a page an anchor: a layout-neutral wrapper (a flex column unless a class is given) that carries\n * the id. Prefer {@link useG9Anchor} on the element itself when there is one.\n */\nexport function G9Anchor(props: G9AnchorProps): ReactNode {\n const { id, kind = 'view', children, className, style, ...rest } = props;\n const anchor = useG9Anchor(id, { kind, ...rest });\n const layout = className ? style : { display: 'flex', flexDirection: 'column', ...style };\n return (\n <view {...anchor.props} {...(className ? { className } : {})} {...(layout ? { style: layout } : {})}>\n {children}\n </view>\n );\n}\n\n/** Options of {@link useG9Scroller}. */\nexport interface G9ScrollerOptions {\n readonly id: string;\n readonly kind: 'list' | 'scroll-view';\n readonly orientation?: 'vertical' | 'horizontal';\n /** A list: its item keys in order (the same strings as `item-key`). */\n readonly itemKeys?: () => readonly string[];\n /** A list: the anchor id of the row with a key. */\n readonly itemAnchor?: (key: string) => string;\n /** A list: the key of a row anchor id, or null. Default: the inverse of a prefix `itemAnchor` (`Prefix.<key>`). */\n readonly anchorKey?: (anchorId: string) => string | null;\n}\n\n/** What {@link useG9Scroller} returns. */\nexport interface G9ScrollerHandle {\n readonly id: string;\n /** Spread onto the `<list>` / `<scroll-view>`. */\n readonly props: { readonly id: string; readonly ref: G9AnchorRef };\n}\n\nfunction prefixInverse(itemAnchor: (key: string) => string): (anchorId: string) => string | null {\n const probe = itemAnchor('\\u0001');\n const at = probe.indexOf('\\u0001');\n if (at < 0) return () => null;\n const prefix = probe.slice(0, at);\n const suffix = probe.slice(at + 1);\n return (anchorId) => {\n if (anchorId.length <= prefix.length + suffix.length || anchorId.slice(0, prefix.length) !== prefix) return null;\n if (suffix && anchorId.slice(-suffix.length) !== suffix) return null;\n return anchorId.slice(prefix.length, anchorId.length - suffix.length);\n };\n}\n\n/**\n * Registers a scroll container, so a scroll position can be named by the control in view (never pixels) and a control\n * inside it can be brought into view — also a list row that is not mounted yet, by its item key. Anchors below\n * {@link G9ScrollerScope} (or a list's rows named by `itemAnchor`) count as inside it.\n */\nexport function useG9Scroller(options: G9ScrollerOptions): G9ScrollerHandle {\n const registry = useContext(G9AnchorRegistryContext);\n const parentId = useContext(G9ScrollerContext);\n const latest = useRef(options);\n latest.current = options;\n const node = useRef<NodesRef | null>(null);\n const [ref] = useState(() => {\n const bind: G9AnchorRef = (n) => {\n node.current = n;\n };\n return bind;\n });\n const { id, kind } = options;\n const orientation = options.orientation ?? 'vertical';\n const hasItems = !!options.itemKeys;\n const hasAnchor = !!options.itemAnchor;\n useEffect(() => {\n if (!registry) return undefined;\n const spec: G9ScrollerSpec = {\n id,\n kind,\n orientation,\n parentId: parentId === id ? null : parentId,\n node: () => node.current,\n ...(hasItems ? { itemKeys: () => latest.current.itemKeys?.() ?? [] } : {}),\n ...(hasAnchor\n ? {\n itemAnchor: (key: string) => (latest.current.itemAnchor as (k: string) => string)(key),\n anchorKey: (anchorId: string) =>\n (latest.current.anchorKey ?? prefixInverse(latest.current.itemAnchor as (k: string) => string))(anchorId),\n }\n : {}),\n };\n return registry.registerScroller(spec);\n }, [registry, id, kind, orientation, parentId, hasItems, hasAnchor]);\n return { id, props: { id: g9AnchorDomId(id), ref } };\n}\n\n/** The anchors below sit in scroller `id` (renders no element). */\nexport function G9ScrollerScope(props: { readonly id: string; readonly children?: ReactNode }): ReactNode {\n return <G9ScrollerContext.Provider value={props.id}>{props.children}</G9ScrollerContext.Provider>;\n}\n"],"names":["g9AnchorDomId","id","useG9AnchorRegistry","useContext","G9AnchorRegistryContext","useG9Anchor","info","options","_options_domId","registry","scrollerId","G9ScrollerContext","layer","G9AnchorLayerContext","latest","useRef","node","external","ref","useState","bind","n","useEffect","undefined","G9Anchor","props","kind","children","className","style","rest","anchor","layout","view","prefixInverse","itemAnchor","probe","at","prefix","suffix","anchorId","useG9Scroller","_options_orientation","parentId","orientation","hasItems","hasAnchor","spec","_latest_current","key","_latest_current_anchorKey","G9ScrollerScope"],"mappings":";;AASO,SAASA,cAAcC,EAAU;IACtC,OAAOA,GAAG,OAAO,CAAC,mBAAmB;AACvC;AAGO,SAASC;IACd,OAAOC,WAAWC;AACpB;AAaO,SAASC,YACdJ,EAA6B,EAC7BK,IAAkB,EAClBC,UAAmE,CAAC,CAAC;QA0B1CC;IAxB3B,MAAMC,WAAWN,WAAWC;IAC5B,MAAMM,aAAaP,WAAWQ;IAC9B,MAAMC,QAAQT,WAAWU;IACzB,MAAMC,SAASC,OAAOT;IACtBQ,OAAO,OAAO,GAAGR;IACjB,MAAMU,OAAOD,OAAwB;IACrC,MAAME,WAAWF,OAAOR,QAAQ,GAAG;IACnCU,SAAS,OAAO,GAAGV,QAAQ,GAAG;IAC9B,MAAM,CAACW,IAAI,GAAGC,SAAS;QACrB,MAAMC,OAAoB,CAACC;gBAEzBJ;YADAD,KAAK,OAAO,GAAGK;oBACfJ,CAAAA,oBAAAA,SAAS,OAAO,AAAD,KAAfA,kBAAAA,IAAAA,CAAAA,UAAmBI;QACrB;QACA,OAAOD;IACT;IACAE,UAAU;QACR,IAAI,CAACb,YAAY,CAACR,IAAI;QACtB,OAAOQ,SAAS,QAAQ,CAACR,IAAI,IAAMa,OAA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C,SAAS,AAAD,IAAvBA,4BAA4BhB,cAAcpB,OAAO,OAAO,CAAC,UAAU,GAA4B0B;;YACpG,IACA,CAAC,CAAC;QACR;QACA,OAAO/B,SAAS,gBAAgB,CAACsC;IACnC,GAAG;QAACtC;QAAUR;QAAIyB;QAAMkB;QAAaD;QAAUE;QAAUC;KAAU;IACnE,OAAO;QAAE7C;QAAI,OAAO;YAAE,IAAID,cAAcC;YAAKiB;QAAI;IAAE;AACrD;AAGO,SAASiC,gBAAgB1B,KAA6D;IAC3F,QAAQd,kBAAkB,SAAS,OAAOc,MAAM,EAAE,GAAGA,MAAM,QAAQ,GAAGd,kBAAkB;AAC1F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anchor/measure.jsx","sources":["../../src/anchor/measure.ts"],"sourcesContent":["import { g9RuntimeTimers } from '@g9tm/lynxcontrols-foundation';\nimport type { NodesRef } from '@lynx-js/types';\nimport type { G9AnchorEntry, G9AnchorRect } from './registry';\n\n// Element methods through NodesRef.invoke, bounded: every call settles (success, failure or a timeout), so a guide or\n// a navigation never waits on an element that went away. Rects are boundingClientRect WITH transforms (a sheet sliding\n// in reports where it is drawn), in dp, relative to the LynxView.\n\ninterface Invokable {\n invoke(options: {\n method: string;\n params?: Record<string, unknown>;\n success?: (r: unknown) => void;\n fail?: (e: unknown) => void;\n }): { exec(): void };\n}\n\n/** One element method; `ok: false` when it failed, the node is gone or it did not answer within `timeoutMs`. */\nexport function invokeNode<T = unknown>(\n node: NodesRef | null | undefined,\n method: string,\n params: Record<string, unknown> = {},\n timeoutMs = 1500,\n): Promise<{ readonly ok: true; readonly value: T } | { readonly ok: false }> {\n return new Promise((resolve) => {\n let settled = false;\n let timer: unknown = null;\n const done = (r: { readonly ok: true; readonly value: T } | { readonly ok: false }) => {\n if (settled) return;\n settled = true;\n if (timer !== null) g9RuntimeTimers.clearTimeout(timer);\n resolve(r);\n };\n const target = node as unknown as Invokable | null | undefined;\n if (!target || typeof target.invoke !== 'function') {\n done({ ok: false });\n return;\n }\n timer = g9RuntimeTimers.setTimeout(() => done({ ok: false }), timeoutMs);\n try {\n target\n .invoke({\n method,\n params,\n success: (value) => done({ ok: true, value: value as T }),\n fail: () => done({ ok: false }),\n })\n .exec();\n } catch {\n done({ ok: false });\n }\n });\n}\n\ninterface RawRect {\n readonly left?: number;\n readonly top?: number;\n readonly width?: number;\n readonly height?: number;\n readonly right?: number;\n readonly bottom?: number;\n}\n\n/** The element's rect (null when it cannot be measured now). */\nexport async function measureNode(node: NodesRef | null | undefined): Promise<G9AnchorRect | null> {\n const r = await invokeNode<RawRect>(node, 'boundingClientRect', { androidEnableTransformProps: true });\n if (!r.ok || !r.value) return null;\n const v = r.value;\n const x = v.left ?? 0;\n const y = v.top ?? 0;\n const width = v.width ?? (v.right ?? x) - x;\n const height = v.height ?? (v.bottom ?? y) - y;\n if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(width) || !Number.isFinite(height)) return null;\n return { x, y, width, height };\n}\n\n/** An anchor's rect: a virtual one's own function, else its element's. */\nexport async function anchorRect(anchor: G9AnchorEntry): Promise<G9AnchorRect | null> {\n if (anchor.binding.rect) {\n try {\n return await anchor.binding.rect();\n } catch {\n return null;\n }\n }\n return measureNode(anchor.binding.node());\n}\n\n/** The window in dp (`SystemInfo` is in physical pixels); 0 × 0 when unknown. */\nexport function windowRect(): G9AnchorRect {\n try {\n const info = (globalThis as { SystemInfo?: { pixelWidth?: number; pixelHeight?: number; pixelRatio?: number } })\n .SystemInfo;\n const ratio = info?.pixelRatio || 1;\n return { x: 0, y: 0, width: (info?.pixelWidth ?? 0) / ratio, height: (info?.pixelHeight ?? 0) / ratio };\n } catch {\n return { x: 0, y: 0, width: 0, height: 0 };\n }\n}\n\n/** The intersection of two rects (null when they do not overlap). */\nexport function intersect(a: G9AnchorRect, b: G9AnchorRect): G9AnchorRect | null {\n const x = Math.max(a.x, b.x);\n const y = Math.max(a.y, b.y);\n const right = Math.min(a.x + a.width, b.x + b.width);\n const bottom = Math.min(a.y + a.height, b.y + b.height);\n return right > x && bottom > y ? { x, y, width: right - x, height: bottom - y } : null;\n}\n\n/** Share (0..1) of `rect` inside `view`; 0 for an empty rect. */\nexport function visibleFraction(rect: G9AnchorRect, view: G9AnchorRect): number {\n const area = rect.width * rect.height;\n if (area <= 0) return 0;\n const i = intersect(rect, view);\n return i ? Math.min(1, (i.width * i.height) / area) : 0;\n}\n\n/** A pause for the native view to settle after a scroll. */\nexport function settleFrame(ms = 34): Promise<void> {\n return new Promise((resolve) => {\n g9RuntimeTimers.setTimeout(resolve, ms);\n });\n}\n"],"names":["invokeNode","node","method","params","timeoutMs","Promise","resolve","settled","timer","done","r","g9RuntimeTimers","target","value","measureNode","_v_left","_v_top","_v_width","_v_right","_v_height","_v_bottom","v","x","y","width","height","Number","anchorRect","anchor","windowRect","info","globalThis","ratio","intersect","a","b","Math","right","bottom","visibleFraction","rect","view","area","i","settleFrame","ms"],"mappings":";AAkBO,SAASA,WACdC,IAAiC,EACjCC,MAAc,EACdC,SAAkC,CAAC,CAAC,EACpCC,YAAY,IAAI;IAEhB,OAAO,IAAIC,QAAQ,CAACC;QAClB,IAAIC,UAAU;QACd,IAAIC,QAAiB;QACrB,MAAMC,OAAO,CAACC;YACZ,IAAIH,SAAS;YACbA,UAAU;YACV,IAAIC,AAAU,SAAVA,OAAgBG,gBAAgB,YAAY,CAACH;YACjDF,QAAQI;QACV;QACA,MAAME,SAASX;QACf,IAAI,CAACW,UAAU,AAAyB,cAAzB,OAAOA,OAAO,MAAM,EAAiB,YAClDH,KAAK;YAAE,IAAI;QAAM;QAGnBD,QAAQG,gBAAgB,UAAU,CAAC,IAAMF,KAAK;gBAAE,IAAI;YAAM,IAAIL;QAC9D,IAAI;YACFQ,OACG,MAAM,CAAC;gBACNV;gBACAC;gBACA,SAAS,CAACU,QAAUJ,KAAK;wBAAE,IAAI;wBAAM,OAAOI;oBAAW;gBACvD,MAAM,IAAMJ,KAAK;wBAAE,IAAI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xC,QAAQ,CAACC;QAClBK,gBAAgB,UAAU,CAACL,SAASuC;IACtC;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anchor/registry.jsx","sources":["../../src/anchor/registry.ts"],"sourcesContent":["import type { G9AnchorRisk, G9ChangeLine } from '@g9tm/lynxcontrols-foundation';\nimport type { NodesRef } from '@lynx-js/types';\n\n// Anchors: every control a guide can point at, an automation can press, or a scroll position can be named by. An anchor\n// is an id, a way to find the element (its NodesRef, or — for something that is not an element, a tree on the map — a\n// rect function), what it is and what it can do. One registry per G9Provider (one per LynxView); registration is cheap\n// and always on: it is a product feature (the guide), not a test hook.\n\n/** What kind of thing an anchor is. */\nexport type G9AnchorKind =\n | 'button'\n | 'entry'\n | 'toggle'\n | 'picker'\n | 'chips'\n | 'tab'\n | 'tab-view'\n | 'list'\n | 'scroll'\n | 'item'\n | 'card'\n | 'label'\n | 'image'\n | 'map'\n | 'view';\n\n/** What an anchor can do, through the control's OWN paths (the same handler a finger triggers, with its guards). */\nexport interface G9AnchorCapabilities {\n activate?(): void | Promise<void>;\n getValue?(): string | null | undefined;\n /** Sets the value; returns the value actually applied when it can read it back. */\n setValue?(value: string): unknown;\n focus?(): void | Promise<void>;\n itemKeys?(): readonly string[];\n selectItem?(key: string): void | Promise<void>;\n expand?(open: boolean): void | Promise<void>;\n}\n\n/** What an anchor is (read live: the latest render's values). */\nexport interface G9AnchorInfo {\n readonly kind: G9AnchorKind;\n label?(): string | null | undefined;\n enabled?(): boolean;\n /** What pressing it does to data. Default `none`. The journey policy reads it. */\n readonly risk?: G9AnchorRisk;\n /** What pressing it would change (a save button's confirmation lists these). */\n changes?(): readonly G9ChangeLine[];\n readonly capabilities?: G9AnchorCapabilities;\n}\n\n/** A rectangle in logical pixels (dp), in the LynxView's coordinates. */\nexport interface G9AnchorRect {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n}\n\n/** Where a mounted anchor lives. */\nexport interface G9AnchorBinding {\n /** The element; null while unmounted or for a virtual anchor. */\n node(): NodesRef | null;\n /** Measures a virtual anchor (instead of the node). */\n rect?(): Promise<G9AnchorRect | null>;\n /** Brings a virtual anchor into view (the map lands on a tree). */\n reveal?(): Promise<boolean>;\n /** The enclosing scroller's id (context), or null. */\n readonly scrollerId: string | null;\n readonly layer: 'page' | 'sheet' | 'popup' | 'floating';\n /** The sheet's handle id when inside a G9 sheet. */\n readonly sheetId?: number;\n}\n\n/** A registered anchor. */\nexport interface G9AnchorEntry {\n readonly id: string;\n /** Registration order: the newest mounted anchor with an id wins. */\n readonly seq: number;\n readonly virtual: boolean;\n info(): G9AnchorInfo;\n readonly binding: G9AnchorBinding;\n}\n\n/** Something that is not an element but can be pointed at (resolved by id pattern). */\nexport interface G9VirtualAnchor extends G9AnchorInfo {\n rect(): Promise<G9AnchorRect | null>;\n reveal?(): Promise<boolean>;\n}\n\n/** Makes virtual anchors for ids it recognises (a tree on the map: `Map.Tree.<id>`). */\nexport interface G9AnchorResolver {\n match(id: string): boolean;\n resolve(id: string): G9VirtualAnchor | null;\n}\n\n/** A registered scroll container. */\nexport interface G9ScrollerSpec {\n readonly id: string;\n readonly kind: 'list' | 'scroll-view';\n readonly orientation: 'vertical' | 'horizontal';\n node(): NodesRef | null;\n /** The scroller this one sits in (context), or null. */\n readonly parentId: string | null;\n /** A list: its item keys in order (the `item-key` strings). */\n itemKeys?(): readonly string[];\n /** A list: the anchor id of the row with this key (a row that is not mounted can still be revealed). */\n itemAnchor?(key: string): string;\n /** A list: the item key of a row anchor, or null when the anchor is not one of its rows. */\n anchorKey?(anchorId: string): string | null;\n}\n\n/** Every anchor and scroller of one provider (one LynxView): registered while mounted, found by id. */\nexport interface G9AnchorRegistry {\n /** Registers an anchor; the returned function removes exactly this registration. */\n register(id: string, info: () => G9AnchorInfo, binding: G9AnchorBinding): () => void;\n /** The newest mounted anchor with this id, else one a resolver makes, else null. */\n find(id: string): G9AnchorEntry | null;\n /** Every mounted anchor, oldest first. */\n all(): readonly G9AnchorEntry[];\n /** Called after any anchor or scroller came or went. */\n subscribe(listener: () => void): () => void;\n addResolver(resolver: G9AnchorResolver): () => void;\n registerScroller(spec: G9ScrollerSpec): () => void;\n scroller(id: string): G9ScrollerSpec | null;\n /** The anchors inside a scroller: bound to it by context, or rows its `anchorKey` names. */\n anchorsIn(scrollerId: string): readonly G9AnchorEntry[];\n /** The list that holds the (maybe not mounted) row anchor `anchorId`, with the row's key. */\n listFor(anchorId: string): { readonly scroller: G9ScrollerSpec; readonly key: string } | null;\n /** The scroller of a mounted anchor: its context one, else a list whose rows include it. */\n scrollerOf(anchor: G9AnchorEntry): G9ScrollerSpec | null;\n readonly revision: number;\n}\n\ninterface Entry {\n readonly anchor: G9AnchorEntry;\n}\n\n/** Creates an empty registry. */\nexport function createAnchorRegistry(): G9AnchorRegistry {\n const byId = new Map<string, Entry[]>();\n const resolvers: G9AnchorResolver[] = [];\n const scrollers = new Map<string, G9ScrollerSpec[]>();\n const listeners = new Set<() => void>();\n let seq = 0;\n let revision = 0;\n\n const changed = () => {\n revision += 1;\n for (const l of Array.from(listeners)) {\n try {\n l();\n } catch {\n // a listener's failure never stops the others\n }\n }\n };\n\n const latestScroller = (id: string): G9ScrollerSpec | null => {\n const list = scrollers.get(id);\n return list && list.length > 0 ? (list[list.length - 1] as G9ScrollerSpec) : null;\n };\n\n const registry: G9AnchorRegistry = {\n register(id, info, binding) {\n const anchor: G9AnchorEntry = { id, seq: ++seq, virtual: false, info, binding };\n const entry: Entry = { anchor };\n const list = byId.get(id) ?? [];\n list.push(entry);\n byId.set(id, list);\n changed();\n let removed = false;\n return () => {\n if (removed) return;\n removed = true;\n const current = byId.get(id);\n if (!current) return;\n const at = current.indexOf(entry);\n if (at >= 0) current.splice(at, 1);\n if (current.length === 0) byId.delete(id);\n changed();\n };\n },\n find(id) {\n const list = byId.get(id);\n if (list && list.length > 0) return (list[list.length - 1] as Entry).anchor;\n for (let i = resolvers.length - 1; i >= 0; i--) {\n const r = resolvers[i] as G9AnchorResolver;\n if (!r.match(id)) continue;\n const v = r.resolve(id);\n if (!v) return null;\n const { rect, reveal, ...info } = v;\n return {\n id,\n seq: 0,\n virtual: true,\n info: () => info,\n binding: { node: () => null, rect, ...(reveal ? { reveal } : {}), scrollerId: null, layer: 'page' },\n };\n }\n return null;\n },\n all() {\n const out: G9AnchorEntry[] = [];\n for (const list of byId.values()) for (const e of list) out.push(e.anchor);\n return out.sort((a, b) => a.seq - b.seq);\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n addResolver(resolver) {\n resolvers.push(resolver);\n return () => {\n const at = resolvers.indexOf(resolver);\n if (at >= 0) resolvers.splice(at, 1);\n };\n },\n registerScroller(spec) {\n const list = scrollers.get(spec.id) ?? [];\n list.push(spec);\n scrollers.set(spec.id, list);\n changed();\n let removed = false;\n return () => {\n if (removed) return;\n removed = true;\n const current = scrollers.get(spec.id);\n if (!current) return;\n const at = current.indexOf(spec);\n if (at >= 0) current.splice(at, 1);\n if (current.length === 0) scrollers.delete(spec.id);\n changed();\n };\n },\n scroller: latestScroller,\n anchorsIn(scrollerId) {\n const spec = latestScroller(scrollerId);\n return registry\n .all()\n .filter((a) => a.binding.scrollerId === scrollerId || (!!spec?.anchorKey && spec.anchorKey(a.id) !== null));\n },\n listFor(anchorId) {\n for (const list of scrollers.values()) {\n const spec = list[list.length - 1] as G9ScrollerSpec;\n const key = spec.anchorKey?.(anchorId) ?? null;\n if (key !== null && (!spec.itemKeys || spec.itemKeys().indexOf(key) >= 0)) return { scroller: spec, key };\n }\n return null;\n },\n scrollerOf(anchor) {\n if (anchor.binding.scrollerId) return latestScroller(anchor.binding.scrollerId);\n return registry.listFor(anchor.id)?.scroller ?? null;\n },\n get revision() {\n return revision;\n },\n };\n return registry;\n}\n"],"names":["createAnchorRegistry","byId","Map","resolvers","scrollers","listeners","Set","seq","revision","changed","l","Array","latestScroller","id","list","registry","info","binding","_byId_get","anchor","entry","removed","current","at","i","r","v","rect","reveal","out","e","a","b","listener","resolver","spec","_scrollers_get","scrollerId","anchorId","key","_registry_listFor"],"mappings":"AA0IO,SAASA;IACd,MAAMC,OAAO,IAAIC;IACjB,MAAMC,YAAgC,EAAE;IACxC,MAAMC,YAAY,IAAIF;IACtB,MAAMG,YAAY,IAAIC;IACtB,IAAIC,MAAM;IACV,IAAIC,WAAW;IAEf,MAAMC,UAAU;QACdD,YAAY;QACZ,KAAK,MAAME,KAAKC,MAAM,IAAI,CAACN,WACzB,IAAI;YACFK;QACF,EAAE,OAAM,CAER;IAEJ;IAEA,MAAME,iBAAiB,CAACC;QACtB,MAAMC,OAAOV,UAAU,GAAG,CAACS;QAC3B,OAAOC,QAAQA,KAAK,MAAM,GAAG,IAAKA,IAAI,CAACA,KAAK,MAAM,GAAG,EAAE,GAAsB;IAC/E;IAEA,MAAMC,WAA6B;QACjC,UAASF,EAAE,EAAEG,IAAI,EAAEC,OAAO;gBAGXC;YAFb,MAAMC,SAAwB;gBAAEN;gBAAI,KAAK,EAAEN;gBAAK,SAAS;gBAAOS;gBAAMC;YAAQ;YAC9E,MAAMG,QAAe;gBAAED;YAAO;YAC9B,MAAML,OAAO,QAAAI,CAAAA,YAAAA,KAAK,GAAG,CAACL,GAAE,IAAXK,YAAgB,EAAE;YAC/BJ,KAAK,IAAI,CAACM;YACVnB,KAAK,GAAG,CAACY,IAAIC;YACbL;YACA,IAAIY,UAAU;YACd,OAAO;gBACL,IAAIA,SAAS;gBACbA,UAAU;gBACV,MAAMC,UAAUrB,KAAK,GAAG,CAACY;gBACzB,IAAI,CAACS,SAAS;gBACd,MAAMC,KAAKD,QAAQ,OAAO,CAACF;gBAC3B,IAAIG,MAAM,GAAGD,QAAQ,MAAM,CAACC,IAAI;gBAChC,IAAID,AAAmB,MAAnBA,QAAQ,MAAM,EAAQrB,KAAK,MAAM,CAACY;gBACtCJ;YACF;QACF;QACA,MAAKI,EAAE;YACL,MAAMC,OAAOb,KAAK,GAAG,CAACY;YACtB,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eAAeO,OAAO,OAAO,CAAC,UAAU;YAC9E,OAAO,QAAP,gBAAOqB,CAAAA,oBAAAA,SAAS,OAAO,CAACrB,OAAO,EAAE,KAA1BqB,KAAAA,IAAAA,kBAA6B,QAAQ,AAAD,IAAC,OAAI;QAClD;QACA,IAAI;YACF,OAAOhC;QACT;IACF;IACA,OAAOO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anchor/scroll.jsx","sources":["../../src/anchor/scroll.ts"],"sourcesContent":["import { type G9ScrollMark, type G9ViewApplied, g9RuntimeTimers } from '@g9tm/lynxcontrols-foundation';\nimport { anchorRect, invokeNode, measureNode, settleFrame, visibleFraction, windowRect } from './measure';\nimport type { G9AnchorEntry, G9AnchorRect, G9AnchorRegistry, G9ScrollerSpec } from './registry';\n\n// Scroll positions by CONTROL, never by pixels (owner, 2026-11-12): the same mark restores the same row on a 5\" phone\n// and a 10\" tablet, and on a screen tall enough not to scroll it does nothing at all. Reading a mark measures the\n// anchors inside the scroller; applying one asks the list for the row by its item key, or the scroll view for the\n// anchor, and then moves by the share of that control's own height that was scrolled past.\n\ninterface ScrollInfo {\n readonly scrollX?: number;\n readonly scrollY?: number;\n readonly maxScrollOffset?: number;\n readonly scrollRange?: number;\n}\n\nasync function scrollInfo(spec: G9ScrollerSpec): Promise<{ readonly at: number; readonly range: number } | null> {\n const r = await invokeNode<ScrollInfo>(spec.node(), 'getScrollInfo');\n if (!r.ok || !r.value) return null;\n const at = (spec.orientation === 'horizontal' ? r.value.scrollX : r.value.scrollY) ?? 0;\n const range = r.value.maxScrollOffset ?? r.value.scrollRange ?? 0;\n return { at: Number.isFinite(at) ? at : 0, range: Number.isFinite(range) ? range : 0 };\n}\n\nconst startOf = (r: G9AnchorRect, horizontal: boolean) => (horizontal ? r.x : r.y);\nconst sizeOf = (r: G9AnchorRect, horizontal: boolean) => (horizontal ? r.width : r.height);\n\n/** What is first in view in a scroller now. */\nexport async function readScrollMark(registry: G9AnchorRegistry, spec: G9ScrollerSpec): Promise<G9ScrollMark> {\n const info = await scrollInfo(spec);\n if (info && info.at <= 1) return { by: 'start' };\n const box = await measureNode(spec.node());\n const horizontal = spec.orientation === 'horizontal';\n if (box) {\n const anchors = registry.anchorsIn(spec.id).filter((a) => !a.virtual);\n const rects = await Promise.all(anchors.map(async (a) => ({ a, r: await anchorRect(a) })));\n const top = startOf(box, horizontal);\n let best: { a: G9AnchorEntry; r: G9AnchorRect } | null = null;\n for (const x of rects) {\n if (!x.r || sizeOf(x.r, horizontal) <= 0) continue;\n if (startOf(x.r, horizontal) + sizeOf(x.r, horizontal) <= top + 0.5) continue;\n if (!best || startOf(x.r, horizontal) < startOf(best.r, horizontal)) best = { a: x.a, r: x.r };\n }\n if (best) {\n const size = sizeOf(best.r, horizontal);\n const offset = Math.min(1, Math.max(0, (top - startOf(best.r, horizontal)) / size));\n const key = spec.anchorKey?.(best.a.id) ?? null;\n return key !== null ? { by: 'item', key, offset } : { by: 'anchor', id: best.a.id, offset };\n }\n }\n if (info && info.range > 0) return { by: 'ratio', ratio: Math.min(1, Math.max(0, info.at / info.range)) };\n return { by: 'start' };\n}\n\nasync function nudge(spec: G9ScrollerSpec, by: number): Promise<boolean> {\n if (Math.abs(by) < 0.5) return true;\n return (await invokeNode(spec.node(), 'scrollBy', { offset: by })).ok;\n}\n\n/** Puts a mark back. `skipped`: nothing scrolls here; `degraded`: an approximation (the row is gone, only a ratio). */\nexport async function applyScrollMark(\n registry: G9AnchorRegistry,\n spec: G9ScrollerSpec,\n mark: G9ScrollMark,\n): Promise<G9ViewApplied> {\n const horizontal = spec.orientation === 'horizontal';\n const toStart = async () =>\n spec.kind === 'list'\n ? (await invokeNode(spec.node(), 'scrollToPosition', { index: 0, alignTo: 'top', smooth: false })).ok\n : (await invokeNode(spec.node(), 'scrollTo', { offset: 0, smooth: false })).ok;\n switch (mark.by) {\n case 'start':\n return (await toStart()) ? 'exact' : 'skipped';\n case 'item': {\n const keys = spec.itemKeys?.() ?? null;\n const index = keys ? keys.indexOf(mark.key) : 0;\n if (spec.kind !== 'list' || index < 0) {\n await toStart();\n return 'degraded';\n }\n const ok = (\n await invokeNode(spec.node(), 'scrollToPosition', {\n index: Math.max(0, index),\n itemKey: mark.key,\n alignTo: 'top',\n smooth: false,\n })\n ).ok;\n if (!ok) return 'skipped';\n if (mark.offset <= 0) return 'exact';\n await settleFrame();\n const anchorId = spec.itemAnchor?.(mark.key);\n const anchor = anchorId ? registry.find(anchorId) : null;\n const r = anchor ? await anchorRect(anchor) : null;\n if (!r) return 'degraded';\n return (await nudge(spec, mark.offset * sizeOf(r, horizontal))) ? 'exact' : 'degraded';\n }\n case 'anchor': {\n const anchor = registry.find(mark.id);\n if (!anchor || anchor.virtual) {\n await toStart();\n return 'degraded';\n }\n const ok = (\n await invokeNode(anchor.binding.node(), 'scrollIntoView', {\n scrollIntoViewOptions: { block: 'start', inline: 'start', behavior: 'none' },\n })\n ).ok;\n if (!ok) return 'skipped';\n if (mark.offset <= 0) return 'exact';\n await settleFrame();\n const r = await anchorRect(anchor);\n if (!r) return 'degraded';\n return (await nudge(spec, mark.offset * sizeOf(r, horizontal))) ? 'exact' : 'degraded';\n }\n case 'ratio': {\n const info = await scrollInfo(spec);\n if (!info || info.range <= 0) return 'skipped';\n const ok =\n spec.kind === 'list'\n ? await nudge(spec, mark.ratio * info.range - info.at)\n : (await invokeNode(spec.node(), 'scrollTo', { offset: mark.ratio * info.range, smooth: false })).ok;\n return ok ? 'degraded' : 'skipped';\n }\n }\n}\n\n/** Options of {@link revealAnchor}. */\nexport interface G9RevealOptions {\n /** Where to put it when it must move. Default `center`. */\n readonly align?: 'start' | 'center' | 'end';\n /** The part of the window controls may be seen in (minus bars, the keyboard). Default: the window. */\n readonly viewport?: G9AnchorRect;\n /** How much must show to count as visible. Default 0.6. */\n readonly minVisible?: number;\n /** How long to wait for a list row to mount. Default 1500 ms. */\n readonly mountTimeoutMs?: number;\n /** Smooth scrolling (a guide) or a jump (restoring). Default false. */\n readonly smooth?: boolean;\n}\n\n/** The result of {@link revealAnchor}. */\nexport interface G9RevealResult {\n readonly ok: boolean;\n readonly anchor: G9AnchorEntry | null;\n readonly rect: G9AnchorRect | null;\n /** Whether anything was scrolled (false when it was already in view: nothing moves on a screen tall enough). */\n readonly scrolled: boolean;\n readonly reason?: 'not-found' | 'not-measurable' | 'off-screen';\n}\n\nfunction waitForAnchor(registry: G9AnchorRegistry, id: string, timeoutMs: number): Promise<G9AnchorEntry | null> {\n const now = registry.find(id);\n if (now) return Promise.resolve(now);\n return new Promise((resolve) => {\n let done = false;\n const finish = (a: G9AnchorEntry | null) => {\n if (done) return;\n done = true;\n off();\n g9RuntimeTimers.clearTimeout(timer);\n resolve(a);\n };\n const off = registry.subscribe(() => {\n const a = registry.find(id);\n if (a) finish(a);\n });\n const timer = g9RuntimeTimers.setTimeout(() => finish(registry.find(id)), timeoutMs);\n });\n}\n\n/**\n * Brings a control into view: a list row that is not mounted is scrolled to by its key first; enclosing scrollers are\n * moved outermost first; a virtual anchor reveals itself. Nothing moves when it is already visible enough.\n */\nexport async function revealAnchor(\n registry: G9AnchorRegistry,\n id: string,\n options: G9RevealOptions = {},\n): Promise<G9RevealResult> {\n const viewport = options.viewport ?? windowRect();\n const minVisible = options.minVisible ?? 0.6;\n const behavior = options.smooth ? 'smooth' : 'none';\n const align = options.align ?? 'center';\n const visible = (r: G9AnchorRect | null) =>\n !!r && (viewport.width <= 0 || visibleFraction(r, viewport) >= minVisible);\n\n let anchor = registry.find(id);\n let scrolled = false;\n if (!anchor) {\n const list = registry.listFor(id);\n if (!list) return { ok: false, anchor: null, rect: null, scrolled, reason: 'not-found' };\n const index = list.scroller.itemKeys?.().indexOf(list.key) ?? 0;\n await invokeNode(list.scroller.node(), 'scrollToPosition', {\n index: Math.max(0, index),\n itemKey: list.key,\n alignTo: align === 'center' ? 'middle' : align === 'end' ? 'bottom' : 'top',\n smooth: !!options.smooth,\n });\n scrolled = true;\n anchor = await waitForAnchor(registry, id, options.mountTimeoutMs ?? 1500);\n if (!anchor) return { ok: false, anchor: null, rect: null, scrolled, reason: 'not-found' };\n await settleFrame();\n }\n\n let rect = await anchorRect(anchor);\n if (visible(rect)) return { ok: true, anchor, rect, scrolled };\n\n if (anchor.virtual) {\n if (anchor.binding.reveal) {\n scrolled = (await anchor.binding.reveal().catch(() => false)) || scrolled;\n rect = await anchorRect(anchor);\n }\n return visible(rect)\n ? { ok: true, anchor, rect, scrolled }\n : { ok: false, anchor, rect, scrolled, reason: rect ? 'off-screen' : 'not-measurable' };\n }\n\n // Outermost scroller first: each brings the next one (or the anchor itself) into view.\n const chain: G9ScrollerSpec[] = [];\n for (\n let s = registry.scrollerOf(anchor);\n s && chain.length < 8;\n s = s.parentId ? registry.scroller(s.parentId) : null\n )\n chain.unshift(s);\n const intoView = { scrollIntoViewOptions: { block: align, inline: 'start', behavior } };\n for (let i = 0; i < chain.length - 1; i++) {\n const inner = chain[i + 1] as G9ScrollerSpec;\n if ((await invokeNode(inner.node(), 'scrollIntoView', intoView)).ok) scrolled = true;\n }\n if ((await invokeNode(anchor.binding.node(), 'scrollIntoView', intoView)).ok) scrolled = true;\n await settleFrame(options.smooth ? 320 : 34);\n rect = await anchorRect(anchor);\n if (visible(rect)) return { ok: true, anchor, rect, scrolled };\n return { ok: false, anchor, rect, scrolled, reason: rect ? 'off-screen' : 'not-measurable' };\n}\n"],"names":["scrollInfo","spec","_ref","_ref1","r","invokeNode","at","range","Number","startOf","horizontal","sizeOf","readScrollMark","registry","info","box","measureNode","anchors","a","rects","Promise","anchorRect","top","best","x","size","offset","Math","key","nudge","by","applyScrollMark","mark","toStart","keys","index","ok","settleFrame","anchorId","anchor","waitForAnchor","id","timeoutMs","now","resolve","done","finish","off","g9RuntimeTimers","timer","revealAnchor","options","_options_viewport","_options_minVisible","_options_align","viewport","windowRect","minVisible","behavior","align","visible","visibleFraction","scrolled","_options_mountTimeoutMs","_list_scroller","list","rect","chain","s","intoView","i","inner"],"mappings":";;AAg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B;YAAQ2B;YAAMJ;YAAU,QAAQI,OAAO,eAAe;QAAiB;IAC1F;IAGA,MAAMC,QAA0B,EAAE;IAClC,IACE,IAAIC,IAAIvD,SAAS,UAAU,CAAC0B,SAC5B6B,KAAKD,MAAM,MAAM,GAAG,GACpBC,IAAIA,EAAE,QAAQ,GAAGvD,SAAS,QAAQ,CAACuD,EAAE,QAAQ,IAAI,KAEjDD,MAAM,OAAO,CAACC;IAChB,MAAMC,WAAW;QAAE,uBAAuB;YAAE,OAAOV;YAAO,QAAQ;YAASD;QAAS;IAAE;IACtF,IAAK,IAAIY,IAAI,GAAGA,IAAIH,MAAM,MAAM,GAAG,GAAGG,IAAK;QACzC,MAAMC,QAAQJ,KAAK,CAACG,IAAI,EAAE;QAC1B,IAAK,OAAMjE,WAAWkE,MAAM,IAAI,IAAI,kBAAkBF,SAAQ,EAAG,EAAE,EAAEP,WAAW;IAClF;IACA,IAAK,OAAMzD,WAAWkC,OAAO,OAAO,CAAC,IAAI,IAAI,kBAAkB8B,SAAQ,EAAG,EAAE,EAAEP,WAAW;IACzF,MAAMzB,YAAYc,QAAQ,MAAM,GAAG,MAAM;IACzCe,OAAO,MAAM7C,WAAWkB;IACxB,IAAIqB,QAAQM,OAAO,OAAO;QAAE,IAAI;QAAM3B;QAAQ2B;QAAMJ;IAAS;IAC7D,OAAO;QAAE,IAAI;QAAOvB;QAAQ2B;QAAMJ;QAAU,QAAQI,OAAO,eAAe;IAAiB;AAC7F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base/control.jsx","sources":["../../src/base/control.ts"],"sourcesContent":["import { type G9AnchorRef, useG9Anchor } from '../anchor/hooks';\nimport type { G9AnchorInfo } from '../anchor/registry';\nimport { useG9Direction } from '../provider/hooks';\n\n/**\n * Props every G9 control shares (MAUI `G9ControlBase` + `IsEnabled`): plan/specs/03 §5. The MAUI lifecycle hooks\n * (`OnApplyVisuals`, `OnPaletteChanged`, `OnCultureChangedHook`, `OnAttachedToLiveTree`, `OnDetachedFromLiveTree`,\n * `OnVisibilityLost`) are React itself: render from props/theme/culture context, effects for attach/detach.\n */\nexport interface G9ControlBaseProps {\n /** Not interactive and dimmed (MAUI `IsEnabled = false`). Default false. */\n readonly disabled?: boolean;\n /** Extra class on the control root. */\n readonly className?: string;\n /** Accessibility label of the control root. */\n readonly accessibilityLabel?: string;\n /**\n * Element `id` of the control root (MAUI `AutomationId`): automation finds it with a selector query (`#id`) and taps\n * its bounds. Used verbatim, so keep it to `[A-Za-z0-9_-]` (a selector reads `.` as a class); parts a control derives\n * from it (`${id}_Header`, a chip's `${id}_${key}`) follow {@link g9ChildId}.\n */\n readonly id?: string;\n}\n\n/** What {@link useG9Control} resolves for a control root. */\nexport interface G9ControlState {\n readonly direction: 'ltr' | 'rtl';\n readonly disabled: boolean;\n /** `g9-dir-<dir>`, the disabled class and the caller's class. */\n readonly className: string;\n /**\n * Spread onto the root element: its `id` when the caller set one, and the `ref` that registers the root as an anchor\n * (`@g9tm/lynxcontrols/anchor`) — so a guide can point at it and an automation can press it through its own paths.\n */\n readonly idProps: Readonly<{ id?: string; ref?: G9AnchorRef }>;\n}\n\n/**\n * The shared control base (MAUI `G9ControlBase`): direction from the culture (set explicitly on every root, specs/02\n * §2), the disabled flag, the root class list, and — when the control has an `id` — its anchor registration (`anchor`:\n * what the control is and can do; without it the root registers as a plain `view`).\n */\nexport function useG9Control(props: G9ControlBaseProps, baseClass: string, anchor?: G9AnchorInfo): G9ControlState {\n const direction = useG9Direction();\n const disabled = props.disabled === true;\n const enabled = !disabled;\n const registered = useG9Anchor(\n props.id,\n anchor ? { enabled: () => enabled, ...anchor } : { kind: 'view', enabled: () => enabled },\n { domId: props.id ?? '' },\n );\n return {\n direction,\n disabled,\n className: `${baseClass} g9-dir-${direction}${disabled ? ' g9-disabled' : ''}${props.className ? ` ${props.className}` : ''}`,\n idProps: props.id ? { id: props.id, ref: registered.ref } : {},\n };\n}\n\n/** `{ id }` when `id` is set (non-empty), else `{}`: spread onto an element that may carry an automation id. */\nexport function g9IdProps(id: string | null | undefined): Readonly<{ id?: string }> {\n return id ? { id } : {};\n}\n\n/**\n * An element id a Lynx selector can address (`#id`): every character outside `[A-Za-z0-9_-]` becomes `_`\n * (`'Popup.Ok'` → `'Popup_Ok'`; a selector reads `.` as a class).\n */\nexport function g9SafeId(id: string): string {\n return id.replace(/[^A-Za-z0-9_-]/g, '_');\n}\n\n/**\n * The id of a part derived from a control's id: {@link g9SafeId} of `${id}_${part}`. `undefined` when the control has\n * no id.\n */\nexport function g9ChildId(id: string | null | undefined, part: string | number): string | undefined {\n return id ? g9SafeId(`${id}_${String(part)}`) : undefined;\n}\n\n/**\n * Inline text alignment at the reading start: stretched text in a mirrored row or column cannot rely on\n * `text-align: start`, which follows the `direction` Lynxtron ignores (E22).\n */\nexport function g9TextStart(direction: 'ltr' | 'rtl'): { textAlign: 'left' | 'right' } {\n return { textAlign: direction === 'rtl' ? 'right' : 'left' };\n}\n\n/**\n * Inline style of a horizontal flex row laid out in reading order, the same on every Lynx engine (MAUI mirrors every\n * horizontal layout under an RTL `FlowDirection`). Lynxtron ignores CSS `direction` (it neither reverses a row nor\n * aligns text), while Android/iOS document that they honour it, so a row never relies on it: RTL reverses the row\n * explicitly and pins the row's own `direction` to `ltr`, so an engine that honours `direction` does not reverse it a\n * second time (plan/specs/02 §2, troubleshooting E22).\n */\nexport function g9RowStyle(direction: 'ltr' | 'rtl'): { flexDirection: 'row' | 'row-reverse'; direction: 'ltr' } {\n return { flexDirection: direction === 'rtl' ? 'row-reverse' : 'row', direction: 'ltr' };\n}\n"],"names":["useG9Control","props","baseClass","anchor","_props_id","direction","useG9Direction","disabled","enabled","registered","useG9Anchor","g9IdProps","id","g9SafeId","g9ChildId","part","String","undefined","g9TextStart","g9RowStyle"],"mappings":";;AA0CO,SAASA,aAAaC,KAAyB,EAAEC,SAAiB,EAAEC,MAAqB;QAOnFC;IANX,MAAMC,YAAYC;IAClB,MAAMC,WAAWN,AAAmB,SAAnBA,MAAM,QAAQ;IAC/B,MAAMO,UAAU,CAACD;IACjB,MAAME,aAAaC,YACjBT,MAAM,EAAE,EACRE,SAAS;QAAE,SAAS,IAAMK;QAAS,GAAGL,MAAM;IAAC,IAAI;QAAE,MAAM;QAAQ,SAAS,IAAMK;IAAQ,GACxF;QAAE,OAAO,QAAAJ,CAAAA,YAAAA,MAAM,EAAE,AAAD,IAAPA,YAAY;IAAG;IAE1B,OAAO;QACLC;QACAE;QACA,WAAW,GAAGL,UAAU,QAAQ,EAAEG,YAAYE,WAAW,iBAAiB,KAAKN,MAAM,SAAS,GAAG,CAAC,CAAC,EAAEA,MAAM,SAAS,EAAE,GAAG,IAAI;QAC7H,SAASA,MAAM,EAAE,GAAG;YAAE,IAAIA,MAAM,EAAE;YAAE,KAAKQ,WAAW,GAAG;QAAC,IAAI,CAAC;IAC/D;AACF;AAGO,SAASE,UAAUC,EAA6B;IACrD,OAAOA,KAAK;QAAEA;IAAG,IAAI,CAAC;AACxB;AAMO,SAASC,SAASD,EAAU;IACjC,OAAOA,GAAG,OAAO,CAAC,mBAAmB;AACvC;AAMO,SAASE,UAAUF,EAA6B,EAAEG,IAAqB;IAC5E,OAAOH,KAAKC,SAAS,GAAGD,GAAG,CAAC,EAAEI,OAAOD,OAAO,IAAIE;AAClD;AAMO,SAASC,YAAYb,SAAwB;IAClD,OAAO;QAAE,WAAWA,AAAc,UAAdA,YAAsB,UAAU;IAAO;AAC7D;AASO,SAASc,WAAWd,SAAwB;IACjD,OAAO;QAAE,eAAeA,AAAc,UAAdA,YAAsB,gBAAgB;QAAO,WAAW;IAAM;AACxF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base/corner-badge.jsx","sources":["../../src/base/corner-badge.tsx"],"sourcesContent":["import './base.css';\nimport type { ReactNode } from '@lynx-js/react';\nimport { useG9Direction } from '../provider/hooks';\n\n/** MAUI `G9CornerBadge` metrics. */\nexport const g9CornerBadgeMetrics = Object.freeze({\n dotSize: 12,\n countHeight: 18,\n fontSize: 10,\n ring: 1.5,\n});\n\n/** Props of {@link G9CornerBadge}. */\nexport interface G9CornerBadgeProps {\n /** Count text (\"3\", \"99+\"); non-blank text wins over the dot. */\n readonly text?: string | null | undefined;\n /** Show an empty dot when there is no text. */\n readonly dot?: boolean;\n /** Fill. Default `var(--g9-error)`. */\n readonly color?: string | null | undefined;\n /** Text colour. Default `var(--g9-on-error)`. */\n readonly textColor?: string;\n /** Ring colour (separates the badge from what it sits on). Default `var(--g9-surface)`. */\n readonly ringColor?: string;\n /** In RTL the count text reads right-to-left (\"99+\" shows \"+99\"). Default true. */\n readonly mirrorTextInRtl?: boolean;\n}\n\n/** Width of a count pill: `max(18, 8 + 7 × length)` (MAUI `G9CornerBadge`). */\nexport function cornerBadgeWidth(text: string): number {\n return Math.max(g9CornerBadgeMetrics.countHeight, 8 + Array.from(text).length * 7);\n}\n\n/** `true` when the badge shows anything. */\nexport function hasCornerBadge(props: Pick<G9CornerBadgeProps, 'text' | 'dot'>): boolean {\n return (props.text != null && props.text.trim() !== '') || props.dot === true;\n}\n\n/**\n * The one corner badge of the library (MAUI `G9CornerBadge`, guide rule 14): centred on the host's top-trailing\n * corner (top-left in RTL), no negative margins (the host reserves half the badge), the number dead-centred, never a\n * touch target. Place it inside a `position: relative` host. Renders nothing when there is no text and no dot.\n */\nexport function G9CornerBadge(props: G9CornerBadgeProps): ReactNode {\n const direction = useG9Direction();\n if (!hasCornerBadge(props)) return null;\n const text = props.text != null && props.text.trim() !== '' ? props.text : null;\n const m = g9CornerBadgeMetrics;\n const width = text ? cornerBadgeWidth(text) : m.dotSize;\n const height = text ? m.countHeight : m.dotSize;\n const side = direction === 'rtl' ? 'left' : 'right';\n return (\n <view\n className=\"g9-corner-badge\"\n style={{\n [side]: `${-width / 2}px`,\n top: `${-height / 2}px`,\n width: `${width}px`,\n height: `${height}px`,\n borderRadius: `${height / 2}px`,\n borderWidth: `${m.ring}px`,\n borderColor: props.ringColor ?? 'var(--g9-surface)',\n backgroundColor: props.color ?? 'var(--g9-error)',\n }}\n >\n {text ? (\n <text\n className=\"g9-corner-badge__text\"\n style={{\n fontSize: `${m.fontSize}px`,\n color: props.textColor ?? 'var(--g9-on-error)',\n direction: direction === 'rtl' && props.mirrorTextInRtl !== false ? 'rtl' : 'ltr',\n }}\n >\n {text}\n </text>\n ) : null}\n </view>\n );\n}\n"],"names":["g9CornerBadgeMetrics","Object","cornerBadgeWidth","text1","Math","Array","hasCornerBadge","props","G9CornerBadge","_props_ringColor","_props_color","_props_textColor","direction","useG9Direction","m","width","height","side","view","text"],"mappings":";;AAKO,MAAMA,uBAAuBC,OAAO,MAAM,CAAC;IAChD,SAAS;IACT,aAAa;IACb,UAAU;IACV,MAAM;AACR;AAmBO,SAASC,iBAAiBC,KAAY;IAC3C,OAAOC,KAAK,GAAG,CAACJ,qBAAqB,WAAW,EAAE,IAAIK,AAA0B,IAA1BA,MAAM,IAAI,CAACF,OAAM,MAAM;AAC/E;AAGO,SAASG,eAAeC,KAA+C;IAC5E,OAAQA,AAAc,QAAdA,MAAM,IAAI,IAAYA,AAAsB,OAAtBA,MAAM,IAAI,CAAC,IAAI,MAAcA,AAAc,SAAdA,MAAM,GAAG;AACtE;AAOO,SAASC,cAAcD,KAAyB;QAkBlCE,kBACIC,cAQNC;IA1BjB,MAAMC,YAAYC;IAClB,IAAI,CAACP,eAAeC,QAAQ,OAAO;IACnC,MAAMJ,QAAOI,AAAc,QAAdA,MAAM,IAAI,IAAYA,AAAsB,OAAtBA,MAAM,IAAI,CAAC,IAAI,KAAYA,MAAM,IAAI,GAAG;IAC3E,MAAMO,IAAId;IACV,MAAMe,QAAQZ,QAAOD,iBAAiBC,SAAQW,EAAE,OAAO;IACvD,MAAME,SAASb,QAAOW,EAAE,WAAW,GAAGA,EAAE,OAAO;IAC/C,MAAMG,OAAOL,AAAc,UAAdA,YAAsB,SAAS;IAC5C,QACGM,KACC,UAAU,kBACV,OAAO;QACL,CAACD,KAAK,EAAE,GAAG,CAACF,QAAQ,EAAE,EAAE,CAAC;QACzB,KAAK,GAAG,CAACC,SAAS,EAAE,EAAE,CAAC;QACvB,OAAO,GAAGD,MAAM,EAAE,CAAC;QACnB,QAAQ,GAAGC,OAAO,EAAE,CAAC;QACrB,cAAc,GAAGA,SAAS,EAAE,EAAE,CAAC;QAC/B,aAAa,GAAGF,EAAE,IAAI,CAAC,EAAE,CAAC;QAC1B,aAAa,QAAAL,CAAAA,mBAAAA,MAAM,SAAS,AAAD,IAAdA,mBAAmB;QAChC,iBAAiB,QAAAC,CAAAA,eAAAA,MAAM,KAAK,AAAD,IAAVA,eAAe;IAClC,GACD;MACC,CAACP,SACEgB,KACC,UAAU,wBACV,OAAO;QACL,UAAU,GAAGL,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC3B,OAAO,QAAAH,CAAAA,mBAAAA,MAAM,SAAS,AAAD,IAAdA,mBAAmB;QAC1B,WAAWC,AAAc,UAAdA,aAAuBL,AAA0B,UAA1BA,MAAM,eAAe,GAAa,QAAQ;IAC9E,GACD;UACC,CAACJ,MAAK;QACR,EAAEgB,QACA,KAAK;IACX,EAAED;AAEN"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base/disposer.jsx","sources":["../../src/base/disposer.ts"],"sourcesContent":["import { useEffect, useState } from '@lynx-js/react';\nimport { type G9TimerHandle, startTimer, stopTimer } from './timers';\n\n/**\n * Owns everything that must stop when its owner goes away: subscriptions, timers, leases (plan/specs/01 §9 \"no work\n * after unmount\"). Teardowns run once, newest first. After `dispose()` nothing new is kept alive: `add` runs its\n * teardown immediately and `setTimeout` schedules nothing.\n */\nexport interface G9Disposer {\n /** `true` once {@link G9Disposer.dispose} ran. */\n readonly disposed: boolean;\n /** Number of teardowns still held (pending timers included). */\n readonly size: number;\n /**\n * Holds `teardown` until dispose. Returns a release function that runs it early (once) and forgets it. A throwing\n * teardown does not stop the others; the first error is rethrown by whoever ran it.\n */\n add(teardown: () => void): () => void;\n /** A timer that is cancelled by dispose. Returns its cancel function. */\n setTimeout(callback: () => void, ms: number): () => void;\n /** Runs every held teardown (newest first) and refuses new work. Idempotent. */\n dispose(): void;\n}\n\n/** Creates a {@link G9Disposer}. */\nexport function createDisposer(): G9Disposer {\n const teardowns = new Set<() => void>();\n let disposed = false;\n\n const disposer: G9Disposer = {\n get disposed() {\n return disposed;\n },\n get size() {\n return teardowns.size;\n },\n add(teardown) {\n if (disposed) {\n teardown();\n return () => {};\n }\n const entry = () => teardown();\n teardowns.add(entry);\n return () => {\n if (teardowns.delete(entry)) entry();\n };\n },\n setTimeout(callback, ms) {\n if (disposed) return () => {};\n let handle: G9TimerHandle;\n const release = disposer.add(() => stopTimer(handle));\n handle = startTimer(() => {\n release();\n callback();\n }, ms);\n return release;\n },\n dispose() {\n if (disposed) return;\n disposed = true;\n const pending = Array.from(teardowns).reverse();\n teardowns.clear();\n let failure: { error: unknown } | null = null;\n for (const teardown of pending) {\n try {\n teardown();\n } catch (error) {\n failure ??= { error };\n }\n }\n if (failure) throw failure.error;\n },\n };\n return disposer;\n}\n\n/**\n * A {@link G9Disposer} bound to the component's lifetime: the same object on every render, disposed on unmount. Use it\n * for timers and subscriptions created by event handlers (effects return their own cleanup).\n */\nexport function useDisposer(): G9Disposer {\n const [disposer] = useState(createDisposer);\n useEffect(() => () => disposer.dispose(), [disposer]);\n return disposer;\n}\n"],"names":["createDisposer","teardowns","Set","disposed","disposer","teardown","entry","callback","ms","handle","release","stopTimer","startTimer","pending","Array","failure","error","useDisposer","useState","useEffect"],"mappings":";;AAyBO,SAASA;IACd,MAAMC,YAAY,IAAIC;IACtB,IAAIC,WAAW;IAEf,MAAMC,WAAuB;QAC3B,IAAI;YACF,OAAOD;QACT;QACA,IAAI;YACF,OAAOF,UAAU,IAAI;QACvB;QACA,KAAII,QAAQ;YACV,IAAIF,UAAU;gBACZE;gBACA,OAAO,KAAO;YAChB;YACA,MAAMC,QAAQ,IAAMD;YACpBJ,UAAU,GAAG,CAACK;YACd,OAAO;gBACL,IAAIL,UAAU,MAAM,CAACK,QAAQA;YAC/B;QACF;QACA,YAAWC,QAAQ,EAAEC,EAAE;YACrB,IAAIL,UAAU,OAAO,KAAO;YAC5B,IAAIM;YACJ,MAAMC,UAAUN,SAAS,GAAG,CAAC,IAAMO,UAAUF;YAC7CA,SAASG,WAAW;gBAClBF;gBACAH;YACF,GAAGC;YACH,OAAOE;QACT;QACA;YACE,IAAIP,UAAU;YACdA,WAAW;YACX,MAAMU,UAAUC,MAAM,IAAI,CAACb,WAAW,OAAO;YAC7CA,UAAU,KAAK;YACf,IAAIc,UAAqC;YACzC,KAAK,MAAMV,YAAYQ,QACrB,IAAI;gBACFR;YACF,EAAE,OAAOW,OAAO;gBACdD,QAAAA,WAAAA,CAAAA,UAAY;oBAAEC;gBAAM;YACtB;YAEF,IAAID,SAAS,MAAMA,QAAQ,KAAK;QAClC;IACF;IACA,OAAOX;AACT;AAMO,SAASa;IACd,MAAM,CAACb,SAAS,GAAGc,SAASlB;IAC5BmB,UAAU,IAAM,IAAMf,SAAS,OAAO,IAAI;QAACA;KAAS;IACpD,OAAOA;AACT"}
|
package/dist/base/press.jsx.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base/press.jsx","sources":["../../src/base/press.ts"],"sourcesContent":["import { useContext, useRef } from '@lynx-js/react';\nimport { G9CoreContext, G9DiagnosticsContext } from '../provider/contexts';\n\n/** Presses closer together than this are dropped (MAUI `G9Press` 300 ms double-fire guard). */\nexport const g9PressGuardMs = 300;\n\n/** Options of {@link useG9Press}. */\nexport interface G9PressOptions {\n /** Blocks the press (disabled, loading, coming soon …). */\n readonly blocked?: boolean;\n /** Diagnostics source for a press handler that throws (e.g. `'G9Button'`). */\n readonly source: string;\n /** Double-fire guard in ms; 0 disables it. Default {@link g9PressGuardMs}. */\n readonly guardMs?: number;\n}\n\nfunction monotonicNow(core: { services: { clock: { monotonicNow(): number } } } | null): number {\n if (core) return core.services.clock.monotonicNow();\n return Date.now();\n}\n\n/**\n * The press of a G9 control (MAUI `G9Press.Invoke`): one handler on the control root (`bindtap`), so a tap on any\n * child (icon, label, badge) fires it exactly once. Blocked presses do nothing; a second press within `guardMs` is\n * dropped; a handler that throws is reported to the provider diagnostics (MAUI `G9Press.ReportFailure`) and never\n * escapes into the event loop. Returns a stable-per-render tap handler.\n */\nexport function useG9Press(onPress: (() => void) | undefined, options: G9PressOptions): () => void {\n const core = useContext(G9CoreContext);\n const diagnostics = useContext(G9DiagnosticsContext);\n const last = useRef(Number.NEGATIVE_INFINITY);\n return () => {\n if (options.blocked || !onPress) return;\n const guard = options.guardMs ?? g9PressGuardMs;\n const now = monotonicNow(core);\n if (guard > 0 && now - last.current < guard) return;\n last.current = now;\n try {\n onPress();\n } catch (error) {\n if (diagnostics) {\n diagnostics.log({\n level: 'error',\n message: `${options.source}: press handler failed.`,\n source: options.source,\n error,\n });\n } else {\n console.error(`[G9] ${options.source}: press handler failed.`, error);\n }\n }\n };\n}\n\n/** A press visual: what the root's style becomes while pressed, and how fast it goes and comes back. */\nexport interface G9PressVisual {\n /** `'scale'` (transform) or `'opacity'`. */\n readonly property: 'scale' | 'opacity';\n readonly rest: number;\n readonly pressed: number;\n /** Press-in duration (ms). */\n readonly inMs: number;\n /** Release duration (ms). */\n readonly outMs: number;\n /** Hovered value (desktop pointer); `undefined` = no hover state. */\n readonly hovered?: number;\n}\n\ninterface MainThreadTarget {\n setStyleProperties?: (styles: Record<string, string>) => void;\n}\n\n/**\n * Press feedback as main-thread twins (plan/specs/02 §3): the touch handlers run on the main thread and set the\n * root's style directly, so the feedback starts on the frame of the touch and never re-renders React. Spread the\n * returned props on the control root. Disabled: no feedback.\n */\nexport function usePressVisual(visual: G9PressVisual, disabled: boolean): Record<string, unknown> {\n const property = visual.property;\n const rest = visual.rest;\n const pressed = visual.pressed;\n const inMs = visual.inMs;\n const outMs = visual.outMs;\n const hovered = visual.hovered;\n const apply = (target: MainThreadTarget | undefined, value: number, ms: number) => {\n 'main thread';\n const css = property === 'scale' ? 'transform' : 'opacity';\n target?.setStyleProperties?.({\n transition: `${css} ${ms}ms ease-out`,\n [css]: property === 'scale' ? `scale(${value})` : String(value),\n });\n };\n const onStart = (event: { currentTarget?: MainThreadTarget }) => {\n 'main thread';\n apply(event.currentTarget, pressed, inMs);\n };\n const onEnd = (event: { currentTarget?: MainThreadTarget }) => {\n 'main thread';\n apply(event.currentTarget, rest, outMs);\n };\n if (disabled) return {};\n const props: Record<string, unknown> = {\n 'main-thread:bindtouchstart': onStart,\n 'main-thread:bindtouchend': onEnd,\n 'main-thread:bindtouchcancel': onEnd,\n };\n if (hovered !== undefined) {\n props['main-thread:bindmouseenter'] = (event: { currentTarget?: MainThreadTarget }) => {\n 'main thread';\n apply(event.currentTarget, hovered, outMs);\n };\n props['main-thread:bindmouseleave'] = onEnd;\n }\n return props;\n}\n"],"names":["g9PressGuardMs","monotonicNow","core","Date","useG9Press","onPress","options","useContext","G9CoreContext","diagnostics","G9DiagnosticsContext","last","useRef","Number","_options_guardMs","guard","now","error","console","usePressVisual","visual","disabled","property","rest","pressed","inMs","outMs","hovered","apply","target","value","ms","css","String","onStart","event","onEnd","props","undefined"],"mappings":";;AAIO,MAAMA,iBAAiB;AAY9B,SAASC,aAAaC,IAAgE;IACpF,IAAIA,MAAM,OAAOA,KAAK,QAAQ,CAAC,KAAK,CAAC,YAAY;IACjD,OAAOC,KAAK,GAAG;AACjB;AAQO,SAASC,WAAWC,OAAiC,EAAEC,OAAuB;IACnF,MAAMJ,OAAOK,WAAWC;IACxB,MAAMC,cAAcF,WAAWG;IAC/B,MAAMC,OAAOC,OAAOC,MAAwB;IAC5C,OAAO;YAESC;QADd,IAAIR,QAAQ,OAAO,IAAI,CAACD,SAAS;QACjC,MAAMU,QAAQ,QAAAD,CAAAA,mBAAAA,QAAQ,OAAO,AAAD,IAAdA,mBAAmBd;QACjC,MAAMgB,MAAMf,aAAaC;QACzB,IAAIa,QAAQ,KAAKC,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IT,AAAYW,WAAZX,SAAuB;QACzBU,KAAK,CAAC,6BAA6B,GAAG,CAACF;YACrC;YACAP,MAAMO,MAAM,aAAa,EAAER,SAASD;QACtC;QACAW,KAAK,CAAC,6BAA6B,GAAGD;IACxC;IACA,OAAOC;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base/pressable.jsx","sources":["../../src/base/pressable.tsx"],"sourcesContent":["import { g9Ms } from '@g9tm/lynxcontrols-foundation';\nimport type { ReactNode } from '@lynx-js/react';\nimport { type G9ControlBaseProps, useG9Control } from './control';\nimport { type G9PressVisual, useG9Press, usePressVisual } from './press';\n\n/** The standard press feedback curve (MAUI `G9PressFeedbackBehavior` defaults: 1 / 0.86 / 0.78 over 110 ms). */\nexport const g9PressFeedbackDefaults: G9PressVisual = Object.freeze({\n property: 'opacity',\n rest: 1,\n hovered: 0.86,\n pressed: 0.78,\n inMs: 110,\n outMs: 110,\n});\n\n/** Props of {@link G9Pressable}. */\nexport interface G9PressableProps extends G9ControlBaseProps {\n /** The press (MAUI `Command` + `CommandParameter`); one handler on the root, children never take the touch. */\n readonly onPress?: () => void;\n /** Opacity at rest. Default 1. */\n readonly restOpacity?: number;\n /** Opacity under a desktop pointer. Default 0.86. */\n readonly hoveredOpacity?: number;\n /** Opacity while pressed. Default 0.78. */\n readonly pressedOpacity?: number;\n /** Each tween's length. Default 110 ms. */\n readonly animationDurationMs?: number;\n readonly children?: ReactNode;\n}\n\n/**\n * Opacity press feedback around any content (MAUI `G9PressFeedbackBehavior` attached to a view; `.For(command)` is\n * `<G9Pressable onPress={…}>`). The feedback runs on the main thread; the press goes through `useG9Press`.\n */\nexport function G9Pressable(props: G9PressableProps): ReactNode {\n const control = useG9Control(props, 'g9-pressable', {\n kind: 'button',\n label: () => props.accessibilityLabel,\n capabilities: { activate: () => press() },\n });\n const press = useG9Press(props.onPress, { blocked: control.disabled, source: 'G9Pressable' });\n const ms = g9Ms(props.animationDurationMs ?? g9PressFeedbackDefaults.inMs);\n const visual = usePressVisual(\n {\n property: 'opacity',\n rest: props.restOpacity ?? g9PressFeedbackDefaults.rest,\n hovered: props.hoveredOpacity ?? (g9PressFeedbackDefaults.hovered as number),\n pressed: props.pressedOpacity ?? g9PressFeedbackDefaults.pressed,\n inMs: ms,\n outMs: ms,\n },\n control.disabled,\n );\n return (\n <view\n className={control.className}\n {...control.idProps}\n style={{ opacity: props.restOpacity ?? 1 }}\n {...(props.accessibilityLabel\n ? { 'accessibility-element': true, 'accessibility-label': props.accessibilityLabel }\n : {})}\n bindtap={press}\n {...visual}\n >\n {props.children}\n </view>\n );\n}\n"],"names":["g9PressFeedbackDefaults","Object","G9Pressable","props","_props_animationDurationMs","_props_restOpacity","_props_hoveredOpacity","_props_pressedOpacity","_props_restOpacity1","control","useG9Control","press","useG9Press","ms","g9Ms","visual","usePressVisual","view"],"mappings":";;;AAMO,MAAMA,0BAAyCC,OAAO,MAAM,CAAC;IAClE,UAAU;IACV,MAAM;IACN,SAAS;IACT,SAAS;IACT,MAAM;IACN,OAAO;AACT;AAqBO,SAASC,YAAYC,KAAuB;QAOjCC,4BAINC,oBACGC,uBACAC,uBAUSC;IAtBtB,MAAMC,UAAUC,aAAaP,OAAO,gBAAgB;QAClD,MAAM;QACN,OAAO,IAAMA,MAAM,kBAAkB;QACrC,cAAc;YAAE,UAAU,IAAMQ;QAAQ;IAC1C;IACA,MAAMA,QAAQC,WAAWT,MAAM,OAAO,EAAE;QAAE,SAASM,QAAQ,QAAQ;QAAE,QAAQ;IAAc;IAC3F,MAAMI,KAAKC,KAAK,QAAAV,CAAAA,6BAAAA,MAAM,mBAAmB,AAAD,IAAxBA,6BAA6BJ,wBAAwB,IAAI;IACzE,MAAMe,SAASC,eACb;QACE,UAAU;QACV,MAAM,QAAAX,CAAAA,qBAAAA,MAAM,WAAW,AAAD,IAAhBA,qBAAqBL,wBAAwB,IAAI;QACvD,SAAS,QAAAM,CAAAA,wBAAAA,MAAM,cAAc,AAAD,IAAnBA,wBAAyBN,wBAAwB,OAAO;QACjE,SAAS,QAAAO,CAAAA,wBAAAA,MAAM,cAAc,AAAD,IAAnBA,wBAAwBP,wBAAwB,OAAO;QAChE,MAAMa;QACN,OAAOA;IACT,GACAJ,QAAQ,QAAQ;IAElB,QACGQ,KACC,WAAWR,QAAQ,SAAS,GAC3B,GAAGA,QAAQ,OAAO,EACnB,OAAO;QAAE,SAAS,QAAAD,CAAAA,sBAAAA,MAAM,WAAW,AAAD,IAAhBA,sBAAqB;IAAE,IACxC,GAAIL,MAAM,kBAAkB,GACzB;QAAE,yBAAyB;QAAM,uBAAuBA,MAAM,kBAAkB;IAAC,IACjF,CAAC,CAAC,EACN,SAASQ,QACR,GAAGI,MAAM,EACX;MACC,CAACZ,MAAM,QAAQ,CAAC;IAClB,EAAEc;AAEN"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base/selection-item.jsx","sources":["../../src/base/selection-item.ts"],"sourcesContent":["import { type G9ImageSource, isIconEmpty } from '@g9tm/lynxcontrols-foundation';\nimport type { G9IconInput } from '../icon/icon';\n\n/**\n * One selectable item (MAUI `G9SelectionItem`), shared by the chip group (WP04), the selection sheet and the pickers\n * (WP05/WP06). Plain data: create it inline or map your own objects to it.\n */\nexport interface G9SelectionItem<TValue = unknown> {\n readonly text: string;\n /** Stable identity; when blank, `text` is the identity (MAUI `SelectionIdentity`). */\n readonly key?: string | null | undefined;\n readonly emoji?: string | null | undefined;\n readonly icon?: G9IconInput | undefined;\n readonly iconPath?: string | null | undefined;\n readonly iconImage?: G9ImageSource | null | undefined;\n readonly iconTintColor?: string | null | undefined;\n /** Colour swatch (one colour = circle, two = split circle). */\n readonly swatchFirstColor?: string | null | undefined;\n readonly swatchSecondColor?: string | null | undefined;\n /** App payload, never read by the controls. */\n readonly value?: TValue | undefined;\n /** Default true. */\n readonly isEnabled?: boolean | undefined;\n /** Selected fill override (wins over the group's). */\n readonly selectedColor?: string | null | undefined;\n readonly selectedTextColor?: string | null | undefined;\n /**\n * The image (`iconPath` / `iconImage`) is a person's picture (MAUI 1.4.10 `IsAvatar`): drawn ROUND, at\n * `G9Metrics.SelectionAvatarSize` (28) in the selection sheet's rows and round at the icon size as a single combo-box\n * value; multi-select chips show the name only. Ignored for an emoji or a glyph.\n */\n readonly isAvatar?: boolean | undefined;\n}\n\n/** The item's icon is a person's picture: `isAvatar` on an image, not an emoji or a glyph (MAUI `IsAvatarImage`). */\nexport function isAvatarImage(item: G9SelectionItem): boolean {\n if (item.isAvatar !== true) return false;\n if (item.emoji != null && item.emoji.trim() !== '') return false;\n const icon = item.icon;\n const glyph =\n icon !== undefined && (typeof icon === 'string' ? icon.trim() !== '' && icon !== 'none' : !isIconEmpty(icon));\n if (glyph) return false;\n return (item.iconPath != null && item.iconPath.trim() !== '') || item.iconImage != null;\n}\n\n/** The identity of an item: `key` unless blank, else `text` (MAUI `G9SelectionItem.SelectionIdentity`). */\nexport function selectionKey(item: Pick<G9SelectionItem, 'key' | 'text'>): string {\n return item.key != null && item.key.trim() !== '' ? item.key : item.text;\n}\n"],"names":["isAvatarImage","item","icon","glyph","undefined","isIconEmpty","selectionKey"],"mappings":";AAmCO,SAASA,cAAcC,IAAqB;IACjD,IAAIA,AAAkB,SAAlBA,KAAK,QAAQ,EAAW,OAAO;IACnC,IAAIA,AAAc,QAAdA,KAAK,KAAK,IAAYA,AAAsB,OAAtBA,KAAK,KAAK,CAAC,IAAI,IAAW,OAAO;IAC3D,MAAMC,OAAOD,KAAK,IAAI;IACtB,MAAME,QACJD,AAASE,WAATF,QAAuB,CAAgB,YAAhB,OAAOA,OAAoBA,AAAgB,OAAhBA,KAAK,IAAI,MAAaA,AAAS,WAATA,OAAkB,CAACG,YAAYH,KAAI;IAC7G,IAAIC,OAAO,OAAO;IAClB,OAAQF,AAAiB,QAAjBA,KAAK,QAAQ,IAAYA,AAAyB,OAAzBA,KAAK,QAAQ,CAAC,IAAI,MAAcA,AAAkB,QAAlBA,KAAK,SAAS;AACjF;AAGO,SAASK,aAAaL,IAA2C;IACtE,OAAOA,AAAY,QAAZA,KAAK,GAAG,IAAYA,AAAoB,OAApBA,KAAK,GAAG,CAAC,IAAI,KAAYA,KAAK,GAAG,GAAGA,KAAK,IAAI;AAC1E"}
|
package/dist/base/timers.jsx.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base/timers.jsx","sources":["../../src/base/timers.ts"],"sourcesContent":["// The runtime timers: foundation's `g9RuntimeTimers` (bundle-scope `setTimeout` / `clearTimeout`; Lynx does not put\n// them on `globalThis`). Every G9 control timer goes through here so a disposer can clear it and tests can fake it.\nimport { g9RuntimeTimers } from '@g9tm/lynxcontrols-foundation';\n\n/** A timer handle as the runtime returns it. */\nexport type G9TimerHandle = unknown;\n\n/** Schedules `callback` after `ms` milliseconds (negative is treated as 0). */\nexport function startTimer(callback: () => void, ms: number): G9TimerHandle {\n return g9RuntimeTimers.setTimeout(callback, Math.max(0, ms));\n}\n\n/** Cancels a timer from {@link startTimer}; cancelling twice or after it fired is harmless. */\nexport function stopTimer(handle: G9TimerHandle): void {\n g9RuntimeTimers.clearTimeout(handle);\n}\n"],"names":["startTimer","callback","ms","g9RuntimeTimers","Math","stopTimer","handle"],"mappings":";AAQO,SAASA,WAAWC,QAAoB,EAAEC,EAAU;IACzD,OAAOC,gBAAgB,UAAU,CAACF,UAAUG,KAAK,GAAG,CAAC,GAAGF;AAC1D;AAGO,SAASG,UAAUC,MAAqB;IAC7CH,gBAAgB,YAAY,CAACG;AAC/B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base/use-controllable-state.jsx","sources":["../../src/base/use-controllable-state.ts"],"sourcesContent":["import { useContext, useRef, useState } from '@lynx-js/react';\nimport { G9DiagnosticsContext } from '../provider/contexts';\nimport { useStableCallback } from './use-stable-callback';\n\n/** Inputs of {@link useControllableState}: one MAUI two-way property (plan/specs/03 §3). */\nexport interface G9ControllableStateOptions<T, TExtra extends unknown[]> {\n /** The controlled value. Present (anything but `undefined`, `null` included) means the caller owns the state. */\n readonly value: T | undefined;\n /** The initial value while uncontrolled. Read once, on the first render. */\n readonly defaultValue: T;\n /** Told once per logical change, with any extra payload the setter received (e.g. `{ source }`). */\n readonly onChange?: ((value: T, ...extra: TExtra) => void) | undefined;\n /** Names the prop in the development diagnostic, e.g. `'G9Switch.checked'`. */\n readonly name: string;\n /** Equality of two values; a setter call with an equal value changes nothing. Default `Object.is`. */\n readonly equals?: ((a: T, b: T) => boolean) | undefined;\n}\n\n/** Sets the value: a value or an updater of the current one, plus the extra payload for `onChange`. */\nexport type G9ControllableSetter<T, TExtra extends unknown[]> = (\n next: T | ((current: T) => T),\n ...extra: TExtra\n) => void;\n\n/**\n * The library's only implementation of controlled/uncontrolled state (plan/specs/03 §3, WP02 design note).\n *\n * - Controlled (`value !== undefined`): the returned value is always `value`; the setter only calls `onChange`.\n * - Uncontrolled: the hook keeps the state, starting at `defaultValue` (read once).\n * - `onChange` fires once per logical change: never for a value equal to the current one and never for a value the\n * parent pushed in through `value`.\n * - Switching between controlled and uncontrolled during the component's life emits one development diagnostic\n * (a `warning` log on the provider's diagnostics hub, or `console.warn` outside a provider) and keeps working with\n * the new mode.\n *\n * The setter's identity is stable. `T` must not be a function type (a function argument is an updater).\n */\nexport function useControllableState<T, TExtra extends unknown[] = []>(\n options: G9ControllableStateOptions<T, TExtra>,\n): [T, G9ControllableSetter<T, TExtra>] {\n const { value, defaultValue, name } = options;\n const controlled = value !== undefined;\n const [internal, setInternal] = useState<T>(defaultValue);\n const diagnostics = useContext(G9DiagnosticsContext);\n\n const wasControlled = useRef(controlled);\n const warned = useRef(false);\n if (wasControlled.current !== controlled) {\n if (!warned.current) {\n warned.current = true;\n const message =\n `${name} switched from ${wasControlled.current ? 'controlled' : 'uncontrolled'} to ` +\n `${controlled ? 'controlled' : 'uncontrolled'}. Decide once: pass the value on every render, or never.`;\n if (diagnostics) diagnostics.log({ level: 'warning', message, source: name });\n else console.warn(`[G9] ${message}`);\n }\n wasControlled.current = controlled;\n }\n\n const current = controlled ? value : internal;\n const latest = useRef(current);\n latest.current = current;\n\n const notify = useStableCallback(options.onChange);\n const equals = useRef(options.equals);\n equals.current = options.equals;\n const isControlled = useRef(controlled);\n isControlled.current = controlled;\n\n const setValue = useStableCallback((next: T | ((current: T) => T), ...extra: TExtra) => {\n const resolved = typeof next === 'function' ? (next as (current: T) => T)(latest.current) : next;\n if ((equals.current ?? Object.is)(latest.current, resolved)) return;\n if (!isControlled.current) {\n latest.current = resolved;\n setInternal(() => resolved);\n }\n notify(resolved, ...extra);\n }) as G9ControllableSetter<T, TExtra>;\n\n return [current, setValue];\n}\n"],"names":["useControllableState","options","value","defaultValue","name","controlled","undefined","internal","setInternal","useState","diagnostics","useContext","G9DiagnosticsContext","wasControlled","useRef","warned","message","console","current","latest","notify","useStableCallback","equals","isControlled","setValue","next","extra","_equals_current","resolved","Object"],"mappings":";;;AAqCO,SAASA,qBACdC,OAA8C;IAE9C,MAAM,EAAEC,KAAK,EAAEC,YAAY,EAAEC,IAAI,EAAE,GAAGH;IACtC,MAAMI,aAAaH,AAAUI,WAAVJ;IACnB,MAAM,CAACK,UAAUC,YAAY,GAAGC,SAAYN;IAC5C,MAAMO,cAAcC,WAAWC;IAE/B,MAAMC,gBAAgBC,OAAOT;IAC7B,MAAMU,SAASD,OAAO;IACtB,IAAID,cAAc,OAAO,KAAKR,YAAY;QACxC,IAAI,CAACU,OAAO,OAAO,EAAE;YACnBA,OAAO,OAAO,GAAG;YACjB,MAAMC,UACJ,GAAGZ,KAAK,eAAe,EAAES,cAAc,OAAO,GAAG,eAAe,eAC/D,MAAER,aAAa,eAAe,eAAe,wDAAwD,CADlB;YAEtF,IAAIK,aAAaA,YAAY,GAAG,CAAC;gBAAE,OAAO;gBAAWM;gBAAS,QAAQZ;YAAK;iBACtEa,QAAQ,IAAI,CAAC,CAAC,KAAK,EAAED,SAAS;QACrC;QACAH,cAAc,OAAO,GAAGR;IAC1B;IAEA,MAAMa,UAAUb,aAAaH,QAAQK;IACrC,MAAMY,SAASL,OAAOI;IACtBC,OAAO,OAAO,GAAGD;IAEjB,MAAME,SAASC,kBAAkBpB,QAAQ,QAAQ;IACjD,MAAMqB,SAASR,OAAOb,QAAQ,MAAM;IACpCqB,OAAO,OAAO,GAAGrB,QAAQ,MAAM;IAC/B,MAAMsB,eAAeT,OAAOT;IAC5BkB,aAAa,OAAO,GAAGlB;IAEvB,MAAMmB,WAAWH,kBAAkB,CAACI,MAA+B,GAAGC;YAE/DC;QADL,MAAMC,WAAW,AAAgB,cAAhB,OAAOH,OAAuBA,KAA2BN,OAAO,OAAO,IAAIM;QAC5F,IAAI,AAAC,SAAAE,CAAAA,kBAAAA,OAAO,OAAO,AAAD,IAAbA,kBAAkBE,OAAO,EAAE,AAAD,EAAGV,OAAO,OAAO,EAAES,WAAW;QAC7D,IAAI,CAACL,aAAa,OAAO,EAAE;YACzBJ,OAAO,OAAO,GAAGS;YACjBpB,YAAY,IAAMoB;QACpB;QACAR,OAAOQ,aAAaF;IACtB;IAEA,OAAO;QAACR;QAASM;KAAS;AAC5B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base/use-stable-callback.jsx","sources":["../../src/base/use-stable-callback.ts"],"sourcesContent":["import { useCallback, useRef } from '@lynx-js/react';\n\n/**\n * A function whose identity never changes but which always calls the latest `callback` (the \"event handler ref\"\n * pattern). Use it for callbacks handed to subscriptions, timers and child props, so a parent re-render neither\n * re-subscribes nor re-renders a memoised child. It always calls the callback of the most recent\n * render. `undefined` makes it a no-op that returns `undefined` (an optional callback prop).\n */\nexport function useStableCallback<TArgs extends unknown[], TResult>(\n callback: ((...args: TArgs) => TResult) | undefined,\n): (...args: TArgs) => TResult | undefined {\n const latest = useRef(callback);\n latest.current = callback;\n return useCallback((...args: TArgs) => latest.current?.(...args), []);\n}\n"],"names":["useStableCallback","callback","latest","useRef","useCallback","args"],"mappings":";AAQO,SAASA,kBACdC,QAAmD;IAEnD,MAAMC,SAASC,OAAOF;IACtBC,OAAO,OAAO,GAAGD;IACjB,OAAOG,YAAY,CAAC,GAAGC;YAAgBH;uBAAAA,CAAAA,kBAAAA,OAAO,OAAO,AAAD,IAAbA,KAAAA,IAAAA,gBAAAA,IAAAA,CAAAA,WAAoBG;OAAO,EAAE;AACtE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"button/button.jsx","sources":["../../src/button/button.tsx"],"sourcesContent":["import './button.css';\nimport { type G9ButtonVariant, type G9ControlSize, type G9ImageSource, G9Metrics } from '@g9tm/lynxcontrols-foundation';\nimport type { ReactNode } from '@lynx-js/react';\nimport { type G9ControlBaseProps, g9RowStyle, useG9Control } from '../base/control';\nimport { useG9Press, usePressVisual } from '../base/press';\nimport { G9ActivityIndicator } from '../display/activity-indicator';\nimport type { G9IconInput } from '../icon/icon';\nimport { G9IconSlot, hasIconSlot } from '../icon/slot';\nimport { useG9Theme } from '../provider/hooks';\nimport { buttonSizePreset, fontAttributesStyle, type G9FontAttributes, resolveButtonPaint } from './visuals';\n\n/** Props of {@link G9Button} (MAUI `G9Button`). */\nexport interface G9ButtonProps extends G9ControlBaseProps {\n readonly text?: string | null;\n /** Text next to the spinner while loading; empty shows the spinner only. */\n readonly loadingText?: string | null;\n /** Colour recipe. Default `'primary'`. */\n readonly variant?: G9ButtonVariant;\n /** Height, padding and font preset. Default `'medium'` (44). */\n readonly size?: G9ControlSize;\n readonly leadingEmoji?: string | null;\n readonly leadingIcon?: G9IconInput;\n readonly leadingImagePath?: string | null;\n readonly leadingImage?: G9ImageSource | null;\n readonly trailingEmoji?: string | null;\n readonly trailingIcon?: G9IconInput;\n readonly trailingImagePath?: string | null;\n readonly trailingImage?: G9ImageSource | null;\n /** Spinner instead of the icons, presses blocked, opacity 0.7, flat fill. Default false. */\n readonly isLoading?: boolean;\n /** One line with a tail ellipsis; false keeps the text on one line at its natural width. Default true. */\n readonly textTruncation?: boolean;\n /** Icon slot and spinner size. Default 20. */\n readonly iconSize?: number;\n /** Font size; default the size preset's (12/14/15/16). */\n readonly fontSize?: number;\n /** Default `'bold'`. */\n readonly fontAttributes?: G9FontAttributes;\n /** Overrides the variant fill (transparent → no fill and no border). */\n readonly baseBackgroundColor?: string | null;\n /** Overrides the text, icon and spinner colour. */\n readonly textColor?: string | null;\n /** The press (MAUI `Clicked` + `Command`): exactly once per tap, never while disabled or loading. */\n readonly onPress?: () => void;\n /** Spinner colour; default the text colour (MAUI `G9SafeButton.SpinnerColor`, which MAUI ignored). */\n readonly spinnerColor?: string;\n /** Blocks presses like `disabled` (dims to 0.38) without being `disabled` (safe buttons while busy). */\n readonly blocked?: boolean;\n /** Height in dp instead of the size preset's (MAUI `HeightRequest` set after the preset, e.g. 46 or 50). */\n readonly heightRequest?: number;\n}\n\n/**\n * Text button (MAUI `G9Button`): variant fill (gradient for the solid variants), 12 px corners, no shadow, optional\n * leading/trailing icons, loading state with a spinner. One press handler on the root: a tap on the icon or the label\n * fires `onPress` once (MAUI \"press must fire\"); a second tap within 300 ms is dropped; a throwing handler is\n * reported to diagnostics. Press feedback: scale 0.96 (80 ms) → 1 (150 ms) on the main thread.\n */\nexport function G9Button(props: G9ButtonProps): ReactNode {\n const control = useG9Control(props, 'g9-button', {\n kind: 'button',\n label: () => props.accessibilityLabel ?? props.text,\n enabled: () => enabled && !loading,\n capabilities: { activate: () => press() },\n });\n const theme = useG9Theme();\n const loading = props.isLoading === true;\n const enabled = !control.disabled && props.blocked !== true;\n const preset = buttonSizePreset(props.size ?? 'medium');\n const height = props.heightRequest && props.heightRequest > 0 ? props.heightRequest : preset.height;\n const paint = resolveButtonPaint({\n variant: props.variant ?? 'primary',\n palette: theme.palette,\n enabled,\n loading,\n baseBackgroundColor: props.baseBackgroundColor,\n textColor: props.textColor,\n kind: 'button',\n });\n const iconSize = props.iconSize && props.iconSize > 0 ? props.iconSize : G9Metrics.InputIconSize;\n const press = useG9Press(props.onPress, { blocked: !enabled || loading, source: 'G9Button' });\n const visual = usePressVisual(\n { property: 'scale', rest: 1, pressed: 0.96, inMs: 80, outMs: 150 },\n !enabled || loading,\n );\n const leading = {\n emoji: props.leadingEmoji,\n icon: props.leadingIcon,\n imagePath: props.leadingImagePath,\n image: props.leadingImage,\n };\n const trailing = {\n emoji: props.trailingEmoji,\n icon: props.trailingIcon,\n imagePath: props.trailingImagePath,\n image: props.trailingImage,\n };\n const label = loading ? (props.loadingText ?? '') : (props.text ?? '');\n const truncate = props.textTruncation !== false;\n return (\n <view\n className={`${control.className}${preset.fill ? ' g9-button--fill' : ''}`}\n {...control.idProps}\n accessibility-element={true}\n accessibility-traits=\"button\"\n {...((props.accessibilityLabel ?? props.text)\n ? { 'accessibility-label': props.accessibilityLabel ?? props.text ?? '' }\n : {})}\n style={{\n ...g9RowStyle(control.direction),\n // MAUI ApplySize: HeightRequest = the preset (52 hero, 44 medium…), the padding a margin around the row — the\n // button never grows with its label (a min-height let hero buttons grow to ~57 dp from the 16 px padding).\n minHeight: `${height}px`,\n height: `${height}px`,\n background: paint.background,\n borderColor: paint.stroke,\n borderWidth: `${paint.strokeWidth}px`,\n borderRadius: `${G9Metrics.RadiusMd}px`,\n opacity: paint.opacity,\n paddingLeft: `${preset.paddingHorizontal}px`,\n paddingRight: `${preset.paddingHorizontal}px`,\n paddingTop: '0px',\n paddingBottom: '0px',\n }}\n bindtap={press}\n {...visual}\n >\n {loading ? (\n <G9ActivityIndicator running size={iconSize} color={props.spinnerColor ?? paint.text} />\n ) : hasIconSlot(leading) ? (\n <G9IconSlot {...leading} size={iconSize} color={paint.text} />\n ) : null}\n {label.trim() !== '' ? (\n <text\n className=\"g9-button__label\"\n {...(truncate ? { 'text-maxline': '1' } : {})}\n style={{\n color: paint.text,\n fontSize: `${props.fontSize && props.fontSize > 0 ? props.fontSize : preset.fontSize}px`,\n ...fontAttributesStyle(props.fontAttributes ?? 'bold'),\n ...(truncate ? { textOverflow: 'ellipsis', overflow: 'hidden' } : { whiteSpace: 'nowrap' }),\n }}\n >\n {label}\n </text>\n ) : null}\n {!loading && hasIconSlot(trailing) ? <G9IconSlot {...trailing} size={iconSize} color={paint.text} /> : null}\n </view>\n );\n}\n"],"names":["G9Button","props","_props_size","_props_variant","_props_loadingText","_props_text","_props_accessibilityLabel","_ref","_props_spinnerColor","_props_fontAttributes","control","useG9Control","enabled","loading","press","theme","useG9Theme","preset","buttonSizePreset","height","paint","resolveButtonPaint","iconSize","G9Metrics","useG9Press","visual","usePressVisual","leading","trailing","label","truncate","view","g9RowStyle","G9ActivityIndicator","hasIconSlot","G9IconSlot","text","fontAttributesStyle"],"mappings":";;;;;;;;AA0DO,SAASA,SAASC,KAAoB;QAUXC,aAGrBC,gBA0BcC,oBAA4BC,aAQ3CC,2BACuBC,MAAAA,4BAsByBC,qBAWzBC;IAhFjC,MAAMC,UAAUC,aAAaV,OAAO,aAAa;QAC/C,MAAM;QACN,OAAO;gBAAMK;2BAAAA,CAAAA,4BAAAA,MAAM,kBAAkB,AAAD,IAAvBA,4BAA4BL,MAAM,IAAI;;QACnD,SAAS,IAAMW,WAAW,CAACC;QAC3B,cAAc;YAAE,UAAU,IAAMC;QAAQ;IAC1C;IACA,MAAMC,QAAQC;IACd,MAAMH,UAAUZ,AAAoB,SAApBA,MAAM,SAAS;IAC/B,MAAMW,UAAU,CAACF,QAAQ,QAAQ,IAAIT,AAAkB,SAAlBA,MAAM,OAAO;IAClD,MAAMgB,SAASC,iBAAiB,QAAAhB,CAAAA,cAAAA,MAAM,IAAI,AAAD,IAATA,cAAc;IAC9C,MAAMiB,SAASlB,MAAM,aAAa,IAAIA,MAAM,aAAa,GAAG,IAAIA,MAAM,aAAa,GAAGgB,OAAO,MAAM;IACnG,MAAMG,QAAQC,mBAAmB;QAC/B,SAAS,QAAAlB,CAAAA,iBAAAA,MAAM,OAAO,AAAD,IAAZA,iBAAiB;QAC1B,SAASY,MAAM,OAAO;QACtBH;QACAC;QACA,qBAAqBZ,MAAM,mBAAmB;QAC9C,WAAWA,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AO,KAAK;IAC9G,EAAEW;AAEN"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"button/header-action-button.jsx","sources":["../../src/button/header-action-button.tsx"],"sourcesContent":["import './button.css';\nimport { formatColor, G9Glyph, type G9ImageSource, withAlpha } from '@g9tm/lynxcontrols-foundation';\nimport type { ReactNode } from '@lynx-js/react';\nimport { type G9ControlBaseProps, useG9Control } from '../base/control';\nimport { useG9Press, usePressVisual } from '../base/press';\nimport { G9ActivityIndicator } from '../display/activity-indicator';\nimport type { G9IconInput } from '../icon/icon';\nimport { G9IconSlot } from '../icon/slot';\nimport { useG9Theme } from '../provider/hooks';\n\n/** MAUI `G9LayoutMetrics.ToolbarIconSize` / `ToolbarButtonSize`. */\nexport const g9ToolbarIconSize = 24;\n/** Touch box of a toolbar / header action button (MAUI `G9LayoutMetrics.ToolbarButtonSize`). */\nexport const g9ToolbarButtonSize = 42;\n\n/** Props of {@link G9HeaderActionButton} (MAUI `G9HeaderActionButton`). */\nexport interface G9HeaderActionButtonProps extends G9ControlBaseProps {\n /** Glyph shown when there is no image and no text. Default `G9Glyph.Menu`. */\n readonly icon?: G9IconInput;\n /** Image; wins over text and glyph. */\n readonly iconImage?: G9ImageSource | null;\n /** Bold 13 label (wins over the glyph). */\n readonly buttonText?: string | null;\n /** Spinner instead of the content; presses blocked. Default false. */\n readonly isBusy?: boolean;\n /** Tinted active state. Default false. */\n readonly isActive?: boolean;\n /** The 8 px dot while active. Default true. */\n readonly showActiveBadge?: boolean;\n /**\n * A COUNT on the action (MAUI 1.4.9 `BadgeText`, AgriPad's «۲» active filters): a 16 px Primary pill with this text\n * over the icon's top end corner, shown whenever it is set — the active dot gives way to it. Null / empty: the dot rules.\n */\n readonly badgeText?: string | null;\n /** Scale 0.92 (70 ms) → 1 (90 ms) on press. Default true. */\n readonly animatePress?: boolean;\n /** Default 24. */\n readonly iconSize?: number;\n /** Square size; ≤ 0 → 42 (MAUI `ToolbarButtonSize`). Default 0. */\n readonly buttonSize?: number;\n readonly onPress?: () => void;\n}\n\n/** Toolbar/header action (MAUI `G9HeaderActionButton`): bordered square with a glyph, image or short text. */\nexport function G9HeaderActionButton(props: G9HeaderActionButtonProps): ReactNode {\n const control = useG9Control(props, 'g9-header-action', {\n kind: 'button',\n label: () => props.accessibilityLabel ?? text,\n capabilities: { activate: () => press() },\n });\n const palette = useG9Theme().palette;\n const busy = props.isBusy === true;\n const active = props.isActive === true;\n const size = props.buttonSize && props.buttonSize > 0 ? props.buttonSize : g9ToolbarButtonSize;\n const iconSize = props.iconSize ?? g9ToolbarIconSize;\n const press = useG9Press(props.onPress, { blocked: control.disabled || busy, source: 'G9HeaderActionButton' });\n const visual = usePressVisual(\n { property: 'scale', rest: 1, pressed: 0.92, inMs: 70, outMs: 90 },\n control.disabled || busy || props.animatePress === false,\n );\n const text = props.buttonText ?? '';\n const badge = props.badgeText != null && props.badgeText !== '' ? props.badgeText : null;\n let content: ReactNode;\n if (busy) content = <G9ActivityIndicator running size={20} color=\"var(--g9-on-surface-variant)\" />;\n else if (props.iconImage) content = <G9IconSlot image={props.iconImage} size={iconSize} />;\n else if (text.trim() !== '') content = <text className=\"g9-header-action__text\">{text}</text>;\n else content = <G9IconSlot icon={props.icon ?? G9Glyph.Menu} size={iconSize} color=\"var(--g9-on-surface-variant)\" />;\n return (\n <view\n className={control.className}\n {...control.idProps}\n style={{\n width: `${size}px`,\n height: `${size}px`,\n opacity: control.disabled || busy ? 0.5 : 1,\n ...(active\n ? {\n backgroundColor: formatColor(withAlpha(palette.Primary, 0.12)),\n borderColor: formatColor(withAlpha(palette.Primary, 0.38)),\n }\n : {}),\n }}\n accessibility-element={true}\n accessibility-traits=\"button\"\n {...((props.accessibilityLabel ?? (text || undefined))\n ? { 'accessibility-label': props.accessibilityLabel ?? text }\n : {})}\n bindtap={press}\n {...visual}\n >\n {content}\n {badge ? (\n <view\n className=\"g9-header-action__count\"\n user-interaction-enabled={false}\n style={{ [control.direction === 'rtl' ? 'left' : 'right']: '2px' }}\n >\n <text className=\"g9-header-action__count-text\">{badge}</text>\n </view>\n ) : active && props.showActiveBadge !== false ? (\n <view className=\"g9-header-action__badge\" style={{ [control.direction === 'rtl' ? 'left' : 'right']: '6px' }} />\n ) : null}\n </view>\n );\n}\n"],"names":["g9ToolbarIconSize","g9ToolbarButtonSize","G9HeaderActionButton","props","_props_iconSize","_props_buttonText","_props_icon","_props_accessibilityLabel","_props_accessibilityLabel1","control","useG9Control","text1","press","palette","useG9Theme","busy","active","size","iconSize","useG9Press","visual","usePressVisual","badge","content","G9ActivityIndicator","G9IconSlot","text","G9Glyph","view","formatColor","withAlpha","undefined"],"mappings":";;;;;;;AAWO,MAAMA,oBAAoB;AAE1B,MAAMC,sBAAsB;AA+B5B,SAASC,qBAAqBC,KAAgC;QAUlDC,iBAMJC,mBAMoBC,aAkBvBC,2BACuBC;IAxCjC,MAAMC,UAAUC,aAAaP,OAAO,oBAAoB;QACtD,MAAM;QACN,OAAO;gBAAMI;2BAAAA,CAAAA,4BAAAA,MAAM,kBAAkB,AAAD,IAAvBA,4BAA4BI;;QACzC,cAAc;YAAE,UAAU,IAAMC;QAAQ;IAC1C;IACA,MAAMC,UAAUC,aAAa,OAAO;IACpC,MAAMC,OAAOZ,AAAiB,SAAjBA,MAAM,MAAM;IACzB,MAAMa,SAASb,AAAmB,SAAnBA,MAAM,QAAQ;IAC7B,MAAMc,OAAOd,MAAM,UAAU,IAAIA,MAAM,UAAU,GAAG,IAAIA,MAAM,UAAU,GAAGF;IAC3E,MAAMiB,WAAW,QAAAd,CAAAA,kBAAAA,MAAM,QAAQ,AAAD,IAAbA,kBAAkBJ;IACnC,MAAMY,QAAQO,WAAWhB,MAAM,OAAO,EAAE;QAAE,SAASM,QAAQ,QAAQ,IAAIM;QAAM,QAAQ;IAAuB;IAC5G,MAAMK,SAASC,eACb;QAAE,UAAU;QAAS,MAAM;QAAG,SAAS;QAAM,MAAM;QAAI,OAAO;IAAG,GACjEZ,QAAQ,QAA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1B,OAAO;QAAE,CAACnB,AAAsB,UAAtBA,QAAQ,SAAS,GAAa,SAAS,QAAQ,EAAE;IAAM,GAClE;UACC,CAACiB,KAAK,UAAU,gCAAgCJ,QAAQI,KAAK;QAC/D,EAAEE,QACAZ,UAAUb,AAA0B,UAA1BA,MAAM,eAAe,IAChCyB,KAAK,UAAU,0BAA0B,OAAO;QAAE,CAACnB,AAAsB,UAAtBA,QAAQ,SAAS,GAAa,SAAS,QAAQ,EAAE;IAAM,OACzG,KAAK;IACX,EAAEmB;AAEN"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"button/icon-button.jsx","sources":["../../src/button/icon-button.tsx"],"sourcesContent":["import './button.css';\nimport { type G9ButtonVariant, type G9ImageSource, G9Metrics, G9StringKey } from '@g9tm/lynxcontrols-foundation';\nimport type { ReactNode } from '@lynx-js/react';\nimport { type G9ControlBaseProps, useG9Control } from '../base/control';\nimport { G9CornerBadge } from '../base/corner-badge';\nimport { useG9Press, usePressVisual } from '../base/press';\nimport { G9ActivityIndicator } from '../display/activity-indicator';\nimport type { G9IconInput } from '../icon/icon';\nimport { G9IconSlot } from '../icon/slot';\nimport { useG9Strings, useG9Theme } from '../provider/hooks';\nimport { resolveButtonPaint } from './visuals';\n\n/** Props of {@link G9IconButton} (MAUI `G9IconButton`). */\nexport interface G9IconButtonProps extends G9ControlBaseProps {\n readonly emoji?: string | null;\n readonly icon?: G9IconInput;\n readonly imagePath?: string | null;\n readonly image?: G9ImageSource | null;\n /** Icon and spinner size; ≤ 0 → 20. Default 20. */\n readonly iconSize?: number;\n /** Square frame size; ≤ 0 → 40. Default 40. */\n readonly buttonSize?: number;\n /** Transparent, no stroke, icon in `textSecondary`. Default false. */\n readonly isGhost?: boolean;\n /** Default `'surface'`. */\n readonly variant?: G9ButtonVariant;\n /** Fully round instead of 12 px corners. Default false. */\n readonly isCircular?: boolean;\n /** Measured (touch) size when larger than the drawn frame; the frame stays centred. Default 0. */\n readonly minimumTouchTarget?: number;\n readonly baseBackgroundColor?: string | null;\n /** Icon colour override. */\n readonly textColor?: string | null;\n readonly isLoading?: boolean;\n /** Count badge on the top-trailing corner; wins over the dot. */\n readonly badgeText?: string | null;\n readonly showBadgeDot?: boolean;\n /** Default `var(--g9-error)`. */\n readonly badgeColor?: string | null;\n /** Default true. */\n readonly mirrorBadgeTextInRtl?: boolean;\n /** Accessibility name (MAUI `AccessibilityText`); `accessibilityLabel` is an alias. */\n readonly accessibilityText?: string | null;\n readonly onPress?: () => void;\n readonly blocked?: boolean;\n}\n\n/**\n * Square icon button (MAUI `G9IconButton`): one icon, variant/ghost fill, optional circle, corner badge that is never\n * dimmed (opacity applies to the frame only), loading spinner, minimum touch target. Press: one handler on the root,\n * scale 0.82 (80 ms) → 1 (150 ms). Accessibility hint: \"Loading\" while loading, else the badge text.\n */\nexport function G9IconButton(props: G9IconButtonProps): ReactNode {\n const control = useG9Control(props, 'g9-icon-button', {\n kind: 'button',\n label: () => props.accessibilityText ?? props.accessibilityLabel,\n enabled: () => enabled && !loading,\n capabilities: { activate: () => press() },\n });\n const theme = useG9Theme();\n const strings = useG9Strings();\n const loading = props.isLoading === true;\n const enabled = !control.disabled && props.blocked !== true;\n const size = props.buttonSize && props.buttonSize > 0 ? props.buttonSize : 40;\n const iconSize = props.iconSize && props.iconSize > 0 ? props.iconSize : G9Metrics.InputIconSize;\n const ghost = props.isGhost === true;\n const paint = resolveButtonPaint({\n variant: props.variant ?? 'surface',\n palette: theme.palette,\n enabled,\n loading,\n baseBackgroundColor: ghost ? 'rgba(0,0,0,0)' : props.baseBackgroundColor,\n textColor: props.textColor ?? (ghost ? theme.palette.TextSecondary : null),\n kind: 'icon',\n });\n const press = useG9Press(props.onPress, { blocked: !enabled || loading, source: 'G9IconButton' });\n const visual = usePressVisual(\n { property: 'scale', rest: 1, pressed: 0.82, inMs: 80, outMs: 150 },\n !enabled || loading,\n );\n const touch = Math.max(props.minimumTouchTarget ?? 0, size);\n const name = props.accessibilityText ?? props.accessibilityLabel;\n const hint = loading ? strings.get(G9StringKey.Loading) : (props.badgeText ?? undefined);\n return (\n <view\n className={control.className}\n {...control.idProps}\n style={{ minWidth: `${touch}px`, minHeight: `${touch}px` }}\n accessibility-element={true}\n accessibility-traits=\"button\"\n {...(name ? { 'accessibility-label': name } : {})}\n {...(hint ? { 'accessibility-value': hint } : {})}\n bindtap={press}\n {...visual}\n >\n <view className=\"g9-icon-button__host\">\n <view\n className=\"g9-icon-button__frame\"\n style={{\n width: `${size}px`,\n height: `${size}px`,\n background: paint.background,\n borderColor: paint.stroke,\n borderWidth: `${paint.strokeWidth}px`,\n borderRadius: `${props.isCircular ? size / 2 : G9Metrics.RadiusMd}px`,\n opacity: paint.opacity,\n }}\n >\n {loading ? (\n <G9ActivityIndicator running size={iconSize} color={paint.text} />\n ) : (\n <G9IconSlot\n emoji={props.emoji}\n icon={props.icon}\n imagePath={props.imagePath}\n image={props.image}\n size={iconSize}\n color={paint.text}\n />\n )}\n </view>\n <G9CornerBadge\n text={props.badgeText}\n dot={props.showBadgeDot === true}\n color={props.badgeColor}\n textColor=\"#FFFFFF\"\n ringColor={ghost ? 'var(--g9-background)' : 'var(--g9-surface)'}\n mirrorTextInRtl={props.mirrorBadgeTextInRtl !== false}\n />\n </view>\n </view>\n );\n}\n"],"names":["G9IconButton","props","_props_variant","_props_textColor","_props_minimumTouchTarget","_props_accessibilityText","_props_badgeText","control","useG9Control","enabled","loading","press","theme","useG9Theme","strings","useG9Strings","size","iconSize","G9Metrics","ghost","paint","resolveButtonPaint","useG9Press","visual","usePressVisual","touch","Math","name","hint","G9StringKey","undefined","view","G9ActivityIndicator","G9IconSlot","G9CornerBadge"],"mappings":";;;;;;;;;AAoDO,SAASA,aAAaC,KAAwB;QAexCC,gBAKEC,kBAQUC,2BACVC,0BAC8CC;IA7B3D,MAAMC,UAAUC,aAAaP,OAAO,kBAAkB;QACpD,MAAM;QACN,OAAO;gBAAMI;2BAAAA,CAAAA,2BAAAA,MAAM,iB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BAC5C,iBAAiBlB,AAA+B,UAA/BA,MAAM,oBAAoB,GAC3C;MACJ,EAAE8B,KAAK;IACT,EAAEA;AAEN"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"button/nav-card.jsx","sources":["../../src/button/nav-card.tsx"],"sourcesContent":["import './button.css';\nimport { formatColor, type G9ImageSource, G9StringKey, mix, resolveThemeColor } from '@g9tm/lynxcontrols-foundation';\nimport type { ReactNode } from '@lynx-js/react';\nimport { type G9ControlBaseProps, g9RowStyle, g9TextStart, useG9Control } from '../base/control';\nimport { G9CornerBadge } from '../base/corner-badge';\nimport { useG9Press, usePressVisual } from '../base/press';\nimport type { G9IconInput } from '../icon/icon';\nimport { G9IconSlot, hasIconSlot } from '../icon/slot';\nimport { useG9Settings, useG9Strings, useG9Theme } from '../provider/hooks';\n\n/** Props of {@link G9NavCard} (MAUI `G9NavCard`). */\nexport interface G9NavCardProps extends G9ControlBaseProps {\n readonly title?: string | null;\n readonly subtitle?: string | null;\n /** Icon and icon-tile tint. Default the primary colour. Must be a colour literal (it is mixed). */\n readonly accentColor?: string | null;\n readonly iconEmoji?: string | null;\n readonly icon?: G9IconInput;\n readonly iconPath?: string | null;\n readonly iconImage?: G9ImageSource | null;\n /** Trailing chevron (forward in LTR, back in RTL). Default true. */\n readonly showChevron?: boolean;\n readonly valueText?: string | null;\n /** Value colour; default error when destructive, else tertiary text. */\n readonly valueColor?: string | null;\n /** Coming-soon badge instead of value and chevron; presses do nothing. Default false. */\n readonly isComingSoon?: boolean;\n /** Badge text; default the localized `comingSoon`. */\n readonly comingSoonText?: string | null;\n readonly iconBadgeText?: string | null;\n readonly showIconBadgeDot?: boolean;\n readonly iconBadgeColor?: string | null;\n /** Default true. */\n readonly mirrorBadgeTextInRtl?: boolean;\n /** Replaces the whole trailing area (value, chevron, coming-soon badge). */\n readonly trailing?: ReactNode;\n /**\n * A small node on the title's line, right after the title (a count pill, an unread dot, a \"6/10\"; MAUI 1.4.0\n * `TitleAccessoryView`). It does not take over the trailing area, so the chevron, value and coming-soon badge keep\n * working beside it. A long title truncates; the accessory never does. Unset keeps the title layout as it was.\n */\n readonly titleAccessory?: ReactNode;\n /** Title (and default value colour) in the error colour. Default false. */\n readonly isDestructive?: boolean;\n /** Tint the card background with the accent (88 % surface). Default false. */\n readonly useAccentSurface?: boolean;\n /** Accent used only for the background tint. */\n readonly cardAccentColor?: string | null;\n /**\n * Paint the icon tile solid in the accent with an `OnPrimary` icon instead of the pastel tile with an accent icon\n * (MAUI 1.4.0 `UseFilledIconChip`): the one primary row of a list. Pair with `useAccentSurface`. Default false.\n */\n readonly useFilledIconChip?: boolean;\n /** The press (MAUI `Tapped` + `Command`); not while disabled or coming soon. */\n readonly onPress?: () => void;\n}\n\n/**\n * Navigation row card (MAUI `G9NavCard`): icon tile (pastel, or filled with `useFilledIconChip`) with optional corner\n * badge, title (with an optional `titleAccessory` after it)/subtitle, value text, chevron or coming-soon badge, or a\n * custom trailing node. Press: scale 0.985 (70 ms) → 1 (120 ms); hover on desktop.\n */\nexport function G9NavCard(props: G9NavCardProps): ReactNode {\n const control = useG9Control(props, 'g9-nav-card', {\n kind: 'card',\n label: () => props.accessibilityLabel ?? label,\n capabilities: { activate: () => press() },\n });\n const palette = useG9Theme().palette;\n const glyphs = useG9Settings().glyphs;\n const strings = useG9Strings();\n const soon = props.isComingSoon === true;\n const destructive = props.isDestructive === true;\n // A theme reference (`var(--g9-success)`) is resolved against the live palette: the accent is mixed below, and a\n // CSS variable cannot be mixed.\n const accent = props.accentColor ? resolveThemeColor(props.accentColor, palette) : palette.Primary;\n const cardAccent = props.cardAccentColor ? resolveThemeColor(props.cardAccentColor, palette) : accent;\n const surface = props.useAccentSurface ? formatColor(mix(cardAccent, palette.Surface, 0.88)) : palette.Surface;\n const press = useG9Press(props.onPress, { blocked: control.disabled || soon, source: 'G9NavCard' });\n const visual = usePressVisual(\n { property: 'scale', rest: 1, pressed: 0.985, inMs: 70, outMs: 120 },\n control.disabled || soon,\n );\n const icon = { emoji: props.iconEmoji, icon: props.icon, imagePath: props.iconPath, image: props.iconImage };\n const subtitle = props.subtitle && props.subtitle.trim() !== '' ? props.subtitle : null;\n const value = props.valueText && props.valueText.trim() !== '' ? props.valueText : null;\n const soonText =\n props.comingSoonText && props.comingSoonText.trim() !== ''\n ? props.comingSoonText\n : strings.get(G9StringKey.ComingSoon);\n const label = [props.title, subtitle].filter(Boolean).join(', ');\n const filledChip = props.useFilledIconChip === true;\n const title = props.title ? (\n <text\n className=\"g9-nav-card__title\"\n text-maxline=\"1\"\n style={{ color: destructive ? palette.Error : palette.TextPrimary, ...g9TextStart(control.direction) }}\n >\n {props.title}\n </text>\n ) : null;\n return (\n <view\n className={control.className}\n {...control.idProps}\n style={{ backgroundColor: surface, ...g9RowStyle(control.direction) }}\n {...(props.trailing === undefined\n ? {\n 'accessibility-element': true,\n 'accessibility-traits': 'button',\n ...((props.accessibilityLabel ?? label)\n ? { 'accessibility-label': props.accessibilityLabel ?? label }\n : {}),\n ...(soon ? { 'accessibility-value': soonText } : value ? { 'accessibility-value': value } : {}),\n }\n : {})}\n bindtap={press}\n {...visual}\n >\n {hasIconSlot(icon) ? (\n <view\n className=\"g9-nav-card__tile\"\n style={{ backgroundColor: filledChip ? accent : formatColor(mix(accent, palette.Surface, 0.82)) }}\n >\n <G9IconSlot {...icon} size={props.iconEmoji ? 22 : 18} color={filledChip ? palette.OnPrimary : accent} />\n <G9CornerBadge\n text={props.iconBadgeText}\n dot={props.showIconBadgeDot === true}\n color={props.iconBadgeColor}\n mirrorTextInRtl={props.mirrorBadgeTextInRtl !== false}\n />\n </view>\n ) : null}\n <view className=\"g9-nav-card__text\">\n {props.titleAccessory === undefined || props.titleAccessory === null ? (\n title\n ) : (\n <view className=\"g9-nav-card__title-row\" style={g9RowStyle(control.direction)}>\n {title}\n <view className=\"g9-nav-card__title-accessory\">{props.titleAccessory}</view>\n </view>\n )}\n {subtitle ? (\n <text className=\"g9-nav-card__subtitle\" text-maxline=\"1\" style={g9TextStart(control.direction)}>\n {subtitle}\n </text>\n ) : null}\n </view>\n {props.trailing !== undefined ? (\n <view className=\"g9-nav-card__trailing\" style={g9RowStyle(control.direction)}>\n {props.trailing}\n </view>\n ) : (\n <view className=\"g9-nav-card__trailing\" style={g9RowStyle(control.direction)}>\n {value && !soon ? (\n <text\n className=\"g9-nav-card__value\"\n text-maxline=\"1\"\n style={{ color: props.valueColor ?? (destructive ? palette.Error : palette.TextTertiary) }}\n >\n {value}\n </text>\n ) : null}\n {soon ? (\n <view className=\"g9-nav-card__soon\">\n <text className=\"g9-nav-card__soon-text\">{soonText}</text>\n </view>\n ) : props.showChevron !== false ? (\n <G9IconSlot\n icon={control.direction === 'rtl' ? glyphs.chevronBack : glyphs.chevronForward}\n size={24}\n color={palette.TextTertiary}\n />\n ) : null}\n </view>\n )}\n </view>\n );\n}\n"],"names":["G9NavCard","props","_props_accessibilityLabel","_props_accessibilityLabel1","_props_valueColor","control","useG9Control","label","press","palette","useG9Theme","glyphs","useG9Settings","strings","useG9Strings","soon","destructive","accent","resolveThemeColor","cardAccent","surface","formatColor","mix","useG9Press","visual","usePressVisual","icon","subtitle","value","soonText","G9StringKey","Boolean","filledChip","title","text","g9TextStart","view","g9RowStyle","undefined","hasIconSlot","G9IconSlot","G9CornerBadge"],"mappings":";;;;;;;AA8DO,SAASA,UAAUC,KAAqB;QAgD9BC,2BACwBC,4BA+CXC;IA/F5B,MAAMC,UAAUC,aAAaL,OAAO,eAAe;QACjD,MAAM;QACN,OAAO;gBAAMC;2BAAAA,CAAAA,4BAAAA,MAAM,kBAAkB,AAAD,IAAvBA,4BAA4BK;;QACzC,cAAc;YAAE,UAAU,IAAMC;QAAQ;IAC1C;IACA,MAAMC,UAAUC,aAAa,OAAO;IACpC,MAAMC,SAASC,gBAAgB,MAAM;IACrC,MAAMC,UAAUC;IAChB,MAAMC,OAAOd,AAAuB,SAAvBA,MAAM,YAAY;IAC/B,MAAMe,cAAcf,AAAwB,SAAx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SafeRunContext } from '@g9tm/lynxcontrols-foundation';\nimport { useRef } from '@lynx-js/react';\nimport { useG9Executor } from '../provider/hooks';\n\n/** Options of {@link useSafeTap} (MAUI `G9SafeTapBehavior`). */\nexport interface G9SafeTapOptions {\n /** Taps needed to run (double tap = 2); taps further apart than `multiTapWindowMs` restart the count. Default 1. */\n readonly numberOfTapsRequired?: number;\n /** Max gap between the taps of a multi-tap. Default 300 ms. */\n readonly multiTapWindowMs?: number;\n /** Default true. */\n readonly enableThrottle?: boolean;\n /** Default one key per hook instance. */\n readonly throttleKey?: string;\n /** Default 369 ms. */\n readonly throttleIntervalMs?: number;\n /** Default `'G9SafeTapBehavior'`. */\n readonly source?: string;\n /** Default true. */\n readonly showErrorPopup?: boolean;\n /** `false` ignores taps (MAUI `CanExecute`). Default true. */\n readonly canExecute?: boolean;\n}\n\nlet counter = 0;\n\n/**\n * A guarded tap for any element (MAUI `G9SafeTapBehavior`): returns a `bindtap` handler that runs `action` through the\n * provider's safe executor (throttle, one run at a time, errors to diagnostics and the popup). No busy state and no\n * visual feedback, as in MAUI. `numberOfTapsRequired` is read on every tap (MAUI read it once at attach).\n */\nexport function useSafeTap(\n action: ((context: G9SafeRunContext) => unknown) | null | undefined,\n options: G9SafeTapOptions = {},\n): () => void {\n const executor = useG9Executor();\n const key = useRef<string | null>(null);\n if (key.current === null) key.current = `G9SafeTapBehavior:${++counter}`;\n const taps = useRef<{ count: number; last: number }>({ count: 0, last: 0 });\n return () => {\n if (!action || options.canExecute === false) return;\n const required = Math.max(1, Math.floor(options.numberOfTapsRequired ?? 1));\n if (required > 1) {\n const now = Date.now();\n const window = options.multiTapWindowMs ?? 300;\n taps.current =\n now - taps.current.last <= window ? { count: taps.current.count + 1, last: now } : { count: 1, last: now };\n if (taps.current.count < required) return;\n taps.current = { count: 0, last: 0 };\n }\n executor.runSafe(action, {\n throttleKey: options.throttleKey ?? (key.current as string),\n enableThrottle: options.enableThrottle !== false,\n ...(options.throttleIntervalMs !== undefined ? { throttleIntervalMs: options.throttleIntervalMs } : {}),\n source: options.source ?? 'G9SafeTapBehavior',\n showErrorPopup: options.showErrorPopup !== false,\n });\n };\n}\n"],"names":["counter","useSafeTap","action","options","executor","useG9Executor","key","useRef","taps","_options_numberOfTapsRequired","_options_throttleKey","_options_source","required","Math","_options_multiTapWindowMs","now","Date","window","undefined"],"mappings":";;AAwBA,IAAIA,UAAU;AAOP,SAASC,WACdC,MAAmE,EACnEC,UAA4B,CAAC,CAAC;IAE9B,MAAMC,WAAWC;IACjB,MAAMC,MAAMC,OAAsB;IAClC,IAAID,AAAgB,SAAhBA,IAAI,OAAO,EAAWA,IAAI,OAAO,GAAG,CAAC,kBAAkB,EAAE,EAAEN,SAAS;IACxE,MAAMQ,OAAOD,OAAwC;QAAE,OAAO;QAAG,MAAM;IAAE;IACzE,OAAO;YAEmCE,+BAUzBC,sBAGLC;QAdV,IAAI,CAACT,UAAUC,AAAuB,UAAvBA,QAAQ,UAAU,EAAY;QAC7C,MAAMS,WAAWC,KAAK,GAAG,CAAC,GAAGA,KAAK,KAAK,CAAC,QAAAJ,CAAAA,gCAAAA,QAAQ,oBAAoB,AAAD,IAA3BA,gCAAgC;QACxE,IAAIG,WAAW,GAAG;gBAEDE;YADf,MAAMC,MAAMC,KAAK,GAAG;YACpB,MAAMC,SAAS,QAAAH,CAAAA,4BAAAA,QAAQ,gBAAgB,AAAD,IAAvBA,4BAA4B;YAC3CN,KAAK,OAAO,GACVO,MAAMP,KAAK,OAAO,CAAC,IAAI,IAAIS,SAAS;gBAAE,OAAOT,KAAK,OAAO,CAAC,KAAK,GAAG;gBAAG,MAAMO;YAAI,IAAI;gBAAE,OAAO;gBAAG,MAAMA;YAAI;YAC3G,IAAIP,KAAK,OAAO,CAAC,KAAK,GAAGI,UAAU;YACnCJ,KAAK,OAAO,GAAG;gBAAE,OAAO;gBAAG,MAAM;YAAE;QACrC;QACAJ,SAAS,OAAO,CAACF,QAAQ;YACvB,aAAa,QAAAQ,CAAAA,u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