primereact 10.9.1 → 10.9.2

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.
Files changed (178) hide show
  1. package/autocomplete/autocomplete.cjs.js +4 -4
  2. package/autocomplete/autocomplete.cjs.min.js +1 -1
  3. package/autocomplete/autocomplete.d.ts +2 -2
  4. package/autocomplete/autocomplete.esm.js +4 -4
  5. package/autocomplete/autocomplete.esm.min.js +1 -1
  6. package/autocomplete/autocomplete.js +4 -4
  7. package/autocomplete/autocomplete.min.js +1 -1
  8. package/breadcrumb/breadcrumb.cjs.js +1 -1
  9. package/breadcrumb/breadcrumb.cjs.min.js +1 -1
  10. package/breadcrumb/breadcrumb.esm.js +1 -1
  11. package/breadcrumb/breadcrumb.esm.min.js +1 -1
  12. package/breadcrumb/breadcrumb.js +1 -1
  13. package/breadcrumb/breadcrumb.min.js +1 -1
  14. package/calendar/calendar.cjs.js +35 -20
  15. package/calendar/calendar.cjs.min.js +1 -1
  16. package/calendar/calendar.d.ts +15 -61
  17. package/calendar/calendar.esm.js +35 -20
  18. package/calendar/calendar.esm.min.js +1 -1
  19. package/calendar/calendar.js +35 -20
  20. package/calendar/calendar.min.js +1 -1
  21. package/componentbase/componentbase.cjs.js +1 -1
  22. package/componentbase/componentbase.cjs.min.js +1 -1
  23. package/componentbase/componentbase.esm.js +1 -1
  24. package/componentbase/componentbase.esm.min.js +1 -1
  25. package/componentbase/componentbase.js +1 -1
  26. package/componentbase/componentbase.min.js +1 -1
  27. package/contextmenu/contextmenu.cjs.js +0 -1
  28. package/contextmenu/contextmenu.cjs.min.js +1 -1
  29. package/contextmenu/contextmenu.esm.js +0 -1
  30. package/contextmenu/contextmenu.esm.min.js +1 -1
  31. package/contextmenu/contextmenu.js +0 -1
  32. package/contextmenu/contextmenu.min.js +1 -1
  33. package/core/core.js +103 -73
  34. package/core/core.min.js +6 -6
  35. package/datatable/datatable.cjs.js +15 -7
  36. package/datatable/datatable.cjs.min.js +1 -1
  37. package/datatable/datatable.esm.js +15 -7
  38. package/datatable/datatable.esm.min.js +1 -1
  39. package/datatable/datatable.js +15 -7
  40. package/datatable/datatable.min.js +1 -1
  41. package/dataview/dataview.cjs.js +6 -2
  42. package/dataview/dataview.cjs.min.js +1 -1
  43. package/dataview/dataview.esm.js +6 -2
  44. package/dataview/dataview.esm.min.js +1 -1
  45. package/dataview/dataview.js +7 -3
  46. package/dataview/dataview.min.js +1 -1
  47. package/dock/dock.cjs.js +0 -1
  48. package/dock/dock.cjs.min.js +1 -1
  49. package/dock/dock.esm.js +0 -1
  50. package/dock/dock.esm.min.js +1 -1
  51. package/dock/dock.js +0 -1
  52. package/dock/dock.min.js +1 -1
  53. package/dropdown/dropdown.cjs.js +24 -22
  54. package/dropdown/dropdown.cjs.min.js +1 -1
  55. package/dropdown/dropdown.d.ts +5 -0
  56. package/dropdown/dropdown.esm.js +25 -23
  57. package/dropdown/dropdown.esm.min.js +1 -1
  58. package/dropdown/dropdown.js +24 -22
  59. package/dropdown/dropdown.min.js +1 -1
  60. package/inputtextarea/inputtextarea.cjs.js +1 -1
  61. package/inputtextarea/inputtextarea.cjs.min.js +1 -1
  62. package/inputtextarea/inputtextarea.esm.js +1 -1
  63. package/inputtextarea/inputtextarea.esm.min.js +1 -1
  64. package/inputtextarea/inputtextarea.js +1 -1
  65. package/inputtextarea/inputtextarea.min.js +1 -1
  66. package/megamenu/megamenu.cjs.js +1 -2
  67. package/megamenu/megamenu.cjs.min.js +1 -1
  68. package/megamenu/megamenu.esm.js +1 -2
  69. package/megamenu/megamenu.esm.min.js +1 -1
  70. package/megamenu/megamenu.js +1 -2
  71. package/megamenu/megamenu.min.js +1 -1
  72. package/mention/mention.cjs.js +1 -1
  73. package/mention/mention.cjs.min.js +1 -1
  74. package/mention/mention.esm.js +1 -1
  75. package/mention/mention.esm.min.js +1 -1
  76. package/mention/mention.js +1 -1
  77. package/mention/mention.min.js +1 -1
  78. package/menu/menu.cjs.js +0 -1
  79. package/menu/menu.cjs.min.js +1 -1
  80. package/menu/menu.esm.js +0 -1
  81. package/menu/menu.esm.min.js +1 -1
  82. package/menu/menu.js +0 -1
  83. package/menu/menu.min.js +1 -1
  84. package/menubar/menubar.cjs.js +0 -1
  85. package/menubar/menubar.cjs.min.js +1 -1
  86. package/menubar/menubar.esm.js +0 -1
  87. package/menubar/menubar.esm.min.js +1 -1
  88. package/menubar/menubar.js +0 -1
  89. package/menubar/menubar.min.js +1 -1
  90. package/multiselect/multiselect.cjs.js +24 -22
  91. package/multiselect/multiselect.cjs.min.js +1 -1
  92. package/multiselect/multiselect.d.ts +6 -1
  93. package/multiselect/multiselect.esm.js +25 -23
  94. package/multiselect/multiselect.esm.min.js +1 -1
  95. package/multiselect/multiselect.js +24 -22
  96. package/multiselect/multiselect.min.js +1 -1
  97. package/package.json +1 -1
  98. package/panelmenu/panelmenu.cjs.js +1 -2
  99. package/panelmenu/panelmenu.cjs.min.js +1 -1
  100. package/panelmenu/panelmenu.esm.js +1 -2
  101. package/panelmenu/panelmenu.esm.min.js +1 -1
  102. package/panelmenu/panelmenu.js +1 -2
  103. package/panelmenu/panelmenu.min.js +1 -1
  104. package/passthrough/tailwind/index.cjs.js +1 -1
  105. package/passthrough/tailwind/index.cjs.min.js +1 -1
  106. package/passthrough/tailwind/index.esm.js +1 -1
  107. package/passthrough/tailwind/index.esm.min.js +1 -1
  108. package/passthrough/tailwind/index.js +1 -1
  109. package/passthrough/tailwind/index.min.js +1 -1
  110. package/picklist/picklist.cjs.js +19 -6
  111. package/picklist/picklist.cjs.min.js +1 -1
  112. package/picklist/picklist.esm.js +19 -6
  113. package/picklist/picklist.esm.min.js +1 -1
  114. package/picklist/picklist.js +19 -6
  115. package/picklist/picklist.min.js +1 -1
  116. package/primereact.all.cjs.js +221 -139
  117. package/primereact.all.cjs.min.js +1 -1
  118. package/primereact.all.esm.js +221 -139
  119. package/primereact.all.esm.min.js +1 -1
  120. package/primereact.all.js +221 -139
  121. package/primereact.all.min.js +1 -1
  122. package/splitbutton/splitbutton.cjs.js +0 -1
  123. package/splitbutton/splitbutton.cjs.min.js +1 -1
  124. package/splitbutton/splitbutton.esm.js +0 -1
  125. package/splitbutton/splitbutton.esm.min.js +1 -1
  126. package/splitbutton/splitbutton.js +0 -1
  127. package/splitbutton/splitbutton.min.js +1 -1
  128. package/tieredmenu/tieredmenu.cjs.js +0 -1
  129. package/tieredmenu/tieredmenu.cjs.min.js +1 -1
  130. package/tieredmenu/tieredmenu.esm.js +0 -1
  131. package/tieredmenu/tieredmenu.esm.min.js +1 -1
  132. package/tieredmenu/tieredmenu.js +0 -1
  133. package/tieredmenu/tieredmenu.min.js +1 -1
  134. package/togglebutton/togglebutton.cjs.js +4 -4
  135. package/togglebutton/togglebutton.cjs.min.js +1 -1
  136. package/togglebutton/togglebutton.esm.js +4 -4
  137. package/togglebutton/togglebutton.esm.min.js +1 -1
  138. package/togglebutton/togglebutton.js +4 -4
  139. package/togglebutton/togglebutton.min.js +1 -1
  140. package/tooltip/tooltip.cjs.js +7 -2
  141. package/tooltip/tooltip.cjs.min.js +1 -1
  142. package/tooltip/tooltip.esm.js +7 -2
  143. package/tooltip/tooltip.esm.min.js +1 -1
  144. package/tooltip/tooltip.js +7 -2
  145. package/tooltip/tooltip.min.js +1 -1
  146. package/tree/tree.cjs.js +37 -38
  147. package/tree/tree.cjs.min.js +1 -1
  148. package/tree/tree.d.ts +11 -1
  149. package/tree/tree.esm.js +38 -39
  150. package/tree/tree.esm.min.js +1 -1
  151. package/tree/tree.js +38 -39
  152. package/tree/tree.min.js +1 -1
  153. package/treeselect/treeselect.cjs.js +10 -6
  154. package/treeselect/treeselect.cjs.min.js +1 -1
  155. package/treeselect/treeselect.d.ts +6 -1
  156. package/treeselect/treeselect.esm.js +11 -7
  157. package/treeselect/treeselect.esm.min.js +1 -1
  158. package/treeselect/treeselect.js +10 -6
  159. package/treeselect/treeselect.min.js +1 -1
  160. package/treetable/treetable.cjs.js +223 -223
  161. package/treetable/treetable.cjs.min.js +1 -1
  162. package/treetable/treetable.esm.js +224 -224
  163. package/treetable/treetable.esm.min.js +1 -1
  164. package/treetable/treetable.js +224 -224
  165. package/treetable/treetable.min.js +1 -1
  166. package/utils/utils.cjs.js +31 -7
  167. package/utils/utils.cjs.min.js +1 -1
  168. package/utils/utils.esm.js +31 -7
  169. package/utils/utils.esm.min.js +1 -1
  170. package/utils/utils.js +31 -7
  171. package/utils/utils.min.js +1 -1
  172. package/virtualscroller/virtualscroller.cjs.js +2 -2
  173. package/virtualscroller/virtualscroller.cjs.min.js +1 -1
  174. package/virtualscroller/virtualscroller.esm.js +2 -2
  175. package/virtualscroller/virtualscroller.esm.min.js +1 -1
  176. package/virtualscroller/virtualscroller.js +2 -2
  177. package/virtualscroller/virtualscroller.min.js +1 -1
  178. package/web-types.json +996 -51
