@selfcommunity/react-ui 0.10.0-alpha.4 → 0.10.0-alpha.5

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.
@@ -56,7 +56,7 @@ const TagAutocomplete = (inProps) => {
56
56
  const [open, setOpen] = (0, react_1.useState)(false);
57
57
  const [value, setValue] = (0, react_1.useState)(typeof defaultValue === 'string' ? null : defaultValue);
58
58
  // HOOKS
59
- const { scAddressingTags } = (0, react_core_1.useSCFetchAddressingTagList)({ fetch: true });
59
+ const { scAddressingTags } = (0, react_core_1.useSCFetchAddressingTagList)({ fetch: open || defaultValue });
60
60
  (0, react_1.useEffect)(() => {
61
61
  if (value === null) {
62
62
  return;
@@ -64,7 +64,7 @@ const TagAutocomplete = (inProps) => {
64
64
  onChange && onChange(value);
65
65
  }, [value]);
66
66
  (0, react_1.useEffect)(() => {
67
- if (scAddressingTags && typeof defaultValue === 'string') {
67
+ if ((scAddressingTags === null || scAddressingTags === void 0 ? void 0 : scAddressingTags.length) !== 0 && typeof defaultValue === 'string') {
68
68
  setValue(scAddressingTags.find((t) => t.id === Number(defaultValue)));
69
69
  }
70
70
  }, [scAddressingTags, defaultValue]);
@@ -79,7 +79,7 @@ const TagAutocomplete = (inProps) => {
79
79
  setValue(newValue);
80
80
  };
81
81
  // Render
82
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: classes.root, open: open, onOpen: handleOpen, onClose: handleClose, options: scAddressingTags || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, handleHomeEndKeys: true, clearIcon: null, noOptionsText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.tags.empty", defaultMessage: "ui.composer.layer.audience.tags.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id, renderTags: (value, getTagProps) => {
82
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: classes.root, open: open, onOpen: handleOpen, onClose: handleClose, options: scAddressingTags || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, handleHomeEndKeys: true, clearIcon: null, noOptionsText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.tags.empty", defaultMessage: "ui.composer.layer.audience.tags.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => (value === null || value === void 0 ? void 0 : value.id) === (option === null || option === void 0 ? void 0 : option.id), renderTags: (value, getTagProps) => {
83
83
  return value.map((option, index) => (0, jsx_runtime_1.jsx)(TagChip_1.default, Object.assign({ tag: option }, getTagProps({ index })), option.id));
84
84
  }, renderOption: (props, option, { selected, inputValue }) => {
85
85
  const matches = (0, match_1.default)(option.name, inputValue);
@@ -54,7 +54,7 @@ const TagAutocomplete = (inProps) => {
54
54
  const [open, setOpen] = useState(false);
55
55
  const [value, setValue] = useState(typeof defaultValue === 'string' ? null : defaultValue);
56
56
  // HOOKS
57
- const { scAddressingTags } = useSCFetchAddressingTagList({ fetch: true });
57
+ const { scAddressingTags } = useSCFetchAddressingTagList({ fetch: open || defaultValue });
58
58
  useEffect(() => {
59
59
  if (value === null) {
60
60
  return;
@@ -62,7 +62,7 @@ const TagAutocomplete = (inProps) => {
62
62
  onChange && onChange(value);
63
63
  }, [value]);
64
64
  useEffect(() => {
65
- if (scAddressingTags && typeof defaultValue === 'string') {
65
+ if ((scAddressingTags === null || scAddressingTags === void 0 ? void 0 : scAddressingTags.length) !== 0 && typeof defaultValue === 'string') {
66
66
  setValue(scAddressingTags.find((t) => t.id === Number(defaultValue)));
67
67
  }
68
68
  }, [scAddressingTags, defaultValue]);
@@ -77,7 +77,7 @@ const TagAutocomplete = (inProps) => {
77
77
  setValue(newValue);
78
78
  };
79
79
  // Render
80
- return (_jsx(Root, Object.assign({ className: classes.root, open: open, onOpen: handleOpen, onClose: handleClose, options: scAddressingTags || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, handleHomeEndKeys: true, clearIcon: null, noOptionsText: _jsx(FormattedMessage, { id: "ui.composer.layer.audience.tags.empty", defaultMessage: "ui.composer.layer.audience.tags.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id, renderTags: (value, getTagProps) => {
80
+ return (_jsx(Root, Object.assign({ className: classes.root, open: open, onOpen: handleOpen, onClose: handleClose, options: scAddressingTags || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, handleHomeEndKeys: true, clearIcon: null, noOptionsText: _jsx(FormattedMessage, { id: "ui.composer.layer.audience.tags.empty", defaultMessage: "ui.composer.layer.audience.tags.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => (value === null || value === void 0 ? void 0 : value.id) === (option === null || option === void 0 ? void 0 : option.id), renderTags: (value, getTagProps) => {
81
81
  return value.map((option, index) => _jsx(TagChip, Object.assign({ tag: option }, getTagProps({ index })), option.id));
82
82
  }, renderOption: (props, option, { selected, inputValue }) => {
83
83
  const matches = match(option.name, inputValue);