@g9tm/lynxcontrols 1.4.11 → 1.6.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.
Files changed (146) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/anchor/context.d.ts +15 -0
  3. package/dist/anchor/context.d.ts.map +1 -0
  4. package/dist/anchor/context.jsx +10 -0
  5. package/dist/anchor/context.jsx.map +1 -0
  6. package/dist/anchor/hooks.d.ts +72 -0
  7. package/dist/anchor/hooks.d.ts.map +1 -0
  8. package/dist/anchor/hooks.jsx +147 -0
  9. package/dist/anchor/hooks.jsx.map +1 -0
  10. package/dist/anchor/index.d.ts +6 -0
  11. package/dist/anchor/index.d.ts.map +1 -0
  12. package/dist/anchor/index.jsx +5 -0
  13. package/dist/anchor/measure.d.ts +22 -0
  14. package/dist/anchor/measure.d.ts.map +1 -0
  15. package/dist/anchor/measure.jsx +110 -0
  16. package/dist/anchor/measure.jsx.map +1 -0
  17. package/dist/anchor/registry.d.ts +108 -0
  18. package/dist/anchor/registry.d.ts.map +1 -0
  19. package/dist/anchor/registry.jsx +142 -0
  20. package/dist/anchor/registry.jsx.map +1 -0
  21. package/dist/anchor/scroll.d.ts +34 -0
  22. package/dist/anchor/scroll.d.ts.map +1 -0
  23. package/dist/anchor/scroll.jsx +255 -0
  24. package/dist/anchor/scroll.jsx.map +1 -0
  25. package/dist/base/control.d.ts +10 -3
  26. package/dist/base/control.d.ts.map +1 -1
  27. package/dist/base/control.jsx +17 -2
  28. package/dist/base/control.jsx.map +1 -1
  29. package/dist/base/pressable.d.ts.map +1 -1
  30. package/dist/base/pressable.jsx +7 -1
  31. package/dist/base/pressable.jsx.map +1 -1
  32. package/dist/button/button.d.ts.map +1 -1
  33. package/dist/button/button.jsx +11 -1
  34. package/dist/button/button.jsx.map +1 -1
  35. package/dist/button/header-action-button.d.ts.map +1 -1
  36. package/dist/button/header-action-button.jsx +10 -1
  37. package/dist/button/header-action-button.jsx.map +1 -1
  38. package/dist/button/icon-button.d.ts.map +1 -1
  39. package/dist/button/icon-button.jsx +11 -1
  40. package/dist/button/icon-button.jsx.map +1 -1
  41. package/dist/button/nav-card.d.ts.map +1 -1
  42. package/dist/button/nav-card.jsx +10 -1
  43. package/dist/button/nav-card.jsx.map +1 -1
  44. package/dist/button/vertical-icon-text-button.d.ts.map +1 -1
  45. package/dist/button/vertical-icon-text-button.jsx +10 -1
  46. package/dist/button/vertical-icon-text-button.jsx.map +1 -1
  47. package/dist/expander/expander.d.ts.map +1 -1
  48. package/dist/expander/expander.jsx +14 -1
  49. package/dist/expander/expander.jsx.map +1 -1
  50. package/dist/fields/editor.d.ts.map +1 -1
  51. package/dist/fields/editor.jsx +17 -1
  52. package/dist/fields/editor.jsx.map +1 -1
  53. package/dist/fields/outlined-field.d.ts +6 -0
  54. package/dist/fields/outlined-field.d.ts.map +1 -1
  55. package/dist/fields/outlined-field.jsx +14 -3
  56. package/dist/fields/outlined-field.jsx.map +1 -1
  57. package/dist/fields/text-entry.d.ts.map +1 -1
  58. package/dist/fields/text-entry.jsx +17 -1
  59. package/dist/fields/text-entry.jsx.map +1 -1
  60. package/dist/fields/use-text-input.d.ts +1 -1
  61. package/dist/guide/confirm-sheet.d.ts +26 -0
  62. package/dist/guide/confirm-sheet.d.ts.map +1 -0
  63. package/dist/guide/confirm-sheet.jsx +146 -0
  64. package/dist/guide/confirm-sheet.jsx.map +1 -0
  65. package/dist/guide/guide.css +428 -0
  66. package/dist/guide/guide.css.map +1 -0
  67. package/dist/guide/index.d.ts +5 -0
  68. package/dist/guide/index.d.ts.map +1 -0
  69. package/dist/guide/index.jsx +4 -0
  70. package/dist/guide/journey.d.ts +46 -0
  71. package/dist/guide/journey.d.ts.map +1 -0
  72. package/dist/guide/journey.jsx +462 -0
  73. package/dist/guide/journey.jsx.map +1 -0
  74. package/dist/guide/placement.d.ts +44 -0
  75. package/dist/guide/placement.d.ts.map +1 -0
  76. package/dist/guide/placement.jsx +119 -0
  77. package/dist/guide/placement.jsx.map +1 -0
  78. package/dist/guide/service.d.ts +95 -0
  79. package/dist/guide/service.d.ts.map +1 -0
  80. package/dist/guide/service.jsx +566 -0
  81. package/dist/guide/service.jsx.map +1 -0
  82. package/dist/guide/settings.d.ts +68 -0
  83. package/dist/guide/settings.d.ts.map +1 -0
  84. package/dist/guide/settings.jsx +66 -0
  85. package/dist/guide/settings.jsx.map +1 -0
  86. package/dist/host/host.d.ts +5 -1
  87. package/dist/host/host.d.ts.map +1 -1
  88. package/dist/host/host.jsx +12 -0
  89. package/dist/host/host.jsx.map +1 -1
  90. package/dist/host/layers.d.ts +3 -1
  91. package/dist/host/layers.d.ts.map +1 -1
  92. package/dist/host/layers.jsx +4 -2
  93. package/dist/host/layers.jsx.map +1 -1
  94. package/dist/host/registry.d.ts +3 -0
  95. package/dist/host/registry.d.ts.map +1 -1
  96. package/dist/host/registry.jsx.map +1 -1
  97. package/dist/index.d.ts +3 -0
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/provider/contexts.d.ts +3 -0
  100. package/dist/provider/contexts.d.ts.map +1 -1
  101. package/dist/provider/contexts.jsx.map +1 -1
  102. package/dist/provider/provider.d.ts.map +1 -1
  103. package/dist/provider/provider.jsx +24 -17
  104. package/dist/provider/provider.jsx.map +1 -1
  105. package/dist/provider/settings.d.ts +4 -0
  106. package/dist/provider/settings.d.ts.map +1 -1
  107. package/dist/provider/settings.jsx +3 -2
  108. package/dist/provider/settings.jsx.map +1 -1
  109. package/dist/route/hooks.d.ts +34 -0
  110. package/dist/route/hooks.d.ts.map +1 -0
  111. package/dist/route/hooks.jsx +147 -0
  112. package/dist/route/hooks.jsx.map +1 -0
  113. package/dist/route/index.d.ts +3 -0
  114. package/dist/route/index.d.ts.map +1 -0
  115. package/dist/route/index.jsx +2 -0
  116. package/dist/route/router.d.ts +201 -0
  117. package/dist/route/router.d.ts.map +1 -0
  118. package/dist/route/router.jsx +810 -0
  119. package/dist/route/router.jsx.map +1 -0
  120. package/dist/sheet/frame.d.ts +3 -1
  121. package/dist/sheet/frame.d.ts.map +1 -1
  122. package/dist/sheet/frame.jsx +67 -25
  123. package/dist/sheet/frame.jsx.map +1 -1
  124. package/dist/sheet/options.d.ts +10 -0
  125. package/dist/sheet/options.d.ts.map +1 -1
  126. package/dist/sheet/options.jsx.map +1 -1
  127. package/dist/sheet/service.d.ts +5 -0
  128. package/dist/sheet/service.d.ts.map +1 -1
  129. package/dist/sheet/service.jsx +14 -2
  130. package/dist/sheet/service.jsx.map +1 -1
  131. package/dist/sheet/sheet.css +9 -0
  132. package/dist/sheet/sheet.css.map +1 -1
  133. package/dist/tabs/tab-view.d.ts +14 -0
  134. package/dist/tabs/tab-view.d.ts.map +1 -1
  135. package/dist/tabs/tab-view.jsx +59 -3
  136. package/dist/tabs/tab-view.jsx.map +1 -1
  137. package/dist/toggle/checkbox.d.ts.map +1 -1
  138. package/dist/toggle/checkbox.jsx +15 -1
  139. package/dist/toggle/checkbox.jsx.map +1 -1
  140. package/dist/toggle/chip-group.d.ts.map +1 -1
  141. package/dist/toggle/chip-group.jsx +12 -1
  142. package/dist/toggle/chip-group.jsx.map +1 -1
  143. package/dist/toggle/switch.d.ts.map +1 -1
  144. package/dist/toggle/switch.jsx +15 -1
  145. package/dist/toggle/switch.jsx.map +1 -1
  146. package/package.json +17 -2