@@ -3,18 +3,18 @@ import * as React from 'react';
3
3
  import PrimeReact, { FilterMatchMode, PrimeReactContext, ariaLabel, localeOption, FilterService } from 'primereact/api';
4
4
  import { ComponentBase, useHandleStyle } from 'primereact/componentbase';
5
5
  import { ObjectUtils, classNames, DomHandler, IconUtils } from 'primereact/utils';
6
- import { useMergeProps, useEventListener, useUnmountEffect, useUpdateEffect, useMountEffect } from 'primereact/hooks';
6
+ import { useMergeProps, useUpdateEffect, useMountEffect, useEventListener, useUnmountEffect } from 'primereact/hooks';
7
7
  import { ArrowDownIcon } from 'primereact/icons/arrowdown';
8
8
  import { ArrowUpIcon } from 'primereact/icons/arrowup';
9
9
  import { SpinnerIcon } from 'primereact/icons/spinner';
10
10
  import { Paginator } from 'primereact/paginator';
11
11
  import { CheckIcon } from 'primereact/icons/check';
12
+ import { Tooltip } from 'primereact/tooltip';
12
13
  import { ChevronDownIcon } from 'primereact/icons/chevrondown';
13
14
  import { ChevronRightIcon } from 'primereact/icons/chevronright';
