odaptos_design_system 2.0.72 → 2.0.73

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.
@@ -1,8 +1,4 @@
1
1
  import React from 'react';
2
- interface OptionType {
3
- label: string;
4
- value: string;
5
- }
6
2
  interface MultiSelectProps {
7
3
  label: string;
8
4
  placeholder?: string;
@@ -16,7 +12,7 @@ interface MultiSelectProps {
16
12
  disabled?: boolean;
17
13
  required?: boolean;
18
14
  defaultValue: any[];
19
- options: OptionType[];
15
+ options: any[];
20
16
  error?: boolean;
21
17
  helperText?: string;
22
18
  errorText?: string;
@@ -26,11 +22,9 @@ interface MultiSelectProps {
26
22
  deleteOption: (value: any) => void;
27
23
  limitTags?: number;
28
24
  onBlur?: () => void;
29
- loadMoreOptions?: () => Promise<OptionType[]>;
30
- initialLoadCount?: number;
31
25
  }
32
26
  /**
33
27
  * Use this component for multiselection !!
34
28
  */
35
- export declare const MultiSelect: ({ options: initialOptions, loadMoreOptions, initialLoadCount, label, placeholder, name, className, onChange, disabled, defaultValue, topLabel, topLabelWeight, topLabelSize, id, inputId, required, error, helperText, errorText, canAddNewOption, deleteOption, disableCloseOnSelect, limitTags, onBlur, ...props }: MultiSelectProps) => React.JSX.Element;
29
+ export declare const MultiSelect: ({ options, label, placeholder, name, className, onChange, disabled, defaultValue, topLabel, topLabelWeight, topLabelSize, id, inputId, required, error, helperText, errorText, canAddNewOption, deleteOption, disableCloseOnSelect, limitTags, onBlur, ...props }: MultiSelectProps) => React.JSX.Element;
36
30
  export {};
@@ -1,8 +1,4 @@
1
1
  import React from 'react';
2
- interface OptionType {
3
- label: string;
4
- value: string;
5
- }
6
2
  interface SingleSelectProps {
7
3
  label: string;
8
4
  placeholder?: string;
@@ -20,14 +16,12 @@ interface SingleSelectProps {
20
16
  errorText?: string;
21
17
  canAddNewOption?: boolean;
22
18
  defaultValue: any;
23
- options: OptionType[];
19
+ options: any[];
24
20
  onChange: (value: any) => void;
25
21
  onBlur?: () => void;
26
- loadMoreOptions?: () => Promise<OptionType[]>;
27
- initialLoadCount?: number;
28
22
  }
29
23
  /**
30
24
  * Use this component for single selection !!
31
25
  */
32
- export declare const SingleSelect: ({ options: initialOptions, loadMoreOptions, initialLoadCount, label, placeholder, name, className, onChange, disabled, defaultValue, topLabel, topLabelWeight, topLabelSize, id, inputId, required, error, helperText, errorText, canAddNewOption, onBlur, ...props }: SingleSelectProps) => React.JSX.Element;
26
+ export declare const SingleSelect: ({ options, label, placeholder, name, className, onChange, disabled, defaultValue, topLabel, topLabelWeight, topLabelSize, id, inputId, required, error, helperText, errorText, canAddNewOption, onBlur, ...props }: SingleSelectProps) => React.JSX.Element;
33
27
  export {};
@@ -13340,21 +13340,11 @@ const CssTextField$1 = /*#__PURE__*/styles$15.styled(material.TextField)({
13340
13340
  }
13341
13341
  }
13342
13342
  });
13343
- // Fonction utilitaire de debounce
13344
- const debounce = (func, delay) => {
13345
- let timeoutId;
13346
- return (...args) => {
13347
- clearTimeout(timeoutId);
13348
- timeoutId = setTimeout(() => func(...args), delay);
13349
- };
13350
- };
13351
13343
  /**
13352
13344
  * Use this component for multiselection !!
13353
13345
  */
13354
13346
  const MultiSelect = ({
13355
- options: initialOptions,
13356
- loadMoreOptions,
13357
- initialLoadCount = 50,
13347
+ options,
13358
13348
  label,
13359
13349
  placeholder,
13360
13350
  name,
@@ -13378,28 +13368,8 @@ const MultiSelect = ({
13378
13368
  onBlur,
13379
13369
  ...props
13380
13370
  }) => {
13381
- const [options, setOptions] = React.useState(initialOptions.slice(0, initialLoadCount));
13382
- const [loading, setLoading] = React.useState(false);
13383
- const [hasMore, setHasMore] = React.useState(initialOptions.length > initialLoadCount);
13384
13371
  const [value, setValue] = React.useState(defaultValue === undefined ? [] : defaultValue);
13385
13372
  const [inputValue, setInputValue] = React__default.useState('');
13386
- const loadMore = React.useCallback(async () => {
13387
- if (loading || !hasMore) return;
13388
- setLoading(true);
13389
- if (loadMoreOptions) {
13390
- const newOptions = await loadMoreOptions();
13391
- setOptions(prevOptions => [...prevOptions, ...newOptions]);
13392
- setHasMore(newOptions.length > 0);
13393
- } else {
13394
- const currentLength = options.length;
13395
- const nextOptions = initialOptions.slice(currentLength, currentLength + initialLoadCount);
13396
- setOptions(prevOptions => [...prevOptions, ...nextOptions]);
13397
- setHasMore(currentLength + nextOptions.length < initialOptions.length);
13398
- }
13399
- setLoading(false);
13400
- }, [loading, hasMore, loadMoreOptions, initialOptions, options.length, initialLoadCount]);
13401
- // Création d'une version debounced de loadMore
13402
- const debouncedLoadMore = React.useRef(debounce(loadMore, 300)).current;
13403
13373
  React.useEffect(() => {
13404
13374
  setValue(defaultValue === undefined ? [] : defaultValue);
13405
13375
  }, [defaultValue]);
@@ -13427,7 +13397,11 @@ const MultiSelect = ({
13427
13397
  setValue(newValue);
13428
13398
  onChange(newValue);
13429
13399
  },
13430
- options: options,
13400
+ options: options ? options : [{
13401
+ label: 'Loading...',
13402
+ value: 0,
13403
+ year: 100
13404
+ }],
13431
13405
  multiple: true,
13432
13406
  autoComplete: options.length > 10,
13433
13407
  size: "small",
@@ -13473,12 +13447,6 @@ const MultiSelect = ({
13473
13447
  renderOption: (props, option, {
13474
13448
  selected
13475
13449
  }) => {
13476
- if (option.value === 'load-more') {
13477
- return /*#__PURE__*/React__default.createElement(material.ListSubheader, {
13478
- key: "load-more",
13479
- component: "div"
13480
- }, loading ? 'Chargement...' : 'Charger plus');
13481
- }
13482
13450
  return /*#__PURE__*/React__default.createElement("li", Object.assign({}, props, {
13483
13451
  id: option.value,
13484
13452
  key: `${props.id}`,
@@ -13516,14 +13484,6 @@ const MultiSelect = ({
13516
13484
  });
13517
13485
  }
13518
13486
  return filtered;
13519
- },
13520
- ListboxProps: {
13521
- onScroll: event => {
13522
- const listboxNode = event.currentTarget;
13523
- if (listboxNode.scrollTop + listboxNode.clientHeight >= listboxNode.scrollHeight - 50) {
13524
- debouncedLoadMore();
13525
- }
13526
- }
13527
13487
  }
13528
13488
  }, props)), errorText && /*#__PURE__*/React__default.createElement(Text, {
13529
13489
  size: "xs",
@@ -15036,14 +14996,6 @@ var css_248z$J = ".SingleSelect-modules_newAutocomplete__eqYQo{min-width:16rem;w
15036
14996
  var styles$J = {"newAutocomplete":"SingleSelect-modules_newAutocomplete__eqYQo","MuiAutocomplete-endAdornment":"SingleSelect-modules_MuiAutocomplete-endAdornment__8EaFU","tags-container":"SingleSelect-modules_tags-container__ohLVa","input_top_label":"SingleSelect-modules_input_top_label__duzAQ","MuiOutlinedInput-root":"SingleSelect-modules_MuiOutlinedInput-root__bpVWQ","MuiInputBase-root":"SingleSelect-modules_MuiInputBase-root__FVaHT","MuiInputBase-formControl":"SingleSelect-modules_MuiInputBase-formControl__lYoNJ","text_below":"SingleSelect-modules_text_below__6l3Mu","icon":"SingleSelect-modules_icon__-dAuA"};
15037
14997
  styleInject(css_248z$J);
15038
14998
 
15039
- // Fonction utilitaire de debounce
15040
- const debounce$1 = (func, delay) => {
15041
- let timeoutId;
15042
- return (...args) => {
15043
- clearTimeout(timeoutId);
15044
- timeoutId = setTimeout(() => func(...args), delay);
15045
- };
15046
- };
15047
14999
  const filter$2 = /*#__PURE__*/Autocomplete.createFilterOptions();
15048
15000
  const CssTextField$6 = /*#__PURE__*/styles$15.styled(material.TextField)({
15049
15001
  '& .MuiInputBase-input': {
@@ -15136,9 +15088,7 @@ const CssTextField$6 = /*#__PURE__*/styles$15.styled(material.TextField)({
15136
15088
  * Use this component for single selection !!
15137
15089
  */
15138
15090
  const SingleSelect = ({
15139
- options: initialOptions,
15140
- loadMoreOptions,
15141
- initialLoadCount = 50,
15091
+ options,
15142
15092
  label,
15143
15093
  placeholder,
15144
15094
  name,
@@ -15161,29 +15111,9 @@ const SingleSelect = ({
15161
15111
  }) => {
15162
15112
  const [value, setValue] = React.useState(defaultValue === undefined ? null : defaultValue);
15163
15113
  const [inputValue, setInputValue] = React__default.useState('');
15164
- const [options, setOptions] = React.useState(initialOptions.slice(0, initialLoadCount));
15165
- const [loading, setLoading] = React.useState(false);
15166
- const [hasMore, setHasMore] = React.useState(initialOptions.length > initialLoadCount);
15167
15114
  React.useEffect(() => {
15168
15115
  setValue(defaultValue === undefined ? null : defaultValue);
15169
15116
  }, [defaultValue]);
15170
- const loadMore = React.useCallback(async () => {
15171
- if (loading || !hasMore) return;
15172
- setLoading(true);
15173
- if (loadMoreOptions) {
15174
- const newOptions = await loadMoreOptions();
15175
- setOptions(prevOptions => [...prevOptions, ...newOptions]);
15176
- setHasMore(newOptions.length > 0);
15177
- } else {
15178
- const currentLength = options.length;
15179
- const nextOptions = initialOptions.slice(currentLength, currentLength + initialLoadCount);
15180
- setOptions(prevOptions => [...prevOptions, ...nextOptions]);
15181
- setHasMore(currentLength + nextOptions.length < initialOptions.length);
15182
- }
15183
- setLoading(false);
15184
- }, [loading, hasMore, loadMoreOptions, initialOptions, options.length, initialLoadCount]);
15185
- // Création d'une version debounced de loadMore
15186
- const debouncedLoadMore = React.useRef(debounce$1(loadMore, 300)).current;
15187
15117
  return /*#__PURE__*/React__default.createElement("div", {
15188
15118
  className: `${className && className}`,
15189
15119
  style: {
@@ -15245,12 +15175,6 @@ const SingleSelect = ({
15245
15175
  }),
15246
15176
  className: `${styles$J.newAutocomplete}`,
15247
15177
  renderOption: (props, option) => {
15248
- if (option.value === 'load-more') {
15249
- return /*#__PURE__*/React__default.createElement(material.ListSubheader, {
15250
- key: "load-more",
15251
- component: "div"
15252
- }, loading ? 'Chargement...' : 'Charger plus');
15253
- }
15254
15178
  return /*#__PURE__*/React__default.createElement("li", Object.assign({}, props, {
15255
15179
  key: option.value,
15256
15180
  id: option.value
@@ -15259,14 +15183,6 @@ const SingleSelect = ({
15259
15183
  size: "sm"
15260
15184
  }));
15261
15185
  },
15262
- ListboxProps: {
15263
- onScroll: event => {
15264
- const listboxNode = event.currentTarget;
15265
- if (listboxNode.scrollTop + listboxNode.clientHeight >= listboxNode.scrollHeight - 50) {
15266
- debouncedLoadMore();
15267
- }
15268
- }
15269
- },
15270
15186
  filterOptions: (options, params) => {
15271
15187
  const filtered = filter$2(options, params);
15272
15188
  const {