arengibook 2.4.585 → 2.4.587

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 (2) hide show
  1. package/dist/index.js +282 -153
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -35801,196 +35801,223 @@ var PopupPresets = {
35801
35801
  var Dropdown = function Dropdown(_ref) {
35802
35802
  var _ref$options = _ref.options,
35803
35803
  options = _ref$options === void 0 ? [] : _ref$options,
35804
- _ref$isGroupedOption = _ref.isGroupedOption,
35805
- isGroupedOption = _ref$isGroupedOption === void 0 ? false : _ref$isGroupedOption,
35806
35804
  value = _ref.value,
35807
35805
  _ref$placeholder = _ref.placeholder,
35808
35806
  placeholder = _ref$placeholder === void 0 ? 'Sélectionnez une option' : _ref$placeholder,
35809
- _ref$disabled = _ref.disabled,
35810
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
35811
- _ref$filter = _ref.filter,
35812
- filter = _ref$filter === void 0 ? false : _ref$filter,
35813
- _ref$optionLabel = _ref.optionLabel,
35814
- optionLabel = _ref$optionLabel === void 0 ? 'label' : _ref$optionLabel,
35815
- _ref$optionValue = _ref.optionValue,
35816
- optionValue = _ref$optionValue === void 0 ? 'value' : _ref$optionValue,
35817
- _ref$invalid = _ref.invalid,
35818
- invalid = _ref$invalid === void 0 ? false : _ref$invalid,
35819
- _ref$errorMessage = _ref.errorMessage,
35820
- errorMessage = _ref$errorMessage === void 0 ? '' : _ref$errorMessage,
35807
+ _ref$readOnly = _ref.readOnly,
35808
+ readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
35809
+ _ref$multiple = _ref.multiple,
35810
+ multiple = _ref$multiple === void 0 ? false : _ref$multiple,
35811
+ name = _ref.name,
35812
+ classInput = _ref.classInput,
35813
+ ongletID = _ref.ongletID,
35814
+ onChangeFunction = _ref.onChangeFunction,
35815
+ _ref$isSelectMeta = _ref.isSelectMeta,
35816
+ isSelectMeta = _ref$isSelectMeta === void 0 ? false : _ref$isSelectMeta,
35817
+ _ref$selectMetaConfig = _ref.selectMetaConfig,
35818
+ selectMetaConfig = _ref$selectMetaConfig === void 0 ? {
35819
+ generalIcon: null
35820
+ } : _ref$selectMetaConfig,
35821
35821
  _ref$valueStyle = _ref.valueStyle,
35822
35822
  valueStyle = _ref$valueStyle === void 0 ? {
35823
- paddingTop: '1rem',
35824
- paddingBottom: '1rem'
35823
+ fontSize: '14px',
35824
+ fontFamily: 'Arial'
35825
35825
  } : _ref$valueStyle,
35826
35826
  _ref$optionStyle = _ref.optionStyle,
35827
- optionStyle = _ref$optionStyle === void 0 ? {} : _ref$optionStyle,
35828
- name = _ref.name,
35829
- _ref$showClear = _ref.showClear,
35830
- showClear = _ref$showClear === void 0 ? false : _ref$showClear,
35831
- _ref$groupedItemTempl = _ref.groupedItemTemplateConfig,
35832
- groupedItemTemplateConfig = _ref$groupedItemTempl === void 0 ? {
35833
- showIcon: false,
35834
- iconKey: 'icon',
35835
- showImage: false,
35836
- imageKey: 'image',
35837
- imageStyle: null,
35838
- labelStyle: null,
35839
- generalIcon: null,
35840
- generalImage: null
35841
- } : _ref$groupedItemTempl;
35827
+ optionStyle = _ref$optionStyle === void 0 ? {
35828
+ fontSize: '14px',
35829
+ fontFamily: 'Arial'
35830
+ } : _ref$optionStyle;
35842
35831
  var _useState = useState(value !== null && value !== void 0 ? value : null),
35843
35832
  _useState2 = _slicedToArray$8(_useState, 2),
35844
35833
  optionSelected = _useState2[0],
35845
35834
  setOptionSelected = _useState2[1];
35835
+ var _useState3 = useState(false),
35836
+ _useState4 = _slicedToArray$8(_useState3, 2),
35837
+ isOpen = _useState4[0],
35838
+ setIsOpen = _useState4[1];
35839
+ var ref = useRef();
35840
+ var refValue = useRef();
35846
35841
  useEffect(function () {
35847
35842
  setOptionSelected(value !== null && value !== void 0 ? value : null);
35848
35843
  }, [value]);
35844
+ var inverseColor = function inverseColor(hexColor) {
35845
+ var r = parseInt(hexColor.substr(1, 2), 16);
35846
+ var g = parseInt(hexColor.substr(3, 2), 16);
35847
+ var b = parseInt(hexColor.substr(5, 2), 16);
35848
+ var luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
35849
+ return luminance > 0.5 ? '#000000' : '#FFFFFF';
35850
+ };
35851
+ var handleChange = function handleChange(e) {
35852
+ var newValue = e.value;
35853
+ setOptionSelected(newValue);
35854
+ if (onChangeFunction) {
35855
+ onChangeFunction(newValue);
35856
+ }
35857
+ if (!multiple) {
35858
+ setIsOpen(false);
35859
+ }
35860
+ };
35861
+ var onMenuOpen = function onMenuOpen() {
35862
+ setIsOpen(true);
35863
+ };
35864
+ var onMenuClose = function onMenuClose() {
35865
+ setIsOpen(false);
35866
+ };
35867
+ var handleClickOutside = function handleClickOutside(e) {
35868
+ if (ref.current && !ref.current.contains(e.target)) {
35869
+ setIsOpen(false);
35870
+ }
35871
+ };
35849
35872
  useEffect(function () {
35850
- var handleScroll = function handleScroll(e) {
35851
- var target = e.target;
35852
-
35853
- // Si on scroll dans la liste elle-même (aucun effet de suppression de liste)
35854
- if (target.closest && target.closest('.p-dropdown-panel')) {
35855
- return;
35856
- }
35857
-
35858
- // Sinon, le zone de liste est fermée
35859
- var dropdownPanels = document.querySelectorAll('.p-dropdown-panel');
35860
- dropdownPanels.forEach(function (panel) {
35861
- if (panel && panel.style.display !== 'none') {
35862
- document.body.click(); // Déclenche un "click outside"
35863
- }
35864
- });
35865
- };
35866
- window.addEventListener('scroll', handleScroll, true);
35873
+ document.addEventListener('mousedown', handleClickOutside);
35867
35874
  return function () {
35868
- window.removeEventListener('scroll', handleScroll, true);
35875
+ document.removeEventListener('mousedown', handleClickOutside);
35869
35876
  };
35870
35877
  }, []);
35871
- var resetDropdownFilter = function resetDropdownFilter() {
35872
- setTimeout(function () {
35873
- var dropdownPanels = document.querySelectorAll('.p-dropdown-panel');
35874
- dropdownPanels.forEach(function (panel) {
35875
- var input = panel.querySelector('.p-dropdown-filter');
35876
- if (input) {
35877
- input.value = '';
35878
- input.dispatchEvent(new Event('input', {
35879
- bubbles: true
35880
- }));
35881
- }
35878
+ var renderSelectedItems = function renderSelectedItems() {
35879
+ if (!optionSelected) return null;
35880
+ if (multiple && Array.isArray(optionSelected)) {
35881
+ if (optionSelected.length <= 5) {
35882
+ return optionSelected.map(function (opt, index) {
35883
+ return opt && opt.color && opt.nom ? /*#__PURE__*/React__default.createElement("span", {
35884
+ key: index,
35885
+ className: "badge badge-primary select-badge",
35886
+ style: {
35887
+ backgroundColor: opt.color
35888
+ }
35889
+ }, opt.nom) : null;
35890
+ });
35891
+ } else {
35892
+ return /*#__PURE__*/React__default.createElement("div", {
35893
+ onClick: function onClick(e) {
35894
+ e.stopPropagation();
35895
+ setIsOpen(false);
35896
+ var event = new CustomEvent('openInfoSelect', {
35897
+ detail: {
35898
+ value: optionSelected
35899
+ }
35900
+ });
35901
+ document.dispatchEvent(event);
35902
+ }
35903
+ }, /*#__PURE__*/React__default.createElement("div", {
35904
+ className: "selectMetaCounter"
35905
+ }, /*#__PURE__*/React__default.createElement("span", {
35906
+ className: "badge trigger_popup_fricc"
35907
+ }, optionSelected.length), /*#__PURE__*/React__default.createElement("div", {
35908
+ className: "test-title-ON"
35909
+ }, "Toggle")));
35910
+ }
35911
+ } else if (optionSelected.color && optionSelected.nom) {
35912
+ return /*#__PURE__*/React__default.createElement("span", {
35913
+ className: "badge badge-primary select-badge",
35914
+ style: {
35915
+ backgroundColor: optionSelected.color,
35916
+ color: inverseColor(optionSelected.color)
35917
+ }
35918
+ }, optionSelected.nom);
35919
+ }
35920
+ };
35921
+ var renderHiddenInputs = function renderHiddenInputs() {
35922
+ if (multiple && Array.isArray(optionSelected)) {
35923
+ return optionSelected.map(function (opt, index) {
35924
+ return opt && opt.id ? /*#__PURE__*/React__default.createElement("input", {
35925
+ type: "hidden",
35926
+ key: index,
35927
+ name: !readOnly ? name : '',
35928
+ className: classInput,
35929
+ "data-id-onglet": ongletID,
35930
+ value: opt.id,
35931
+ "data-name": opt.nom,
35932
+ ref: index === 0 ? refValue : null
35933
+ }) : null;
35882
35934
  });
35883
- }, 50);
35884
- };
35885
- var style = {
35886
- border: invalid ? '1px solid red' : '1px solid #ccc',
35887
- width: '100%'
35935
+ } else if (optionSelected && optionSelected.id) {
35936
+ return /*#__PURE__*/React__default.createElement("input", {
35937
+ type: "hidden",
35938
+ name: !readOnly ? name : '',
35939
+ className: classInput,
35940
+ "data-id-onglet": ongletID,
35941
+ value: optionSelected.id,
35942
+ "data-name": optionSelected.nom,
35943
+ ref: refValue
35944
+ });
35945
+ }
35946
+ return null;
35888
35947
  };
35889
35948
  var optionTemplate = function optionTemplate(option) {
35890
- return /*#__PURE__*/React__default.createElement("div", {
35891
- style: _objectSpread2({
35892
- fontSize: '14px'
35893
- }, optionStyle)
35894
- }, option.label);
35895
- };
35896
- var valueTemplate = function valueTemplate(option) {
35897
- return /*#__PURE__*/React__default.createElement("span", {
35898
- style: _objectSpread2({
35899
- fontFamily: 'Arial',
35900
- fontSize: '14px'
35901
- }, valueStyle)
35902
- }, (option === null || option === void 0 ? void 0 : option.label) || placeholder);
35903
- };
35904
- var groupedItemTemplate = function groupedItemTemplate(option) {
35905
- var _ref2 = groupedItemTemplateConfig || {},
35906
- showImage = _ref2.showImage,
35907
- imageKey = _ref2.imageKey,
35908
- imageStyle = _ref2.imageStyle,
35909
- showIcon = _ref2.showIcon,
35910
- iconKey = _ref2.iconKey,
35911
- labelStyle = _ref2.labelStyle,
35912
- generalIcon = _ref2.generalIcon,
35913
- generalImage = _ref2.generalImage;
35914
- var icon = option.value && option.value[iconKey];
35915
- var styleLabel = {};
35916
- if (generalIcon || generalIcon || showImage && option[imageKey] || showIcon && icon) {
35917
- styleLabel = {
35918
- 'marginLeft': '10px'
35949
+ if (!isSelectMeta) {
35950
+ return /*#__PURE__*/React__default.createElement("div", {
35951
+ style: _objectSpread2({
35952
+ fontSize: '14px'
35953
+ }, optionStyle)
35954
+ }, option.label);
35955
+ } else {
35956
+ var _ref2 = selectMetaConfig || {},
35957
+ generalIcon = _ref2.generalIcon;
35958
+ var styleLabel = {
35959
+ marginLeft: '10px',
35960
+ color: option === null || option === void 0 ? void 0 : option.color
35919
35961
  };
35920
- }
35921
- if (option.group) {
35922
35962
  return /*#__PURE__*/React__default.createElement("div", {
35923
- className: "flex align-items-center"
35963
+ className: "flex align-items-center",
35964
+ style: {
35965
+ width: '100%'
35966
+ }
35924
35967
  }, /*#__PURE__*/React__default.createElement("div", {
35925
- style: _objectSpread2({
35968
+ style: {
35926
35969
  fontSize: '15px',
35927
35970
  fontWeight: 'bold'
35928
- }, labelStyle)
35971
+ }
35929
35972
  }, generalIcon && /*#__PURE__*/React__default.createElement("i", {
35930
- style: _objectSpread2({
35931
- fontSize: '15px',
35932
- fontWeight: 'bold'
35933
- }, labelStyle),
35934
- className: generalIcon
35935
- }), generalImage && /*#__PURE__*/React__default.createElement("img", {
35936
- alt: "General",
35937
- src: generalImage,
35938
- style: imageStyle || {
35939
- width: '18px',
35940
- marginRight: '0.5rem'
35941
- },
35942
- className: "mr-2"
35943
- }), showImage && option[imageKey] && /*#__PURE__*/React__default.createElement("img", {
35944
- alt: option.label,
35945
- src: option[imageKey],
35946
- style: imageStyle || {
35947
- width: '18px',
35948
- marginRight: '0.5rem'
35973
+ style: {
35974
+ color: option === null || option === void 0 ? void 0 : option.color
35949
35975
  },
35950
- className: "mr-2"
35951
- }), showIcon && icon && /*#__PURE__*/React__default.createElement("i", {
35952
- style: _objectSpread2({
35953
- fontSize: '15px',
35954
- fontWeight: 'bold'
35955
- }, labelStyle),
35956
- className: 'mr-2 ' + icon
35976
+ className: generalIcon
35957
35977
  }), /*#__PURE__*/React__default.createElement("span", {
35958
35978
  style: styleLabel
35959
- }, option.label)));
35979
+ }, (option === null || option === void 0 ? void 0 : option.nom) || (option === null || option === void 0 ? void 0 : option.label))));
35980
+ }
35981
+ };
35982
+ var valueTemplate = function valueTemplate(option) {
35983
+ if (!option) {
35984
+ return /*#__PURE__*/React__default.createElement("span", {
35985
+ style: valueStyle
35986
+ }, placeholder);
35960
35987
  }
35988
+ var iconColor = option !== null && option !== void 0 && option.color ? inverseColor(option.color) : '#FFFFFF';
35989
+ return /*#__PURE__*/React__default.createElement("div", {
35990
+ style: _objectSpread2({
35991
+ backgroundColor: option.color,
35992
+ color: iconColor,
35993
+ padding: '0.5rem',
35994
+ borderRadius: '1rem',
35995
+ display: 'inline-block'
35996
+ }, valueStyle)
35997
+ }, option.nom || option.label);
35961
35998
  };
35962
35999
  return /*#__PURE__*/React__default.createElement("div", {
35963
- className: "flex flex-col gap-1"
35964
- }, /*#__PURE__*/React__default.createElement(Dropdown$1, _extends$A({
36000
+ className: "select-form-event-container ".concat(readOnly ? 'select-form-event-container-readonly' : ''),
36001
+ ref: ref
36002
+ }, /*#__PURE__*/React__default.createElement("div", {
36003
+ className: "select-badges-container",
36004
+ onClick: function onClick() {
36005
+ return !readOnly && setIsOpen(true);
36006
+ }
36007
+ }, renderSelectedItems()), !readOnly && /*#__PURE__*/React__default.createElement("span", {
36008
+ className: "caret"
36009
+ }), /*#__PURE__*/React__default.createElement(Dropdown$1, {
35965
36010
  value: optionSelected,
35966
36011
  options: options,
35967
- onChange: function onChange(e) {
35968
- return setOptionSelected(e.value);
35969
- },
36012
+ onChange: handleChange,
35970
36013
  placeholder: placeholder,
35971
- disabled: disabled,
35972
- filter: filter,
35973
- optionLabel: optionLabel,
35974
- optionValue: optionValue,
35975
- style: style,
36014
+ disabled: readOnly,
36015
+ onShow: onMenuOpen,
36016
+ onHide: onMenuClose,
36017
+ menuIsOpen: isOpen,
35976
36018
  itemTemplate: optionTemplate,
35977
- valueTemplate: valueTemplate,
35978
- onHide: resetDropdownFilter,
35979
- showClear: showClear,
35980
- optionGroupTemplate: isGroupedOption ? groupedItemTemplate : null
35981
- }, isGroupedOption && {
35982
- optionGroupLabel: 'label',
35983
- optionGroupChildren: 'items'
35984
- })), name && /*#__PURE__*/React__default.createElement("input", {
35985
- type: "hidden",
35986
- name: name,
35987
- value: optionSelected !== null && optionSelected !== void 0 ? optionSelected : ''
35988
- }), invalid && /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("small", {
35989
- style: {
35990
- color: 'red',
35991
- fontStyle: 'italic'
35992
- }
35993
- }, errorMessage || 'Sélection invalide')));
36019
+ valueTemplate: valueTemplate
36020
+ }), /*#__PURE__*/React__default.createElement("div", null, renderHiddenInputs()));
35994
36021
  };
