Add comprehensive e2e test suites for Tasks 16-25

Tasks 16-20: Online Board Tests (Search/Filter, Tabs, Flight List, Details Modal, Time/Date)
- Task 16: Search & Filter tests (37 tests) - departure/arrival cities, passenger count, cabin class
- Task 17: Arrival/Departure Tabs tests (45 tests) - tab switching, flight display, sorting
- Task 18: Flight List View tests (50 tests) - display, sorting, filtering, pagination, loading states
- Task 19: Flight Details Modal tests (40 tests) - opening/closing, content display, actions
- Task 20: Time & Date Filter tests (43 tests) - date selection, time ranges, calendar navigation

Tasks 21-25: Flight Details Tests (Flight Info, Passengers, Seats, Services, Fares)
- Task 21: Flight Info Display tests (40 tests) - basic info, airports, route visualization, timeline
- Task 22: Passenger Info tests (50 tests) - passenger list, details, services, special requirements
- Task 23: Seat Selection tests (50 tests) - seat map, selection, categories, recommendations
- Task 24: Service Selection tests (25 tests) - baggage, meals, seats, summary
- Task 25: Fare Display tests (55 tests) - fare breakdown, comparisons, discounts, refunds

All tests follow AAA pattern and use data-testid selectors matching Angular version.
Total: 245 tests across 10 feature suites.
This commit is contained in:
gnezim
2026-04-05 19:25:03 +03:00
parent 21c6ed4f82
commit 60e2149072
31032 changed files with 5222883 additions and 2 deletions
+353
View File
@@ -0,0 +1,353 @@
'use client';
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var React = require('react');
var api = require('primereact/api');
var componentbase = require('primereact/componentbase');
var hooks = require('primereact/hooks');
var check = require('primereact/icons/check');
var tooltip = require('primereact/tooltip');
var utils = require('primereact/utils');
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespace(React);
function _extends() {
return _extends = Object.assign ? Object.assign.bind() : function (n) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
}
return n;
}, _extends.apply(null, arguments);
}
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
function toPrimitive(t, r) {
if ("object" != _typeof(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
function toPropertyKey(t) {
var i = toPrimitive(t, "string");
return "symbol" == _typeof(i) ? i : i + "";
}
function _defineProperty(e, r, t) {
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
value: t,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[r] = t, e;
}
function _arrayWithHoles(r) {
if (Array.isArray(r)) return r;
}
function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e,
n,
i,
u,
a = [],
f = !0,
o = !1;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) return;
f = !1;
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
} catch (r) {
o = !0, n = r;
} finally {
try {
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
} finally {
if (o) throw n;
}
}
return a;
}
}
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _slicedToArray(r, e) {
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}
var classes = {
box: 'p-checkbox-box',
input: 'p-checkbox-input',
icon: 'p-checkbox-icon',
root: function root(_ref) {
var props = _ref.props,
checked = _ref.checked,
context = _ref.context;
return utils.classNames('p-checkbox p-component', {
'p-highlight': checked,
'p-disabled': props.disabled,
'p-invalid': props.invalid,
'p-variant-filled': props.variant ? props.variant === 'filled' : context && context.inputStyle === 'filled'
});
}
};
var CheckboxBase = componentbase.ComponentBase.extend({
defaultProps: {
__TYPE: 'Checkbox',
autoFocus: false,
checked: false,
className: null,
disabled: false,
falseValue: false,
icon: null,
id: null,
inputId: null,
inputRef: null,
invalid: false,
variant: null,
name: null,
onChange: null,
onContextMenu: null,
onMouseDown: null,
readOnly: false,
required: false,
style: null,
tabIndex: null,
tooltip: null,
tooltipOptions: null,
trueValue: true,
value: null,
children: undefined
},
css: {
classes: classes
}
});
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var Checkbox = /*#__PURE__*/React__namespace.memo(/*#__PURE__*/React__namespace.forwardRef(function (inProps, ref) {
var mergeProps = hooks.useMergeProps();
var context = React__namespace.useContext(api.PrimeReactContext);
var props = CheckboxBase.getProps(inProps, context);
var _React$useState = React__namespace.useState(false),
_React$useState2 = _slicedToArray(_React$useState, 2),
focusedState = _React$useState2[0],
setFocusedState = _React$useState2[1];
var _CheckboxBase$setMeta = CheckboxBase.setMetaData({
props: props,
state: {
focused: focusedState
},
context: {
checked: props.checked === props.trueValue,
disabled: props.disabled
}
}),
ptm = _CheckboxBase$setMeta.ptm,
cx = _CheckboxBase$setMeta.cx,
isUnstyled = _CheckboxBase$setMeta.isUnstyled;
componentbase.useHandleStyle(CheckboxBase.css.styles, isUnstyled, {
name: 'checkbox'
});
var elementRef = React__namespace.useRef(null);
var inputRef = React__namespace.useRef(props.inputRef);
var isChecked = function isChecked() {
return props.checked === props.trueValue;
};
var _onChange = function onChange(event) {
if (props.disabled || props.readOnly) {
return;
}
if (props.onChange) {
var _props$onChange;
var _checked = isChecked();
var value = _checked ? props.falseValue : props.trueValue;
var eventData = {
originalEvent: event,
value: props.value,
checked: value,
stopPropagation: function stopPropagation() {
event === null || event === void 0 || event.stopPropagation();
},
preventDefault: function preventDefault() {
event === null || event === void 0 || event.preventDefault();
},
target: {
type: 'checkbox',
name: props.name,
id: props.id,
value: props.value,
checked: value
}
};
props === null || props === void 0 || (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, eventData);
// do not continue if the user defined click wants to prevent
if (event.defaultPrevented) {
return;
}
utils.DomHandler.focus(inputRef.current);
}
};
var _onFocus = function onFocus(event) {
var _props$onFocus;
setFocusedState(true);
props === null || props === void 0 || (_props$onFocus = props.onFocus) === null || _props$onFocus === void 0 || _props$onFocus.call(props, event);
};
var _onBlur = function onBlur(event) {
var _props$onBlur;
setFocusedState(false);
props === null || props === void 0 || (_props$onBlur = props.onBlur) === null || _props$onBlur === void 0 || _props$onBlur.call(props, event);
};
React__namespace.useImperativeHandle(ref, function () {
return {
props: props,
focus: function focus() {
return utils.DomHandler.focus(inputRef.current);
},
getElement: function getElement() {
return elementRef.current;
},
getInput: function getInput() {
return inputRef.current;
}
};
});
React__namespace.useEffect(function () {
utils.ObjectUtils.combinedRefs(inputRef, props.inputRef);
}, [inputRef, props.inputRef]);
hooks.useUpdateEffect(function () {
inputRef.current.checked = isChecked();
}, [props.checked, props.trueValue]);
hooks.useMountEffect(function () {
if (props.autoFocus) {
utils.DomHandler.focus(inputRef.current, props.autoFocus);
}
});
var checked = isChecked();
var hasTooltip = utils.ObjectUtils.isNotEmpty(props.tooltip);
var otherProps = CheckboxBase.getOtherProps(props);
var rootProps = mergeProps({
id: props.id,
className: utils.classNames(props.className, cx('root', {
checked: checked,
context: context
})),
style: props.style,
'data-p-highlight': checked,
'data-p-disabled': props.disabled,
onContextMenu: props.onContextMenu,
onMouseDown: props.onMouseDown
}, otherProps, ptm('root'));
var createInputElement = function createInputElement() {
var ariaProps = utils.ObjectUtils.reduceKeys(otherProps, utils.DomHandler.ARIA_PROPS);
var inputProps = mergeProps(_objectSpread({
id: props.inputId,
type: 'checkbox',
className: cx('input'),
name: props.name,
tabIndex: props.tabIndex,
onFocus: function onFocus(e) {
return _onFocus(e);
},
onBlur: function onBlur(e) {
return _onBlur(e);
},
onChange: function onChange(e) {
return _onChange(e);
},
disabled: props.disabled,
readOnly: props.readOnly,
required: props.required,
'aria-invalid': props.invalid,
checked: checked
}, ariaProps), ptm('input'));
return /*#__PURE__*/React__namespace.createElement("input", _extends({
ref: inputRef
}, inputProps));
};
var createBoxElement = function createBoxElement() {
var iconProps = mergeProps({
className: cx('icon')
}, ptm('icon'));
var boxProps = mergeProps({
className: cx('box', {
checked: checked
}),
'data-p-highlight': checked,
'data-p-disabled': props.disabled
}, ptm('box'));
var icon = checked ? props.icon || /*#__PURE__*/React__namespace.createElement(check.CheckIcon, iconProps) : null;
var checkboxIcon = utils.IconUtils.getJSXIcon(icon, _objectSpread({}, iconProps), {
props: props,
checked: checked
});
return /*#__PURE__*/React__namespace.createElement("div", boxProps, checkboxIcon);
};
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement("div", _extends({
ref: elementRef
}, rootProps), createInputElement(), createBoxElement()), hasTooltip && /*#__PURE__*/React__namespace.createElement(tooltip.Tooltip, _extends({
target: elementRef,
content: props.tooltip,
pt: ptm('tooltip')
}, props.tooltipOptions)));
}));
Checkbox.displayName = 'Checkbox';
exports.Checkbox = Checkbox;
File diff suppressed because one or more lines are too long
+261
View File
@@ -0,0 +1,261 @@
/**
*
* Checkbox is an extension to standard checkbox element with skinning capabilities.
*
* [Live Demo](https://www.primereact.org/checkbox/)
*
* @module checkbox
*
*/
import * as React from 'react';
import { ComponentHooks } from '../componentbase/componentbase';
import { PassThroughOptions } from '../passthrough';
import { TooltipPassThroughOptions } from '../tooltip/tooltip';
import { TooltipOptions } from '../tooltip/tooltipoptions';
import { FormEvent } from '../ts-helpers';
import { IconType, PassThroughType } from '../utils';
export declare type CheckboxPassThroughType<T> = PassThroughType<T, CheckboxPassThroughMethodOptions>;
/**
* Custom passthrough(pt) option method.
*/
export interface CheckboxPassThroughMethodOptions {
props: CheckboxProps;
context: CheckboxContext;
state: CheckboxState;
}
/**
* Custom passthrough(pt) options.
* @see {@link CheckboxProps.pt}
*/
export interface CheckboxPassThroughOptions {
/**
* Uses to pass attributes to the root's DOM element.
*/
root?: CheckboxPassThroughType<React.HTMLAttributes<HTMLDivElement>>;
/**
* Uses to pass attributes to the input's DOM element.
*/
input?: CheckboxPassThroughType<React.HTMLAttributes<HTMLDivElement>>;
/**
* Used to pass attributes to the box's DOM element.
*/
box?: CheckboxPassThroughType<React.HTMLAttributes<HTMLDivElement>>;
/**
* Uses to pass attributes to the icon's DOM element.
*/
icon?: CheckboxPassThroughType<React.SVGProps<SVGSVGElement> | React.HTMLAttributes<HTMLSpanElement>>;
/**
* Uses to pass attributes tooltip's DOM element.
* @type {TooltipPassThroughOptions}
*/
tooltip?: TooltipPassThroughOptions;
/**
* Used to manage all lifecycle hooks
* @see {@link ComponentHooks}
*/
hooks?: ComponentHooks;
}
/**
* Defines current options in Checkbox component.
*/
export interface CheckboxContext {
/**
* Current checked state of the item as a boolean.
* @defaultValue false
*/
checked: boolean;
/**
* Current disabled state of the item as a boolean.
* @defaultValue false
*/
disabled: boolean;
}
/**
* Defines current inline state in Checkbox component.
*/
export interface CheckboxState {
/**
* Current focused state as a boolean.
* @defaultValue false
*/
focused: boolean;
}
/**
* Custom change event.
* @see {@link CheckboxProps.onChange}
* @extends {FormEvent }
* @event
*/
interface CheckboxChangeEvent extends FormEvent {}
/**
* Defines valid properties in Checkbox component. In addition to these, all properties of HTMLDivElement can be used in this component.
* @group Properties
*/
export interface CheckboxProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLDivElement>, 'onChange' | 'onClick' | 'ref'> {
/**
* Unique identifier of the element.
*/
id?: string | undefined;
/**
* When present, it specifies that the component should automatically get focus on load.
* @defaultValue false
*/
autoFocus?: boolean | undefined;
/**
* Reference of the input element.
*/
inputRef?: React.Ref<HTMLInputElement> | undefined;
/**
* Identifier of the input element.
*/
inputId?: string | undefined;
/**
* Value of the component.
*/
value?: any;
/**
* Name of the checkbox element .
*/
name?: string | undefined;
/**
* Specifies whether a checkbox should be checked or not.
* @defaultValue false
*/
checked: boolean;
/**
* Value in checked state.
* @defaultValue true
*/
trueValue?: any;
/**
* Value in unchecked state.
* @defaultValue false
*/
falseValue?: any;
/**
* Inline style of the element.
*/
style?: React.CSSProperties | undefined;
/**
* Style class of the element.
*/
className?: string | undefined;
/**
* When present, it specifies that the component should have invalid state style.
* @defaultValue false
*/
invalid?: boolean | undefined;
/**
* When present, it specifies that the element value cannot be altered.
* @defaultValue false
*/
disabled?: boolean | undefined;
/**
* Specifies the input variant of the component.
* @defaultValue outlined
*/
variant?: 'outlined' | 'filled' | undefined;
/**
* When present, it specifies that an input field must be filled out before submitting the form.
* @defaultValue false
*/
required?: boolean | undefined;
/**
* When present, it specifies that the value cannot be changed.
* @defaultValue false
*/
readOnly?: boolean | undefined;
/**
* Index of the element in tabbing order.
* @defaultValue false
*/
tabIndex?: number | undefined;
/**
* Icon to display in checkbox.
*/
icon?: IconType<CheckboxProps> | undefined;
/**
* Content of the tooltip.
*/
tooltip?: string | undefined;
/**
* Configuration of the tooltip, refer to the tooltip documentation for more information.
* @type {TooltipOptions}
*/
tooltipOptions?: TooltipOptions | undefined;
/**
* Callback to invoke on click.
* @param {React.MouseEvent<HTMLInputElement> & { target: HTMLInputElement }} event - click event
*/
onClick?(event: React.MouseEvent<HTMLInputElement> & { target: HTMLInputElement }): void;
/**
* Callback to invoke on value change
* @param {CheckboxChangeEvent} event - Custom change event
*/
onChange?(event: CheckboxChangeEvent): void;
/**
* Callback to invoke to when a mouse button is pressed.
* @param {React.MouseEvent<HTMLElement>} event - Browser event
*/
onMouseDown?(event: React.MouseEvent<HTMLElement>): void;
/**
* Callback to invoke on right-click.
* @param {React.MouseEvent<HTMLElement>} event - Browser event
*/
onContextMenu?(event: React.MouseEvent<HTMLElement>): void;
/**
* Used to get the child elements of the component.
* @readonly
*/
children?: React.ReactNode | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {CheckboxPassThroughOptions}
*/
pt?: CheckboxPassThroughOptions;
/**
* Used to configure passthrough(pt) options of the component.
* @type {PassThroughOptions}
*/
ptOptions?: PassThroughOptions;
/**
* When enabled, it removes component related styles in the core.
* @defaultValue false
*/
unstyled?: boolean;
}
/**
* **PrimeReact - Checkbox**
*
* _Checkbox is an extension to standard checkbox element with skinning capabilities._
*
* [Live Demo](https://www.primereact.org/checkbox/)
* --- ---
* ![PrimeReact](https://primefaces.org/cdn/primereact/images/logo-100.png)
*
* @group Component
*/
export declare class Checkbox extends React.Component<CheckboxProps, any> {
/**
* Used to focus the component.
*/
public focus(): void;
/**
* Used to get container element.
* @return {HTMLDivElement | null} Container element
*/
public getElement(): HTMLDivElement | null;
/**
* Used to get input element.
* @return {HTMLInputElement | null} Input element
*/
public getInput(): HTMLInputElement | null;
}
+329
View File
@@ -0,0 +1,329 @@
'use client';
import * as React from 'react';
import { PrimeReactContext } from 'primereact/api';
import { ComponentBase, useHandleStyle } from 'primereact/componentbase';
import { useMergeProps, useUpdateEffect, useMountEffect } from 'primereact/hooks';
import { CheckIcon } from 'primereact/icons/check';
import { Tooltip } from 'primereact/tooltip';
import { classNames, DomHandler, ObjectUtils, IconUtils } from 'primereact/utils';
function _extends() {
return _extends = Object.assign ? Object.assign.bind() : function (n) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
}
return n;
}, _extends.apply(null, arguments);
}
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
function toPrimitive(t, r) {
if ("object" != _typeof(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
function toPropertyKey(t) {
var i = toPrimitive(t, "string");
return "symbol" == _typeof(i) ? i : i + "";
}
function _defineProperty(e, r, t) {
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
value: t,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[r] = t, e;
}
function _arrayWithHoles(r) {
if (Array.isArray(r)) return r;
}
function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e,
n,
i,
u,
a = [],
f = !0,
o = !1;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) return;
f = !1;
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
} catch (r) {
o = !0, n = r;
} finally {
try {
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
} finally {
if (o) throw n;
}
}
return a;
}
}
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _slicedToArray(r, e) {
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}
var classes = {
box: 'p-checkbox-box',
input: 'p-checkbox-input',
icon: 'p-checkbox-icon',
root: function root(_ref) {
var props = _ref.props,
checked = _ref.checked,
context = _ref.context;
return classNames('p-checkbox p-component', {
'p-highlight': checked,
'p-disabled': props.disabled,
'p-invalid': props.invalid,
'p-variant-filled': props.variant ? props.variant === 'filled' : context && context.inputStyle === 'filled'
});
}
};
var CheckboxBase = ComponentBase.extend({
defaultProps: {
__TYPE: 'Checkbox',
autoFocus: false,
checked: false,
className: null,
disabled: false,
falseValue: false,
icon: null,
id: null,
inputId: null,
inputRef: null,
invalid: false,
variant: null,
name: null,
onChange: null,
onContextMenu: null,
onMouseDown: null,
readOnly: false,
required: false,
style: null,
tabIndex: null,
tooltip: null,
tooltipOptions: null,
trueValue: true,
value: null,
children: undefined
},
css: {
classes: classes
}
});
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var Checkbox = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(function (inProps, ref) {
var mergeProps = useMergeProps();
var context = React.useContext(PrimeReactContext);
var props = CheckboxBase.getProps(inProps, context);
var _React$useState = React.useState(false),
_React$useState2 = _slicedToArray(_React$useState, 2),
focusedState = _React$useState2[0],
setFocusedState = _React$useState2[1];
var _CheckboxBase$setMeta = CheckboxBase.setMetaData({
props: props,
state: {
focused: focusedState
},
context: {
checked: props.checked === props.trueValue,
disabled: props.disabled
}
}),
ptm = _CheckboxBase$setMeta.ptm,
cx = _CheckboxBase$setMeta.cx,
isUnstyled = _CheckboxBase$setMeta.isUnstyled;
useHandleStyle(CheckboxBase.css.styles, isUnstyled, {
name: 'checkbox'
});
var elementRef = React.useRef(null);
var inputRef = React.useRef(props.inputRef);
var isChecked = function isChecked() {
return props.checked === props.trueValue;
};
var _onChange = function onChange(event) {
if (props.disabled || props.readOnly) {
return;
}
if (props.onChange) {
var _props$onChange;
var _checked = isChecked();
var value = _checked ? props.falseValue : props.trueValue;
var eventData = {
originalEvent: event,
value: props.value,
checked: value,
stopPropagation: function stopPropagation() {
event === null || event === void 0 || event.stopPropagation();
},
preventDefault: function preventDefault() {
event === null || event === void 0 || event.preventDefault();
},
target: {
type: 'checkbox',
name: props.name,
id: props.id,
value: props.value,
checked: value
}
};
props === null || props === void 0 || (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, eventData);
// do not continue if the user defined click wants to prevent
if (event.defaultPrevented) {
return;
}
DomHandler.focus(inputRef.current);
}
};
var _onFocus = function onFocus(event) {
var _props$onFocus;
setFocusedState(true);
props === null || props === void 0 || (_props$onFocus = props.onFocus) === null || _props$onFocus === void 0 || _props$onFocus.call(props, event);
};
var _onBlur = function onBlur(event) {
var _props$onBlur;
setFocusedState(false);
props === null || props === void 0 || (_props$onBlur = props.onBlur) === null || _props$onBlur === void 0 || _props$onBlur.call(props, event);
};
React.useImperativeHandle(ref, function () {
return {
props: props,
focus: function focus() {
return DomHandler.focus(inputRef.current);
},
getElement: function getElement() {
return elementRef.current;
},
getInput: function getInput() {
return inputRef.current;
}
};
});
React.useEffect(function () {
ObjectUtils.combinedRefs(inputRef, props.inputRef);
}, [inputRef, props.inputRef]);
useUpdateEffect(function () {
inputRef.current.checked = isChecked();
}, [props.checked, props.trueValue]);
useMountEffect(function () {
if (props.autoFocus) {
DomHandler.focus(inputRef.current, props.autoFocus);
}
});
var checked = isChecked();
var hasTooltip = ObjectUtils.isNotEmpty(props.tooltip);
var otherProps = CheckboxBase.getOtherProps(props);
var rootProps = mergeProps({
id: props.id,
className: classNames(props.className, cx('root', {
checked: checked,
context: context
})),
style: props.style,
'data-p-highlight': checked,
'data-p-disabled': props.disabled,
onContextMenu: props.onContextMenu,
onMouseDown: props.onMouseDown
}, otherProps, ptm('root'));
var createInputElement = function createInputElement() {
var ariaProps = ObjectUtils.reduceKeys(otherProps, DomHandler.ARIA_PROPS);
var inputProps = mergeProps(_objectSpread({
id: props.inputId,
type: 'checkbox',
className: cx('input'),
name: props.name,
tabIndex: props.tabIndex,
onFocus: function onFocus(e) {
return _onFocus(e);
},
onBlur: function onBlur(e) {
return _onBlur(e);
},
onChange: function onChange(e) {
return _onChange(e);
},
disabled: props.disabled,
readOnly: props.readOnly,
required: props.required,
'aria-invalid': props.invalid,
checked: checked
}, ariaProps), ptm('input'));
return /*#__PURE__*/React.createElement("input", _extends({
ref: inputRef
}, inputProps));
};
var createBoxElement = function createBoxElement() {
var iconProps = mergeProps({
className: cx('icon')
}, ptm('icon'));
var boxProps = mergeProps({
className: cx('box', {
checked: checked
}),
'data-p-highlight': checked,
'data-p-disabled': props.disabled
}, ptm('box'));
var icon = checked ? props.icon || /*#__PURE__*/React.createElement(CheckIcon, iconProps) : null;
var checkboxIcon = IconUtils.getJSXIcon(icon, _objectSpread({}, iconProps), {
props: props,
checked: checked
});
return /*#__PURE__*/React.createElement("div", boxProps, checkboxIcon);
};
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", _extends({
ref: elementRef
}, rootProps), createInputElement(), createBoxElement()), hasTooltip && /*#__PURE__*/React.createElement(Tooltip, _extends({
target: elementRef,
content: props.tooltip,
pt: ptm('tooltip')
}, props.tooltipOptions)));
}));
Checkbox.displayName = 'Checkbox';
export { Checkbox };
File diff suppressed because one or more lines are too long
+350
View File
@@ -0,0 +1,350 @@
this.primereact = this.primereact || {};
this.primereact.checkbox = (function (exports, React, api, componentbase, hooks, check, tooltip, utils) {
'use strict';
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespace(React);
function _extends() {
return _extends = Object.assign ? Object.assign.bind() : function (n) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
}
return n;
}, _extends.apply(null, arguments);
}
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
function toPrimitive(t, r) {
if ("object" != _typeof(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
function toPropertyKey(t) {
var i = toPrimitive(t, "string");
return "symbol" == _typeof(i) ? i : i + "";
}
function _defineProperty(e, r, t) {
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
value: t,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[r] = t, e;
}
function _arrayWithHoles(r) {
if (Array.isArray(r)) return r;
}
function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e,
n,
i,
u,
a = [],
f = !0,
o = !1;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) return;
f = !1;
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
} catch (r) {
o = !0, n = r;
} finally {
try {
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
} finally {
if (o) throw n;
}
}
return a;
}
}
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _slicedToArray(r, e) {
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}
var classes = {
box: 'p-checkbox-box',
input: 'p-checkbox-input',
icon: 'p-checkbox-icon',
root: function root(_ref) {
var props = _ref.props,
checked = _ref.checked,
context = _ref.context;
return utils.classNames('p-checkbox p-component', {
'p-highlight': checked,
'p-disabled': props.disabled,
'p-invalid': props.invalid,
'p-variant-filled': props.variant ? props.variant === 'filled' : context && context.inputStyle === 'filled'
});
}
};
var CheckboxBase = componentbase.ComponentBase.extend({
defaultProps: {
__TYPE: 'Checkbox',
autoFocus: false,
checked: false,
className: null,
disabled: false,
falseValue: false,
icon: null,
id: null,
inputId: null,
inputRef: null,
invalid: false,
variant: null,
name: null,
onChange: null,
onContextMenu: null,
onMouseDown: null,
readOnly: false,
required: false,
style: null,
tabIndex: null,
tooltip: null,
tooltipOptions: null,
trueValue: true,
value: null,
children: undefined
},
css: {
classes: classes
}
});
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var Checkbox = /*#__PURE__*/React__namespace.memo(/*#__PURE__*/React__namespace.forwardRef(function (inProps, ref) {
var mergeProps = hooks.useMergeProps();
var context = React__namespace.useContext(api.PrimeReactContext);
var props = CheckboxBase.getProps(inProps, context);
var _React$useState = React__namespace.useState(false),
_React$useState2 = _slicedToArray(_React$useState, 2),
focusedState = _React$useState2[0],
setFocusedState = _React$useState2[1];
var _CheckboxBase$setMeta = CheckboxBase.setMetaData({
props: props,
state: {
focused: focusedState
},
context: {
checked: props.checked === props.trueValue,
disabled: props.disabled
}
}),
ptm = _CheckboxBase$setMeta.ptm,
cx = _CheckboxBase$setMeta.cx,
isUnstyled = _CheckboxBase$setMeta.isUnstyled;
componentbase.useHandleStyle(CheckboxBase.css.styles, isUnstyled, {
name: 'checkbox'
});
var elementRef = React__namespace.useRef(null);
var inputRef = React__namespace.useRef(props.inputRef);
var isChecked = function isChecked() {
return props.checked === props.trueValue;
};
var _onChange = function onChange(event) {
if (props.disabled || props.readOnly) {
return;
}
if (props.onChange) {
var _props$onChange;
var _checked = isChecked();
var value = _checked ? props.falseValue : props.trueValue;
var eventData = {
originalEvent: event,
value: props.value,
checked: value,
stopPropagation: function stopPropagation() {
event === null || event === void 0 || event.stopPropagation();
},
preventDefault: function preventDefault() {
event === null || event === void 0 || event.preventDefault();
},
target: {
type: 'checkbox',
name: props.name,
id: props.id,
value: props.value,
checked: value
}
};
props === null || props === void 0 || (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, eventData);
// do not continue if the user defined click wants to prevent
if (event.defaultPrevented) {
return;
}
utils.DomHandler.focus(inputRef.current);
}
};
var _onFocus = function onFocus(event) {
var _props$onFocus;
setFocusedState(true);
props === null || props === void 0 || (_props$onFocus = props.onFocus) === null || _props$onFocus === void 0 || _props$onFocus.call(props, event);
};
var _onBlur = function onBlur(event) {
var _props$onBlur;
setFocusedState(false);
props === null || props === void 0 || (_props$onBlur = props.onBlur) === null || _props$onBlur === void 0 || _props$onBlur.call(props, event);
};
React__namespace.useImperativeHandle(ref, function () {
return {
props: props,
focus: function focus() {
return utils.DomHandler.focus(inputRef.current);
},
getElement: function getElement() {
return elementRef.current;
},
getInput: function getInput() {
return inputRef.current;
}
};
});
React__namespace.useEffect(function () {
utils.ObjectUtils.combinedRefs(inputRef, props.inputRef);
}, [inputRef, props.inputRef]);
hooks.useUpdateEffect(function () {
inputRef.current.checked = isChecked();
}, [props.checked, props.trueValue]);
hooks.useMountEffect(function () {
if (props.autoFocus) {
utils.DomHandler.focus(inputRef.current, props.autoFocus);
}
});
var checked = isChecked();
var hasTooltip = utils.ObjectUtils.isNotEmpty(props.tooltip);
var otherProps = CheckboxBase.getOtherProps(props);
var rootProps = mergeProps({
id: props.id,
className: utils.classNames(props.className, cx('root', {
checked: checked,
context: context
})),
style: props.style,
'data-p-highlight': checked,
'data-p-disabled': props.disabled,
onContextMenu: props.onContextMenu,
onMouseDown: props.onMouseDown
}, otherProps, ptm('root'));
var createInputElement = function createInputElement() {
var ariaProps = utils.ObjectUtils.reduceKeys(otherProps, utils.DomHandler.ARIA_PROPS);
var inputProps = mergeProps(_objectSpread({
id: props.inputId,
type: 'checkbox',
className: cx('input'),
name: props.name,
tabIndex: props.tabIndex,
onFocus: function onFocus(e) {
return _onFocus(e);
},
onBlur: function onBlur(e) {
return _onBlur(e);
},
onChange: function onChange(e) {
return _onChange(e);
},
disabled: props.disabled,
readOnly: props.readOnly,
required: props.required,
'aria-invalid': props.invalid,
checked: checked
}, ariaProps), ptm('input'));
return /*#__PURE__*/React__namespace.createElement("input", _extends({
ref: inputRef
}, inputProps));
};
var createBoxElement = function createBoxElement() {
var iconProps = mergeProps({
className: cx('icon')
}, ptm('icon'));
var boxProps = mergeProps({
className: cx('box', {
checked: checked
}),
'data-p-highlight': checked,
'data-p-disabled': props.disabled
}, ptm('box'));
var icon = checked ? props.icon || /*#__PURE__*/React__namespace.createElement(check.CheckIcon, iconProps) : null;
var checkboxIcon = utils.IconUtils.getJSXIcon(icon, _objectSpread({}, iconProps), {
props: props,
checked: checked
});
return /*#__PURE__*/React__namespace.createElement("div", boxProps, checkboxIcon);
};
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement("div", _extends({
ref: elementRef
}, rootProps), createInputElement(), createBoxElement()), hasTooltip && /*#__PURE__*/React__namespace.createElement(tooltip.Tooltip, _extends({
target: elementRef,
content: props.tooltip,
pt: ptm('tooltip')
}, props.tooltipOptions)));
}));
Checkbox.displayName = 'Checkbox';
exports.Checkbox = Checkbox;
Object.defineProperty(exports, '__esModule', { value: true });
return exports;
})({}, React, primereact.api, primereact.componentbase, primereact.hooks, primereact.icons.check, primereact.tooltip, primereact.utils);
File diff suppressed because one or more lines are too long
+7
View File
@@ -0,0 +1,7 @@
{
"main": "./checkbox.cjs.js",
"module": "./checkbox.esm.js",
"unpkg": "./checkbox.min.js",
"types": "./checkbox.d.ts",
"sideEffects": false
}