@g9tm/lynxcontrols 1.4.7 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/anchor/context.d.ts +15 -0
- package/dist/anchor/context.d.ts.map +1 -0
- package/dist/anchor/context.jsx +10 -0
- package/dist/anchor/context.jsx.map +1 -0
- package/dist/anchor/hooks.d.ts +72 -0
- package/dist/anchor/hooks.d.ts.map +1 -0
- package/dist/anchor/hooks.jsx +147 -0
- package/dist/anchor/hooks.jsx.map +1 -0
- package/dist/anchor/index.d.ts +6 -0
- package/dist/anchor/index.d.ts.map +1 -0
- package/dist/anchor/index.jsx +5 -0
- package/dist/anchor/measure.d.ts +22 -0
- package/dist/anchor/measure.d.ts.map +1 -0
- package/dist/anchor/measure.jsx +110 -0
- package/dist/anchor/measure.jsx.map +1 -0
- package/dist/anchor/registry.d.ts +108 -0
- package/dist/anchor/registry.d.ts.map +1 -0
- package/dist/anchor/registry.jsx +142 -0
- package/dist/anchor/registry.jsx.map +1 -0
- package/dist/anchor/scroll.d.ts +34 -0
- package/dist/anchor/scroll.d.ts.map +1 -0
- package/dist/anchor/scroll.jsx +255 -0
- package/dist/anchor/scroll.jsx.map +1 -0
- package/dist/base/control.d.ts +10 -3
- package/dist/base/control.d.ts.map +1 -1
- package/dist/base/control.jsx +17 -2
- package/dist/base/control.jsx.map +1 -1
- package/dist/base/index.d.ts +1 -1
- package/dist/base/index.d.ts.map +1 -1
- package/dist/base/index.jsx +1 -1
- package/dist/base/pressable.d.ts.map +1 -1
- package/dist/base/pressable.jsx +7 -1
- package/dist/base/pressable.jsx.map +1 -1
- package/dist/base/selection-item.d.ts +9 -1
- package/dist/base/selection-item.d.ts.map +1 -1
- package/dist/base/selection-item.jsx +10 -1
- package/dist/base/selection-item.jsx.map +1 -1
- package/dist/button/button.css +20 -0
- package/dist/button/button.css.map +1 -1
- package/dist/button/button.d.ts.map +1 -1
- package/dist/button/button.jsx +11 -1
- package/dist/button/button.jsx.map +1 -1
- package/dist/button/header-action-button.d.ts +5 -0
- package/dist/button/header-action-button.d.ts.map +1 -1
- package/dist/button/header-action-button.jsx +16 -2
- package/dist/button/header-action-button.jsx.map +1 -1
- package/dist/button/icon-button.d.ts.map +1 -1
- package/dist/button/icon-button.jsx +11 -1
- package/dist/button/icon-button.jsx.map +1 -1
- package/dist/button/nav-card.d.ts.map +1 -1
- package/dist/button/nav-card.jsx +10 -1
- package/dist/button/nav-card.jsx.map +1 -1
- package/dist/button/vertical-icon-text-button.d.ts.map +1 -1
- package/dist/button/vertical-icon-text-button.jsx +10 -1
- package/dist/button/vertical-icon-text-button.jsx.map +1 -1
- package/dist/button/visuals.d.ts.map +1 -1
- package/dist/button/visuals.jsx +1 -1
- package/dist/button/visuals.jsx.map +1 -1
- package/dist/expander/expander.d.ts.map +1 -1
- package/dist/expander/expander.jsx +14 -1
- package/dist/expander/expander.jsx.map +1 -1
- package/dist/fields/editor.d.ts.map +1 -1
- package/dist/fields/editor.jsx +18 -2
- package/dist/fields/editor.jsx.map +1 -1
- package/dist/fields/fields.css +21 -0
- package/dist/fields/fields.css.map +1 -1
- package/dist/fields/index.d.ts +1 -1
- package/dist/fields/index.d.ts.map +1 -1
- package/dist/fields/index.jsx +1 -1
- package/dist/fields/outlined-field.d.ts +33 -1
- package/dist/fields/outlined-field.d.ts.map +1 -1
- package/dist/fields/outlined-field.jsx +43 -5
- package/dist/fields/outlined-field.jsx.map +1 -1
- package/dist/fields/text-entry.d.ts.map +1 -1
- package/dist/fields/text-entry.jsx +18 -2
- package/dist/fields/text-entry.jsx.map +1 -1
- package/dist/guide/guide.css +453 -0
- package/dist/guide/guide.css.map +1 -0
- package/dist/guide/index.d.ts +5 -0
- package/dist/guide/index.d.ts.map +1 -0
- package/dist/guide/index.jsx +4 -0
- package/dist/guide/journey.d.ts +46 -0
- package/dist/guide/journey.d.ts.map +1 -0
- package/dist/guide/journey.jsx +464 -0
- package/dist/guide/journey.jsx.map +1 -0
- package/dist/guide/placement.d.ts +44 -0
- package/dist/guide/placement.d.ts.map +1 -0
- package/dist/guide/placement.jsx +119 -0
- package/dist/guide/placement.jsx.map +1 -0
- package/dist/guide/service.d.ts +85 -0
- package/dist/guide/service.d.ts.map +1 -0
- package/dist/guide/service.jsx +620 -0
- package/dist/guide/service.jsx.map +1 -0
- package/dist/guide/settings.d.ts +50 -0
- package/dist/guide/settings.d.ts.map +1 -0
- package/dist/guide/settings.jsx +60 -0
- package/dist/guide/settings.jsx.map +1 -0
- package/dist/host/host.d.ts +5 -1
- package/dist/host/host.d.ts.map +1 -1
- package/dist/host/host.jsx +12 -0
- package/dist/host/host.jsx.map +1 -1
- package/dist/host/layers.d.ts +3 -1
- package/dist/host/layers.d.ts.map +1 -1
- package/dist/host/layers.jsx +4 -2
- package/dist/host/layers.jsx.map +1 -1
- package/dist/host/registry.d.ts +3 -0
- package/dist/host/registry.d.ts.map +1 -1
- package/dist/host/registry.jsx.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/pickers/combo-box.d.ts +8 -0
- package/dist/pickers/combo-box.d.ts.map +1 -1
- package/dist/pickers/combo-box.jsx +51 -9
- package/dist/pickers/combo-box.jsx.map +1 -1
- package/dist/pickers/date-time-picker.d.ts +2 -2
- package/dist/pickers/date-time-picker.d.ts.map +1 -1
- package/dist/pickers/date-time-picker.jsx +4 -3
- package/dist/pickers/date-time-picker.jsx.map +1 -1
- package/dist/pickers/date-time.d.ts +5 -2
- package/dist/pickers/date-time.d.ts.map +1 -1
- package/dist/pickers/date-time.jsx +1 -1
- package/dist/pickers/date-time.jsx.map +1 -1
- package/dist/pickers/picker-sheet.d.ts +6 -2
- package/dist/pickers/picker-sheet.d.ts.map +1 -1
- package/dist/pickers/picker-sheet.jsx +2 -3
- package/dist/pickers/picker-sheet.jsx.map +1 -1
- package/dist/pickers/picker.d.ts.map +1 -1
- package/dist/pickers/picker.jsx +3 -2
- package/dist/pickers/picker.jsx.map +1 -1
- package/dist/pickers/pickers.css +27 -0
- package/dist/pickers/pickers.css.map +1 -1
- package/dist/pickers/timespan-picker.d.ts.map +1 -1
- package/dist/pickers/timespan-picker.jsx +3 -2
- package/dist/pickers/timespan-picker.jsx.map +1 -1
- package/dist/pickers/trigger.d.ts +3 -1
- package/dist/pickers/trigger.d.ts.map +1 -1
- package/dist/pickers/trigger.jsx +6 -1
- package/dist/pickers/trigger.jsx.map +1 -1
- package/dist/provider/contexts.d.ts +3 -0
- package/dist/provider/contexts.d.ts.map +1 -1
- package/dist/provider/contexts.jsx.map +1 -1
- package/dist/provider/provider.d.ts.map +1 -1
- package/dist/provider/provider.jsx +24 -17
- package/dist/provider/provider.jsx.map +1 -1
- package/dist/provider/settings.d.ts +16 -0
- package/dist/provider/settings.d.ts.map +1 -1
- package/dist/provider/settings.jsx +7 -3
- package/dist/provider/settings.jsx.map +1 -1
- package/dist/provider/theme.css +4 -0
- package/dist/provider/theme.css.map +1 -1
- package/dist/range-slider/math.d.ts +14 -4
- package/dist/range-slider/math.d.ts.map +1 -1
- package/dist/range-slider/math.jsx +16 -4
- package/dist/range-slider/math.jsx.map +1 -1
- package/dist/range-slider/range-slider.css +17 -0
- package/dist/range-slider/range-slider.css.map +1 -1
- package/dist/range-slider/range-slider.d.ts +11 -0
- package/dist/range-slider/range-slider.d.ts.map +1 -1
- package/dist/range-slider/range-slider.jsx +35 -13
- package/dist/range-slider/range-slider.jsx.map +1 -1
- package/dist/route/hooks.d.ts +34 -0
- package/dist/route/hooks.d.ts.map +1 -0
- package/dist/route/hooks.jsx +147 -0
- package/dist/route/hooks.jsx.map +1 -0
- package/dist/route/index.d.ts +3 -0
- package/dist/route/index.d.ts.map +1 -0
- package/dist/route/index.jsx +2 -0
- package/dist/route/router.d.ts +201 -0
- package/dist/route/router.d.ts.map +1 -0
- package/dist/route/router.jsx +810 -0
- package/dist/route/router.jsx.map +1 -0
- package/dist/selection/index.d.ts +2 -1
- package/dist/selection/index.d.ts.map +1 -1
- package/dist/selection/index.jsx +2 -1
- package/dist/selection/selection-sheet.d.ts +3 -1
- package/dist/selection/selection-sheet.d.ts.map +1 -1
- package/dist/selection/selection-sheet.jsx +57 -8
- package/dist/selection/selection-sheet.jsx.map +1 -1
- package/dist/selection/selection.css +7 -0
- package/dist/selection/selection.css.map +1 -1
- package/dist/selection/window.d.ts +29 -0
- package/dist/selection/window.d.ts.map +1 -0
- package/dist/selection/window.jsx +24 -0
- package/dist/selection/window.jsx.map +1 -0
- package/dist/sheet/frame.d.ts +3 -1
- package/dist/sheet/frame.d.ts.map +1 -1
- package/dist/sheet/frame.jsx +72 -26
- package/dist/sheet/frame.jsx.map +1 -1
- package/dist/sheet/header.d.ts.map +1 -1
- package/dist/sheet/header.jsx +3 -1
- package/dist/sheet/header.jsx.map +1 -1
- package/dist/sheet/index.d.ts +1 -1
- package/dist/sheet/index.d.ts.map +1 -1
- package/dist/sheet/index.jsx +1 -1
- package/dist/sheet/options.d.ts +30 -0
- package/dist/sheet/options.d.ts.map +1 -1
- package/dist/sheet/options.jsx +2 -1
- package/dist/sheet/options.jsx.map +1 -1
- package/dist/sheet/service.d.ts +13 -0
- package/dist/sheet/service.d.ts.map +1 -1
- package/dist/sheet/service.jsx +27 -4
- package/dist/sheet/service.jsx.map +1 -1
- package/dist/sheet/sheet.css +9 -0
- package/dist/sheet/sheet.css.map +1 -1
- package/dist/sheet/sizing.d.ts +2 -0
- package/dist/sheet/sizing.d.ts.map +1 -1
- package/dist/sheet/sizing.jsx +2 -1
- package/dist/sheet/sizing.jsx.map +1 -1
- package/dist/tabs/tab-view.d.ts +14 -0
- package/dist/tabs/tab-view.d.ts.map +1 -1
- package/dist/tabs/tab-view.jsx +59 -3
- package/dist/tabs/tab-view.jsx.map +1 -1
- package/dist/toggle/checkbox.d.ts.map +1 -1
- package/dist/toggle/checkbox.jsx +15 -1
- package/dist/toggle/checkbox.jsx.map +1 -1
- package/dist/toggle/chip-group.d.ts +9 -1
- package/dist/toggle/chip-group.d.ts.map +1 -1
- package/dist/toggle/chip-group.jsx +63 -13
- package/dist/toggle/chip-group.jsx.map +1 -1
- package/dist/toggle/switch.d.ts +1 -1
- package/dist/toggle/switch.d.ts.map +1 -1
- package/dist/toggle/switch.jsx +18 -3
- package/dist/toggle/switch.jsx.map +1 -1
- package/dist/toggle/toggle.css +20 -0
- package/dist/toggle/toggle.css.map +1 -1
- package/package.json +17 -2
package/dist/button/visuals.jsx
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button/visuals.jsx","sources":["../../src/button/visuals.ts"],"sourcesContent":["import {\n buildSolidOrGradient,\n createBorderColor,\n fillToCss,\n formatColor,\n type G9ButtonVariant,\n type G9ControlSize,\n G9Metrics,\n type G9PaletteValues,\n getContrastingTextColor,\n resolveButtonVariant,\n toRgba,\n tryParseColor,\n} from '@g9tm/lynxcontrols-foundation';\n\n/** What a button paints (MAUI `G9Visuals.ButtonVisualResult` + the stroke/opacity rules of G9Button/G9IconButton). */\nexport interface G9ButtonPaint {\n /** CSS `background` (a colour or a vertical gradient). */\n readonly background: string;\n readonly text: string;\n readonly stroke: string;\n readonly strokeWidth: number;\n /** 0.38 when not effectively enabled, 0.70 while loading, else 1. */\n readonly opacity: number;\n}\n\n/** Inputs of {@link resolveButtonPaint}. */\nexport interface G9ButtonPaintInput {\n readonly variant: G9ButtonVariant;\n readonly palette: G9PaletteValues;\n /** `IsEnabled && !blocked`. */\n readonly enabled: boolean;\n readonly loading: boolean;\n readonly baseBackgroundColor?: string | null | undefined;\n readonly textColor?: string | null | undefined;\n /** `'button'`: tonal has a 1.5 stroke; `'icon'`: only outline/text do (MAUI G9IconButton). */\n readonly kind: 'button' | 'icon';\n}\n\n/**\n * Resolves the paint of a button (MAUI `G9Button.OnApplyVisuals` / `G9IconButton.OnApplyVisuals`):\n * - variant colours from `resolveButtonVariant`; the gradient only while enabled and not loading;\n * - `baseBackgroundColor`: fully transparent → no fill, no border; otherwise a flat fill, contrasting text and a\n * darkened border (stroke 1 when visible);\n * - `textColor` always wins for text/icon/spinner;\n * - stroke 1.5 for outline/text (and tonal on `G9Button`), else 0.\n * A colour that is not a parseable literal (e.g. a `var(--…)` token) is used as given: flat fill, the variant's text\n * colour unless `textColor` is set, and no derived border.\n */\nexport function resolveButtonPaint(input: G9ButtonPaintInput): G9ButtonPaint {\n const variant = resolveButtonVariant(input.variant, input.palette);\n const opacity = !input.enabled ? 0.38 : input.loading ? 0.7 : 1;\n const base = input.baseBackgroundColor;\n if (base != null) {\n const parsed = tryParseColor(base);\n if (parsed && parsed.a === 0) {\n return {\n background: 'transparent',\n text: input.textColor ?? variant.text,\n stroke: 'transparent',\n strokeWidth: 0,\n opacity,\n };\n }\n if (!parsed) {\n return {\n background: base,\n text: input.textColor ?? variant.text,\n stroke: 'transparent',\n strokeWidth: 0,\n opacity,\n };\n }\n const stroke = createBorderColor(parsed);\n return {\n background: formatColor(parsed),\n text: input.textColor ?? formatColor(getContrastingTextColor(parsed)),\n stroke: formatColor(stroke),\n strokeWidth: toRgba(stroke).a > 0 ? 1 : 0,\n opacity,\n };\n }\n const outlined =\n input.variant === 'outline' || input.variant === 'text' || (input.kind === 'button' && input.variant === 'tonal');\n return {\n background: fillToCss(\n buildSolidOrGradient(variant.background, variant.usesGradient && input.enabled && !input.loading),\n ),\n text: input.textColor ?? variant.text,\n stroke: variant.stroke,\n strokeWidth: outlined ? 1.5 : 0,\n opacity,\n };\n}\n\n/** Size preset of `G9Button` (MAUI `ApplySizePreset`). */\nexport interface G9ButtonSizePreset {\n readonly height: number;\n readonly paddingHorizontal: number;\n readonly paddingVertical: number;\n readonly fontSize: number;\n /** Hero buttons fill the width. */\n readonly fill: boolean;\n}\n\n/** MAUI G9Button size presets: small 36 / medium 44 / large 48 / hero 52. */\nexport function buttonSizePreset(size: G9ControlSize): G9ButtonSizePreset {\n switch (size) {\n case 'small':\n return {\n height: G9Metrics.ButtonHeightSmall,\n paddingHorizontal: 12,\n paddingVertical: 8,\n fontSize: G9Metrics.ButtonFontSmall,\n fill: false,\n };\n case 'large':\n return {\n height: G9Metrics.ButtonHeightLarge,\n paddingHorizontal: 20,\n paddingVertical: 14,\n fontSize: G9Metrics.ButtonFontLarge,\n fill: false,\n };\n case 'hero':\n return {\n height: G9Metrics.ButtonHeightHero,\n paddingHorizontal: 16,\n paddingVertical:
|
|
1
|
+
{"version":3,"file":"button/visuals.jsx","sources":["../../src/button/visuals.ts"],"sourcesContent":["import {\n buildSolidOrGradient,\n createBorderColor,\n fillToCss,\n formatColor,\n type G9ButtonVariant,\n type G9ControlSize,\n G9Metrics,\n type G9PaletteValues,\n getContrastingTextColor,\n resolveButtonVariant,\n toRgba,\n tryParseColor,\n} from '@g9tm/lynxcontrols-foundation';\n\n/** What a button paints (MAUI `G9Visuals.ButtonVisualResult` + the stroke/opacity rules of G9Button/G9IconButton). */\nexport interface G9ButtonPaint {\n /** CSS `background` (a colour or a vertical gradient). */\n readonly background: string;\n readonly text: string;\n readonly stroke: string;\n readonly strokeWidth: number;\n /** 0.38 when not effectively enabled, 0.70 while loading, else 1. */\n readonly opacity: number;\n}\n\n/** Inputs of {@link resolveButtonPaint}. */\nexport interface G9ButtonPaintInput {\n readonly variant: G9ButtonVariant;\n readonly palette: G9PaletteValues;\n /** `IsEnabled && !blocked`. */\n readonly enabled: boolean;\n readonly loading: boolean;\n readonly baseBackgroundColor?: string | null | undefined;\n readonly textColor?: string | null | undefined;\n /** `'button'`: tonal has a 1.5 stroke; `'icon'`: only outline/text do (MAUI G9IconButton). */\n readonly kind: 'button' | 'icon';\n}\n\n/**\n * Resolves the paint of a button (MAUI `G9Button.OnApplyVisuals` / `G9IconButton.OnApplyVisuals`):\n * - variant colours from `resolveButtonVariant`; the gradient only while enabled and not loading;\n * - `baseBackgroundColor`: fully transparent → no fill, no border; otherwise a flat fill, contrasting text and a\n * darkened border (stroke 1 when visible);\n * - `textColor` always wins for text/icon/spinner;\n * - stroke 1.5 for outline/text (and tonal on `G9Button`), else 0.\n * A colour that is not a parseable literal (e.g. a `var(--…)` token) is used as given: flat fill, the variant's text\n * colour unless `textColor` is set, and no derived border.\n */\nexport function resolveButtonPaint(input: G9ButtonPaintInput): G9ButtonPaint {\n const variant = resolveButtonVariant(input.variant, input.palette);\n const opacity = !input.enabled ? 0.38 : input.loading ? 0.7 : 1;\n const base = input.baseBackgroundColor;\n if (base != null) {\n const parsed = tryParseColor(base);\n if (parsed && parsed.a === 0) {\n return {\n background: 'transparent',\n text: input.textColor ?? variant.text,\n stroke: 'transparent',\n strokeWidth: 0,\n opacity,\n };\n }\n if (!parsed) {\n return {\n background: base,\n text: input.textColor ?? variant.text,\n stroke: 'transparent',\n strokeWidth: 0,\n opacity,\n };\n }\n const stroke = createBorderColor(parsed);\n return {\n background: formatColor(parsed),\n text: input.textColor ?? formatColor(getContrastingTextColor(parsed)),\n stroke: formatColor(stroke),\n strokeWidth: toRgba(stroke).a > 0 ? 1 : 0,\n opacity,\n };\n }\n const outlined =\n input.variant === 'outline' || input.variant === 'text' || (input.kind === 'button' && input.variant === 'tonal');\n return {\n background: fillToCss(\n buildSolidOrGradient(variant.background, variant.usesGradient && input.enabled && !input.loading),\n ),\n text: input.textColor ?? variant.text,\n stroke: variant.stroke,\n strokeWidth: outlined ? 1.5 : 0,\n opacity,\n };\n}\n\n/** Size preset of `G9Button` (MAUI `ApplySizePreset`). */\nexport interface G9ButtonSizePreset {\n readonly height: number;\n readonly paddingHorizontal: number;\n readonly paddingVertical: number;\n readonly fontSize: number;\n /** Hero buttons fill the width. */\n readonly fill: boolean;\n}\n\n/** MAUI G9Button size presets: small 36 / medium 44 / large 48 / hero 52. */\nexport function buttonSizePreset(size: G9ControlSize): G9ButtonSizePreset {\n switch (size) {\n case 'small':\n return {\n height: G9Metrics.ButtonHeightSmall,\n paddingHorizontal: 12,\n paddingVertical: 8,\n fontSize: G9Metrics.ButtonFontSmall,\n fill: false,\n };\n case 'large':\n return {\n height: G9Metrics.ButtonHeightLarge,\n paddingHorizontal: 20,\n paddingVertical: 14,\n fontSize: G9Metrics.ButtonFontLarge,\n fill: false,\n };\n case 'hero':\n // 52 tall with 12 above and below the text row, not 16 (MAUI 1.4.11): 16 left a 16 px label 20 px of height and cut\n // a Persian descender off («ج» of «خروج» on AgriPad's sign-out button, TR-0035).\n return {\n height: G9Metrics.ButtonHeightHero,\n paddingHorizontal: 16,\n paddingVertical: 12,\n fontSize: G9Metrics.ButtonFontHero,\n fill: true,\n };\n default:\n return {\n height: G9Metrics.ButtonHeightMedium,\n paddingHorizontal: 16,\n paddingVertical: 12,\n fontSize: G9Metrics.ButtonFontMedium,\n fill: false,\n };\n }\n}\n\n/** MAUI `FontAttributes`. */\nexport type G9FontAttributes = 'none' | 'bold' | 'italic' | 'boldItalic';\n\n/** CSS for {@link G9FontAttributes}. */\nexport function fontAttributesStyle(attributes: G9FontAttributes): {\n fontWeight: 'bold' | 'normal';\n fontStyle: 'italic' | 'normal';\n} {\n return {\n fontWeight: attributes === 'bold' || attributes === 'boldItalic' ? 'bold' : 'normal',\n fontStyle: attributes === 'italic' || attributes === 'boldItalic' ? 'italic' : 'normal',\n };\n}\n"],"names":["resolveButtonPaint","input","_input_textColor","variant","resolveButtonVariant","opacity","base","_input_textColor1","parsed","tryParseColor","_input_textColor2","_input_textColor3","stroke","createBorderColor","formatColor","getContrastingTextColor","toRgba","outlined","fillToCss","buildSolidOrGradient","buttonSizePreset","size","G9Metrics","fontAttributesStyle","attributes"],"mappings":";AAiDO,SAASA,mBAAmBC,KAAyB;QAuClDC;IAtCR,MAAMC,UAAUC,qBAAqBH,MAAM,OAAO,EAAEA,MAAM,OAAO;IACjE,MAAMI,UAAU,AAACJ,MAAM,OAAO,GAAUA,MAAM,OAAO,GAAG,MAAM,IAA7B;IACjC,MAAMK,OAAOL,MAAM,mBAAmB;IACtC,IAAIK,AAAQ,QAARA,MAAc;YAuBRC;QAtBR,MAAMC,SAASC,cAAcH;QAC7B,IAAIE,UAAUA,AAAa,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AS,CAAC;CAC/B;AAED,+CAA+C;AAC/C,MAAM,WAAW,gBAAgB;IAC/B,4CAA4C;IAC5C,MAAM,IAAI,IAAI,CAAC;CAChB;AAID;;;;GAIG;AACH,eAAO,MAAM,UAAU,8GAyGrB,CAAC"}
|
|
@@ -11,7 +11,20 @@ import { useG9Settings, useG9Theme } from "../provider/hooks.jsx";
|
|
|
11
11
|
const g9ExpanderDurationMs = 220;
|
|
12
12
|
const expander_G9Expander = forwardRef(function(props, ref) {
|
|
13
13
|
var _props_defaultExpanded, _props_contentPadding, _props_headerHeight, _props_iconColor, _props_titleColor, _props_chevronColor;
|
|
14
|
-
const control = useG9Control(props, 'g9-expander'
|
|
14
|
+
const control = useG9Control(props, 'g9-expander', {
|
|
15
|
+
kind: 'view',
|
|
16
|
+
label: ()=>{
|
|
17
|
+
var _props_accessibilityLabel;
|
|
18
|
+
return null != (_props_accessibilityLabel = props.accessibilityLabel) ? _props_accessibilityLabel : props.title;
|
|
19
|
+
},
|
|
20
|
+
capabilities: {
|
|
21
|
+
activate: ()=>press(),
|
|
22
|
+
getValue: ()=>String(expanded),
|
|
23
|
+
expand: (open)=>{
|
|
24
|
+
if (open !== expanded) press();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
15
28
|
const glyphs = useG9Settings().glyphs;
|
|
16
29
|
const palette = useG9Theme().palette;
|
|
17
30
|
const [expanded, setExpanded] = useControllableState({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expander/expander.jsx","sources":["../../src/expander/expander.tsx"],"sourcesContent":["import './expander.css';\nimport type { G9ImageSource } from '@g9tm/lynxcontrols-foundation';\nimport { g9Ms } from '@g9tm/lynxcontrols-foundation';\nimport { forwardRef, type ReactNode, useEffect, useImperativeHandle, useRef, useState } from '@lynx-js/react';\nimport { type G9ControlBaseProps, g9ChildId, g9IdProps, g9RowStyle, useG9Control } from '../base/control';\nimport { useG9Press, usePressVisual } from '../base/press';\nimport { type G9TimerHandle, startTimer, stopTimer } from '../base/timers';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { g9FieldNotchStyle } from '../fields/notch';\nimport type { G9IconInput } from '../icon/icon';\nimport { G9IconSlot, hasIconSlot } from '../icon/slot';\nimport { useG9Settings, useG9Theme } from '../provider/hooks';\n\n/** Expand/collapse duration (MAUI `G9Metrics` expander 220 ms). */\nexport const g9ExpanderDurationMs = 220;\n\n/** Props of {@link G9Expander} (MAUI `G9Expander`). */\nexport interface G9ExpanderProps extends G9ControlBaseProps {\n readonly title?: string | null;\n /** Default `var(--g9-text-primary)`. */\n readonly titleColor?: string | null;\n readonly iconEmoji?: string | null;\n readonly icon?: G9IconInput;\n readonly iconPath?: string | null;\n readonly iconImage?: G9ImageSource | null;\n /** Default `var(--g9-text-primary)`. */\n readonly iconColor?: string | null;\n /** Default `var(--g9-text-secondary)`. */\n readonly chevronColor?: string | null;\n /** Controlled open state (MAUI `IsExpanded`). */\n readonly expanded?: boolean;\n readonly defaultExpanded?: boolean;\n /** Once per change made by the expander (header tap, `toggle()`); never for pushed values. */\n readonly onExpandedChange?: (expanded: boolean) => void;\n /** Card look: surface, 1 px outline, 16 px corners, 14 × 12 padding. Default false. */\n readonly showFrame?: boolean;\n /** Minimum header height. Default 48. */\n readonly headerHeight?: number;\n /** Content padding `[left, top, right, bottom]` (an 8 px top gap is always added). Default 0. */\n readonly contentPadding?: readonly [number, number, number, number];\n /** The content (MAUI `ExpanderContent`): mounted at once and kept, hidden while collapsed. */\n readonly children?: ReactNode;\n}\n\n/** Imperative handle of {@link G9Expander}. */\nexport interface G9ExpanderHandle {\n /** Same as a header tap (MAUI `Toggle`). */\n toggle(): void;\n}\n\ntype Phase = 'open' | 'opening' | 'closing' | 'closed';\n\n/**\n * Collapsible section (MAUI `G9Expander`): only the header toggles; the chevron turns 180° and the content height\n * animates over 220 ms (CSS transition on the measured height; instant when it cannot be measured). The first render\n * does not animate. The content stays mounted.\n */\nexport const G9Expander = forwardRef<G9ExpanderHandle, G9ExpanderProps>(function G9Expander(props, ref): ReactNode {\n const control = useG9Control(props, 'g9-expander');\n const glyphs = useG9Settings().glyphs;\n // A framed expander is a Surface card: fields inside notch their floated label with it.\n const palette = useG9Theme().palette;\n const [expanded, setExpanded] = useControllableState<boolean>({\n value: props.expanded,\n defaultValue: props.defaultExpanded ?? false,\n onChange: props.onExpandedChange,\n name: 'G9Expander.expanded',\n });\n const [phase, setPhase] = useState<Phase>(expanded ? 'open' : 'closed');\n const [measured, setMeasured] = useState(0);\n const timer = useRef<G9TimerHandle | null>(null);\n const first = useRef(true);\n useEffect(() => {\n if (first.current) {\n first.current = false;\n return;\n }\n if (timer.current !== null) stopTimer(timer.current);\n if (measured <= 0) {\n setPhase(expanded ? 'open' : 'closed');\n return;\n }\n setPhase(expanded ? 'opening' : 'closing');\n timer.current = startTimer(() => {\n timer.current = null;\n setPhase(expanded ? 'open' : 'closed');\n }, g9Ms(g9ExpanderDurationMs));\n }, [expanded]);\n useEffect(\n () => () => {\n if (timer.current !== null) stopTimer(timer.current);\n },\n [],\n );\n\n const toggle = () => {\n if (!control.disabled) setExpanded((v) => !v);\n };\n useImperativeHandle(ref, () => ({ toggle }));\n const press = useG9Press(toggle, { blocked: control.disabled, source: 'G9Expander', guardMs: 0 });\n const visual = usePressVisual({ property: 'scale', rest: 1, pressed: 0.99, inMs: 60, outMs: 90 }, control.disabled);\n const icon = { emoji: props.iconEmoji, icon: props.icon, imagePath: props.iconPath, image: props.iconImage };\n const [pl, pt, pr, pb] = props.contentPadding ?? [0, 0, 0, 0];\n const height = phase === 'open' ? undefined : phase === 'opening' ? `${measured}px` : '0px';\n return (\n <view\n className={`${control.className}${props.showFrame ? ' g9-expander--frame' : ''}`}\n {...control.idProps}\n style={props.showFrame ? g9FieldNotchStyle(palette.Surface) : {}}\n >\n <view\n className=\"g9-expander__header\"\n {...g9IdProps(g9ChildId(props.id, 'Header'))}\n style={{ minHeight: `${props.headerHeight ?? 48}px`, ...g9RowStyle(control.direction) }}\n accessibility-element={true}\n accessibility-traits=\"button\"\n {...(props.title ? { 'accessibility-label': props.title } : {})}\n bindtap={press}\n {...visual}\n >\n <view className=\"g9-expander__lead\" style={g9RowStyle(control.direction)}>\n {hasIconSlot(icon) ? (\n <G9IconSlot {...icon} size={20} color={props.iconColor ?? 'var(--g9-text-primary)'} />\n ) : null}\n {props.title ? (\n <text\n className=\"g9-expander__title\"\n text-maxline=\"1\"\n style={{ color: props.titleColor ?? 'var(--g9-text-primary)' }}\n >\n {props.title}\n </text>\n ) : null}\n </view>\n <view className={`g9-expander__chevron${expanded ? ' g9-expander__chevron--open' : ''}`}>\n <G9IconSlot icon={glyphs.chevron} size={22} color={props.chevronColor ?? 'var(--g9-text-secondary)'} />\n </view>\n </view>\n <view className={`g9-expander__clip g9-expander__clip--${phase}`} style={height === undefined ? {} : { height }}>\n <view\n className=\"g9-expander__content\"\n style={{ padding: `${pt + 8}px ${pr}px ${pb}px ${pl}px` }}\n bindlayoutchange={(e: { detail?: { height?: number } }) => {\n const h = e.detail?.height ?? 0;\n if (h > 0 && h !== measured) setMeasured(h);\n }}\n >\n {props.children}\n </view>\n </view>\n </view>\n );\n});\n"],"names":["g9ExpanderDurationMs","G9Expander","forwardRef","props","ref","_props_defaultExpanded","_props_contentPadding","_props_headerHeight","_props_iconColor","_props_titleColor","_props_chevronColor","control","useG9Control","glyphs","useG9Settings","palette","useG9Theme","expanded","setExpanded","useControllableState","phase","setPhase","useState","measured","setMeasured","timer","useRef","first","useEffect","stopTimer","startTimer","g9Ms","toggle","v","useImperativeHandle","press","useG9Press","visual","usePressVisual","icon","pl","pt","pr","pb","height","undefined","view","g9FieldNotchStyle","g9IdProps","g9ChildId","g9RowStyle","hasIconSlot","G9IconSlot","text","e","_e_detail","h"],"mappings":";;;;;;;;;;AAcO,MAAMA,uBAAuB;AA2C7B,MAAMC,sBAAaC,WAA8C,SAAoBC,KAAK,EAAEC,GAAG;QAOpFC,wBAsCSC,uBAWIC,qBASoBC,kBAMrBC,m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qBACV,aAAa,IACb,OAAO;QAAE,OAAO,QAAA5C,CAAAA,oBAAAA,MAAM,UAAU,AAAD,IAAfA,oBAAoB;IAAyB,GAC9D;cACC,CAACN,MAAM,KAAK,CAAC;YACf,EAAEkD,QACA,KAAK;QACX,EAAEP,KAAK;QACP,CAACA,KAAK,WAAW,CAAC,oBAAoB,EAAE7B,WAAW,gCAAgC,IAAI,EAAE;UACvF,CAACmC,WAAW,MAAMvC,OAAO,OAAO,EAAE,MAAM,IAAI,OAAO,QAAAH,CAAAA,sBAAAA,MAAM,YAAY,AAAD,IAAjBA,sBAAsB,6BAA8B;QACzG,EAAEoC,KAAK;MACT,EAAEA,KAAK;MACP,CAACA,KAAK,WAAW,CAAC,qCAAqC,EAAE1B,OAAO,EAAE,OAAOwB,AAAWC,WAAXD,SAAuB,CAAC,IAAI;QAAEA;IAAO,GAAG;QAC/G,CAACE,KACC,UAAU,uBACV,OAAO;QAAE,SAAS,GAAGL,KAAK,EAAE,GAAG,EAAEC,GAAG,GAAG,EAAEC,GAAG,GAAG,EAAEH,GAAG,EAAE,CAAC;IAAC,GACxD,kBAAkB,CAACc;;YACPC;QAAV,MAAMC,IAAI,QAAJA,CAAAA,OAAAA,QAAID,CAAAA,YAAAA,EAAE,MAAM,AAAD,IAAPA,KAAAA,IAAAA,UAAU,MAAM,AAAD,IAAC,OAAI;QAC9B,IAAIC,IAAI,KAAKA,MAAMjC,UAAUC,YAAYgC;IAC3C,GACD;UACC,CAACrD,MAAM,QAAQ,CAAC;QAClB,EAAE2C,KAAK;MACT,EAAEA,KAAK;IACT,EAAEA;AAEN"}
|
|
1
|
+
{"version":3,"file":"expander/expander.jsx","sources":["../../src/expander/expander.tsx"],"sourcesContent":["import './expander.css';\nimport type { G9ImageSource } from '@g9tm/lynxcontrols-foundation';\nimport { g9Ms } from '@g9tm/lynxcontrols-foundation';\nimport { forwardRef, type ReactNode, useEffect, useImperativeHandle, useRef, useState } from '@lynx-js/react';\nimport { type G9ControlBaseProps, g9ChildId, g9IdProps, g9RowStyle, useG9Control } from '../base/control';\nimport { useG9Press, usePressVisual } from '../base/press';\nimport { type G9TimerHandle, startTimer, stopTimer } from '../base/timers';\nimport { useControllableState } from '../base/use-controllable-state';\nimport { g9FieldNotchStyle } from '../fields/notch';\nimport type { G9IconInput } from '../icon/icon';\nimport { G9IconSlot, hasIconSlot } from '../icon/slot';\nimport { useG9Settings, useG9Theme } from '../provider/hooks';\n\n/** Expand/collapse duration (MAUI `G9Metrics` expander 220 ms). */\nexport const g9ExpanderDurationMs = 220;\n\n/** Props of {@link G9Expander} (MAUI `G9Expander`). */\nexport interface G9ExpanderProps extends G9ControlBaseProps {\n readonly title?: string | null;\n /** Default `var(--g9-text-primary)`. */\n readonly titleColor?: string | null;\n readonly iconEmoji?: string | null;\n readonly icon?: G9IconInput;\n readonly iconPath?: string | null;\n readonly iconImage?: G9ImageSource | null;\n /** Default `var(--g9-text-primary)`. */\n readonly iconColor?: string | null;\n /** Default `var(--g9-text-secondary)`. */\n readonly chevronColor?: string | null;\n /** Controlled open state (MAUI `IsExpanded`). */\n readonly expanded?: boolean;\n readonly defaultExpanded?: boolean;\n /** Once per change made by the expander (header tap, `toggle()`); never for pushed values. */\n readonly onExpandedChange?: (expanded: boolean) => void;\n /** Card look: surface, 1 px outline, 16 px corners, 14 × 12 padding. Default false. */\n readonly showFrame?: boolean;\n /** Minimum header height. Default 48. */\n readonly headerHeight?: number;\n /** Content padding `[left, top, right, bottom]` (an 8 px top gap is always added). Default 0. */\n readonly contentPadding?: readonly [number, number, number, number];\n /** The content (MAUI `ExpanderContent`): mounted at once and kept, hidden while collapsed. */\n readonly children?: ReactNode;\n}\n\n/** Imperative handle of {@link G9Expander}. */\nexport interface G9ExpanderHandle {\n /** Same as a header tap (MAUI `Toggle`). */\n toggle(): void;\n}\n\ntype Phase = 'open' | 'opening' | 'closing' | 'closed';\n\n/**\n * Collapsible section (MAUI `G9Expander`): only the header toggles; the chevron turns 180° and the content height\n * animates over 220 ms (CSS transition on the measured height; instant when it cannot be measured). The first render\n * does not animate. The content stays mounted.\n */\nexport const G9Expander = forwardRef<G9ExpanderHandle, G9ExpanderProps>(function G9Expander(props, ref): ReactNode {\n const control = useG9Control(props, 'g9-expander', {\n kind: 'view',\n label: () => props.accessibilityLabel ?? props.title,\n capabilities: {\n activate: () => press(),\n getValue: () => String(expanded),\n expand: (open) => {\n if (open !== expanded) press();\n },\n },\n });\n const glyphs = useG9Settings().glyphs;\n // A framed expander is a Surface card: fields inside notch their floated label with it.\n const palette = useG9Theme().palette;\n const [expanded, setExpanded] = useControllableState<boolean>({\n value: props.expanded,\n defaultValue: props.defaultExpanded ?? false,\n onChange: props.onExpandedChange,\n name: 'G9Expander.expanded',\n });\n const [phase, setPhase] = useState<Phase>(expanded ? 'open' : 'closed');\n const [measured, setMeasured] = useState(0);\n const timer = useRef<G9TimerHandle | null>(null);\n const first = useRef(true);\n useEffect(() => {\n if (first.current) {\n first.current = false;\n return;\n }\n if (timer.current !== null) stopTimer(timer.current);\n if (measured <= 0) {\n setPhase(expanded ? 'open' : 'closed');\n return;\n }\n setPhase(expanded ? 'opening' : 'closing');\n timer.current = startTimer(() => {\n timer.current = null;\n setPhase(expanded ? 'open' : 'closed');\n }, g9Ms(g9ExpanderDurationMs));\n }, [expanded]);\n useEffect(\n () => () => {\n if (timer.current !== null) stopTimer(timer.current);\n },\n [],\n );\n\n const toggle = () => {\n if (!control.disabled) setExpanded((v) => !v);\n };\n useImperativeHandle(ref, () => ({ toggle }));\n const press = useG9Press(toggle, { blocked: control.disabled, source: 'G9Expander', guardMs: 0 });\n const visual = usePressVisual({ property: 'scale', rest: 1, pressed: 0.99, inMs: 60, outMs: 90 }, control.disabled);\n const icon = { emoji: props.iconEmoji, icon: props.icon, imagePath: props.iconPath, image: props.iconImage };\n const [pl, pt, pr, pb] = props.contentPadding ?? [0, 0, 0, 0];\n const height = phase === 'open' ? undefined : phase === 'opening' ? `${measured}px` : '0px';\n return (\n <view\n className={`${control.className}${props.showFrame ? ' g9-expander--frame' : ''}`}\n {...control.idProps}\n style={props.showFrame ? g9FieldNotchStyle(palette.Surface) : {}}\n >\n <view\n className=\"g9-expander__header\"\n {...g9IdProps(g9ChildId(props.id, 'Header'))}\n style={{ minHeight: `${props.headerHeight ?? 48}px`, ...g9RowStyle(control.direction) }}\n accessibility-element={true}\n accessibility-traits=\"button\"\n {...(props.title ? { 'accessibility-label': props.title } : {})}\n bindtap={press}\n {...visual}\n >\n <view className=\"g9-expander__lead\" style={g9RowStyle(control.direction)}>\n {hasIconSlot(icon) ? (\n <G9IconSlot {...icon} size={20} color={props.iconColor ?? 'var(--g9-text-primary)'} />\n ) : null}\n {props.title ? (\n <text\n className=\"g9-expander__title\"\n text-maxline=\"1\"\n style={{ color: props.titleColor ?? 'var(--g9-text-primary)' }}\n >\n {props.title}\n </text>\n ) : null}\n </view>\n <view className={`g9-expander__chevron${expanded ? ' g9-expander__chevron--open' : ''}`}>\n <G9IconSlot icon={glyphs.chevron} size={22} color={props.chevronColor ?? 'var(--g9-text-secondary)'} />\n </view>\n </view>\n <view className={`g9-expander__clip g9-expander__clip--${phase}`} style={height === undefined ? {} : { height }}>\n <view\n className=\"g9-expander__content\"\n style={{ padding: `${pt + 8}px ${pr}px ${pb}px ${pl}px` }}\n bindlayoutchange={(e: { detail?: { height?: number } }) => {\n const h = e.detail?.height ?? 0;\n if (h > 0 && h !== measured) setMeasured(h);\n }}\n >\n {props.children}\n </view>\n </view>\n </view>\n );\n});\n"],"names":["g9ExpanderDurationMs","G9Expander","forwardRef","props","ref","_props_defaultExpanded","_props_contentPadding","_props_headerHeight","_props_iconColor","_props_titleColor","_props_chevronColor","control","useG9Control","_props_accessibilityLabel","press","String","expanded","open","glyphs","useG9Settings","palette","useG9Theme","setExpanded","useControllableState","phase","setPhase","useState","measured","setMeasured","timer","useRef","first","useEffect","stopTimer","startTimer","g9Ms","toggle","v","useImperativeHandle","useG9Press","visual","usePressVisual","icon","pl","pt","pr","pb","height","undef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AE,MAAM,AAAD,IAAPA,KAAAA,IAAAA,UAAU,MAAM,AAAD,IAAC,OAAI;QAC9B,IAAIC,IAAI,KAAKA,MAAMhC,UAAUC,YAAY+B;IAC3C,GACD;UACC,CAACxD,MAAM,QAAQ,CAAC;QAClB,EAAE8C,KAAK;MACT,EAAEA,KAAK;IACT,EAAEA;AAEN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../src/fields/editor.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAgB,MAAM,kBAAkB,CAAC;AAE/F,0DAA0D;AAC1D,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,aAAa,CAAC;AAE1D,mDAAmD;AACnD,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,mDAAmD;IACnD,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC,mEAAmE;IACnE,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,+FAA+F;IAC/F,QAAQ,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IACrC,4DAA4D;IAC5D,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IACvC,4EAA4E;IAC5E,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CAC5C;AAED,6CAA6C;AAC7C,MAAM,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../src/fields/editor.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAgB,MAAM,kBAAkB,CAAC;AAE/F,0DAA0D;AAC1D,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,aAAa,CAAC;AAE1D,mDAAmD;AACnD,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,mDAAmD;IACnD,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC,mEAAmE;IACnE,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,+FAA+F;IAC/F,QAAQ,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IACrC,4DAA4D;IAC5D,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IACvC,4EAA4E;IAC5E,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CAC5C;AAED,6CAA6C;AAC7C,MAAM,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,6GA2DnB,CAAC"}
|
package/dist/fields/editor.jsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { G9Metrics } from "@g9tm/lynxcontrols-foundation";
|
|
2
2
|
import { forwardRef, useImperativeHandle } from "@lynx-js/react";
|
|
3
3
|
import { useG9Settings } from "../provider/hooks.jsx";
|
|
4
|
-
import { G9OutlinedField } from "./outlined-field.jsx";
|
|
4
|
+
import { G9OutlinedField, resolveInnerHint } from "./outlined-field.jsx";
|
|
5
5
|
import { useTextInput } from "./use-text-input.jsx";
|
|
6
6
|
const editor_G9Editor = forwardRef(function(props, ref) {
|
|
7
7
|
var _props_minimumEditorHeight, _props_maxEditorHeight, _props_autoSize, _core_errorText;
|
|
@@ -20,7 +20,23 @@ const editor_G9Editor = forwardRef(function(props, ref) {
|
|
|
20
20
|
const min = null != (_props_minimumEditorHeight = props.minimumEditorHeight) ? _props_minimumEditorHeight : 96;
|
|
21
21
|
const max = null != (_props_maxEditorHeight = props.maxEditorHeight) ? _props_maxEditorHeight : 0;
|
|
22
22
|
const autoSize = null != (_props_autoSize = props.autoSize) ? _props_autoSize : 'textChanges';
|
|
23
|
-
return <G9OutlinedField
|
|
23
|
+
return <G9OutlinedField anchor={{
|
|
24
|
+
kind: 'entry',
|
|
25
|
+
label: ()=>{
|
|
26
|
+
var _props_label;
|
|
27
|
+
return null != (_props_label = props.label) ? _props_label : props.placeholder;
|
|
28
|
+
},
|
|
29
|
+
enabled: ()=>!props.disabled,
|
|
30
|
+
capabilities: {
|
|
31
|
+
getValue: ()=>core.text,
|
|
32
|
+
setValue: (v)=>{
|
|
33
|
+
core.setText(v, {
|
|
34
|
+
source: 'programmatic'
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
focus: ()=>core.focus()
|
|
38
|
+
}
|
|
39
|
+
}} {...props} hint={resolveInnerHint(props)} multiline hasError={core.hasError} errorText={null != (_core_errorText = core.errorText) ? _core_errorText : null} focused={core.focused} hasValue={core.hasValue} textLength={core.text.length} trailingAffordance={affordance} onFocusRequest={core.focus}>
|
|
24
40
|
<textarea {...core.elementProps} className="g9-field__textarea" ios-spell-check={false !== props.isSpellCheckEnabled} ios-auto-correct={false !== props.isTextPredictionEnabled} style={{
|
|
25
41
|
direction: core.textDirection,
|
|
26
42
|
textAlign: 'rtl' === core.textDirection ? 'right' : 'left',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields/editor.jsx","sources":["../../src/fields/editor.tsx"],"sourcesContent":["import { G9Metrics } from '@g9tm/lynxcontrols-foundation';\nimport { forwardRef, type ReactNode, useImperativeHandle } from '@lynx-js/react';\nimport { useG9Settings } from '../provider/hooks';\nimport { G9OutlinedField, type G9TrailingAffordance } from './outlined-field';\nimport { type G9TextInputHandle, type G9TextInputProps, useTextInput } from './use-text-input';\n\n/** How the editor grows (MAUI `EditorAutoSizeOption`). */\nexport type G9EditorAutoSize = 'disabled' | 'textChanges';\n\n/** Props of {@link G9Editor} (MAUI `G9Editor`). */\nexport interface G9EditorProps extends G9TextInputProps {\n /** Minimum height of the text area. Default 96. */\n readonly minimumEditorHeight?: number;\n /** Maximum height while growing; `0` (default) means unbounded. */\n readonly maxEditorHeight?: number;\n /** `'textChanges'` (default) grows with the text; `'disabled'` keeps `minimumEditorHeight`. */\n readonly autoSize?: G9EditorAutoSize;\n /** Spell checking (iOS `ios-spell-check`). Default true. */\n readonly isSpellCheckEnabled?: boolean;\n /** Word prediction / autocorrect (iOS `ios-auto-correct`). Default true. */\n readonly isTextPredictionEnabled?: boolean;\n}\n\n/** Imperative handle of {@link G9Editor}. */\nexport type G9EditorHandle = G9TextInputHandle;\n\n/**\n * Multi-line outlined text area (MAUI `G9Editor`): the text-entry behaviour on a `<textarea>`, a microphone pinned to\n * the bottom-end corner whenever dictation is available, height from `minimumEditorHeight`/`maxEditorHeight`/\n * `autoSize`. Validates on blur only for email/url/custom types (no `validator`, as in MAUI). Requires the host's\n * `xelement-input` registration.\n */\nexport const G9Editor = forwardRef<G9EditorHandle, G9EditorProps>(function G9Editor(props, ref): ReactNode {\n const glyphs = useG9Settings().glyphs;\n const core = useTextInput(props, { name: 'G9Editor.value', showMic: (s) => s.available });\n useImperativeHandle(ref, () => core.handle);\n const affordance: G9TrailingAffordance | null = core.showMic\n ? {\n icon: core.dictation.listening ? glyphs.micOff : glyphs.mic,\n color: core.dictation.listening ? 'var(--g9-error)' : 'var(--g9-primary)',\n signature: 'voice',\n onPress: core.pressMic,\n }\n : null;\n const min = props.minimumEditorHeight ?? 96;\n const max = props.maxEditorHeight ?? 0;\n const autoSize = props.autoSize ?? 'textChanges';\n return (\n <G9OutlinedField\n {...props}\n multiline\n hasError={core.hasError}\n errorText={core.errorText ?? null}\n focused={core.focused}\n hasValue={core.hasValue}\n textLength={core.text.length}\n trailingAffordance={affordance}\n onFocusRequest={core.focus}\n >\n <textarea\n {...core.elementProps}\n className=\"g9-field__textarea\"\n ios-spell-check={props.isSpellCheckEnabled !== false}\n ios-auto-correct={props.isTextPredictionEnabled !== false}\n style={{\n direction: core.textDirection,\n textAlign: core.textDirection === 'rtl' ? 'right' : 'left',\n ...(core.font ? { fontFamily: core.font } : {}),\n color: props.disabled ? 'var(--g9-text-disabled)' : 'var(--g9-text-primary)',\n ...(autoSize === 'disabled'\n ? { height: `${min}px` }\n : { minHeight: `${min}px`, ...(max > 0 ? { maxHeight: `${Math.max(min, max)}px` } : {}) }),\n paddingTop: `${G9Metrics.FloatingLabelClearance + 8}px`,\n paddingBottom: '8px',\n }}\n />\n </G9OutlinedField>\n );\n});\n"],"names":["G9Editor","forwardRef","props","ref","_props_minimumEditorHeight","_props_maxEditorHeight","_props_autoSize","_core_errorText","glyphs","useG9Settings","core","useTextInput","s","useImperativeHandle","affordance","min","max","autoSize","G9OutlinedField","textarea","Math","G9Metrics"],"mappings":";;;;;AAgCO,MAAMA,kBAAWC,WAA0C,SAAkBC,KAAK,EAAEC,GAAG;QAYhFC,4BACAC,wBACKC,
|
|
1
|
+
{"version":3,"file":"fields/editor.jsx","sources":["../../src/fields/editor.tsx"],"sourcesContent":["import { G9Metrics } from '@g9tm/lynxcontrols-foundation';\nimport { forwardRef, type ReactNode, useImperativeHandle } from '@lynx-js/react';\nimport { useG9Settings } from '../provider/hooks';\nimport { G9OutlinedField, type G9TrailingAffordance, resolveInnerHint } from './outlined-field';\nimport { type G9TextInputHandle, type G9TextInputProps, useTextInput } from './use-text-input';\n\n/** How the editor grows (MAUI `EditorAutoSizeOption`). */\nexport type G9EditorAutoSize = 'disabled' | 'textChanges';\n\n/** Props of {@link G9Editor} (MAUI `G9Editor`). */\nexport interface G9EditorProps extends G9TextInputProps {\n /** Minimum height of the text area. Default 96. */\n readonly minimumEditorHeight?: number;\n /** Maximum height while growing; `0` (default) means unbounded. */\n readonly maxEditorHeight?: number;\n /** `'textChanges'` (default) grows with the text; `'disabled'` keeps `minimumEditorHeight`. */\n readonly autoSize?: G9EditorAutoSize;\n /** Spell checking (iOS `ios-spell-check`). Default true. */\n readonly isSpellCheckEnabled?: boolean;\n /** Word prediction / autocorrect (iOS `ios-auto-correct`). Default true. */\n readonly isTextPredictionEnabled?: boolean;\n}\n\n/** Imperative handle of {@link G9Editor}. */\nexport type G9EditorHandle = G9TextInputHandle;\n\n/**\n * Multi-line outlined text area (MAUI `G9Editor`): the text-entry behaviour on a `<textarea>`, a microphone pinned to\n * the bottom-end corner whenever dictation is available, height from `minimumEditorHeight`/`maxEditorHeight`/\n * `autoSize`. Validates on blur only for email/url/custom types (no `validator`, as in MAUI). Requires the host's\n * `xelement-input` registration.\n */\nexport const G9Editor = forwardRef<G9EditorHandle, G9EditorProps>(function G9Editor(props, ref): ReactNode {\n const glyphs = useG9Settings().glyphs;\n const core = useTextInput(props, { name: 'G9Editor.value', showMic: (s) => s.available });\n useImperativeHandle(ref, () => core.handle);\n const affordance: G9TrailingAffordance | null = core.showMic\n ? {\n icon: core.dictation.listening ? glyphs.micOff : glyphs.mic,\n color: core.dictation.listening ? 'var(--g9-error)' : 'var(--g9-primary)',\n signature: 'voice',\n onPress: core.pressMic,\n }\n : null;\n const min = props.minimumEditorHeight ?? 96;\n const max = props.maxEditorHeight ?? 0;\n const autoSize = props.autoSize ?? 'textChanges';\n return (\n <G9OutlinedField\n anchor={{\n kind: 'entry',\n label: () => props.label ?? props.placeholder,\n enabled: () => !props.disabled,\n capabilities: {\n getValue: () => core.text,\n setValue: (v: string) => {\n core.setText(v, { source: 'programmatic' });\n },\n focus: () => core.focus(),\n },\n }}\n {...props}\n hint={resolveInnerHint(props)}\n multiline\n hasError={core.hasError}\n errorText={core.errorText ?? null}\n focused={core.focused}\n hasValue={core.hasValue}\n textLength={core.text.length}\n trailingAffordance={affordance}\n onFocusRequest={core.focus}\n >\n <textarea\n {...core.elementProps}\n className=\"g9-field__textarea\"\n ios-spell-check={props.isSpellCheckEnabled !== false}\n ios-auto-correct={props.isTextPredictionEnabled !== false}\n style={{\n direction: core.textDirection,\n textAlign: core.textDirection === 'rtl' ? 'right' : 'left',\n ...(core.font ? { fontFamily: core.font } : {}),\n color: props.disabled ? 'var(--g9-text-disabled)' : 'var(--g9-text-primary)',\n ...(autoSize === 'disabled'\n ? { height: `${min}px` }\n : { minHeight: `${min}px`, ...(max > 0 ? { maxHeight: `${Math.max(min, max)}px` } : {}) }),\n paddingTop: `${G9Metrics.FloatingLabelClearance + 8}px`,\n paddingBottom: '8px',\n }}\n />\n </G9OutlinedField>\n );\n});\n"],"names":["G9Editor","forwardRef","props","ref","_props_minimumEditorHeight","_props_maxEditorHeight","_props_autoSize","_core_errorText","glyphs","useG9Settings","core","useTextInput","s","useImperativeHandle","affordance","min","max","autoSize","G9OutlinedField","_props_label","v","resolveInnerHint","textarea","Math","G9Metrics"],"mappings":";;;;;AAgCO,MAAMA,kBAAWC,WAA0C,SAAkBC,KAAK,EAAEC,GAAG;QAYhFC,4BACAC,wBACKC,iBAmBFC;IAhCf,MAAMC,SAASC,gBAAgB,MAAM;IACrC,MAAMC,OAAOC,aAAaT,OAAO;QAAE,MAAM;QAAkB,SAAS,CAACU,IAAMA,EAAE,SAAS;IAAC;IACvFC,oBAAoBV,KAAK,IAAMO,KAAK,MAAM;IAC1C,MAAMI,aAA0CJ,KAAK,OAAO,GACxD;QACE,MAAMA,KAAK,SAAS,CAAC,SAAS,GAAGF,OAAO,MAAM,GAAGA,OAAO,GAAG;QAC3D,OAAOE,KAAK,SAAS,CAAC,SAAS,GAAG,oBAAoB;QACtD,WAAW;QACX,SAASA,KAAK,QAAQ;IACxB,IACA;IACJ,MAAMK,MAAM,QAAAX,CAAAA,6BAAAA,MAAM,mBAAmB,AAAD,IAAxBA,6BAA6B;IACzC,MAAMY,MAAM,QAAAX,CAAAA,yBAAAA,MAAM,eAAe,AAAD,IAApBA,yBAAyB;IACrC,MAAMY,WAAW,QAAAX,CAAAA,kBAAAA,MAAM,QAAQ,AAAD,IAAbA,kBAAkB;IACnC,QACGY,gBACC,QAAQ;QACN,MAAM;QACN,OAAO;gBAAMC;2BAAAA,CAAAA,eAAAA,MAAM,KAAK,AAAD,IAAVA,eAAejB,MAAM,WAAW;;QAC7C,SAAS,IAAM,CAACA,MAAM,QAAQ;QAC9B,cAAc;YACZ,UAAU,IAAMQ,KAAK,IAAI;YACzB,UA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pointer-events: none;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
display: flex;
|
|
48
|
+
position: absolute;
|
|
49
|
+
top: 0;
|
|
50
|
+
bottom: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.g9-field__hint--multiline {
|
|
54
|
+
justify-content: flex-start;
|
|
55
|
+
bottom: auto;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.g9-field__hint-text {
|
|
59
|
+
text-overflow: ellipsis;
|
|
60
|
+
width: 100%;
|
|
61
|
+
font-size: 15px;
|
|
62
|
+
}
|
|
63
|
+
|
|
43
64
|
.g9-field__textarea {
|
|
44
65
|
background-color: #0000;
|
|
45
66
|
width: 100%;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://./src/fields/fields.css"],"names":[],"mappings":"AACA;EAAE,sBAAsB;EACtB,WAAW;EACX,aAAa;AACf;;AAGA;EAAE,uBAAuB;EACvB,sBAAsB;EACtB,aAAa;EACb,kBAAkB;AACpB;;AAGA;EAAE,oBAAoB;EACpB,mBAAmB;EACnB,kBAAkB;EAClB,MAAM;EACN,SAAS;EACT,OAAO;EACP,QAAQ;AACV;;AAaA;EAVE,sBAAsB;EACtB,OAAO;EACP,uBAAuB;EACvB,aAAa;AACf;;AAaA;EAVE,uBAAuB;EACvB,WAAW;EACX,YAAY;EACZ,eAAe;AACjB;;AAcA;EAXE,uBAAuB;EACvB,YAAY;AACd;;
|
|
1
|
+
{"version":3,"sources":["webpack://./src/fields/fields.css"],"names":[],"mappings":"AACA;EAAE,sBAAsB;EACtB,WAAW;EACX,aAAa;AACf;;AAGA;EAAE,uBAAuB;EACvB,sBAAsB;EACtB,aAAa;EACb,kBAAkB;AACpB;;AAGA;EAAE,oBAAoB;EACpB,mBAAmB;EACnB,kBAAkB;EAClB,MAAM;EACN,SAAS;EACT,OAAO;EACP,QAAQ;AACV;;AAaA;EAVE,sBAAsB;EACtB,OAAO;EACP,u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ACxC;;AAyBA;EAtBE,iBAAiB;EACjB,+BAA+B;AACjC;;AAyBA;EAtBE,6BAA6B;EAC7B,eAAe;AACjB;;AAyBA;EAtBE,8BAA8B;AAChC;;AAyBA;EAtBE,8BAA8B;EAC9B,eAAe;AACjB;;AAyBA;EAtBE,mCAAmC;EACnC,iBAAiB;EACjB,eAAe;AACjB","sourcesContent":["/* Outlined fields (MAUI G9OutlinedFieldBase). Colours come from the theme variables; sizes from G9Metrics. */\n.g9-field {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n\n.g9-field__box {\n display: flex;\n flex-direction: column;\n position: relative;\n background-color: transparent;\n}\n\n.g9-field__outline {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n border-style: solid;\n pointer-events: none;\n}\n\n.g9-field__halo {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n border-style: solid;\n pointer-events: none;\n}\n\n.g9-field__content {\n display: flex;\n flex-direction: column;\n justify-content: center;\n flex: 1;\n}\n\n.g9-field__input {\n width: 100%;\n height: 100%;\n font-size: 15px;\n background-color: transparent;\n}\n\n/* The read-only value: a text line centred like the input's. */\n.g9-field__input--readonly {\n height: auto;\n text-overflow: ellipsis;\n}\n\n/* MAUI 1.4.9 RestingPlaceholder: the hint inside an empty box (under an always-floated label, or placeholderInside),\n over the input where its text starts — the input's 15 px in TextTertiary; it never takes a touch. */\n.g9-field__hint {\n position: absolute;\n top: 0px;\n bottom: 0px;\n display: flex;\n flex-direction: column;\n justify-content: center;\n pointer-events: none;\n}\n\n.g9-field__hint--multiline {\n bottom: auto;\n justify-content: flex-start;\n}\n\n.g9-field__hint-text {\n width: 100%;\n font-size: 15px;\n text-overflow: ellipsis;\n}\n\n.g9-field__textarea {\n width: 100%;\n font-size: 15px;\n background-color: transparent;\n}\n\n.g9-field__slot {\n display: flex;\n position: absolute;\n align-items: center;\n justify-content: center;\n}\n\n.g9-field__label {\n position: absolute;\n height: 22px;\n line-height: 22px;\n padding-left: 4px;\n padding-right: 4px;\n background-color: transparent;\n transition-property: top, font-size, transform, color;\n transition-duration: 160ms;\n pointer-events: none;\n}\n\n/* Only a floated label sits on the outline: its notch paints the colour behind the field (a container that is not\n --g9-background sets --g9-field-notch-background; G9 sheets and popups do). At rest it paints nothing. */\n.g9-field__label--floated {\n background-color: var(--g9-field-notch-background, var(--g9-background));\n}\n\n.g9-field__footer {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n padding-top: 4px;\n padding-left: 14px;\n padding-right: 14px;\n}\n\n.g9-field__helper {\n flex: 1;\n font-size: 11.5px;\n}\n\n.g9-field__counter {\n font-size: 11px;\n color: var(--g9-text-tertiary);\n}\n\n.g9-field__busy {\n width: 18px;\n height: 18px;\n border-width: 2px;\n border-style: solid;\n border-radius: 9px;\n animation: g9-field-spin 800ms linear infinite;\n}\n\n@keyframes g9-field-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n\n/* Disabled dims the field (MAUI DisabledDimAlpha) part by part: an opacity on the box itself renders it into a layer\n the size of the box on Android, which cut the floated label above it in half. The label takes the disabled colour\n instead, so its notch still hides the outline. */\n.g9-field--disabled .g9-field__outline,\n.g9-field--disabled .g9-field__halo,\n.g9-field--disabled .g9-field__content,\n.g9-field--disabled .g9-field__slot,\n.g9-field--disabled .g9-field__footer {\n opacity: 0.45;\n}\n\n/* PIN entry (MAUI G9PinEntry): the row is always left-to-right. */\n.g9-pin {\n display: flex;\n flex-direction: row;\n align-items: center;\n position: relative;\n direction: ltr;\n}\n\n.g9-pin__cell {\n display: flex;\n align-items: center;\n justify-content: center;\n margin-right: 8px;\n border-style: solid;\n border-width: 1.4px;\n border-radius: 10px;\n border-color: var(--g9-outline-variant);\n background-color: var(--g9-surface);\n}\n\n.g9-pin__cell--filled {\n border-color: var(--g9-primary-border);\n}\n\n.g9-pin__cell--active {\n border-width: 2px;\n border-color: var(--g9-primary);\n}\n\n.g9-pin__char {\n font-size: 22px;\n color: var(--g9-text-primary);\n}\n\n.g9-pin--disabled .g9-pin__char {\n color: var(--g9-text-disabled);\n}\n\n.g9-pin__placeholder {\n font-size: 22px;\n color: var(--g9-text-tertiary);\n}\n\n.g9-pin__separator {\n font-size: 22px;\n margin-right: 6px;\n color: var(--g9-on-surface-variant);\n}\n"],"sourceRoot":""}
|
package/dist/fields/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { G9VoiceDictation, type G9VoiceDictationOptions, } from './dictation.js'
|
|
|
2
2
|
export { G9Editor, type G9EditorAutoSize, type G9EditorHandle, type G9EditorProps } from './editor.js';
|
|
3
3
|
export { customPatternCacheSize, decimalSeparatorFor, type G9LynxInputElementType, g9CustomPatternCacheLimit, inputTypeHasValidationRule, inputTypePrefersLeftToRight, isAbsoluteUri, resolveEffectiveKeyboard, resolveInputElementType, resolveKeyboardForInputType, sanitizeInputText, validateInputText, } from './input-policy.js';
|
|
4
4
|
export { g9FieldNotchBackgroundVariable, g9FieldNotchStyle } from './notch.js';
|
|
5
|
-
export { G9OutlinedField, type G9OutlinedFieldFrameProps, type G9OutlinedFieldProps, type G9OutlinedFieldState, type G9OutlinedFieldStateInput, type G9TrailingAffordance, resolveOutlinedFieldState, useOutlinedField, } from './outlined-field.js';
|
|
5
|
+
export { G9OutlinedField, type G9OutlinedFieldFrameProps, type G9OutlinedFieldProps, type G9OutlinedFieldState, type G9OutlinedFieldStateInput, type G9TrailingAffordance, resolveInnerHint, resolveOutlinedFieldState, resolveRestingPlaceholder, useOutlinedField, } from './outlined-field.js';
|
|
6
6
|
export { filterPin, G9PinEntry, type G9PinEntryHandle, type G9PinEntryProps, isPinCharAllowed, parsePinGroupSizes, pinCellCount, } from './pin-entry.js';
|
|
7
7
|
export { type G9SearchContext, G9SearchEntry, type G9SearchEntryHandle, type G9SearchEntryProps, } from './search-entry.js';
|
|
8
8
|
export { type G9FieldSlotLayout, type G9FieldSlotLayoutInput, type G9PhysicalPadding, resolveFieldSlotLayout, } from './slot-layout.js';
|
|
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AAO,EACL,KAAK,eAAe,EACpB,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC9G,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,KAAK,eAAe,EACpB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC"}
|
package/dist/fields/index.jsx
CHANGED
|
@@ -2,7 +2,7 @@ export { G9VoiceDictation } from "./dictation.jsx";
|
|
|
2
2
|
export { G9Editor } from "./editor.jsx";
|
|
3
3
|
export { customPatternCacheSize, decimalSeparatorFor, g9CustomPatternCacheLimit, inputTypeHasValidationRule, inputTypePrefersLeftToRight, isAbsoluteUri, resolveEffectiveKeyboard, resolveInputElementType, resolveKeyboardForInputType, sanitizeInputText, validateInputText } from "./input-policy.jsx";
|
|
4
4
|
export { g9FieldNotchBackgroundVariable, g9FieldNotchStyle } from "./notch.jsx";
|
|
5
|
-
export { G9OutlinedField, resolveOutlinedFieldState, useOutlinedField } from "./outlined-field.jsx";
|
|
5
|
+
export { G9OutlinedField, resolveInnerHint, resolveOutlinedFieldState, resolveRestingPlaceholder, useOutlinedField } from "./outlined-field.jsx";
|
|
6
6
|
export { G9PinEntry, filterPin, isPinCharAllowed, parsePinGroupSizes, pinCellCount } from "./pin-entry.jsx";
|
|
7
7
|
export { G9SearchEntry } from "./search-entry.jsx";
|
|
8
8
|
export { resolveFieldSlotLayout } from "./slot-layout.jsx";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import './fields.css';
|
|
2
2
|
import { G9FilledValueHighlight, type G9ImageSource } from '@g9tm/lynxcontrols-foundation';
|
|
3
3
|
import { type ReactNode } from '@lynx-js/react';
|
|
4
|
+
import type { G9AnchorInfo } from '../anchor/registry.js';
|
|
4
5
|
import type { G9IconInput } from '../icon/icon.js';
|
|
5
6
|
import { type G9PhysicalPadding } from './slot-layout.js';
|
|
6
7
|
/** Props every outlined field shares (the public members of MAUI `G9OutlinedFieldBase`). */
|
|
@@ -10,6 +11,11 @@ export interface G9OutlinedFieldProps {
|
|
|
10
11
|
* it to `[A-Za-z0-9_-]`.
|
|
11
12
|
*/
|
|
12
13
|
readonly id?: string;
|
|
14
|
+
/**
|
|
15
|
+
* What the field is and can do as an anchor (`@g9tm/lynxcontrols/anchor`); the text inputs pass their value paths.
|
|
16
|
+
* Registered only with an `id`.
|
|
17
|
+
*/
|
|
18
|
+
readonly anchor?: G9AnchorInfo;
|
|
13
19
|
/** Floating label. Without it the placeholder is the label (MAUI `Label ?? Placeholder`). */
|
|
14
20
|
readonly label?: string | null;
|
|
15
21
|
/** Placeholder; shown as the label when `label` is not set. */
|
|
@@ -20,8 +26,18 @@ export interface G9OutlinedFieldProps {
|
|
|
20
26
|
readonly errorText?: string | null;
|
|
21
27
|
/** Error state: error outline, label and helper colour. Validation can also set it (`validate()`). Default false. */
|
|
22
28
|
readonly hasError?: boolean;
|
|
23
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Keep the label floated even when empty and unfocused. Default false. With a `label` AND a `placeholder` the
|
|
31
|
+
* placeholder is then drawn inside the empty box under the floated label (MAUI 1.4.9: «عنوان» floated with «عنوان کار
|
|
32
|
+
* را وارد کنید» inside).
|
|
33
|
+
*/
|
|
24
34
|
readonly alwaysFloat?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The `placeholder` is the box's own hint (MAUI 1.4.9 `PlaceholderInside`): inside while the field is empty, gone with
|
|
37
|
+
* a value, never lifted into the notch as a label — a chat composer's «یادداشت خود را بنویسید...». A `label`, if set,
|
|
38
|
+
* still floats as usual. Default false: without a label the placeholder is the floating label's text.
|
|
39
|
+
*/
|
|
40
|
+
readonly placeholderInside?: boolean;
|
|
25
41
|
/** Value visible and selectable but not editable (MAUI `IsReadOnly`). Default false. */
|
|
26
42
|
readonly readOnly?: boolean;
|
|
27
43
|
/** Not interactive and dimmed (MAUI `IsEnabled = false`). Default false. */
|
|
@@ -98,6 +114,17 @@ export interface G9OutlinedFieldState {
|
|
|
98
114
|
readonly haloWidth: number;
|
|
99
115
|
readonly fieldHeight: number;
|
|
100
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* The hint a field draws INSIDE its box while it is empty, or `null` (MAUI 1.4.9 `RestingPlaceholder`). Without a `label`
|
|
119
|
+
* (or with `placeholderInside`) it is the `placeholder`. With a label it is drawn only when `alwaysFloat` keeps the label
|
|
120
|
+
* up in the notch — otherwise the resting label sits where the hint would be — and never when it repeats the label.
|
|
121
|
+
*/
|
|
122
|
+
export declare function resolveRestingPlaceholder(props: Pick<G9OutlinedFieldProps, 'label' | 'placeholder' | 'alwaysFloat' | 'placeholderInside'>): string | null;
|
|
123
|
+
/**
|
|
124
|
+
* The hint a TEXT input draws itself (MAUI 1.4.9 `G9TextEntry` / `G9Editor`): only while the field owns it — a label is
|
|
125
|
+
* set, or `placeholderInside` — since without a label the floating label already is the placeholder.
|
|
126
|
+
*/
|
|
127
|
+
export declare function resolveInnerHint(props: Pick<G9OutlinedFieldProps, 'label' | 'placeholder' | 'alwaysFloat' | 'placeholderInside'>): string | null;
|
|
101
128
|
/**
|
|
102
129
|
* Resolves the field's state colours and footer (MAUI `ResolveStateColor`, `ResolveFloatingLabelColor`, the footer
|
|
103
130
|
* part of `Refresh`). Precedence: error > status colour > focus > accented filled value > resting.
|
|
@@ -135,6 +162,11 @@ export interface G9OutlinedFieldFrameProps extends G9OutlinedFieldProps {
|
|
|
135
162
|
readonly multiline?: boolean;
|
|
136
163
|
/** Accessibility label of the box (defaults to the label text). */
|
|
137
164
|
readonly accessibilityLabel?: string;
|
|
165
|
+
/**
|
|
166
|
+
* A hint the frame draws over the content while the field is empty (`resolveInnerHint`, MAUI 1.4.9): text inputs pass
|
|
167
|
+
* it; the pickers draw their own value text. TextTertiary, the input's 15 px, never taking a touch.
|
|
168
|
+
*/
|
|
169
|
+
readonly hint?: string | null;
|
|
138
170
|
}
|
|
139
171
|
/**
|
|
140
172
|
* The outlined field frame (MAUI `G9OutlinedFieldBase`): outline with a notched floating label, leading and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outlined-field.d.ts","sourceRoot":"","sources":["../../src/fields/outlined-field.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,KAAK,aAAa,EAAa,MAAM,+BAA+B,CAAC;AACtG,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"outlined-field.d.ts","sourceRoot":"","sources":["../../src/fields/outlined-field.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,KAAK,aAAa,EAAa,MAAM,+BAA+B,CAAC;AACtG,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,gBAAgB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,KAAK,iBAAiB,EAA0B,MAAM,eAAe,CAAC;AAM/E,4FAA4F;AAC5F,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,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IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,yBAAyB,GAAG,SAAS,CAkO3E"}
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import "./fields.css";
|
|
2
2
|
import { G9FilledValueHighlight, G9Metrics } from "@g9tm/lynxcontrols-foundation";
|
|
3
3
|
import { useState } from "@lynx-js/react";
|
|
4
|
-
import {
|
|
4
|
+
import { useG9Anchor } from "../anchor/hooks.jsx";
|
|
5
|
+
import { g9RowStyle } from "../base/control.jsx";
|
|
5
6
|
import { g9KeyboardTargetProps } from "../host/keyboard.jsx";
|
|
6
7
|
import { G9IconSlot, hasIconSlot } from "../icon/slot.jsx";
|
|
7
8
|
import { useG9Direction, useG9Settings } from "../provider/hooks.jsx";
|
|
8
9
|
import { resolveFieldSlotLayout } from "./slot-layout.jsx";
|
|
9
10
|
const v = (token)=>`var(--g9-${token})`;
|
|
11
|
+
const blank = (s)=>null == s || '' === s.trim();
|
|
12
|
+
function resolveRestingPlaceholder(props) {
|
|
13
|
+
if (blank(props.placeholder)) return null;
|
|
14
|
+
const placeholder = props.placeholder;
|
|
15
|
+
if (true === props.placeholderInside || blank(props.label)) return placeholder;
|
|
16
|
+
return true === props.alwaysFloat && props.label !== placeholder ? placeholder : null;
|
|
17
|
+
}
|
|
18
|
+
function resolveInnerHint(props) {
|
|
19
|
+
const owns = true === props.placeholderInside || !blank(props.label);
|
|
20
|
+
return owns ? resolveRestingPlaceholder(props) : null;
|
|
21
|
+
}
|
|
10
22
|
function resolveOutlinedFieldState(props, input) {
|
|
11
23
|
var _props_filledValueHighlight, _props_statusColor, _props_errorText, _props_helperText, _props_maxLength, _ref, _props_label;
|
|
12
24
|
const hasError = true === props.hasError;
|
|
@@ -28,7 +40,7 @@ function resolveOutlinedFieldState(props, input) {
|
|
|
28
40
|
const counterText = true === props.showCharacterCounter && maxLength > 0 ? `${input.textLength} / ${maxLength}` : '';
|
|
29
41
|
const emphasis = input.focused || hasError || useStatus;
|
|
30
42
|
const halo = true === props.showFocusHalo && input.focused && !hasError && !useStatus;
|
|
31
|
-
const labelRaw = null != (_ref = null != (_props_label = props.label) ? _props_label : props.placeholder) ? _ref : '';
|
|
43
|
+
const labelRaw = null != (_ref = null != (_props_label = props.label) ? _props_label : true === props.placeholderInside ? null : props.placeholder) ? _ref : '';
|
|
32
44
|
return {
|
|
33
45
|
floated,
|
|
34
46
|
stateColor,
|
|
@@ -55,7 +67,17 @@ function physicalSide(column) {
|
|
|
55
67
|
return 0 === column ? 'left' : 'right';
|
|
56
68
|
}
|
|
57
69
|
function G9OutlinedField(props) {
|
|
58
|
-
var _props_valueFloated, _props_textLength, _props_restingTone, _props_leadingEmoji, _props_leadingImagePath, _props_leadingImage, _props_trailingEmoji, _props_trailingImagePath, _props_trailingImage, _props_trailingAffordance, _props_innerContentPadding, _pad_left, _pad_top, _pad_right, _pad_bottom, _affordance_color;
|
|
70
|
+
var _props_anchor, _props_valueFloated, _props_textLength, _props_restingTone, _props_leadingEmoji, _props_leadingImagePath, _props_leadingImage, _props_trailingEmoji, _props_trailingImagePath, _props_trailingImage, _props_trailingAffordance, _props_innerContentPadding, _pad_left, _pad_top, _pad_right, _pad_bottom, _affordance_color;
|
|
71
|
+
const anchorHandle = useG9Anchor(props.id, null != (_props_anchor = props.anchor) ? _props_anchor : {
|
|
72
|
+
kind: 'entry',
|
|
73
|
+
label: ()=>{
|
|
74
|
+
var _props_label;
|
|
75
|
+
return null != (_props_label = props.label) ? _props_label : props.placeholder;
|
|
76
|
+
},
|
|
77
|
+
enabled: ()=>!props.disabled
|
|
78
|
+
}, props.id ? {
|
|
79
|
+
domId: props.id
|
|
80
|
+
} : {});
|
|
59
81
|
const direction = useG9Direction();
|
|
60
82
|
const isRtl = 'rtl' === direction;
|
|
61
83
|
const state = useOutlinedField(props, {
|
|
@@ -134,7 +156,7 @@ function G9OutlinedField(props) {
|
|
|
134
156
|
borderColor: state.stateColor,
|
|
135
157
|
borderTopColor: 'transparent'
|
|
136
158
|
}}/> : affordance ? <G9IconSlot icon={affordance.icon} color={null != (_affordance_color = affordance.color) ? _affordance_color : state.stateColor} size={iconSize}/> : <G9IconSlot {...trailing} color={state.stateColor} size={iconSize}/>;
|
|
137
|
-
return <view className={`g9-field g9-dir-${direction}${disabled ? ' g9-field--disabled' : ''}${props.className ? ` ${props.className}` : ''}`} {...
|
|
159
|
+
return <view className={`g9-field g9-dir-${direction}${disabled ? ' g9-field--disabled' : ''}${props.className ? ` ${props.className}` : ''}`} {...anchorHandle.props}>
|
|
138
160
|
<view {...g9KeyboardTargetProps} className={`g9-field__box${state.floated ? ' g9-field__box--floated' : ''}${props.focused ? ' g9-field__box--focused' : ''}`} accessibility-element={false} style={{
|
|
139
161
|
height: multiline ? void 0 : `${state.fieldHeight}px`,
|
|
140
162
|
minHeight: multiline ? `${state.fieldHeight}px` : void 0,
|
|
@@ -166,6 +188,22 @@ function G9OutlinedField(props) {
|
|
|
166
188
|
paddingBottom: `${slot.innerPadding.bottom}px`
|
|
167
189
|
}}>
|
|
168
190
|
{props.children}
|
|
191
|
+
{props.hint && !props.hasValue && true !== props.valueFloated ? <view className={`g9-field__hint${multiline ? ' g9-field__hint--multiline' : ''}`} user-interaction-enabled={false} style={{
|
|
192
|
+
left: `${slot.innerPadding.left + (hasLeading && 0 === slot.leadingColumn ? G9Metrics.LeadingIconSlotWidth : 0) + (hasTrailing && 0 === slot.trailingColumn ? G9Metrics.TrailingIconSlotWidth : 0)}px`,
|
|
193
|
+
right: `${slot.innerPadding.right + (hasLeading && 2 === slot.leadingColumn ? G9Metrics.LeadingIconSlotWidth : 0) + (hasTrailing && 2 === slot.trailingColumn ? G9Metrics.TrailingIconSlotWidth : 0)}px`,
|
|
194
|
+
...multiline ? {
|
|
195
|
+
top: `${slot.innerPadding.top}px`
|
|
196
|
+
} : {}
|
|
197
|
+
}}>
|
|
198
|
+
<text className="g9-field__hint-text" {...multiline ? {} : {
|
|
199
|
+
'text-maxline': '1'
|
|
200
|
+
}} style={{
|
|
201
|
+
textAlign: isRtl ? 'right' : 'left',
|
|
202
|
+
color: disabled ? 'var(--g9-text-disabled)' : 'var(--g9-text-tertiary)'
|
|
203
|
+
}}>
|
|
204
|
+
{props.hint}
|
|
205
|
+
</text>
|
|
206
|
+
</view> : null}
|
|
169
207
|
</view>
|
|
170
208
|
{hasLeading ? <view className="g9-field__slot g9-field__slot--leading" style={slotStyle(slot.leadingColumn, G9Metrics.LeadingIconSlotWidth, false)} catchtap={onLeadingTap} {...leadingActionable ? {
|
|
171
209
|
'accessibility-element': true,
|
|
@@ -204,6 +242,6 @@ function G9OutlinedField(props) {
|
|
|
204
242
|
</view> : null}
|
|
205
243
|
</view>;
|
|
206
244
|
}
|
|
207
|
-
export { G9OutlinedField, resolveOutlinedFieldState, useOutlinedField };
|
|
245
|
+
export { G9OutlinedField, resolveInnerHint, resolveOutlinedFieldState, resolveRestingPlaceholder, useOutlinedField };
|
|
208
246
|
|
|
209
247
|
//# sourceMappingURL=outlined-field.jsx.map
|