@@ -1 +1 @@
1
- {"version":3,"file":"tabs/tab-view.jsx","sources":["../../src/tabs/tab-view.tsx"],"sourcesContent":["import './tabs.css';\nimport { ViewPager, type ViewPagerRef } from '@lynx-js/lynx-ui-view-pager';\nimport { type ReactNode, useEffect, useMemo, useRef, useState } from '@lynx-js/react';\nimport { g9RowStyle } from '../base/control';\nimport { startTimer, stopTimer } from '../base/timers';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { G9ActivityIndicator } from '../display/activity-indicator';\nimport { type G9NodeRef, invokeNodeWhenReady } from '../fields/use-text-input';\nimport { G9IconSlot } from '../icon/slot';\nimport { useG9Culture, useG9Direction } from '../provider/hooks';\nimport {\n effectiveTabIndex,\n type G9TabBarPosition,\n type G9TabItem,\n type G9TabMode,\n G9TabRealizer,\n type G9TabStyle,\n g9TabViewMetrics,\n tabBadge,\n tabContentSlideFrom,\n tabKey,\n tabVisualOrder,\n thicknessCss,\n} from './model';\n\n/** Props of {@link G9TabView}. */\nexport interface G9TabViewProps {\n /** The tabs (MAUI `Items`). Add, remove or reorder freely; give tabs a `key` so their bodies follow them. */\n readonly items: readonly G9TabItem[];\n /** Controlled selection (MAUI `SelectedIndex`, two-way). Out-of-range values show the nearest tab. */\n readonly selectedIndex?: number;\n /** Initial selection while uncontrolled. Default 0. */\n readonly defaultSelectedIndex?: number;\n /** A tab was chosen by a tap or a swipe (MAUI `SelectionChanged`). */\n readonly onSelectionChange?: (index: number) => void;\n /** Bar height (MAUI `TabHeight`). Default 52. */\n readonly tabHeight?: number;\n /** Bar background (MAUI `TabBarBackground`). Default transparent (underlined) / surface-container-low (pill). */\n readonly tabBarBackground?: string | null;\n /** Underline colour (underlined) or active text colour (pill) (MAUI `IndicatorColor`). Default primary. */\n readonly indicatorColor?: string | null;\n /** `'fixed'` (default): equal full-width cells. `'scrollable'`: auto-width cells that scroll. */\n readonly mode?: G9TabMode;\n /** `'top'` (default) or `'bottom'`. */\n readonly barPosition?: G9TabBarPosition;\n /** `'underlined'` (default) or `'pill'` (MAUI `Style`). */\n readonly tabStyle?: G9TabStyle;\n /** Only the bar: no content panel; drive your own host from `onSelectionChange` (MAUI `HeaderOnly`). */\n readonly headerOnly?: boolean;\n /** Border and rounded corners around the content (MAUI `ShowFrame`). Default false. */\n readonly showFrame?: boolean;\n /** Content border radius when `showFrame` (MAUI `FrameCornerRadius`). Default 0. */\n readonly frameCornerRadius?: number;\n /** Inset around the active body (MAUI `ContentPadding`): one value, `[h, v]` or `[l, t, r, b]`. Default 10,10,10,0. */\n readonly contentPadding?: number | readonly number[];\n /** Build every body up front instead of lazily on first activation (MAUI `EagerContent`). Default false. */\n readonly eagerContent?: boolean;\n /** Swipe between bodies (lynx-ui ViewPager). A Lynx addition; default false, as in MAUI. */\n readonly swipeEnabled?: boolean;\n readonly className?: string;\n}\n\n/**\n * Tabs with a bar and lazily realized bodies (MAUI `G9TabView`). Underlined (default) or pill style, fixed or\n * scrollable cells, bar on top or bottom, header-only; the indicator slides between cells; bodies are built on first\n * activation (spinner, then {@link g9TabViewMetrics} `lazyRealizeDelayMs`) and kept, hidden, so scroll and form state\n * survive; RTL reverses the cell order. With `swipeEnabled` the bodies sit in a lynx-ui ViewPager.\n */\nexport function G9TabView(props: G9TabViewProps): ReactNode {\n const items = props.items;\n const tabStyle = props.tabStyle ?? 'underlined';\n const mode = props.mode ?? 'fixed';\n const barPosition = props.barPosition ?? 'top';\n const tabHeight = props.tabHeight ?? g9TabViewMetrics.tabHeight;\n const rtl = useG9Direction() === 'rtl';\n const culture = useG9Culture();\n const [selected, setSelected] = useControllableState<number>({\n value: props.selectedIndex,\n defaultValue: props.defaultSelectedIndex ?? 0,\n onChange: props.onSelectionChange,\n name: 'G9TabView.selectedIndex',\n });\n const count = items.length;\n const effective = effectiveTabIndex(selected, count);\n const keys = items.map((item, i) => tabKey(item, i));\n const activeKey = effective >= 0 ? (keys[effective] as string) : null;\n\n const eager = props.eagerContent === true;\n const eagerRef = useRef(eager);\n eagerRef.current = eager;\n const realizer = useMemo(() => new G9TabRealizer(() => eagerRef.current), []);\n realizer.retain(keys);\n const [, setVersion] = useState(0);\n const [pending, setPending] = useState<string | null>(null);\n\n // Lazy-once realization of the active body; rapid switches realize only the latest.\n useEffect(() => {\n if (activeKey === null || props.headerOnly) {\n setPending(null);\n return;\n }\n const token = realizer.activate(activeKey);\n if (token === 'shown') {\n setPending(null);\n return;\n }\n setPending(activeKey);\n const t = startTimer(() => {\n if (realizer.realize(token)) {\n setPending(null);\n setVersion((v) => v + 1);\n }\n }, g9TabViewMetrics.lazyRealizeDelayMs);\n return () => stopTimer(t);\n }, [activeKey, props.headerOnly]);\n\n // Directional reveal of the newly active body (6 px slide + fade, 160 ms CubicOut).\n const previous = useRef(-1);\n const [reveal, setReveal] = useState<{ key: string | null; from: number; settled: boolean }>({\n key: activeKey,\n from: 0,\n settled: true,\n });\n useEffect(() => {\n const prev = previous.current;\n previous.current = effective;\n if (prev === effective || prev < 0) return;\n setReveal({ key: activeKey, from: tabContentSlideFrom(prev, effective, rtl), settled: false });\n const t = startTimer(() => setReveal((r) => ({ ...r, settled: true })), 16);\n return () => stopTimer(t);\n }, [effective]);\n\n const select = (index: number) => {\n if (index !== effective) setSelected(index);\n };\n\n const pager = useRef<ViewPagerRef | null>(null);\n const swipe = props.swipeEnabled === true && !props.headerOnly;\n const order = tabVisualOrder(count, rtl);\n const visualIndex = order.indexOf(effective);\n useEffect(() => {\n if (!swipe || visualIndex < 0) return;\n try {\n pager.current?.scrollToPage(visualIndex, true);\n } catch {\n // The pager is gone (unmounted mid-switch).\n }\n }, [visualIndex, swipe]);\n\n const bar = (\n <TabBarStrip\n items={items}\n order={order}\n effective={effective}\n tabStyle={tabStyle}\n mode={mode}\n tabHeight={tabHeight}\n background={props.tabBarBackground ?? null}\n indicatorColor={props.indicatorColor ?? null}\n numbering={culture.numberingSystem}\n onSelect={select}\n />\n );\n\n const bodyOf = (index: number): ReactNode => {\n const item = items[index] as G9TabItem;\n const key = keys[index] as string;\n const active = index === effective;\n if (!realizer.isRealized(key)) {\n return active && pending === key ? <Spinner /> : null;\n }\n const revealing = active && reveal.key === key && !reveal.settled;\n const style = {\n display: (active || swipe ? 'flex' : 'none') as 'flex' | 'none',\n transform: `translateX(${revealing ? reveal.from : 0}px)`,\n opacity: revealing ? 0 : 1,\n transition:\n revealing || swipe\n ? 'none'\n : `transform ${g9TabViewMetrics.contentTransitionMs}ms ease-out, opacity ${g9TabViewMetrics.contentTransitionMs}ms ease-out`,\n };\n const content = typeof item.content === 'function' ? (item.content as () => ReactNode)() : item.content;\n return (\n <view key={key} className={`g9-tabs__panel${active ? ' g9-tabs__panel--active' : ''}`} style={style}>\n {content}\n </view>\n );\n };\n\n const frame = props.showFrame\n ? {\n borderWidth: '1px',\n borderStyle: 'solid',\n borderColor: 'var(--g9-outline-variant)',\n borderRadius: `${props.frameCornerRadius ?? 0}px`,\n }\n : {};\n const content = props.headerOnly ? null : (\n <view\n className=\"g9-tabs__content\"\n style={{ padding: thicknessCss(props.contentPadding ?? g9TabViewMetrics.contentPadding), ...frame }}\n >\n {swipe ? (\n <ViewPager\n ref={pager}\n className=\"g9-tabs__pager\"\n data={order}\n getItemKey={(index: number) => keys[index] as string}\n initialSelectIndex={Math.max(visualIndex, 0)}\n onPageChange={(event) => {\n const next = order[Number(event.detail.index)];\n if (next !== undefined) select(next);\n }}\n >\n {(index: number) => <view className=\"g9-tabs__page\">{bodyOf(index)}</view>}\n </ViewPager>\n ) : (\n <>\n {items.map((_, i) => bodyOf(i))}\n {pending !== null && pending === activeKey ? <Spinner /> : null}\n </>\n )}\n </view>\n );\n\n return (\n <view\n className={`g9-tabs g9-tabs--${tabStyle} g9-tabs--${barPosition}${props.headerOnly ? ' g9-tabs--header-only' : ''} ${props.className ?? ''}`}\n >\n {barPosition === 'bottom' ? content : null}\n {bar}\n {barPosition === 'top' ? content : null}\n </view>\n );\n}\n\nfunction Spinner(): ReactNode {\n return (\n <view className=\"g9-tabs__spinner\">\n <G9ActivityIndicator running size={24} />\n </view>\n );\n}\n\ninterface StripProps {\n readonly items: readonly G9TabItem[];\n readonly order: readonly number[];\n readonly effective: number;\n readonly tabStyle: G9TabStyle;\n readonly mode: G9TabMode;\n readonly tabHeight: number;\n readonly background: string | null;\n readonly indicatorColor: string | null;\n readonly numbering: Parameters<typeof tabBadge>[1];\n readonly onSelect: (index: number) => void;\n}\n\nfunction TabBarStrip(props: StripProps): ReactNode {\n const { items, order, effective, tabStyle, mode } = props;\n const count = order.length;\n const pill = tabStyle === 'pill';\n const direction = useG9Direction();\n const indicator = props.indicatorColor ?? 'var(--g9-primary)';\n const fixed = mode === 'fixed';\n const cellRefs = useRef<Array<G9NodeRef | null>>([]);\n useEffect(() => {\n if (fixed || effective < 0) return;\n invokeNodeWhenReady({ current: cellRefs.current[effective] ?? null }, 'scrollIntoView', {\n scrollIntoViewOptions: { behavior: 'smooth', block: 'center', inline: 'center' },\n });\n }, [effective, fixed]);\n\n const cells = order.map((index, position) => {\n const item = items[index] as G9TabItem;\n const active = index === effective;\n const badge = tabBadge(item, props.numbering);\n const textColor = active\n ? pill\n ? (props.indicatorColor ?? 'var(--g9-on-primary-container)')\n : 'var(--g9-on-surface)'\n : 'var(--g9-on-surface-variant)';\n return (\n <view\n key={tabKey(item, index)}\n ref={(node: G9NodeRef | null) => {\n cellRefs.current[index] = node;\n }}\n className={`g9-tabs__cell${active ? ' g9-tabs__cell--active' : ''}`}\n style={fixed ? { flex: '1' } : {}}\n accessibility-element\n accessibility-traits=\"button\"\n accessibility-label={item.text ?? ''}\n bindtap={() => props.onSelect(index)}\n >\n {/* Sibling order is paint order in Lynx: the active pill goes first, behind the label. */}\n {!fixed && active ? (\n <view\n className={pill ? 'g9-tabs__cell-pill' : 'g9-tabs__cell-underline'}\n style={pill ? {} : { backgroundColor: indicator }}\n />\n ) : null}\n {position > 0 && !pill ? <view className=\"g9-tabs__separator\" /> : null}\n <view className=\"g9-tabs__cell-row\" style={g9RowStyle(direction)}>\n <G9IconSlot\n emoji={item.emoji}\n icon={item.icon}\n imagePath={item.imagePath}\n image={item.image}\n size={18}\n color={textColor}\n />\n {item.text ? (\n <text className=\"g9-tabs__label\" style={{ color: textColor, fontWeight: active ? '600' : '400' }}>\n {item.text}\n </text>\n ) : null}\n {badge === 'dot' ? (\n <view className=\"g9-tabs__badge-dot\" style={{ backgroundColor: item.badgeColor ?? 'var(--g9-error)' }} />\n ) : badge !== null ? (\n // MAUI CreateBadge: `badgeColor ?? palette.Primary` (only the dot defaults to Error).\n <view className=\"g9-tabs__badge\" style={{ backgroundColor: item.badgeColor ?? 'var(--g9-primary)' }}>\n <text className=\"g9-tabs__badge-text\">{badge}</text>\n </view>\n ) : null}\n </view>\n </view>\n );\n });\n\n const position = order.indexOf(effective);\n const slider =\n fixed && position >= 0 ? (\n <view\n className={pill ? 'g9-tabs__pill' : 'g9-tabs__underline'}\n style={{\n left: `${(position * 100) / count}%`,\n width: `${100 / count}%`,\n transition: `left ${g9TabViewMetrics.indicatorMoveMs}ms cubic-bezier(0.215, 0.61, 0.355, 1)`,\n }}\n >\n <view\n className={pill ? 'g9-tabs__pill-fill' : 'g9-tabs__underline-fill'}\n style={pill ? {} : { backgroundColor: indicator }}\n />\n </view>\n ) : null;\n\n const barStyle = {\n height: `${props.tabHeight}px`,\n backgroundColor: props.background ?? (pill ? 'var(--g9-surface-container-low)' : 'transparent'),\n };\n return (\n <view className=\"g9-tabs__bar\" style={barStyle}>\n {fixed ? (\n <view className=\"g9-tabs__cells\">\n {slider}\n {cells}\n </view>\n ) : (\n <scroll-view className=\"g9-tabs__scroller\" scroll-orientation=\"horizontal\">\n <view className=\"g9-tabs__cells g9-tabs__cells--scrollable\">{cells}</view>\n </scroll-view>\n )}\n </view>\n );\n}\n"],"names":["G9TabView","props","_props_tabStyle","_props_mode","_props_barPosition","_props_tabHeight","_props_defaultSelectedIndex","_props_tabBarBackground","_props_indicatorColor","_props_frameCornerRadius","_props_contentPadding","_props_className","items","tabStyle","mode","barPosition","tabHeight","g9TabViewMetrics","rtl","useG9Direction","culture","useG9Culture","selected","setSelected","useControllableState","count","effective","effectiveTabIndex","keys","item","i","tabKey","activeKey","eager","eagerRef","useRef","realizer","useMemo","G9TabRealizer","setVersion","useState","pending","setPending","useEffect","token","t","startTimer","v","stopTimer","previous","reveal","setReveal","prev","tabContentSlideFrom","r","select","index","pager","swipe","order","tabVisualOrder","visualIndex","_pager_current","bar","TabBarStrip","bodyOf","key","active","Spinner","revealing","style","content","view","frame","thicknessCss","ViewPager","Math","event","next","Number","undefined","_","G9ActivityIndicator","_props_background","pill","direction","indicator","fixed","cellRefs","_cellRefs_current_effective","invokeNodeWhenReady","cells","position","_item_text","_item_badgeColor","_item_badgeColor1","badge","tabBadge","textColor","node","g9RowStyle","G9IconSlot","text","slider","barStyle","scroll-view"],"mappings":";;;;;;;;;;;AAoEO,SAASA,UAAUC,KAAqB;QAE5BC,iBACJC,aACOC,oBACFC,kBAKFC,6BA+EAC,yBACIC,uBAoCGC,0BAMYC,uBA2BsFC;IA9JzH,MAAMC,QAAQX,MAAM,KAAK;IACzB,MAAMY,WAAW,QAAAX,CAAAA,kBAAAA,MAAM,QAAQ,AAAD,IAAbA,kBAAkB;IACnC,MAAMY,OAAO,QAAAX,CAAAA,cAAAA,MAAM,IAAI,AAAD,IAATA,cAAc;IAC3B,MAAMY,cAAc,QAAAX,CAAAA,qBAAAA,MAAM,WAAW,AAAD,IAAhBA,qBAAqB;IACzC,MAAMY,YAAY,QAAAX,CAAAA,mBAAAA,MAAM,SAAS,AAAD,IAAdA,mBAAmBY,iBAAiB,SAAS;IAC/D,MAAMC,MAAMC,AAAqB,UAArBA;IACZ,MAAMC,UAAUC;IAChB,MAAM,CAACC,UAAUC,YAAY,GAAGC,qBAA6B;QAC3D,OAAOvB,MAAM,aAAa;QAC1B,cAAc,QAAAK,CAAAA,8BAAAA,MAAM,oBAAoB,AAAD,IAAzBA,8BAA8B;QAC5C,UAAUL,MAAM,iBAAiB;QACjC,MAAM;IACR;IACA,MAAMwB,QAAQb,MAAM,MAAM;IAC1B,MAAMc,YAAYC,kBAAkBL,UAAUG;IAC9C,MAAMG,OAAOhB,MAAM,GAAG,CAAC,CAACiB,MAAMC,IAAMC,OAAOF,MAAMC;IACjD,MAAME,YAAYN,aAAa,IAAKE,IAAI,CAACF,UAAU,GAAc;IAEjE,MAAMO,QAAQhC,AAAuB,SAAvBA,MAAM,YAAY;IAChC,MAAMiC,WAAWC,OAAOF;IACxBC,SAAS,OAAO,GAAGD;IACnB,MAAMG,WAAWC,QAAQ,IAAM,IAAIC,cAAc,IAAMJ,SAAS,OAAO,GAAG,EAAE;IAC5EE,SAAS,MAAM,CAAC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AWjC,MAAM,OAAO,CAACjC;IAC/B,MAAM6E,SACJhB,SAASK,YAAY,KAClBpB,KACC,WAAWY,OAAO,kBAAkB,sBACpC,OAAO;QACL,MAAM,GAAIQ,AAAW,MAAXA,WAAkBnE,MAAM,CAAC,CAAC;QACpC,OAAO,GAAG,MAAMA,MAAM,CAAC,CAAC;QACxB,YAAY,CAAC,KAAK,EAAER,iBAAiB,eAAe,CAAC,sCAAsC,CAAC;IAC9F,GACD;QACC,CAACuD,KACC,WAAWY,OAAO,uBAAuB,2BACzC,OAAOA,OAAO,CAAC,IAAI;QAAE,iBAAiBE;IAAU,IAChD;MACJ,EAAEd,QACA;IAEN,MAAMgC,WAAW;QACf,QAAQ,GAAGvG,MAAM,SAAS,CAAC,EAAE,CAAC;QAC9B,iBAAiB,QAAAkF,CAAAA,oBAAAA,MAAM,UAAU,AAAD,IAAfA,oBAAqBC,OAAO,oCAAoC;IACnF;IACA,QACGZ,KAAK,UAAU,eAAe,OAAOgC,UAAU;MAC9C,CAACjB,SACEf,KAAK,UAAU,iBAAiB;UAC/B,CAAC+B,OAAO;UACR,CAACZ,MAAM;QACT,EAAEnB,SAEDiC,YAAY,UAAU,oBAAoB,mBAAmB,aAAa;UACzE,CAACjC,KAAK,UAAU,6CAA6CmB,QAAQnB,KAAK;QAC5E,EAAEiC,aACF;IACJ,EAAEjC;AAEN"}
1
+ {"version":3,"file":"tabs/tab-view.jsx","sources":["../../src/tabs/tab-view.tsx"],"sourcesContent":["import './tabs.css';\nimport type { G9SegmentInput } from '@g9tm/lynxcontrols-foundation';\nimport { ViewPager, type ViewPagerRef } from '@lynx-js/lynx-ui-view-pager';\nimport { type ReactNode, useEffect, useMemo, useRef, useState } from '@lynx-js/react';\nimport { useG9Anchor, useG9AnchorRegistry } from '../anchor/hooks';\nimport { g9RowStyle } from '../base/control';\nimport { startTimer, stopTimer } from '../base/timers';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { G9ActivityIndicator } from '../display/activity-indicator';\nimport { type G9NodeRef, invokeNodeWhenReady } from '../fields/use-text-input';\nimport { G9IconSlot } from '../icon/slot';\nimport { useG9Culture, useG9Direction } from '../provider/hooks';\nimport { useG9Place } from '../route/hooks';\nimport {\n effectiveTabIndex,\n type G9TabBarPosition,\n type G9TabItem,\n type G9TabMode,\n G9TabRealizer,\n type G9TabStyle,\n g9TabViewMetrics,\n tabBadge,\n tabContentSlideFrom,\n tabKey,\n tabVisualOrder,\n thicknessCss,\n} from './model';\n\n/** Props of {@link G9TabView}. */\nexport interface G9TabViewProps {\n /**\n * Element `id` of the tab view: it registers as an anchor (`@g9tm/lynxcontrols/anchor`) that lists and selects its tabs,\n * and each tab cell as `${id}_Tab_${key}` (a guide can point at a tab, an automation can press it).\n */\n readonly id?: string;\n /**\n * The navigation place of the selected tab (`@g9tm/lynxcontrols/route`): a segment for its key, or null when the tab is\n * not a place of its own (the first tab of a header strip is often the page itself). Declared as an inner place; the\n * router leaves it by selecting the first tab.\n */\n readonly routeSegment?: (key: string) => G9SegmentInput | null;\n /** The tab view is on screen (a kept-alive page passes its own `active`). Default true. */\n readonly routeActive?: boolean;\n /** The tabs (MAUI `Items`). Add, remove or reorder freely; give tabs a `key` so their bodies follow them. */\n readonly items: readonly G9TabItem[];\n /** Controlled selection (MAUI `SelectedIndex`, two-way). Out-of-range values show the nearest tab. */\n readonly selectedIndex?: number;\n /** Initial selection while uncontrolled. Default 0. */\n readonly defaultSelectedIndex?: number;\n /** A tab was chosen by a tap or a swipe (MAUI `SelectionChanged`). */\n readonly onSelectionChange?: (index: number) => void;\n /** Bar height (MAUI `TabHeight`). Default 52. */\n readonly tabHeight?: number;\n /** Bar background (MAUI `TabBarBackground`). Default transparent (underlined) / surface-container-low (pill). */\n readonly tabBarBackground?: string | null;\n /** Underline colour (underlined) or active text colour (pill) (MAUI `IndicatorColor`). Default primary. */\n readonly indicatorColor?: string | null;\n /** `'fixed'` (default): equal full-width cells. `'scrollable'`: auto-width cells that scroll. */\n readonly mode?: G9TabMode;\n /** `'top'` (default) or `'bottom'`. */\n readonly barPosition?: G9TabBarPosition;\n /** `'underlined'` (default) or `'pill'` (MAUI `Style`). */\n readonly tabStyle?: G9TabStyle;\n /** Only the bar: no content panel; drive your own host from `onSelectionChange` (MAUI `HeaderOnly`). */\n readonly headerOnly?: boolean;\n /** Border and rounded corners around the content (MAUI `ShowFrame`). Default false. */\n readonly showFrame?: boolean;\n /** Content border radius when `showFrame` (MAUI `FrameCornerRadius`). Default 0. */\n readonly frameCornerRadius?: number;\n /** Inset around the active body (MAUI `ContentPadding`): one value, `[h, v]` or `[l, t, r, b]`. Default 10,10,10,0. */\n readonly contentPadding?: number | readonly number[];\n /** Build every body up front instead of lazily on first activation (MAUI `EagerContent`). Default false. */\n readonly eagerContent?: boolean;\n /** Swipe between bodies (lynx-ui ViewPager). A Lynx addition; default false, as in MAUI. */\n readonly swipeEnabled?: boolean;\n readonly className?: string;\n}\n\n/**\n * Tabs with a bar and lazily realized bodies (MAUI `G9TabView`). Underlined (default) or pill style, fixed or\n * scrollable cells, bar on top or bottom, header-only; the indicator slides between cells; bodies are built on first\n * activation (spinner, then {@link g9TabViewMetrics} `lazyRealizeDelayMs`) and kept, hidden, so scroll and form state\n * survive; RTL reverses the cell order. With `swipeEnabled` the bodies sit in a lynx-ui ViewPager.\n */\nexport function G9TabView(props: G9TabViewProps): ReactNode {\n const items = props.items;\n const tabStyle = props.tabStyle ?? 'underlined';\n const mode = props.mode ?? 'fixed';\n const barPosition = props.barPosition ?? 'top';\n const tabHeight = props.tabHeight ?? g9TabViewMetrics.tabHeight;\n const rtl = useG9Direction() === 'rtl';\n const culture = useG9Culture();\n const [selected, setSelected] = useControllableState<number>({\n value: props.selectedIndex,\n defaultValue: props.defaultSelectedIndex ?? 0,\n onChange: props.onSelectionChange,\n name: 'G9TabView.selectedIndex',\n });\n const count = items.length;\n const effective = effectiveTabIndex(selected, count);\n const keys = items.map((item, i) => tabKey(item, i));\n const activeKey = effective >= 0 ? (keys[effective] as string) : null;\n\n const eager = props.eagerContent === true;\n const eagerRef = useRef(eager);\n eagerRef.current = eager;\n const realizer = useMemo(() => new G9TabRealizer(() => eagerRef.current), []);\n realizer.retain(keys);\n const [, setVersion] = useState(0);\n const [pending, setPending] = useState<string | null>(null);\n\n // Lazy-once realization of the active body; rapid switches realize only the latest.\n useEffect(() => {\n if (activeKey === null || props.headerOnly) {\n setPending(null);\n return;\n }\n const token = realizer.activate(activeKey);\n if (token === 'shown') {\n setPending(null);\n return;\n }\n setPending(activeKey);\n const t = startTimer(() => {\n if (realizer.realize(token)) {\n setPending(null);\n setVersion((v) => v + 1);\n }\n }, g9TabViewMetrics.lazyRealizeDelayMs);\n return () => stopTimer(t);\n }, [activeKey, props.headerOnly]);\n\n // Directional reveal of the newly active body (6 px slide + fade, 160 ms CubicOut).\n const previous = useRef(-1);\n const [reveal, setReveal] = useState<{ key: string | null; from: number; settled: boolean }>({\n key: activeKey,\n from: 0,\n settled: true,\n });\n useEffect(() => {\n const prev = previous.current;\n previous.current = effective;\n if (prev === effective || prev < 0) return;\n setReveal({ key: activeKey, from: tabContentSlideFrom(prev, effective, rtl), settled: false });\n const t = startTimer(() => setReveal((r) => ({ ...r, settled: true })), 16);\n return () => stopTimer(t);\n }, [effective]);\n\n const select = (index: number) => {\n if (index !== effective) setSelected(index);\n };\n const anchor = useG9Anchor(\n props.id,\n {\n kind: 'tab-view',\n capabilities: {\n itemKeys: () => keys,\n getValue: () => activeKey,\n selectItem: (key) => {\n const at = keys.indexOf(key);\n if (at >= 0) select(at);\n },\n },\n },\n props.id ? { domId: props.id } : {},\n );\n const routeSegment = activeKey !== null && props.routeSegment ? props.routeSegment(activeKey) : null;\n useG9Place(routeSegment ? { segment: routeSegment, layer: 'inner', close: () => select(0) } : null, {\n active: props.routeActive ?? true,\n });\n\n const pager = useRef<ViewPagerRef | null>(null);\n const swipe = props.swipeEnabled === true && !props.headerOnly;\n const order = tabVisualOrder(count, rtl);\n const visualIndex = order.indexOf(effective);\n useEffect(() => {\n if (!swipe || visualIndex < 0) return;\n try {\n pager.current?.scrollToPage(visualIndex, true);\n } catch {\n // The pager is gone (unmounted mid-switch).\n }\n }, [visualIndex, swipe]);\n\n const bar = (\n <TabBarStrip\n items={items}\n order={order}\n effective={effective}\n tabStyle={tabStyle}\n mode={mode}\n tabHeight={tabHeight}\n background={props.tabBarBackground ?? null}\n indicatorColor={props.indicatorColor ?? null}\n numbering={culture.numberingSystem}\n onSelect={select}\n anchorId={props.id ?? null}\n />\n );\n\n const bodyOf = (index: number): ReactNode => {\n const item = items[index] as G9TabItem;\n const key = keys[index] as string;\n const active = index === effective;\n if (!realizer.isRealized(key)) {\n return active && pending === key ? <Spinner /> : null;\n }\n const revealing = active && reveal.key === key && !reveal.settled;\n const style = {\n display: (active || swipe ? 'flex' : 'none') as 'flex' | 'none',\n transform: `translateX(${revealing ? reveal.from : 0}px)`,\n opacity: revealing ? 0 : 1,\n transition:\n revealing || swipe\n ? 'none'\n : `transform ${g9TabViewMetrics.contentTransitionMs}ms ease-out, opacity ${g9TabViewMetrics.contentTransitionMs}ms ease-out`,\n };\n const content = typeof item.content === 'function' ? (item.content as () => ReactNode)() : item.content;\n return (\n <view key={key} className={`g9-tabs__panel${active ? ' g9-tabs__panel--active' : ''}`} style={style}>\n {content}\n </view>\n );\n };\n\n const frame = props.showFrame\n ? {\n borderWidth: '1px',\n borderStyle: 'solid',\n borderColor: 'var(--g9-outline-variant)',\n borderRadius: `${props.frameCornerRadius ?? 0}px`,\n }\n : {};\n const content = props.headerOnly ? null : (\n <view\n className=\"g9-tabs__content\"\n style={{ padding: thicknessCss(props.contentPadding ?? g9TabViewMetrics.contentPadding), ...frame }}\n >\n {swipe ? (\n <ViewPager\n ref={pager}\n className=\"g9-tabs__pager\"\n data={order}\n getItemKey={(index: number) => keys[index] as string}\n initialSelectIndex={Math.max(visualIndex, 0)}\n onPageChange={(event) => {\n const next = order[Number(event.detail.index)];\n if (next !== undefined) select(next);\n }}\n >\n {(index: number) => <view className=\"g9-tabs__page\">{bodyOf(index)}</view>}\n </ViewPager>\n ) : (\n <>\n {items.map((_, i) => bodyOf(i))}\n {pending !== null && pending === activeKey ? <Spinner /> : null}\n </>\n )}\n </view>\n );\n\n return (\n <view\n {...anchor.props}\n className={`g9-tabs g9-tabs--${tabStyle} g9-tabs--${barPosition}${props.headerOnly ? ' g9-tabs--header-only' : ''} ${props.className ?? ''}`}\n >\n {barPosition === 'bottom' ? content : null}\n {bar}\n {barPosition === 'top' ? content : null}\n </view>\n );\n}\n\nfunction Spinner(): ReactNode {\n return (\n <view className=\"g9-tabs__spinner\">\n <G9ActivityIndicator running size={24} />\n </view>\n );\n}\n\ninterface StripProps {\n readonly items: readonly G9TabItem[];\n readonly order: readonly number[];\n readonly effective: number;\n readonly tabStyle: G9TabStyle;\n readonly mode: G9TabMode;\n readonly tabHeight: number;\n readonly background: string | null;\n readonly indicatorColor: string | null;\n readonly numbering: Parameters<typeof tabBadge>[1];\n readonly onSelect: (index: number) => void;\n /** The tab view's anchor id: each cell registers as `${anchorId}_Tab_${key}`. */\n readonly anchorId: string | null;\n}\n\nfunction TabBarStrip(props: StripProps): ReactNode {\n const { items, order, effective, tabStyle, mode } = props;\n const count = order.length;\n const pill = tabStyle === 'pill';\n const direction = useG9Direction();\n const indicator = props.indicatorColor ?? 'var(--g9-primary)';\n const fixed = mode === 'fixed';\n const cellRefs = useRef<Array<G9NodeRef | null>>([]);\n const registry = useG9AnchorRegistry();\n const latest = useRef(props);\n latest.current = props;\n const cellKeys = items.map((item, i) => tabKey(item, i)).join('|');\n useEffect(() => {\n const base = props.anchorId;\n if (!registry || !base) return undefined;\n const offs = latest.current.items.map((item, index) =>\n registry.register(\n `${base}_Tab_${tabKey(item, index)}`,\n () => ({\n kind: 'tab',\n label: () => latest.current.items[index]?.text ?? null,\n capabilities: { activate: () => latest.current.onSelect(index) },\n }),\n { node: () => cellRefs.current[index] ?? null, scrollerId: null, layer: 'page' },\n ),\n );\n return () => {\n for (const off of offs) off();\n };\n }, [registry, props.anchorId, cellKeys]);\n useEffect(() => {\n if (fixed || effective < 0) return;\n invokeNodeWhenReady({ current: cellRefs.current[effective] ?? null }, 'scrollIntoView', {\n scrollIntoViewOptions: { behavior: 'smooth', block: 'center', inline: 'center' },\n });\n }, [effective, fixed]);\n\n const cells = order.map((index, position) => {\n const item = items[index] as G9TabItem;\n const active = index === effective;\n const badge = tabBadge(item, props.numbering);\n const textColor = active\n ? pill\n ? (props.indicatorColor ?? 'var(--g9-on-primary-container)')\n : 'var(--g9-on-surface)'\n : 'var(--g9-on-surface-variant)';\n return (\n <view\n key={tabKey(item, index)}\n ref={(node: G9NodeRef | null) => {\n cellRefs.current[index] = node;\n }}\n className={`g9-tabs__cell${active ? ' g9-tabs__cell--active' : ''}`}\n style={fixed ? { flex: '1' } : {}}\n accessibility-element\n accessibility-traits=\"button\"\n accessibility-label={item.text ?? ''}\n bindtap={() => props.onSelect(index)}\n >\n {/* Sibling order is paint order in Lynx: the active pill goes first, behind the label. */}\n {!fixed && active ? (\n <view\n className={pill ? 'g9-tabs__cell-pill' : 'g9-tabs__cell-underline'}\n style={pill ? {} : { backgroundColor: indicator }}\n />\n ) : null}\n {position > 0 && !pill ? <view className=\"g9-tabs__separator\" /> : null}\n <view className=\"g9-tabs__cell-row\" style={g9RowStyle(direction)}>\n <G9IconSlot\n emoji={item.emoji}\n icon={item.icon}\n imagePath={item.imagePath}\n image={item.image}\n size={18}\n color={textColor}\n />\n {item.text ? (\n <text className=\"g9-tabs__label\" style={{ color: textColor, fontWeight: active ? '600' : '400' }}>\n {item.text}\n </text>\n ) : null}\n {badge === 'dot' ? (\n <view className=\"g9-tabs__badge-dot\" style={{ backgroundColor: item.badgeColor ?? 'var(--g9-error)' }} />\n ) : badge !== null ? (\n // MAUI CreateBadge: `badgeColor ?? palette.Primary` (only the dot defaults to Error).\n <view className=\"g9-tabs__badge\" style={{ backgroundColor: item.badgeColor ?? 'var(--g9-primary)' }}>\n <text className=\"g9-tabs__badge-text\">{badge}</text>\n </view>\n ) : null}\n </view>\n </view>\n );\n });\n\n const position = order.indexOf(effective);\n const slider =\n fixed && position >= 0 ? (\n <view\n className={pill ? 'g9-tabs__pill' : 'g9-tabs__underline'}\n style={{\n left: `${(position * 100) / count}%`,\n width: `${100 / count}%`,\n transition: `left ${g9TabViewMetrics.indicatorMoveMs}ms cubic-bezier(0.215, 0.61, 0.355, 1)`,\n }}\n >\n <view\n className={pill ? 'g9-tabs__pill-fill' : 'g9-tabs__underline-fill'}\n style={pill ? {} : { backgroundColor: indicator }}\n />\n </view>\n ) : null;\n\n const barStyle = {\n height: `${props.tabHeight}px`,\n backgroundColor: props.background ?? (pill ? 'var(--g9-surface-container-low)' : 'transparent'),\n };\n return (\n <view className=\"g9-tabs__bar\" style={barStyle}>\n {fixed ? (\n <view className=\"g9-tabs__cells\">\n {slider}\n {cells}\n </view>\n ) : (\n <scroll-view className=\"g9-tabs__scroller\" scroll-orientation=\"horizontal\">\n <view className=\"g9-tabs__cells g9-tabs__cells--scrollable\">{cells}</view>\n </scroll-view>\n )}\n </view>\n );\n}\n"],"names":["G9TabView","props","_props_tabStyle","_props_mode","_props_barPosition","_props_tabHeight","_props_defaultSelectedIndex","_props_routeActive","_props_tabBarBackground","_props_indicatorColor","_props_id","_props_frameCornerRadius","_props_contentPadding","_props_className","items","tabStyle","mode","barPosition","tabHeight","g9TabViewMetrics","rtl","useG9Direction","culture","useG9Culture","selected","setSelected","useControllableState","count","effective","effectiveTabIndex","keys","item","i","tabKey","activeKey","eager","eagerRef","useRef","realizer","useMemo","G9TabRealizer","setVersion","useState","pending","setPending","useEffect","token","t","startTimer","v","stopTimer","previous","reveal","setReveal","prev","tabContentSlideFrom","r","select","index","anchor","useG9Anchor","key","at","routeSegment","useG9Place","pager","swipe","order","tabVisualOrder","visualIndex","_pager_current","bar","TabBarStrip","bodyOf","active","Spinner","revealing","style","content","view","frame","thicknessCss","ViewPager","Math","event","next","Number","undefined","_","G9ActivityIndicator","_props_background","pill","direction","indicator","fixed","cellRefs","registry","useG9AnchorRegistry","latest","cellKeys","base","offs","_latest_current_items_index","_cellRefs_current_index","off","_cellRefs_current_effective","invokeNodeWhenReady","cells","position","_item_text","_item_badgeColor","_item_badgeColor1","badge","tabBadge","textColor","node","g9RowStyle","G9IconSlot","text","slider","barStyle","scroll-view"],"mappings":";;;;;;;;;;;;;AAoFO,SAASA,UAAUC,KAAqB;QAE5BC,iBACJC,aACOC,oBACFC,kBAKFC,6BA0ENC,oBAwBMC,yBACIC,uBAGNC,WAkCSC,0BAMYC,uBA4BsFC;IAnLzH,MAAMC,QAAQb,MAAM,KAAK;IACzB,MAAMc,WAAW,QAAAb,CAAAA,kBAAAA,MAAM,QAAQ,AAAD,IAAbA,kBAAkB;IACnC,MAAMc,OAAO,QAAAb,CAAAA,cAAAA,MAAM,IAAI,AAAD,IAATA,cAAc;IAC3B,MAAMc,cAAc,QAAAb,CAAAA,qBAAAA,MAAM,WAAW,AAAD,IAAhBA,qBAAqB;IACzC,MAAMc,YAAY,QAAAb,CAAAA,mBAAAA,MAAM,SAAS,AAAD,IAAdA,mBAAmBc,iBAAiB,SAAS;IAC/D,MAAMC,MAAMC,AAAqB,UAArBA;IACZ,MAAMC,UAAUC;IAChB,MAAM,CAACC,UAAUC,YAAY,GAAGC,qBAA6B;QAC3D,OAAOzB,MAAM,aAAa;QAC1B,cAAc,QAAAK,CAAAA,8BAAAA,MAAM,oBAAoB,AAAD,IAAzBA,8BAA8B;QAC5C,UAAUL,MAAM,iBAAiB;QACjC,MAAM;IACR;IACA,MAAM0B,QAAQb,MAAM,MAAM;IAC1B,MAAMc,YAAYC,kBAAkBL,UAAUG;IAC9C,MAAMG,OAAOhB,MAAM,GAAG,CAAC,CAACiB,MAAMC,IAAMC,OAAOF,MAAMC;IACjD,MAAME,YAAYN,aAAa,IAAKE,IAAI,CAACF,UAAU,GAAc;IAEjE,MAAMO,QAAQlC,AAAuB,SAAvBA,MAAM,YAAY;IAChC,MAAMmC,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IACzD,mDAAmD;IACnD,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,2GAA2G;IAC3G,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtD,wEAAwE;IACxE,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IACxC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,KAAK,IAAI,CAAC;IAClE,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,oEAAoE;IACpE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC9C,gGAAgG;IAChG,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CACvC;AAED,+CAA+C;AAC/C,MAAM,WAAW,gBAAgB;IAC/B,6DAA6D;IAC7D,MAAM,IAAI,IAAI,CAAC;CAChB;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,8GAmIrB,CAAC"}
@@ -42,7 +42,21 @@ function checkBoxSvg(progress, morph, colors, disabled) {
42
42
  }
