igniteui-webcomponents 7.3.0-beta.0 → 7.3.0-beta.1
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/CHANGELOG.md +20 -0
- package/animations/player.d.ts +7 -2
- package/animations/player.js +1 -2
- package/animations/player.js.map +1 -1
- package/components/accordion/accordion.js +4 -16
- package/components/accordion/accordion.js.map +1 -1
- package/components/avatar/avatar.d.ts +0 -1
- package/components/avatar/avatar.js +5 -9
- package/components/avatar/avatar.js.map +1 -1
- package/components/badge/badge.d.ts +1 -3
- package/components/badge/badge.js +4 -8
- package/components/badge/badge.js.map +1 -1
- package/components/banner/banner.d.ts +6 -5
- package/components/banner/banner.js +19 -17
- package/components/banner/banner.js.map +1 -1
- package/components/button/button-base.d.ts +1 -1
- package/components/button/button-base.js.map +1 -1
- package/components/button-group/button-group.d.ts +0 -1
- package/components/button-group/button-group.js +12 -17
- package/components/button-group/button-group.js.map +1 -1
- package/components/calendar/base.d.ts +3 -13
- package/components/calendar/base.js +10 -31
- package/components/calendar/base.js.map +1 -1
- package/components/calendar/calendar.d.ts +2 -2
- package/components/calendar/months-view/months-view.d.ts +1 -1
- package/components/calendar/months-view/months-view.js.map +1 -1
- package/components/carousel/carousel-indicator.d.ts +1 -1
- package/components/carousel/carousel-indicator.js +13 -13
- package/components/carousel/carousel-indicator.js.map +1 -1
- package/components/carousel/carousel-slide.d.ts +0 -2
- package/components/carousel/carousel-slide.js +7 -9
- package/components/carousel/carousel-slide.js.map +1 -1
- package/components/carousel/carousel.d.ts +52 -35
- package/components/carousel/carousel.js +136 -122
- package/components/carousel/carousel.js.map +1 -1
- package/components/carousel/themes/carousel.base.css.js +1 -1
- package/components/carousel/themes/carousel.base.css.js.map +1 -1
- package/components/chat/chat-input.d.ts +1 -1
- package/components/chat/chat-input.js +21 -21
- package/components/chat/chat-input.js.map +1 -1
- package/components/chat/chat.d.ts +0 -2
- package/components/chat/chat.js +6 -12
- package/components/chat/chat.js.map +1 -1
- package/components/checkbox/checkbox-base.d.ts +1 -1
- package/components/checkbox/checkbox.d.ts +3 -5
- package/components/checkbox/checkbox.js +33 -44
- package/components/checkbox/checkbox.js.map +1 -1
- package/components/checkbox/switch.d.ts +1 -1
- package/components/checkbox/switch.js +23 -34
- package/components/checkbox/switch.js.map +1 -1
- package/components/chip/chip.d.ts +1 -14
- package/components/chip/chip.js +12 -33
- package/components/chip/chip.js.map +1 -1
- package/components/combo/combo-item.d.ts +1 -3
- package/components/combo/combo-item.js +5 -12
- package/components/combo/combo-item.js.map +1 -1
- package/components/combo/combo.d.ts +7 -20
- package/components/combo/combo.js +59 -81
- package/components/combo/combo.js.map +1 -1
- package/components/date-picker/date-picker.base.d.ts +12 -9
- package/components/date-picker/date-picker.base.js +24 -31
- package/components/date-picker/date-picker.base.js.map +1 -1
- package/components/date-picker/date-picker.d.ts +1 -1
- package/components/date-picker/date-picker.js +3 -5
- package/components/date-picker/date-picker.js.map +1 -1
- package/components/date-range-picker/date-range-input.d.ts +2 -4
- package/components/date-range-picker/date-range-input.js +6 -37
- package/components/date-range-picker/date-range-input.js.map +1 -1
- package/components/date-range-picker/date-range-picker.d.ts +2 -5
- package/components/date-range-picker/date-range-picker.js +15 -28
- package/components/date-range-picker/date-range-picker.js.map +1 -1
- package/components/date-range-picker/predefined-ranges-area.d.ts +2 -2
- package/components/date-range-picker/predefined-ranges-area.js +4 -6
- package/components/date-range-picker/predefined-ranges-area.js.map +1 -1
- package/components/date-range-picker/validators.d.ts +1 -1
- package/components/date-range-picker/validators.js +5 -18
- package/components/date-range-picker/validators.js.map +1 -1
- package/components/date-time-input/date-part.d.ts +2 -1
- package/components/date-time-input/date-part.js +38 -75
- package/components/date-time-input/date-part.js.map +1 -1
- package/components/date-time-input/date-time-input.base.d.ts +31 -12
- package/components/date-time-input/date-time-input.base.js +43 -11
- package/components/date-time-input/date-time-input.base.js.map +1 -1
- package/components/date-time-input/date-time-input.d.ts +1 -3
- package/components/date-time-input/date-time-input.js +7 -40
- package/components/date-time-input/date-time-input.js.map +1 -1
- package/components/date-time-input/datetime-mask-parser.d.ts +8 -0
- package/components/date-time-input/datetime-mask-parser.js +8 -8
- package/components/date-time-input/datetime-mask-parser.js.map +1 -1
- package/components/date-time-input/validators.js +3 -14
- package/components/date-time-input/validators.js.map +1 -1
- package/components/dialog/dialog.d.ts +6 -7
- package/components/dialog/dialog.js +21 -26
- package/components/dialog/dialog.js.map +1 -1
- package/components/divider/divider.d.ts +1 -4
- package/components/divider/divider.js +8 -17
- package/components/divider/divider.js.map +1 -1
- package/components/dropdown/dropdown-group.js +1 -6
- package/components/dropdown/dropdown-group.js.map +1 -1
- package/components/expansion-panel/expansion-panel.d.ts +15 -5
- package/components/expansion-panel/expansion-panel.js +23 -34
- package/components/expansion-panel/expansion-panel.js.map +1 -1
- package/components/file-input/file-input.d.ts +2 -14
- package/components/file-input/file-input.js +5 -23
- package/components/file-input/file-input.js.map +1 -1
- package/components/highlight/highlight.d.ts +6 -8
- package/components/highlight/highlight.js +12 -20
- package/components/highlight/highlight.js.map +1 -1
- package/components/icon/icon.d.ts +1 -1
- package/components/icon/registry/types.d.ts +1 -1
- package/components/icon/registry/types.js.map +1 -1
- package/components/input/input.d.ts +9 -19
- package/components/input/input.js +30 -60
- package/components/input/input.js.map +1 -1
- package/components/mask-input/mask-input.d.ts +1 -1
- package/components/mask-input/mask-input.js +2 -4
- package/components/mask-input/mask-input.js.map +1 -1
- package/components/nav-drawer/nav-drawer.d.ts +7 -7
- package/components/nav-drawer/nav-drawer.js +12 -23
- package/components/nav-drawer/nav-drawer.js.map +1 -1
- package/components/progress/base.d.ts +4 -7
- package/components/progress/base.js +21 -45
- package/components/progress/base.js.map +1 -1
- package/components/qr-code/qr-code.d.ts +1 -1
- package/components/qr-code/qr-code.js +3 -2
- package/components/qr-code/qr-code.js.map +1 -1
- package/components/qr-code/types.d.ts +1 -1
- package/components/qr-code/types.js.map +1 -1
- package/components/radio/controller.d.ts +2 -30
- package/components/radio/controller.js +8 -94
- package/components/radio/controller.js.map +1 -1
- package/components/radio/radio.d.ts +5 -5
- package/components/radio/radio.js +48 -58
- package/components/radio/radio.js.map +1 -1
- package/components/radio-group/radio-group.d.ts +1 -2
- package/components/radio-group/radio-group.js +2 -9
- package/components/radio-group/radio-group.js.map +1 -1
- package/components/rating/rating.d.ts +24 -12
- package/components/rating/rating.js +79 -73
- package/components/rating/rating.js.map +1 -1
- package/components/resize-container/default-ghost.js +4 -3
- package/components/resize-container/default-ghost.js.map +1 -1
- package/components/resize-container/resize-container.d.ts +1 -1
- package/components/resize-container/resize-container.js +5 -3
- package/components/resize-container/resize-container.js.map +1 -1
- package/components/resize-container/resize-controller.js +4 -3
- package/components/resize-container/resize-controller.js.map +1 -1
- package/components/select/select-group.d.ts +2 -1
- package/components/select/select-group.js +7 -11
- package/components/select/select-group.js.map +1 -1
- package/components/select/select.d.ts +3 -4
- package/components/select/select.js +23 -28
- package/components/select/select.js.map +1 -1
- package/components/slider/range-slider.d.ts +3 -2
- package/components/slider/range-slider.js +22 -70
- package/components/slider/range-slider.js.map +1 -1
- package/components/slider/slider-base.d.ts +9 -6
- package/components/slider/slider-base.js +27 -28
- package/components/slider/slider-base.js.map +1 -1
- package/components/slider/slider.js +9 -5
- package/components/slider/slider.js.map +1 -1
- package/components/splitter/splitter.d.ts +1 -1
- package/components/splitter/splitter.js.map +1 -1
- package/components/stepper/step.d.ts +3 -0
- package/components/stepper/step.js +9 -5
- package/components/stepper/step.js.map +1 -1
- package/components/stepper/stepper.d.ts +0 -11
- package/components/stepper/stepper.js +21 -86
- package/components/stepper/stepper.js.map +1 -1
- package/components/tabs/tab.d.ts +1 -1
- package/components/tabs/tab.js +6 -5
- package/components/tabs/tab.js.map +1 -1
- package/components/tabs/tabs.d.ts +1 -5
- package/components/tabs/tabs.js +12 -34
- package/components/tabs/tabs.js.map +1 -1
- package/components/textarea/textarea.d.ts +6 -7
- package/components/textarea/textarea.js +3 -10
- package/components/textarea/textarea.js.map +1 -1
- package/components/theme-provider/theme-provider.d.ts +2 -4
- package/components/theme-provider/theme-provider.js +11 -21
- package/components/theme-provider/theme-provider.js.map +1 -1
- package/components/tile-manager/tile-manager.d.ts +10 -21
- package/components/tile-manager/tile-manager.js +43 -74
- package/components/tile-manager/tile-manager.js.map +1 -1
- package/components/tile-manager/tile.d.ts +10 -18
- package/components/tile-manager/tile.js +50 -67
- package/components/tile-manager/tile.js.map +1 -1
- package/components/tooltip/tooltip.d.ts +4 -7
- package/components/tooltip/tooltip.js +20 -28
- package/components/tooltip/tooltip.js.map +1 -1
- package/components/tree/tree.d.ts +1 -14
- package/components/tree/tree.js +5 -23
- package/components/tree/tree.js.map +1 -1
- package/components/tree/tree.navigation.d.ts +1 -1
- package/components/tree/tree.navigation.js.map +1 -1
- package/components/validation-container/validation-container.d.ts +1 -2
- package/components/validation-container/validation-container.js.map +1 -1
- package/components/virtualization/engine.d.ts +40 -38
- package/components/virtualization/engine.js.map +1 -1
- package/components/virtualization/types.d.ts +6 -5
- package/components/virtualization/types.js.map +1 -1
- package/components/virtualization/virtualization.d.ts +94 -80
- package/components/virtualization/virtualization.js +10 -2
- package/components/virtualization/virtualization.js.map +1 -1
- package/custom-elements.json +9940 -7738
- package/igniteui-webcomponents.css-data.json +1 -1
- package/igniteui-webcomponents.html-data.json +1 -1
- package/internals/controllers/aria-projection.d.ts +6 -6
- package/internals/controllers/aria-projection.js.map +1 -1
- package/internals/controllers/context-provider.d.ts +48 -0
- package/internals/controllers/context-provider.js +29 -0
- package/internals/controllers/context-provider.js.map +1 -0
- package/internals/controllers/drag.js +6 -6
- package/internals/controllers/drag.js.map +1 -1
- package/internals/controllers/gestures.js +3 -0
- package/internals/controllers/gestures.js.map +1 -1
- package/internals/controllers/group.d.ts +64 -0
- package/internals/controllers/group.js +104 -0
- package/internals/controllers/group.js.map +1 -0
- package/internals/controllers/internals.d.ts +16 -3
- package/internals/controllers/internals.js +10 -3
- package/internals/controllers/internals.js.map +1 -1
- package/internals/controllers/key-bindings.d.ts +6 -0
- package/internals/controllers/key-bindings.js +3 -0
- package/internals/controllers/key-bindings.js.map +1 -1
- package/internals/controllers/roving-focus.d.ts +72 -0
- package/internals/controllers/roving-focus.js +61 -0
- package/internals/controllers/roving-focus.js.map +1 -0
- package/internals/controllers/slot.d.ts +8 -0
- package/internals/controllers/slot.js +4 -0
- package/internals/controllers/slot.js.map +1 -1
- package/internals/controllers/toggle.d.ts +96 -0
- package/internals/controllers/toggle.js +65 -0
- package/internals/controllers/toggle.js.map +1 -0
- package/internals/date/converters.js +2 -5
- package/internals/date/converters.js.map +1 -1
- package/internals/date/model.d.ts +4 -0
- package/internals/date/model.js +6 -0
- package/internals/date/model.js.map +1 -1
- package/internals/decorators/coerced-property.d.ts +47 -0
- package/internals/decorators/coerced-property.js +36 -0
- package/internals/decorators/coerced-property.js.map +1 -0
- package/internals/i18n/i18n-controller.d.ts +22 -3
- package/internals/i18n/i18n-controller.js +28 -6
- package/internals/i18n/i18n-controller.js.map +1 -1
- package/internals/mixins/alert.d.ts +1 -1
- package/internals/mixins/alert.js +5 -3
- package/internals/mixins/alert.js.map +1 -1
- package/internals/mixins/combo-box.d.ts +3 -12
- package/internals/mixins/combo-box.js +6 -32
- package/internals/mixins/combo-box.js.map +1 -1
- package/internals/mixins/forms/associated.js +18 -0
- package/internals/mixins/forms/associated.js.map +1 -1
- package/internals/mixins/forms/types.d.ts +20 -1
- package/internals/mixins/forms/types.js.map +1 -1
- package/internals/mixins/i18n.d.ts +31 -0
- package/internals/mixins/i18n.js +36 -0
- package/internals/mixins/i18n.js.map +1 -0
- package/internals/mixins/mask-behavior.d.ts +6 -5
- package/internals/mixins/mask-behavior.js +1 -2
- package/internals/mixins/mask-behavior.js.map +1 -1
- package/internals/mixins/option.js +4 -2
- package/internals/mixins/option.js.map +1 -1
- package/internals/templates/masked-input.d.ts +1 -1
- package/internals/templates/masked-input.js.map +1 -1
- package/internals/templates/slotted-icon.d.ts +32 -0
- package/internals/templates/slotted-icon.js +19 -0
- package/internals/templates/slotted-icon.js.map +1 -0
- package/internals/templates/toggle-shell.d.ts +46 -0
- package/internals/templates/toggle-shell.js +38 -0
- package/internals/templates/toggle-shell.js.map +1 -0
- package/internals/timing.d.ts +32 -0
- package/internals/timing.js +20 -0
- package/internals/timing.js.map +1 -0
- package/internals/utils/arrays.d.ts +2 -2
- package/internals/utils/arrays.js.map +1 -1
- package/internals/utils/dom.d.ts +22 -0
- package/internals/utils/dom.js +15 -1
- package/internals/utils/dom.js.map +1 -1
- package/internals/utils/math.d.ts +1 -1
- package/internals/utils/math.js.map +1 -1
- package/internals/utils/types.d.ts +1 -1
- package/internals/utils/types.js.map +1 -1
- package/internals/validators.d.ts +23 -0
- package/internals/validators.js +21 -0
- package/internals/validators.js.map +1 -1
- package/package.json +1 -1
- package/theming/theming-controller.d.ts +3 -3
- package/theming/theming-controller.js.map +1 -1
- package/web-types.json +2 -2
- package/internals/decorators/watch.d.ts +0 -5
- package/internals/decorators/watch.js +0 -19
- package/internals/decorators/watch.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mask-behavior.js","sourceRoot":"","sources":["../../../src/internals/mixins/mask-behavior.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,iBAAiB,GAIlB,MAAM,6CAA6C,CAAC;AAMrD,OAAO,EACL,cAAc,EACd,OAAO,EACP,OAAO,EACP,QAAQ,GACT,MAAM,gCAAgC,CAAC;AAcxC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAuB;IAClD,CAAC,YAAY,EAAE,QAAQ,CAAC;IACxB,CAAC,uBAAuB,EAAE,iBAAiB,CAAC;IAC5C,CAAC,sBAAsB,EAAE,gBAAgB,CAAC;IAC1C,CAAC,aAAa,EAAE,QAAQ,CAAC;IACzB,CAAC,iBAAiB,EAAE,QAAQ,CAAC;IAC7B,CAAC,gBAAgB,EA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AK,EAAE;6DACoB;IA+DrB;QADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yDACnB;IAQxB;QADC,QAAQ,EAAE;mDAGV;IAaD;QADC,QAAQ,EAAE;qDAGV;IA2VH,OAAO,mBACJ,CAAC;AACN,CAAC","sourcesContent":["import type { LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport {\n createMaskHistory,\n type MaskEditKind,\n type MaskHistory,\n type MaskHistoryState,\n} from '../../components/mask-input/mask-history.js';\nimport type { MaskParser } from '../../components/mask-input/mask-parser.js';\nimport type {\n RangeTextSelectMode,\n SelectionRangeDirection,\n} from '../../components/types.js';\nimport {\n addKeybindings,\n ctrlKey,\n metaKey,\n shiftKey,\n} from '../controllers/key-bindings.js';\nimport type { AbstractConstructor } from './constructor.js';\n\nexport type MaskSelection = {\n start: number;\n end: number;\n};\n\n/**\n * The `inputType` values the mask editor models, mapped to their undo granularity.\n *\n * Anything absent is a native mutation we do not model - auto-fill is the empty-string\n * entry, `deleteWordBackward` and friends are simply not handled.\n */\nconst MaskEditKinds = new Map<string, MaskEditKind>([\n ['insertText', 'insert'],\n ['deleteContentBackward', 'delete-backward'],\n ['deleteContentForward', 'delete-forward'],\n ['deleteByCut', 'atomic'],\n ['insertFromPaste', 'atomic'],\n ['insertFromDrop', 'atomic'],\n ['', 'atomic'],\n]);\n\n/**\n * Public + protected interface contributed by {@link MaskBehaviorMixin}.\n * Declared as a `declare class` so consumers can see protected members through\n * the cast return type (mirrors the pattern used by the form-associated mixins).\n */\nexport declare class MaskBehaviorElementInterface {\n //#region Required from host\n\n protected readonly _input?: HTMLInputElement;\n protected readonly _parser: MaskParser;\n\n /** Reflects the current parser state into the host's public value. */\n protected _syncValueFromMask(): void;\n\n /** Delegates Enter-key handling to the form-associated base. */\n protected _handleEnterKeydown(event: KeyboardEvent): void;\n\n //#endregion\n\n //#region Internal state\n\n protected _maskSelection: MaskSelection;\n protected _compositionStart: number;\n protected _focused: boolean;\n protected _maskedValue: string;\n protected readonly _history: MaskHistory;\n\n protected get _inputSelection(): MaskSelection;\n protected get _isEmptyMask(): boolean;\n protected get _historyText(): string;\n\n //#endregion\n\n //#region Public attributes and properties\n\n /**\n * Makes the control a readonly field.\n * @attr readonly\n * @default false\n */\n public readOnly: boolean;\n\n /**\n * The mask pattern of the component.\n * @attr\n */\n public get mask(): string;\n public set mask(value: string);\n\n /**\n * The prompt symbol to use for unfilled parts of the mask pattern.\n * @attr\n * @default '_'\n */\n public get prompt(): string;\n public set prompt(value: string);\n\n //#endregion\n\n //#region Event handlers\n\n protected _handleInput(event: InputEvent): Promise<void>;\n protected _handleBeforeInput(event: InputEvent): void;\n protected _updateInput(text: string, range: MaskSelection): Promise<void>;\n protected _commitMaskedValue(value: string): void;\n protected _emitInputEvent(): void;\n protected _setMaskSelection(event: Event): void;\n protected _handleCompositionStart(): void;\n protected _handleCompositionEnd(event: CompositionEvent): void;\n protected _handleClick(): void;\n\n //#endregion\n\n //#region Undo/redo\n\n protected _recordHistory(\n kind: MaskEditKind,\n next: string,\n caret: number,\n selection?: MaskSelection\n ): void;\n\n protected _historyStep(direction: 'undo' | 'redo'): Promise<void>;\n protected _historyResync(): void;\n\n //#endregion\n\n //#region Public methods\n\n /** Sets the text selection range of the control. */\n public setSelectionRange(\n start?: number,\n end?: number,\n direction?: SelectionRangeDirection\n ): void;\n\n /** Replaces the selected text in the control and re-applies the mask. */\n public setRangeText(\n replacement: string,\n start?: number,\n end?: number,\n selectMode?: RangeTextSelectMode\n ): void;\n\n //#endregion\n}\n\n/**\n * Adds masked-input behavior (parser-driven editing, selection tracking,\n * composition handling, range text replacement) to a LitElement-derived class.\n *\n * The host class is expected to provide:\n * - `_input` – the native `<input>` element (typically via `@query('input')`).\n * - `_parser` – a {@link MaskParser} (or subclass) instance.\n * - `_setTouchedState` – from `FormAssociatedMixin`.\n * - `emitEvent` – from `EventEmitterMixin`.\n * - `select` – from the host base.\n *\n * The host class must implement `_syncValueFromMask` to bridge the masked\n * text back into its public `value`. It is called by the default\n * `_commitMaskedValue` implementation.\n */\nexport function MaskBehaviorMixin<T extends AbstractConstructor<LitElement>>(\n superClass: T\n): AbstractConstructor<MaskBehaviorElementInterface> & T {\n abstract class MaskBehaviorElement extends superClass {\n //#region Required from host\n\n protected abstract readonly _input?: HTMLInputElement;\n protected abstract readonly _parser: MaskParser;\n protected abstract _setTouchedState(): void;\n public abstract select(): void;\n public abstract emitEvent(name: string, init?: CustomEventInit): boolean;\n\n protected abstract _syncValueFromMask(): void;\n protected abstract _handleEnterKeydown(event: KeyboardEvent): void;\n\n //#endregion\n\n //#region Internal state\n\n protected _maskSelection: MaskSelection = { start: 0, end: 0 };\n protected _compositionStart = 0;\n\n /**\n * The signature is the source pattern rather than the escaped one: the date parsers\n * convert a date format into mask flags, so `MM/dd/yyyy` and `dd/MM/yyyy` share an\n * escaped mask of `00/00/0000` while meaning entirely different things.\n */\n protected readonly _history = createMaskHistory(\n () => `${this._parser.mask} ${this._parser.prompt}`\n );\n\n @state()\n protected _focused = false;\n\n @state()\n protected _maskedValue = '';\n\n protected get _inputSelection(): MaskSelection {\n return {\n start: this._input?.selectionStart || 0,\n end: this._input?.selectionEnd || 0,\n };\n }\n\n /** Indicates whether the current mask value is empty. */\n protected get _isEmptyMask(): boolean {\n return this._maskedValue === this._parser.emptyMask;\n }\n\n /**\n * The masked text as the undo history sees it. `igc-mask-input` blanks it on blur and\n * restores the empty mask on focus; both spell the same empty document, so without\n * this normalization every focus of an empty editor would look like a foreign change.\n */\n protected get _historyText(): string {\n return this._maskedValue || this._parser.emptyMask;\n }\n\n //#endregion\n\n //#region Lifecycle\n\n constructor(...args: any[]) {\n super(...args);\n\n // Assigning `input.value` - which every masked edit does - clears the browser's\n // own undo stack, so the standard shortcuts have to be served from `_history`.\n // The IME owns the text until `compositionend`, hence the `isComposing` guard.\n const step =\n (direction: 'undo' | 'redo') =>\n (event: KeyboardEvent): void => {\n if (!event.isComposing) {\n this._historyStep(direction);\n }\n };\n\n addKeybindings(this, {\n skip: () => this.readOnly,\n bindingDefaults: { repeat: true },\n })\n .set([ctrlKey, 'z'], step('undo'))\n .set([metaKey, 'z'], step('undo'))\n .set([ctrlKey, 'y'], step('redo'))\n .set([ctrlKey, shiftKey, 'z'], step('redo'))\n .set([metaKey, shiftKey, 'z'], step('redo'));\n }\n\n //#endregion\n\n //#region Public attributes and properties\n\n /**\n * Makes the control a readonly field.\n *\n * @attr readonly\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public readOnly = false;\n\n /**\n * The mask pattern of the component.\n *\n * @attr\n */\n @property()\n public set mask(value: string) {\n this._parser.mask = value;\n }\n\n public get mask(): string {\n return this._parser.mask;\n }\n\n /**\n * The prompt symbol to use for unfilled parts of the mask pattern.\n *\n * @attr\n * @default '_'\n */\n @property()\n public set prompt(value: string) {\n this._parser.prompt = value;\n }\n\n public get prompt(): string {\n return this._parser.prompt;\n }\n\n //#endregion\n\n //#region Event handlers\n\n protected async _handleInput({\n inputType,\n isComposing,\n }: InputEvent): Promise<void> {\n const value = this._input?.value ?? '';\n const { start, end } = this._maskSelection;\n const deletePosition = this._parser.getNextNonLiteralPosition(end) + 1;\n\n // Reachable only where `beforeinput` is not cancelable - normally the browser's\n // history commands are intercepted before they ever mutate the input.\n if (inputType === 'historyUndo' || inputType === 'historyRedo') {\n return this._historyStep(inputType === 'historyUndo' ? 'undo' : 'redo');\n }\n\n // A composing backspace is handled by the composition events instead.\n if (inputType === 'deleteContentBackward' && isComposing) {\n return;\n }\n\n const kind = MaskEditKinds.get(inputType ?? '');\n\n if (kind === undefined) {\n // A non-modeled mutation has already changed the input's DOM value, so re-render\n // to let the `live()` binding roll it back to the masked text. Never mid-IME\n // though - `insertCompositionText` fires repeatedly there and resetting the value\n // underneath the browser breaks composition outright.\n if (!isComposing) {\n this.requestUpdate();\n }\n return;\n }\n\n this._setTouchedState();\n\n switch (inputType) {\n case 'deleteContentForward': {\n await this._updateInput('', { start, end: deletePosition }, kind);\n this._input?.setSelectionRange(deletePosition, deletePosition);\n // `_updateInput` settled on the parser's cursor, but the caret actually ends up\n // past the deleted character - record that so a run of deletes coalesces.\n this._history.settle(this._historyText, deletePosition);\n return;\n }\n\n case 'deleteContentBackward':\n return this._updateInput(\n '',\n {\n start: this._parser.getPreviousNonLiteralPosition(\n this._inputSelection.start + 1\n ),\n end,\n },\n kind\n );\n\n case 'deleteByCut':\n return this._updateInput('', this._maskSelection, kind);\n\n case 'insertText':\n return this._updateInput(\n value.substring(start, this._inputSelection.end),\n this._maskSelection,\n kind\n );\n\n case 'insertFromPaste':\n return this._updateInput(\n value.substring(start, this._inputSelection.end),\n {\n start,\n end: this._inputSelection.start,\n },\n kind\n );\n\n case 'insertFromDrop':\n // An external drop is preceded by no `dragstart`, so `_maskSelection` is stale.\n return this._updateInput(\n value.substring(\n this._inputSelection.start,\n this._inputSelection.end\n ),\n { ...this._inputSelection },\n kind,\n {\n start: this._inputSelection.start,\n end: this._inputSelection.start,\n }\n );\n\n // Potential browser auto-fill behavior\n case undefined:\n case '':\n return this._updateInput(\n this._parser.parse(\n value.substring(start, this._inputSelection.end)\n ),\n {\n start,\n end: this._inputSelection.end,\n },\n kind,\n { start, end: start }\n );\n }\n }\n\n /**\n * Default mask-update routine. Re-applies the parser, commits the result through\n * {@link MaskBehaviorElementInterface._commitMaskedValue} and emits an input event\n * when the edit is not at the trailing mask boundary.\n */\n protected async _updateInput(\n text: string,\n range: MaskSelection,\n kind: MaskEditKind = 'atomic',\n caretBefore?: MaskSelection\n ): Promise<void> {\n const { value, end } = this._parser.replace(\n this._maskedValue,\n text,\n range.start,\n range.end\n );\n\n this._recordHistory(kind, value, end, caretBefore ?? this._maskSelection);\n this._commitMaskedValue(value);\n this.requestUpdate();\n\n if (range.start !== this._parser.mask.length) {\n this._emitInputEvent();\n }\n\n await this.updateComplete;\n this._input?.setSelectionRange(end, end);\n }\n\n /**\n * Writes a fully-formed masked text into the component's value pipeline.\n *\n * This is the one step where the leaves genuinely differ - `igc-mask-input` commits\n * straight to its form value, while the date editors keep the text as a draft until\n * blur - so it is also the only thing undo/redo has to delegate.\n */\n protected _commitMaskedValue(value: string): void {\n this._maskedValue = value;\n this._syncValueFromMask();\n }\n\n /**\n * Emits an `igcInput` event with the current masked value as detail.\n * Override to emit a different payload (e.g. the parsed value).\n */\n protected _emitInputEvent(): void {\n this._setTouchedState();\n this.emitEvent('igcInput', { detail: this._maskedValue });\n }\n\n protected _setMaskSelection(event: Event): void {\n this._maskSelection = this._inputSelection;\n if (event instanceof KeyboardEvent) {\n this._handleEnterKeydown(event);\n }\n }\n\n protected _handleCompositionStart(): void {\n this._compositionStart = this._inputSelection.start;\n }\n\n protected _handleCompositionEnd({ data }: CompositionEvent): void {\n // The whole composed sequence is one undo step, anchored where it began.\n this._updateInput(\n data,\n { start: this._compositionStart, end: this._inputSelection.end },\n 'atomic',\n { start: this._compositionStart, end: this._compositionStart }\n );\n }\n\n protected _handleClick(): void {\n const { selectionStart: start, selectionEnd: end } = this._input ?? {\n selectionStart: 0,\n selectionEnd: 0,\n };\n\n // Clicking at the end of the input field will select the entire mask\n if (start === end && start === this._maskedValue.length) {\n this.select();\n }\n }\n\n /**\n * Intercepts the browser's own history commands - the Edit and context menus, and\n * the software keyboard on mobile - which never reach the key bindings. The native\n * stack is empty anyway, so letting one through would only de-sync the input's DOM\n * value from the masked text.\n */\n protected _handleBeforeInput(event: InputEvent): void {\n const { inputType } = event;\n\n if (inputType !== 'historyUndo' && inputType !== 'historyRedo') {\n return;\n }\n\n event.preventDefault();\n\n if (!this.readOnly) {\n this._historyStep(inputType === 'historyUndo' ? 'undo' : 'redo');\n }\n }\n\n //#endregion\n\n //#region Undo/redo\n\n /**\n * Snapshots the current masked text before `next` replaces it, then reports where the\n * caret ends up. Must be called *before* the text is committed.\n *\n * Only a real change earns an undo step: a character the mask rejects, a backspace at\n * position zero or a spin that hit a boundary would otherwise leave behind a step\n * that appears to do nothing when undone.\n */\n protected _recordHistory(\n kind: MaskEditKind,\n next: string,\n caret: number,\n selection: MaskSelection = this._inputSelection\n ): void {\n const previous = this._historyText;\n\n if (next !== previous) {\n this._history.record(kind, { value: previous, ...selection });\n }\n\n this._history.settle(next, caret);\n }\n\n /** Reconciles the history with the current masked text. */\n protected _historyResync(): void {\n this._history.resync(this._historyText);\n }\n\n /** Restores the neighboring history state in the given direction. */\n protected async _historyStep(direction: 'undo' | 'redo'): Promise<void> {\n if (this.readOnly) {\n return;\n }\n\n const current: MaskHistoryState = {\n value: this._historyText,\n ...this._inputSelection,\n };\n\n const state =\n direction === 'undo'\n ? this._history.undo(current)\n : this._history.redo(current);\n\n if (!state) {\n return;\n }\n\n this._setTouchedState();\n this._commitMaskedValue(state.value);\n this.requestUpdate();\n\n // Native inputs announce an undo as an `input` event, and the composite hosts\n // (`igc-date-picker`, `igc-date-range-picker`) read the draft value from ours.\n this._emitInputEvent();\n\n await this.updateComplete;\n\n // Through the mixin method, since the input's own keydown handler has already\n // overwritten `_maskSelection` with the caret as it was before the restore.\n this.setSelectionRange(state.start, state.end);\n }\n\n //#endregion\n\n //#region Public methods\n\n /* blazorSuppress */\n /** Sets the text selection range of the control */\n public setSelectionRange(\n start?: number,\n end?: number,\n direction: SelectionRangeDirection = 'none'\n ): void {\n this._input?.setSelectionRange(start ?? null, end ?? null, direction);\n this._maskSelection = { start: start ?? 0, end: end ?? 0 };\n }\n\n /* blazorSuppress */\n /** Replaces the selected text in the control and re-applies the mask */\n public setRangeText(\n replacement: string,\n start?: number,\n end?: number,\n selectMode?: RangeTextSelectMode\n ): void {\n const current = this._inputSelection;\n const _start = start ?? current.start;\n const _end = end ?? current.end;\n\n const result = this._parser.replace(\n this._maskedValue || this._parser.emptyMask,\n replacement,\n _start,\n _end\n );\n const next = this._parser.apply(this._parser.parse(result.value));\n\n this._recordHistory('atomic', next, _start, current);\n this._commitMaskedValue(next);\n\n this.updateComplete.then(() => {\n switch (selectMode) {\n case 'select':\n this.setSelectionRange(_start, _end);\n break;\n case 'start':\n this.setSelectionRange(_start, _start);\n break;\n case 'end':\n this.setSelectionRange(_end, _end);\n break;\n default:\n this.setSelectionRange(current.start, current.end);\n }\n });\n }\n\n //#endregion\n }\n\n return MaskBehaviorElement as unknown as AbstractConstructor<MaskBehaviorElementInterface> &\n T;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mask-behavior.js","sourceRoot":"","sources":["../../../src/internals/mixins/mask-behavior.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,iBAAiB,GAIlB,MAAM,6CAA6C,CAAC;AAMrD,OAAO,EACL,cAAc,EACd,OAAO,EACP,OAAO,EACP,QAAQ,GACT,MAAM,gCAAgC,CAAC;AAcxC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAuB;IAClD,CAAC,YAAY,EAAE,QAAQ,CAAC;IACxB,CAAC,uBAAuB,EAAE,iBAAiB,CAAC;IAC5C,CAAC,sBAAsB,EAAE,gBAAgB,CAAC;IAC1C,CAAC,aAAa,EAAE,QAAQ,CAAC;IACzB,CAAC,iBAAiB,EAAE,QAAQ,CAAC;IAC7B,CAAC,gBAAgB,EAAE,QAAQ,CAAC;IAC5B,CAAC,EAAE,EAAE,QAAQ,CAAC;CACf,CAAC,CAAC;AA6HH,MAAM,UAAU,iBAAiB,CAC/B,UAAa;IAEb,MAAe,mBAAoB,SAAQ,UAAU;QAsCnD,IAAc,eAAe;YAC3B,OAAO;gBACL,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,cAAc,IAAI,CAAC;gBACvC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,YAAY,IAAI,CAAC;aACpC,CAAC;QACJ,CAAC;QAGD,IAAc,YAAY;YACxB,OAAO,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;QACtD,CAAC;QAOD,IAAc,YAAY;YACxB,OAAO,IAA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AM,CAAC,KAAK,CAAC,CAAC,CAAC;YAElE,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YACrD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;YAE9B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE;gBAC5B,QAAQ,UAAU,EAAE,CAAC;oBACnB,KAAK,QAAQ;wBACX,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;wBACrC,MAAM;oBACR,KAAK,OAAO;wBACV,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;wBACvC,MAAM;oBACR,KAAK,KAAK;wBACR,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;wBACnC,MAAM;oBACR;wBACE,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;gBACvD,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KAGF;IAnbW;QADT,KAAK,EAAE;yDACmB;IAGjB;QADT,KAAK,EAAE;6DACoB;IA+DrB;QADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yDACnB;IAQxB;QADC,QAAQ,EAAE;mDAGV;IAaD;QADC,QAAQ,EAAE;qDAGV;IA0VH,OAAO,mBACJ,CAAC;AACN,CAAC","sourcesContent":["import type { LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport {\n createMaskHistory,\n type MaskEditKind,\n type MaskHistory,\n type MaskHistoryState,\n} from '../../components/mask-input/mask-history.js';\nimport type { MaskParser } from '../../components/mask-input/mask-parser.js';\nimport type {\n RangeTextSelectMode,\n SelectionRangeDirection,\n} from '../../components/types.js';\nimport {\n addKeybindings,\n ctrlKey,\n metaKey,\n shiftKey,\n} from '../controllers/key-bindings.js';\nimport type { AbstractConstructor } from './constructor.js';\n\nexport type MaskSelection = {\n start: number;\n end: number;\n};\n\n/**\n * The `inputType` values the mask editor models, mapped to their undo granularity.\n *\n * Anything absent is a native mutation we do not model - auto-fill is the empty-string\n * entry, `deleteWordBackward` and friends are simply not handled.\n */\nconst MaskEditKinds = new Map<string, MaskEditKind>([\n ['insertText', 'insert'],\n ['deleteContentBackward', 'delete-backward'],\n ['deleteContentForward', 'delete-forward'],\n ['deleteByCut', 'atomic'],\n ['insertFromPaste', 'atomic'],\n ['insertFromDrop', 'atomic'],\n ['', 'atomic'],\n]);\n\n/**\n * Public + protected interface contributed by {@link MaskBehaviorMixin}.\n * Declared as a `declare class` so consumers can see protected members through\n * the cast return type (mirrors the pattern used by the form-associated mixins).\n */\nexport declare class MaskBehaviorElementInterface {\n //#region Required from host\n\n protected readonly _input?: HTMLInputElement;\n protected readonly _parser: MaskParser;\n\n /** Reflects the current parser state into the host's public value. */\n protected _syncValueFromMask(): void;\n\n /** Delegates Enter-key handling to the form-associated base. */\n protected _handleEnterKeydown(event: KeyboardEvent): void;\n\n //#endregion\n\n //#region Internal state\n\n protected _maskSelection: MaskSelection;\n protected _compositionStart: number;\n protected _focused: boolean;\n protected _maskedValue: string;\n protected readonly _history: MaskHistory;\n\n protected get _inputSelection(): MaskSelection;\n protected get _isEmptyMask(): boolean;\n protected get _historyText(): string;\n\n //#endregion\n\n //#region Public attributes and properties\n\n /**\n * Makes the control a readonly field.\n * @attr readonly\n * @default false\n */\n public readOnly: boolean;\n\n /**\n * The mask pattern of the component.\n * @attr\n */\n public get mask(): string;\n public set mask(value: string);\n\n /**\n * The prompt symbol to use for unfilled parts of the mask pattern.\n * @attr\n * @default '_'\n */\n public get prompt(): string;\n public set prompt(value: string);\n\n //#endregion\n\n //#region Event handlers\n\n protected _handleInput(event: InputEvent): Promise<void>;\n protected _handleBeforeInput(event: InputEvent): void;\n protected _updateInput(text: string, range: MaskSelection): Promise<void>;\n protected _commitMaskedValue(value: string): void;\n protected _emitInputEvent(): void;\n protected _setMaskSelection(event: Event): void;\n protected _handleCompositionStart(): void;\n protected _handleCompositionEnd(event: CompositionEvent): void;\n protected _handleClick(): void;\n\n //#endregion\n\n //#region Undo/redo\n\n protected _recordHistory(\n kind: MaskEditKind,\n next: string,\n caret: number,\n selection?: MaskSelection\n ): void;\n\n protected _historyStep(direction: 'undo' | 'redo'): Promise<void>;\n protected _historyResync(): void;\n\n //#endregion\n\n //#region Public methods\n\n /** Sets the text selection range of the control. */\n public setSelectionRange(\n start?: number,\n end?: number,\n direction?: SelectionRangeDirection\n ): void;\n\n /** Replaces the selected text in the control and re-applies the mask. */\n public setRangeText(\n replacement: string,\n start?: number,\n end?: number,\n selectMode?: RangeTextSelectMode\n ): void;\n\n //#endregion\n}\n\n/**\n * Adds masked-input behavior (parser-driven editing, selection tracking,\n * composition handling, range text replacement) to a LitElement-derived class.\n *\n * The host class is expected to provide:\n * - `_input` - the native `<input>` element (typically via `@query('input')`).\n * - `_parser` - a {@link MaskParser} (or subclass) instance.\n * - `_setTouchedState` - from `FormAssociatedMixin`.\n * - `_emitTouchedEvent` - from `FormAssociatedMixin`.\n * - `emitEvent` - from `EventEmitterMixin`.\n * - `select` - from the host base.\n *\n * The host class must implement `_syncValueFromMask` to bridge the masked\n * text back into its public `value`. It is called by the default\n * `_commitMaskedValue` implementation.\n */\nexport function MaskBehaviorMixin<T extends AbstractConstructor<LitElement>>(\n superClass: T\n): AbstractConstructor<MaskBehaviorElementInterface> & T {\n abstract class MaskBehaviorElement extends superClass {\n //#region Required from host\n\n protected abstract readonly _input?: HTMLInputElement;\n protected abstract readonly _parser: MaskParser;\n protected abstract _setTouchedState(): void;\n protected abstract _emitTouchedEvent(\n eventName: string,\n init?: CustomEventInit\n ): boolean;\n public abstract select(): void;\n public abstract emitEvent(name: string, init?: CustomEventInit): boolean;\n\n protected abstract _syncValueFromMask(): void;\n protected abstract _handleEnterKeydown(event: KeyboardEvent): void;\n\n //#endregion\n\n //#region Internal state\n\n protected _maskSelection: MaskSelection = { start: 0, end: 0 };\n protected _compositionStart = 0;\n\n /**\n * The signature is the source pattern rather than the escaped one: the date parsers\n * convert a date format into mask flags, so `MM/dd/yyyy` and `dd/MM/yyyy` share an\n * escaped mask of `00/00/0000` while meaning entirely different things.\n */\n protected readonly _history = createMaskHistory(\n () => `${this._parser.mask} ${this._parser.prompt}`\n );\n\n @state()\n protected _focused = false;\n\n @state()\n protected _maskedValue = '';\n\n protected get _inputSelection(): MaskSelection {\n return {\n start: this._input?.selectionStart || 0,\n end: this._input?.selectionEnd || 0,\n };\n }\n\n /** Indicates whether the current mask value is empty. */\n protected get _isEmptyMask(): boolean {\n return this._maskedValue === this._parser.emptyMask;\n }\n\n /**\n * The masked text as the undo history sees it. `igc-mask-input` blanks it on blur and\n * restores the empty mask on focus; both spell the same empty document, so without\n * this normalization every focus of an empty editor would look like a foreign change.\n */\n protected get _historyText(): string {\n return this._maskedValue || this._parser.emptyMask;\n }\n\n //#endregion\n\n //#region Lifecycle\n\n constructor(...args: any[]) {\n super(...args);\n\n // Assigning `input.value` - which every masked edit does - clears the browser's\n // own undo stack, so the standard shortcuts have to be served from `_history`.\n // The IME owns the text until `compositionend`, hence the `isComposing` guard.\n const step =\n (direction: 'undo' | 'redo') =>\n (event: KeyboardEvent): void => {\n if (!event.isComposing) {\n this._historyStep(direction);\n }\n };\n\n addKeybindings(this, {\n skip: () => this.readOnly,\n bindingDefaults: { repeat: true },\n })\n .set([ctrlKey, 'z'], step('undo'))\n .set([metaKey, 'z'], step('undo'))\n .set([ctrlKey, 'y'], step('redo'))\n .set([ctrlKey, shiftKey, 'z'], step('redo'))\n .set([metaKey, shiftKey, 'z'], step('redo'));\n }\n\n //#endregion\n\n //#region Public attributes and properties\n\n /**\n * Makes the control a readonly field.\n *\n * @attr readonly\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public readOnly = false;\n\n /**\n * The mask pattern of the component.\n *\n * @attr\n */\n @property()\n public set mask(value: string) {\n this._parser.mask = value;\n }\n\n public get mask(): string {\n return this._parser.mask;\n }\n\n /**\n * The prompt symbol to use for unfilled parts of the mask pattern.\n *\n * @attr\n * @default '_'\n */\n @property()\n public set prompt(value: string) {\n this._parser.prompt = value;\n }\n\n public get prompt(): string {\n return this._parser.prompt;\n }\n\n //#endregion\n\n //#region Event handlers\n\n protected async _handleInput({\n inputType,\n isComposing,\n }: InputEvent): Promise<void> {\n const value = this._input?.value ?? '';\n const { start, end } = this._maskSelection;\n const deletePosition = this._parser.getNextNonLiteralPosition(end) + 1;\n\n // Reachable only where `beforeinput` is not cancelable - normally the browser's\n // history commands are intercepted before they ever mutate the input.\n if (inputType === 'historyUndo' || inputType === 'historyRedo') {\n return this._historyStep(inputType === 'historyUndo' ? 'undo' : 'redo');\n }\n\n // A composing backspace is handled by the composition events instead.\n if (inputType === 'deleteContentBackward' && isComposing) {\n return;\n }\n\n const kind = MaskEditKinds.get(inputType ?? '');\n\n if (kind === undefined) {\n // A non-modeled mutation has already changed the input's DOM value, so re-render\n // to let the `live()` binding roll it back to the masked text. Never mid-IME\n // though - `insertCompositionText` fires repeatedly there and resetting the value\n // underneath the browser breaks composition outright.\n if (!isComposing) {\n this.requestUpdate();\n }\n return;\n }\n\n this._setTouchedState();\n\n switch (inputType) {\n case 'deleteContentForward': {\n await this._updateInput('', { start, end: deletePosition }, kind);\n this._input?.setSelectionRange(deletePosition, deletePosition);\n // `_updateInput` settled on the parser's cursor, but the caret actually ends up\n // past the deleted character - record that so a run of deletes coalesces.\n this._history.settle(this._historyText, deletePosition);\n return;\n }\n\n case 'deleteContentBackward':\n return this._updateInput(\n '',\n {\n start: this._parser.getPreviousNonLiteralPosition(\n this._inputSelection.start + 1\n ),\n end,\n },\n kind\n );\n\n case 'deleteByCut':\n return this._updateInput('', this._maskSelection, kind);\n\n case 'insertText':\n return this._updateInput(\n value.substring(start, this._inputSelection.end),\n this._maskSelection,\n kind\n );\n\n case 'insertFromPaste':\n return this._updateInput(\n value.substring(start, this._inputSelection.end),\n {\n start,\n end: this._inputSelection.start,\n },\n kind\n );\n\n case 'insertFromDrop':\n // An external drop is preceded by no `dragstart`, so `_maskSelection` is stale.\n return this._updateInput(\n value.substring(\n this._inputSelection.start,\n this._inputSelection.end\n ),\n { ...this._inputSelection },\n kind,\n {\n start: this._inputSelection.start,\n end: this._inputSelection.start,\n }\n );\n\n // Potential browser auto-fill behavior\n case undefined:\n case '':\n return this._updateInput(\n this._parser.parse(\n value.substring(start, this._inputSelection.end)\n ),\n {\n start,\n end: this._inputSelection.end,\n },\n kind,\n { start, end: start }\n );\n }\n }\n\n /**\n * Default mask-update routine. Re-applies the parser, commits the result through\n * {@link MaskBehaviorElementInterface._commitMaskedValue} and emits an input event\n * when the edit is not at the trailing mask boundary.\n */\n protected async _updateInput(\n text: string,\n range: MaskSelection,\n kind: MaskEditKind = 'atomic',\n caretBefore?: MaskSelection\n ): Promise<void> {\n const { value, end } = this._parser.replace(\n this._maskedValue,\n text,\n range.start,\n range.end\n );\n\n this._recordHistory(kind, value, end, caretBefore ?? this._maskSelection);\n this._commitMaskedValue(value);\n this.requestUpdate();\n\n if (range.start !== this._parser.mask.length) {\n this._emitInputEvent();\n }\n\n await this.updateComplete;\n this._input?.setSelectionRange(end, end);\n }\n\n /**\n * Writes a fully-formed masked text into the component's value pipeline.\n *\n * This is the one step where the leaves genuinely differ - `igc-mask-input` commits\n * straight to its form value, while the date editors keep the text as a draft until\n * blur - so it is also the only thing undo/redo has to delegate.\n */\n protected _commitMaskedValue(value: string): void {\n this._maskedValue = value;\n this._syncValueFromMask();\n }\n\n /**\n * Emits an `igcInput` event with the current masked value as detail.\n * Override to emit a different payload (e.g. the parsed value).\n */\n protected _emitInputEvent(): void {\n this._emitTouchedEvent('igcInput', { detail: this._maskedValue });\n }\n\n protected _setMaskSelection(event: Event): void {\n this._maskSelection = this._inputSelection;\n if (event instanceof KeyboardEvent) {\n this._handleEnterKeydown(event);\n }\n }\n\n protected _handleCompositionStart(): void {\n this._compositionStart = this._inputSelection.start;\n }\n\n protected _handleCompositionEnd({ data }: CompositionEvent): void {\n // The whole composed sequence is one undo step, anchored where it began.\n this._updateInput(\n data,\n { start: this._compositionStart, end: this._inputSelection.end },\n 'atomic',\n { start: this._compositionStart, end: this._compositionStart }\n );\n }\n\n protected _handleClick(): void {\n const { selectionStart: start, selectionEnd: end } = this._input ?? {\n selectionStart: 0,\n selectionEnd: 0,\n };\n\n // Clicking at the end of the input field will select the entire mask\n if (start === end && start === this._maskedValue.length) {\n this.select();\n }\n }\n\n /**\n * Intercepts the browser's own history commands - the Edit and context menus, and\n * the software keyboard on mobile - which never reach the key bindings. The native\n * stack is empty anyway, so letting one through would only de-sync the input's DOM\n * value from the masked text.\n */\n protected _handleBeforeInput(event: InputEvent): void {\n const { inputType } = event;\n\n if (inputType !== 'historyUndo' && inputType !== 'historyRedo') {\n return;\n }\n\n event.preventDefault();\n\n if (!this.readOnly) {\n this._historyStep(inputType === 'historyUndo' ? 'undo' : 'redo');\n }\n }\n\n //#endregion\n\n //#region Undo/redo\n\n /**\n * Snapshots the current masked text before `next` replaces it, then reports where the\n * caret ends up. Must be called *before* the text is committed.\n *\n * Only a real change earns an undo step: a character the mask rejects, a backspace at\n * position zero or a spin that hit a boundary would otherwise leave behind a step\n * that appears to do nothing when undone.\n */\n protected _recordHistory(\n kind: MaskEditKind,\n next: string,\n caret: number,\n selection: MaskSelection = this._inputSelection\n ): void {\n const previous = this._historyText;\n\n if (next !== previous) {\n this._history.record(kind, { value: previous, ...selection });\n }\n\n this._history.settle(next, caret);\n }\n\n /** Reconciles the history with the current masked text. */\n protected _historyResync(): void {\n this._history.resync(this._historyText);\n }\n\n /** Restores the neighboring history state in the given direction. */\n protected async _historyStep(direction: 'undo' | 'redo'): Promise<void> {\n if (this.readOnly) {\n return;\n }\n\n const current: MaskHistoryState = {\n value: this._historyText,\n ...this._inputSelection,\n };\n\n const state =\n direction === 'undo'\n ? this._history.undo(current)\n : this._history.redo(current);\n\n if (!state) {\n return;\n }\n\n this._setTouchedState();\n this._commitMaskedValue(state.value);\n this.requestUpdate();\n\n // Native inputs announce an undo as an `input` event, and the composite hosts\n // (`igc-date-picker`, `igc-date-range-picker`) read the draft value from ours.\n this._emitInputEvent();\n\n await this.updateComplete;\n\n // Through the mixin method, since the input's own keydown handler has already\n // overwritten `_maskSelection` with the caret as it was before the restore.\n this.setSelectionRange(state.start, state.end);\n }\n\n //#endregion\n\n //#region Public methods\n\n /* blazorSuppress */\n /** Sets the text selection range of the control */\n public setSelectionRange(\n start?: number,\n end?: number,\n direction: SelectionRangeDirection = 'none'\n ): void {\n this._input?.setSelectionRange(start ?? null, end ?? null, direction);\n this._maskSelection = { start: start ?? 0, end: end ?? 0 };\n }\n\n /* blazorSuppress */\n /** Replaces the selected text in the control and re-applies the mask */\n public setRangeText(\n replacement: string,\n start?: number,\n end?: number,\n selectMode?: RangeTextSelectMode\n ): void {\n const current = this._inputSelection;\n const _start = start ?? current.start;\n const _end = end ?? current.end;\n\n const result = this._parser.replace(\n this._maskedValue || this._parser.emptyMask,\n replacement,\n _start,\n _end\n );\n const next = this._parser.apply(this._parser.parse(result.value));\n\n this._recordHistory('atomic', next, _start, current);\n this._commitMaskedValue(next);\n\n this.updateComplete.then(() => {\n switch (selectMode) {\n case 'select':\n this.setSelectionRange(_start, _end);\n break;\n case 'start':\n this.setSelectionRange(_start, _start);\n break;\n case 'end':\n this.setSelectionRange(_end, _end);\n break;\n default:\n this.setSelectionRange(current.start, current.end);\n }\n });\n }\n\n //#endregion\n }\n\n return MaskBehaviorElement as unknown as AbstractConstructor<MaskBehaviorElementInterface> &\n T;\n}\n"]}
|
|
@@ -13,6 +13,10 @@ export class IgcBaseOptionLikeComponent extends LitElement {
|
|
|
13
13
|
this._internals = addInternalsController(this, {
|
|
14
14
|
initialARIA: { role: 'option' },
|
|
15
15
|
reflectRole: true,
|
|
16
|
+
aria: () => ({
|
|
17
|
+
ariaDisabled: `${this.disabled}`,
|
|
18
|
+
ariaSelected: `${this.selected}`,
|
|
19
|
+
}),
|
|
16
20
|
});
|
|
17
21
|
this._active = false;
|
|
18
22
|
this._disabled = false;
|
|
@@ -29,14 +33,12 @@ export class IgcBaseOptionLikeComponent extends LitElement {
|
|
|
29
33
|
}
|
|
30
34
|
set disabled(value) {
|
|
31
35
|
this._disabled = Boolean(value);
|
|
32
|
-
this._internals.setARIA({ ariaDisabled: `${this.disabled}` });
|
|
33
36
|
}
|
|
34
37
|
get disabled() {
|
|
35
38
|
return this._disabled;
|
|
36
39
|
}
|
|
37
40
|
set selected(value) {
|
|
38
41
|
this._selected = Boolean(value);
|
|
39
|
-
this._internals.setARIA({ ariaSelected: `${this._selected}` });
|
|
40
42
|
this.active = this.selected;
|
|
41
43
|
}
|
|
42
44
|
get selected() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"option.js","sourceRoot":"","sources":["../../../src/internals/mixins/option.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAGrE,MAAM,OAAgB,0BAA2B,SAAQ,UAAU;IAAnE;;QACqB,eAAU,GAAG,sBAAsB,CAAC,IAAI,EAAE;YAC3D,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC/B,WAAW,EAAE,IAAI;
|
|
1
|
+
{"version":3,"file":"option.js","sourceRoot":"","sources":["../../../src/internals/mixins/option.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAGrE,MAAM,OAAg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CAAC;IACtB,CAAC;IAED,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC;IAC3D,CAAC;IAEkB,MAAM;QACvB,OAAO,IAAI,CAAA;;;;;;;;;;KAUV,CAAC;IACJ,CAAC;CACF;AA1EoB;IADlB,kBAAkB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4DACO;AAW7C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wDAG1C;AAWD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0DAG1C;AAWD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0DAI1C;AAaD;IADC,QAAQ,EAAE;uDAGV","sourcesContent":["import { html, LitElement } from 'lit';\nimport { property, queryAssignedNodes } from 'lit/decorators.js';\nimport { addInternalsController } from '../controllers/internals.js';\n\n/* omitModule */\nexport abstract class IgcBaseOptionLikeComponent extends LitElement {\n protected readonly _internals = addInternalsController(this, {\n initialARIA: { role: 'option' },\n reflectRole: true,\n aria: () => ({\n ariaDisabled: `${this.disabled}`,\n ariaSelected: `${this.selected}`,\n }),\n });\n\n protected _active = false;\n protected _disabled = false;\n protected _selected = false;\n protected _value!: string;\n\n @queryAssignedNodes({ flatten: true })\n protected readonly _content!: Array<Element>;\n\n protected get _contentSlotText(): string {\n return this._content.map((node) => node.textContent).join('');\n }\n\n /**\n * Whether the item is active.\n * @attr\n */\n @property({ type: Boolean, reflect: true })\n public set active(value: boolean) {\n this._active = Boolean(value);\n }\n\n public get active(): boolean {\n return this._active;\n }\n\n /**\n * Whether the item is disabled.\n * @attr\n */\n @property({ type: Boolean, reflect: true })\n public set disabled(value: boolean) {\n this._disabled = Boolean(value);\n }\n\n public get disabled(): boolean {\n return this._disabled;\n }\n\n /**\n * Whether the item is selected.\n * @attr\n */\n @property({ type: Boolean, reflect: true })\n public set selected(value: boolean) {\n this._selected = Boolean(value);\n this.active = this.selected;\n }\n\n public get selected(): boolean {\n return this._selected;\n }\n\n /**\n * The current value of the item.\n * If not specified, the element's text content is used.\n *\n * @attr\n */\n @property()\n public set value(value: string) {\n this._value = value;\n }\n\n public get value(): string {\n return this._value ? this._value : this._contentSlotText;\n }\n\n protected override render() {\n return html`\n <section part=\"prefix\">\n <slot name=\"prefix\"></slot>\n </section>\n <section part=\"content\">\n <slot></slot>\n </section>\n <section part=\"suffix\">\n <slot name=\"suffix\"></slot>\n </section>\n `;\n }\n}\n"]}
|
|
@@ -18,7 +18,7 @@ export interface MaskedInputOptions {
|
|
|
18
18
|
/** When provided, sets the `tabindex` attribute. */
|
|
19
19
|
tabindex?: number;
|
|
20
20
|
/**
|
|
21
|
-
* Resolved ARIA bindings for the native input
|
|
21
|
+
* Resolved ARIA bindings for the native input - the projected host state
|
|
22
22
|
* merged with the editor's own (see `AriaTargetController.resolveBindings`).
|
|
23
23
|
*/
|
|
24
24
|
aria: ResolvedARIABindings;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"masked-input.js","sourceRoot":"","sources":["../../../src/internals/templates/masked-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EACL,YAAY,GAEb,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAiDzC,MAAM,UAAU,uBAAuB,CACrC,IAAwB;IAExB,OAAO,IAAI,CAAA;;WAEF,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;;aAEhB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;aACvB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;eAClB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;qBACV,IAAI,CAAC,WAAW;kBACnB,IAAI,CAAC,QAAQ;kBACb,IAAI,CAAC,QAAQ;mBACZ,IAAI,CAAC,SAAS;kBACf,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;iBAC1B,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC;QACrD,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;eAChB,IAAI,CAAC,OAAO;qBACN,IAAI,CAAC,aAAa;eACxB,IAAI,CAAC,OAAO;cACb,IAAI,CAAC,MAAM;eACV,IAAI,CAAC,OAAO;iBACV,IAAI,CAAC,kBAAkB;aAC3B,IAAI,CAAC,kBAAkB;mBACjB,IAAI,CAAC,kBAAkB;0BAChB,IAAI,CAAC,kBAAkB;wBACzB,IAAI,CAAC,gBAAgB;gBAC7B,IAAI,CAAC,QAAQ;eACd,IAAI,CAAC,OAAO;mBACR,IAAI,CAAC,WAAW;mBAChB,IAAI,CAAC,WAAW;;GAEhC,CAAC;AACJ,CAAC","sourcesContent":["import { html, type TemplateResult } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport {\n ariaBindings,\n type ResolvedARIABindings,\n} from '../controllers/aria-projection.js';\nimport { partMap } from '../part-map.js';\nimport { bindIf } from '../utils/lit.js';\n\nexport interface MaskedInputOptions {\n /** Optional id for the native input element. */\n id?: string;\n /** Resolved part-name map applied to the input. */\n partNames: Record<string, boolean>;\n /** The form-associated name attribute. */\n name?: string;\n /** Current value to render through `live()`. */\n value: string;\n /** Pre-resolved placeholder text. Caller decides empty-string semantics. */\n placeholder: string;\n readOnly: boolean;\n disabled: boolean;\n autofocus?: boolean;\n inputMode?: string;\n /** When provided, sets the `tabindex` attribute. */\n tabindex?: number;\n /**\n * Resolved ARIA bindings for the native input
|
|
1
|
+
{"version":3,"file":"masked-input.js","sourceRoot":"","sources":["../../../src/internals/templates/masked-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EACL,YAAY,GAEb,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAiDzC,MAAM,UAAU,uBAAuB,CACrC,IAAwB;IAExB,OAAO,IAAI,CAAA;;WAEF,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;;aAEhB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;aACvB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;eAClB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;qBACV,IAAI,CAAC,WAAW;kBACnB,IAAI,CAAC,QAAQ;kBACb,IAAI,CAAC,QAAQ;mBACZ,IAAI,CAAC,SAAS;kBACf,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;iBAC1B,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC;QACrD,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;eAChB,IAAI,CAAC,OAAO;qBACN,IAAI,CAAC,aAAa;eACxB,IAAI,CAAC,OAAO;cACb,IAAI,CAAC,MAAM;eACV,IAAI,CAAC,OAAO;iBACV,IAAI,CAAC,kBAAkB;aAC3B,IAAI,CAAC,kBAAkB;mBACjB,IAAI,CAAC,kBAAkB;0BAChB,IAAI,CAAC,kBAAkB;wBACzB,IAAI,CAAC,gBAAgB;gBAC7B,IAAI,CAAC,QAAQ;eACd,IAAI,CAAC,OAAO;mBACR,IAAI,CAAC,WAAW;mBAChB,IAAI,CAAC,WAAW;;GAEhC,CAAC;AACJ,CAAC","sourcesContent":["import { html, type TemplateResult } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport {\n ariaBindings,\n type ResolvedARIABindings,\n} from '../controllers/aria-projection.js';\nimport { partMap } from '../part-map.js';\nimport { bindIf } from '../utils/lit.js';\n\nexport interface MaskedInputOptions {\n /** Optional id for the native input element. */\n id?: string;\n /** Resolved part-name map applied to the input. */\n partNames: Record<string, boolean>;\n /** The form-associated name attribute. */\n name?: string;\n /** Current value to render through `live()`. */\n value: string;\n /** Pre-resolved placeholder text. Caller decides empty-string semantics. */\n placeholder: string;\n readOnly: boolean;\n disabled: boolean;\n autofocus?: boolean;\n inputMode?: string;\n /** When provided, sets the `tabindex` attribute. */\n tabindex?: number;\n /**\n * Resolved ARIA bindings for the native input - the projected host state\n * merged with the editor's own (see `AriaTargetController.resolveBindings`).\n */\n aria: ResolvedARIABindings;\n\n // Required mask handlers\n onInput: (event: InputEvent) => void;\n /** Wired to `beforeinput` so the component owns `historyUndo` / `historyRedo`. */\n onBeforeInput: (event: InputEvent) => void;\n onFocus: (event: FocusEvent) => void;\n onBlur: (event: FocusEvent) => void;\n onClick: () => void;\n /** Wired to `keydown`, `cut`, and `dragstart` to capture the current selection. */\n onSetMaskSelection: (event: Event) => void;\n onCompositionStart: () => void;\n onCompositionEnd: (event: CompositionEvent) => void;\n\n // Optional handlers\n onChange?: () => void;\n onWheel?: (event: WheelEvent) => void;\n onDragEnter?: () => void;\n onDragLeave?: () => void;\n}\n\n/**\n * Renders the native `<input>` element shared by mask-driven components\n * (`igc-mask-input`, `igc-date-time-input`, `igc-date-range-input`).\n * Centralizes mask event wiring so leaves only describe their extras.\n */\nexport function renderMaskedNativeInput(\n opts: MaskedInputOptions\n): TemplateResult {\n return html`\n <input\n id=${ifDefined(opts.id)}\n type=\"text\"\n part=${partMap(opts.partNames)}\n name=${ifDefined(opts.name)}\n .value=${live(opts.value)}\n .placeholder=${opts.placeholder}\n ?readonly=${opts.readOnly}\n ?disabled=${opts.disabled}\n ?autofocus=${opts.autofocus}\n inputmode=${ifDefined(opts.inputMode)}\n tabindex=${bindIf(opts.tabindex != null, opts.tabindex)}\n ${ariaBindings(opts.aria)}\n @input=${opts.onInput}\n @beforeinput=${opts.onBeforeInput}\n @focus=${opts.onFocus}\n @blur=${opts.onBlur}\n @click=${opts.onClick}\n @keydown=${opts.onSetMaskSelection}\n @cut=${opts.onSetMaskSelection}\n @dragstart=${opts.onSetMaskSelection}\n @compositionstart=${opts.onCompositionStart}\n @compositionend=${opts.onCompositionEnd}\n @change=${opts.onChange}\n @wheel=${opts.onWheel}\n @dragenter=${opts.onDragEnter}\n @dragleave=${opts.onDragLeave}\n />\n `;\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
import '../../components/icon/icon.js';
|
|
3
|
+
export interface SlottedIconOptions {
|
|
4
|
+
/** The name of the slot that overrides the default icon. */
|
|
5
|
+
slot: string;
|
|
6
|
+
/** The registry name of the default icon rendered as fallback content. */
|
|
7
|
+
icon: string;
|
|
8
|
+
/** Controls the `hidden` attribute of the slot element. */
|
|
9
|
+
hidden?: boolean;
|
|
10
|
+
/** The `title` of the default icon. */
|
|
11
|
+
title?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The accessible label of the default icon. When set, the icon is exposed
|
|
14
|
+
* to the accessibility tree with that label instead of being `aria-hidden`.
|
|
15
|
+
*/
|
|
16
|
+
label?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether an unlabeled default icon carries `aria-hidden="true"`.
|
|
19
|
+
* Pass false when an ancestor element already hides the icon from the
|
|
20
|
+
* accessibility tree.
|
|
21
|
+
*
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
ariaHidden?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Renders a named slot with a default icon from the internal collection as
|
|
28
|
+
* fallback content - the "overridable built-in control" idiom of the library.
|
|
29
|
+
* Callers own the wrapping element with its parts, visibility gating and
|
|
30
|
+
* event handlers, and must register the icon component themselves.
|
|
31
|
+
*/
|
|
32
|
+
export declare function renderSlottedIcon(options: SlottedIconOptions): TemplateResult;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
3
|
+
import '../../components/icon/icon.js';
|
|
4
|
+
import { bindIf } from '../utils/lit.js';
|
|
5
|
+
export function renderSlottedIcon(options) {
|
|
6
|
+
const ariaHidden = options.label ? false : (options.ariaHidden ?? true);
|
|
7
|
+
return html `
|
|
8
|
+
<slot name=${options.slot} ?hidden=${options.hidden ?? false}>
|
|
9
|
+
<igc-icon
|
|
10
|
+
name=${options.icon}
|
|
11
|
+
collection="default"
|
|
12
|
+
title=${ifDefined(options.title)}
|
|
13
|
+
aria-label=${ifDefined(options.label)}
|
|
14
|
+
aria-hidden=${bindIf(ariaHidden, 'true')}
|
|
15
|
+
></igc-icon>
|
|
16
|
+
</slot>
|
|
17
|
+
`;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=slotted-icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slotted-icon.js","sourceRoot":"","sources":["../../../src/internals/templates/slotted-icon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD,OAAO,+BAA+B,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAgCzC,MAAM,UAAU,iBAAiB,CAAC,OAA2B;IAC3D,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC;IAExE,OAAO,IAAI,CAAA;iBACI,OAAO,CAAC,IAAI,YAAY,OAAO,CAAC,MAAM,IAAI,KAAK;;eAEjD,OAAO,CAAC,IAAI;;gBAEX,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;qBACnB,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;sBACvB,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC;;;GAG7C,CAAC;AACJ,CAAC","sourcesContent":["import { html, type TemplateResult } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n// The import satisfies the lit-analyzer element resolution for `igc-icon`.\n// It carries no side effects - registration stays with the consuming components.\nimport '../../components/icon/icon.js';\nimport { bindIf } from '../utils/lit.js';\n\nexport interface SlottedIconOptions {\n /** The name of the slot that overrides the default icon. */\n slot: string;\n /** The registry name of the default icon rendered as fallback content. */\n icon: string;\n /** Controls the `hidden` attribute of the slot element. */\n hidden?: boolean;\n /** The `title` of the default icon. */\n title?: string;\n /**\n * The accessible label of the default icon. When set, the icon is exposed\n * to the accessibility tree with that label instead of being `aria-hidden`.\n */\n label?: string;\n /**\n * Whether an unlabeled default icon carries `aria-hidden=\"true\"`.\n * Pass false when an ancestor element already hides the icon from the\n * accessibility tree.\n *\n * @default true\n */\n ariaHidden?: boolean;\n}\n\n/**\n * Renders a named slot with a default icon from the internal collection as\n * fallback content - the \"overridable built-in control\" idiom of the library.\n * Callers own the wrapping element with its parts, visibility gating and\n * event handlers, and must register the icon component themselves.\n */\nexport function renderSlottedIcon(options: SlottedIconOptions): TemplateResult {\n const ariaHidden = options.label ? false : (options.ariaHidden ?? true);\n\n return html`\n <slot name=${options.slot} ?hidden=${options.hidden ?? false}>\n <igc-icon\n name=${options.icon}\n collection=\"default\"\n title=${ifDefined(options.title)}\n aria-label=${ifDefined(options.label)}\n aria-hidden=${bindIf(ariaHidden, 'true')}\n ></igc-icon>\n </slot>\n `;\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
export interface ToggleShellOptions {
|
|
3
|
+
/** The type of the native input element. */
|
|
4
|
+
type: 'checkbox' | 'radio';
|
|
5
|
+
/** The id of the native input; the wrapping label points at it through `for`. */
|
|
6
|
+
inputId: string;
|
|
7
|
+
/** The id of the label span, the fallback `aria-labelledby` target. */
|
|
8
|
+
labelId: string;
|
|
9
|
+
/** Resolved part-name map for the wrapping label element. */
|
|
10
|
+
baseParts: Record<string, boolean>;
|
|
11
|
+
/** Resolved part-name map for the control span. */
|
|
12
|
+
controlParts: Record<string, boolean>;
|
|
13
|
+
/** Resolved part-name map for the label span. */
|
|
14
|
+
labelParts: Record<string, boolean>;
|
|
15
|
+
/** Renders the control indicator inside the control span. */
|
|
16
|
+
renderControl: () => TemplateResult;
|
|
17
|
+
/** Current checked state rendered through `live()`. */
|
|
18
|
+
checked: boolean;
|
|
19
|
+
/** Hides the label span when the default slot has no assigned content. */
|
|
20
|
+
hideLabel: boolean;
|
|
21
|
+
name?: string;
|
|
22
|
+
value?: string;
|
|
23
|
+
required: boolean;
|
|
24
|
+
disabled: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Current indeterminate state rendered through `live()`. When absent, the
|
|
27
|
+
* binding stays `false` and `live()` skips the property write entirely.
|
|
28
|
+
*/
|
|
29
|
+
indeterminate?: boolean;
|
|
30
|
+
/** When provided, sets the `tabindex` attribute. */
|
|
31
|
+
tabindex?: number;
|
|
32
|
+
/** Resolved `aria-labelledby` target - an external id or `labelId`. */
|
|
33
|
+
ariaLabelledBy: string;
|
|
34
|
+
/** When provided, sets the `aria-describedby` attribute. */
|
|
35
|
+
ariaDescribedBy?: string;
|
|
36
|
+
onClick: (event: PointerEvent) => void;
|
|
37
|
+
onKeyDown: (event: KeyboardEvent) => void;
|
|
38
|
+
onBlur?: () => void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Renders the label-wrapped native input shared by the toggle controls
|
|
42
|
+
* (`igc-checkbox`, `igc-switch`, `igc-radio`).
|
|
43
|
+
* Centralizes the input binding set so leaves only describe their part maps
|
|
44
|
+
* and control indicator.
|
|
45
|
+
*/
|
|
46
|
+
export declare function renderToggleShell(options: ToggleShellOptions): TemplateResult;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { html, nothing } from 'lit';
|
|
2
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
3
|
+
import { live } from 'lit/directives/live.js';
|
|
4
|
+
import { partMap } from '../part-map.js';
|
|
5
|
+
import { bindIf } from '../utils/lit.js';
|
|
6
|
+
export function renderToggleShell(options) {
|
|
7
|
+
return html `
|
|
8
|
+
<label part=${partMap(options.baseParts)} for=${options.inputId}>
|
|
9
|
+
<input
|
|
10
|
+
id=${options.inputId}
|
|
11
|
+
type=${options.type}
|
|
12
|
+
name=${ifDefined(options.name)}
|
|
13
|
+
value=${ifDefined(options.value)}
|
|
14
|
+
?required=${options.required}
|
|
15
|
+
?disabled=${options.disabled}
|
|
16
|
+
.checked=${live(options.checked)}
|
|
17
|
+
.indeterminate=${live(options.indeterminate ?? false)}
|
|
18
|
+
tabindex=${bindIf(options.tabindex != null, options.tabindex)}
|
|
19
|
+
aria-labelledby=${options.ariaLabelledBy}
|
|
20
|
+
aria-describedby=${ifDefined(options.ariaDescribedBy)}
|
|
21
|
+
@keydown=${options.onKeyDown}
|
|
22
|
+
@click=${options.onClick}
|
|
23
|
+
@blur=${options.onBlur ?? nothing}
|
|
24
|
+
/>
|
|
25
|
+
<span part=${partMap(options.controlParts)}
|
|
26
|
+
>${options.renderControl()}</span
|
|
27
|
+
>
|
|
28
|
+
<span
|
|
29
|
+
id=${options.labelId}
|
|
30
|
+
part=${partMap(options.labelParts)}
|
|
31
|
+
?hidden=${options.hideLabel}
|
|
32
|
+
>
|
|
33
|
+
<slot></slot>
|
|
34
|
+
</span>
|
|
35
|
+
</label>
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=toggle-shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle-shell.js","sourceRoot":"","sources":["../../../src/internals/templates/toggle-shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAgDzC,MAAM,UAAU,iBAAiB,CAAC,OAA2B;IAC3D,OAAO,IAAI,CAAA;kBACK,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,OAAO,CAAC,OAAO;;aAEtD,OAAO,CAAC,OAAO;eACb,OAAO,CAAC,IAAI;eACZ,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;gBACtB,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;oBACpB,OAAO,CAAC,QAAQ;oBAChB,OAAO,CAAC,QAAQ;mBACjB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;yBACf,IAAI,CAAC,OAAO,CAAC,aAAa,IAAI,KAAK,CAAC;mBAC1C,MAAM,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC;0BAC3C,OAAO,CAAC,cAAc;2BACrB,SAAS,CAAC,OAAO,CAAC,eAAe,CAAC;mBAC1C,OAAO,CAAC,SAAS;iBACnB,OAAO,CAAC,OAAO;gBAChB,OAAO,CAAC,MAAM,IAAI,OAAO;;mBAEtB,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;WACrC,OAAO,CAAC,aAAa,EAAE;;;aAGrB,OAAO,CAAC,OAAO;eACb,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;kBACxB,OAAO,CAAC,SAAS;;;;;GAKhC,CAAC;AACJ,CAAC","sourcesContent":["import { html, nothing, type TemplateResult } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { partMap } from '../part-map.js';\nimport { bindIf } from '../utils/lit.js';\n\nexport interface ToggleShellOptions {\n /** The type of the native input element. */\n type: 'checkbox' | 'radio';\n /** The id of the native input; the wrapping label points at it through `for`. */\n inputId: string;\n /** The id of the label span, the fallback `aria-labelledby` target. */\n labelId: string;\n /** Resolved part-name map for the wrapping label element. */\n baseParts: Record<string, boolean>;\n /** Resolved part-name map for the control span. */\n controlParts: Record<string, boolean>;\n /** Resolved part-name map for the label span. */\n labelParts: Record<string, boolean>;\n /** Renders the control indicator inside the control span. */\n renderControl: () => TemplateResult;\n /** Current checked state rendered through `live()`. */\n checked: boolean;\n /** Hides the label span when the default slot has no assigned content. */\n hideLabel: boolean;\n name?: string;\n value?: string;\n required: boolean;\n disabled: boolean;\n /**\n * Current indeterminate state rendered through `live()`. When absent, the\n * binding stays `false` and `live()` skips the property write entirely.\n */\n indeterminate?: boolean;\n /** When provided, sets the `tabindex` attribute. */\n tabindex?: number;\n /** Resolved `aria-labelledby` target - an external id or `labelId`. */\n ariaLabelledBy: string;\n /** When provided, sets the `aria-describedby` attribute. */\n ariaDescribedBy?: string;\n\n onClick: (event: PointerEvent) => void;\n onKeyDown: (event: KeyboardEvent) => void;\n onBlur?: () => void;\n}\n\n/**\n * Renders the label-wrapped native input shared by the toggle controls\n * (`igc-checkbox`, `igc-switch`, `igc-radio`).\n * Centralizes the input binding set so leaves only describe their part maps\n * and control indicator.\n */\nexport function renderToggleShell(options: ToggleShellOptions): TemplateResult {\n return html`\n <label part=${partMap(options.baseParts)} for=${options.inputId}>\n <input\n id=${options.inputId}\n type=${options.type}\n name=${ifDefined(options.name)}\n value=${ifDefined(options.value)}\n ?required=${options.required}\n ?disabled=${options.disabled}\n .checked=${live(options.checked)}\n .indeterminate=${live(options.indeterminate ?? false)}\n tabindex=${bindIf(options.tabindex != null, options.tabindex)}\n aria-labelledby=${options.ariaLabelledBy}\n aria-describedby=${ifDefined(options.ariaDescribedBy)}\n @keydown=${options.onKeyDown}\n @click=${options.onClick}\n @blur=${options.onBlur ?? nothing}\n />\n <span part=${partMap(options.controlParts)}\n >${options.renderControl()}</span\n >\n <span\n id=${options.labelId}\n part=${partMap(options.labelParts)}\n ?hidden=${options.hideLabel}\n >\n <slot></slot>\n </span>\n </label>\n `;\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A restartable timeout handle. See {@link createTimer}.
|
|
3
|
+
*/
|
|
4
|
+
export type Timer = {
|
|
5
|
+
/** Whether the timer is currently armed. */
|
|
6
|
+
readonly active: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* (Re)arms the timer, canceling a previously armed run.
|
|
9
|
+
*
|
|
10
|
+
* When `delay` is omitted, the default delay of the timer is used.
|
|
11
|
+
*/
|
|
12
|
+
start(delay?: number): void;
|
|
13
|
+
/** Cancels the armed run, if any. */
|
|
14
|
+
stop(): void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Creates a restartable timeout around `callback`.
|
|
18
|
+
*
|
|
19
|
+
* Every `start` supersedes the previous one, so the callback runs at most once,
|
|
20
|
+
* `delay` milliseconds after the most recent `start` - the recurring
|
|
21
|
+
* "clear the stored handle, then set it again" bookkeeping is kept in one place.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const timer = createTimer(() => this.hideTooltip(), 500);
|
|
26
|
+
*
|
|
27
|
+
* timer.start(); // arms the timer with the default delay
|
|
28
|
+
* timer.start(1000); // supersedes the run above
|
|
29
|
+
* timer.stop(); // cancels it altogether
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function createTimer(callback: () => void, defaultDelay?: number): Timer;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function createTimer(callback, defaultDelay = 0) {
|
|
2
|
+
let handle;
|
|
3
|
+
return {
|
|
4
|
+
get active() {
|
|
5
|
+
return handle !== undefined;
|
|
6
|
+
},
|
|
7
|
+
start(delay = defaultDelay) {
|
|
8
|
+
clearTimeout(handle);
|
|
9
|
+
handle = setTimeout(() => {
|
|
10
|
+
handle = undefined;
|
|
11
|
+
callback();
|
|
12
|
+
}, delay);
|
|
13
|
+
},
|
|
14
|
+
stop() {
|
|
15
|
+
clearTimeout(handle);
|
|
16
|
+
handle = undefined;
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=timing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timing.js","sourceRoot":"","sources":["../../src/internals/timing.ts"],"names":[],"mappings":"AAgCA,MAAM,UAAU,WAAW,CAAC,QAAoB,EAAE,YAAY,GAAG,CAAC;IAChE,IAAI,MAAiD,CAAC;IAEtD,OAAO;QACL,IAAI,MAAM;YACR,OAAO,MAAM,KAAK,SAAS,CAAC;QAC9B,CAAC;QACD,KAAK,CAAC,KAAK,GAAG,YAAY;YACxB,YAAY,CAAC,MAAM,CAAC,CAAC;YACrB,MAAM,GAAG,UAAU,CAAC,GAAG,EAAE;gBACvB,MAAM,GAAG,SAAS,CAAC;gBACnB,QAAQ,EAAE,CAAC;YACb,CAAC,EAAE,KAAK,CAAC,CAAC;QACZ,CAAC;QACD,IAAI;YACF,YAAY,CAAC,MAAM,CAAC,CAAC;YACrB,MAAM,GAAG,SAAS,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * A restartable timeout handle. See {@link createTimer}.\n */\nexport type Timer = {\n /** Whether the timer is currently armed. */\n readonly active: boolean;\n /**\n * (Re)arms the timer, canceling a previously armed run.\n *\n * When `delay` is omitted, the default delay of the timer is used.\n */\n start(delay?: number): void;\n /** Cancels the armed run, if any. */\n stop(): void;\n};\n\n/**\n * Creates a restartable timeout around `callback`.\n *\n * Every `start` supersedes the previous one, so the callback runs at most once,\n * `delay` milliseconds after the most recent `start` - the recurring\n * \"clear the stored handle, then set it again\" bookkeeping is kept in one place.\n *\n * @example\n * ```typescript\n * const timer = createTimer(() => this.hideTooltip(), 500);\n *\n * timer.start(); // arms the timer with the default delay\n * timer.start(1000); // supersedes the run above\n * timer.stop(); // cancels it altogether\n * ```\n */\nexport function createTimer(callback: () => void, defaultDelay = 0): Timer {\n let handle: ReturnType<typeof setTimeout> | undefined;\n\n return {\n get active(): boolean {\n return handle !== undefined;\n },\n start(delay = defaultDelay): void {\n clearTimeout(handle);\n handle = setTimeout(() => {\n handle = undefined;\n callback();\n }, delay);\n },\n stop(): void {\n clearTimeout(handle);\n handle = undefined;\n },\n };\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Returns the first element of the given array.
|
|
3
3
|
*
|
|
4
4
|
* @remarks
|
|
5
|
-
* Assumes a non-empty array
|
|
5
|
+
* Assumes a non-empty array - for an empty one it returns `undefined`
|
|
6
6
|
* typed as `T`.
|
|
7
7
|
*/
|
|
8
8
|
export declare function firstOf<T>(arr: T[]): T;
|
|
@@ -10,7 +10,7 @@ export declare function firstOf<T>(arr: T[]): T;
|
|
|
10
10
|
* Returns the last element of the given array.
|
|
11
11
|
*
|
|
12
12
|
* @remarks
|
|
13
|
-
* Assumes a non-empty array
|
|
13
|
+
* Assumes a non-empty array - for an empty one it returns `undefined`
|
|
14
14
|
* typed as `T`.
|
|
15
15
|
*/
|
|
16
16
|
export declare function lastOf<T>(arr: T[]): T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrays.js","sourceRoot":"","sources":["../../../src/internals/utils/arrays.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,OAAO,CAAI,GAAQ;IACjC,OAAO,GAAG,CAAC,EAAE,CAAC,CAAC,CAAM,CAAC;AACxB,CAAC;AASD,M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IAC/C,CAAC;IAED,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACzB,CAAC","sourcesContent":["/**\n * Returns the first element of the given array.\n *\n * @remarks\n * Assumes a non-empty array
|
|
1
|
+
{"version":3,"file":"arrays.js","sourceRoot":"","sources":["../../../src/internals/utils/arrays.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,OAAO,CAAI,GAAQ;IACjC,OAAO,GAAG,CAAC,EAAE,CAAC,CAAC,CAAM,CAAC;AACxB,CAAC;AASD,MAAM,UAAU,MAAM,CAAI,GAAQ;IAChC,OAAO,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAM,CAAC;AACzB,CAAC;AAYD,MAAM,SAAS,CAAC,CAAC,KAAK,CAAI,GAAQ,EAAE,IAAY;IAC9C,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;QAC1C,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAKD,MAAM,UAAU,OAAO,CACrB,CAAoC;IAEpC,OAAO,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;AACnD,CAAC;AAYD,MAAM,UAAU,OAAO,CAAI,KAAe;IACxC,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,EAAE,CAAC;IAC7B,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC;AAYD,MAAM,UAAU,SAAS,CACvB,KAAU,EACV,QAA+B;IAE/B,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,MAAM,KAAK,GAAQ,EAAE,CAAC;IAEtB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACzB,CAAC","sourcesContent":["/**\n * Returns the first element of the given array.\n *\n * @remarks\n * Assumes a non-empty array - for an empty one it returns `undefined`\n * typed as `T`.\n */\nexport function firstOf<T>(arr: T[]) {\n return arr.at(0) as T;\n}\n\n/**\n * Returns the last element of the given array.\n *\n * @remarks\n * Assumes a non-empty array - for an empty one it returns `undefined`\n * typed as `T`.\n */\nexport function lastOf<T>(arr: T[]) {\n return arr.at(-1) as T;\n}\n\n/**\n * Splits an array into chunks of a specified size and returns a generator that yields each chunk.\n *\n * @example\n * ```typescript\n * [...chunk([1, 2, 3, 4, 5], 2)]; // [[1, 2], [3, 4], [5]]\n * ```\n *\n * @throws If the `size` parameter is not a safe integer greater than or equal to 1.\n */\nexport function* chunk<T>(arr: T[], size: number): Generator<T[]> {\n if (!Number.isSafeInteger(size) || size < 1) {\n throw new Error('size must be an integer >= 1');\n }\n\n for (let i = 0; i < arr.length; i += size) {\n yield arr.slice(i, i + size);\n }\n}\n\n/**\n * Returns whether a given collection is empty.\n */\nexport function isEmpty<T, U extends object>(\n x: ArrayLike<T> | Set<T> | Map<U, T>\n): boolean {\n return 'length' in x ? x.length < 1 : x.size < 1;\n}\n\n/**\n * Ensures the given value is wrapped in an array. If the value is already an array, it is returned as-is. If the value is undefined, an empty array is returned.\n *\n * @example\n * ```typescript\n * asArray(5); // [5]\n * asArray([1, 2, 3]); // [1, 2, 3]\n * asArray(undefined); // []\n * ```\n */\nexport function asArray<T>(value?: T | T[]): T[] {\n if (value == null) return [];\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Splits an array into two based on a predicate function, returning a tuple of [truthy, falsy] arrays.\n *\n * @example\n * ```typescript\n * const [evens, odds] = partition([1, 2, 3, 4], x => x % 2 === 0);\n * console.log(evens); // [2, 4]\n * console.log(odds); // [1, 3]\n * ```\n */\nexport function partition<T>(\n array: T[],\n isTruthy: (value: T) => boolean\n): [truthy: T[], falsy: T[]] {\n const truthy: T[] = [];\n const falsy: T[] = [];\n\n for (const item of array) {\n (isTruthy(item) ? truthy : falsy).push(item);\n }\n\n return [truthy, falsy];\n}\n"]}
|
package/internals/utils/dom.d.ts
CHANGED
|
@@ -58,6 +58,28 @@ export declare function getCenterPoint(element: Element): {
|
|
|
58
58
|
x: number;
|
|
59
59
|
y: number;
|
|
60
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Maps a pointer's `clientX` coordinate to a fraction in the [0, 1] range of the
|
|
63
|
+
* element's bounding box width, measured from the element's logical start edge -
|
|
64
|
+
* the left edge when `ltr` is true, the right one otherwise.
|
|
65
|
+
*
|
|
66
|
+
* Returns 0 for an element without layout.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* // Pointer 30px into a 120px wide element
|
|
71
|
+
* pointToFraction(element, event.clientX); // 0.25
|
|
72
|
+
* pointToFraction(element, event.clientX, false); // 0.75
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function pointToFraction(element: Element, clientX: number, ltr?: boolean): number;
|
|
76
|
+
/**
|
|
77
|
+
* Concatenates the text content of the given nodes into a single string,
|
|
78
|
+
* trimmed and with consecutive whitespace collapsed.
|
|
79
|
+
*
|
|
80
|
+
* Useful for deriving an accessible label from projected content.
|
|
81
|
+
*/
|
|
82
|
+
export declare function normalizedTextContent(nodes: Iterable<Node>): string;
|
|
61
83
|
/** Returns whether the given client coordinates lie within the bounding box of the element. */
|
|
62
84
|
export declare function isPointInsideElement(element: Element, x: number, y: number): boolean;
|
|
63
85
|
/** Returns the scale factor of a given element based on its bounding client rect and offset dimensions. */
|
package/internals/utils/dom.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isServer } from 'lit';
|
|
2
|
-
import { asNumber, numberInRangeInclusive } from './math.js';
|
|
2
|
+
import { asNumber, clamp, numberInRangeInclusive } from './math.js';
|
|
3
3
|
import { merge } from './objects.js';
|
|
4
4
|
import { isDefined } from './types.js';
|
|
5
5
|
export function isLTR(element) {
|
|
@@ -91,6 +91,20 @@ export function getCenterPoint(element) {
|
|
|
91
91
|
y: top + height * 0.5,
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
+
export function pointToFraction(element, clientX, ltr = true) {
|
|
95
|
+
const { left, right, width } = element.getBoundingClientRect();
|
|
96
|
+
if (width === 0) {
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
return clamp((ltr ? clientX - left : right - clientX) / width, 0, 1);
|
|
100
|
+
}
|
|
101
|
+
export function normalizedTextContent(nodes) {
|
|
102
|
+
let text = '';
|
|
103
|
+
for (const node of nodes) {
|
|
104
|
+
text += node.textContent ?? '';
|
|
105
|
+
}
|
|
106
|
+
return text.trim().replace(/\s+/gu, ' ');
|
|
107
|
+
}
|
|
94
108
|
export function isPointInsideElement(element, x, y) {
|
|
95
109
|
const { left, right, top, bottom } = element.getBoundingClientRect();
|
|
96
110
|
return (numberInRangeInclusive(x, left, right) &&
|