14
15
  import { MinusIcon } from 'primereact/icons/minus';
15
16
  import { Ripple } from 'primereact/ripple';
16
17
  import { OverlayService } from 'primereact/overlayservice';
17
- import { Tooltip } from 'primereact/tooltip';
18
18
  import { SortAltIcon } from 'primereact/icons/sortalt';
19
19
  import { SortAmountDownIcon } from 'primereact/icons/sortamountdown';
20
20
  import { SortAmountUpAltIcon } from 'primereact/icons/sortamountupalt';
@@ -328,7 +328,7 @@ var classes$1 = {
328
328
  return {
329
329
  'p-highlight': isSelected(),
330
330
  'p-highlight-contextmenu': props.contextMenuSelectionKey && props.contextMenuSelectionKey === props.node.key,
331
- 'p-row-odd': props.rowIndex % 2 !== 0
331
+ 'p-row-odd': parseInt(String(props.rowIndex).split('_').pop(), 10) % 2 !== 0
332
332
  };
333
333
  },
334
334
  rowCheckbox: function rowCheckbox(_ref6) {
@@ -456,8 +456,228 @@ var TreeTableBase = ComponentBase.extend({
456
456
  }
457
457
  });
458
458
 
459
+ var classes = {
460
+ box: 'p-checkbox-box',
461
+ input: 'p-checkbox-input',
462
+ icon: 'p-checkbox-icon',
463
+ root: function root(_ref) {
464
+ var props = _ref.props,
465
+ checked = _ref.checked,
466
+ context = _ref.context;
467
+ return classNames('p-checkbox p-component', {
468
+ 'p-highlight': checked,
469
+ 'p-disabled': props.disabled,
470
+ 'p-invalid': props.invalid,
471
+ 'p-variant-filled': props.variant ? props.variant === 'filled' : context && context.inputStyle === 'filled'
472
+ });
473
+ }
474
+ };
475
+ var CheckboxBase = ComponentBase.extend({
476
+ defaultProps: {
477
+ __TYPE: 'Checkbox',
478
+ autoFocus: false,
479
+ checked: false,
480
+ className: null,
481
+ disabled: false,
482
+ falseValue: false,
483
+ icon: null,
484
+ id: null,
485
+ inputId: null,
486
+ inputRef: null,
487
+ invalid: false,
488
+ variant: null,
489
+ name: null,
490
+ onChange: null,
491
+ onContextMenu: null,
492
+ onMouseDown: null,
493
+ readOnly: false,
494
+ required: false,
495
+ style: null,
496
+ tabIndex: null,
497
+ tooltip: null,
498
+ tooltipOptions: null,
499
+ trueValue: true,
500
+ value: null,
501
+ children: undefined
502
+ },
503
+ css: {
504
+ classes: classes
505
+ }
506
+ });
507
+
459
508
  function ownKeys$6(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; }