43
43
  const checkbox_G9CheckBox = forwardRef(function(props, ref) {
44
44
  var _props_defaultChecked, _props_defaultIndeterminate, _props_accessibilityLabel, _ref, _props_accessibilityLabel1;
45
- const control = useG9Control(props, 'g9-checkbox');
45
+ const control = useG9Control(props, 'g9-checkbox', {
46
+ kind: 'toggle',
47
+ label: ()=>{
48
+ var _props_accessibilityLabel;
49
+ return null != (_props_accessibilityLabel = props.accessibilityLabel) ? _props_accessibilityLabel : props.text;
50
+ },
51
+ capabilities: {
52
+ activate: ()=>press(),
53
+ getValue: ()=>String(checked),
54
+ setValue: (v)=>{
55
+ if ('true' === v !== checked) press();
56
+ return String('true' === v);
57
+ }
58
+ }
59
+ });
46
60
  const palette = useG9Theme().palette;
47
61
  const strings = useG9Strings();
48
62
  const [checked, setChecked] = useControllableState({
@@ -1 +1 @@
1
- {"version":3,"file":"toggle/checkbox.jsx","sources":["../../src/toggle/checkbox.tsx"],"sourcesContent":["import './toggle.css';\nimport { formatColor, type G9PaletteValues, G9StringKey, withAlpha } from '@g9tm/lynxcontrols-foundation';\nimport { forwardRef, type ReactNode, useEffect, useImperativeHandle, useRef } from '@lynx-js/react';\nimport type { NodesRef } from '@lynx-js/types';\nimport { type G9ControlBaseProps, g9RowStyle, g9TextStart, useG9Control } from '../base/control';\nimport { useG9Press } from '../base/press';\nimport { type G9TimerHandle, startTimer, stopTimer } from '../base/timers';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { useG9Strings, useG9Theme } from '../provider/hooks';\nimport { checkMarkPath, fillAmount, nextOnTap, targetMorph, targetProgress } from './checkbox-math';\n\n/** Box size, corner and stroke (MAUI `G9Metrics` check-box values, ADR-0028). */\nexport const g9CheckBoxMetrics = Object.freeze({\n box: 20,\n corner: 6,\n stroke: 2,\n touchTarget: 48,\n progressMs: 200,\n morphMs: 150,\n});\n\n/** Colours the box is drawn with. */\nexport interface G9CheckBoxColors {\n readonly outline: string;\n readonly fill: string;\n readonly mark: string;\n}\n\n/** The palette colours of a check box (outline, fill, mark; disabled variants). */\nexport function checkBoxColors(palette: G9PaletteValues, disabled: boolean): G9CheckBoxColors {\n return {\n outline: palette.Outline,\n fill: disabled ? palette.TextDisabled : palette.Primary,\n mark: disabled ? palette.Surface : palette.OnPrimary,\n };\n}\n\n/**\n * The SVG of the box at an animation state (MAUI `G9CheckBoxDrawable`): the outline fades with `1 − fill`\n * (× 0.55 disabled), the fill grows from 78 % to 100 % with its alpha, the mark (tick → dash by `morph`) is trimmed by\n * the golden phase functions. Never mirrored in RTL.\n */\nexport function checkBoxSvg(progress: number, morph: number, colors: G9CheckBoxColors, disabled: boolean): string {\n const m = g9CheckBoxMetrics;\n const fill = fillAmount(progress);\n const outlineAlpha = (1 - fill) * (disabled ? 0.55 : 1);\n const scale = 0.78 + 0.22 * fill;\n const side = m.box * scale;\n const offset = (m.box - side) / 2;\n const r = (n: number) => Math.round(n * 1000) / 1000;\n const parts = [\n `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${m.box}\" height=\"${m.box}\" viewBox=\"0 0 ${m.box} ${m.box}\">`,\n ];\n if (outlineAlpha > 0.001) {\n parts.push(\n `<rect x=\"1\" y=\"1\" width=\"${m.box - 2}\" height=\"${m.box - 2}\" rx=\"${m.corner - 1}\" fill=\"none\" stroke=\"${formatColor(withAlpha(colors.outline, outlineAlpha))}\" stroke-width=\"${m.stroke}\"/>`,\n );\n }\n if (fill > 0.001) {\n parts.push(\n `<rect x=\"${r(offset)}\" y=\"${r(offset)}\" width=\"${r(side)}\" height=\"${r(side)}\" rx=\"${r(m.corner * scale)}\" fill=\"${formatColor(withAlpha(colors.fill, fill))}\"/>`,\n );\n }\n const path = checkMarkPath(progress, morph, m.box);\n if (path) {\n parts.push(\n `<path d=\"${path}\" fill=\"none\" stroke=\"${formatColor(colors.mark)}\" stroke-width=\"${m.stroke}\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>`,\n );\n }\n parts.push('</svg>');\n return parts.join('');\n}\n\n/** Props of {@link G9CheckBox} (MAUI `G9CheckBox`). */\nexport interface G9CheckBoxProps extends G9ControlBaseProps {\n /** Controlled checked state (MAUI `IsChecked`). */\n readonly checked?: boolean;\n readonly defaultChecked?: boolean;\n /** Once per change of `checked` caused by the control (MAUI `CheckedChanged`); never for pushed values. */\n readonly onCheckedChange?: (checked: boolean) => void;\n /** Controlled third state (MAUI `IsIndeterminate`); a tap clears it. */\n readonly indeterminate?: boolean;\n readonly defaultIndeterminate?: boolean;\n readonly onIndeterminateChange?: (indeterminate: boolean) => void;\n /** Label at the end side; also the accessibility name. */\n readonly text?: string | null;\n /** After every user toggle, with the new state (MAUI `Command`). */\n readonly onPress?: (checked: boolean) => void;\n /** 48 px touch slot with the box at the top; false: a 20 px slot, box centred. Default true. */\n readonly reserveTouchTarget?: boolean;\n}\n\n/** Imperative handle of {@link G9CheckBox}. */\nexport interface G9CheckBoxHandle {\n /** Same as a tap (MAUI `Toggle`); ignored while disabled. */\n toggle(): void;\n}\n\n/**\n * Tri-state check box (MAUI `G9CheckBox`, ADR-0028): tap toggles, indeterminate → checked, never into\n * indeterminate. The box animates (200 ms fill/tick, 150 ms tick↔dash) by updating the SVG attribute directly\n * (`setNativeProps`), never by re-rendering per frame; the first render does not animate.\n */\nexport const G9CheckBox = forwardRef<G9CheckBoxHandle, G9CheckBoxProps>(function G9CheckBox(props, ref): ReactNode {\n const control = useG9Control(props, 'g9-checkbox');\n const palette = useG9Theme().palette;\n const strings = useG9Strings();\n const [checked, setChecked] = useControllableState<boolean>({\n value: props.checked,\n defaultValue: props.defaultChecked ?? false,\n onChange: props.onCheckedChange,\n name: 'G9CheckBox.checked',\n });\n const [indeterminate, setIndeterminate] = useControllableState<boolean>({\n value: props.indeterminate,\n defaultValue: props.defaultIndeterminate ?? false,\n onChange: props.onIndeterminateChange,\n name: 'G9CheckBox.indeterminate',\n });\n const colors = checkBoxColors(palette, control.disabled);\n const progressTarget = targetProgress(checked, indeterminate);\n const morphTarget = targetMorph(indeterminate);\n\n // Animation state lives outside React: the drawn progress/morph and the frame timer.\n const svgRef = useRef<NodesRef | null>(null);\n const drawn = useRef({ progress: progressTarget, morph: morphTarget });\n const frame = useRef<G9TimerHandle | null>(null);\n const latest = useRef({ colors, disabled: control.disabled });\n latest.current = { colors, disabled: control.disabled };\n useEffect(() => {\n const from = { ...drawn.current };\n if (from.progress === progressTarget && from.morph === morphTarget) return;\n // Unchecked → indeterminate draws the dash directly; a fade-out keeps the current mark shape.\n const morphFrom = from.progress < 0.01 ? morphTarget : from.morph;\n const morphTo = progressTarget === 0 ? morphFrom : morphTarget;\n const started = Date.now();\n const step = () => {\n const t = Date.now() - started;\n const p = Math.min(1, t / g9CheckBoxMetrics.progressMs);\n const q = Math.min(1, t / g9CheckBoxMetrics.morphMs);\n const easeOut = 1 - (1 - p) ** 3;\n const easeInOut = q < 0.5 ? 4 * q * q * q : 1 - (-2 * q + 2) ** 3 / 2;\n drawn.current = {\n progress: from.progress + (progressTarget - from.progress) * easeOut,\n morph: morphFrom + (morphTo - morphFrom) * easeInOut,\n };\n try {\n svgRef.current\n ?.setNativeProps({\n content: checkBoxSvg(\n drawn.current.progress,\n drawn.current.morph,\n latest.current.colors,\n latest.current.disabled,\n ),\n })\n .exec();\n } catch {\n // Unmounted between frames.\n }\n frame.current = p < 1 || q < 1 ? startTimer(step, 16) : null;\n };\n if (frame.current !== null) stopTimer(frame.current);\n step();\n return () => {\n if (frame.current !== null) stopTimer(frame.current);\n frame.current = null;\n };\n }, [progressTarget, morphTarget]);\n\n const toggle = () => {\n if (control.disabled) return;\n const next = nextOnTap(checked, indeterminate);\n setIndeterminate(next.indeterminate);\n setChecked(next.checked);\n props.onPress?.(next.checked);\n };\n useImperativeHandle(ref, () => ({ toggle }));\n const press = useG9Press(toggle, { blocked: control.disabled, source: 'G9CheckBox', guardMs: 0 });\n\n const reserve = props.reserveTouchTarget !== false;\n const text = props.text && props.text.trim() !== '' ? props.text : null;\n const state = indeterminate\n ? strings.get(G9StringKey.PartiallyChecked)\n : checked\n ? strings.get(G9StringKey.Checked)\n : strings.get(G9StringKey.NotChecked);\n return (\n <view\n className={`${control.className}${text ? ' g9-checkbox--labelled' : ''}`}\n {...control.idProps}\n style={g9RowStyle(control.direction)}\n accessibility-element={true}\n accessibility-traits=\"button\"\n accessibility-value={state}\n {...((props.accessibilityLabel ?? text) ? { 'accessibility-label': props.accessibilityLabel ?? text ?? '' } : {})}\n bindtap={press}\n >\n <view\n className={`g9-checkbox__slot${reserve ? ' g9-checkbox__slot--reserve' : ''}`}\n style={{ width: `${reserve ? g9CheckBoxMetrics.touchTarget : g9CheckBoxMetrics.box}px` }}\n >\n <svg\n ref={svgRef}\n className=\"g9-checkbox__box\"\n content={checkBoxSvg(drawn.current.progress, drawn.current.morph, colors, control.disabled)}\n />\n </view>\n {text ? (\n <text\n className=\"g9-checkbox__text\"\n style={{\n ...g9TextStart(control.direction),\n color: control.disabled ? 'var(--g9-text-disabled)' : 'var(--g9-text-primary)',\n paddingTop: reserve ? '12px' : '0px',\n paddingBottom: reserve ? '12px' : '0px',\n }}\n >\n {text}\n </text>\n ) : null}\n </view>\n );\n});\n"],"names":["g9CheckBoxMetrics","Object","checkBoxColors","palette","disabled","checkBoxSvg","progress","morph","colors","m","fill","fillAmount","outlineAlpha","scale","side","offset","r","n","Math","parts","formatColor","withAlpha","path","checkMarkPath","G9CheckBox","forwardRef","props","ref","_props_defaultChecked","_props_defaultIndeterminate","_props_accessibilityLabel","_ref","control","useG9Control","useG9Theme","strings","useG9Strings","checked","setChecked","useControllableState","indeterminate","setIndeterminate","progressTarget","targetProgress","morphTarget","targetMorph","svgRef","useRef","drawn","frame","latest","useEffect","from","morphFrom","morphTo","started","Date","step","t","p","q","easeOut","easeInOut","_svgRef_current","startTimer","stopTimer","toggle","next","nextOnTap","useImperativeHandle","press","useG9Press","reserve","text1","state","G9StringKey","view","g9RowStyle","svg","text","g9TextStart"],"mappings":";;;;;;;;;AAYO,MAAMA,oBAAoBC,OAAO,MAAM,CAAC;IAC7C,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,aAAa;IACb,YAAY;IACZ,SAAS;AACX;AAUO,SAASC,eAAeC,OAAwB,EAAEC,QAAiB;IACxE,OAAO;QACL,SAASD,QAAQ,OAAO;QACxB,MAAMC,WAAWD,QAAQ,YAAY,GAAGA,QAAQ,OAAO;QACvD,MAAMC,WAAWD,QAAQ,OAAO,GAAGA,QAAQ,SAAS;IACtD;AACF;AAOO,SAASE,YAAYC,QAAgB,EAAEC,KAAa,EAAEC,MAAwB,EAAEJ,QAAiB;IACtG,MAAMK,IAAIT;IACV,MAAMU,OAAOC,WAAWL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YAAY2C,MAAM,OAAO,CAAC,QAAQ,EAAEA,MAAM,OAAO,CAAC,KAAK,EAAExC,QAAQwB,QAAQ,QAAQ,IAC1F;MACJ,EAAE4C,KAAK;MACP,CAACH,SACEM,KACC,UAAU,oBACV,OAAO;QACL,GAAGC,YAAYhD,QAAQ,SAAS,CAAC;QACjC,OAAOA,QAAQ,QAAQ,GAAG,4BAA4B;QACtD,YAAYwC,UAAU,SAAS;QAC/B,eAAeA,UAAU,SAAS;IACpC,GACD;UACC,CAACC,MAAK;QACR,EAAEM,QACA,KAAK;IACX,EAAEH;AAEN"}
1
+ {"version":3,"file":"toggle/checkbox.jsx","sources":["../../src/toggle/checkbox.tsx"],"sourcesContent":["import './toggle.css';\nimport { formatColor, type G9PaletteValues, G9StringKey, withAlpha } from '@g9tm/lynxcontrols-foundation';\nimport { forwardRef, type ReactNode, useEffect, useImperativeHandle, useRef } from '@lynx-js/react';\nimport type { NodesRef } from '@lynx-js/types';\nimport { type G9ControlBaseProps, g9RowStyle, g9TextStart, useG9Control } from '../base/control';\nimport { useG9Press } from '../base/press';\nimport { type G9TimerHandle, startTimer, stopTimer } from '../base/timers';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { useG9Strings, useG9Theme } from '../provider/hooks';\nimport { checkMarkPath, fillAmount, nextOnTap, targetMorph, targetProgress } from './checkbox-math';\n\n/** Box size, corner and stroke (MAUI `G9Metrics` check-box values, ADR-0028). */\nexport const g9CheckBoxMetrics = Object.freeze({\n box: 20,\n corner: 6,\n stroke: 2,\n touchTarget: 48,\n progressMs: 200,\n morphMs: 150,\n});\n\n/** Colours the box is drawn with. */\nexport interface G9CheckBoxColors {\n readonly outline: string;\n readonly fill: string;\n readonly mark: string;\n}\n\n/** The palette colours of a check box (outline, fill, mark; disabled variants). */\nexport function checkBoxColors(palette: G9PaletteValues, disabled: boolean): G9CheckBoxColors {\n return {\n outline: palette.Outline,\n fill: disabled ? palette.TextDisabled : palette.Primary,\n mark: disabled ? palette.Surface : palette.OnPrimary,\n };\n}\n\n/**\n * The SVG of the box at an animation state (MAUI `G9CheckBoxDrawable`): the outline fades with `1 − fill`\n * (× 0.55 disabled), the fill grows from 78 % to 100 % with its alpha, the mark (tick → dash by `morph`) is trimmed by\n * the golden phase functions. Never mirrored in RTL.\n */\nexport function checkBoxSvg(progress: number, morph: number, colors: G9CheckBoxColors, disabled: boolean): string {\n const m = g9CheckBoxMetrics;\n const fill = fillAmount(progress);\n const outlineAlpha = (1 - fill) * (disabled ? 0.55 : 1);\n const scale = 0.78 + 0.22 * fill;\n const side = m.box * scale;\n const offset = (m.box - side) / 2;\n const r = (n: number) => Math.round(n * 1000) / 1000;\n const parts = [\n `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${m.box}\" height=\"${m.box}\" viewBox=\"0 0 ${m.box} ${m.box}\">`,\n ];\n if (outlineAlpha > 0.001) {\n parts.push(\n `<rect x=\"1\" y=\"1\" width=\"${m.box - 2}\" height=\"${m.box - 2}\" rx=\"${m.corner - 1}\" fill=\"none\" stroke=\"${formatColor(withAlpha(colors.outline, outlineAlpha))}\" stroke-width=\"${m.stroke}\"/>`,\n );\n }\n if (fill > 0.001) {\n parts.push(\n `<rect x=\"${r(offset)}\" y=\"${r(offset)}\" width=\"${r(side)}\" height=\"${r(side)}\" rx=\"${r(m.corner * scale)}\" fill=\"${formatColor(withAlpha(colors.fill, fill))}\"/>`,\n );\n }\n const path = checkMarkPath(progress, morph, m.box);\n if (path) {\n parts.push(\n `<path d=\"${path}\" fill=\"none\" stroke=\"${formatColor(colors.mark)}\" stroke-width=\"${m.stroke}\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>`,\n );\n }\n parts.push('</svg>');\n return parts.join('');\n}\n\n/** Props of {@link G9CheckBox} (MAUI `G9CheckBox`). */\nexport interface G9CheckBoxProps extends G9ControlBaseProps {\n /** Controlled checked state (MAUI `IsChecked`). */\n readonly checked?: boolean;\n readonly defaultChecked?: boolean;\n /** Once per change of `checked` caused by the control (MAUI `CheckedChanged`); never for pushed values. */\n readonly onCheckedChange?: (checked: boolean) => void;\n /** Controlled third state (MAUI `IsIndeterminate`); a tap clears it. */\n readonly indeterminate?: boolean;\n readonly defaultIndeterminate?: boolean;\n readonly onIndeterminateChange?: (indeterminate: boolean) => void;\n /** Label at the end side; also the accessibility name. */\n readonly text?: string | null;\n /** After every user toggle, with the new state (MAUI `Command`). */\n readonly onPress?: (checked: boolean) => void;\n /** 48 px touch slot with the box at the top; false: a 20 px slot, box centred. Default true. */\n readonly reserveTouchTarget?: boolean;\n}\n\n/** Imperative handle of {@link G9CheckBox}. */\nexport interface G9CheckBoxHandle {\n /** Same as a tap (MAUI `Toggle`); ignored while disabled. */\n toggle(): void;\n}\n\n/**\n * Tri-state check box (MAUI `G9CheckBox`, ADR-0028): tap toggles, indeterminate → checked, never into\n * indeterminate. The box animates (200 ms fill/tick, 150 ms tick↔dash) by updating the SVG attribute directly\n * (`setNativeProps`), never by re-rendering per frame; the first render does not animate.\n */\nexport const G9CheckBox = forwardRef<G9CheckBoxHandle, G9CheckBoxProps>(function G9CheckBox(props, ref): ReactNode {\n const control = useG9Control(props, 'g9-checkbox', {\n kind: 'toggle',\n label: () => props.accessibilityLabel ?? props.text,\n capabilities: {\n activate: () => press(),\n getValue: () => String(checked),\n setValue: (v) => {\n if ((v === 'true') !== checked) press();\n return String(v === 'true');\n },\n },\n });\n const palette = useG9Theme().palette;\n const strings = useG9Strings();\n const [checked, setChecked] = useControllableState<boolean>({\n value: props.checked,\n defaultValue: props.defaultChecked ?? false,\n onChange: props.onCheckedChange,\n name: 'G9CheckBox.checked',\n });\n const [indeterminate, setIndeterminate] = useControllableState<boolean>({\n value: props.indeterminate,\n defaultValue: props.defaultIndeterminate ?? false,\n onChange: props.onIndeterminateChange,\n name: 'G9CheckBox.indeterminate',\n });\n const colors = checkBoxColors(palette, control.disabled);\n const progressTarget = targetProgress(checked, indeterminate);\n const morphTarget = targetMorph(indeterminate);\n\n // Animation state lives outside React: the drawn progress/morph and the frame timer.\n const svgRef = useRef<NodesRef | null>(null);\n const drawn = useRef({ progress: progressTarget, morph: morphTarget });\n const frame = useRef<G9TimerHandle | null>(null);\n const latest = useRef({ colors, disabled: control.disabled });\n latest.current = { colors, disabled: control.disabled };\n useEffect(() => {\n const from = { ...drawn.current };\n if (from.progress === progressTarget && from.morph === morphTarget) return;\n // Unchecked → indeterminate draws the dash directly; a fade-out keeps the current mark shape.\n const morphFrom = from.progress < 0.01 ? morphTarget : from.morph;\n const morphTo = progressTarget === 0 ? morphFrom : morphTarget;\n const started = Date.now();\n const step = () => {\n const t = Date.now() - started;\n const p = Math.min(1, t / g9CheckBoxMetrics.progressMs);\n const q = Math.min(1, t / g9CheckBoxMetrics.morphMs);\n const easeOut = 1 - (1 - p) ** 3;\n const easeInOut = q < 0.5 ? 4 * q * q * q : 1 - (-2 * q + 2) ** 3 / 2;\n drawn.current = {\n progress: from.progress + (progressTarget - from.progress) * easeOut,\n morph: morphFrom + (morphTo - morphFrom) * easeInOut,\n };\n try {\n svgRef.current\n ?.setNativeProps({\n content: checkBoxSvg(\n drawn.current.progress,\n drawn.current.morph,\n latest.current.colors,\n latest.current.disabled,\n ),\n })\n .exec();\n } catch {\n // Unmounted between frames.\n }\n frame.current = p < 1 || q < 1 ? startTimer(step, 16) : null;\n };\n if (frame.current !== null) stopTimer(frame.current);\n step();\n return () => {\n if (frame.current !== null) stopTimer(frame.current);\n frame.current = null;\n };\n }, [progressTarget, morphTarget]);\n\n const toggle = () => {\n if (control.disabled) return;\n const next = nextOnTap(checked, indeterminate);\n setIndeterminate(next.indeterminate);\n setChecked(next.checked);\n props.onPress?.(next.checked);\n };\n useImperativeHandle(ref, () => ({ toggle }));\n const press = useG9Press(toggle, { blocked: control.disabled, source: 'G9CheckBox', guardMs: 0 });\n\n const reserve = props.reserveTouchTarget !== false;\n const text = props.text && props.text.trim() !== '' ? props.text : null;\n const state = indeterminate\n ? strings.get(G9StringKey.PartiallyChecked)\n : checked\n ? strings.get(G9StringKey.Checked)\n : strings.get(G9StringKey.NotChecked);\n return (\n <view\n className={`${control.className}${text ? ' g9-checkbox--labelled' : ''}`}\n {...control.idProps}\n style={g9RowStyle(control.direction)}\n accessibility-element={true}\n accessibility-traits=\"button\"\n accessibility-value={state}\n {...((props.accessibilityLabel ?? text) ? { 'accessibility-label': props.accessibilityLabel ?? text ?? '' } : {})}\n bindtap={press}\n >\n <view\n className={`g9-checkbox__slot${reserve ? ' g9-checkbox__slot--reserve' : ''}`}\n style={{ width: `${reserve ? g9CheckBoxMetrics.touchTarget : g9CheckBoxMetrics.box}px` }}\n >\n <svg\n ref={svgRef}\n className=\"g9-checkbox__box\"\n content={checkBoxSvg(drawn.current.progress, drawn.current.morph, colors, control.disabled)}\n />\n </view>\n {text ? (\n <text\n className=\"g9-checkbox__text\"\n style={{\n ...g9TextStart(control.direction),\n color: control.disabled ? 'var(--g9-text-disabled)' : 'var(--g9-text-primary)',\n paddingTop: reserve ? '12px' : '0px',\n paddingBottom: reserve ? '12px' : '0px',\n }}\n >\n {text}\n </text>\n ) : null}\n </view>\n );\n});\n"],"names":["g9CheckBoxMetrics","Object","checkBoxColors","palette","disabled","checkBoxSvg","progress","morph","colors","m","fill","fillAmount","outlineAlpha","scale","side","offset","r","n","Math","parts","formatColor","withAlpha","path","checkMarkPath","G9CheckBox","forwardRef","props","ref","_props_defaultChecked","_props_defaultIndeterminate","_props_accessibilityLabel","_ref","control","useG9Control","press","String","checked","v","useG9Theme","strings","useG9Strings","setChecked","useControllableState","indeterminate","setIndeterminate","progressTarget","targetProgress","morphTarget","targetMorph","svgRef","useRef","drawn","frame","latest","useEffect","from","morphFrom","morphTo","started","Date","step","t","p","q","easeOut","easeInOut","_svgRef_current","startTimer","stopTimer","toggle","next","nextOnTap","useImperativeHandle","useG9Press","reserve","text1","state","G9StringKey","view","g9RowStyle","svg","text","g9TextStart"],"mappings":";;;;;;;;;AAYO,MAAMA,oBAAoBC,OAAO,MAAM,CAAC;IAC7C,KAAK;I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G;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,SAAS,CA0J9D"}
@@ -9,7 +9,18 @@ import { useG9Settings, useG9Strings, useG9Theme } from "../provider/hooks.jsx";
9
9
  const EMPTY = [];
10
10
  function G9ChipGroup(props) {
11
11
  var _props_defaultSelectedKeys, _props_defaultSelectedKey, _props_chipHeight, _props_itemSpacing, _props_iconSize, _props_chipCornerRadius;
12
- const control = useG9Control(props, 'g9-chip-group');
12
+ const control = useG9Control(props, 'g9-chip-group', {
13
+ kind: 'chips',
14
+ label: ()=>props.accessibilityLabel,
15
+ capabilities: {
16
+ itemKeys: ()=>props.items.map((i)=>selectionKey(i)),
17
+ getValue: ()=>single ? null != key ? key : '' : keys.join(','),
18
+ selectItem: (k)=>{
19
+ const item = props.items.find((i)=>selectionKey(i) === k);
20
+ if (item) tap(item);
21
+ }
22
+ }
23
+ });
13
24
  const palette = useG9Theme().palette;
14
25
  const glyphs = useG9Settings().glyphs;
15
26
  const strings = useG9Strings();
@@ -1 +1 @@
1
- {"version":3,"file":"toggle/chip-group.jsx","sources":["../../src/toggle/chip-group.tsx"],"sourcesContent":["import './toggle.css';\nimport {\n buildSolidOrGradient,\n fillToCss,\n formatColor,\n type G9ChipGroupLayoutMode,\n type G9ChipGroupSelectionMode,\n G9Metrics,\n G9StringKey,\n mix,\n tryParseColor,\n} from '@g9tm/lynxcontrols-foundation';\nimport type { ReactNode } from '@lynx-js/react';\nimport { type G9ControlBaseProps, g9ChildId, g9IdProps, g9RowStyle, useG9Control } from '../base/control';\nimport { useG9Press } from '../base/press';\nimport { type G9SelectionItem, selectionKey } from '../base/selection-item';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { G9IconSlot, hasIconSlot } from '../icon/slot';\nimport { useG9Settings, useG9Strings, useG9Theme } from '../provider/hooks';\n\n/** Props of {@link G9ChipGroup} (MAUI `G9ChipGroup`). */\nexport interface G9ChipGroupProps extends G9ControlBaseProps {\n /** One chip per item (MAUI `ItemsSource`). Selection is by `selectionKey(item)`, so replaced objects keep it. */\n readonly items: ReadonlyArray<G9SelectionItem>;\n /** Default `'multiSelection'`. */\n readonly selectionMode?: G9ChipGroupSelectionMode;\n /** Multi mode: controlled selected keys (MAUI `SelectedItems`). */\n readonly selectedKeys?: ReadonlyArray<string>;\n readonly defaultSelectedKeys?: ReadonlyArray<string>;\n readonly onSelectedKeysChange?: (keys: ReadonlyArray<string>) => void;\n /** Single mode: controlled selected key (MAUI `SelectedItem`); `null` = none. */\n readonly selectedKey?: string | null;\n readonly defaultSelectedKey?: string | null;\n readonly onSelectedKeyChange?: (key: string | null, item: G9SelectionItem | null) => void;\n /** Single mode: tapping the selected chip clears the selection. Default false. */\n readonly allowNullSelection?: boolean;\n /** Gap between chips. Default 6. */\n readonly itemSpacing?: number;\n /** Default 36. */\n readonly chipHeight?: number;\n /** Leading icon size. Default 16. */\n readonly iconSize?: number;\n /** Group-wide selected fill (an item's `selectedColor` wins). Default primary. */\n readonly selectedBackground?: string | null;\n /** Group-wide selected text colour. Default on-primary. */\n readonly selectedTextColor?: string | null;\n /**\n * `'wrap'` (default), one horizontally scrolling line, or (MAUI 1.4.9) `'segmented'`: equal flat cells that share each\n * row — AgriPad's design for short exclusive choices.\n */\n readonly layoutMode?: G9ChipGroupLayoutMode;\n /**\n * `'segmented'` only: how many equal cells one row holds; more items wrap onto the next row in the same columns (the\n * design's «مرتب‌سازی بر اساس», three a row). `0` (default) = every item on one row.\n */\n readonly segmentColumns?: number;\n /** Default 9 (`G9LayoutMetrics.ControlCornerRadius`). */\n readonly chipCornerRadius?: number;\n /** Check mark at the trailing edge of selected chips. Default true. */\n readonly showSelectionCheckmark?: boolean;\n /**\n * After every user tap (MAUI `SelectionChanged`): single mode `[item]` or `[]` (also when the tap changed nothing),\n * multi mode the selected items.\n */\n readonly onSelectionChange?: (items: ReadonlyArray<G9SelectionItem>) => void;\n}\n\nconst EMPTY: ReadonlyArray<string> = [];\n\n/**\n * Chip group (MAUI `G9ChipGroup`): single or multi selection by item identity, wrap or single-line scroll, colour\n * transition (140 ms) and check mark (120 ms) in CSS, press pulse 0.94 on the main thread. Disabled items are dimmed\n * and ignore taps.\n */\nexport function G9ChipGroup(props: G9ChipGroupProps): ReactNode {\n const control = useG9Control(props, 'g9-chip-group');\n const palette = useG9Theme().palette;\n const glyphs = useG9Settings().glyphs;\n const strings = useG9Strings();\n const single = props.selectionMode === 'singleSelection';\n const [keys, setKeys] = useControllableState<ReadonlyArray<string>>({\n value: props.selectedKeys,\n defaultValue: props.defaultSelectedKeys ?? EMPTY,\n onChange: props.onSelectedKeysChange,\n name: 'G9ChipGroup.selectedKeys',\n });\n const [key, setKey] = useControllableState<string | null, [G9SelectionItem | null]>({\n value: props.selectedKey,\n defaultValue: props.defaultSelectedKey ?? null,\n onChange: props.onSelectedKeyChange,\n name: 'G9ChipGroup.selectedKey',\n });\n const isSelected = (item: G9SelectionItem) =>\n single ? key === selectionKey(item) : keys.includes(selectionKey(item));\n\n const tap = (item: G9SelectionItem) => {\n if (control.disabled || item.isEnabled === false) return;\n const k = selectionKey(item);\n if (single) {\n const next = key === k ? (props.allowNullSelection ? null : k) : k;\n setKey(next, next === null ? null : item);\n props.onSelectionChange?.(next === null ? [] : [item]);\n return;\n }\n const next = keys.includes(k) ? keys.filter((x) => x !== k) : [...keys, k];\n setKeys(next);\n props.onSelectionChange?.(props.items.filter((i) => next.includes(selectionKey(i))));\n };\n\n const height = props.chipHeight ?? G9Metrics.ChipHeight;\n const spacing = props.itemSpacing ?? G9Metrics.ChipSpacing;\n const iconSize = props.iconSize ?? G9Metrics.ChipIconSize;\n const radius = props.chipCornerRadius ?? 9;\n const checkmark = props.showSelectionCheckmark !== false;\n const segmented = props.layoutMode === 'segmented';\n const chips = props.items.map((item) => {\n const selected = isSelected(item);\n let background: string;\n let stroke: string;\n let color: string;\n if (segmented) {\n // MAUI 1.4.9 segment: resting = a grey cell on a hairline; chosen = a faint accent tint (8 % over Surface), the\n // accent as the outline, the text in the strong text colour and bold. Flat — no gradient.\n const accent = item.selectedColor ?? props.selectedBackground ?? palette.Primary;\n const parsedAccent = tryParseColor(accent);\n background = selected\n ? parsedAccent\n ? formatColor(mix(palette.Surface, parsedAccent, 0.08))\n : accent\n : palette.SurfaceContainer;\n stroke = selected ? (parsedAccent ? formatColor(parsedAccent) : accent) : palette.OutlineVariant;\n color = selected\n ? (item.selectedTextColor ?? props.selectedTextColor ?? palette.TextPrimary)\n : palette.TextSecondary;\n } else {\n const bg = item.selectedColor ?? props.selectedBackground ?? palette.Primary;\n const fg = item.selectedTextColor ?? props.selectedTextColor ?? palette.OnPrimary;\n const parsed = tryParseColor(bg);\n background = selected ? (parsed ? fillToCss(buildSolidOrGradient(parsed, true)) : bg) : palette.Surface;\n stroke = selected ? (parsed ? formatColor(parsed) : bg) : palette.OutlineVariant;\n color = selected ? fg : palette.TextSecondary;\n }\n return (\n <Chip\n key={selectionKey(item)}\n direction={control.direction}\n item={item}\n selected={selected}\n background={background}\n stroke={stroke}\n color={color}\n height={segmented ? Math.max(height, G9Metrics.SegmentHeight) : height}\n spacing={spacing}\n iconSize={iconSize}\n radius={segmented ? G9Metrics.SegmentCornerRadius : radius}\n checkmark={checkmark && !segmented}\n segment={segmented}\n checkIcon={glyphs.check}\n groupDisabled={control.disabled}\n selectedLabel={strings.get(G9StringKey.Selected)}\n onTap={tap}\n id={g9ChildId(props.id, selectionKey(item))}\n />\n );\n });\n if (segmented) {\n // One row per `columns` items, every cell the same width (MAUI's star columns): a short last row keeps the column\n // width with empty fillers instead of stretching its cells.\n const columns =\n props.segmentColumns && props.segmentColumns > 0\n ? Math.min(props.segmentColumns, Math.max(1, chips.length))\n : Math.max(1, chips.length);\n const rows: ReactNode[] = [];\n for (let start = 0; start < chips.length; start += columns) {\n const cells: ReactNode[] = chips.slice(start, start + columns);\n while (cells.length < columns)\n cells.push(<view key={`fill-${cells.length}`} className=\"g9-chip-group__segment-fill\" />);\n rows.push(\n <view\n key={`row-${start}`}\n className=\"g9-chip-group__segment-row\"\n style={{ ...g9RowStyle(control.direction), columnGap: `${spacing}px` }}\n >\n {cells}\n </view>,\n );\n }\n return (\n <view\n className={`${control.className} g9-chip-group--segmented`}\n {...control.idProps}\n style={{ rowGap: `${spacing}px` }}\n >\n {rows}\n </view>\n );\n }\n const scroll = props.layoutMode === 'singleLineScroll';\n return scroll ? (\n <scroll-view\n className={`${control.className} g9-chip-group--scroll`}\n {...control.idProps}\n scroll-orientation=\"horizontal\"\n >\n <view className=\"g9-chip-group__line\" style={g9RowStyle(control.direction)}>\n {chips}\n </view>\n </scroll-view>\n ) : (\n <view\n className={`${control.className} g9-chip-group--wrap`}\n {...control.idProps}\n style={g9RowStyle(control.direction)}\n >\n {chips}\n </view>\n );\n}\n\ninterface ChipProps {\n readonly item: G9SelectionItem;\n readonly selected: boolean;\n readonly background: string;\n readonly stroke: string;\n readonly color: string;\n readonly height: number;\n readonly spacing: number;\n readonly iconSize: number;\n readonly radius: number;\n readonly checkmark: boolean;\n readonly checkIcon: Parameters<typeof G9IconSlot>[0]['icon'];\n readonly groupDisabled: boolean;\n readonly selectedLabel: string;\n readonly onTap: (item: G9SelectionItem) => void;\n readonly direction: 'ltr' | 'rtl';\n /** A segmented cell: fills its column, no margin (the row's gap is the spacing), 14 px text bold only when chosen. */\n readonly segment?: boolean;\n /** The chip's automation id (`${groupId}_${key}`). */\n readonly id: string | undefined;\n}\n\nfunction Chip(props: ChipProps): ReactNode {\n const { item } = props;\n const disabled = props.groupDisabled || item.isEnabled === false;\n const press = useG9Press(() => props.onTap(item), { blocked: disabled, source: 'G9ChipGroup', guardMs: 0 });\n return (\n <view\n className={`g9-chip${props.segment ? ' g9-chip--segment' : ''}${props.selected ? ' g9-chip--selected' : ''}${item.isEnabled === false ? ' g9-chip--disabled' : ''}`}\n {...g9IdProps(props.id)}\n style={{\n ...g9RowStyle(props.direction),\n height: `${props.height}px`,\n minHeight: `${props.height}px`,\n ...(props.segment\n ? {}\n : {\n [props.direction === 'rtl' ? 'marginLeft' : 'marginRight']: `${props.spacing}px`,\n marginBottom: `${props.spacing}px`,\n }),\n borderRadius: `${props.radius}px`,\n background: props.background,\n borderColor: props.stroke,\n }}\n accessibility-element={true}\n accessibility-traits=\"button\"\n accessibility-label={item.text}\n {...(props.selected ? { 'accessibility-value': props.selectedLabel } : {})}\n bindtap={press}\n >\n {/* Only when the item has one (MAUI adds the icon view only then): an empty slot still took the row's 6 dp gap,\n and every icon-less chip came out 6 dp wider than MAUI's. */}\n {hasIconSlot({ emoji: item.emoji, icon: item.icon, imagePath: item.iconPath, image: item.iconImage }) ? (\n <G9IconSlot\n emoji={item.emoji}\n icon={item.icon}\n imagePath={item.iconPath}\n image={item.iconImage}\n size={props.iconSize}\n color={props.color}\n />\n ) : null}\n <text\n className=\"g9-chip__text\"\n style={{\n color: props.color,\n ...(props.segment\n ? { fontSize: `${G9Metrics.SegmentFontSize}px`, fontWeight: props.selected ? 'bold' : 'normal' }\n : {}),\n }}\n >\n {item.text}\n </text>\n {props.checkmark ? (\n <view className={`g9-chip__check${props.selected ? ' g9-chip__check--on' : ''}`}>\n <G9IconSlot icon={props.checkIcon} size={G9Metrics.ChipIconSize} color={props.color} />\n </view>\n ) : null}\n </view>\n );\n}\n"],"names":["EMPTY","G9ChipGroup","props","_props_defaultSelectedKeys","_props_defaultSelectedKey","_props_chipHeight","_props_itemSpacing","_props_iconSize","_props_chipCornerRadius","control","useG9Control","palette","useG9Theme","glyphs","useG9Settings","strings","useG9Strings","single","keys","setKeys","useControllableState","key","setKey","isSelected","item","selectionKey","tap","k","next","x","i","height","G9Metrics","spacing","iconSize","radius","checkmark","segmented","chips","selected","background","stroke","color","_ref","_ref1","accent","parsedAccent","tryParseColor","formatColor","mix","_ref2","_ref3","bg","fg","parsed","fillToCss","buildSolidOrGradient","Chip","Math","G9StringKey","g9ChildId","columns","rows","start","cells","view","g9RowStyle","scroll","scroll-view","disabled","press","useG9Press","g9IdProps","hasIconSlot","G9IconSlot","text"],"mappings":";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D,KAAK,KAAK;QAAE,MAAMA,KAAK,IAAI;QAAE,WAAWA,KAAK,QAAQ;QAAE,OAAOA,KAAK,SAAS;IAAC,MAChGkD,WACC,OAAOlD,KAAK,KAAK,EACjB,MAAMA,KAAK,IAAI,EACf,WAAWA,KAAK,QAAQ,EACxB,OAAOA,KAAK,SAAS,EACrB,MAAMtB,MAAM,QAAQ,EACpB,OAAOA,MAAM,KAAK,MAElB,KAAK;MACT,CAACyE,KACC,UAAU,gBACV,OAAO;QACL,OAAOzE,MAAM,KAAK;QAClB,GAAIA,MAAM,OAAO,GACb;YAAE,UAAU,GAAG8B,UAAU,eAAe,CAAC,EAAE,CAAC;YAAE,YAAY9B,MAAM,QAAQ,GAAG,SAAS;QAAS,IAC7F,CAAC,CAAC;IACR,GACD;QACC,CAACsB,KAAK,IAAI,CAAC;MACb,EAAEmD,KAAK;MACP,CAACzE,MAAM,SAAS,IACb+D,KAAK,WAAW,CAAC,cAAc,EAAE/D,MAAM,QAAQ,GAAG,wBAAwB,IAAI,EAAE;UAC/E,CAACwE,WAAW,MAAMxE,MAAM,SAAS,EAAE,MAAM8B,UAAU,YAAY,EAAE,OAAO9B,MAAM,KAAK,GAAI;QACzF,EAAE+D,QACA,KAAK;IACX,EAAEA;AAEN"}
1
+ {"version":3,"file":"toggle/chip-group.jsx","sources":["../../src/toggle/chip-group.tsx"],"sourcesContent":["import './toggle.css';\nimport {\n buildSolidOrGradient,\n fillToCss,\n formatColor,\n type G9ChipGroupLayoutMode,\n type G9ChipGroupSelectionMode,\n G9Metrics,\n G9StringKey,\n mix,\n tryParseColor,\n} from '@g9tm/lynxcontrols-foundation';\nimport type { ReactNode } from '@lynx-js/react';\nimport { type G9ControlBaseProps, g9ChildId, g9IdProps, g9RowStyle, useG9Control } from '../base/control';\nimport { useG9Press } from '../base/press';\nimport { type G9SelectionItem, selectionKey } from '../base/selection-item';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { G9IconSlot, hasIconSlot } from '../icon/slot';\nimport { useG9Settings, useG9Strings, useG9Theme } from '../provider/hooks';\n\n/** Props of {@link G9ChipGroup} (MAUI `G9ChipGroup`). */\nexport interface G9ChipGroupProps extends G9ControlBaseProps {\n /** One chip per item (MAUI `ItemsSource`). Selection is by `selectionKey(item)`, so replaced objects keep it. */\n readonly items: ReadonlyArray<G9SelectionItem>;\n /** Default `'multiSelection'`. */\n readonly selectionMode?: G9ChipGroupSelectionMode;\n /** Multi mode: controlled selected keys (MAUI `SelectedItems`). */\n readonly selectedKeys?: ReadonlyArray<string>;\n readonly defaultSelectedKeys?: ReadonlyArray<string>;\n readonly onSelectedKeysChange?: (keys: ReadonlyArray<string>) => void;\n /** Single mode: controlled selected key (MAUI `SelectedItem`); `null` = none. */\n readonly selectedKey?: string | null;\n readonly defaultSelectedKey?: string | null;\n readonly onSelectedKeyChange?: (key: string | null, item: G9SelectionItem | null) => void;\n /** Single mode: tapping the selected chip clears the selection. Default false. */\n readonly allowNullSelection?: boolean;\n /** Gap between chips. Default 6. */\n readonly itemSpacing?: number;\n /** Default 36. */\n readonly chipHeight?: number;\n /** Leading icon size. Default 16. */\n readonly iconSize?: number;\n /** Group-wide selected fill (an item's `selectedColor` wins). Default primary. */\n readonly selectedBackground?: string | null;\n /** Group-wide selected text colour. Default on-primary. */\n readonly selectedTextColor?: string | null;\n /**\n * `'wrap'` (default), one horizontally scrolling line, or (MAUI 1.4.9) `'segmented'`: equal flat cells that share each\n * row — AgriPad's design for short exclusive choices.\n */\n readonly layoutMode?: G9ChipGroupLayoutMode;\n /**\n * `'segmented'` only: how many equal cells one row holds; more items wrap onto the next row in the same columns (the\n * design's «مرتب‌سازی بر اساس», three a row). `0` (default) = every item on one row.\n */\n readonly segmentColumns?: number;\n /** Default 9 (`G9LayoutMetrics.ControlCornerRadius`). */\n readonly chipCornerRadius?: number;\n /** Check mark at the trailing edge of selected chips. Default true. */\n readonly showSelectionCheckmark?: boolean;\n /**\n * After every user tap (MAUI `SelectionChanged`): single mode `[item]` or `[]` (also when the tap changed nothing),\n * multi mode the selected items.\n */\n readonly onSelectionChange?: (items: ReadonlyArray<G9SelectionItem>) => void;\n}\n\nconst EMPTY: ReadonlyArray<string> = [];\n\n/**\n * Chip group (MAUI `G9ChipGroup`): single or multi selection by item identity, wrap or single-line scroll, colour\n * transition (140 ms) and check mark (120 ms) in CSS, press pulse 0.94 on the main thread. Disabled items are dimmed\n * and ignore taps.\n */\nexport function G9ChipGroup(props: G9ChipGroupProps): ReactNode {\n const control = useG9Control(props, 'g9-chip-group', {\n kind: 'chips',\n label: () => props.accessibilityLabel,\n capabilities: {\n itemKeys: () => props.items.map((i) => selectionKey(i)),\n getValue: () => (single ? (key ?? '') : keys.join(',')),\n selectItem: (k) => {\n const item = props.items.find((i) => selectionKey(i) === k);\n if (item) tap(item);\n },\n },\n });\n const palette = useG9Theme().palette;\n const glyphs = useG9Settings().glyphs;\n const strings = useG9Strings();\n const single = props.selectionMode === 'singleSelection';\n const [keys, setKeys] = useControllableState<ReadonlyArray<string>>({\n value: props.selectedKeys,\n defaultValue: props.defaultSelectedKeys ?? EMPTY,\n onChange: props.onSelectedKeysChange,\n name: 'G9ChipGroup.selectedKeys',\n });\n const [key, setKey] = useControllableState<string | null, [G9SelectionItem | null]>({\n value: props.selectedKey,\n defaultValue: props.defaultSelectedKey ?? null,\n onChange: props.onSelectedKeyChange,\n name: 'G9ChipGroup.selectedKey',\n });\n const isSelected = (item: G9SelectionItem) =>\n single ? key === selectionKey(item) : keys.includes(selectionKey(item));\n\n const tap = (item: G9SelectionItem) => {\n if (control.disabled || item.isEnabled === false) return;\n const k = selectionKey(item);\n if (single) {\n const next = key === k ? (props.allowNullSelection ? null : k) : k;\n setKey(next, next === null ? null : item);\n props.onSelectionChange?.(next === null ? [] : [item]);\n return;\n }\n const next = keys.includes(k) ? keys.filter((x) => x !== k) : [...keys, k];\n setKeys(next);\n props.onSelectionChange?.(props.items.filter((i) => next.includes(selectionKey(i))));\n };\n\n const height = props.chipHeight ?? G9Metrics.ChipHeight;\n const spacing = props.itemSpacing ?? G9Metrics.ChipSpacing;\n const iconSize = props.iconSize ?? G9Metrics.ChipIconSize;\n const radius = props.chipCornerRadius ?? 9;\n const checkmark = props.showSelectionCheckmark !== false;\n const segmented = props.layoutMode === 'segmented';\n const chips = props.items.map((item) => {\n const selected = isSelected(item);\n let background: string;\n let stroke: string;\n let color: string;\n if (segmented) {\n // MAUI 1.4.9 segment: resting = a grey cell on a hairline; chosen = a faint accent tint (8 % over Surface), the\n // accent as the outline, the text in the strong text colour and bold. Flat — no gradient.\n const accent = item.selectedColor ?? props.selectedBackground ?? palette.Primary;\n const parsedAccent = tryParseColor(accent);\n background = selected\n ? parsedAccent\n ? formatColor(mix(palette.Surface, parsedAccent, 0.08))\n : accent\n : palette.SurfaceContainer;\n stroke = selected ? (parsedAccent ? formatColor(parsedAccent) : accent) : palette.OutlineVariant;\n color = selected\n ? (item.selectedTextColor ?? props.selectedTextColor ?? palette.TextPrimary)\n : palette.TextSecondary;\n } else {\n const bg = item.selectedColor ?? props.selectedBackground ?? palette.Primary;\n const fg = item.selectedTextColor ?? props.selectedTextColor ?? palette.OnPrimary;\n const parsed = tryParseColor(bg);\n background = selected ? (parsed ? fillToCss(buildSolidOrGradient(parsed, true)) : bg) : palette.Surface;\n stroke = selected ? (parsed ? formatColor(parsed) : bg) : palette.OutlineVariant;\n color = selected ? fg : palette.TextSecondary;\n }\n return (\n <Chip\n key={selectionKey(item)}\n direction={control.direction}\n item={item}\n selected={selected}\n background={background}\n stroke={stroke}\n color={color}\n height={segmented ? Math.max(height, G9Metrics.SegmentHeight) : height}\n spacing={spacing}\n iconSize={iconSize}\n radius={segmented ? G9Metrics.SegmentCornerRadius : radius}\n checkmark={checkmark && !segmented}\n segment={segmented}\n checkIcon={glyphs.check}\n groupDisabled={control.disabled}\n selectedLabel={strings.get(G9StringKey.Selected)}\n onTap={tap}\n id={g9ChildId(props.id, selectionKey(item))}\n />\n );\n });\n if (segmented) {\n // One row per `columns` items, every cell the same width (MAUI's star columns): a short last row keeps the column\n // width with empty fillers instead of stretching its cells.\n const columns =\n props.segmentColumns && props.segmentColumns > 0\n ? Math.min(props.segmentColumns, Math.max(1, chips.length))\n : Math.max(1, chips.length);\n const rows: ReactNode[] = [];\n for (let start = 0; start < chips.length; start += columns) {\n const cells: ReactNode[] = chips.slice(start, start + columns);\n while (cells.length < columns)\n cells.push(<view key={`fill-${cells.length}`} className=\"g9-chip-group__segment-fill\" />);\n rows.push(\n <view\n key={`row-${start}`}\n className=\"g9-chip-group__segment-row\"\n style={{ ...g9RowStyle(control.direction), columnGap: `${spacing}px` }}\n >\n {cells}\n </view>,\n );\n }\n return (\n <view\n className={`${control.className} g9-chip-group--segmented`}\n {...control.idProps}\n style={{ rowGap: `${spacing}px` }}\n >\n {rows}\n </view>\n );\n }\n const scroll = props.layoutMode === 'singleLineScroll';\n return scroll ? (\n <scroll-view\n className={`${control.className} g9-chip-group--scroll`}\n {...control.idProps}\n scroll-orientation=\"horizontal\"\n >\n <view className=\"g9-chip-group__line\" style={g9RowStyle(control.direction)}>\n {chips}\n </view>\n </scroll-view>\n ) : (\n <view\n className={`${control.className} g9-chip-group--wrap`}\n {...control.idProps}\n style={g9RowStyle(control.direction)}\n >\n {chips}\n </view>\n );\n}\n\ninterface ChipProps {\n readonly item: G9SelectionItem;\n readonly selected: boolean;\n readonly background: string;\n readonly stroke: string;\n readonly color: string;\n readonly height: number;\n readonly spacing: number;\n readonly iconSize: number;\n readonly radius: number;\n readonly checkmark: boolean;\n readonly checkIcon: Parameters<typeof G9IconSlot>[0]['icon'];\n readonly groupDisabled: boolean;\n readonly selectedLabel: string;\n readonly onTap: (item: G9SelectionItem) => void;\n readonly direction: 'ltr' | 'rtl';\n /** A segmented cell: fills its column, no margin (the row's gap is the spacing), 14 px text bold only when chosen. */\n readonly segment?: boolean;\n /** The chip's automation id (`${groupId}_${key}`). */\n readonly id: string | undefined;\n}\n\nfunction Chip(props: ChipProps): ReactNode {\n const { item } = props;\n const disabled = props.groupDisabled || item.isEnabled === false;\n const press = useG9Press(() => props.onTap(item), { blocked: disabled, source: 'G9ChipGroup', guardMs: 0 });\n return (\n <view\n className={`g9-chip${props.segment ? ' g9-chip--segment' : ''}${props.selected ? ' g9-chip--selected' : ''}${item.isEnabled === false ? ' g9-chip--disabled' : ''}`}\n {...g9IdProps(props.id)}\n style={{\n ...g9RowStyle(props.direction),\n height: `${props.height}px`,\n minHeight: `${props.height}px`,\n ...(props.segment\n ? {}\n : {\n [props.direction === 'rtl' ? 'marginLeft' : 'marginRight']: `${props.spacing}px`,\n marginBottom: `${props.spacing}px`,\n }),\n borderRadius: `${props.radius}px`,\n background: props.background,\n borderColor: props.stroke,\n }}\n accessibility-element={true}\n accessibility-traits=\"button\"\n accessibility-label={item.text}\n {...(props.selected ? { 'accessibility-value': props.selectedLabel } : {})}\n bindtap={press}\n >\n {/* Only when the item has one (MAUI adds the icon view only then): an empty slot still took the row's 6 dp gap,\n and every icon-less chip came out 6 dp wider than MAUI's. */}\n {hasIconSlot({ emoji: item.emoji, icon: item.icon, imagePath: item.iconPath, image: item.iconImage }) ? (\n <G9IconSlot\n emoji={item.emoji}\n icon={item.icon}\n imagePath={item.iconPath}\n image={item.iconImage}\n size={props.iconSize}\n color={props.color}\n />\n ) : null}\n <text\n className=\"g9-chip__text\"\n style={{\n color: props.color,\n ...(props.segment\n ? { fontSize: `${G9Metrics.SegmentFontSize}px`, fontWeight: props.selected ? 'bold' : 'normal' }\n : {}),\n }}\n >\n {item.text}\n </text>\n {props.checkmark ? (\n <view className={`g9-chip__check${props.selected ? ' g9-chip__check--on' : ''}`}>\n <G9IconSlot icon={props.checkIcon} size={G9Metrics.ChipIconSize} color={props.color} />\n </view>\n ) : null}\n </view>\n );\n}\n"],"names":["EMPTY","G9ChipGroup","props","_props_defaultSelectedKeys","_props_defaultSelectedKey","_props_chipHeight","_props_itemSpacing","_props_iconSize","_props_chipCornerRadius","control","useG9Control","i","selectionKey","single","key","keys","k","item","tap","palette","useG9Theme","glyphs","useG9Settings","strings","useG9Strings","setKeys","useControllableState","setKey","isSelected","next","x","height","G9Metrics","spacing","iconSize","radius","checkmark","segmented","chips","selected","background","stroke","color","_ref","_ref1","accent","parsedAccent","tryParseColor","formatColor","mix","_ref2","_ref3","bg","fg","parsed","fillToCss","buildSolidOrGradient","Chip","Math","G9StringKey","g9ChildId","columns","rows","start","cells","view","g9RowStyle","scroll","scroll-view","disabled","press","useG9Press","g9IdProps","hasIconSlot","G9IconSlot","text"],"mappings":";;;;;;;;AAmEA,MAAMA,QAA+B,EAAE;AAOhC,SAASC,YAAYC,KAAuB;QAmBjCC,4BAMAC,2BAqBDC,mBACCC,oBACCC,iBACFC;IAhDf,MAAMC,UAAUC,aAAaR,OAAO,iBAAiB;QACnD,MAAM;QACN,OAAO,IAAMA,MAAM,kBAAkB;QACrC,cAAc;YACZ,UAAU,IAAMA,MAAM,KAAK,CAAC,GAAG,CAAC,CAACS,IAAMC,aAAaD;YACpD,UAAU,IAAOE,SAAUC,QAAAA,MAAAA,MAAO,KAAMC,KAAK,IAAI,CAAC;YAClD,YAAY,CAACC;gBACX,MAAMC,OAAOf,MAAM,KAAK,CAAC,IAAI,CAAC,CAACS,IAAMC,aAAaD,OAAOK;gBACzD,IAAIC,MAAMC,IAAID;YAChB;QACF;IACF;IACA,MAAME,UAAUC,aAAa,OAAO;IACpC,MAAMC,SAASC,gBAAgB,MAAM;IACrC,MAAMC,UAAUC;IAChB,MAAMX,SAASX,AAAwB,sBAAxBA,MAAM,aAAa;IAClC,MAAM,CAACa,MAAMU,QAAQ,GAAGC,qBAA4C;QAClE,OAAOxB,MAAM,YAAY;QACzB,cAAc,QAAAC,CAAAA,6BAAAA,MAAM,mBAAmB,AAAD,IAAxBA,6BAA6BH;QAC3C,UAAUE,MAAM,oBAAoB;QACpC,MAAM;IACR;IACA,MAAM,CAACY,KAAKa,OAAO,GAAGD,qBAA8D;QAClF,OAAOxB,MAAM,WAAW;QACxB,cAAc,QAAA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AAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtD,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,yGAAyG;IACzG,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,4FAA4F;IAC5F,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,yDAAyD;IACzD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAED,6CAA6C;AAC7C,MAAM,WAAW,cAAc;IAC7B,qBAAqB;IACrB,MAAM,IAAI,IAAI,CAAC;CAChB;AAID;;;;GAIG;AACH,eAAO,MAAM,QAAQ,0GAoInB,CAAC"}
@@ -76,7 +76,21 @@ function G9SwitchGroup(props) {
76
76
  let switchIds = 0;
77
77
  const switch_G9Switch = forwardRef(function(props, ref) {
78
78
  var _props_defaultChecked, _props_accessibilityLabel, _ref, _props_accessibilityLabel1;
79
- const control = useG9Control(props, 'g9-switch');
79
+ const control = useG9Control(props, 'g9-switch', {
80
+ kind: 'toggle',
81
+ label: ()=>{
82
+ var _props_accessibilityLabel;
83
+ return null != (_props_accessibilityLabel = props.accessibilityLabel) ? _props_accessibilityLabel : props.title;
84
+ },
85
+ capabilities: {
86
+ activate: ()=>press(),
87
+ getValue: ()=>String(checked),
88
+ setValue: (v)=>{
89
+ if ('true' === v !== checked) press();
90
+ return String('true' === v);
91
+ }
92
+ }
93
+ });
80
94
  const theme = useG9Theme();
81
95
  const strings = useG9Strings();
82
96
  const settings = useG9Settings();
@@ -1 +1 @@
1
- {"version":3,"file":"toggle/switch.jsx","sources":["../../src/toggle/switch.tsx"],"sourcesContent":["import './toggle.css';\nimport {\n formatColor,\n G9Metrics,\n G9StringKey,\n switchOffTrack,\n switchOnTrack,\n switchThumbOff,\n switchThumbOn,\n} from '@g9tm/lynxcontrols-foundation';\nimport {\n createContext,\n forwardRef,\n type ReactNode,\n useContext,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from '@lynx-js/react';\nimport { type G9ControlBaseProps, g9RowStyle, g9TextStart, useG9Control } from '../base/control';\nimport { useG9Press } from '../base/press';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { G9CoreContext } from '../provider/contexts';\nimport { useG9Settings, useG9Strings, useG9Theme } from '../provider/hooks';\n\n// ---- selection groups (MAUI `SelectionGroup`: radio-style, scoped to the provider) -------------------------------\n\ninterface GroupMember {\n turnOff(): void;\n}\n\nconst registries = new WeakMap<object, Map<string, Set<GroupMember>>>();\nconst globalScope = {};\n\nfunction groupSet(scope: object, group: string): Set<GroupMember> {\n let groups = registries.get(scope);\n if (!groups) {\n groups = new Map();\n registries.set(scope, groups);\n }\n let set = groups.get(group);\n if (!set) {\n set = new Set();\n groups.set(group, set);\n }\n return set;\n}\n\n// ---- G9SwitchGroup ---------------------------------------------------------------------------------------------\n\ninterface SwitchGroupContextValue {\n readonly minOneActive: boolean;\n activeCount(): number;\n report(id: number, on: boolean | null): void;\n}\n\nconst SwitchGroupContext = createContext<SwitchGroupContextValue | null>(null);\n\n/** Props of {@link G9SwitchGroup} (MAUI `G9SwitchGroup`). */\nexport interface G9SwitchGroupProps extends G9ControlBaseProps {\n /** A tap cannot turn off the last active switch of the group (it shakes). Default false. */\n readonly minOneActive?: boolean;\n /** Shows `active / total` under the switches (warning colour at ≤ 1 with `minOneActive`). Default false. */\n readonly showLiveStatus?: boolean;\n /** Told when the number of active switches changes (MAUI `ActiveSwitchCount`). */\n readonly onActiveCountChange?: (active: number, total: number) => void;\n readonly children?: ReactNode;\n}\n\n/**\n * A vertical group of switches (MAUI `G9SwitchGroup`): counts its switches (nearest group only, as MAUI's direct\n * children), optionally keeps one on and shows a live `active / total` status. It does not make switches exclusive:\n * use `selectionGroup` for radio behaviour.\n */\nexport function G9SwitchGroup(props: G9SwitchGroupProps): ReactNode {\n const control = useG9Control(props, 'g9-switch-group');\n const [states, setStates] = useState<ReadonlyMap<number, boolean>>(() => new Map());\n const latest = useRef(states);\n latest.current = states;\n const minOneActive = props.minOneActive === true;\n const minRef = useRef(minOneActive);\n minRef.current = minOneActive;\n // One context object for the group's life: switches key their effects on it.\n const value = useRef<SwitchGroupContextValue | null>(null);\n if (value.current === null) {\n value.current = {\n get minOneActive() {\n return minRef.current;\n },\n activeCount: () => {\n let n = 0;\n for (const on of latest.current.values()) if (on) n++;\n return n;\n },\n report: (id, on) =>\n setStates((current) => {\n if (on === null ? !current.has(id) : current.get(id) === on) return current;\n const next = new Map(current);\n if (on === null) next.delete(id);\n else next.set(id, on);\n latest.current = next;\n return next;\n }),\n };\n }\n let active = 0;\n for (const on of states.values()) if (on) active++;\n const total = states.size;\n const notify = useRef(props.onActiveCountChange);\n notify.current = props.onActiveCountChange;\n useEffect(() => {\n notify.current?.(active, total);\n }, [active, total]);\n const warn = minOneActive && active <= 1;\n return (\n <SwitchGroupContext.Provider value={value.current}>\n <view className={control.className} {...control.idProps}>\n {props.children}\n {props.showLiveStatus ? (\n <text\n className=\"g9-switch-group__status\"\n style={{ color: warn ? 'var(--g9-warning)' : 'var(--g9-text-tertiary)' }}\n >\n {`${active} / ${total}`}\n </text>\n ) : null}\n </view>\n </SwitchGroupContext.Provider>\n );\n}\n\n// ---- G9Switch ----------------------------------------------------------------------------------------------------\n\n/** Props of {@link G9Switch} (MAUI `G9Switch`). */\nexport interface G9SwitchProps extends G9ControlBaseProps {\n /** Controlled state (MAUI `IsOn`). */\n readonly checked?: boolean;\n readonly defaultChecked?: boolean;\n /**\n * Once per change made by the switch: a tap, `toggle()`, or being turned off by its selection group (MAUI\n * `Toggled`). Never for a value the parent pushed in.\n */\n readonly onCheckedChange?: (checked: boolean) => void;\n /** A tap cannot turn it off (it shakes); code still can. Default false. */\n readonly isRequired?: boolean;\n /** Radio group name: turning this on turns off the others with the same name under the same provider. */\n readonly selectionGroup?: string | null;\n /** Form row: title/description fill the start, switch at the end, padded. Default false. */\n readonly isInFormRow?: boolean;\n /** Bold 14 title (form row only); the accessibility name. */\n readonly title?: string | null;\n /** 12 px description under the title (form row only). */\n readonly description?: string | null;\n}\n\n/** Imperative handle of {@link G9Switch}. */\nexport interface G9SwitchHandle {\n /** Same as a tap. */\n toggle(): void;\n}\n\nlet switchIds = 0;\n\n/**\n * Switch (MAUI `G9Switch`): 56 × 32 track, 24 px thumb that stretches while travelling, 240 ms spring-like CSS\n * transition, tick/dot track mark; RTL moves the \"on\" side to the left unless `toggles.switchMirrorInRtl` is false. A blocked tap (required, or the last active\n * switch of a `minOneActive` group) shakes instead of toggling. Disabled: opacity 0.45.\n */\nexport const G9Switch = forwardRef<G9SwitchHandle, G9SwitchProps>(function G9Switch(props, ref): ReactNode {\n const control = useG9Control(props, 'g9-switch');\n const theme = useG9Theme();\n const strings = useG9Strings();\n const settings = useG9Settings();\n const core = useContext(G9CoreContext);\n const group = useContext(SwitchGroupContext);\n const [checked, setChecked] = useControllableState<boolean>({\n value: props.checked,\n defaultValue: props.defaultChecked ?? false,\n onChange: props.onCheckedChange,\n name: 'G9Switch.checked',\n });\n const [shake, setShake] = useState(0);\n const id = useRef(0);\n if (id.current === 0) id.current = ++switchIds;\n const latestChecked = useRef(checked);\n latestChecked.current = checked;\n const setRef = useRef(setChecked);\n setRef.current = setChecked;\n\n // Report to the group.\n useEffect(() => {\n group?.report(id.current, checked);\n }, [group, checked]);\n useEffect(() => () => group?.report(id.current, null), [group]);\n\n // Selection group registration (while mounted and named).\n const groupName = props.selectionGroup && props.selectionGroup.trim() !== '' ? props.selectionGroup : null;\n const scope: object = core ?? globalScope;\n const memberRef = useRef<GroupMember | null>(null);\n useEffect(() => {\n if (!groupName) return;\n const member: GroupMember = { turnOff: () => setRef.current(false) };\n const set = groupSet(scope, groupName);\n set.add(member);\n memberRef.current = member;\n return () => {\n set.delete(member);\n memberRef.current = null;\n };\n }, [groupName, scope]);\n useEffect(() => {\n if (!checked || !groupName) return;\n for (const other of groupSet(scope, groupName)) if (other !== memberRef.current) other.turnOff();\n }, [checked, groupName, scope]);\n\n const toggle = () => {\n if (control.disabled) return;\n const on = latestChecked.current;\n if (on && (props.isRequired || (group?.minOneActive && group.activeCount() <= 1))) {\n setShake((n) => n + 1);\n return;\n }\n setChecked(!on);\n };\n useImperativeHandle(ref, () => ({ toggle }));\n const press = useG9Press(toggle, { blocked: control.disabled, source: 'G9Switch', guardMs: 0 });\n\n // The row flows with the language; the toggle mirrors only while the app lets it (MAUI 1.4.10 MirrorInRtl).\n const rtl = control.direction === 'rtl' && settings.toggles.switchMirrorInRtl;\n const width = G9Metrics.SwitchWidth;\n const thumb = G9Metrics.SwitchThumb;\n const travel = width - 4 - thumb - 4;\n const x = (checked ? travel : 0) * (rtl ? -1 : 1);\n const track = formatColor(checked ? switchOnTrack(theme) : switchOffTrack(theme));\n const thumbColor = formatColor(checked ? switchThumbOn(theme) : switchThumbOff(theme));\n const form = props.isInFormRow === true;\n const title = props.title && props.title.trim() !== '' ? props.title : null;\n const description = props.description && props.description.trim() !== '' ? props.description : null;\n return (\n <view\n className={`${control.className}${form ? ' g9-switch--row' : ''}`}\n {...control.idProps}\n style={g9RowStyle(control.direction)}\n accessibility-element={true}\n accessibility-traits=\"button\"\n {...(checked ? { 'accessibility-value': strings.get(G9StringKey.Selected) } : {})}\n {...((props.accessibilityLabel ?? title)\n ? { 'accessibility-label': props.accessibilityLabel ?? title ?? '' }\n : {})}\n bindtap={press}\n >\n {form ? (\n <view className=\"g9-switch__text\">\n {title ? (\n <text className=\"g9-switch__title\" style={g9TextStart(control.direction)}>\n {title}\n </text>\n ) : null}\n {description ? (\n <text className=\"g9-switch__description\" style={g9TextStart(control.direction)}>\n {description}\n </text>\n ) : null}\n </view>\n ) : null}\n <view\n key={`shake-${shake}`}\n className={`g9-switch__track${shake > 0 ? ' g9-switch__track--shake' : ''}`}\n style={{ width: `${width}px`, height: `${G9Metrics.SwitchHeight}px`, backgroundColor: track }}\n >\n {/* MAUI G9SwitchDrawable.DrawTrackMark: the mark is ALWAYS 15 dp from the track's start edge — on, the thumb has\n travelled to the end and the tick shows beside it; off, the thumb covers the dot. (Centring the tick at\n the end put it under the thumb: no tick was ever visible.) */}\n <view className=\"g9-switch__mark\" style={{ [rtl ? 'right' : 'left']: checked ? '9px' : '12px' }}>\n {checked ? <text className=\"g9-switch__tick\">✓</text> : <view className=\"g9-switch__dot\" />}\n </view>\n <view\n className=\"g9-switch__thumb\"\n style={{\n [rtl ? 'right' : 'left']: '4px',\n width: `${thumb}px`,\n height: `${thumb}px`,\n backgroundColor: thumbColor,\n transform: `translateX(${x}px)`,\n }}\n />\n </view>\n </view>\n );\n});\n"],"names":["registries","WeakMap","globalScope","groupSet","scope","group","groups","Map","set","Set","SwitchGroupContext","createContext","G9SwitchGroup","props","control","useG9Control","states","setStates","useState","latest","useRef","minOneActive","minRef","value","n","on","id","current","next","active","total","notify","useEffect","warn","view","text","switchIds","G9Switch","forwardRef","ref","_props_defaultChecked","_props_accessibilityLabel","_ref","theme","useG9Theme","strings","useG9Strings","settings","useG9Settings","core","useContext","G9CoreContext","checked","setChecked","useControllableState","shake","setShake","latestChecked","setRef","groupName","memberRef","member","other","toggle","useImperativeHandle","press","useG9Press","rtl","width","G9Metrics","thumb","travel","x","track","formatColor","switchOnTrack","switchOffTrack","thumbColor","switchThumbOn","switchThumbOff","form","title","description","g9RowStyle","G9StringKey","g9TextStart"],"mappings":";;;;;;;;AAgCA,MAAMA,aAAa,IAAIC;AACvB,MAAMC,cAAc,CAAC;AAErB,SAASC,SAASC,KAAa,EAAEC,KAAa;IAC5C,IAAIC,SAASN,WAAW,GAAG,CAACI;IAC5B,IAAI,CAACE,QAAQ;QACXA,SAAS,IAAIC;QACbP,WAAW,GAAG,CAACI,OAAOE;I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BuC,KAAI,IAAhCvC,OAAqC;IAAG,IACjE,CAAC,CAAC,EACN,SAASuB,OACV;MACC,CAACe,QACE9C,KAAK,UAAU,kBAAkB;UAChC,CAAC+C,SACE9C,KAAK,UAAU,mBAAmB,OAAOkD,YAAYvE,QAAQ,SAAS,GAAG;cACxE,CAACmE,MAAM;YACT,EAAE9C,QACA,KAAK;UACT,CAAC+C,eACE/C,KAAK,UAAU,yBAAyB,OAAOkD,YAAYvE,QAAQ,SAAS,GAAG;cAC9E,CAACoE,YAAY;YACf,EAAE/C,QACA,KAAK;QACX,EAAED,QACA,KAAK;MACT,CAACA,KACC,KAAK,CAAC,MAAM,EAAEqB,OAAO,EACrB,WAAW,CAAC,gBAAgB,EAAEA,QAAQ,IAAI,6BAA6B,IAAI,EAC3E,OAAO;QAAE,OAAO,GAAGa,MAAM,EAAE,CAAC;QAAE,QAAQ,GAAGC,UAAU,YAAY,CAAC,EAAE,CAAC;QAAE,iBAAiBI;IAAM,GAC7F;QACC,EAEkE;QAClE,CAACvC,KAAK,UAAU,kBAAkB,OAAO;QAAE,CAACiC,MAAM,UAAU,OAAO,EAAEf,UAAU,QAAQ;IAAO,GAAG;UAC/F,CAACA,WAAWjB,KAAK,UAAU,kBAAkB,CAAC,EAAEA,SAASD,KAAK,UAAU,mBAAoB;QAC9F,EAAEA,KAAK;QACP,CAACA,KACC,UAAU,mBACV,OAAO;QACL,CAACiC,MAAM,UAAU,OAAO,EAAE;QAC1B,OAAO,GAAGG,MAAM,EAAE,CAAC;QACnB,QAAQ,GAAGA,MAAM,EAAE,CAAC;QACpB,iBAAiBO;QACjB,WAAW,CAAC,WAAW,EAAEL,EAAE,GAAG,CAAC;IACjC,IACA;MACJ,EAAEtC,KAAK;IACT,EAAEA;AAEN"}
1
+ {"version":3,"file":"toggle/switch.jsx","sources":["../../src/toggle/switch.tsx"],"sourcesContent":["import './toggle.css';\nimport {\n formatColor,\n G9Metrics,\n G9StringKey,\n switchOffTrack,\n switchOnTrack,\n switchThumbOff,\n switchThumbOn,\n} from '@g9tm/lynxcontrols-foundation';\nimport {\n createContext,\n forwardRef,\n type ReactNode,\n useContext,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from '@lynx-js/react';\nimport { type G9ControlBaseProps, g9RowStyle, g9TextStart, useG9Control } from '../base/control';\nimport { useG9Press } from '../base/press';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { G9CoreContext } from '../provider/contexts';\nimport { useG9Settings, useG9Strings, useG9Theme } from '../provider/hooks';\n\n// ---- selection groups (MAUI `SelectionGroup`: radio-style, scoped to the provider) -------------------------------\n\ninterface GroupMember {\n turnOff(): void;\n}\n\nconst registries = new WeakMap<object, Map<string, Set<GroupMember>>>();\nconst globalScope = {};\n\nfunction groupSet(scope: object, group: string): Set<GroupMember> {\n let groups = registries.get(scope);\n if (!groups) {\n groups = new Map();\n registries.set(scope, groups);\n }\n let set = groups.get(group);\n if (!set) {\n set = new Set();\n groups.set(group, set);\n }\n return set;\n}\n\n// ---- G9SwitchGroup ---------------------------------------------------------------------------------------------\n\ninterface SwitchGroupContextValue {\n readonly minOneActive: boolean;\n activeCount(): number;\n report(id: number, on: boolean | null): void;\n}\n\nconst SwitchGroupContext = createContext<SwitchGroupContextValue | null>(null);\n\n/** Props of {@link G9SwitchGroup} (MAUI `G9SwitchGroup`). */\nexport interface G9SwitchGroupProps extends G9ControlBaseProps {\n /** A tap cannot turn off the last active switch of the group (it shakes). Default false. */\n readonly minOneActive?: boolean;\n /** Shows `active / total` under the switches (warning colour at ≤ 1 with `minOneActive`). Default false. */\n readonly showLiveStatus?: boolean;\n /** Told when the number of active switches changes (MAUI `ActiveSwitchCount`). */\n readonly onActiveCountChange?: (active: number, total: number) => void;\n readonly children?: ReactNode;\n}\n\n/**\n * A vertical group of switches (MAUI `G9SwitchGroup`): counts its switches (nearest group only, as MAUI's direct\n * children), optionally keeps one on and shows a live `active / total` status. It does not make switches exclusive:\n * use `selectionGroup` for radio behaviour.\n */\nexport function G9SwitchGroup(props: G9SwitchGroupProps): ReactNode {\n const control = useG9Control(props, 'g9-switch-group');\n const [states, setStates] = useState<ReadonlyMap<number, boolean>>(() => new Map());\n const latest = useRef(states);\n latest.current = states;\n const minOneActive = props.minOneActive === true;\n const minRef = useRef(minOneActive);\n minRef.current = minOneActive;\n // One context object for the group's life: switches key their effects on it.\n const value = useRef<SwitchGroupContextValue | null>(null);\n if (value.current === null) {\n value.current = {\n get minOneActive() {\n return minRef.current;\n },\n activeCount: () => {\n let n = 0;\n for (const on of latest.current.values()) if (on) n++;\n return n;\n },\n report: (id, on) =>\n setStates((current) => {\n if (on === null ? !current.has(id) : current.get(id) === on) return current;\n const next = new Map(current);\n if (on === null) next.delete(id);\n else next.set(id, on);\n latest.current = next;\n return next;\n }),\n };\n }\n let active = 0;\n for (const on of states.values()) if (on) active++;\n const total = states.size;\n const notify = useRef(props.onActiveCountChange);\n notify.current = props.onActiveCountChange;\n useEffect(() => {\n notify.current?.(active, total);\n }, [active, total]);\n const warn = minOneActive && active <= 1;\n return (\n <SwitchGroupContext.Provider value={value.current}>\n <view className={control.className} {...control.idProps}>\n {props.children}\n {props.showLiveStatus ? (\n <text\n className=\"g9-switch-group__status\"\n style={{ color: warn ? 'var(--g9-warning)' : 'var(--g9-text-tertiary)' }}\n >\n {`${active} / ${total}`}\n </text>\n ) : null}\n </view>\n </SwitchGroupContext.Provider>\n );\n}\n\n// ---- G9Switch ----------------------------------------------------------------------------------------------------\n\n/** Props of {@link G9Switch} (MAUI `G9Switch`). */\nexport interface G9SwitchProps extends G9ControlBaseProps {\n /** Controlled state (MAUI `IsOn`). */\n readonly checked?: boolean;\n readonly defaultChecked?: boolean;\n /**\n * Once per change made by the switch: a tap, `toggle()`, or being turned off by its selection group (MAUI\n * `Toggled`). Never for a value the parent pushed in.\n */\n readonly onCheckedChange?: (checked: boolean) => void;\n /** A tap cannot turn it off (it shakes); code still can. Default false. */\n readonly isRequired?: boolean;\n /** Radio group name: turning this on turns off the others with the same name under the same provider. */\n readonly selectionGroup?: string | null;\n /** Form row: title/description fill the start, switch at the end, padded. Default false. */\n readonly isInFormRow?: boolean;\n /** Bold 14 title (form row only); the accessibility name. */\n readonly title?: string | null;\n /** 12 px description under the title (form row only). */\n readonly description?: string | null;\n}\n\n/** Imperative handle of {@link G9Switch}. */\nexport interface G9SwitchHandle {\n /** Same as a tap. */\n toggle(): void;\n}\n\nlet switchIds = 0;\n\n/**\n * Switch (MAUI `G9Switch`): 56 × 32 track, 24 px thumb that stretches while travelling, 240 ms spring-like CSS\n * transition, tick/dot track mark; RTL moves the \"on\" side to the left unless `toggles.switchMirrorInRtl` is false. A blocked tap (required, or the last active\n * switch of a `minOneActive` group) shakes instead of toggling. Disabled: opacity 0.45.\n */\nexport const G9Switch = forwardRef<G9SwitchHandle, G9SwitchProps>(function G9Switch(props, ref): ReactNode {\n const control = useG9Control(props, 'g9-switch', {\n kind: 'toggle',\n label: () => props.accessibilityLabel ?? props.title,\n capabilities: {\n activate: () => press(),\n getValue: () => String(checked),\n setValue: (v) => {\n if ((v === 'true') !== checked) press();\n return String(v === 'true');\n },\n },\n });\n const theme = useG9Theme();\n const strings = useG9Strings();\n const settings = useG9Settings();\n const core = useContext(G9CoreContext);\n const group = useContext(SwitchGroupContext);\n const [checked, setChecked] = useControllableState<boolean>({\n value: props.checked,\n defaultValue: props.defaultChecked ?? false,\n onChange: props.onCheckedChange,\n name: 'G9Switch.checked',\n });\n const [shake, setShake] = useState(0);\n const id = useRef(0);\n if (id.current === 0) id.current = ++switchIds;\n const latestChecked = useRef(checked);\n latestChecked.current = checked;\n const setRef = useRef(setChecked);\n setRef.current = setChecked;\n\n // Report to the group.\n useEffect(() => {\n group?.report(id.current, checked);\n }, [group, checked]);\n useEffect(() => () => group?.report(id.current, null), [group]);\n\n // Selection group registration (while mounted and named).\n const groupName = props.selectionGroup && props.selectionGroup.trim() !== '' ? props.selectionGroup : null;\n const scope: object = core ?? globalScope;\n const memberRef = useRef<GroupMember | null>(null);\n useEffect(() => {\n if (!groupName) return;\n const member: GroupMember = { turnOff: () => setRef.current(false) };\n const set = groupSet(scope, groupName);\n set.add(member);\n memberRef.current = member;\n return () => {\n set.delete(member);\n memberRef.current = null;\n };\n }, [groupName, scope]);\n useEffect(() => {\n if (!checked || !groupName) return;\n for (const other of groupSet(scope, groupName)) if (other !== memberRef.current) other.turnOff();\n }, [checked, groupName, scope]);\n\n const toggle = () => {\n if (control.disabled) return;\n const on = latestChecked.current;\n if (on && (props.isRequired || (group?.minOneActive && group.activeCount() <= 1))) {\n setShake((n) => n + 1);\n return;\n }\n setChecked(!on);\n };\n useImperativeHandle(ref, () => ({ toggle }));\n const press = useG9Press(toggle, { blocked: control.disabled, source: 'G9Switch', guardMs: 0 });\n\n // The row flows with the language; the toggle mirrors only while the app lets it (MAUI 1.4.10 MirrorInRtl).\n const rtl = control.direction === 'rtl' && settings.toggles.switchMirrorInRtl;\n const width = G9Metrics.SwitchWidth;\n const thumb = G9Metrics.SwitchThumb;\n const travel = width - 4 - thumb - 4;\n const x = (checked ? travel : 0) * (rtl ? -1 : 1);\n const track = formatColor(checked ? switchOnTrack(theme) : switchOffTrack(theme));\n const thumbColor = formatColor(checked ? switchThumbOn(theme) : switchThumbOff(theme));\n const form = props.isInFormRow === true;\n const title = props.title && props.title.trim() !== '' ? props.title : null;\n const description = props.description && props.description.trim() !== '' ? props.description : null;\n return (\n <view\n className={`${control.className}${form ? ' g9-switch--row' : ''}`}\n {...control.idProps}\n style={g9RowStyle(control.direction)}\n accessibility-element={true}\n accessibility-traits=\"button\"\n {...(checked ? { 'accessibility-value': strings.get(G9StringKey.Selected) } : {})}\n {...((props.accessibilityLabel ?? title)\n ? { 'accessibility-label': props.accessibilityLabel ?? title ?? '' }\n : {})}\n bindtap={press}\n >\n {form ? (\n <view className=\"g9-switch__text\">\n {title ? (\n <text className=\"g9-switch__title\" style={g9TextStart(control.direction)}>\n {title}\n </text>\n ) : null}\n {description ? (\n <text className=\"g9-switch__description\" style={g9TextStart(control.direction)}>\n {description}\n </text>\n ) : null}\n </view>\n ) : null}\n <view\n key={`shake-${shake}`}\n className={`g9-switch__track${shake > 0 ? ' g9-switch__track--shake' : ''}`}\n style={{ width: `${width}px`, height: `${G9Metrics.SwitchHeight}px`, backgroundColor: track }}\n >\n {/* MAUI G9SwitchDrawable.DrawTrackMark: the mark is ALWAYS 15 dp from the track's start edge — on, the thumb has\n travelled to the end and the tick shows beside it; off, the thumb covers the dot. (Centring the tick at\n the end put it under the thumb: no tick was ever visible.) */}\n <view className=\"g9-switch__mark\" style={{ [rtl ? 'right' : 'left']: checked ? '9px' : '12px' }}>\n {checked ? <text className=\"g9-switch__tick\">✓</text> : <view className=\"g9-switch__dot\" />}\n </view>\n <view\n className=\"g9-switch__thumb\"\n style={{\n [rtl ? 'right' : 'left']: '4px',\n width: `${thumb}px`,\n height: `${thumb}px`,\n backgroundColor: thumbColor,\n transform: `translateX(${x}px)`,\n }}\n />\n </view>\n </view>\n );\n});\n"],"names":["registries","WeakMap","globalScope","groupSet","scope","group","groups","Map","set","Set","SwitchGroupContext","createContext","G9SwitchGroup","props","control","useG9Control","states","setStates","useState","latest","useRef","minOneActive","minRef","value","n","on","id","current","next","active","total","notify","useEffect","warn","view","text","switchIds","G9Switch","forwardRef","ref","_props_defaultChecked","_props_accessibilityLabel","_ref","press","String","checked","v","theme","useG9Theme","strings","useG9Strings","settings","useG9Settings","core","useContext","G9CoreContext","setChecked","useControllableState","shake","setShake","latestChecked","setRef","groupName","memberRef","member","other","toggle","useImperativeHandle","useG9Press","rtl","width","G9Metrics","thumb","travel","x","track","formatColor","switchOnTrack","switchOffTrack","thumbColor","switchThumbOn","switchThumbOff","form","title","description","g9RowStyle","G9StringKey","g9TextStart"],"mappings":";;;;;;;;AAgCA,MAAMA,aAAa,IAAIC;AACvB,MAAMC,cAAc,CAAC;AAErB,SAASC,SAASC,KAAa,EAAEC,KAAa;IAC5C,IAAIC,SAASN,WAAW,GAAG,CAACI;IAC5B,IAAI,C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,OAAO,EAAE;QAC1B,OAAO,GAAGG,MAAM,EAAE,CAAC;QACnB,QAAQ,GAAGA,MAAM,EAAE,CAAC;QACpB,iBAAiBO;QACjB,WAAW,CAAC,WAAW,EAAEL,EAAE,GAAG,CAAC;IACjC,IACA;MACJ,EAAExC,KAAK;IACT,EAAEA;AAEN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@g9tm/lynxcontrols",
3
- "version": "1.4.11",
3
+ "version": "1.6.0",
4
4
  "description": "ReactLynx controls and overlay infrastructure: provider/host, sheets, popups, toasts, fields, buttons, pickers, tab view, tab bar, edge panel, swipe rows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -13,6 +13,21 @@
13
13
  "types": "./dist/index.d.ts",
14
14
  "default": "./dist/index.jsx"
15
15
  },
16
+ "./anchor": {
17
+ "source": "./src/anchor/index.ts",
18
+ "types": "./dist/anchor/index.d.ts",
19
+ "default": "./dist/anchor/index.jsx"
20
+ },
21
+ "./guide": {
22
+ "source": "./src/guide/index.ts",
23
+ "types": "./dist/guide/index.d.ts",
24
+ "default": "./dist/guide/index.jsx"
25
+ },
26
+ "./route": {
27
+ "source": "./src/route/index.ts",
28
+ "types": "./dist/route/index.d.ts",
29
+ "default": "./dist/route/index.jsx"
30
+ },
16
31
  "./base": {
17
32
  "source": "./src/base/index.ts",
18
33
  "types": "./dist/base/index.d.ts",
@@ -137,7 +152,7 @@
137
152
  "build": "rslib build"
138
153
  },
139
154
  "dependencies": {
140
- "@g9tm/lynxcontrols-foundation": "1.4.11",
155
+ "@g9tm/lynxcontrols-foundation": "1.6.0",
141
156
  "@lynx-js/lynx-ui-common": "3.139.0",
142
157
  "@lynx-js/lynx-ui-deferred-component": "3.139.0",
143
158
  "@lynx-js/lynx-ui-draggable": "3.139.0",