@g9tm/lynxcontrols 1.4.2 → 1.4.4
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/button/button.css +1 -0
- package/dist/button/button.css.map +1 -1
- package/dist/button/button.d.ts +2 -0
- package/dist/button/button.d.ts.map +1 -1
- package/dist/button/button.jsx +3 -2
- package/dist/button/button.jsx.map +1 -1
- package/dist/fields/outlined-field.d.ts +1 -1
- package/dist/fields/outlined-field.d.ts.map +1 -1
- package/dist/fields/outlined-field.jsx +13 -3
- package/dist/fields/outlined-field.jsx.map +1 -1
- package/dist/fields/use-text-input.d.ts.map +1 -1
- package/dist/fields/use-text-input.jsx +2 -2
- package/dist/fields/use-text-input.jsx.map +1 -1
- package/dist/pickers/date-time-picker.d.ts.map +1 -1
- package/dist/pickers/date-time-picker.jsx +13 -4
- package/dist/pickers/date-time-picker.jsx.map +1 -1
- package/dist/pickers/picker-sheet.d.ts +5 -1
- package/dist/pickers/picker-sheet.d.ts.map +1 -1
- package/dist/pickers/picker-sheet.jsx +3 -17
- package/dist/pickers/picker-sheet.jsx.map +1 -1
- package/dist/pickers/pickers.css +32 -43
- package/dist/pickers/pickers.css.map +1 -1
- package/dist/pickers/wheel-column.d.ts +3 -1
- package/dist/pickers/wheel-column.d.ts.map +1 -1
- package/dist/pickers/wheel-column.jsx +17 -3
- package/dist/pickers/wheel-column.jsx.map +1 -1
- package/dist/popup/frame.d.ts +6 -0
- package/dist/popup/frame.d.ts.map +1 -1
- package/dist/popup/frame.jsx +8 -6
- package/dist/popup/frame.jsx.map +1 -1
- package/dist/popup/popup.css +23 -16
- package/dist/popup/popup.css.map +1 -1
- package/dist/popup/service.d.ts.map +1 -1
- package/dist/popup/service.jsx +3 -2
- package/dist/popup/service.jsx.map +1 -1
- package/dist/range-slider/range-slider.css +5 -0
- package/dist/range-slider/range-slider.css.map +1 -1
- package/dist/range-slider/range-slider.jsx +1 -1
- package/dist/range-slider/range-slider.jsx.map +1 -1
- package/dist/selection/selection-sheet.d.ts.map +1 -1
- package/dist/selection/selection-sheet.jsx +4 -2
- package/dist/selection/selection-sheet.jsx.map +1 -1
- package/dist/selection/selection.css +15 -0
- package/dist/selection/selection.css.map +1 -1
- package/dist/sheet/frame.d.ts.map +1 -1
- package/dist/sheet/frame.jsx +28 -21
- package/dist/sheet/frame.jsx.map +1 -1
- package/dist/sheet/sheet.css +10 -0
- package/dist/sheet/sheet.css.map +1 -1
- package/dist/sheet/sizing.d.ts +6 -0
- package/dist/sheet/sizing.d.ts.map +1 -1
- package/dist/sheet/sizing.jsx +4 -2
- package/dist/sheet/sizing.jsx.map +1 -1
- package/dist/tabs/model.d.ts +1 -1
- package/dist/tabs/model.d.ts.map +1 -1
- package/dist/tabs/model.jsx.map +1 -1
- package/dist/tabs/tab-view.jsx +1 -1
- package/dist/tabs/tab-view.jsx.map +1 -1
- package/dist/toggle/chip-group.jsx +8 -2
- package/dist/toggle/chip-group.jsx.map +1 -1
- package/dist/toggle/switch.jsx +2 -1
- package/dist/toggle/switch.jsx.map +1 -1
- package/dist/toggle/toggle.css +5 -2
- package/dist/toggle/toggle.css.map +1 -1
- package/package.json +2 -2
|
@@ -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 type G9CalendarSystem,\n type G9Culture,\n G9DateTimeDisplayFormat,\n G9DateTimePickerMode,\n type G9LocalDate,\n type G9LocalDateTime,\n G9StringKey,\n localDateTimeFromDate,\n} from '@g9tm/lynxcontrols-foundation';\nimport { type ReactNode, useRef, useState } from '@lynx-js/react';\nimport { useG9Press } from '../base/press';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { useG9Culture, useG9Service, useG9Settings, useG9Strings } 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 { 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 <view\n className=\"g9-picker-sheet__today\"\n accessibility-element={true}\n accessibility-traits=\"button\"\n bindtap={today}\n >\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 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","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","G9StringKey","G9WheelColumn","dayWheelItems","daysInMonth","day","monthWheelItems","month","yearWheelItems","year","hourWheelItems","hour","minuteWheelItems","minute","G9DateTimePicker","_props_defaultValue","_props_mode","_props_placeholder","sheets","useG9Sheets","useG9Culture","glyphs","useG9Settings","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":";;;;;;;;;;;AAqCO,MAAMA,mBAAmB;AA+CzB,SAASC,kBAAkBC,KAAqB;IACrD,MAAMC,UAAUC;IAChB,MAAM,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGN;IAC5C,MAAM,CAACO,OAAOC,cAAc,GAAGC,SAAS,IAAMC,iBAAiBV,MAAM,OAAO,EAAEK,QAAQF;IAItF,MAAMQ,SAASC,OAAOL;IACtB,MAAMM,WAAW,CAACC;QAChBH,OAAO,OAAO,GA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AAA,IAAAA,CAAAA,uBAA0CJ;YAC5C,OAAO,IAAIzE,AAAyC,UAAzCA,OAAO,OAAO,CAAC,KAAK,CAAC,eAAe,IAAcA,OAAO,OAAO,CAAC,KAAK,KAAKmE,UACpFjE,SAASiE;QAEb;IAEF,QACGW,YACC,OAAO;QAAE,cAAcnF,SAAS6B,qBAAqB,IAAI,GAAG2B,OAAO,KAAK,GAAGA,OAAO,QAAQ;QAAE,GAAG9D,KAAK;IAAC,GACrG,UAAUO,AAAU,SAAVA,OACV,QAAQoE,QACT;MACC,CAAClC,KAAK,WAAW,CAAC,eAAe,EAAElC,QAAQ,KAAK,iCAAiC,EAAE,aAAa,IAAI;QAClG,CAACA,QAAQ+D,OAAO/D,SAASP,MAAM,KAAK,GAAG,KAAK,QAAC0D,CAAAA,qBAAAA,MAAM,WAAW,AAAD,IAAhBA,qBAAqB,GAAI;MACxE,EAAEjB,KAAK;IACT,EAAEgD;AAEN"}
|
|
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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entIn`, MAUI's crossfade).
|
|
13
13
|
*/
|
|
14
14
|
export declare function showPickerSheet<T>(sheets: G9SheetService, body: (props: G9PickerSheetBodyProps<T>) => ReactNode): Promise<T | null>;
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* The drum sheet header (MAUI `G9DateTimePickerSheet` / `G9TimeSpanPickerSheet.CreateHeader`): a Grid "Auto,*,Auto" of
|
|
17
|
+
* Padding (16, 10) — Cancel as a small Text-variant G9Button (Primary text in an Outline pill), the title 15 bold
|
|
18
|
+
* TextPrimary, Done as a small Primary G9Button.
|
|
19
|
+
*/
|
|
16
20
|
export declare function PickerSheetHeader(props: {
|
|
17
21
|
readonly title: string;
|
|
18
22
|
readonly onCancel: () => void;
|
|
@@ -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;;;;GAIG;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,CAqBnB;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;;;;GAIG;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,CAqBnB;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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./pickers.css";
|
|
2
2
|
import { G9StringKey } from "@g9tm/lynxcontrols-foundation";
|
|
3
3
|
import { g9RowStyle } from "../base/control.jsx";
|
|
4
|
-
import {
|
|
4
|
+
import { G9Button } from "../button/button.jsx";
|
|
5
5
|
import { useG9Direction, useG9Strings } from "../provider/hooks.jsx";
|
|
6
6
|
import { useG9SheetContext } from "../sheet/frame.jsx";
|
|
7
7
|
import { fitToContentSheetOptions } from "../sheet/options.jsx";
|
|
@@ -34,26 +34,12 @@ async function showPickerSheet(sheets, body) {
|
|
|
34
34
|
function PickerSheetHeader(props) {
|
|
35
35
|
const strings = useG9Strings();
|
|
36
36
|
const direction = useG9Direction();
|
|
37
|
-
const cancel = useG9Press(props.onCancel, {
|
|
38
|
-
source: 'G9PickerSheet',
|
|
39
|
-
guardMs: 0
|
|
40
|
-
});
|
|
41
|
-
const done = useG9Press(props.onDone, {
|
|
42
|
-
source: 'G9PickerSheet',
|
|
43
|
-
guardMs: 0
|
|
44
|
-
});
|
|
45
37
|
return <view className="g9-picker-sheet__header" style={g9RowStyle(direction)}>
|
|
46
|
-
<
|
|
47
|
-
<text className="g9-picker-sheet__action-text">{strings.get(G9StringKey.Cancel)}</text>
|
|
48
|
-
</view>
|
|
38
|
+
<G9Button className="g9-picker-sheet__cancel" text={strings.get(G9StringKey.Cancel)} variant="text" size="small" onPress={props.onCancel}/>
|
|
49
39
|
<text className="g9-picker-sheet__title" text-maxline="1">
|
|
50
40
|
{props.title}
|
|
51
41
|
</text>
|
|
52
|
-
<
|
|
53
|
-
<text className="g9-picker-sheet__action-text g9-picker-sheet__action-text--done">
|
|
54
|
-
{strings.get(G9StringKey.Done)}
|
|
55
|
-
</text>
|
|
56
|
-
</view>
|
|
42
|
+
<G9Button className="g9-picker-sheet__done" text={strings.get(G9StringKey.Done)} variant="primary" size="small" onPress={props.onDone}/>
|
|
57
43
|
</view>;
|
|
58
44
|
}
|
|
59
45
|
export { PickerSheetHeader, showPickerSheet };
|
|
@@ -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 {
|
|
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. The body is built after\n * the open motion and revealed as one settled unit (`fadeDeferredContentIn`, MAUI's crossfade).\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 />, {\n ...fitToContentSheetOptions(),\n fadeDeferredContentIn: true,\n loadingSkeleton: 'none',\n });\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":";;;;;;;AAqBO,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,CAAC,KAAOI,QAAS;QACzC,GAAGM,0BAA0B;QAC7B,uBAAuB;QACvB,iBAAiB;IACnB;IACA,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"}
|
package/dist/pickers/pickers.css
CHANGED
|
@@ -100,61 +100,42 @@
|
|
|
100
100
|
.g9-picker-sheet__header {
|
|
101
101
|
flex-direction: row;
|
|
102
102
|
align-items: center;
|
|
103
|
-
|
|
104
|
-
padding-left: 8px;
|
|
105
|
-
padding-right: 8px;
|
|
103
|
+
padding: 10px 16px;
|
|
106
104
|
display: flex;
|
|
107
105
|
}
|
|
108
106
|
|
|
109
|
-
.g9-picker-sheet__action {
|
|
110
|
-
justify-content: center;
|
|
111
|
-
align-items: center;
|
|
112
|
-
min-width: 64px;
|
|
113
|
-
height: 40px;
|
|
114
|
-
display: flex;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.g9-picker-sheet__action-text {
|
|
118
|
-
color: var(--g9-text-secondary);
|
|
119
|
-
font-size: 15px;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.g9-picker-sheet__action-text--done {
|
|
123
|
-
color: var(--g9-primary);
|
|
124
|
-
font-weight: 700;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
107
|
.g9-picker-sheet__title {
|
|
128
108
|
text-align: center;
|
|
129
|
-
color: var(--g9-
|
|
109
|
+
color: var(--g9-text-primary);
|
|
130
110
|
flex: 1;
|
|
131
|
-
font-size:
|
|
111
|
+
font-size: 15px;
|
|
132
112
|
font-weight: 700;
|
|
133
113
|
}
|
|
134
114
|
|
|
135
115
|
.g9-picker-sheet__preview {
|
|
136
116
|
text-align: center;
|
|
137
|
-
color: var(--g9-
|
|
138
|
-
|
|
139
|
-
font-size:
|
|
117
|
+
color: var(--g9-primary);
|
|
118
|
+
padding: 4px 16px 8px;
|
|
119
|
+
font-size: 13px;
|
|
120
|
+
font-weight: 700;
|
|
140
121
|
}
|
|
141
122
|
|
|
142
123
|
.g9-picker-sheet__today {
|
|
143
|
-
|
|
144
|
-
border-
|
|
124
|
+
border-style: solid;
|
|
125
|
+
border-width: 1px;
|
|
126
|
+
border-radius: 16px;
|
|
145
127
|
justify-content: center;
|
|
146
128
|
align-self: center;
|
|
147
129
|
align-items: center;
|
|
148
|
-
|
|
149
|
-
margin
|
|
150
|
-
padding
|
|
151
|
-
padding-right: 14px;
|
|
130
|
+
column-gap: 6px;
|
|
131
|
+
margin: 2px 0 6px;
|
|
132
|
+
padding: 6px 12px;
|
|
152
133
|
display: flex;
|
|
153
134
|
}
|
|
154
135
|
|
|
155
136
|
.g9-picker-sheet__today-text {
|
|
156
|
-
color: var(--g9-
|
|
157
|
-
font-size:
|
|
137
|
+
color: var(--g9-primary);
|
|
138
|
+
font-size: 12px;
|
|
158
139
|
font-weight: 700;
|
|
159
140
|
}
|
|
160
141
|
|
|
@@ -180,7 +161,8 @@
|
|
|
180
161
|
text-align: center;
|
|
181
162
|
color: var(--g9-text-tertiary);
|
|
182
163
|
margin-bottom: 4px;
|
|
183
|
-
font-size:
|
|
164
|
+
font-size: 10px;
|
|
165
|
+
font-weight: 700;
|
|
184
166
|
}
|
|
185
167
|
|
|
186
168
|
.g9-wheel__viewport {
|
|
@@ -190,13 +172,19 @@
|
|
|
190
172
|
|
|
191
173
|
.g9-wheel__band {
|
|
192
174
|
border-style: solid;
|
|
193
|
-
border-width: 1.
|
|
194
|
-
border-
|
|
195
|
-
|
|
196
|
-
|
|
175
|
+
border-width: 1.2px;
|
|
176
|
+
border-radius: 12px;
|
|
177
|
+
position: absolute;
|
|
178
|
+
left: 8px;
|
|
179
|
+
right: 8px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.g9-wheel__fade {
|
|
197
183
|
position: absolute;
|
|
198
|
-
|
|
199
|
-
|
|
184
|
+
top: 0;
|
|
185
|
+
bottom: 0;
|
|
186
|
+
left: 0;
|
|
187
|
+
right: 0;
|
|
200
188
|
}
|
|
201
189
|
|
|
202
190
|
.g9-wheel__row {
|
|
@@ -206,12 +194,13 @@
|
|
|
206
194
|
}
|
|
207
195
|
|
|
208
196
|
.g9-wheel__text {
|
|
209
|
-
color: var(--g9-text-
|
|
197
|
+
color: var(--g9-text-tertiary);
|
|
210
198
|
font-size: 16px;
|
|
211
199
|
}
|
|
212
200
|
|
|
213
201
|
.g9-wheel__row--selected .g9-wheel__text {
|
|
214
|
-
color: var(--g9-primary);
|
|
202
|
+
color: var(--g9-text-primary);
|
|
203
|
+
font-size: 17px;
|
|
215
204
|
font-weight: 700;
|
|
216
205
|
}
|
|
217
206
|
|
|
@@ -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;;AAGA;EAAE,mBAAmB;EACnB,mBAAmB;EACnB,aAAa;AACf;;AAGA;EAAE,mCAAmC;EACnC,kBAAkB;EAClB,mBAAmB;EACnB,mBAAmB;EACnB,YAAY;EACZ,iBAAiB;EACjB,iBAAiB;EACjB,kBAAkB;EAClB,aAAa;AACf;;AAGA;EAAE,gBAAgB;EAChB,eAAe;AACjB;;AAGA;EAAE,qCAAqC;EACrC,mBAAmB;EACnB,iBAAiB;EACjB,uCAAuC;AACzC;;AAGA;EAAE,2BAA2B;EAC3B,eAAe;EACf,gBAAgB;AAClB;;AAGA;EAAE,+BAA+B;AACjC;;AAGA;EAAE,mCAAmC;EACnC,sBAAsB;EACtB,oBAAoB;EACpB,aAAa;AACf;;AAGA;EAAE,mBAAmB;EACnB,mBAAmB;EACnB,
|
|
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;;AAGA;EAAE,mBAAmB;EACnB,mBAAmB;EACnB,aAAa;AACf;;AAGA;EAAE,mCAAmC;EACnC,kBAAkB;EAClB,mBAAmB;EACnB,mBAAmB;EACnB,YAAY;EACZ,iBAAiB;EACjB,iBAAiB;EACjB,kBAAkB;EAClB,aAAa;AACf;;AAGA;EAAE,gBAAgB;EAChB,eAAe;AACjB;;AAGA;EAAE,qCAAqC;EACrC,mBAAmB;EACnB,iBAAiB;EACjB,uCAAuC;AACzC;;AAGA;EAAE,2BAA2B;EAC3B,eAAe;EACf,gBAAgB;AAClB;;AAGA;EAAE,+BAA+B;AACjC;;AAGA;EAAE,mCAAmC;EACnC,sBAAsB;EACtB,oBAAoB;EACpB,aAAa;AACf;;AAGA;EAAE,mBAAmB;EACnB,mBAAmB;EACnB,kBAAkB;EAClB,aAAa;AACf;;AAGA;EAAE,kBAAkB;EAClB,6BAA6B;EAC7B,OAAO;EACP,eAAe;EACf,gBAAgB;AAClB;;AAIA;EADE,kBAAkB;EAClB,wBAAwB;EACxB,qBAAqB;EACrB,eAAe;EACf,gBAAgB;AAClB;;AAKA;EAFE,mBAAmB;EACnB,iBAAiB;EACjB,mBAAmB;EACnB,uBAAuB;EACvB,kBAAkB;EAClB,mBAAmB;EACnB,eAAe;EACf,iBAAiB;EACjB,iBAAiB;EACjB,aAAa;AACf;;AAKA;EAFE,wBAAwB;EACxB,eAAe;EACf,gBAAgB;AAClB;;AAKA;EAFE,mBAAmB;EACnB,iBAAiB;EACjB,kBAAkB;EAClB,aAAa;AACf;;AAOA;EAJE,cAAc;EACd,2BAA2B;AAC7B;;AAOA;EAJE,sBAAsB;EACtB,OAAO;EACP,aAAa;AACf;;AAQA;EALE,kBAAkB;EAClB,8BAA8B;EAC9B,kBAAkB;EAClB,eAAe;EACf,gBAAgB;AAClB;;AAQA;EALE,kBAAkB;EAClB,gBAAgB;AAClB;;AASA;EANE,mBAAmB;EACnB,mBAAmB;EACnB,mBAAmB;EACnB,kBAAkB;EAClB,SAAS;EACT,UAAU;AACZ;;AASA;EANE,kBAAkB;EAClB,MAAM;EACN,SAAS;EACT,OAAO;EACP,QAAQ;AACV;;AASA;EANE,uBAAuB;EACvB,mBAAmB;EACnB,aAAa;AACf;;AAUA;EAPE,8BAA8B;EAC9B,eAAe;AACjB;;AAUA;EAPE,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.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":""}
|
|
@@ -2,7 +2,7 @@ import './pickers.css';
|
|
|
2
2
|
import { type ReactNode } from '@lynx-js/react';
|
|
3
3
|
import type { G9WheelItem } from './date-time.js';
|
|
4
4
|
/** Row height of a wheel (MAUI `G9Metrics.DrumRowHeight`). */
|
|
5
|
-
export declare const g9WheelRowHeight =
|
|
5
|
+
export declare const g9WheelRowHeight = 44;
|
|
6
6
|
/** Rows a wheel shows (the selected row is the middle one). */
|
|
7
7
|
export declare const g9WheelVisibleRows = 5;
|
|
8
8
|
/** The row a scroll offset rests on: the nearest row, clamped to the list. */
|
|
@@ -16,6 +16,8 @@ export interface G9WheelColumnProps<V extends string | number> {
|
|
|
16
16
|
/** Caption above the column (Day, Month, …). */
|
|
17
17
|
readonly label?: string;
|
|
18
18
|
readonly rowHeight?: number;
|
|
19
|
+
/** Width weight among the sheet's wheels (MAUI's Star sizes: the month drum is 1.7, the others 1). Default 1. */
|
|
20
|
+
readonly weight?: number;
|
|
19
21
|
readonly visibleRows?: number;
|
|
20
22
|
/** The resting row is within two rows of an end (the year window grows there). */
|
|
21
23
|
readonly onNearEdge?: (edge: 'start' | 'end') => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wheel-column.d.ts","sourceRoot":"","sources":["../../src/pickers/wheel-column.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"wheel-column.d.ts","sourceRoot":"","sources":["../../src/pickers/wheel-column.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,gBAAgB,CAAC;AAI7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,8DAA8D;AAC9D,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,+DAA+D;AAC/D,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAGxF;AAED,sCAAsC;AACtC,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IAC3D,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,yEAAyE;IACzE,QAAQ,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC3C,gDAAgD;IAChD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,iHAAiH;IACjH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,kFAAkF;IAClF,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,KAAK,KAAK,IAAI,CAAC;IACtD,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACtC;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,SAAS,CA0HhG"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import "./pickers.css";
|
|
2
|
+
import { formatColor, withAlpha } from "@g9tm/lynxcontrols-foundation";
|
|
2
3
|
import { useEffect, useRef, useState } from "@lynx-js/react";
|
|
3
4
|
import { invokeNodeWhenReady } from "../fields/use-text-input.jsx";
|
|
4
|
-
|
|
5
|
+
import { useG9Theme } from "../provider/hooks.jsx";
|
|
6
|
+
const g9WheelRowHeight = 44;
|
|
5
7
|
const g9WheelVisibleRows = 5;
|
|
6
8
|
function wheelIndexAt(scrollTop, rowHeight, count) {
|
|
7
9
|
if (count <= 0) return 0;
|
|
@@ -61,7 +63,14 @@ function G9WheelColumn(props) {
|
|
|
61
63
|
setLive((prev)=>prev === index ? prev : index);
|
|
62
64
|
};
|
|
63
65
|
const onScrollEnd = ()=>settle(wheelIndexAt(scrollTop.current, rowHeight, latest.current.items.length));
|
|
64
|
-
|
|
66
|
+
const palette = useG9Theme().palette;
|
|
67
|
+
const surface = formatColor(palette.Surface);
|
|
68
|
+
const clear = formatColor(withAlpha(palette.Surface, 0));
|
|
69
|
+
return <view className="g9-wheel" accessibility-label={null != (_ref = null != (_props_accessibilityLabel = props.accessibilityLabel) ? _props_accessibilityLabel : props.label) ? _ref : ''} {...void 0 !== props.weight && 1 !== props.weight ? {
|
|
70
|
+
style: {
|
|
71
|
+
flex: props.weight
|
|
72
|
+
}
|
|
73
|
+
} : {}}>
|
|
65
74
|
{props.label ? <text className="g9-wheel__label" text-maxline="1">
|
|
66
75
|
{props.label}
|
|
67
76
|
</text> : null}
|
|
@@ -70,7 +79,9 @@ function G9WheelColumn(props) {
|
|
|
70
79
|
}}>
|
|
71
80
|
<view className="g9-wheel__band" user-interaction-enabled={false} style={{
|
|
72
81
|
top: `${pad}px`,
|
|
73
|
-
height: `${rowHeight}px
|
|
82
|
+
height: `${rowHeight}px`,
|
|
83
|
+
backgroundColor: formatColor(withAlpha(palette.Primary, 0.06)),
|
|
84
|
+
borderColor: formatColor(withAlpha(palette.Primary, 0.55))
|
|
74
85
|
}}/>
|
|
75
86
|
<scroll-view ref={(n)=>{
|
|
76
87
|
node.current = n;
|
|
@@ -91,6 +102,9 @@ function G9WheelColumn(props) {
|
|
|
91
102
|
height: `${pad}px`
|
|
92
103
|
}}/>
|
|
93
104
|
</scroll-view>
|
|
105
|
+
<view className="g9-wheel__fade" user-interaction-enabled={false} style={{
|
|
106
|
+
background: `linear-gradient(to bottom, ${surface} 0%, ${clear} 30%, ${clear} 70%, ${surface} 100%)`
|
|
107
|
+
}}/>
|
|
94
108
|
</view>
|
|
95
109
|
</view>;
|
|
96
110
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickers/wheel-column.jsx","sources":["../../src/pickers/wheel-column.tsx"],"sourcesContent":["import './pickers.css';\nimport { type ReactNode, useEffect, useRef, useState } from '@lynx-js/react';\nimport type { NodesRef } from '@lynx-js/types';\nimport { invokeNodeWhenReady } from '../fields/use-text-input';\nimport type { G9WheelItem } from './date-time';\n\n/** Row height of a wheel (MAUI `G9Metrics.DrumRowHeight`). */\nexport const g9WheelRowHeight = 40;\n/** Rows a wheel shows (the selected row is the middle one). */\nexport const g9WheelVisibleRows = 5;\n\n/** The row a scroll offset rests on: the nearest row, clamped to the list. */\nexport function wheelIndexAt(scrollTop: number, rowHeight: number, count: number): number {\n if (count <= 0) return 0;\n return Math.min(count - 1, Math.max(0, Math.round(scrollTop / rowHeight)));\n}\n\n/** Props of {@link G9WheelColumn}. */\nexport interface G9WheelColumnProps<V extends string | number> {\n readonly items: ReadonlyArray<G9WheelItem<V>>;\n readonly value: V;\n /** The user brought another row to rest in the band (after the snap). */\n readonly onValueChange: (value: V) => void;\n /** Caption above the column (Day, Month, …). */\n readonly label?: string;\n readonly rowHeight?: number;\n readonly visibleRows?: number;\n /** The resting row is within two rows of an end (the year window grows there). */\n readonly onNearEdge?: (edge: 'start' | 'end') => void;\n readonly accessibilityLabel?: string;\n}\n\n/**\n * One drum of the date/time and duration pickers (MAUI `G9DrumColumn`): a vertical `scroll-view` of fixed-height\n * rows behind a selection band. The highlighted row follows the scroll live; when the scroll ends (finger lifted and\n * the fling done — Lynx reports it, so MAUI's 16 ms settle polling is not needed) the column glides to the nearest\n * row and reports its value. A tap on a row selects it. A new `value` from the parent rolls the column to it\n * (animated once mounted); the column never echoes a value it reported itself.\n */\nexport function G9WheelColumn<V extends string | number>(props: G9WheelColumnProps<V>): ReactNode {\n const rowHeight = props.rowHeight ?? g9WheelRowHeight;\n const visible = props.visibleRows ?? g9WheelVisibleRows;\n const pad = rowHeight * Math.floor(visible / 2);\n const count = props.items.length;\n const valueIndex = Math.max(\n 0,\n props.items.findIndex((i) => i.value === props.value),\n );\n const [live, setLive] = useState(valueIndex);\n const node = useRef<NodesRef | null>(null);\n const scrollTop = useRef(valueIndex * rowHeight);\n const reported = useRef<V | null>(null);\n const mounted = useRef(false);\n const latest = useRef(props);\n latest.current = props;\n\n const scrollToIndex = (index: number, smooth: boolean) => {\n scrollTop.current = index * rowHeight;\n invokeNodeWhenReady(node, 'scrollTo', { offset: index * rowHeight, smooth });\n };\n\n // Follow the parent's value (and item changes) unless it is the one this column just reported.\n useEffect(() => {\n if (reported.current !== null && reported.current === props.value) {\n reported.current = null;\n return;\n }\n reported.current = null;\n setLive(valueIndex);\n scrollToIndex(valueIndex, mounted.current);\n mounted.current = true;\n }, [props.value, count]);\n\n const settle = (index: number) => {\n const item = latest.current.items[index];\n scrollToIndex(index, true);\n setLive(index);\n if (index <= 2) latest.current.onNearEdge?.('start');\n if (index >= latest.current.items.length - 3) latest.current.onNearEdge?.('end');\n if (!item || item.value === latest.current.value) return;\n reported.current = item.value;\n latest.current.onValueChange(item.value);\n };\n\n const onScroll = (e: { detail?: { scrollTop?: number } }) => {\n const top = e.detail?.scrollTop;\n if (typeof top !== 'number') return;\n scrollTop.current = top;\n const index = wheelIndexAt(top, rowHeight, latest.current.items.length);\n setLive((prev) => (prev === index ? prev : index));\n };\n const onScrollEnd = () => settle(wheelIndexAt(scrollTop.current, rowHeight, latest.current.items.length));\n\n return (\n <view className=\"g9-wheel\" accessibility-label={props.accessibilityLabel ?? props.label ?? ''}>\n {props.label ? (\n <text className=\"g9-wheel__label\" text-maxline=\"1\">\n {props.label}\n </text>\n ) : null}\n <view className=\"g9-wheel__viewport\" style={{ height: `${rowHeight * visible}px` }}>\n <view\n className=\"g9-wheel__band\"\n user-interaction-enabled={false}\n style={{ top: `${pad}px`, height: `${rowHeight}px` }}\n />\n <scroll-view\n ref={(n: NodesRef | null) => {\n node.current = n;\n }}\n className=\"g9-wheel__scroll\"\n scroll-orientation=\"vertical\"\n style={{ height: `${rowHeight * visible}px` }}\n bindscroll={onScroll}\n bindscrollend={onScrollEnd}\n >\n <view style={{ height: `${pad}px` }} />\n {props.items.map((item, i) => (\n <view\n key={String(item.value)}\n className={`g9-wheel__row${i === live ? ' g9-wheel__row--selected' : ''}`}\n style={{ height: `${rowHeight}px` }}\n accessibility-element={true}\n accessibility-traits=\"button\"\n accessibility-value={i === live ? 'selected' : ''}\n accessibility-label={item.text}\n bindtap={() => settle(i)}\n >\n <text className=\"g9-wheel__text\" text-maxline=\"1\">\n {item.text}\n </text>\n </view>\n ))}\n <view style={{ height: `${pad}px` }} />\n </scroll-view>\n </view>\n </view>\n );\n}\n"],"names":["g9WheelRowHeight","g9WheelVisibleRows","wheelIndexAt","scrollTop","rowHeight","count","Math","G9WheelColumn","props","_props_rowHeight","_props_visibleRows","_ref","visible","pad","valueIndex","i","live","setLive","useState","node","useRef","reported","mounted","latest","scrollToIndex","index","smooth","invokeNodeWhenReady","useEffect","settle","_latest_current","_latest_current1","item","onScroll","e","_e_detail","top","prev","onScrollEnd","view","text","scroll-view","n","String"],"mappings":";;;AAOO,MAAMA,mBAAmB;AAEzB,MAAMC,qBAAqB;AAG3B,SAASC,aAAaC,SAAiB,EAAEC,SAAiB,EAAEC,KAAa;IAC9E,IAAIA,SAAS,GAAG,OAAO;IACvB,OAAOC,KAAK,GAAG,CAACD,QAAQ,GAAGC,KAAK,GAAG,CAAC,GAAGA,KAAK,KAAK,CAACH,YAAYC;AAChE;AAwBO,SAASG,cAAyCC,KAA4B;QACjEC,kBACFC,oBAqDkCC,MAAAA;IAtDlD,MAAMP,YAAY,QAAAK,CAAAA,mBAAAA,MAAM,SAAS,AAAD,IAAdA,mBAAmBT;IACrC,MAAMY,UAAU,QAAAF,CAAAA,qBAAAA,MAAM,WAAW,AAAD,IAAhBA,qBAAqBT;IACrC,MAAMY,MAAMT,YAAYE,KAAK,KAAK,CAACM,UAAU;IAC7C,MAAMP,QAAQG,MAAM,KAAK,CAAC,MAAM;IAChC,MAAMM,aAAaR,KAAK,GAAG,CACzB,GACAE,MAAM,KAAK,CAAC,SAAS,CAAC,CAACO,IAAMA,EAAE,KAAK,KAAKP,MAAM,KAAK;IAEtD,MAAM,CAACQ,MAAMC,QAAQ,GAAGC,SAASJ;IACjC,MAAMK,OAAOC,OAAwB;IACrC,MAAMjB,YAAYiB,OAAON,aAAaV;IACtC,MAAMiB,WAAWD,OAAiB;IAClC,MAAME,UAAUF,OAAO;IACvB,MAAMG,SAASH,OAAOZ;IACtBe,OAAO,OAAO,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C,OAAO,6BAA6B,IAAI,EACzE,OAAO;YAAE,QAAQ,GAAGZ,UAAU,EAAE,CAAC;QAAC,GAClC,uBAAuB,MACvB,qBAAqB,SACrB,qBAAqBW,MAAMC,OAAO,aAAa,IAC/C,qBAAqBgB,KAAK,IAAI,EAC9B,SAAS,IAAMH,OAAOd,IACvB;cACC,CAACyB,KAAK,UAAU,iBAAiB,aAAa,IAAI;gBAChD,CAACR,KAAK,IAAI,CAAC;cACb,EAAEQ,KAAK;YACT,EAAED,OACD;UACH,CAACA,KAAK,OAAO;QAAE,QAAQ,GAAG1B,IAAI,EAAE,CAAC;IAAC,IAAK;QACzC,EAAE4B,YAAY;MAChB,EAAEF,KAAK;IACT,EAAEA;AAEN"}
|
|
1
|
+
{"version":3,"file":"pickers/wheel-column.jsx","sources":["../../src/pickers/wheel-column.tsx"],"sourcesContent":["import './pickers.css';\nimport { formatColor, withAlpha } from '@g9tm/lynxcontrols-foundation';\nimport { type ReactNode, useEffect, useRef, useState } from '@lynx-js/react';\nimport type { NodesRef } from '@lynx-js/types';\nimport { invokeNodeWhenReady } from '../fields/use-text-input';\nimport { useG9Theme } from '../provider/hooks';\nimport type { G9WheelItem } from './date-time';\n\n/** Row height of a wheel (MAUI `G9Metrics.DrumRowHeight`). */\nexport const g9WheelRowHeight = 44;\n/** Rows a wheel shows (the selected row is the middle one). */\nexport const g9WheelVisibleRows = 5;\n\n/** The row a scroll offset rests on: the nearest row, clamped to the list. */\nexport function wheelIndexAt(scrollTop: number, rowHeight: number, count: number): number {\n if (count <= 0) return 0;\n return Math.min(count - 1, Math.max(0, Math.round(scrollTop / rowHeight)));\n}\n\n/** Props of {@link G9WheelColumn}. */\nexport interface G9WheelColumnProps<V extends string | number> {\n readonly items: ReadonlyArray<G9WheelItem<V>>;\n readonly value: V;\n /** The user brought another row to rest in the band (after the snap). */\n readonly onValueChange: (value: V) => void;\n /** Caption above the column (Day, Month, …). */\n readonly label?: string;\n readonly rowHeight?: number;\n /** Width weight among the sheet's wheels (MAUI's Star sizes: the month drum is 1.7, the others 1). Default 1. */\n readonly weight?: number;\n readonly visibleRows?: number;\n /** The resting row is within two rows of an end (the year window grows there). */\n readonly onNearEdge?: (edge: 'start' | 'end') => void;\n readonly accessibilityLabel?: string;\n}\n\n/**\n * One drum of the date/time and duration pickers (MAUI `G9DrumColumn`): a vertical `scroll-view` of fixed-height\n * rows behind a selection band. The highlighted row follows the scroll live; when the scroll ends (finger lifted and\n * the fling done — Lynx reports it, so MAUI's 16 ms settle polling is not needed) the column glides to the nearest\n * row and reports its value. A tap on a row selects it. A new `value` from the parent rolls the column to it\n * (animated once mounted); the column never echoes a value it reported itself.\n */\nexport function G9WheelColumn<V extends string | number>(props: G9WheelColumnProps<V>): ReactNode {\n const rowHeight = props.rowHeight ?? g9WheelRowHeight;\n const visible = props.visibleRows ?? g9WheelVisibleRows;\n const pad = rowHeight * Math.floor(visible / 2);\n const count = props.items.length;\n const valueIndex = Math.max(\n 0,\n props.items.findIndex((i) => i.value === props.value),\n );\n const [live, setLive] = useState(valueIndex);\n const node = useRef<NodesRef | null>(null);\n const scrollTop = useRef(valueIndex * rowHeight);\n const reported = useRef<V | null>(null);\n const mounted = useRef(false);\n const latest = useRef(props);\n latest.current = props;\n\n const scrollToIndex = (index: number, smooth: boolean) => {\n scrollTop.current = index * rowHeight;\n invokeNodeWhenReady(node, 'scrollTo', { offset: index * rowHeight, smooth });\n };\n\n // Follow the parent's value (and item changes) unless it is the one this column just reported.\n useEffect(() => {\n if (reported.current !== null && reported.current === props.value) {\n reported.current = null;\n return;\n }\n reported.current = null;\n setLive(valueIndex);\n scrollToIndex(valueIndex, mounted.current);\n mounted.current = true;\n }, [props.value, count]);\n\n const settle = (index: number) => {\n const item = latest.current.items[index];\n scrollToIndex(index, true);\n setLive(index);\n if (index <= 2) latest.current.onNearEdge?.('start');\n if (index >= latest.current.items.length - 3) latest.current.onNearEdge?.('end');\n if (!item || item.value === latest.current.value) return;\n reported.current = item.value;\n latest.current.onValueChange(item.value);\n };\n\n const onScroll = (e: { detail?: { scrollTop?: number } }) => {\n const top = e.detail?.scrollTop;\n if (typeof top !== 'number') return;\n scrollTop.current = top;\n const index = wheelIndexAt(top, rowHeight, latest.current.items.length);\n setLive((prev) => (prev === index ? prev : index));\n };\n const onScrollEnd = () => settle(wheelIndexAt(scrollTop.current, rowHeight, latest.current.items.length));\n\n // MAUI G9DrumColumnDrawable: the band a hairline tint (Primary 6 %) and outline (Primary 55 %, 1.2 dp, corner 12, 8 dp\n // in from each side); over the rows, Surface fading out across the top 30 % and back in across the bottom 30 %.\n const palette = useG9Theme().palette;\n const surface = formatColor(palette.Surface);\n const clear = formatColor(withAlpha(palette.Surface, 0));\n return (\n <view\n className=\"g9-wheel\"\n accessibility-label={props.accessibilityLabel ?? props.label ?? ''}\n // The same shorthand as the class's `flex: 1`, and only for a weighted wheel: the longhand (grow / shrink / 0 px\n // basis) re-laid the column out after the opening scrollTo and dropped every wheel back to its first row.\n {...(props.weight !== undefined && props.weight !== 1 ? { style: { flex: props.weight } } : {})}\n >\n {props.label ? (\n <text className=\"g9-wheel__label\" text-maxline=\"1\">\n {props.label}\n </text>\n ) : null}\n <view className=\"g9-wheel__viewport\" style={{ height: `${rowHeight * visible}px` }}>\n <view\n className=\"g9-wheel__band\"\n user-interaction-enabled={false}\n style={{\n top: `${pad}px`,\n height: `${rowHeight}px`,\n backgroundColor: formatColor(withAlpha(palette.Primary, 0.06)),\n borderColor: formatColor(withAlpha(palette.Primary, 0.55)),\n }}\n />\n <scroll-view\n ref={(n: NodesRef | null) => {\n node.current = n;\n }}\n className=\"g9-wheel__scroll\"\n scroll-orientation=\"vertical\"\n style={{ height: `${rowHeight * visible}px` }}\n bindscroll={onScroll}\n bindscrollend={onScrollEnd}\n >\n <view style={{ height: `${pad}px` }} />\n {props.items.map((item, i) => (\n <view\n key={String(item.value)}\n className={`g9-wheel__row${i === live ? ' g9-wheel__row--selected' : ''}`}\n style={{ height: `${rowHeight}px` }}\n accessibility-element={true}\n accessibility-traits=\"button\"\n accessibility-value={i === live ? 'selected' : ''}\n accessibility-label={item.text}\n bindtap={() => settle(i)}\n >\n <text className=\"g9-wheel__text\" text-maxline=\"1\">\n {item.text}\n </text>\n </view>\n ))}\n <view style={{ height: `${pad}px` }} />\n </scroll-view>\n <view\n className=\"g9-wheel__fade\"\n user-interaction-enabled={false}\n style={{\n background: `linear-gradient(to bottom, ${surface} 0%, ${clear} 30%, ${clear} 70%, ${surface} 100%)`,\n }}\n />\n </view>\n </view>\n );\n}\n"],"names":["g9WheelRowHeight","g9WheelVisibleRows","wheelIndexAt","scrollTop","rowHeight","count","Math","G9WheelColumn","props","_props_rowHeight","_props_visibleRows","_ref","visible","pad","valueIndex","i","live","setLive","useState","node","useRef","reported","mounted","latest","scrollToIndex","index","smooth","invokeNodeWhenReady","useEffect","settle","_latest_current","_latest_current1","item","onScroll","e","_e_detail","top","prev","onScrollEnd","palette","useG9Theme","surface","formatColor","clear","withAlpha","view","undefined","text","scroll-view","n","String"],"mappings":";;;;;AASO,MAAMA,mBAAmB;AAEzB,MAAMC,qBAAqB;AAG3B,SAASC,aAAaC,SAAiB,EAAEC,SAAiB,EAAEC,KAAa;IAC9E,IAAIA,SAAS,GAAG,OAAO;IACvB,OAAOC,KAAK,GAAG,CAACD,QAAQ,GAAGC,KAAK,GAAG,CAAC,GAAGA,KAAK,KAAK,CAACH,YAAYC;AAChE;AA0BO,SAASG,cAAyCC,KAA4B;QACjEC,kBACFC,oBA4DSC,MAAAA;IA7DzB,MAAMP,YAAY,QAAAK,CAAAA,mBAAAA,MAAM,SAAS,AAAD,IAAdA,mBAAmBT;IACrC,MAAMY,UAAU,QAAAF,CAAAA,qBAAAA,MAAM,WAAW,AAAD,IAAhBA,qBAAqBT;IACrC,MAAMY,MAAMT,YAAYE,KAAK,KAAK,CAACM,UAAU;IAC7C,MAAMP,QAAQG,MAAM,KAAK,CAAC,MAAM;IAChC,MAAMM,aAAaR,KAAK,GAAG,CACzB,GACAE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,CAAC;IACtG,IACA;MACJ,EAAEI,KAAK;IACT,EAAEA;AAEN"}
|
package/dist/popup/frame.d.ts
CHANGED
|
@@ -52,6 +52,12 @@ export interface G9PopupViewOpenOptions {
|
|
|
52
52
|
/** The card can be dragged: by a `<G9PopupDragHandle>` inside it, or anywhere when there is none. */
|
|
53
53
|
readonly isDraggable?: boolean;
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* The size every MAUI popup RESTS at: `G9PopupView` builds its card container with `ScaleX = ScaleY = 0.92` and its
|
|
57
|
+
* open animations only ever set `Scale` (which multiplies them), so the card, its text and its buttons all show at
|
|
58
|
+
* 92 % — a 403 dp card measures 371 dp on screen (MAUI 6.2.36, Pixel 9 Pro XL). The port reproduces what users see.
|
|
59
|
+
*/
|
|
60
|
+
export declare const g9PopupRestingScale = 0.92;
|
|
55
61
|
/** The pose a card starts from / leaves to, per motion (MAUI `G9PopupView` animation table). */
|
|
56
62
|
export declare function popupMotionPose(animation: G9PopupAnimationType, phase: 'enter' | 'exit'): {
|
|
57
63
|
opacity: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../src/popup/frame.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAiB,KAAK,SAAS,EAA2C,MAAM,gBAAgB,CAAC;AAIxG,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAGjB,mFAAmF;AACnF,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,gEAAgE;AAChE,MAAM,WAAW,sBAAs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G,OAAO,CAAC;IAC3C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,CAoH5D"}
|
package/dist/popup/frame.jsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import "./popup.css";
|
|
2
|
-
import { resolveThemeColor } from "@g9tm/lynxcontrols-foundation";
|
|
2
|
+
import { formatColor, resolveThemeColor, withAlpha } from "@g9tm/lynxcontrols-foundation";
|
|
3
3
|
import { createContext, useContext, useEffect, useRef, useState } from "@lynx-js/react";
|
|
4
4
|
import { g9SafeId } from "../base/control.jsx";
|
|
5
5
|
import { g9FieldNotchStyle } from "../fields/notch.jsx";
|
|
6
6
|
import { useG9Theme } from "../provider/hooks.jsx";
|
|
7
7
|
import { popupScrimOpacity } from "./types.jsx";
|
|
8
|
+
const g9PopupRestingScale = 0.92;
|
|
8
9
|
function popupMotionPose(animation, phase) {
|
|
9
10
|
switch(animation){
|
|
10
11
|
case 'none':
|
|
@@ -121,10 +122,11 @@ function G9PopupDragHandle(props) {
|
|
|
121
122
|
</view>;
|
|
122
123
|
}
|
|
123
124
|
function PopupFrame(props) {
|
|
124
|
-
var _o_cardBackground, _o_animation, _o_animationDuration, _o_overlayMode, _o_animationEasing, _o_autoSizeMode, _o_absoluteX, _o_absoluteY, _o_relativeAbsoluteX, _o_relativeAbsoluteY, _o_padding, _o_overlayOpacity, _o_blurIntensity,
|
|
125
|
+
var _o_cardBackground, _o_overlayColor, _o_animation, _o_animationDuration, _o_overlayMode, _o_animationEasing, _o_autoSizeMode, _o_absoluteX, _o_absoluteY, _o_relativeAbsoluteX, _o_relativeAbsoluteY, _o_padding, _o_overlayOpacity, _o_blurIntensity, _o_cornerRadius, _o_cardBackground1, _o_borderColor;
|
|
125
126
|
const o = props.options;
|
|
126
127
|
const palette = useG9Theme().palette;
|
|
127
128
|
const notch = g9FieldNotchStyle(resolveThemeColor(null != (_o_cardBackground = o.cardBackground) ? _o_cardBackground : 'var(--g9-surface)', palette));
|
|
129
|
+
const scrimColor = formatColor(withAlpha(resolveThemeColor(null != (_o_overlayColor = o.overlayColor) ? _o_overlayColor : 'var(--g9-scrim)', palette), 1));
|
|
128
130
|
const animation = null != (_o_animation = o.animation) ? _o_animation : 'slideUp';
|
|
129
131
|
const duration = null != (_o_animationDuration = o.animationDuration) ? _o_animationDuration : 240;
|
|
130
132
|
const mode = null != (_o_overlayMode = o.overlayMode) ? _o_overlayMode : 'transparent';
|
|
@@ -193,8 +195,8 @@ function PopupFrame(props) {
|
|
|
193
195
|
return <view className={`g9-popup${'none' === mode ? ' g9-popup--nonmodal' : ''}${placed ? ' g9-popup--placed' : ''}`} {...'none' === mode ? {
|
|
194
196
|
'event-through': true
|
|
195
197
|
} : {}}>
|
|
196
|
-
{'none' !== mode ? <view className="g9-popup__scrim" style={{
|
|
197
|
-
backgroundColor:
|
|
198
|
+
{'none' !== mode ? <view flatten={false} className="g9-popup__scrim" style={{
|
|
199
|
+
backgroundColor: scrimColor,
|
|
198
200
|
opacity: 'open' === props.phase ? scrimOpacity : 0,
|
|
199
201
|
transition: 'enter' === props.phase ? 'none' : `opacity ${duration}ms`
|
|
200
202
|
}} bindtap={()=>{
|
|
@@ -222,7 +224,7 @@ function PopupFrame(props) {
|
|
|
222
224
|
padding: `${pad[1]}px ${pad[2]}px ${pad[3]}px ${pad[0]}px`,
|
|
223
225
|
...notch,
|
|
224
226
|
opacity: pose.opacity,
|
|
225
|
-
transform: `${dragTranslate}${pose.transform}`,
|
|
227
|
+
transform: `${dragTranslate}${pose.transform} scale(${g9PopupRestingScale})`,
|
|
226
228
|
transition
|
|
227
229
|
}} bindlayoutchange={(e)=>{
|
|
228
230
|
var _ref, _ref1;
|
|
@@ -247,6 +249,6 @@ function PopupFrame(props) {
|
|
|
247
249
|
</view>
|
|
248
250
|
</view>;
|
|
249
251
|
}
|
|
250
|
-
export { G9PopupDragHandle, PopupFrame, popupEasingCss, popupMotionPose, relativePopupPlacement };
|
|
252
|
+
export { G9PopupDragHandle, PopupFrame, g9PopupRestingScale, popupEasingCss, popupMotionPose, relativePopupPlacement };
|
|
251
253
|
|
|
252
254
|
//# sourceMappingURL=frame.jsx.map
|