460
509
  function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
510
+ var Checkbox = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(function (inProps, ref) {
511
+ var mergeProps = useMergeProps();
512
+ var context = React.useContext(PrimeReactContext);
513
+ var props = CheckboxBase.getProps(inProps, context);
514
+ var _React$useState = React.useState(false),
515
+ _React$useState2 = _slicedToArray(_React$useState, 2),
516
+ focusedState = _React$useState2[0],
517
+ setFocusedState = _React$useState2[1];
518
+ var _CheckboxBase$setMeta = CheckboxBase.setMetaData({
519
+ props: props,
520
+ state: {
521
+ focused: focusedState
522
+ },
523
+ context: {
524
+ checked: props.checked === props.trueValue,
525
+ disabled: props.disabled
526
+ }
527
+ }),
528
+ ptm = _CheckboxBase$setMeta.ptm,
529
+ cx = _CheckboxBase$setMeta.cx,
530
+ isUnstyled = _CheckboxBase$setMeta.isUnstyled;
531
+ useHandleStyle(CheckboxBase.css.styles, isUnstyled, {
532
+ name: 'checkbox'
533
+ });
534
+ var elementRef = React.useRef(null);
535
+ var inputRef = React.useRef(props.inputRef);
536
+ var isChecked = function isChecked() {
537
+ return props.checked === props.trueValue;
538
+ };
539
+ var _onChange = function onChange(event) {
540
+ if (props.disabled || props.readonly) {
541
+ return;
542
+ }
543
+ if (props.onChange) {
544
+ var _props$onChange;
545
+ var _checked = isChecked();
546
+ var value = _checked ? props.falseValue : props.trueValue;
547
+ var eventData = {
548
+ originalEvent: event,
549
+ value: props.value,
550
+ checked: value,
551
+ stopPropagation: function stopPropagation() {
552
+ event === null || event === void 0 || event.stopPropagation();
553
+ },
554
+ preventDefault: function preventDefault() {
555
+ event === null || event === void 0 || event.preventDefault();
556
+ },
557
+ target: {
558
+ type: 'checkbox',
559
+ name: props.name,
560
+ id: props.id,
561
+ value: props.value,
562
+ checked: value
563
+ }
564
+ };
565
+ props === null || props === void 0 || (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, eventData);
566
+
567
+ // do not continue if the user defined click wants to prevent
568
+ if (event.defaultPrevented) {
569
+ return;
570
+ }
571
+ DomHandler.focus(inputRef.current);
572
+ }
573
+ };
574
+ var _onFocus = function onFocus(event) {
575
+ var _props$onFocus;
576
+ setFocusedState(true);
577
+ props === null || props === void 0 || (_props$onFocus = props.onFocus) === null || _props$onFocus === void 0 || _props$onFocus.call(props, event);
578
+ };
579
+ var _onBlur = function onBlur(event) {
580
+ var _props$onBlur;
581
+ setFocusedState(false);
582
+ props === null || props === void 0 || (_props$onBlur = props.onBlur) === null || _props$onBlur === void 0 || _props$onBlur.call(props, event);
583
+ };
584
+ React.useImperativeHandle(ref, function () {
585
+ return {
586
+ props: props,
587
+ focus: function focus() {
588
+ return DomHandler.focus(inputRef.current);
589
+ },
590
+ getElement: function getElement() {
591
+ return elementRef.current;
592
+ },
593
+ getInput: function getInput() {
594
+ return inputRef.current;
595
+ }
596
+ };
597
+ });
598
+ React.useEffect(function () {
599
+ ObjectUtils.combinedRefs(inputRef, props.inputRef);
600
+ }, [inputRef, props.inputRef]);
601
+ useUpdateEffect(function () {
602
+ inputRef.current.checked = isChecked();
603
+ }, [props.checked, props.trueValue]);
604
+ useMountEffect(function () {
605
+ if (props.autoFocus) {
606
+ DomHandler.focus(inputRef.current, props.autoFocus);
607
+ }
608
+ });
609
+ var checked = isChecked();
610
+ var hasTooltip = ObjectUtils.isNotEmpty(props.tooltip);
611
+ var otherProps = CheckboxBase.getOtherProps(props);
612
+ var rootProps = mergeProps({
613
+ id: props.id,
614
+ className: classNames(props.className, cx('root', {
615
+ checked: checked,
616
+ context: context
617
+ })),
618
+ style: props.style,
619
+ 'data-p-highlight': checked,
620
+ 'data-p-disabled': props.disabled,
621
+ onContextMenu: props.onContextMenu,
622
+ onMouseDown: props.onMouseDown
623
+ }, otherProps, ptm('root'));
624
+ var createInputElement = function createInputElement() {
625
+ var ariaProps = ObjectUtils.reduceKeys(otherProps, DomHandler.ARIA_PROPS);
626
+ var inputProps = mergeProps(_objectSpread$6({
627
+ id: props.inputId,
628
+ type: 'checkbox',
629
+ className: cx('input'),
630
+ name: props.name,
631
+ tabIndex: props.tabIndex,
632
+ onFocus: function onFocus(e) {
633
+ return _onFocus(e);
634
+ },
635
+ onBlur: function onBlur(e) {
636
+ return _onBlur(e);
637
+ },
638
+ onChange: function onChange(e) {
639
+ return _onChange(e);
640
+ },
641
+ disabled: props.disabled,
642
+ readOnly: props.readOnly,
643
+ required: props.required,
644
+ 'aria-invalid': props.invalid,
645
+ checked: checked
646
+ }, ariaProps), ptm('input'));
647
+ return /*#__PURE__*/React.createElement("input", _extends({
648
+ ref: inputRef
649
+ }, inputProps));
650
+ };
651
+ var createBoxElement = function createBoxElement() {
652
+ var iconProps = mergeProps({
653
+ className: cx('icon')
654
+ }, ptm('icon'));
655
+ var boxProps = mergeProps({
656
+ className: cx('box', {
657
+ checked: checked
658
+ }),
659
+ 'data-p-highlight': checked,
660
+ 'data-p-disabled': props.disabled
661
+ }, ptm('box'));
662
+ var icon = checked ? props.icon || /*#__PURE__*/React.createElement(CheckIcon, iconProps) : null;
663
+ var checkboxIcon = IconUtils.getJSXIcon(icon, _objectSpread$6({}, iconProps), {
664
+ props: props,
665
+ checked: checked
666
+ });
667
+ return /*#__PURE__*/React.createElement("div", boxProps, checkboxIcon);
668
+ };
669
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", _extends({
670
+ ref: elementRef
671
+ }, rootProps), createInputElement(), createBoxElement()), hasTooltip && /*#__PURE__*/React.createElement(Tooltip, _extends({
672
+ target: elementRef,
673
+ content: props.tooltip,
674
+ pt: ptm('tooltip')
675
+ }, props.tooltipOptions)));
676
+ }));
677
+ Checkbox.displayName = 'Checkbox';
678
+
679
+ function ownKeys$5(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; }
680
+ function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
461
681
  var TreeTableBodyCell = function TreeTableBodyCell(props) {
462
682
  var _React$useState = React.useState(false),
463
683
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -518,7 +738,7 @@ var TreeTableBodyCell = function TreeTableBodyCell(props) {
518
738
  };
519
739
  var getCellCallbackParams = function getCellCallbackParams(event) {
520
740
  var params = getCellParams();
521
- return _objectSpread$6({
741
+ return _objectSpread$5({
522
742
  originalEvent: event
523
743
  }, params);
524
744
  };
@@ -700,226 +920,6 @@ var TreeTableBodyCell = function TreeTableBodyCell(props) {
700
920
  };
701
921
  TreeTableBodyCell.displayName = 'TreeTableBodyCell';
702
922
 
703
- var classes = {
704
- box: 'p-checkbox-box',
705
- input: 'p-checkbox-input',
706
- icon: 'p-checkbox-icon',
707
- root: function root(_ref) {
708
- var props = _ref.props,
709
- checked = _ref.checked,
710
- context = _ref.context;
711
- return classNames('p-checkbox p-component', {
712
- 'p-highlight': checked,
713
- 'p-disabled': props.disabled,
714
- 'p-invalid': props.invalid,
715
- 'p-variant-filled': props.variant ? props.variant === 'filled' : context && context.inputStyle === 'filled'
716
- });
717
- }
718
- };
719
- var CheckboxBase = ComponentBase.extend({
720
- defaultProps: {
721
- __TYPE: 'Checkbox',
722
- autoFocus: false,
723
- checked: false,
724
- className: null,
725
- disabled: false,
726
- falseValue: false,
727
- icon: null,
728
- id: null,
729
- inputId: null,
730
- inputRef: null,
731
- invalid: false,
732
- variant: null,
733
- name: null,
734
- onChange: null,
735
- onContextMenu: null,
736
- onMouseDown: null,
737
- readOnly: false,
738
- required: false,
739
- style: null,
740
- tabIndex: null,
741
- tooltip: null,
742
- tooltipOptions: null,
743
- trueValue: true,
744
- value: null,
745
- children: undefined
746
- },
747
- css: {
748
- classes: classes
749
- }
750
- });
751
-
752
- function ownKeys$5(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; }
753
- function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
754
- var Checkbox = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(function (inProps, ref) {
755
- var mergeProps = useMergeProps();
756
- var context = React.useContext(PrimeReactContext);
757
- var props = CheckboxBase.getProps(inProps, context);
758
- var _React$useState = React.useState(false),
759
- _React$useState2 = _slicedToArray(_React$useState, 2),
760
- focusedState = _React$useState2[0],
761
- setFocusedState = _React$useState2[1];
762
- var _CheckboxBase$setMeta = CheckboxBase.setMetaData({
763
- props: props,
764
- state: {
765
- focused: focusedState
766
- },
767
- context: {
768
- checked: props.checked === props.trueValue,
769
- disabled: props.disabled
770
- }
771
- }),
772
- ptm = _CheckboxBase$setMeta.ptm,
773
- cx = _CheckboxBase$setMeta.cx,
774
- isUnstyled = _CheckboxBase$setMeta.isUnstyled;
775
- useHandleStyle(CheckboxBase.css.styles, isUnstyled, {
776
- name: 'checkbox'
777
- });
778
- var elementRef = React.useRef(null);
779
- var inputRef = React.useRef(props.inputRef);
780
- var isChecked = function isChecked() {
781
- return props.checked === props.trueValue;
782
- };
783
- var _onChange = function onChange(event) {
784
- if (props.disabled || props.readonly) {
785
- return;
786
- }
787
- if (props.onChange) {
788
- var _props$onChange;
789
- var _checked = isChecked();
790
- var value = _checked ? props.falseValue : props.trueValue;
791
- var eventData = {
792
- originalEvent: event,
793
- value: props.value,
794
- checked: value,
795
- stopPropagation: function stopPropagation() {
796
- event === null || event === void 0 || event.stopPropagation();
797
- },
798
- preventDefault: function preventDefault() {
799
- event === null || event === void 0 || event.preventDefault();
800
- },
801
- target: {
802
- type: 'checkbox',
803
- name: props.name,
804
- id: props.id,
805
- value: props.value,
806
- checked: value
807
- }
808
- };
809
- props === null || props === void 0 || (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, eventData);
810
-
811
- // do not continue if the user defined click wants to prevent
812
- if (event.defaultPrevented) {
813
- return;
814
- }
815
- DomHandler.focus(inputRef.current);
816
- }
817
- };
818
- var _onFocus = function onFocus(event) {
819
- var _props$onFocus;
820
- setFocusedState(true);
821
- props === null || props === void 0 || (_props$onFocus = props.onFocus) === null || _props$onFocus === void 0 || _props$onFocus.call(props, event);
822
- };
823
- var _onBlur = function onBlur(event) {
824
- var _props$onBlur;
825
- setFocusedState(false);
826
- props === null || props === void 0 || (_props$onBlur = props.onBlur) === null || _props$onBlur === void 0 || _props$onBlur.call(props, event);
827
- };
828
- React.useImperativeHandle(ref, function () {
829
- return {
830
- props: props,
831
- focus: function focus() {
832
- return DomHandler.focus(inputRef.current);
833
- },
834
- getElement: function getElement() {
835
- return elementRef.current;
836
- },
837
- getInput: function getInput() {
838
- return inputRef.current;
839
- }
840
- };
841
- });
842
- React.useEffect(function () {
843
- ObjectUtils.combinedRefs(inputRef, props.inputRef);
844
- }, [inputRef, props.inputRef]);
845
- useUpdateEffect(function () {
846
- inputRef.current.checked = isChecked();
847
- }, [props.checked, props.trueValue]);
848
- useMountEffect(function () {
849
- if (props.autoFocus) {
850
- DomHandler.focus(inputRef.current, props.autoFocus);
851
- }
852
- });
853
- var checked = isChecked();
854
- var hasTooltip = ObjectUtils.isNotEmpty(props.tooltip);
855
- var otherProps = CheckboxBase.getOtherProps(props);
856
- var rootProps = mergeProps({
857
- id: props.id,
858
- className: classNames(props.className, cx('root', {
859
- checked: checked,
860
- context: context
861
- })),
862
- style: props.style,
863
- 'data-p-highlight': checked,
864
- 'data-p-disabled': props.disabled,
865
- onContextMenu: props.onContextMenu,
866
- onMouseDown: props.onMouseDown
867
- }, otherProps, ptm('root'));
868
- var createInputElement = function createInputElement() {
869
- var ariaProps = ObjectUtils.reduceKeys(otherProps, DomHandler.ARIA_PROPS);
870
- var inputProps = mergeProps(_objectSpread$5({
871
- id: props.inputId,
872
- type: 'checkbox',
873
- className: cx('input'),
874
- name: props.name,
875
- tabIndex: props.tabIndex,
876
- onFocus: function onFocus(e) {
877
- return _onFocus(e);
878
- },
879
- onBlur: function onBlur(e) {
880
- return _onBlur(e);
881
- },
882
- onChange: function onChange(e) {
883
- return _onChange(e);
884
- },
885
- disabled: props.disabled,
886
- readOnly: props.readOnly,
887
- required: props.required,
888
- 'aria-invalid': props.invalid,
889
- checked: checked
890
- }, ariaProps), ptm('input'));
891
- return /*#__PURE__*/React.createElement("input", _extends({
892
- ref: inputRef
893
- }, inputProps));
894
- };
895
- var createBoxElement = function createBoxElement() {
896
- var iconProps = mergeProps({
897
- className: cx('icon')
898
- }, ptm('icon'));
899
- var boxProps = mergeProps({
900
- className: cx('box', {
901
- checked: checked
902
- }),
903
- 'data-p-highlight': checked,
904
- 'data-p-disabled': props.disabled
905
- }, ptm('box'));
906
- var icon = checked ? props.icon || /*#__PURE__*/React.createElement(CheckIcon, iconProps) : null;
907
- var checkboxIcon = IconUtils.getJSXIcon(icon, _objectSpread$5({}, iconProps), {
908
- props: props,
909
- checked: checked
910
- });
911
- return /*#__PURE__*/React.createElement("div", boxProps, checkboxIcon);
912
- };
913
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", _extends({
914
- ref: elementRef
915
- }, rootProps), createInputElement(), createBoxElement()), hasTooltip && /*#__PURE__*/React.createElement(Tooltip, _extends({
916
- target: elementRef,
917
- content: props.tooltip,
918
- pt: ptm('tooltip')
919
- }, props.tooltipOptions)));
920
- }));
921
- Checkbox.displayName = 'Checkbox';
922
-
923
923
  function _createForOfIteratorHelper$3(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
924
924
  function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
925
925
  function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }