@allxsmith/bestax-bulma 5.8.2 → 5.8.3

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.
package/dist/index.esm.js CHANGED
@@ -7067,10 +7067,16 @@ Rate.displayName = 'Rate';
7067
7067
  * onSelect={(item) => console.log(item)}
7068
7068
  * />
7069
7069
  */
7070
- const Autocomplete = forwardRef(({ data = [], value: controlledValue, placeholder, field = 'label', clearable = false, openOnFocus = false, keepFirst = false, keepOpen = false, selectOnClickOutside = false, maxHeight = 200, loading = false, disabled = false, checkInfiniteScroll = false, infiniteScrollDistance = 50, color, size, onInput, onSelect, onActiveChange, onInfiniteScroll, itemTemplate, header, footer, empty, name, form, required,
7070
+ const Autocomplete = forwardRef(({ data = [], value: controlledValue, placeholder, field = 'label', clearable = false, openOnFocus = false, keepFirst = false, keepOpen = false, selectOnClickOutside = false, maxHeight = 200, loading = false, disabled = false, checkInfiniteScroll = false, infiniteScrollDistance = 50, color, size, onInput, onSelect, onActiveChange, onInfiniteScroll, itemTemplate, header, footer, empty, name, form, required, id,
7071
7071
  // Field props
7072
7072
  label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName, className, ...props }, ref) => {
7073
7073
  const insideField = useInsideField();
7074
+ const { controlId, fieldLabelProps } = useAutoLabelId({
7075
+ label,
7076
+ id,
7077
+ labelProps,
7078
+ rendersLabel: !insideField,
7079
+ });
7074
7080
  const { bulmaHelperClasses, rest } = useBulmaClasses(props);
7075
7081
  const { classPrefix } = useConfig();
7076
7082
  const containerRef = useRef(null);
@@ -7266,7 +7272,7 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
7266
7272
  [`is-${messageColor}`]: !!messageColor,
7267
7273
  });
7268
7274
  const messageEl = message ? jsx("p", { className: helpClass, children: message }) : null;
7269
- const autocompleteElement = (jsxs("div", { ref: containerRef, className: combinedClasses, ...rest, children: [jsxs("div", { className: controlClasses, children: [jsx("input", { ref: combinedRef, type: "text", className: inputClasses, value: inputValue, placeholder: placeholder, disabled: disabled, name: name, form: form, required: required, onChange: handleInputChange, onFocus: handleFocus, onKeyDown: handleKeyDown, role: "combobox", "aria-expanded": isActive, "aria-haspopup": "listbox", "aria-autocomplete": "list", autoComplete: "off" }), clearable && inputValue && !disabled && (jsx("span", { className: iconRightClickableClass, onClick: handleClear, role: "button", "aria-label": "Clear", children: jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", width: "16", height: "16", children: [jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }) })), loading && (jsx("span", { className: iconRightClass, children: jsx("span", { className: loaderClass }) }))] }), isActive && (filteredData.length > 0 || empty) && (jsx("div", { className: dropdownMenuClasses, children: jsxs("div", { ref: dropdownRef, className: dropdownContentClass, style: { maxHeight: `${maxHeight}px`, overflowY: 'auto' }, role: "listbox", onScroll: handleDropdownScroll, children: [header && jsx("div", { className: dropdownHeaderClass, children: header }), filteredData.length > 0 ? (filteredData.map((item, index) => {
7275
+ const autocompleteElement = (jsxs("div", { ref: containerRef, className: combinedClasses, ...rest, children: [jsxs("div", { className: controlClasses, children: [jsx("input", { ref: combinedRef, type: "text", className: inputClasses, id: controlId, value: inputValue, placeholder: placeholder, disabled: disabled, name: name, form: form, required: required, onChange: handleInputChange, onFocus: handleFocus, onKeyDown: handleKeyDown, role: "combobox", "aria-expanded": isActive, "aria-haspopup": "listbox", "aria-autocomplete": "list", autoComplete: "off" }), clearable && inputValue && !disabled && (jsx("span", { className: iconRightClickableClass, onClick: handleClear, role: "button", "aria-label": "Clear", children: jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", width: "16", height: "16", children: [jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }) })), loading && (jsx("span", { className: iconRightClass, children: jsx("span", { className: loaderClass }) }))] }), isActive && (filteredData.length > 0 || empty) && (jsx("div", { className: dropdownMenuClasses, children: jsxs("div", { ref: dropdownRef, className: dropdownContentClass, style: { maxHeight: `${maxHeight}px`, overflowY: 'auto' }, role: "listbox", onScroll: handleDropdownScroll, children: [header && jsx("div", { className: dropdownHeaderClass, children: header }), filteredData.length > 0 ? (filteredData.map((item, index) => {
7270
7276
  const isDisabled = typeof item !== 'string' && item.disabled;
7271
7277
  const isHighlighted = index === highlightedIndex;
7272
7278
  const itemClasses = prefixedClassNames(classPrefix, 'dropdown-item', {
@@ -7278,7 +7284,7 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
7278
7284
  : getDisplayValue(item) }, index));
7279
7285
  })) : (jsx("div", { className: emptyItemClasses, children: empty })), footer && jsx("div", { className: dropdownFooterClass, children: footer })] }) }))] }));
7280
7286
  if (!insideField) {
7281
- return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: labelProps, horizontal: horizontal, className: fieldClassName, children: [autocompleteElement, messageEl] }));
7287
+ return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [autocompleteElement, messageEl] }));
7282
7288
  }
7283
7289
  return (jsxs(Fragment, { children: [autocompleteElement, messageEl] }));
7284
7290
  });
@@ -7309,7 +7315,7 @@ Autocomplete.displayName = 'Autocomplete';
7309
7315
  */
7310
7316
  const Taginput = forwardRef(({
7311
7317
  // Field props
7312
- label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName, value: controlledValue, defaultValue = [], data = [], placeholder, field = 'label', allowNew = true, allowDuplicates = false, openOnFocus = false, removeOnKeys = true, confirmKeys = ['Enter', ','], closable = true, attached = false, maxTags, maxlength, disabled = false, readonly = false, rounded = false, ellipsis = false, hasCounter = true, onPasteSeparators = [','], beforeAdding, createTag, keepFirst = false, keepOpen = true, loading = false, ariaCloseLabel, icon, iconLibrary: iconLibraryProp, iconVariant, iconFeatures, color, tagColor, size, onChange, onAdd, onRemove, onTyping, tagTemplate, name, form, className, ...props }, ref) => {
7318
+ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName, value: controlledValue, defaultValue = [], data = [], placeholder, field = 'label', allowNew = true, allowDuplicates = false, openOnFocus = false, removeOnKeys = true, confirmKeys = ['Enter', ','], closable = true, attached = false, maxTags, maxlength, disabled = false, readonly = false, rounded = false, ellipsis = false, hasCounter = true, onPasteSeparators = [','], beforeAdding, createTag, keepFirst = false, keepOpen = true, loading = false, ariaCloseLabel, icon, iconLibrary: iconLibraryProp, iconVariant, iconFeatures, color, tagColor, size, onChange, onAdd, onRemove, onTyping, tagTemplate, name, form, id, className, ...props }, ref) => {
7313
7319
  const insideField = useInsideField();
7314
7320
  const { bulmaHelperClasses, rest } = useBulmaClasses(props);
7315
7321
  const { classPrefix } = useConfig();
@@ -7325,6 +7331,15 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
7325
7331
  const [highlightedIndex, setHighlightedIndex] = useState(-1);
7326
7332
  // Use controlled or internal tags
7327
7333
  const tags = controlledValue !== undefined ? controlledValue : internalTags;
7334
+ const isMaxReached = maxTags !== undefined && tags.length >= maxTags;
7335
+ // At the tag limit the text input is not rendered, so there is nothing to
7336
+ // wire the label to.
7337
+ const { controlId, fieldLabelProps } = useAutoLabelId({
7338
+ label,
7339
+ id,
7340
+ labelProps,
7341
+ rendersLabel: !insideField && !isMaxReached,
7342
+ });
7328
7343
  // Get display value from tag
7329
7344
  const getDisplayValue = (tag) => {
7330
7345
  if (typeof tag === 'string')
@@ -7567,7 +7582,6 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
7567
7582
  [`is-${size}`]: !!size,
7568
7583
  });
7569
7584
  const combinedClasses = classNames(taginputClasses, bulmaHelperClasses, className);
7570
- const isMaxReached = maxTags !== undefined && tags.length >= maxTags;
7571
7585
  // Counter text
7572
7586
  const showCounter = hasCounter && (maxTags !== undefined || maxlength !== undefined);
7573
7587
  const counterText = maxTags !== undefined
@@ -7591,12 +7605,14 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
7591
7605
  e.stopPropagation();
7592
7606
  removeTag(index);
7593
7607
  }, "aria-label": ariaCloseLabel || `Remove ${displayVal}` }))] }, index));
