-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎹 Pager: Migrate number_box + select_box + rest embedded components (#…
- Loading branch information
Showing
93 changed files
with
3,111 additions
and
4,787 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { createContext } from '@devextreme/runtime/inferno'; | ||
|
||
export interface ConfigContextValue { rtlEnabled?: boolean } | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const ConfigContext = createContext<ConfigContextValue | undefined>(undefined) as any; |
19 changes: 19 additions & 0 deletions
19
packages/devextreme/js/__internal/core/r1/config_provider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { BaseInfernoComponent } from '@devextreme/runtime/inferno'; | ||
|
||
export interface ConfigProviderProps { | ||
rtlEnabled?: boolean; | ||
children: JSX.Element; | ||
} | ||
|
||
export const ConfigProviderDefaultProps = {}; | ||
export class ConfigProvider extends BaseInfernoComponent<ConfigProviderProps> { | ||
public state: any = {}; | ||
|
||
render(): JSX.Element { | ||
return ( | ||
this.props.children | ||
); | ||
} | ||
} | ||
ConfigProvider.defaultProps = ConfigProviderDefaultProps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-type-alias | ||
export type EventCallback<T = undefined> = T extends undefined ? () => void : (value: T) => void; | ||
|
||
export class WorkaroundForVue { | ||
// TODO: empty class as a WA for https://github.com/DevExpress/devextreme-renovation/issues/725 | ||
public dummy = ''; | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/devextreme/js/__internal/core/r1/utils/effect_return.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export type DisposeEffectReturn = (() => void); | ||
export type EffectReturn = DisposeEffectReturn | undefined; |
7 changes: 7 additions & 0 deletions
7
packages/devextreme/js/__internal/core/r1/utils/get_computed_style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { getWindow } from '../../../../core/utils/window'; | ||
|
||
export default function getElementComputedStyle(el: Element | undefined | null): | ||
CSSStyleDeclaration | null { | ||
const window = getWindow(); | ||
return el ? window.getComputedStyle?.(el) : null; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/devextreme/js/__internal/core/r1/utils/render_utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const combineClasses = ( | ||
classesMap: { [key: string]: boolean }, | ||
): string => Object.keys(classesMap) | ||
.filter((cssClass) => !!cssClass && classesMap[cssClass]) | ||
.join(' '); |
24 changes: 24 additions & 0 deletions
24
packages/devextreme/js/__internal/core/r1/utils/resolve_rtl.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import globalConfig from '../../../../core/config'; | ||
import { isDefined } from '../../../../core/utils/type'; | ||
import type { ConfigContextValue } from '../config_context'; | ||
|
||
export function resolveRtlEnabled(rtlProp?: boolean, config?: ConfigContextValue): | ||
boolean | undefined { | ||
if (rtlProp !== undefined) { | ||
return rtlProp; | ||
} | ||
if (config?.rtlEnabled !== undefined) { | ||
return config.rtlEnabled; | ||
} | ||
return globalConfig().rtlEnabled; | ||
} | ||
|
||
export function resolveRtlEnabledDefinition(rtlProp?: boolean, config?: ConfigContextValue): | ||
boolean { | ||
const isPropDefined = isDefined(rtlProp); | ||
const onlyGlobalDefined = isDefined(globalConfig().rtlEnabled) | ||
&& !isPropDefined && !isDefined(config?.rtlEnabled); | ||
return (isPropDefined | ||
&& (rtlProp !== config?.rtlEnabled)) | ||
|| onlyGlobalDefined; | ||
} |
49 changes: 49 additions & 0 deletions
49
packages/devextreme/js/__internal/core/r1/utils/subscribe_to_event copy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as clickEvent from '../../../../events/click'; | ||
import eventsEngine from '../../../../events/core/events_engine'; | ||
import scrollEvents from '../../../../events/gesture/emitter.gesture.scroll'; | ||
import pointerEvents from '../../../../events/pointer'; | ||
import { addNamespace } from '../../../../events/utils/index'; | ||
import type { EffectReturn } from './effect_return'; | ||
|
||
export function subscribeToEvent(eventName: string) { | ||
return ( | ||
element: HTMLElement | Document | undefined | null, | ||
handler: unknown, | ||
eventData?: unknown, | ||
namespace?: string, | ||
): EffectReturn => { | ||
const event = namespace ? addNamespace(eventName, namespace) : eventName; | ||
if (handler) { | ||
eventsEngine.on(element, event, eventData, handler); | ||
return (): void => { | ||
eventsEngine.off(element, event, handler); | ||
}; | ||
} | ||
return undefined; | ||
}; | ||
} | ||
export const subscribeToClickEvent = subscribeToEvent(clickEvent.name); | ||
|
||
export const subscribeToScrollEvent = subscribeToEvent(scrollEvents.scroll); | ||
export const subscribeToScrollInitEvent = subscribeToEvent(scrollEvents.init); | ||
export const subscribeToDXScrollStartEvent = subscribeToEvent(scrollEvents.start); | ||
export const subscribeToDXScrollMoveEvent = subscribeToEvent(scrollEvents.move); | ||
export const subscribeToDXScrollEndEvent = subscribeToEvent(scrollEvents.end); | ||
export const subscribeToDXScrollStopEvent = subscribeToEvent(scrollEvents.stop); | ||
export const subscribeToDXScrollCancelEvent = subscribeToEvent(scrollEvents.cancel); | ||
|
||
export const subscribeToDXPointerDownEvent = subscribeToEvent(pointerEvents.down); | ||
export const subscribeToDXPointerUpEvent = subscribeToEvent(pointerEvents.up); | ||
export const subscribeToDXPointerMoveEvent = subscribeToEvent(pointerEvents.move); | ||
|
||
export const subscribeToMouseEnterEvent = subscribeToEvent('mouseenter'); | ||
export const subscribeToMouseLeaveEvent = subscribeToEvent('mouseleave'); | ||
|
||
export const subscribeToKeyDownEvent = subscribeToEvent('keydown'); | ||
|
||
export const subscribeToDxActiveEvent = subscribeToEvent('dxactive'); | ||
export const subscribeToDxInactiveEvent = subscribeToEvent('dxinactive'); | ||
export const subscribeToDxHoverStartEvent = subscribeToEvent('dxhoverstart'); | ||
export const subscribeToDxHoverEndEvent = subscribeToEvent('dxhoverend'); | ||
export const subscribeToDxFocusInEvent = subscribeToEvent('focusin'); | ||
export const subscribeToDxFocusOutEvent = subscribeToEvent('focusout'); |
49 changes: 49 additions & 0 deletions
49
packages/devextreme/js/__internal/core/r1/utils/subscribe_to_event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as clickEvent from '../../../../events/click'; | ||
import eventsEngine from '../../../../events/core/events_engine'; | ||
import scrollEvents from '../../../../events/gesture/emitter.gesture.scroll'; | ||
import pointerEvents from '../../../../events/pointer'; | ||
import { addNamespace } from '../../../../events/utils/index'; | ||
import type { EffectReturn } from './effect_return'; | ||
|
||
export function subscribeToEvent(eventName: string) { | ||
return ( | ||
element: HTMLElement | Document | undefined | null, | ||
handler: unknown, | ||
eventData?: unknown, | ||
namespace?: string, | ||
): EffectReturn => { | ||
const event = namespace ? addNamespace(eventName, namespace) : eventName; | ||
if (handler) { | ||
eventsEngine.on(element, event, eventData, handler); | ||
return (): void => { | ||
eventsEngine.off(element, event, handler); | ||
}; | ||
} | ||
return undefined; | ||
}; | ||
} | ||
export const subscribeToClickEvent = subscribeToEvent(clickEvent.name); | ||
|
||
export const subscribeToScrollEvent = subscribeToEvent(scrollEvents.scroll); | ||
export const subscribeToScrollInitEvent = subscribeToEvent(scrollEvents.init); | ||
export const subscribeToDXScrollStartEvent = subscribeToEvent(scrollEvents.start); | ||
export const subscribeToDXScrollMoveEvent = subscribeToEvent(scrollEvents.move); | ||
export const subscribeToDXScrollEndEvent = subscribeToEvent(scrollEvents.end); | ||
export const subscribeToDXScrollStopEvent = subscribeToEvent(scrollEvents.stop); | ||
export const subscribeToDXScrollCancelEvent = subscribeToEvent(scrollEvents.cancel); | ||
|
||
export const subscribeToDXPointerDownEvent = subscribeToEvent(pointerEvents.down); | ||
export const subscribeToDXPointerUpEvent = subscribeToEvent(pointerEvents.up); | ||
export const subscribeToDXPointerMoveEvent = subscribeToEvent(pointerEvents.move); | ||
|
||
export const subscribeToMouseEnterEvent = subscribeToEvent('mouseenter'); | ||
export const subscribeToMouseLeaveEvent = subscribeToEvent('mouseleave'); | ||
|
||
export const subscribeToKeyDownEvent = subscribeToEvent('keydown'); | ||
|
||
export const subscribeToDxActiveEvent = subscribeToEvent('dxactive'); | ||
export const subscribeToDxInactiveEvent = subscribeToEvent('dxinactive'); | ||
export const subscribeToDxHoverStartEvent = subscribeToEvent('dxhoverstart'); | ||
export const subscribeToDxHoverEndEvent = subscribeToEvent('dxhoverend'); | ||
export const subscribeToDxFocusInEvent = subscribeToEvent('focusin'); | ||
export const subscribeToDxFocusOutEvent = subscribeToEvent('focusout'); |
3 changes: 3 additions & 0 deletions
3
packages/devextreme/js/__internal/core/r1/utils/type_conversion.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function toNumber(attribute: string | undefined): number { | ||
return attribute ? Number(attribute.replace('px', '')) : 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
export interface BaseWidgetProps { | ||
className?: string; | ||
accessKey?: string; | ||
activeStateEnabled?: boolean; | ||
disabled?: boolean; | ||
focusStateEnabled?: boolean; | ||
height?: string | number | (() => (string | number)); | ||
hint?: string; | ||
hoverStateEnabled?: boolean; | ||
onClick?: (e: any) => void; | ||
onKeyDown?: (e: any) => any; | ||
rtlEnabled?: boolean; | ||
tabIndex?: number; | ||
visible?: boolean; | ||
width?: string | number | (() => (string | number)); | ||
} | ||
|
||
export const BaseWidgetDefaultProps: BaseWidgetProps = { | ||
className: '', | ||
activeStateEnabled: false, | ||
disabled: false, | ||
focusStateEnabled: false, | ||
hoverStateEnabled: false, | ||
tabIndex: 0, | ||
visible: true, | ||
}; |
42 changes: 42 additions & 0 deletions
42
packages/devextreme/js/__internal/pager/common/base_pager_props.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { PagerDisplayMode } from '@js/common/grids'; | ||
|
||
import messageLocalization from '../../../localization/message'; | ||
import type { EventCallback } from '../../core/r1/event_callback'; | ||
|
||
export interface BasePagerProps { | ||
gridCompatibility?: boolean; | ||
className?: string; | ||
showInfo?: boolean; | ||
infoText?: string; | ||
lightModeEnabled?: boolean; | ||
displayMode?: PagerDisplayMode; | ||
maxPagesCount: number; | ||
pageCount: number; | ||
pagesCountText?: string; | ||
visible?: boolean; | ||
hasKnownLastPage?: boolean; | ||
pagesNavigatorVisible?: boolean | 'auto'; | ||
showPageSizes?: boolean; | ||
pageSizes: (number | 'all')[]; | ||
rtlEnabled?: boolean; | ||
showNavigationButtons?: boolean; | ||
totalCount?: number; | ||
label?: string; | ||
onKeyDown?: EventCallback<Event>; | ||
} | ||
|
||
export const BasePagerDefaultProps: BasePagerProps = { | ||
gridCompatibility: true, | ||
showInfo: false, | ||
displayMode: 'adaptive', | ||
maxPagesCount: 10, | ||
pageCount: 10, | ||
visible: true, | ||
hasKnownLastPage: true, | ||
pagesNavigatorVisible: 'auto', | ||
showPageSizes: true, | ||
pageSizes: [5, 10], | ||
showNavigationButtons: false, | ||
totalCount: 0, | ||
label: messageLocalization.format('dxPager-ariaLabel'), | ||
}; |
File renamed without changes.
7 changes: 4 additions & 3 deletions
7
...i/pager/common/keyboard_action_context.ts → ...l/pager/common/keyboard_action_context.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.