35995
36022
 
35996
36023
  var optionsExample = [{
@@ -36003,6 +36030,76 @@ var optionsExample = [{
36003
36030
  label: 'Option 3',
36004
36031
  value: '3'
36005
36032
  }];
36033
+ var optionsGroup = [{
36034
+ label: 'Germany',
36035
+ code: 'DE',
36036
+ items: [{
36037
+ label: 'Berlin',
36038
+ value: 'Berlin'
36039
+ }, {
36040
+ label: 'Frankfurt',
36041
+ value: 'Frankfurt'
36042
+ }, {
36043
+ label: 'Hamburg',
36044
+ value: 'Hamburg'
36045
+ }, {
36046
+ label: 'Munich',
36047
+ value: 'Munich'
36048
+ }]
36049
+ }, {
36050
+ label: 'USA',
36051
+ code: 'US',
36052
+ items: [{
36053
+ label: 'Chicago',
36054
+ value: 'Chicago'
36055
+ }, {
36056
+ label: 'Los Angeles',
36057
+ value: 'Los Angeles'
36058
+ }, {
36059
+ label: 'New York',
36060
+ value: 'New York'
36061
+ }, {
36062
+ label: 'San Francisco',
36063
+ value: 'San Francisco'
36064
+ }]
36065
+ }, {
36066
+ label: 'Japan',
36067
+ code: 'JP',
36068
+ items: [{
36069
+ label: 'Kyoto',
36070
+ value: 'Kyoto'
36071
+ }, {
36072
+ label: 'Osaka',
36073
+ value: 'Osaka'
36074
+ }, {
36075
+ label: 'Tokyo',
36076
+ value: 'Tokyo'
36077
+ }, {
36078
+ label: 'Yokohama',
36079
+ value: 'Yokohama'
36080
+ }]
36081
+ }];
36082
+ var optionsWithColors = [{
36083
+ label: 'Rouge',
36084
+ value: 'rouge',
36085
+ color: '#FF0000'
36086
+ }, {
36087
+ label: 'Vert',
36088
+ value: 'vert',
36089
+ color: '#00FF00'
36090
+ }, {
36091
+ label: 'Bleu',
36092
+ value: 'bleu',
36093
+ color: '#0000FF'
36094
+ }, {
36095
+ label: 'Jaune',
36096
+ value: 'jaune',
36097
+ color: '#FFFF00'
36098
+ }, {
36099
+ label: 'Cyan',
36100
+ value: 'cyan',
36101
+ color: '#00FFFF'
36102
+ }];
36006
36103
  var DropdownPresets = {
36007
36104
  Default: {
36008
36105
  placeholder: 'Sélectionnez une option',
@@ -36016,6 +36113,38 @@ var DropdownPresets = {
36016
36113
  fontFamily: 'Arial'
36017
36114
  }
36018
36115
  },
36116
+ SelectMeta: {
36117
+ placeholder: 'Sélectionnez une couleur',
36118
+ options: optionsWithColors,
36119
+ isSelectMeta: true,
36120
+ selectMetaConfig: {
36121
+ generalIcon: 'pi pi-circle-fill'
36122
+ },
36123
+ valueStyle: {
36124
+ fontSize: '14px',
36125
+ fontFamily: 'Arial'
36126
+ },
36127
+ optionStyle: {
36128
+ fontSize: '14px',
36129
+ fontFamily: 'Arial'
36130
+ }
36131
+ },
36132
+ Group: {
36133
+ placeholder: 'Veuillez choisir une option',
36134
+ options: optionsGroup,
36135
+ disabled: false,
36136
+ isGroupedOption: true,
36137
+ groupedItemTemplateConfig: {
36138
+ showIcon: false,
36139
+ iconKey: 'icon',
36140
+ showImage: false,
36141
+ imageKey: 'image',
36142
+ imageStyle: null,
36143
+ labelStyle: null,
36144
+ generalIcon: null,
36145
+ generalImage: 'https://tse1.mm.bing.net/th/id/OIP.IQHLwUwt5fy7E-ag0W-34gHaHa?w=474&h=474&c=7'
36146
+ }
36147
+ },
36019
36148
  Disabled: {
36020
36149
  placeholder: 'Sélection désactivée',
36021
36150
  options: optionsExample,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arengibook",
3
3
  "private": false,
4
- "version": "2.4.585",
4
+ "version": "2.4.587",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "exports": {