@g9tm/lynxcontrols 1.4.5 → 1.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/base/index.d.ts +1 -1
- package/dist/base/index.d.ts.map +1 -1
- package/dist/base/index.jsx +1 -1
- package/dist/base/pressable.d.ts.map +1 -1
- package/dist/base/pressable.jsx +2 -1
- package/dist/base/pressable.jsx.map +1 -1
- package/dist/base/selection-item.d.ts +9 -1
- package/dist/base/selection-item.d.ts.map +1 -1
- package/dist/base/selection-item.jsx +10 -1
- package/dist/base/selection-item.jsx.map +1 -1
- package/dist/button/button.css +20 -0
- package/dist/button/button.css.map +1 -1
- package/dist/button/header-action-button.d.ts +5 -0
- package/dist/button/header-action-button.d.ts.map +1 -1
- package/dist/button/header-action-button.jsx +6 -1
- package/dist/button/header-action-button.jsx.map +1 -1
- package/dist/button/visuals.d.ts.map +1 -1
- package/dist/button/visuals.jsx +1 -1
- package/dist/button/visuals.jsx.map +1 -1
- package/dist/cascade/cascade-panel.d.ts.map +1 -1
- package/dist/cascade/cascade-panel.jsx +2 -2
- package/dist/cascade/cascade-panel.jsx.map +1 -1
- package/dist/edge-panel/edge-panel.jsx +5 -5
- package/dist/edge-panel/edge-panel.jsx.map +1 -1
- package/dist/expander/expander.d.ts.map +1 -1
- package/dist/expander/expander.jsx +2 -1
- package/dist/expander/expander.jsx.map +1 -1
- package/dist/fields/editor.d.ts.map +1 -1
- package/dist/fields/editor.jsx +2 -2
- package/dist/fields/editor.jsx.map +1 -1
- package/dist/fields/fields.css +21 -0
- package/dist/fields/fields.css.map +1 -1
- package/dist/fields/index.d.ts +1 -1
- package/dist/fields/index.d.ts.map +1 -1
- package/dist/fields/index.jsx +1 -1
- package/dist/fields/outlined-field.d.ts +27 -1
- package/dist/fields/outlined-field.d.ts.map +1 -1
- package/dist/fields/outlined-field.jsx +29 -2
- package/dist/fields/outlined-field.jsx.map +1 -1
- package/dist/fields/text-entry.d.ts.map +1 -1
- package/dist/fields/text-entry.jsx +2 -2
- package/dist/fields/text-entry.jsx.map +1 -1
- package/dist/host/host.css.map +1 -1
- package/dist/host/host.d.ts +3 -2
- package/dist/host/host.d.ts.map +1 -1
- package/dist/host/host.jsx +2 -2
- package/dist/host/host.jsx.map +1 -1
- package/dist/pickers/combo-box.d.ts +8 -0
- package/dist/pickers/combo-box.d.ts.map +1 -1
- package/dist/pickers/combo-box.jsx +51 -9
- package/dist/pickers/combo-box.jsx.map +1 -1
- package/dist/pickers/date-time-picker.d.ts +2 -2
- package/dist/pickers/date-time-picker.d.ts.map +1 -1
- package/dist/pickers/date-time-picker.jsx +4 -3
- package/dist/pickers/date-time-picker.jsx.map +1 -1
- package/dist/pickers/date-time.d.ts +5 -2
- package/dist/pickers/date-time.d.ts.map +1 -1
- package/dist/pickers/date-time.jsx +1 -1
- package/dist/pickers/date-time.jsx.map +1 -1
- package/dist/pickers/picker-sheet.d.ts +6 -2
- package/dist/pickers/picker-sheet.d.ts.map +1 -1
- package/dist/pickers/picker-sheet.jsx +2 -3
- package/dist/pickers/picker-sheet.jsx.map +1 -1
- package/dist/pickers/picker.d.ts.map +1 -1
- package/dist/pickers/picker.jsx +3 -2
- package/dist/pickers/picker.jsx.map +1 -1
- package/dist/pickers/pickers.css +27 -0
- package/dist/pickers/pickers.css.map +1 -1
- package/dist/pickers/timespan-picker.d.ts.map +1 -1
- package/dist/pickers/timespan-picker.jsx +3 -2
- package/dist/pickers/timespan-picker.jsx.map +1 -1
- package/dist/pickers/trigger.d.ts +3 -1
- package/dist/pickers/trigger.d.ts.map +1 -1
- package/dist/pickers/trigger.jsx +6 -1
- package/dist/pickers/trigger.jsx.map +1 -1
- package/dist/plus-button/model.d.ts.map +1 -1
- package/dist/plus-button/model.jsx +5 -1
- package/dist/plus-button/model.jsx.map +1 -1
- package/dist/popup/frame.jsx +2 -2
- package/dist/popup/frame.jsx.map +1 -1
- package/dist/popup/service.d.ts.map +1 -1
- package/dist/popup/service.jsx +2 -2
- package/dist/popup/service.jsx.map +1 -1
- package/dist/provider/provider.css +4 -0
- package/dist/provider/provider.css.map +1 -1
- package/dist/provider/provider.d.ts.map +1 -1
- package/dist/provider/provider.jsx +4 -2
- package/dist/provider/provider.jsx.map +1 -1
- package/dist/provider/settings.d.ts +12 -0
- package/dist/provider/settings.d.ts.map +1 -1
- package/dist/provider/settings.jsx +6 -3
- package/dist/provider/settings.jsx.map +1 -1
- package/dist/provider/theme.css +4 -0
- package/dist/provider/theme.css.map +1 -1
- package/dist/range-slider/math.d.ts +14 -4
- package/dist/range-slider/math.d.ts.map +1 -1
- package/dist/range-slider/math.jsx +16 -4
- package/dist/range-slider/math.jsx.map +1 -1
- package/dist/range-slider/range-slider.css +17 -0
- package/dist/range-slider/range-slider.css.map +1 -1
- package/dist/range-slider/range-slider.d.ts +11 -0
- package/dist/range-slider/range-slider.d.ts.map +1 -1
- package/dist/range-slider/range-slider.jsx +35 -13
- package/dist/range-slider/range-slider.jsx.map +1 -1
- package/dist/selection/index.d.ts +2 -1
- package/dist/selection/index.d.ts.map +1 -1
- package/dist/selection/index.jsx +2 -1
- package/dist/selection/selection-sheet.d.ts +8 -1
- package/dist/selection/selection-sheet.d.ts.map +1 -1
- package/dist/selection/selection-sheet.jsx +64 -11
- package/dist/selection/selection-sheet.jsx.map +1 -1
- package/dist/selection/selection.css +7 -0
- package/dist/selection/selection.css.map +1 -1
- package/dist/selection/window.d.ts +29 -0
- package/dist/selection/window.d.ts.map +1 -0
- package/dist/selection/window.jsx +24 -0
- package/dist/selection/window.jsx.map +1 -0
- package/dist/sheet/frame.d.ts.map +1 -1
- package/dist/sheet/frame.jsx +35 -9
- package/dist/sheet/frame.jsx.map +1 -1
- package/dist/sheet/header.d.ts.map +1 -1
- package/dist/sheet/header.jsx +3 -1
- package/dist/sheet/header.jsx.map +1 -1
- package/dist/sheet/index.d.ts +2 -1
- package/dist/sheet/index.d.ts.map +1 -1
- package/dist/sheet/index.jsx +2 -1
- package/dist/sheet/motion.d.ts.map +1 -1
- package/dist/sheet/motion.jsx +14 -0
- package/dist/sheet/motion.jsx.map +1 -1
- package/dist/sheet/options.d.ts +26 -0
- package/dist/sheet/options.d.ts.map +1 -1
- package/dist/sheet/options.jsx +2 -1
- package/dist/sheet/options.jsx.map +1 -1
- package/dist/sheet/scroll-indicator.d.ts +33 -0
- package/dist/sheet/scroll-indicator.d.ts.map +1 -0
- package/dist/sheet/scroll-indicator.jsx +84 -0
- package/dist/sheet/scroll-indicator.jsx.map +1 -0
- package/dist/sheet/service.d.ts +8 -0
- package/dist/sheet/service.d.ts.map +1 -1
- package/dist/sheet/service.jsx +15 -4
- package/dist/sheet/service.jsx.map +1 -1
- package/dist/sheet/sheet.css +14 -0
- package/dist/sheet/sheet.css.map +1 -1
- package/dist/sheet/sizing.d.ts +2 -0
- package/dist/sheet/sizing.d.ts.map +1 -1
- package/dist/sheet/sizing.jsx +2 -1
- package/dist/sheet/sizing.jsx.map +1 -1
- package/dist/tab-bar/tab-bar.d.ts.map +1 -1
- package/dist/tab-bar/tab-bar.jsx +11 -6
- package/dist/tab-bar/tab-bar.jsx.map +1 -1
- package/dist/toast/service.jsx +3 -3
- package/dist/toast/service.jsx.map +1 -1
- package/dist/toast/store.d.ts.map +1 -1
- package/dist/toast/store.jsx +3 -2
- package/dist/toast/store.jsx.map +1 -1
- package/dist/toggle/chip-group.d.ts +9 -1
- package/dist/toggle/chip-group.d.ts.map +1 -1
- package/dist/toggle/chip-group.jsx +51 -12
- package/dist/toggle/chip-group.jsx.map +1 -1
- package/dist/toggle/switch.d.ts +1 -1
- package/dist/toggle/switch.d.ts.map +1 -1
- package/dist/toggle/switch.jsx +3 -2
- package/dist/toggle/switch.jsx.map +1 -1
- package/dist/toggle/toggle.css +20 -0
- package/dist/toggle/toggle.css.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickers/combo-box.jsx","sources":["../../src/pickers/combo-box.tsx"],"sourcesContent":["import './pickers.css';\nimport { buildSolidOrGradient, fillToCss, G9StringKey, type G9TextInputDirection } from '@g9tm/lynxcontrols-foundation';\nimport { type ReactNode, useRef } from '@lynx-js/react';\nimport { g9RowStyle } from '../base/control';\nimport { type G9SelectionItem, selectionKey } from '../base/selection-item';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { useG9Direction, useG9Settings, useG9Strings, useG9Theme } from '../provider/hooks';\nimport { showSelectionSheet } from '../selection/selection-sheet';\nimport { useG9Sheets } from '../sheet/service';\nimport {\n type G9PickerFieldProps,\n PickerField,\n SelectionValueIcon,\n usePickerOpen,\n valueDirection,\n valueDirectionClass,\n} from './trigger';\n\n/** Chips shown in the box before the `+N` overflow chip (MAUI combo). */\nexport const g9ComboMaxChips = 2;\n\n/** Props of {@link G9ComboBox}. */\nexport interface G9ComboBoxProps<T extends G9SelectionItem = G9SelectionItem> extends G9PickerFieldProps {\n /** The rows (MAUI `ItemsSource`). Disabled items are left out except selected ones (shown dimmed). */\n readonly items: ReadonlyArray<T>;\n /** Multi-selection (MAUI `AllowMultipleSelection`): `values` instead of `value`, Done commits. Default false. */\n readonly allowMultiple?: boolean;\n /** Single mode: the selected key (MAUI `SelectedItem`). */\n readonly value?: string | null;\n readonly defaultValue?: string | null;\n readonly onValueChange?: (key: string | null, item: T | null) => void;\n /** Multi mode: the selected keys, in list order (MAUI `SelectedItems`). */\n readonly values?: ReadonlyArray<string>;\n readonly defaultValues?: ReadonlyArray<string>;\n readonly onValuesChange?: (keys: ReadonlyArray<string>, items: ReadonlyArray<T>) => void;\n /** Sheet title; default the label, else the placeholder. */\n readonly sheetTitle?: string | null;\n /** Text when the search finds nothing (MAUI `EmptyStateText`, default localized \"No results\"). */\n readonly emptyStateText?: string | null;\n /** A × in the trailing slot clears the selection while there is one (MAUI `ClearButton`). Default true. */\n readonly clearButton?: boolean;\n /** Direction of the value/chips and the sheet rows (MAUI `ValueTextDirection`). Default follows the culture. */\n readonly valueTextDirection?: G9TextInputDirection;\n}\n\n/** Two key lists hold the same keys in the same order. */\nexport function sameSelectionKeys(a: ReadonlyArray<string>, b: ReadonlyArray<string>): boolean {\n return a.length === b.length && a.every((k, i) => k === b[i]);\n}\nconst sameKeys = sameSelectionKeys;\n\n/**\n * Searchable single or multi selection in an outlined box (MAUI `G9ComboBox`). The sheet always has search. Single:\n * only a pick writes the value; a dismissal leaves it. Multi: Done commits, and so does dismissing a sheet whose\n * selection changed; an untouched dismissal writes nothing. The box shows the value (icon or swatch + text), or up\n * to two chips and a `+N` chip; with `clearButton` the trailing search glyph becomes × while there is a value and a\n * tap on it clears without opening. A result that arrives after the field unmounted, or after a newer open, is\n * dropped.\n */\nexport function G9ComboBox<T extends G9SelectionItem = G9SelectionItem>(props: G9ComboBoxProps<T>): ReactNode {\n const sheets = useG9Sheets();\n const glyphs = useG9Settings().glyphs;\n const strings = useG9Strings();\n const culture = useG9Direction();\n const primary = useG9Theme().palette.Primary;\n const open = usePickerOpen();\n const multiple = props.allowMultiple === true;\n const byKey = (keys: ReadonlyArray<string>) =>\n keys.map((k) => props.items.find((i) => selectionKey(i) === k)).filter((i): i is T => i !== undefined);\n const [key, setKey] = useControllableState<string | null, [T | null]>({\n value: props.value,\n defaultValue: props.defaultValue ?? null,\n onChange: props.onValueChange,\n name: 'G9ComboBox.value',\n });\n const [keys, setKeys] = useControllableState<ReadonlyArray<string>, [ReadonlyArray<T>]>({\n value: props.values,\n defaultValue: props.defaultValues ?? [],\n onChange: props.onValuesChange,\n name: 'G9ComboBox.values',\n equals: sameKeys,\n });\n const latest = useRef({ props, key, keys });\n latest.current = { props, key, keys };\n\n const selected = multiple ? byKey(keys) : byKey(key === null ? [] : [key]);\n const hasValue = selected.length > 0;\n const blocked = props.disabled === true || props.readOnly === true;\n\n const clear = () => {\n if (multiple) setKeys([], []);\n else setKey(null, null);\n };\n\n const onOpen = () =>\n open(async (isCurrent) => {\n const { props: p, key: k, keys: ks } = latest.current;\n const current = p.allowMultiple ? ks : k === null ? [] : [k];\n const picked = current\n .map((c) => p.items.find((i) => selectionKey(i) === c))\n .filter((i): i is T => i !== undefined);\n const items = p.items.filter((i) => i.isEnabled !== false || picked.includes(i));\n if (items.length === 0) return;\n const result = await showSelectionSheet(sheets, {\n title: p.sheetTitle?.trim() ? p.sheetTitle : (p.label ?? p.placeholder ?? ''),\n items,\n selectedItems: picked,\n allowMultiple: p.allowMultiple === true,\n closeOnSingleSelection: p.allowMultiple !== true,\n showSearch: true,\n emptyText: p.emptyStateText ?? strings.get(G9StringKey.NoResults),\n ...(p.valueTextDirection ? { itemTextDirection: p.valueTextDirection } : {}),\n });\n if (!isCurrent()) return;\n if (p.allowMultiple) {\n if (!result.wasAccepted && !result.selectionChanged) return;\n const next = result.items.map(selectionKey);\n if (sameKeys(next, latest.current.keys)) return;\n setKeys(next, result.items);\n } else if (result.wasAccepted) {\n const item = result.items[0] ?? null;\n setKey(item ? selectionKey(item) : null, item);\n }\n });\n\n const showClear = props.clearButton !== false && hasValue && !blocked;\n const dir = valueDirectionClass(props.valueTextDirection, culture);\n const row = g9RowStyle(valueDirection(props.valueTextDirection, culture));\n return (\n <PickerField\n field={{ trailingIcon: glyphs.search, ...props }}\n hasValue={hasValue}\n onOpen={onOpen}\n trailingAffordance={\n showClear\n ? { icon: glyphs.clear, signature: 'clear', label: strings.get(G9StringKey.Clear), onPress: clear }\n : null\n }\n >\n <view className={`g9-combo__value ${dir}`} style={row}>\n {multiple && hasValue ? (\n <view className=\"g9-combo__chips\" style={row}>\n {selected.slice(0, g9ComboMaxChips).map((item) => (\n // MAUI G9Colors.BuildSolidOrGradient(palette.Primary, useGradient: true).\n <view\n key={selectionKey(item)}\n className=\"g9-combo__chip\"\n style={{ ...row, background: fillToCss(buildSolidOrGradient(primary, true)) }}\n >\n <SelectionValueIcon item={item} color=\"var(--g9-on-primary)\" />\n <text className=\"g9-combo__chip-text\" text-maxline=\"1\">\n {item.text}\n </text>\n </view>\n ))}\n {selected.length > g9ComboMaxChips ? (\n <view className=\"g9-combo__chip g9-combo__chip--more\">\n <text className=\"g9-combo__chip-text\">{`+${selected.length - g9ComboMaxChips}`}</text>\n </view>\n ) : null}\n </view>\n ) : (\n [\n hasValue ? <SelectionValueIcon key=\"i\" item={selected[0] as T} /> : null,\n <text\n key=\"t\"\n className={`g9-picker__text${hasValue ? '' : ' g9-picker__text--placeholder'}`}\n text-maxline=\"1\"\n >\n {hasValue ? (selected[0] as T).text : props.label ? '' : (props.placeholder ?? '')}\n </text>,\n ]\n )}\n </view>\n </PickerField>\n );\n}\n"],"names":["g9ComboMaxChips","sameSelectionKeys","a","b","k","i","sameKeys","G9ComboBox","props","_props_defaultValue","_props_defaultValues","_props_placeholder","sheets","useG9Sheets","glyphs","useG9Settings","strings","useG9Strings","culture","useG9Direction","primary","useG9Theme","open","usePickerOpen","multiple","byKey","keys","selectionKey","undefined","key","setKey","useControllableState","setKeys","latest","useRef","selected","hasValue","blocked","clear","onOpen","isCurrent","_ref","_p_emptyStateText","_p_sheetTitle","p","ks","current","picked","c","items","result","showSelectionSheet","G9StringKey","next","_result_items_","item","showClear","dir","valueDirectionClass","row","g9RowStyle","valueDirection","PickerField","view","fillToCss","buildSolidOrGradient","SelectionValueIcon","text"],"mappings":";;;;;;;;;;AAmBO,MAAMA,kBAAkB;AA2BxB,SAASC,kBAAkBC,CAAwB,EAAEC,CAAwB;IAClF,OAAOD,EAAE,MAAM,KAAKC,EAAE,MAAM,IAAID,EAAE,KAAK,CAAC,CAACE,GAAGC,IAAMD,MAAMD,CAAC,CAACE,EAAE;AAC9D;AACA,MAAMC,WAAWL;AAUV,SAASM,WAAwDC,KAAyB;QAY/EC,qBAMAC,sBA4FsDC;IA7GtE,MAAMC,SAASC;IACf,MAAMC,SAASC,gBAAgB,MAAM;IACrC,MAAMC,UAAUC;IAChB,MAAMC,UAAUC;IAChB,MAAMC,UAAUC,aAAa,OAAO,CAAC,OAAO;IAC5C,MAAMC,OAAOC;IACb,MAAMC,WAAWhB,A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B,CAAC,CAAC,EAAEhC,SAAS,MAAM,GAAGnC,iBAAiB,GAAGmE,KAAK;cACxF,EAAEJ,QACA,KAAK;UACX,EAAEA,QAEF;QACE3B,YAAY8B,mBAAmB,IAAI,IAAI,MAAM/B,QAAQ,CAAC,EAAE,MAAY;SACnEgC,KACC,IAAI,IACJ,WAAW,CAAC,eAAe,EAAE/B,WAAW,KAAK,iCAAiC,EAC9E,aAAa,IACd;cACC,CAACA,WAAYD,QAAQ,CAAC,EAAE,CAAO,IAAI,GAAG3B,MAAM,KAAK,GAAG,KAAK,QAACG,CAAAA,qBAAAA,MAAM,WAAW,AAAD,IAAhBA,qBAAqB,GAAI;YACrF,EAAEwD;KACH,CACD;MACJ,EAAEJ,KAAK;IACT,EAAED;AAEN"}
|
|
1
|
+
{"version":3,"file":"pickers/combo-box.jsx","sources":["../../src/pickers/combo-box.tsx"],"sourcesContent":["import { resolveRestingPlaceholder } from '../fields/outlined-field';\nimport './pickers.css';\nimport { buildSolidOrGradient, fillToCss, G9StringKey, type G9TextInputDirection } from '@g9tm/lynxcontrols-foundation';\nimport { type ReactNode, useRef } from '@lynx-js/react';\nimport { g9RowStyle } from '../base/control';\nimport { type G9SelectionItem, isAvatarImage, selectionKey } from '../base/selection-item';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { G9IconSlot, hasIconSlot } from '../icon/slot';\nimport { useG9Direction, useG9Settings, useG9Strings, useG9Theme } from '../provider/hooks';\nimport { showSelectionSheet } from '../selection/selection-sheet';\nimport { useG9Sheets } from '../sheet/service';\nimport {\n type G9PickerFieldProps,\n PickerField,\n SelectionValueIcon,\n usePickerOpen,\n valueDirection,\n valueDirectionClass,\n} from './trigger';\n\n/** Chips shown in the box before the `+N` overflow chip (MAUI combo). */\nexport const g9ComboMaxChips = 2;\n\n/** Props of {@link G9ComboBox}. */\nexport interface G9ComboBoxProps<T extends G9SelectionItem = G9SelectionItem> extends G9PickerFieldProps {\n /** The rows (MAUI `ItemsSource`). Disabled items are left out except selected ones (shown dimmed). */\n readonly items: ReadonlyArray<T>;\n /** Multi-selection (MAUI `AllowMultipleSelection`): `values` instead of `value`, Done commits. Default false. */\n readonly allowMultiple?: boolean;\n /** Single mode: the selected key (MAUI `SelectedItem`). */\n readonly value?: string | null;\n readonly defaultValue?: string | null;\n readonly onValueChange?: (key: string | null, item: T | null) => void;\n /** Multi mode: the selected keys, in list order (MAUI `SelectedItems`). */\n readonly values?: ReadonlyArray<string>;\n readonly defaultValues?: ReadonlyArray<string>;\n readonly onValuesChange?: (keys: ReadonlyArray<string>, items: ReadonlyArray<T>) => void;\n /** Sheet title; default the label, else the placeholder. */\n readonly sheetTitle?: string | null;\n /** Text when the search finds nothing (MAUI `EmptyStateText`, default localized \"No results\"). */\n readonly emptyStateText?: string | null;\n /** A × in the trailing slot clears the selection while there is one (MAUI `ClearButton`). Default true. */\n readonly clearButton?: boolean;\n /** Direction of the value/chips and the sheet rows (MAUI `ValueTextDirection`). Default follows the culture. */\n readonly valueTextDirection?: G9TextInputDirection;\n /**\n * How a multi-select field draws its chosen items (MAUI 1.4.10 `ChipStyle`): `'filled'` (default — primary chips) or\n * `'tonal'` — light pills (SurfaceContainerLow, an OutlineVariant hairline, TextPrimary 14) each with its own «×» that\n * removes that one item without opening the sheet. Pair with `clearButton={false}` to keep the trailing glyph (AgriPad).\n */\n readonly chipStyle?: G9ComboBoxChipStyle;\n}\n\n/** MAUI `G9ComboBoxChipStyle`. */\nexport type G9ComboBoxChipStyle = 'filled' | 'tonal';\n\n/** Two key lists hold the same keys in the same order. */\nexport function sameSelectionKeys(a: ReadonlyArray<string>, b: ReadonlyArray<string>): boolean {\n return a.length === b.length && a.every((k, i) => k === b[i]);\n}\nconst sameKeys = sameSelectionKeys;\n\n/**\n * Searchable single or multi selection in an outlined box (MAUI `G9ComboBox`). The sheet always has search. Single:\n * only a pick writes the value; a dismissal leaves it. Multi: Done commits, and so does dismissing a sheet whose\n * selection changed; an untouched dismissal writes nothing. The box shows the value (icon or swatch + text), or up\n * to two chips and a `+N` chip; with `clearButton` the trailing search glyph becomes × while there is a value and a\n * tap on it clears without opening. A result that arrives after the field unmounted, or after a newer open, is\n * dropped.\n */\nexport function G9ComboBox<T extends G9SelectionItem = G9SelectionItem>(props: G9ComboBoxProps<T>): ReactNode {\n const sheets = useG9Sheets();\n const glyphs = useG9Settings().glyphs;\n const strings = useG9Strings();\n const culture = useG9Direction();\n const primary = useG9Theme().palette.Primary;\n const open = usePickerOpen();\n const multiple = props.allowMultiple === true;\n const byKey = (keys: ReadonlyArray<string>) =>\n keys.map((k) => props.items.find((i) => selectionKey(i) === k)).filter((i): i is T => i !== undefined);\n const [key, setKey] = useControllableState<string | null, [T | null]>({\n value: props.value,\n defaultValue: props.defaultValue ?? null,\n onChange: props.onValueChange,\n name: 'G9ComboBox.value',\n });\n const [keys, setKeys] = useControllableState<ReadonlyArray<string>, [ReadonlyArray<T>]>({\n value: props.values,\n defaultValue: props.defaultValues ?? [],\n onChange: props.onValuesChange,\n name: 'G9ComboBox.values',\n equals: sameKeys,\n });\n const latest = useRef({ props, key, keys });\n latest.current = { props, key, keys };\n\n const selected = multiple ? byKey(keys) : byKey(key === null ? [] : [key]);\n const hasValue = selected.length > 0;\n const blocked = props.disabled === true || props.readOnly === true;\n\n const clear = () => {\n if (multiple) setKeys([], []);\n else setKey(null, null);\n };\n // A tonal chip's «×» (MAUI RemoveSelected): one item out, the sheet stays closed (catchtap keeps the box's tap away).\n const removeOne = (item: T) => {\n if (blocked) return;\n const k = selectionKey(item);\n const next = latest.current.keys.filter((x) => x !== k);\n if (next.length !== latest.current.keys.length) setKeys(next, byKey(next));\n };\n const tonal = props.chipStyle === 'tonal';\n\n const onOpen = () =>\n open(async (isCurrent) => {\n const { props: p, key: k, keys: ks } = latest.current;\n const current = p.allowMultiple ? ks : k === null ? [] : [k];\n const picked = current\n .map((c) => p.items.find((i) => selectionKey(i) === c))\n .filter((i): i is T => i !== undefined);\n const items = p.items.filter((i) => i.isEnabled !== false || picked.includes(i));\n if (items.length === 0) return;\n const result = await showSelectionSheet(sheets, {\n title: p.sheetTitle?.trim() ? p.sheetTitle : (p.label ?? p.placeholder ?? ''),\n items,\n selectedItems: picked,\n allowMultiple: p.allowMultiple === true,\n closeOnSingleSelection: p.allowMultiple !== true,\n showSearch: true,\n emptyText: p.emptyStateText ?? strings.get(G9StringKey.NoResults),\n ...(p.valueTextDirection ? { itemTextDirection: p.valueTextDirection } : {}),\n });\n if (!isCurrent()) return;\n if (p.allowMultiple) {\n if (!result.wasAccepted && !result.selectionChanged) return;\n const next = result.items.map(selectionKey);\n if (sameKeys(next, latest.current.keys)) return;\n setKeys(next, result.items);\n } else if (result.wasAccepted) {\n const item = result.items[0] ?? null;\n setKey(item ? selectionKey(item) : null, item);\n }\n });\n\n const showClear = props.clearButton !== false && hasValue && !blocked;\n const dir = valueDirectionClass(props.valueTextDirection, culture);\n const row = g9RowStyle(valueDirection(props.valueTextDirection, culture));\n return (\n <PickerField\n field={{ trailingIcon: glyphs.search, ...props }}\n hasValue={hasValue}\n onOpen={onOpen}\n trailingAffordance={\n showClear\n ? { icon: glyphs.clear, signature: 'clear', label: strings.get(G9StringKey.Clear), onPress: clear }\n : null\n }\n >\n <view className={`g9-combo__value ${dir}`} style={row}>\n {multiple && hasValue ? (\n <view className=\"g9-combo__chips\" style={row}>\n {selected.slice(0, g9ComboMaxChips).map((item) =>\n tonal ? (\n <TonalChip\n key={selectionKey(item)}\n item={item}\n row={row}\n rtl={valueDirection(props.valueTextDirection, culture) === 'rtl'}\n removable={!blocked}\n onRemove={() => removeOne(item)}\n />\n ) : (\n // MAUI G9Colors.BuildSolidOrGradient(palette.Primary, useGradient: true).\n <view\n key={selectionKey(item)}\n className=\"g9-combo__chip\"\n style={{ ...row, background: fillToCss(buildSolidOrGradient(primary, true)) }}\n >\n <SelectionValueIcon item={item} color=\"var(--g9-on-primary)\" inChip />\n <text className=\"g9-combo__chip-text\" text-maxline=\"1\">\n {item.text}\n </text>\n </view>\n ),\n )}\n {selected.length > g9ComboMaxChips ? (\n <view className=\"g9-combo__chip g9-combo__chip--more\">\n <text className=\"g9-combo__chip-text\">{`+${selected.length - g9ComboMaxChips}`}</text>\n </view>\n ) : null}\n </view>\n ) : (\n [\n hasValue ? <SelectionValueIcon key=\"i\" item={selected[0] as T} /> : null,\n <text\n key=\"t\"\n className={`g9-picker__text${hasValue ? '' : ' g9-picker__text--placeholder'}`}\n text-maxline=\"1\"\n >\n {hasValue ? (selected[0] as T).text : (resolveRestingPlaceholder(props) ?? '')}\n </text>,\n ]\n )}\n </view>\n </PickerField>\n );\n}\n\n/**\n * A `chipStyle: 'tonal'` chip (MAUI 1.4.10 `CreateTonalChip`): 34 high, fully rounded, SurfaceContainerLow on a 1 px\n * OutlineVariant hairline, padding 10 at the start and 6 at the end, 4 after it; an icon (never an avatar) at 14, the text\n * in TextPrimary 14, then a 24 px «×» (TextTertiary 16) that removes this item. Only the «×» takes the tap — the rest of\n * the chip lets it through to the field, which opens the sheet.\n */\nfunction TonalChip(props: {\n readonly item: G9SelectionItem;\n readonly row: ReturnType<typeof g9RowStyle>;\n readonly rtl: boolean;\n readonly removable: boolean;\n readonly onRemove: () => void;\n}): ReactNode {\n const glyphs = useG9Settings().glyphs;\n const { item } = props;\n const icon = {\n emoji: item.emoji ?? null,\n icon: item.icon,\n imagePath: item.iconPath ?? null,\n image: item.iconImage ?? null,\n };\n return (\n // Physical sides from the row's direction (a row never relies on CSS `direction` — Lynxtron ignores it).\n <view\n className=\"g9-combo__tonal\"\n style={{\n ...props.row,\n ...(props.rtl\n ? { paddingRight: '10px', paddingLeft: '6px', marginLeft: '4px' }\n : { paddingLeft: '10px', paddingRight: '6px', marginRight: '4px' }),\n }}\n >\n {!isAvatarImage(item) && hasIconSlot(icon) ? (\n <G9IconSlot {...icon} size={14} color={item.iconTintColor ?? 'var(--g9-on-surface-variant)'} />\n ) : null}\n <text className=\"g9-combo__tonal-text\" text-maxline=\"1\">\n {item.text}\n </text>\n <view\n className=\"g9-combo__tonal-close\"\n accessibility-element={true}\n accessibility-traits=\"button\"\n accessibility-label={item.text}\n {...(props.removable ? { catchtap: props.onRemove } : {})}\n >\n <G9IconSlot icon={glyphs.clear} size={16} color=\"var(--g9-text-tertiary)\" />\n </view>\n </view>\n );\n}\n"],"names":["g9ComboMaxChips","sameSelectionKeys","a","b","k","i","sameKeys","G9ComboBox","props","_props_defaultValue","_props_defaultValues","_resolveRestingPlaceholder","sheets","useG9Sheets","glyphs","useG9Settings","strings","useG9Strings","culture","useG9Direction","primary","useG9Theme","open","usePickerOpen","multiple","byKey","keys","selectionKey","undefined","key","setKey","useControllableState","setKeys","latest","useRef","selected","hasValue","blocked","clear","removeOne","item","next","x","tonal","onOpen","isCurrent","_ref","_p_emptyStateText","_p_sheetTitle","p","ks","current","picked","c","items","result","showSelectionSheet","G9StringKey","_result_items_","showClear","dir","valueDirectionClass","row","g9RowStyle","valueDirection","PickerField","view","TonalChip","fillToCss","buildSolidOrGradient","SelectionValueIcon","text","_item_emoji","_item_iconPath","_item_iconImage","_item_iconTintColor","icon","isAvatarImage","hasIconSlot","G9IconSlot"],"mappings":";;;;;;;;;;;;AAqBO,MAAMA,kBAAkB;AAoCxB,SAASC,kBAAkBC,CAAwB,EAAEC,CAAwB;IAClF,OAAOD,EAAE,MAAM,KAAKC,EAAE,MAAM,IAAID,EAAE,KAAK,CAAC,CAACE,GAAGC,IAAMD,MAAMD,CAAC,CAACE,EAAE;AAC9D;AACA,MAAMC,WAAWL;AAUV,SAASM,WAAwDC,KAAyB;QAY/EC,qBAMAC,sBA+GmCC;IAhInD,MAAMC,SAASC;IACf,MAAMC,SAASC,gBAAgB,MAAM;IACrC,MAAMC,UAAUC;IAChB,MAAMC,UAAUC;IAChB,MAAMC,UAAUC,aAAa,OAAO,CAAC,OAAO;IAC5C,MAAMC,OAAOC;IACb,MAAMC,WAAWhB,AAAwB,SAAxBA,MAAM,aAAa;IACpC,MAAMiB,QAAQ,CAACC,OACbA,KAAK,GAAG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AAAD,IAAbA,kBAAkB;IAC3B;IACA,QAEGR,KACC,UAAU,kBACV,OAAO;QACL,GAAG1D,MAAM,GAAG;QACZ,GAAIA,MAAM,GAAG,GACT;YAAE,cAAc;YAAQ,aAAa;YAAO,YAAY;QAAM,IAC9D;YAAE,aAAa;YAAQ,cAAc;YAAO,aAAa;QAAM,CAAC;IACtE,GACD;MACC,CAAC,CAACqE,cAAcrC,SAASsC,YAAYF,SAClCG,YAAY,GAAGH,IAAI,EAAE,MAAM,IAAI,OAAO,QAAAD,CAAAA,sBAAAA,KAAK,aAAa,AAAD,IAAjBA,sBAAsB,oCAC3D,KAAK;MACT,CAACJ,KAAK,UAAU,uBAAuB,aAAa,IAAI;QACtD,CAAC/B,KAAK,IAAI,CAAC;MACb,EAAE+B,KAAK;MACP,CAACL,KACC,UAAU,wBACV,uBAAuB,MACvB,qBAAqB,SACrB,qBAAqB1B,KAAK,IAAI,GAC7B,GAAIhC,MAAM,SAAS,GAAG;QAAE,UAAUA,MAAM,QAAQ;IAAC,IAAI,CAAC,CAAC,EACzD;QACC,CAACuE,WAAW,MAAMjE,OAAO,KAAK,EAAE,MAAM,IAAI,MAAM,2BAA4B;MAC9E,EAAEoD,KAAK;IACT,EAAEA;AAEN"}
|
|
@@ -2,8 +2,8 @@ import './pickers.css';
|
|
|
2
2
|
import { type G9CalendarSystem, type G9Culture, G9DateTimeDisplayFormat, G9DateTimePickerMode, type G9LocalDate, type G9LocalDateTime } from '@g9tm/lynxcontrols-foundation';
|
|
3
3
|
import { type ReactNode } from '@lynx-js/react';
|
|
4
4
|
import { type G9PickerFieldProps } from './trigger.js';
|
|
5
|
-
/** Years the year window grows by at an edge (MAUI `YearWindowStep
|
|
6
|
-
export declare const g9YearWindowStep =
|
|
5
|
+
/** Years the year window grows by at an edge (MAUI `YearWindowStep`: 12 since 1.4.11, was 25). */
|
|
6
|
+
export declare const g9YearWindowStep = 12;
|
|
7
7
|
/** Props of {@link G9DateTimePicker}. */
|
|
8
8
|
export interface G9DateTimePickerProps extends G9PickerFieldProps {
|
|
9
9
|
/** The value, always Gregorian (MAUI `SelectedDateTime`); `null` = none. Controlled with `onValueChange`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-time-picker.d.ts","sourceRoot":"","sources":["../../src/pickers/date-time-picker.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"date-time-picker.d.ts","sourceRoot":"","sources":["../../src/pickers/date-time-picker.tsx"],"names":[],"mappings":"AACA,OAAO,eAAe,CAAC;AACvB,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,uBAAuB,EACvB,oBAAoB,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EAIrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,gBAAgB,CAAC;AAuBlE,OAAO,EAAE,KAAK,kBAAkB,EAA8B,MAAM,WAAW,CAAC;AAGhF,kGAAkG;AAClG,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,yCAAyC;AACzC,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,6GAA6G;IAC7G,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,YAAY,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC/C,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,CAAC;IACjE,wBAAwB;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,oBAAoB,CAAC;IACrC,6BAA6B;IAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACjD,mEAAmE;IACnE,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,OAA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BAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,CA6ExE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveRestingPlaceholder } from "../fields/outlined-field.jsx";
|
|
1
2
|
import "./pickers.css";
|
|
2
3
|
import { G9DateTimeDisplayFormat, G9DateTimePickerMode, G9StringKey, daysInMonth, formatColor, localDateTimeFromDate, withAlpha } from "@g9tm/lynxcontrols-foundation";
|
|
3
4
|
import { useRef, useState } from "@lynx-js/react";
|
|
@@ -11,7 +12,7 @@ import { asDateTime, clampPickerValue, composePickerValue, dayWheelItems, format
|
|
|
11
12
|
import { PickerSheetHeader, showPickerSheet } from "./picker-sheet.jsx";
|
|
12
13
|
import { PickerField, usePickerOpen } from "./trigger.jsx";
|
|
13
14
|
import { G9WheelColumn } from "./wheel-column.jsx";
|
|
14
|
-
const g9YearWindowStep =
|
|
15
|
+
const g9YearWindowStep = 12;
|
|
15
16
|
function DateTimeSheetBody(props) {
|
|
16
17
|
const strings = useG9Strings();
|
|
17
18
|
const palette = useG9Theme().palette;
|
|
@@ -88,7 +89,7 @@ function DateTimeSheetBody(props) {
|
|
|
88
89
|
</view>;
|
|
89
90
|
}
|
|
90
91
|
function G9DateTimePicker(props) {
|
|
91
|
-
var _props_defaultValue, _props_mode,
|
|
92
|
+
var _props_defaultValue, _props_mode, _resolveRestingPlaceholder;
|
|
92
93
|
const sheets = useG9Sheets();
|
|
93
94
|
const culture = useG9Culture();
|
|
94
95
|
const strings = useG9Strings();
|
|
@@ -141,7 +142,7 @@ function G9DateTimePicker(props) {
|
|
|
141
142
|
...props
|
|
142
143
|
}} hasValue={null !== value} onOpen={onOpen}>
|
|
143
144
|
<text className={`g9-picker__text${value ? '' : ' g9-picker__text--placeholder'}`} text-maxline="1">
|
|
144
|
-
{value ? format(value) :
|
|
145
|
+
{value ? format(value) : null != (_resolveRestingPlaceholder = resolveRestingPlaceholder(props)) ? _resolveRestingPlaceholder : ''}
|
|
145
146
|
</text>
|
|
146
147
|
</PickerField>;
|
|
147
148
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickers/date-time-picker.jsx","sources":["../../src/pickers/date-time-picker.tsx"],"sourcesContent":["import './pickers.css';\nimport {\n daysInMonth,\n formatColor,\n type G9CalendarSystem,\n type G9Culture,\n G9DateTimeDisplayFormat,\n G9DateTimePickerMode,\n type G9LocalDate,\n type G9LocalDateTime,\n G9StringKey,\n localDateTimeFromDate,\n withAlpha,\n} from '@g9tm/lynxcontrols-foundation';\nimport { type ReactNode, useRef, useState } from '@lynx-js/react';\nimport { g9RowStyle } from '../base/control';\nimport { useG9Press } from '../base/press';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { G9IconSlot } from '../icon/slot';\nimport { useG9Culture, useG9Service, useG9Settings, useG9Strings, useG9Theme } from '../provider/hooks';\nimport { useG9Sheets } from '../sheet/service';\nimport {\n asDateTime,\n clampPickerValue,\n composePickerValue,\n dayWheelItems,\n formatPickerValue,\n hourWheelItems,\n minuteWheelItems,\n monthWheelItems,\n normalizePickerBounds,\n pickerParts,\n resolvePickerCalendar,\n yearWheelItems,\n yearWindow,\n} from './date-time';\nimport { PickerSheetHeader, showPickerSheet } from './picker-sheet';\nimport { type G9PickerFieldProps, PickerField, usePickerOpen } from './trigger';\nimport { G9WheelColumn } from './wheel-column';\n\n/** Years the year window grows by at an edge (MAUI `YearWindowStep`). */\nexport const g9YearWindowStep = 25;\n\n/** Props of {@link G9DateTimePicker}. */\nexport interface G9DateTimePickerProps extends G9PickerFieldProps {\n /** The value, always Gregorian (MAUI `SelectedDateTime`); `null` = none. Controlled with `onValueChange`. */\n readonly value?: G9LocalDateTime | null;\n readonly defaultValue?: G9LocalDateTime | null;\n readonly onValueChange?: (value: G9LocalDateTime | null) => void;\n /** Default `'date'`. */\n readonly mode?: G9DateTimePickerMode;\n /** Default `'shortDate'`. */\n readonly displayFormat?: G9DateTimeDisplayFormat;\n /** Text of the `'custom'` format (MAUI `FormattedDisplayText`). */\n readonly formattedDisplayText?: string | null;\n readonly minDate?: G9LocalDate | null;\n readonly maxDate?: G9LocalDate | null;\n /** Hours 0–23 instead of 12-hour AM/PM. Default false. */\n readonly twentyFourHourDisplay?: boolean;\n /**\n * Default true (MAUI `RestoreOnCancel`): Cancel or a dismissal puts back the value the picker had when it opened if\n * it changed meanwhile. False leaves the current value.\n */\n readonly restoreOnCancel?: boolean;\n /** The Today / Now chip. Default true. */\n readonly showTodayButton?: boolean;\n /** Calendar override; default Persian for `fa`, else Gregorian (follows the language, not the direction). */\n readonly calendar?: G9CalendarSystem | null;\n /** Done confirmed a value (MAUI `DateTimeSelected`). */\n readonly onDateTimeSelected?: (value: G9LocalDateTime) => void;\n}\n\ninterface SheetBodyProps {\n readonly title: string;\n readonly initial: G9LocalDateTime;\n readonly now: () => G9LocalDateTime;\n readonly mode: G9DateTimePickerMode;\n readonly calendar: G9CalendarSystem;\n readonly culture: G9Culture;\n readonly bounds: { min: G9LocalDateTime | null; max: G9LocalDateTime | null };\n readonly twentyFourHour: boolean;\n readonly showToday: boolean;\n readonly format: (value: G9LocalDateTime) => string;\n readonly done: (value: G9LocalDateTime) => void;\n readonly cancel: () => void;\n}\n\n/** The drum sheet body (MAUI `G9DateTimePickerSheet`): header, live preview, Today/Now chip, the wheels. */\nexport function DateTimeSheetBody(props: SheetBodyProps): ReactNode {\n const strings = useG9Strings();\n const palette = useG9Theme().palette;\n const glyphs = useG9Settings().glyphs;\n const { calendar, culture, bounds, mode } = props;\n const [value, setValueState] = useState(() => clampPickerValue(props.initial, bounds, calendar));\n // The latest value, written synchronously: a wheel that settles and a Done tap (or a second wheel) can arrive before\n // the re-render binds handlers that close over the new state. Reading the render's `value` there returned the old\n // one, and a second wheel overwrote the first (seen on the Windows CI agent, Azure builds 539/541).\n const latest = useRef(value);\n const setValue = (next: G9LocalDateTime) => {\n latest.current = next;\n setValueState(next);\n };\n const partsOf = (v: G9LocalDateTime) => ({ ...pickerParts(v, calendar), hour: v.hour, minute: v.minute });\n const parts = partsOf(value);\n const minYear = bounds.min ? pickerParts(bounds.min, calendar).year : null;\n const maxYear = bounds.max ? pickerParts(bounds.max, calendar).year : null;\n const [years, setYears] = useState(() => yearWindow(parts.year, minYear, maxYear));\n // A value outside the window (Today, a clamp) rebuilds it around the value.\n const window_ = parts.year < years.from || parts.year > years.to ? yearWindow(parts.year, minYear, maxYear) : years;\n const change = (patch: Partial<typeof parts>) =>\n setValue(composePickerValue({ ...partsOf(latest.current), ...patch }, calendar, bounds));\n const grow = (edge: 'start' | 'end') =>\n setYears((w) =>\n edge === 'end'\n ? { from: w.from, to: Math.min(maxYear ?? 9999, 9999, w.to + g9YearWindowStep) }\n : { from: Math.max(minYear ?? 1, 1, w.from - g9YearWindowStep), to: w.to },\n );\n const today = useG9Press(\n () => {\n const now = props.now();\n setValue(clampPickerValue(mode === G9DateTimePickerMode.Date ? asDateTime(now) : now, bounds, calendar));\n },\n { source: 'G9DateTimePicker', guardMs: 0 },\n );\n const showDate = mode !== G9DateTimePickerMode.Time;\n const showTime = mode !== G9DateTimePickerMode.Date;\n return (\n <view className=\"g9-picker-sheet\">\n <PickerSheetHeader title={props.title} onCancel={props.cancel} onDone={() => props.done(latest.current)} />\n <text className=\"g9-picker-sheet__preview\" text-maxline=\"1\">\n {props.format(value)}\n </text>\n {props.showToday ? (\n // MAUI CreateTodayChip: a 14 dp calendar and 12 bold Primary text, 6 apart, in a pill of Primary 8 % with a\n // Primary 30 % stroke.\n <view\n className=\"g9-picker-sheet__today\"\n accessibility-element={true}\n accessibility-traits=\"button\"\n bindtap={today}\n style={{\n ...g9RowStyle(culture.direction),\n backgroundColor: formatColor(withAlpha(palette.Primary, 0.08)),\n borderColor: formatColor(withAlpha(palette.Primary, 0.3)),\n }}\n >\n <G9IconSlot icon={glyphs.calendarToday} size={14} color={palette.Primary} />\n <text className=\"g9-picker-sheet__today-text\">\n {strings.get(mode === G9DateTimePickerMode.Time ? G9StringKey.Now : G9StringKey.Today)}\n </text>\n </view>\n ) : null}\n <view className={`g9-picker-sheet__wheels g9-dir-${culture.direction}`}>\n {showDate ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Day)}\n items={dayWheelItems(daysInMonth(calendar, parts.year, parts.month), culture)}\n value={parts.day}\n onValueChange={(day) => change({ day })}\n />\n ) : null}\n {showDate ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Month)}\n weight={1.7}\n items={monthWheelItems(calendar, culture)}\n value={parts.month}\n onValueChange={(month) => change({ month })}\n />\n ) : null}\n {showDate ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Year)}\n items={yearWheelItems(window_.from, window_.to, culture)}\n value={parts.year}\n onValueChange={(year) => change({ year })}\n onNearEdge={grow}\n />\n ) : null}\n {showTime ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Hour)}\n items={hourWheelItems(props.twentyFourHour, culture)}\n value={parts.hour}\n onValueChange={(hour) => change({ hour })}\n />\n ) : null}\n {showTime ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Minute)}\n items={minuteWheelItems(culture)}\n value={parts.minute}\n onValueChange={(minute) => change({ minute })}\n />\n ) : null}\n </view>\n </view>\n );\n}\n\n/**\n * Date, time or date-time in an outlined box (MAUI `G9DateTimePicker`): a tap opens the drum sheet (Cancel, title,\n * Done, live preview, Today/Now, day/month/year and hour/minute wheels). The calendar follows the language (`fa` →\n * Persian) unless `calendar` is set; the value stays Gregorian. Min/max clamp the drums (they roll onto the clamped\n * value); a day past the month's end clamps to its last day. Done writes the value and fires `onDateTimeSelected`;\n * Cancel and dismissals write nothing (see `restoreOnCancel`). Must be inside a `G9Host`.\n */\nexport function G9DateTimePicker(props: G9DateTimePickerProps): ReactNode {\n const sheets = useG9Sheets();\n const culture = useG9Culture();\n const strings = useG9Strings();\n const glyphs = useG9Settings().glyphs;\n const clock = useG9Service('clock');\n const open = usePickerOpen();\n const [value, setValue] = useControllableState<G9LocalDateTime | null>({\n value: props.value,\n defaultValue: props.defaultValue ?? null,\n onChange: props.onValueChange,\n name: 'G9DateTimePicker.value',\n });\n const latest = useRef({ props, value });\n latest.current = { props, value };\n const mode = props.mode ?? G9DateTimePickerMode.Date;\n const calendar = resolvePickerCalendar(culture, props.calendar);\n const format = (v: G9LocalDateTime) =>\n formatPickerValue(v, culture, {\n mode,\n displayFormat: props.displayFormat ?? G9DateTimeDisplayFormat.ShortDate,\n twentyFourHour: props.twentyFourHourDisplay === true,\n calendar,\n customText: props.formattedDisplayText ?? null,\n });\n\n const onOpen = () =>\n open(async (isCurrent) => {\n const previous = latest.current.value;\n const p = latest.current.props;\n const now = () => localDateTimeFromDate(new Date(clock.now()));\n const title = p.label?.trim()\n ? p.label\n : strings.get(\n mode === G9DateTimePickerMode.Time\n ? G9StringKey.SelectTime\n : mode === G9DateTimePickerMode.DateTime\n ? G9StringKey.SelectDateTime\n : G9StringKey.SelectDate,\n );\n const bounds = normalizePickerBounds(p.minDate, p.maxDate, calendar);\n const result = await showPickerSheet<G9LocalDateTime>(sheets, ({ done, cancel }) => (\n <DateTimeSheetBody\n title={title}\n initial={previous ?? now()}\n now={now}\n mode={mode}\n calendar={calendar}\n culture={culture}\n bounds={bounds}\n twentyFourHour={p.twentyFourHourDisplay === true}\n showToday={p.showTodayButton !== false}\n format={format}\n done={done}\n cancel={cancel}\n />\n ));\n if (!isCurrent()) return;\n if (result) {\n setValue(result);\n latest.current.props.onDateTimeSelected?.(result);\n } else if (latest.current.props.restoreOnCancel !== false && latest.current.value !== previous) {\n setValue(previous);\n }\n });\n\n return (\n <PickerField\n field={{ trailingIcon: mode === G9DateTimePickerMode.Time ? glyphs.clock : glyphs.calendar, ...props }}\n hasValue={value !== null}\n onOpen={onOpen}\n >\n <text className={`g9-picker__text${value ? '' : ' g9-picker__text--placeholder'}`} text-maxline=\"1\">\n {value ? format(value) : props.label ? '' : (props.placeholder ?? '')}\n </text>\n </PickerField>\n );\n}\n"],"names":["g9YearWindowStep","DateTimeSheetBody","props","strings","useG9Strings","palette","useG9Theme","glyphs","useG9Settings","calendar","culture","bounds","mode","value","setValueState","useState","clampPickerValue","latest","useRef","setValue","next","partsOf","v","pickerParts","parts","minYear","maxYear","years","setYears","yearWindow","window_","change","patch","composePickerValue","grow","edge","w","Math","today","useG9Press","now","G9DateTimePickerMode","asDateTime","showDate","showTime","view","PickerSheetHeader","text","g9RowStyle","formatColor","withAlpha","G9IconSlot","G9StringKey","G9WheelColumn","dayWheelItems","daysInMonth","day","monthWheelItems","month","yearWheelItems","year","hourWheelItems","hour","minuteWheelItems","minute","G9DateTimePicker","_props_defaultValue","_props_mode","_props_placeholder","sheets","useG9Sheets","useG9Culture","clock","useG9Service","open","usePickerOpen","useControllableState","resolvePickerCalendar","format","_props_displayFormat","_props_formattedDisplayText","formatPickerValue","G9DateTimeDisplayFormat","onOpen","isCurrent","_p_label","previous","p","localDateTimeFromDate","Date","title","normalizePickerBounds","result","showPickerSheet","done","cancel","_latest_current_props","PickerField"],"mappings":";;;;;;;;;;;;;AAyCO,MAAMA,mBAAmB;AA+CzB,SAASC,kBAAkBC,KAAqB;IACrD,MAAMC,UAAUC;IAChB,MAAMC,UAAUC,aAAa,OAAO;IACpC,MAAMC,SAASC,gBAAgB,MAAM;IACrC,MAAM,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGV;IAC5C,MAAM,CAACW,OAAOC,cAAc,GAAGC,SAAS,IAAMC,iBAAiBd,MAAM,OAAO,EAAES,QAAQF;IAItF,MAAMQ,SAASC,OAAOL;IACtB,MAAMM,WAAW,CAACC;QAChBH,OAAO,OAAO,GAAGG;QACjBN,cAAcM;IAChB;IACA,MAAMC,UAAU,CAACC,IAAwB;YAAE,GAAGC,YAAYD,GAAGb,SAAS;YAAE,MAAMa,EAAE,IAAI;YAAE,QAAQA,EAAE,MAAM;QAAC;IACvG,MAAME,QAAQH,QAAQR;IACtB,MAAMY,UAAUd,OAAO,GAAG,GAAGY,YAAYZ,OAAO,GAAG,E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EAAE,kBAAkB,AAAD,KAAtCA,yCAAAA,IAAAA,CAAAA,uBAA0CJ;YAC5C,OAAO,IAAI3E,AAAyC,UAAzCA,OAAO,OAAO,CAAC,KAAK,CAAC,eAAe,IAAcA,OAAO,OAAO,CAAC,KAAK,KAAKqE,UACpFnE,SAASmE;QAEb;IAEF,QACGW,YACC,OAAO;QAAE,cAAcrF,SAAS6B,qBAAqB,IAAI,GAAGlC,OAAO,KAAK,GAAGA,OAAO,QAAQ;QAAE,GAAGL,KAAK;IAAC,GACrG,UAAUW,AAAU,SAAVA,OACV,QAAQsE,QACT;MACC,CAACpC,KAAK,WAAW,CAAC,eAAe,EAAElC,QAAQ,KAAK,iCAAiC,EAAE,aAAa,IAAI;QAClG,CAACA,QAAQiE,OAAOjE,SAASX,MAAM,KAAK,GAAG,KAAK,QAACkE,CAAAA,qBAAAA,MAAM,WAAW,AAAD,IAAhBA,qBAAqB,GAAI;MACxE,EAAErB,KAAK;IACT,EAAEkD;AAEN"}
|
|
1
|
+
{"version":3,"file":"pickers/date-time-picker.jsx","sources":["../../src/pickers/date-time-picker.tsx"],"sourcesContent":["import { resolveRestingPlaceholder } from '../fields/outlined-field';\nimport './pickers.css';\nimport {\n daysInMonth,\n formatColor,\n type G9CalendarSystem,\n type G9Culture,\n G9DateTimeDisplayFormat,\n G9DateTimePickerMode,\n type G9LocalDate,\n type G9LocalDateTime,\n G9StringKey,\n localDateTimeFromDate,\n withAlpha,\n} from '@g9tm/lynxcontrols-foundation';\nimport { type ReactNode, useRef, useState } from '@lynx-js/react';\nimport { g9RowStyle } from '../base/control';\nimport { useG9Press } from '../base/press';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { G9IconSlot } from '../icon/slot';\nimport { useG9Culture, useG9Service, useG9Settings, useG9Strings, useG9Theme } from '../provider/hooks';\nimport { useG9Sheets } from '../sheet/service';\nimport {\n asDateTime,\n clampPickerValue,\n composePickerValue,\n dayWheelItems,\n formatPickerValue,\n hourWheelItems,\n minuteWheelItems,\n monthWheelItems,\n normalizePickerBounds,\n pickerParts,\n resolvePickerCalendar,\n yearWheelItems,\n yearWindow,\n} from './date-time';\nimport { PickerSheetHeader, showPickerSheet } from './picker-sheet';\nimport { type G9PickerFieldProps, PickerField, usePickerOpen } from './trigger';\nimport { G9WheelColumn } from './wheel-column';\n\n/** Years the year window grows by at an edge (MAUI `YearWindowStep`: 12 since 1.4.11, was 25). */\nexport const g9YearWindowStep = 12;\n\n/** Props of {@link G9DateTimePicker}. */\nexport interface G9DateTimePickerProps extends G9PickerFieldProps {\n /** The value, always Gregorian (MAUI `SelectedDateTime`); `null` = none. Controlled with `onValueChange`. */\n readonly value?: G9LocalDateTime | null;\n readonly defaultValue?: G9LocalDateTime | null;\n readonly onValueChange?: (value: G9LocalDateTime | null) => void;\n /** Default `'date'`. */\n readonly mode?: G9DateTimePickerMode;\n /** Default `'shortDate'`. */\n readonly displayFormat?: G9DateTimeDisplayFormat;\n /** Text of the `'custom'` format (MAUI `FormattedDisplayText`). */\n readonly formattedDisplayText?: string | null;\n readonly minDate?: G9LocalDate | null;\n readonly maxDate?: G9LocalDate | null;\n /** Hours 0–23 instead of 12-hour AM/PM. Default false. */\n readonly twentyFourHourDisplay?: boolean;\n /**\n * Default true (MAUI `RestoreOnCancel`): Cancel or a dismissal puts back the value the picker had when it opened if\n * it changed meanwhile. False leaves the current value.\n */\n readonly restoreOnCancel?: boolean;\n /** The Today / Now chip. Default true. */\n readonly showTodayButton?: boolean;\n /** Calendar override; default Persian for `fa`, else Gregorian (follows the language, not the direction). */\n readonly calendar?: G9CalendarSystem | null;\n /** Done confirmed a value (MAUI `DateTimeSelected`). */\n readonly onDateTimeSelected?: (value: G9LocalDateTime) => void;\n}\n\ninterface SheetBodyProps {\n readonly title: string;\n readonly initial: G9LocalDateTime;\n readonly now: () => G9LocalDateTime;\n readonly mode: G9DateTimePickerMode;\n readonly calendar: G9CalendarSystem;\n readonly culture: G9Culture;\n readonly bounds: { min: G9LocalDateTime | null; max: G9LocalDateTime | null };\n readonly twentyFourHour: boolean;\n readonly showToday: boolean;\n readonly format: (value: G9LocalDateTime) => string;\n readonly done: (value: G9LocalDateTime) => void;\n readonly cancel: () => void;\n}\n\n/** The drum sheet body (MAUI `G9DateTimePickerSheet`): header, live preview, Today/Now chip, the wheels. */\nexport function DateTimeSheetBody(props: SheetBodyProps): ReactNode {\n const strings = useG9Strings();\n const palette = useG9Theme().palette;\n const glyphs = useG9Settings().glyphs;\n const { calendar, culture, bounds, mode } = props;\n const [value, setValueState] = useState(() => clampPickerValue(props.initial, bounds, calendar));\n // The latest value, written synchronously: a wheel that settles and a Done tap (or a second wheel) can arrive before\n // the re-render binds handlers that close over the new state. Reading the render's `value` there returned the old\n // one, and a second wheel overwrote the first (seen on the Windows CI agent, Azure builds 539/541).\n const latest = useRef(value);\n const setValue = (next: G9LocalDateTime) => {\n latest.current = next;\n setValueState(next);\n };\n const partsOf = (v: G9LocalDateTime) => ({ ...pickerParts(v, calendar), hour: v.hour, minute: v.minute });\n const parts = partsOf(value);\n const minYear = bounds.min ? pickerParts(bounds.min, calendar).year : null;\n const maxYear = bounds.max ? pickerParts(bounds.max, calendar).year : null;\n const [years, setYears] = useState(() => yearWindow(parts.year, minYear, maxYear));\n // A value outside the window (Today, a clamp) rebuilds it around the value.\n const window_ = parts.year < years.from || parts.year > years.to ? yearWindow(parts.year, minYear, maxYear) : years;\n const change = (patch: Partial<typeof parts>) =>\n setValue(composePickerValue({ ...partsOf(latest.current), ...patch }, calendar, bounds));\n const grow = (edge: 'start' | 'end') =>\n setYears((w) =>\n edge === 'end'\n ? { from: w.from, to: Math.min(maxYear ?? 9999, 9999, w.to + g9YearWindowStep) }\n : { from: Math.max(minYear ?? 1, 1, w.from - g9YearWindowStep), to: w.to },\n );\n const today = useG9Press(\n () => {\n const now = props.now();\n setValue(clampPickerValue(mode === G9DateTimePickerMode.Date ? asDateTime(now) : now, bounds, calendar));\n },\n { source: 'G9DateTimePicker', guardMs: 0 },\n );\n const showDate = mode !== G9DateTimePickerMode.Time;\n const showTime = mode !== G9DateTimePickerMode.Date;\n return (\n <view className=\"g9-picker-sheet\">\n <PickerSheetHeader title={props.title} onCancel={props.cancel} onDone={() => props.done(latest.current)} />\n <text className=\"g9-picker-sheet__preview\" text-maxline=\"1\">\n {props.format(value)}\n </text>\n {props.showToday ? (\n // MAUI CreateTodayChip: a 14 dp calendar and 12 bold Primary text, 6 apart, in a pill of Primary 8 % with a\n // Primary 30 % stroke.\n <view\n className=\"g9-picker-sheet__today\"\n accessibility-element={true}\n accessibility-traits=\"button\"\n bindtap={today}\n style={{\n ...g9RowStyle(culture.direction),\n backgroundColor: formatColor(withAlpha(palette.Primary, 0.08)),\n borderColor: formatColor(withAlpha(palette.Primary, 0.3)),\n }}\n >\n <G9IconSlot icon={glyphs.calendarToday} size={14} color={palette.Primary} />\n <text className=\"g9-picker-sheet__today-text\">\n {strings.get(mode === G9DateTimePickerMode.Time ? G9StringKey.Now : G9StringKey.Today)}\n </text>\n </view>\n ) : null}\n <view className={`g9-picker-sheet__wheels g9-dir-${culture.direction}`}>\n {showDate ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Day)}\n items={dayWheelItems(daysInMonth(calendar, parts.year, parts.month), culture)}\n value={parts.day}\n onValueChange={(day) => change({ day })}\n />\n ) : null}\n {showDate ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Month)}\n weight={1.7}\n items={monthWheelItems(calendar, culture)}\n value={parts.month}\n onValueChange={(month) => change({ month })}\n />\n ) : null}\n {showDate ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Year)}\n items={yearWheelItems(window_.from, window_.to, culture)}\n value={parts.year}\n onValueChange={(year) => change({ year })}\n onNearEdge={grow}\n />\n ) : null}\n {showTime ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Hour)}\n items={hourWheelItems(props.twentyFourHour, culture)}\n value={parts.hour}\n onValueChange={(hour) => change({ hour })}\n />\n ) : null}\n {showTime ? (\n <G9WheelColumn\n label={strings.get(G9StringKey.Minute)}\n items={minuteWheelItems(culture)}\n value={parts.minute}\n onValueChange={(minute) => change({ minute })}\n />\n ) : null}\n </view>\n </view>\n );\n}\n\n/**\n * Date, time or date-time in an outlined box (MAUI `G9DateTimePicker`): a tap opens the drum sheet (Cancel, title,\n * Done, live preview, Today/Now, day/month/year and hour/minute wheels). The calendar follows the language (`fa` →\n * Persian) unless `calendar` is set; the value stays Gregorian. Min/max clamp the drums (they roll onto the clamped\n * value); a day past the month's end clamps to its last day. Done writes the value and fires `onDateTimeSelected`;\n * Cancel and dismissals write nothing (see `restoreOnCancel`). Must be inside a `G9Host`.\n */\nexport function G9DateTimePicker(props: G9DateTimePickerProps): ReactNode {\n const sheets = useG9Sheets();\n const culture = useG9Culture();\n const strings = useG9Strings();\n const glyphs = useG9Settings().glyphs;\n const clock = useG9Service('clock');\n const open = usePickerOpen();\n const [value, setValue] = useControllableState<G9LocalDateTime | null>({\n value: props.value,\n defaultValue: props.defaultValue ?? null,\n onChange: props.onValueChange,\n name: 'G9DateTimePicker.value',\n });\n const latest = useRef({ props, value });\n latest.current = { props, value };\n const mode = props.mode ?? G9DateTimePickerMode.Date;\n const calendar = resolvePickerCalendar(culture, props.calendar);\n const format = (v: G9LocalDateTime) =>\n formatPickerValue(v, culture, {\n mode,\n displayFormat: props.displayFormat ?? G9DateTimeDisplayFormat.ShortDate,\n twentyFourHour: props.twentyFourHourDisplay === true,\n calendar,\n customText: props.formattedDisplayText ?? null,\n });\n\n const onOpen = () =>\n open(async (isCurrent) => {\n const previous = latest.current.value;\n const p = latest.current.props;\n const now = () => localDateTimeFromDate(new Date(clock.now()));\n const title = p.label?.trim()\n ? p.label\n : strings.get(\n mode === G9DateTimePickerMode.Time\n ? G9StringKey.SelectTime\n : mode === G9DateTimePickerMode.DateTime\n ? G9StringKey.SelectDateTime\n : G9StringKey.SelectDate,\n );\n const bounds = normalizePickerBounds(p.minDate, p.maxDate, calendar);\n const result = await showPickerSheet<G9LocalDateTime>(sheets, ({ done, cancel }) => (\n <DateTimeSheetBody\n title={title}\n initial={previous ?? now()}\n now={now}\n mode={mode}\n calendar={calendar}\n culture={culture}\n bounds={bounds}\n twentyFourHour={p.twentyFourHourDisplay === true}\n showToday={p.showTodayButton !== false}\n format={format}\n done={done}\n cancel={cancel}\n />\n ));\n if (!isCurrent()) return;\n if (result) {\n setValue(result);\n latest.current.props.onDateTimeSelected?.(result);\n } else if (latest.current.props.restoreOnCancel !== false && latest.current.value !== previous) {\n setValue(previous);\n }\n });\n\n return (\n <PickerField\n field={{ trailingIcon: mode === G9DateTimePickerMode.Time ? glyphs.clock : glyphs.calendar, ...props }}\n hasValue={value !== null}\n onOpen={onOpen}\n >\n <text className={`g9-picker__text${value ? '' : ' g9-picker__text--placeholder'}`} text-maxline=\"1\">\n {value ? format(value) : (resolveRestingPlaceholder(props) ?? '')}\n </text>\n </PickerField>\n );\n}\n"],"names":["g9YearWindowStep","DateTimeSheetBody","props","strings","useG9Strings","palette","useG9Theme","glyphs","useG9Settings","calendar","culture","bounds","mode","value","setValueState","useState","clampPickerValue","latest","useRef","setValue","next","partsOf","v","pickerParts","parts","minYear","maxYear","years","setYears","yearWindow","window_","change","patch","composePickerValue","grow","edge","w","Math","today","useG9Press","now","G9DateTimePickerMode","asDateTime","showDate","showTime","view","PickerSheetHeader","text","g9RowStyle","formatColor","withAlpha","G9IconSlot","G9StringKey","G9WheelColumn","dayWheelItems","daysInMonth","day","monthWheelItems","month","yearWheelItems","year","hourWheelItems","hour","minuteWheelItems","minute","G9DateTimePicker","_props_defaultValue","_props_mode","_resolveRestingPlaceholder","sheets","useG9Sheets","useG9Culture","clock","useG9Service","open","usePickerOpen","useControllableState","resolvePickerCalendar","format","_props_displayFormat","_props_formattedDisplayText","formatPickerValue","G9DateTimeDisplayFormat","onOpen","isCurrent","_p_label","previous","p","localDateTimeFromDate","Date","title","normalizePickerBounds","result","showPickerSheet","done","cancel","_latest_current_props","PickerField"],"mappings":";;;;;;;;;;;;;;AA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face G9WheelItem<V extends string | number = number> {
|
|
|
4
4
|
readonly value: V;
|
|
5
5
|
readonly text: string;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Year rows are a window of at most ±12 years around the selection (MAUI `YearWindowRadius`; 50 until 1.4.11, when the
|
|
9
|
+
* picker began to open pre-built: every row is paid for in the tap-to-open time, and the window grows at both edges).
|
|
10
|
+
*/
|
|
11
|
+
export declare const g9YearWindowRadius = 12;
|
|
9
12
|
/** The calendar a picker shows: the explicit one, else Persian for a `fa` culture, else Gregorian (MAUI rule). */
|
|
10
13
|
export declare function resolvePickerCalendar(culture: G9Culture, calendar?: G9CalendarSystem | null): G9CalendarSystem;
|
|
11
14
|
/** A date-time with its time part (a plain date reads as midnight). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-time.d.ts","sourceRoot":"","sources":["../../src/pickers/date-time.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,uBAAuB,EACvB,oBAAoB,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EAOrB,MAAM,+BAA+B,CAAC;AAKvC,2DAA2D;AAC3D,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM;IAC7D,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED
|
|
1
|
+
{"version":3,"file":"date-time.d.ts","sourceRoot":"","sources":["../../src/pickers/date-time.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,uBAAuB,EACvB,oBAAoB,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EAOrB,MAAM,+BAA+B,CAAC;AAKvC,2DAA2D;AAC3D,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,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CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC5C,uGAAuG;IACvG,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,GAAE,qBAA0B,GAAG,MAAM,CA6BrH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { G9DateTimeDisplayFormat, G9DateTimePickerMode, clampToPersianRange, compareLocal, daysInMonth, formatLocalDateTime, fromCalendarDate, getMonthNames, isPersianLanguage, isSupportedByPersianCalendar, localDateTime, toCalendarDate, toNativeDigits } from "@g9tm/lynxcontrols-foundation";
|
|
2
|
-
const g9YearWindowRadius =
|
|
2
|
+
const g9YearWindowRadius = 12;
|
|
3
3
|
function resolvePickerCalendar(culture, calendar) {
|
|
4
4
|
if (calendar) return calendar;
|
|
5
5
|
return isPersianLanguage(culture) ? 'persian' : 'gregorian';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickers/date-time.jsx","sources":["../../src/pickers/date-time.ts"],"sourcesContent":["import {\n clampToPersianRange,\n compareLocal,\n daysInMonth,\n formatLocalDateTime,\n fromCalendarDate,\n type G9CalendarSystem,\n type G9Culture,\n G9DateTimeDisplayFormat,\n G9DateTimePickerMode,\n type G9LocalDate,\n type G9LocalDateTime,\n getMonthNames,\n isPersianLanguage,\n isSupportedByPersianCalendar,\n localDateTime,\n toCalendarDate,\n toNativeDigits,\n} from '@g9tm/lynxcontrols-foundation';\n\n// Date math and text of the date/time picker (MAUI `G9DateTimePicker` + `G9DateTimePickerSheet`), Intl-free: every\n// calendar step goes through the foundation calendar functions.\n\n/** One wheel row: the value it stands for and its text. */\nexport interface G9WheelItem<V extends string | number = number> {\n readonly value: V;\n readonly text: string;\n}\n\n/** Year rows are a window of at most ±50 years around the selection (MAUI `YearWindowRadius`). */\nexport const g9YearWindowRadius = 50;\n\n/** The calendar a picker shows: the explicit one, else Persian for a `fa` culture, else Gregorian (MAUI rule). */\nexport function resolvePickerCalendar(culture: G9Culture, calendar?: G9CalendarSystem | null): G9CalendarSystem {\n if (calendar) return calendar;\n return isPersianLanguage(culture) ? 'persian' : 'gregorian';\n}\n\n/** A date-time with its time part (a plain date reads as midnight). */\nexport function asDateTime(value: G9LocalDate): G9LocalDateTime {\n const t = value as Partial<G9LocalDateTime>;\n return localDateTime(\n value.year,\n value.month,\n value.day,\n t.hour ?? 0,\n t.minute ?? 0,\n t.second ?? 0,\n t.millisecond ?? 0,\n );\n}\n\n/**\n * Min/max for a calendar: Persian bounds are pulled into the range the Persian calendar supports (from 0622-03-22),\n * and an inverted pair is swapped.\n */\nexport function normalizePickerBounds(\n min: G9LocalDate | null | undefined,\n max: G9LocalDate | null | undefined,\n calendar: G9CalendarSystem,\n): { min: G9LocalDateTime | null; max: G9LocalDateTime | null } {\n let lo = min ? asDateTime(min) : null;\n let hi = max ? asDateTime(max) : null;\n if (calendar === 'persian') {\n lo = lo ? clampToPersianRange(lo) : null;\n hi = hi ? clampToPersianRange(hi) : null;\n }\n if (lo && hi && compareDateTime(lo, hi) > 0) [lo, hi] = [hi, lo];\n return { min: lo, max: hi };\n}\n\n/** Orders two date-times (date first, then time). */\nexport function compareDateTime(a: G9LocalDateTime, b: G9LocalDateTime): number {\n const d = compareLocal(a, b);\n if (d !== 0) return d;\n return (\n a.hour * 3_600_000 +\n a.minute * 60_000 +\n a.second * 1000 +\n a.millisecond -\n (b.hour * 3_600_000 + b.minute * 60_000 + b.second * 1000 + b.millisecond)\n );\n}\n\n/** Clamps a value into `[min, max]` (either bound optional) and, for Persian, into the supported range. */\nexport function clampPickerValue(\n value: G9LocalDateTime,\n bounds: { min: G9LocalDateTime | null; max: G9LocalDateTime | null },\n calendar: G9CalendarSystem,\n): G9LocalDateTime {\n let v = calendar === 'persian' ? clampToPersianRange(value) : value;\n if (bounds.min && compareDateTime(v, bounds.min) < 0) v = bounds.min;\n if (bounds.max && compareDateTime(v, bounds.max) > 0) v = bounds.max;\n return v;\n}\n\n/** The value's parts in the picker calendar (what the day/month/year wheels show). */\nexport function pickerParts(\n value: G9LocalDateTime,\n calendar: G9CalendarSystem,\n): {\n year: number;\n month: number;\n day: number;\n} {\n const c = toCalendarDate(value, calendar);\n return { year: c.year, month: c.month, day: c.day };\n}\n\n/**\n * Builds the value from wheel parts: the day is clamped to the month's length (31 Farvardin → 30 Mehr, 29 Feb → 28\n * in a common year, Esfand 30 → 29), then the result is clamped to the bounds.\n */\nexport function composePickerValue(\n parts: { year: number; month: number; day: number; hour: number; minute: number },\n calendar: G9CalendarSystem,\n bounds: { min: G9LocalDateTime | null; max: G9LocalDateTime | null },\n): G9LocalDateTime {\n const day = Math.min(parts.day, daysInMonth(calendar, parts.year, parts.month));\n const date = fromCalendarDate({ calendar, year: parts.year, month: parts.month, day });\n return clampPickerValue(localDateTime(date.year, date.month, date.day, parts.hour, parts.minute), bounds, calendar);\n}\n\nconst digits = (culture: G9Culture, n: number, width: number) =>\n toNativeDigits(String(n).padStart(width, '0'), culture.numberingSystem);\n\n/** Day rows 1…count (two digits, native numerals). */\nexport function dayWheelItems(count: number, culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: count }, (_, i) => ({ value: i + 1, text: digits(culture, i + 1, 2) }));\n}\n\n/** Month rows with the calendar's month names. */\nexport function monthWheelItems(calendar: G9CalendarSystem, culture: G9Culture): G9WheelItem[] {\n return getMonthNames(calendar, culture).map((text, i) => ({ value: i + 1, text }));\n}\n\n/**\n * The year window (MAUI `BuildYears`): ±{@link g9YearWindowRadius} around `year`, inside the bounds' years (and the\n * calendar's 1…9999 range).\n */\nexport function yearWindow(year: number, minYear: number | null, maxYear: number | null): { from: number; to: number } {\n const lo = Math.max(1, minYear ?? 1);\n const hi = Math.min(9999, maxYear ?? 9999);\n return { from: Math.max(lo, year - g9YearWindowRadius), to: Math.min(hi, year + g9YearWindowRadius) };\n}\n\n/** Year rows `from…to` (four digits, native numerals). */\nexport function yearWheelItems(from: number, to: number, culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: Math.max(0, to - from + 1) }, (_, i) => ({\n value: from + i,\n text: digits(culture, from + i, 4),\n }));\n}\n\n/** Hour rows 0…23: `HH`, or `hh tt` in 12-hour display (MAUI `BuildHours`). */\nexport function hourWheelItems(twentyFourHour: boolean, culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: 24 }, (_, h) => ({\n value: h,\n text: formatLocalDateTime(localDateTime(2000, 1, 1, h), twentyFourHour ? 'HH' : 'hh tt', culture, {\n calendar: 'gregorian',\n }),\n }));\n}\n\n/** Minute rows 0…59. */\nexport function minuteWheelItems(culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: 60 }, (_, m) => ({ value: m, text: digits(culture, m, 2) }));\n}\n\n/** Options of {@link formatPickerValue}. */\nexport interface G9PickerFormatOptions {\n readonly mode?: G9DateTimePickerMode;\n readonly displayFormat?: G9DateTimeDisplayFormat;\n readonly twentyFourHour?: boolean;\n readonly calendar?: G9CalendarSystem | null;\n /** Text of the `'custom'` format (MAUI `FormattedDisplayText`); blank falls back to the short date. */\n readonly customText?: string | null;\n}\n\n/**\n * The trigger and preview text (MAUI `FormatValue`). Gregorian: short `d MMM yyyy`, long `MMMM d, yyyy`, time\n * `HH:mm`/`hh:mm tt`, short date-time `d MMM yyyy, HH:mm`, long date-time `MMMM d, yyyy, hh:mm tt`. Persian:\n * `dd MMMM yyyy` and `{date}، {time}` (a date the Persian calendar cannot hold is written Gregorian). The `'time'`\n * mode always shows the time; `'custom'` shows `customText`.\n */\nexport function formatPickerValue(value: G9LocalDate, culture: G9Culture, options: G9PickerFormatOptions = {}): string {\n const format = options.displayFormat ?? G9DateTimeDisplayFormat.ShortDate;\n if (format === G9DateTimeDisplayFormat.Custom && options.customText && options.customText.trim() !== '') {\n return options.customText;\n }\n const v = asDateTime(value);\n const time = options.twentyFourHour ? 'HH:mm' : 'hh:mm tt';\n const calendar = resolvePickerCalendar(culture, options.calendar);\n const effective = options.mode === G9DateTimePickerMode.Time ? G9DateTimeDisplayFormat.TimeOnly : format;\n if (calendar === 'persian' && isSupportedByPersianCalendar(v)) {\n const fmt = (p: string) => formatLocalDateTime(v, p, culture, { calendar: 'persian' });\n const date = fmt('dd MMMM yyyy');\n if (effective === G9DateTimeDisplayFormat.TimeOnly) return fmt(time);\n if (effective === G9DateTimeDisplayFormat.ShortDateTime || effective === G9DateTimeDisplayFormat.LongDateTime) {\n return `${date}، ${fmt(time)}`;\n }\n return date;\n }\n const pattern =\n effective === G9DateTimeDisplayFormat.LongDate\n ? 'MMMM d, yyyy'\n : effective === G9DateTimeDisplayFormat.TimeOnly\n ? time\n : effective === G9DateTimeDisplayFormat.ShortDateTime\n ? 'd MMM yyyy, HH:mm'\n : effective === G9DateTimeDisplayFormat.LongDateTime\n ? 'MMMM d, yyyy, hh:mm tt'\n : 'd MMM yyyy';\n return formatLocalDateTime(v, pattern, culture, { calendar: 'gregorian' });\n}\n"],"names":["g9YearWindowRadius","resolvePickerCalendar","culture","calendar","isPersianLanguage","asDateTime","value","_t_hour","_t_minute","_t_second","_t_millisecond","t","localDateTime","normalizePickerBounds","min","max","lo","hi","clampToPersianRange","compareDateTime","a","b","d","compareLocal","clampPickerValue","bounds","v","pickerParts","c","toCalendarDate","composePickerValue","parts","day","Math","daysInMonth","date","fromCalendarDate","digits","n","width","toNativeDigits","String","dayWheelItems","count","Array","_","i","monthWheelItems","getMonthNames","text","yearWindow","year","minYear","maxYear","yearWheelItems","from","to","hourWheelItems","twentyFourHour","h","formatLocalDateTime","minuteWheelItems","m","formatPickerValue","options","_options_displayFormat","format","G9DateTimeDisplayFormat","time","effective","G9DateTimePickerMode","isSupportedByPersianCalendar","fmt","p","pattern"],"mappings":";AA8BO,MAAMA,qBAAqB;AAG3B,SAASC,sBAAsBC,OAAkB,EAAEC,QAAkC;IAC1F,IAAIA,UAAU,OAAOA;IACrB,OAAOC,kBAAkBF,WAA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wBAAwB,MAAM,IAAIH,QAAQ,UAAU,IAAIA,AAA8B,OAA9BA,QAAQ,UAAU,CAAC,IAAI,IAC5F,OAAOA,QAAQ,UAAU;IAE3B,MAAMtC,IAAIrB,WAAWC;IACrB,MAAM8D,OAAOJ,QAAQ,cAAc,GAAG,UAAU;IAChD,MAAM7D,WAAWF,sBAAsBC,SAAS8D,QAAQ,QAAQ;IAChE,MAAMK,YAAYL,QAAQ,IAAI,KAAKM,qBAAqB,IAAI,GAAGH,wBAAwB,QAAQ,GAAGD;IAClG,IAAI/D,AAAa,cAAbA,YAA0BoE,6BAA6B7C,IAAI;QAC7D,MAAM8C,MAAM,CAACC,IAAcb,oBAAoBlC,GAAG+C,GAAGvE,SAAS;gBAAE,UAAU;YAAU;QACpF,MAAMiC,OAAOqC,IAAI;QACjB,IAAIH,cAAcF,wBAAwB,QAAQ,EAAE,OAAOK,IAAIJ;QAC/D,IAAIC,cAAcF,wBAAwB,aAAa,IAAIE,cAAcF,wBAAwB,YAAY,EAC3G,OAAO,GAAGhC,KAAK,EAAE,EAAEqC,IAAIJ,OAAO;QAEhC,OAAOjC;IACT;IACA,MAAMuC,UACJL,cAAcF,wBAAwB,QAAQ,GAC1C,iBACAE,cAAcF,wBAAwB,QAAQ,GAC5CC,OACAC,cAAcF,wBAAwB,aAAa,GACjD,sBACAE,cAAcF,wBAAwB,YAAY,GAChD,2BACA;IACZ,OAAOP,oBAAoBlC,GAAGgD,SAASxE,SAAS;QAAE,UAAU;IAAY;AAC1E"}
|
|
1
|
+
{"version":3,"file":"pickers/date-time.jsx","sources":["../../src/pickers/date-time.ts"],"sourcesContent":["import {\n clampToPersianRange,\n compareLocal,\n daysInMonth,\n formatLocalDateTime,\n fromCalendarDate,\n type G9CalendarSystem,\n type G9Culture,\n G9DateTimeDisplayFormat,\n G9DateTimePickerMode,\n type G9LocalDate,\n type G9LocalDateTime,\n getMonthNames,\n isPersianLanguage,\n isSupportedByPersianCalendar,\n localDateTime,\n toCalendarDate,\n toNativeDigits,\n} from '@g9tm/lynxcontrols-foundation';\n\n// Date math and text of the date/time picker (MAUI `G9DateTimePicker` + `G9DateTimePickerSheet`), Intl-free: every\n// calendar step goes through the foundation calendar functions.\n\n/** One wheel row: the value it stands for and its text. */\nexport interface G9WheelItem<V extends string | number = number> {\n readonly value: V;\n readonly text: string;\n}\n\n/**\n * Year rows are a window of at most ±12 years around the selection (MAUI `YearWindowRadius`; 50 until 1.4.11, when the\n * picker began to open pre-built: every row is paid for in the tap-to-open time, and the window grows at both edges).\n */\nexport const g9YearWindowRadius = 12;\n\n/** The calendar a picker shows: the explicit one, else Persian for a `fa` culture, else Gregorian (MAUI rule). */\nexport function resolvePickerCalendar(culture: G9Culture, calendar?: G9CalendarSystem | null): G9CalendarSystem {\n if (calendar) return calendar;\n return isPersianLanguage(culture) ? 'persian' : 'gregorian';\n}\n\n/** A date-time with its time part (a plain date reads as midnight). */\nexport function asDateTime(value: G9LocalDate): G9LocalDateTime {\n const t = value as Partial<G9LocalDateTime>;\n return localDateTime(\n value.year,\n value.month,\n value.day,\n t.hour ?? 0,\n t.minute ?? 0,\n t.second ?? 0,\n t.millisecond ?? 0,\n );\n}\n\n/**\n * Min/max for a calendar: Persian bounds are pulled into the range the Persian calendar supports (from 0622-03-22),\n * and an inverted pair is swapped.\n */\nexport function normalizePickerBounds(\n min: G9LocalDate | null | undefined,\n max: G9LocalDate | null | undefined,\n calendar: G9CalendarSystem,\n): { min: G9LocalDateTime | null; max: G9LocalDateTime | null } {\n let lo = min ? asDateTime(min) : null;\n let hi = max ? asDateTime(max) : null;\n if (calendar === 'persian') {\n lo = lo ? clampToPersianRange(lo) : null;\n hi = hi ? clampToPersianRange(hi) : null;\n }\n if (lo && hi && compareDateTime(lo, hi) > 0) [lo, hi] = [hi, lo];\n return { min: lo, max: hi };\n}\n\n/** Orders two date-times (date first, then time). */\nexport function compareDateTime(a: G9LocalDateTime, b: G9LocalDateTime): number {\n const d = compareLocal(a, b);\n if (d !== 0) return d;\n return (\n a.hour * 3_600_000 +\n a.minute * 60_000 +\n a.second * 1000 +\n a.millisecond -\n (b.hour * 3_600_000 + b.minute * 60_000 + b.second * 1000 + b.millisecond)\n );\n}\n\n/** Clamps a value into `[min, max]` (either bound optional) and, for Persian, into the supported range. */\nexport function clampPickerValue(\n value: G9LocalDateTime,\n bounds: { min: G9LocalDateTime | null; max: G9LocalDateTime | null },\n calendar: G9CalendarSystem,\n): G9LocalDateTime {\n let v = calendar === 'persian' ? clampToPersianRange(value) : value;\n if (bounds.min && compareDateTime(v, bounds.min) < 0) v = bounds.min;\n if (bounds.max && compareDateTime(v, bounds.max) > 0) v = bounds.max;\n return v;\n}\n\n/** The value's parts in the picker calendar (what the day/month/year wheels show). */\nexport function pickerParts(\n value: G9LocalDateTime,\n calendar: G9CalendarSystem,\n): {\n year: number;\n month: number;\n day: number;\n} {\n const c = toCalendarDate(value, calendar);\n return { year: c.year, month: c.month, day: c.day };\n}\n\n/**\n * Builds the value from wheel parts: the day is clamped to the month's length (31 Farvardin → 30 Mehr, 29 Feb → 28\n * in a common year, Esfand 30 → 29), then the result is clamped to the bounds.\n */\nexport function composePickerValue(\n parts: { year: number; month: number; day: number; hour: number; minute: number },\n calendar: G9CalendarSystem,\n bounds: { min: G9LocalDateTime | null; max: G9LocalDateTime | null },\n): G9LocalDateTime {\n const day = Math.min(parts.day, daysInMonth(calendar, parts.year, parts.month));\n const date = fromCalendarDate({ calendar, year: parts.year, month: parts.month, day });\n return clampPickerValue(localDateTime(date.year, date.month, date.day, parts.hour, parts.minute), bounds, calendar);\n}\n\nconst digits = (culture: G9Culture, n: number, width: number) =>\n toNativeDigits(String(n).padStart(width, '0'), culture.numberingSystem);\n\n/** Day rows 1…count (two digits, native numerals). */\nexport function dayWheelItems(count: number, culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: count }, (_, i) => ({ value: i + 1, text: digits(culture, i + 1, 2) }));\n}\n\n/** Month rows with the calendar's month names. */\nexport function monthWheelItems(calendar: G9CalendarSystem, culture: G9Culture): G9WheelItem[] {\n return getMonthNames(calendar, culture).map((text, i) => ({ value: i + 1, text }));\n}\n\n/**\n * The year window (MAUI `BuildYears`): ±{@link g9YearWindowRadius} around `year`, inside the bounds' years (and the\n * calendar's 1…9999 range).\n */\nexport function yearWindow(year: number, minYear: number | null, maxYear: number | null): { from: number; to: number } {\n const lo = Math.max(1, minYear ?? 1);\n const hi = Math.min(9999, maxYear ?? 9999);\n return { from: Math.max(lo, year - g9YearWindowRadius), to: Math.min(hi, year + g9YearWindowRadius) };\n}\n\n/** Year rows `from…to` (four digits, native numerals). */\nexport function yearWheelItems(from: number, to: number, culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: Math.max(0, to - from + 1) }, (_, i) => ({\n value: from + i,\n text: digits(culture, from + i, 4),\n }));\n}\n\n/** Hour rows 0…23: `HH`, or `hh tt` in 12-hour display (MAUI `BuildHours`). */\nexport function hourWheelItems(twentyFourHour: boolean, culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: 24 }, (_, h) => ({\n value: h,\n text: formatLocalDateTime(localDateTime(2000, 1, 1, h), twentyFourHour ? 'HH' : 'hh tt', culture, {\n calendar: 'gregorian',\n }),\n }));\n}\n\n/** Minute rows 0…59. */\nexport function minuteWheelItems(culture: G9Culture): G9WheelItem[] {\n return Array.from({ length: 60 }, (_, m) => ({ value: m, text: digits(culture, m, 2) }));\n}\n\n/** Options of {@link formatPickerValue}. */\nexport interface G9PickerFormatOptions {\n readonly mode?: G9DateTimePickerMode;\n readonly displayFormat?: G9DateTimeDisplayFormat;\n readonly twentyFourHour?: boolean;\n readonly calendar?: G9CalendarSystem | null;\n /** Text of the `'custom'` format (MAUI `FormattedDisplayText`); blank falls back to the short date. */\n readonly customText?: string | null;\n}\n\n/**\n * The trigger and preview text (MAUI `FormatValue`). Gregorian: short `d MMM yyyy`, long `MMMM d, yyyy`, time\n * `HH:mm`/`hh:mm tt`, short date-time `d MMM yyyy, HH:mm`, long date-time `MMMM d, yyyy, hh:mm tt`. Persian:\n * `dd MMMM yyyy` and `{date}، {time}` (a date the Persian calendar cannot hold is written Gregorian). The `'time'`\n * mode always shows the time; `'custom'` shows `customText`.\n */\nexport function formatPickerValue(value: G9LocalDate, culture: G9Culture, options: G9PickerFormatOptions = {}): string {\n const format = options.displayFormat ?? G9DateTimeDisplayFormat.ShortDate;\n if (format === G9DateTimeDisplayFormat.Custom && options.customText && options.customText.trim() !== '') {\n return options.customText;\n }\n const v = asDateTime(value);\n const time = options.twentyFourHour ? 'HH:mm' : 'hh:mm tt';\n const calendar = resolvePickerCalendar(culture, options.calendar);\n const effective = options.mode === G9DateTimePickerMode.Time ? G9DateTimeDisplayFormat.TimeOnly : format;\n if (calendar === 'persian' && isSupportedByPersianCalendar(v)) {\n const fmt = (p: string) => formatLocalDateTime(v, p, culture, { calendar: 'persian' });\n const date = fmt('dd MMMM yyyy');\n if (effective === G9DateTimeDisplayFormat.TimeOnly) return fmt(time);\n if (effective === G9DateTimeDisplayFormat.ShortDateTime || effective === G9DateTimeDisplayFormat.LongDateTime) {\n return `${date}، ${fmt(time)}`;\n }\n return date;\n }\n const pattern =\n effective === G9DateTimeDisplayFormat.LongDate\n ? 'MMMM d, yyyy'\n : effective === G9DateTimeDisplayFormat.TimeOnly\n ? time\n : effective === G9DateTimeDisplayFormat.ShortDateTime\n ? 'd MMM yyyy, HH:mm'\n : effective === G9DateTimeDisplayFormat.LongDateTime\n ? 'MMMM d, yyyy, hh:mm tt'\n : 'd MMM yyyy';\n return formatLocalDateTime(v, pattern, culture, { calendar: 'gregorian' });\n}\n"],"names":["g9YearWindowRadius","resolvePickerCalendar","culture","calendar","isPersianLanguage","asDateTime","value","_t_hour","_t_minute","_t_second","_t_millisecond","t","localDateTime","normalizePickerBounds","min","max","lo","hi","clampToPersianRange","compareDateTime","a","b","d","compareLocal","clampPickerValue","bounds","v","pickerParts","c","toCalendarDate","composePickerValue","parts","day","Math","daysInMonth","date","fromCalendarDate","digits","n","width","toNativeDigits","String","dayWheelItems","count","Array","_","i","monthWheelItems","getMonthNames","text","yearWindow","year","minYear","maxYear","yearWheelItems","from","to","hourWheelItems","twentyFourHour","h","formatLocalDateTime","minuteWheelItems","m","formatPickerValue","options","_options_displayFormat","format","G9DateTimeDisplayFormat","time","effective","G9DateTimePickerMode","isSupportedByPersianCalendar","fmt","p","pattern"],"mappings":";AAiCO,MAAMA,qBAAqB;AAG3B,SAASC,sBAAsBC,OAAkB,EAAEC,QAAkC;IAC1F,IAAIA,UAAU,OAAOA;IACrB,OAAOC,kBAAkBF,WAAW,YAAY;AAClD;AAGO,SAASG,WAAWC,KAAkB;QAMzCC,SACAC,WACAC,WACAC;IARF,MAAMC,IAAIL;IACV,OAAOM,cACLN,MAAM,IAAI,EACVA,MAAM,KAAK,EACXA,MAAM,GAAG,UACTC,CAAAA,UAAAA,EAAE,IAAI,AAAD,IAALA,UAAU,WACVC,CAAAA,YAAAA,EAAE,MAAM,AAAD,IAAPA,YAAY,WACZC,CAAAA,YAAAA,EAAE,MAAM,AAAD,IAAPA,YAAY,WACZC,CAAAA,iBAAAA,EAAE,WAAW,AAAD,IAAZA,iBAAiB;AAErB;AAMO,SAASG,sBACdC,GAAmC,EACnCC,GAAmC,EACnCZ,QAA0B;IAE1B,IAAIa,KAAKF,MAAMT,WAAWS,OAAO;IACjC,IAAIG,KAAKF,MAAMV,WAAWU,OAAO;IACjC,IAAIZ,AAAa,cAAbA,UAAwB;QAC1Ba,KAAKA,KAAKE,oBAAoBF,MAAM;QACpCC,KAAKA,KAAKC,oBAAoBD,MAAM;IACtC;IACA,IAAID,MAAMC,MAAME,gBAAgBH,IAAIC,MAAM,GAAG,CAACD,IAAIC,GAAG,GAAG;QAACA;QAAID;KAAG;IAChE,OAAO;QAAE,KAAKA;QAAI,KAAKC;IAAG;AAC5B;AAGO,SAASE,gBAAgBC,CAAkB,EAAEC,CAAkB;IACpE,MAAMC,IAAIC,aAAaH,GAAGC;IAC1B,IAAIC,AAAM,MAANA,GAAS,O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,GAAGgD,SAASxE,SAAS;QAAE,UAAU;IAAY;AAC1E"}
|
|
@@ -8,8 +8,12 @@ export interface G9PickerSheetBodyProps<T> {
|
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Opens a fit-to-content drum sheet (MAUI `G9DateTimePickerSheet.ShowAsync` / `G9TimeSpanPickerSheet.ShowAsync`) and
|
|
11
|
-
* resolves the value Done returned, or `null` for Cancel, any dismissal, or a throttled open.
|
|
12
|
-
*
|
|
11
|
+
* resolves the value Done returned, or `null` for Cancel, any dismissal, or a throttled open.
|
|
12
|
+
*
|
|
13
|
+
* ⛔ PRE-BUILT (MAUI 1.4.11): the body is built on the tap and opens finished — no spinner, and nothing waits on the
|
|
14
|
+
* open motion. It used to be a factory shown behind a spinner until the sheet had opened plus 369 ms: the only sheet of
|
|
15
|
+
* the suite that visibly «loaded» (MAUI's field report 2026-11-08, Samsung A24: the spinner stayed for seconds). What made
|
|
16
|
+
* an eager build costly is gone with the ±12-year window (`g9YearWindowRadius`).
|
|
13
17
|
*/
|
|
14
18
|
export declare function showPickerSheet<T>(sheets: G9SheetService, body: (props: G9PickerSheetBodyProps<T>) => ReactNode): Promise<T | null>;
|
|
15
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picker-sheet.d.ts","sourceRoot":"","sources":["../../src/pickers/picker-sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAMhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,wFAAwF;AACxF,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED
|
|
1
|
+
{"version":3,"file":"picker-sheet.d.ts","sourceRoot":"","sources":["../../src/pickers/picker-sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAMhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,wFAAwF;AACxF,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,CAAC,EACrC,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,CAAC,CAAC,KAAK,SAAS,GACpD,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAiBnB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;CAC7B,GAAG,SAAS,CAwBZ"}
|
|
@@ -22,10 +22,9 @@ async function showPickerSheet(sheets, body) {
|
|
|
22
22
|
cancel: ()=>finish(null)
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
|
-
const handle = sheets.show(
|
|
25
|
+
const handle = sheets.show(<Body/>, {
|
|
26
26
|
...fitToContentSheetOptions(),
|
|
27
|
-
|
|
28
|
-
loadingSkeleton: 'none'
|
|
27
|
+
deferContent: false
|
|
29
28
|
});
|
|
30
29
|
if (!handle) return null;
|
|
31
30
|
await handle.result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickers/picker-sheet.jsx","sources":["../../src/pickers/picker-sheet.tsx"],"sourcesContent":["import './pickers.css';\nimport { G9StringKey } from '@g9tm/lynxcontrols-foundation';\nimport type { ReactNode } from '@lynx-js/react';\nimport { g9RowStyle } from '../base/control';\nimport { G9Button } from '../button/button';\nimport { useG9Direction, useG9Strings } from '../provider/hooks';\nimport { useG9SheetContext } from '../sheet/frame';\nimport { fitToContentSheetOptions } from '../sheet/options';\nimport type { G9SheetService } from '../sheet/service';\n\n/** Props a drum sheet body receives: finish with a value (Done) or without (Cancel). */\nexport interface G9PickerSheetBodyProps<T> {\n readonly done: (value: T) => void;\n readonly cancel: () => void;\n}\n\n/**\n * Opens a fit-to-content drum sheet (MAUI `G9DateTimePickerSheet.ShowAsync` / `G9TimeSpanPickerSheet.ShowAsync`) and\n * resolves the value Done returned, or `null` for Cancel, any dismissal, or a throttled open.
|
|
1
|
+
{"version":3,"file":"pickers/picker-sheet.jsx","sources":["../../src/pickers/picker-sheet.tsx"],"sourcesContent":["import './pickers.css';\nimport { G9StringKey } from '@g9tm/lynxcontrols-foundation';\nimport type { ReactNode } from '@lynx-js/react';\nimport { g9RowStyle } from '../base/control';\nimport { G9Button } from '../button/button';\nimport { useG9Direction, useG9Strings } from '../provider/hooks';\nimport { useG9SheetContext } from '../sheet/frame';\nimport { fitToContentSheetOptions } from '../sheet/options';\nimport type { G9SheetService } from '../sheet/service';\n\n/** Props a drum sheet body receives: finish with a value (Done) or without (Cancel). */\nexport interface G9PickerSheetBodyProps<T> {\n readonly done: (value: T) => void;\n readonly cancel: () => void;\n}\n\n/**\n * Opens a fit-to-content drum sheet (MAUI `G9DateTimePickerSheet.ShowAsync` / `G9TimeSpanPickerSheet.ShowAsync`) and\n * resolves the value Done returned, or `null` for Cancel, any dismissal, or a throttled open.\n *\n * ⛔ PRE-BUILT (MAUI 1.4.11): the body is built on the tap and opens finished — no spinner, and nothing waits on the\n * open motion. It used to be a factory shown behind a spinner until the sheet had opened plus 369 ms: the only sheet of\n * the suite that visibly «loaded» (MAUI's field report 2026-11-08, Samsung A24: the spinner stayed for seconds). What made\n * an eager build costly is gone with the ±12-year window (`g9YearWindowRadius`).\n */\nexport async function showPickerSheet<T>(\n sheets: G9SheetService,\n body: (props: G9PickerSheetBodyProps<T>) => ReactNode,\n): Promise<T | null> {\n let result: T | null = null;\n let finished = false;\n const Body = () => {\n const handle = useG9SheetContext()?.handle;\n const finish = (value: T | null) => {\n if (finished) return;\n finished = true;\n result = value;\n handle?.close();\n };\n return body({ done: (v) => finish(v), cancel: () => finish(null) });\n };\n const handle = sheets.show(<Body />, { ...fitToContentSheetOptions(), deferContent: false });\n if (!handle) return null;\n await handle.result;\n return result;\n}\n\n/**\n * The drum sheet header (MAUI `G9DateTimePickerSheet` / `G9TimeSpanPickerSheet.CreateHeader`): a Grid \"Auto,*,Auto\" of\n * Padding (16, 10) — Cancel as a small Text-variant G9Button (Primary text in an Outline pill), the title 15 bold\n * TextPrimary, Done as a small Primary G9Button.\n */\nexport function PickerSheetHeader(props: {\n readonly title: string;\n readonly onCancel: () => void;\n readonly onDone: () => void;\n}): ReactNode {\n const strings = useG9Strings();\n const direction = useG9Direction();\n return (\n <view className=\"g9-picker-sheet__header\" style={g9RowStyle(direction)}>\n <G9Button\n className=\"g9-picker-sheet__cancel\"\n text={strings.get(G9StringKey.Cancel)}\n variant=\"text\"\n size=\"small\"\n onPress={props.onCancel}\n />\n <text className=\"g9-picker-sheet__title\" text-maxline=\"1\">\n {props.title}\n </text>\n <G9Button\n className=\"g9-picker-sheet__done\"\n text={strings.get(G9StringKey.Done)}\n variant=\"primary\"\n size=\"small\"\n onPress={props.onDone}\n />\n </view>\n );\n}\n"],"names":["showPickerSheet","sheets","body","result","finished","Body","_useG9SheetContext","handle","finish","value","v","fitToContentSheetOptions","PickerSheetHeader","props","strings","useG9Strings","direction","useG9Direction","view","g9RowStyle","G9Button","G9StringKey","text"],"mappings":";;;;;;;AAyBO,eAAeA,gBACpBC,MAAsB,EACtBC,IAAqD;IAErD,IAAIC,SAAmB;IACvB,IAAIC,WAAW;IACf,MAAMC,OAAO;YACIC;QAAf,MAAMC,SAAS,QAAAD,CAAAA,qBAAAA,mBAAkB,IAAlBA,KAAAA,IAAAA,mBAAqB,MAAM;QAC1C,MAAME,SAAS,CAACC;YACd,IAAIL,UAAU;YACdA,WAAW;YACXD,SAASM;YACTF,QAAAA,UAAAA,OAAQ,KAAK;QACf;QACA,OAAOL,KAAK;YAAE,MAAM,CAACQ,IAAMF,OAAOE;YAAI,QAAQ,IAAMF,OAAO;QAAM;IACnE;IACA,MAAMD,SAASN,OAAO,IAAI,EAAEI,QAAS;QAAE,GAAGM,0BAA0B;QAAE,cAAc;IAAM;IAC1F,IAAI,CAACJ,QAAQ,OAAO;IACpB,MAAMA,OAAO,MAAM;IACnB,OAAOJ;AACT;AAOO,SAASS,kBAAkBC,KAIjC;IACC,MAAMC,UAAUC;IAChB,MAAMC,YAAYC;IAClB,QACGC,KAAK,UAAU,0BAA0B,OAAOC,WAAWH,YAAY;MACtE,CAACI,SACC,UAAU,0BACV,MAAMN,QAAQ,GAAG,CAACO,YAAY,MAAM,GACpC,QAAQ,OACR,KAAK,QACL,SAASR,MAAM,QAAQ,GACvB;MACF,CAACS,KAAK,UAAU,yBAAyB,aAAa,IAAI;QACxD,CAACT,MAAM,KAAK,CAAC;MACf,EAAES,KAAK;MACP,CAACF,SACC,UAAU,wBACV,MAAMN,QAAQ,GAAG,CAACO,YAAY,IAAI,GAClC,QAAQ,UACR,KAAK,QACL,SAASR,MAAM,MAAM,GACrB;IACJ,EAAEK;AAEN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picker.d.ts","sourceRoot":"","sources":["../../src/pickers/picker.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"picker.d.ts","sourceRoot":"","sources":["../../src/pickers/picker.tsx"],"names":[],"mappings":"AACA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,SAAS,EAAU,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,KAAK,eAAe,EAAgB,MAAM,wBAAwB,CAAC;AAK5E,OAAO,EAAE,KAAK,kBAAkB,EAAkD,MAAM,WAAW,CAAC;AAEpG,iCAAiC;AACjC,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe,CAAE,SAAQ,kBAAkB;IACpG,uGAAuG;IACvG,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACjC,0GAA0G;IAC1G,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,gGAAgG;IAChG,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IACtE,gFAAgF;IAChF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACnC,mHAAmH;IACnH,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5C,wGAAwG;IACxG,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5C;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,SAAS,CAiDxG"}
|
package/dist/pickers/picker.jsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveRestingPlaceholder } from "../fields/outlined-field.jsx";
|
|
1
2
|
import "./pickers.css";
|
|
2
3
|
import { useRef } from "@lynx-js/react";
|
|
3
4
|
import { selectionKey } from "../base/selection-item.jsx";
|
|
@@ -7,7 +8,7 @@ import { showSelectionSheet } from "../selection/selection-sheet.jsx";
|
|
|
7
8
|
import { useG9Sheets } from "../sheet/service.jsx";
|
|
8
9
|
import { PickerField, SelectionValueIcon, usePickerOpen } from "./trigger.jsx";
|
|
9
10
|
function G9Picker(props) {
|
|
10
|
-
var _props_defaultValue,
|
|
11
|
+
var _props_defaultValue, _resolveRestingPlaceholder;
|
|
11
12
|
const sheets = useG9Sheets();
|
|
12
13
|
const glyphs = useG9Settings().glyphs;
|
|
13
14
|
const open = usePickerOpen();
|
|
@@ -63,7 +64,7 @@ function G9Picker(props) {
|
|
|
63
64
|
}} hasValue={void 0 !== selected} onOpen={onOpen}>
|
|
64
65
|
{selected ? <SelectionValueIcon item={selected}/> : null}
|
|
65
66
|
<text className={`g9-picker__text${selected ? '' : ' g9-picker__text--placeholder'}`} text-maxline="1">
|
|
66
|
-
{selected ? selected.text :
|
|
67
|
+
{selected ? selected.text : null != (_resolveRestingPlaceholder = resolveRestingPlaceholder(props)) ? _resolveRestingPlaceholder : ''}
|
|
67
68
|
</text>
|
|
68
69
|
</PickerField>;
|
|
69
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickers/picker.jsx","sources":["../../src/pickers/picker.tsx"],"sourcesContent":["import './pickers.css';\nimport { type ReactNode, useRef } from '@lynx-js/react';\nimport { type G9SelectionItem, selectionKey } from '../base/selection-item';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { useG9Settings } from '../provider/hooks';\nimport { showSelectionSheet } from '../selection/selection-sheet';\nimport { useG9Sheets } from '../sheet/service';\nimport { type G9PickerFieldProps, PickerField, SelectionValueIcon, usePickerOpen } from './trigger';\n\n/** Props of {@link G9Picker}. */\nexport interface G9PickerProps<T extends G9SelectionItem = G9SelectionItem> extends G9PickerFieldProps {\n /** The rows of the sheet (MAUI `ItemsSource`). Disabled items are left out except the selected one. */\n readonly items: ReadonlyArray<T>;\n /** Selected item key (`selectionKey`: key, else text); `null` = none. Controlled with `onValueChange`. */\n readonly value?: string | null;\n readonly defaultValue?: string | null;\n /** The selection changed: by a pick, or by `restoreOnCancel` putting back the opening value. */\n readonly onValueChange?: (key: string | null, item: T | null) => void;\n /** Sheet title; default the label, else the placeholder (MAUI `SheetTitle`). */\n readonly sheetTitle?: string | null;\n /**\n * Default true (MAUI `RestoreOnCancel`): a dismissed sheet puts back the value the picker had when it opened (if it\n * changed meanwhile) and reports `onSelectionCancelled`. False leaves the current value and reports nothing.\n */\n readonly restoreOnCancel?: boolean;\n /** A row was picked (MAUI `ItemSelected` + `SelectionAcceptedCommand`); only for a pick, never for a dismissal. */\n readonly onItemSelected?: (item: T) => void;\n /** The sheet was dismissed without a pick (MAUI `SelectionCancelled` + `SelectionCancelledCommand`). */\n readonly onSelectionCancelled?: () => void;\n}\n\n/**\n * Single selection from a list in an outlined box (MAUI `G9Picker`): a tap opens the selection sheet (no search; a\n * pick closes it), the box shows the item's icon or swatch and text, the trailing chevron hints at the sheet. Must\n * be inside a `G9Host` (the sheet).\n */\nexport function G9Picker<T extends G9SelectionItem = G9SelectionItem>(props: G9PickerProps<T>): ReactNode {\n const sheets = useG9Sheets();\n const glyphs = useG9Settings().glyphs;\n const open = usePickerOpen();\n const [key, setKey] = useControllableState<string | null, [T | null]>({\n value: props.value,\n defaultValue: props.defaultValue ?? null,\n onChange: props.onValueChange,\n name: 'G9Picker.value',\n });\n const latest = useRef({ props, key });\n latest.current = { props, key };\n const selected = key === null ? undefined : props.items.find((i) => selectionKey(i) === key);\n\n const onOpen = () =>\n open(async (isCurrent) => {\n const p = latest.current.props;\n const previousKey = latest.current.key;\n const previous = previousKey === null ? undefined : p.items.find((i) => selectionKey(i) === previousKey);\n const items = p.items.filter((i) => i.isEnabled !== false || i === previous);\n if (items.length === 0) return;\n const result = await showSelectionSheet(sheets, {\n title: p.sheetTitle?.trim() ? p.sheetTitle : (p.label ?? p.placeholder ?? ''),\n items,\n selectedItems: previous ? [previous] : [],\n allowMultiple: false,\n closeOnSingleSelection: true,\n showSearch: false,\n });\n if (!isCurrent()) return;\n const next = result.wasAccepted ? result.items[0] : undefined;\n const now = latest.current.props;\n if (next) {\n setKey(selectionKey(next), next);\n now.onItemSelected?.(next);\n } else if (now.restoreOnCancel !== false) {\n if (latest.current.key !== previousKey) setKey(previousKey, previous ?? null);\n now.onSelectionCancelled?.();\n }\n });\n\n return (\n <PickerField field={{ trailingIcon: glyphs.chevron, ...props }} hasValue={selected !== undefined} onOpen={onOpen}>\n {selected ? <SelectionValueIcon item={selected} /> : null}\n <text className={`g9-picker__text${selected ? '' : ' g9-picker__text--placeholder'}`} text-maxline=\"1\">\n {selected ? selected.text :
|
|
1
|
+
{"version":3,"file":"pickers/picker.jsx","sources":["../../src/pickers/picker.tsx"],"sourcesContent":["import { resolveRestingPlaceholder } from '../fields/outlined-field';\nimport './pickers.css';\nimport { type ReactNode, useRef } from '@lynx-js/react';\nimport { type G9SelectionItem, selectionKey } from '../base/selection-item';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { useG9Settings } from '../provider/hooks';\nimport { showSelectionSheet } from '../selection/selection-sheet';\nimport { useG9Sheets } from '../sheet/service';\nimport { type G9PickerFieldProps, PickerField, SelectionValueIcon, usePickerOpen } from './trigger';\n\n/** Props of {@link G9Picker}. */\nexport interface G9PickerProps<T extends G9SelectionItem = G9SelectionItem> extends G9PickerFieldProps {\n /** The rows of the sheet (MAUI `ItemsSource`). Disabled items are left out except the selected one. */\n readonly items: ReadonlyArray<T>;\n /** Selected item key (`selectionKey`: key, else text); `null` = none. Controlled with `onValueChange`. */\n readonly value?: string | null;\n readonly defaultValue?: string | null;\n /** The selection changed: by a pick, or by `restoreOnCancel` putting back the opening value. */\n readonly onValueChange?: (key: string | null, item: T | null) => void;\n /** Sheet title; default the label, else the placeholder (MAUI `SheetTitle`). */\n readonly sheetTitle?: string | null;\n /**\n * Default true (MAUI `RestoreOnCancel`): a dismissed sheet puts back the value the picker had when it opened (if it\n * changed meanwhile) and reports `onSelectionCancelled`. False leaves the current value and reports nothing.\n */\n readonly restoreOnCancel?: boolean;\n /** A row was picked (MAUI `ItemSelected` + `SelectionAcceptedCommand`); only for a pick, never for a dismissal. */\n readonly onItemSelected?: (item: T) => void;\n /** The sheet was dismissed without a pick (MAUI `SelectionCancelled` + `SelectionCancelledCommand`). */\n readonly onSelectionCancelled?: () => void;\n}\n\n/**\n * Single selection from a list in an outlined box (MAUI `G9Picker`): a tap opens the selection sheet (no search; a\n * pick closes it), the box shows the item's icon or swatch and text, the trailing chevron hints at the sheet. Must\n * be inside a `G9Host` (the sheet).\n */\nexport function G9Picker<T extends G9SelectionItem = G9SelectionItem>(props: G9PickerProps<T>): ReactNode {\n const sheets = useG9Sheets();\n const glyphs = useG9Settings().glyphs;\n const open = usePickerOpen();\n const [key, setKey] = useControllableState<string | null, [T | null]>({\n value: props.value,\n defaultValue: props.defaultValue ?? null,\n onChange: props.onValueChange,\n name: 'G9Picker.value',\n });\n const latest = useRef({ props, key });\n latest.current = { props, key };\n const selected = key === null ? undefined : props.items.find((i) => selectionKey(i) === key);\n\n const onOpen = () =>\n open(async (isCurrent) => {\n const p = latest.current.props;\n const previousKey = latest.current.key;\n const previous = previousKey === null ? undefined : p.items.find((i) => selectionKey(i) === previousKey);\n const items = p.items.filter((i) => i.isEnabled !== false || i === previous);\n if (items.length === 0) return;\n const result = await showSelectionSheet(sheets, {\n title: p.sheetTitle?.trim() ? p.sheetTitle : (p.label ?? p.placeholder ?? ''),\n items,\n selectedItems: previous ? [previous] : [],\n allowMultiple: false,\n closeOnSingleSelection: true,\n showSearch: false,\n });\n if (!isCurrent()) return;\n const next = result.wasAccepted ? result.items[0] : undefined;\n const now = latest.current.props;\n if (next) {\n setKey(selectionKey(next), next);\n now.onItemSelected?.(next);\n } else if (now.restoreOnCancel !== false) {\n if (latest.current.key !== previousKey) setKey(previousKey, previous ?? null);\n now.onSelectionCancelled?.();\n }\n });\n\n return (\n <PickerField field={{ trailingIcon: glyphs.chevron, ...props }} hasValue={selected !== undefined} onOpen={onOpen}>\n {selected ? <SelectionValueIcon item={selected} /> : null}\n <text className={`g9-picker__text${selected ? '' : ' g9-picker__text--placeholder'}`} text-maxline=\"1\">\n {selected ? selected.text : (resolveRestingPlaceholder(props) ?? '')}\n </text>\n </PickerField>\n );\n}\n"],"names":["G9Picker","props","_props_defaultValue","_resolveRestingPlaceholder","sheets","useG9Sheets","glyphs","useG9Settings","open","usePickerOpen","key","setKey","useControllableState","latest","useRef","selected","undefined","i","selectionKey","onOpen","isCurrent","_ref","_p_sheetTitle","p","previousKey","previous","items","result","showSelectionSheet","next","now","PickerField","SelectionValueIcon","text"],"mappings":";;;;;;;;;AAqCO,SAASA,SAAsDC,KAAuB;QAM3EC,qBAuCmBC;IA5CnC,MAAMC,SAASC;IACf,MAAMC,SAASC,gBAAgB,MAAM;IACrC,MAAMC,OAAOC;IACb,MAAM,CAACC,KAAKC,OAAO,GAAGC,qBAAgD;QACpE,OAAOX,MAAM,KAAK;QAClB,cAAc,QAAAC,CAAAA,sBAAAA,MAAM,YAAY,AAAD,IAAjBA,sBAAsB;QACpC,UAAUD,MAAM,aAAa;QAC7B,MAAM;IACR;IACA,MAAMY,SAASC,OAAO;QAAEb;QAAOS;IAAI;IACnCG,OAAO,OAAO,GAAG;QAAEZ;QAAOS;IAAI;IAC9B,MAAMK,WAAWL,AAAQ,SAARA,MAAeM,SAAYf,MAAM,KAAK,CAAC,IAAI,CAAC,CAACgB,IAAMC,aAAaD,OAAOP;IAExF,MAAMS,SAAS,IACbX,KAAK,OAAOY;gBAOsCC,MAAAA;gBAAvCC;YANT,MAAMC,IAAIV,OAAO,OAAO,CAAC,KAAK;YAC9B,MAAMW,cAAcX,OAAO,OAAO,CAAC,GAAG;YACtC,MAAMY,WAAWD,AAAgB,SAAhBA,cAAuBR,SAAYO,EAAE,KAAK,CAAC,IAAI,CAAC,CAACN,IAAMC,aAAaD,OAAOO;YAC5F,MAAME,QAAQH,EAAE,KAAK,CAAC,MAAM,CAAC,CAACN,IAAMA,AAAgB,UAAhBA,EAAE,SAAS,IAA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A,SAAS,IAAI,GAAG,QAACZ,CAAAA,6BAAAA,0BAA0BF,MAAK,IAA/BE,6BAAoC,GAAI;MACvE,EAAE8B,KAAK;IACT,EAAEF;AAEN"}
|
package/dist/pickers/pickers.css
CHANGED
|
@@ -50,6 +50,33 @@
|
|
|
50
50
|
display: flex;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
.g9-combo__tonal {
|
|
54
|
+
border-style: solid;
|
|
55
|
+
border-width: 1px;
|
|
56
|
+
border-color: var(--g9-outline-variant);
|
|
57
|
+
background-color: var(--g9-surface-container-low);
|
|
58
|
+
border-radius: 17px;
|
|
59
|
+
flex-direction: row;
|
|
60
|
+
align-items: center;
|
|
61
|
+
column-gap: 8px;
|
|
62
|
+
height: 34px;
|
|
63
|
+
display: flex;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.g9-combo__tonal-text {
|
|
67
|
+
color: var(--g9-text-primary);
|
|
68
|
+
text-overflow: ellipsis;
|
|
69
|
+
font-size: 14px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.g9-combo__tonal-close {
|
|
73
|
+
justify-content: center;
|
|
74
|
+
align-items: center;
|
|
75
|
+
width: 24px;
|
|
76
|
+
height: 24px;
|
|
77
|
+
display: flex;
|
|
78
|
+
}
|
|
79
|
+
|
|
53
80
|
.g9-combo__chips {
|
|
54
81
|
flex-direction: row;
|
|
55
82
|
align-items: center;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://./src/pickers/pickers.css"],"names":[],"mappings":"AAAA;EACE,mBAAmB;EACnB,mBAAmB;EACnB,YAAY;EACZ,aAAa;AACf;;AAEA;EACE,6BAA6B;EAC7B,cAAc;EACd,eAAe;AACjB;;AAEA;EACE,8BAA8B;AAChC;;AAGA;EAAE,iBAAiB;AACnB;;AAGA;EAAE,gBAAgB;EAChB,eAAe;AACjB;;AAGA;EAAE,iBAAiB;EACjB,aAAa;AACf;;AAGA;EAAE,gBAAgB;EAChB,eAAe;AACjB;;AAGA;EAAE,iBAAiB;AACnB;;AAGA;EAAE,gBAAgB;EAChB,eAAe;AACjB;;AAGA;EAAE,mBAAmB;EACnB,mBAAmB;EACnB,YAAY;EACZ,aAAa;AACf;;
|
|
1
|
+
{"version":3,"sources":["webpack://./src/pickers/pickers.css"],"names":[],"mappings":"AAAA;EACE,mBAAmB;EACnB,mBAAmB;EACnB,YAAY;EACZ,aAAa;AACf;;AAEA;EACE,6BAA6B;EAC7B,cAAc;EACd,eAAe;AACjB;;AAEA;EACE,8BAA8B;AAChC;;AAGA;EAAE,iBAAiB;AACnB;;AAGA;EAAE,gBAAgB;EAChB,eAAe;AACjB;;AAGA;EAAE,iBAAiB;EACjB,aAAa;AACf;;AAGA;EAAE,gBAAgB;EAChB,eAAe;AACjB;;AAGA;EAAE,iBAAiB;AACnB;;AAGA;EAAE,gBAAgB;EAChB,eAAe;AACjB;;AAGA;EAAE,mBAAmB;EACnB,mBAAmB;EACnB,YAAY;EACZ,aAAa;AACf;;AAIA;EADE,mBAAmB;EACnB,iBAAiB;EACjB,uCAAuC;EACvC,iDAAiD;EACjD,mBAAmB;EACnB,mBAAmB;EACnB,mBAAmB;EACnB,eAAe;EACf,YAAY;EACZ,aAAa;AACf;;AAIA;EADE,6BAA6B;EAC7B,uBAAuB;EACvB,eAAe;AACjB;;AAIA;EADE,uBAAuB;EACvB,mBAAmB;EACnB,WAAW;EACX,YAAY;EACZ,aAAa;AACf;;AAIA;EADE,mBAAmB;EACnB,mBAAmB;EACnB,aAAa;AACf;;AAIA;EADE,mCAAmC;EACnC,kBAAkB;EAClB,mBAAmB;EACnB,mBAAmB;EACnB,YAAY;EACZ,iBAAiB;EACjB,iBAAiB;EACjB,kBAAkB;EAClB,aAAa;AACf;;AAIA;EADE,gBAAgB;EAChB,eAAe;AACjB;;AAIA;EADE,qCAAqC;EACrC,mBAAmB;EACnB,iBAAiB;EACjB,uCAAuC;AACzC;;AAIA;EADE,2BAA2B;EAC3B,eAAe;EACf,gBAAgB;AAClB;;AAIA;EADE,+BAA+B;AACjC;;AAIA;EADE,mCAAmC;EACnC,sBAAsB;EACtB,oBAAoB;EACpB,aAAa;AACf;;AAIA;EADE,mBAAmB;EACnB,mBAAmB;EACnB,kBAAkB;EAClB,aAAa;AACf;;AAIA;EADE,kBAAkB;EAClB,6BAA6B;EAC7B,OAAO;EACP,eAAe;EACf,gBAAgB;AAClB;;AAKA;EAFE,kBAAkB;EAClB,wBAAwB;EACxB,qBAAqB;EACrB,eAAe;EACf,gBAAgB;AAClB;;AAMA;EAHE,mBAAmB;EACnB,iBAAiB;EACjB,mBAAmB;EACnB,uBAAuB;EACvB,kBAAkB;EAClB,mBAAmB;EACnB,eAAe;EACf,iBAAiB;EACjB,iBAAiB;EACjB,aAAa;AACf;;AAMA;EAHE,wBAAwB;EACxB,eAAe;EACf,gBAAgB;AAClB;;AAMA;EAHE,mBAAmB;EACnB,iBAAiB;EACjB,kBAAkB;EAClB,aAAa;AACf;;AAQA;EALE,cAAc;EACd,2BAA2B;AAC7B;;AAQA;EALE,sBAAsB;EACtB,OAAO;EACP,aAAa;AACf;;AASA;EANE,kBAAkB;EAClB,8BAA8B;EAC9B,kBAAkB;EAClB,eAAe;EACf,gBAAgB;AAClB;;AASA;EANE,kBAAkB;EAClB,gBAAgB;AAClB;;AAUA;EAPE,mBAAmB;EACnB,mBAAmB;EACnB,mBAAmB;EACnB,kBAAkB;EAClB,SAAS;EACT,UAAU;AACZ;;AAUA;EAPE,kBAAkB;EAClB,MAAM;EACN,SAAS;EACT,OAAO;EACP,QAAQ;AACV;;AAUA;EAPE,uBAAuB;EACvB,mBAAmB;EACnB,aAAa;AACf;;AAWA;EARE,8BAA8B;EAC9B,eAAe;AACjB;;AAWA;EARE,6BAA6B;EAC7B,eAAe;EACf,gBAAgB;AAClB","sourcesContent":[".g9-picker__value {\n display: flex;\n flex-direction: row;\n align-items: center;\n height: 100%;\n}\n\n.g9-picker__text {\n font-size: 15px;\n color: var(--g9-text-primary);\n flex-shrink: 1;\n}\n\n.g9-picker__text--placeholder {\n color: var(--g9-text-tertiary);\n}\n\n/* Gap after the swatch on the reading side (logical margins are dropped by the Lynx encoder, specs/02 §7). */\n.g9-picker__swatch {\n margin-right: 8px;\n}\n\n.g9-dir-rtl .g9-picker__swatch {\n margin-right: 0px;\n margin-left: 8px;\n}\n\n.g9-picker__icon {\n display: flex;\n margin-right: 8px;\n}\n\n.g9-dir-rtl .g9-picker__icon {\n margin-right: 0px;\n margin-left: 8px;\n}\n\n.g9-combo__chip .g9-picker__icon {\n margin-right: 6px;\n}\n\n.g9-dir-rtl .g9-combo__chip .g9-picker__icon {\n margin-right: 0px;\n margin-left: 6px;\n}\n\n.g9-combo__value {\n display: flex;\n flex-direction: row;\n align-items: center;\n height: 100%;\n}\n\n/* MAUI 1.4.10 ChipStyle.Tonal: a light pill per chosen item with its own close mark. */\n.g9-combo__tonal {\n display: flex;\n flex-direction: row;\n align-items: center;\n column-gap: 8px;\n height: 34px;\n border-radius: 17px;\n border-width: 1px;\n border-style: solid;\n border-color: var(--g9-outline-variant);\n background-color: var(--g9-surface-container-low);\n}\n\n.g9-combo__tonal-text {\n font-size: 14px;\n color: var(--g9-text-primary);\n text-overflow: ellipsis;\n}\n\n.g9-combo__tonal-close {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n}\n\n.g9-combo__chips {\n display: flex;\n flex-direction: row;\n align-items: center;\n}\n\n.g9-combo__chip {\n display: flex;\n flex-direction: row;\n align-items: center;\n height: 28px;\n padding-left: 9px;\n padding-right: 9px;\n margin-right: 6px;\n border-radius: 6px;\n background-color: var(--g9-primary);\n}\n\n.g9-dir-rtl .g9-combo__chip {\n margin-right: 0px;\n margin-left: 6px;\n}\n\n.g9-combo__chip--more {\n background: var(--g9-surface-variant);\n border-width: 1px;\n border-style: solid;\n border-color: var(--g9-outline-variant);\n}\n\n.g9-combo__chip-text {\n font-size: 13px;\n font-weight: 700;\n color: var(--g9-on-primary);\n}\n\n.g9-combo__chip--more .g9-combo__chip-text {\n color: var(--g9-text-secondary);\n}\n\n.g9-picker-sheet {\n display: flex;\n flex-direction: column;\n padding-bottom: 10px;\n background-color: var(--g9-surface);\n}\n\n.g9-picker-sheet__header {\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 10px 16px;\n}\n\n.g9-picker-sheet__title {\n flex: 1;\n text-align: center;\n font-size: 15px;\n font-weight: 700;\n color: var(--g9-text-primary);\n}\n\n/* MAUI: the live preview 13 bold Primary, Padding (16, 4, 16, 8). */\n.g9-picker-sheet__preview {\n text-align: center;\n font-size: 13px;\n font-weight: 700;\n color: var(--g9-primary);\n padding: 4px 16px 8px 16px;\n}\n\n/* Colours inline (Primary at 8 % / 30 %). */\n.g9-picker-sheet__today {\n align-self: center;\n padding: 6px 12px;\n column-gap: 6px;\n border-radius: 16px;\n border-width: 1px;\n border-style: solid;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 2px 0px 6px 0px;\n}\n\n.g9-picker-sheet__today-text {\n font-size: 12px;\n font-weight: 700;\n color: var(--g9-primary);\n}\n\n.g9-picker-sheet__wheels {\n display: flex;\n flex-direction: row;\n padding-left: 8px;\n padding-right: 8px;\n}\n\n/* Mirrored explicitly; the row's own direction stays ltr so an engine that honours `direction` does not reverse it\n again (Lynxtron ignores `direction`, E22). */\n.g9-picker-sheet__wheels.g9-dir-rtl {\n direction: ltr;\n flex-direction: row-reverse;\n}\n\n.g9-wheel {\n flex: 1;\n display: flex;\n flex-direction: column;\n}\n\n/* MAUI DrumLabelFontSize 10, bold, TextTertiary. */\n.g9-wheel__label {\n text-align: center;\n font-size: 10px;\n font-weight: 700;\n color: var(--g9-text-tertiary);\n margin-bottom: 4px;\n}\n\n.g9-wheel__viewport {\n position: relative;\n overflow: hidden;\n}\n\n/* Colours set inline from the palette (Primary at 6 % / 55 %): CSS cannot take an alpha off a colour variable. */\n.g9-wheel__band {\n position: absolute;\n left: 8px;\n right: 8px;\n border-radius: 12px;\n border-width: 1.2px;\n border-style: solid;\n}\n\n.g9-wheel__fade {\n position: absolute;\n top: 0px;\n left: 0px;\n right: 0px;\n bottom: 0px;\n}\n\n.g9-wheel__row {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n/* MAUI G9DrumColumn.Apply: 16 TextTertiary; the selected row 17 bold TextPrimary. */\n.g9-wheel__text {\n font-size: 16px;\n color: var(--g9-text-tertiary);\n}\n\n.g9-wheel__row--selected .g9-wheel__text {\n font-size: 17px;\n color: var(--g9-text-primary);\n font-weight: 700;\n}\n"],"sourceRoot":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timespan-picker.d.ts","sourceRoot":"","sources":["../../src/pickers/timespan-picker.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"timespan-picker.d.ts","sourceRoot":"","sources":["../../src/pickers/timespan-picker.tsx"],"names":[],"mappings":"AACA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,+BAA+B,CAAC;AAC5F,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,gBAAgB,CAAC;AAMlE,OAAO,EAIL,oBAAoB,EAKrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,kBAAkB,EAA8B,MAAM,WAAW,CAAC;AAGhF,yCAAyC;AACzC,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,0GAA0G;IAC1G,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACrD,qDAAqD;IACrD,QAAQ,CAAC,IAAI,CAAC,EAAE,oBAAoB,CAAC;IACrC,qFAAqF;IACrF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,2DAA2D;IAC3D,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAQD,yGAAyG;AACzG,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;CAC7B,GAAG,SAAS,CAoEZ;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,CA2CxE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveRestingPlaceholder } from "../fields/outlined-field.jsx";
|
|
1
2
|
import "./pickers.css";
|
|
2
3
|
import { G9StringKey, toNativeDigits } from "@g9tm/lynxcontrols-foundation";
|
|
3
4
|
import { useRef, useState } from "@lynx-js/react";
|
|
@@ -52,7 +53,7 @@ function TimeSpanSheetBody(props) {
|
|
|
52
53
|
</view>;
|
|
53
54
|
}
|
|
54
55
|
function G9TimeSpanPicker(props) {
|
|
55
|
-
var _props_mode, _props_defaultValue,
|
|
56
|
+
var _props_mode, _props_defaultValue, _resolveRestingPlaceholder;
|
|
56
57
|
const sheets = useG9Sheets();
|
|
57
58
|
const culture = useG9Culture();
|
|
58
59
|
const strings = useG9Strings();
|
|
@@ -90,7 +91,7 @@ function G9TimeSpanPicker(props) {
|
|
|
90
91
|
...props
|
|
91
92
|
}} hasValue={null !== value} onOpen={onOpen}>
|
|
92
93
|
<text className={`g9-picker__text${null !== value ? '' : ' g9-picker__text--placeholder'}`} text-maxline="1">
|
|
93
|
-
{null !== value ? formatTimeSpan(value, mode, strings, culture) :
|
|
94
|
+
{null !== value ? formatTimeSpan(value, mode, strings, culture) : null != (_resolveRestingPlaceholder = resolveRestingPlaceholder(props)) ? _resolveRestingPlaceholder : ''}
|
|
94
95
|
</text>
|
|
95
96
|
</PickerField>;
|
|
96
97
|
}
|