7594
- }), !isMaxReached && (jsx("input", { ref: combinedRef, type: "text", className: inputClasses, value: inputValue, placeholder: tags.length === 0 ? placeholder : undefined, disabled: disabled, readOnly: readonly, maxLength: maxlength, onChange: handleInputChange, onFocus: handleFocus, onKeyDown: handleKeyDown, onPaste: handlePaste, "aria-label": "Add tag" }))] }), loading && (jsx("span", { className: iconRightClass, children: jsx("span", { className: loaderClass }) }))] }), isActive && filteredData.length > 0 && (jsx("div", { className: dropdownMenuClasses, children: jsx("div", { ref: dropdownRef, className: dropdownContentClasses, role: "listbox", children: filteredData.map((item, index) => (jsx("a", { className: pcn('dropdown-item', {
7608
+ }), !isMaxReached && (jsx("input", { ref: combinedRef, type: "text", className: inputClasses, id: controlId, value: inputValue, placeholder: tags.length === 0 ? placeholder : undefined, disabled: disabled, readOnly: readonly, maxLength: maxlength, onChange: handleInputChange, onFocus: handleFocus, onKeyDown: handleKeyDown, onPaste: handlePaste, "aria-label": controlId && fieldLabelProps?.htmlFor === controlId
7609
+ ? undefined
7610
+ : 'Add tag' }))] }), loading && (jsx("span", { className: iconRightClass, children: jsx("span", { className: loaderClass }) }))] }), isActive && filteredData.length > 0 && (jsx("div", { className: dropdownMenuClasses, children: jsx("div", { ref: dropdownRef, className: dropdownContentClasses, role: "listbox", children: filteredData.map((item, index) => (jsx("a", { className: pcn('dropdown-item', {
7595
7611
  'is-active': index === highlightedIndex,
7596
7612
  }), onClick: () => addTag(item), onMouseEnter: () => setHighlightedIndex(index), role: "option", "aria-selected": index === highlightedIndex, children: item }, index))) }) })), showCounter && jsx("small", { className: counterClasses, children: counterText }), name &&
7597
7613
  tags.map((tag, i) => (jsx("input", { type: "hidden", name: name, value: getDisplayValue(tag), form: form }, `tag-input-${i}`)))] }));
7598
7614
  if (!insideField) {
7599
- return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: labelProps, horizontal: horizontal, className: fieldClassName, children: [taginputElement, messageEl] }));
7615
+ return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [taginputElement, messageEl] }));
7600
7616
  }
7601
7617
  return (jsxs(Fragment, { children: [taginputElement, messageEl] }));
7602
7618
  });