UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

76 lines (75 loc) 2.69 kB
/** * DevExtreme (esm/__internal/pagination/common/light_button.js) * Version: 24.2.6 * Build date: Mon Mar 17 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import { createVNode } from "inferno"; import { InfernoComponent, InfernoEffect } from "@devextreme/runtime/inferno"; import { createRef } from "inferno"; import { subscribeToClickEvent } from "../../core/r1/utils/subscribe_to_event"; import { KeyboardActionContext } from "./keyboard_action_context"; export const LightButtonDefaultProps = { className: "", label: "", tabIndex: 0, selected: false }; export class LightButton extends InfernoComponent { constructor(props) { super(props); this.state = {}; this.refs = null; this.widgetRef = createRef(); this.keyboardEffect = this.keyboardEffect.bind(this); this.subscribeToClick = this.subscribeToClick.bind(this) } getComponentProps() { return this.props } getKeyboardContext() { if (this.context[KeyboardActionContext.id]) { return this.context[KeyboardActionContext.id] } return KeyboardActionContext.defaultValue } componentWillUpdate(nextProps, nextState, context) { super.componentWillUpdate(nextProps, nextState, context) } createEffects() { return [new InfernoEffect(this.keyboardEffect, [this.getKeyboardContext(), this.props.onClick]), new InfernoEffect(this.subscribeToClick, [this.props.onClick])] } updateEffects() { var _this$_effects$, _this$_effects$2; null === (_this$_effects$ = this._effects[0]) || void 0 === _this$_effects$ || _this$_effects$.update([this.getKeyboardContext(), this.props.onClick]); null === (_this$_effects$2 = this._effects[1]) || void 0 === _this$_effects$2 || _this$_effects$2.update([this.props.onClick]) } keyboardEffect() { return this.getKeyboardContext().registerKeyboardAction(this.widgetRef.current, this.props.onClick) } subscribeToClick() { return subscribeToClickEvent(this.widgetRef.current, this.props.onClick) } render() { return createVNode(1, "div", this.props.className, this.props.children, 0, { tabIndex: this.props.tabIndex, role: "button", "aria-label": this.props.label, "aria-current": this.props.selected ? "page" : void 0 }, null, this.widgetRef) } } LightButton.defaultProps = LightButtonDefaultProps;