@allxsmith/bestax-bulma 5.8.1 → 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.cjs.js CHANGED
@@ -5903,6 +5903,25 @@ const CheckboxesComponent = ({ label, labelSize, labelProps, horizontal, message
5903
5903
  };
5904
5904
  const Checkboxes = withSubComponents(CheckboxesComponent, { Checkbox }, 'Checkboxes');
5905
5905
 
5906
+ /**
5907
+ * Associates the convenience `label` prop with its control (#368): generates
5908
+ * an id for the control and returns labelProps carrying a matching `htmlFor`.
5909
+ * A user-supplied `id` is used as the target instead of the generated one, and
5910
+ * an explicit `labelProps.htmlFor` disables generation entirely — the user has
5911
+ * taken over the association. Internal; not part of the public API.
5912
+ */
5913
+ function useAutoLabelId({ label, id, labelProps, rendersLabel, }) {
5914
+ // Called unconditionally per the rules of hooks; SSR-safe on React 18 and 19.
5915
+ const generatedId = React.useId();
5916
+ // Truthiness mirrors Field's own `if (label)` render gate.
5917
+ const active = !!label && rendersLabel;
5918
+ const controlId = id ?? (active && !labelProps?.htmlFor ? generatedId : undefined);
5919
+ const fieldLabelProps = active
5920
+ ? { htmlFor: controlId, ...labelProps }
5921
+ : labelProps;
5922
+ return { controlId, fieldLabelProps };
5923
+ }
5924
+
5906
5925
  /**
5907
5926
  * The `File` component provides a Bulma-styled file input, supporting color, size, boxed/fullwidth/align styles, icons, "has name", and filename display.
5908
5927
  *
@@ -5915,6 +5934,12 @@ const File = React.forwardRef(({
5915
5934
  // Field props
5916
5935
  label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName, color, size, isBoxed, isFullwidth, isRight, isCentered, hasName, buttonLabel, iconLeft, iconRight, className, inputClassName, fileName, ...props }, ref) => {
5917
5936
  const insideField = useInsideField();
5937
+ const { controlId, fieldLabelProps } = useAutoLabelId({
5938
+ label,
5939
+ id: props.id,
5940
+ labelProps,
5941
+ rendersLabel: !insideField,
5942
+ });
5918
5943
  const { classPrefix } = useConfig();
5919
5944
  const { bulmaHelperClasses, rest } = useBulmaClasses({
5920
5945
  color,
@@ -5944,9 +5969,9 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
5944
5969
  [`is-${messageColor}`]: !!messageColor,
5945
5970
  });
5946
5971
  const messageEl = message ? jsxRuntime.jsx("p", { className: helpClass, children: message }) : null;
5947
- const fileElement = (jsxRuntime.jsx("div", { className: fileClass, children: jsxRuntime.jsxs("label", { className: usePrefixedClassNames('file-label'), children: [jsxRuntime.jsx("input", { ref: ref, className: classNames(usePrefixedClassNames('file-input'), inputClassName), type: "file", ...rest }), jsxRuntime.jsxs("span", { className: usePrefixedClassNames('file-cta'), children: [iconLeft && (jsxRuntime.jsx("span", { className: prefixedClassNames(classPrefix, 'file-icon'), children: iconLeft })), jsxRuntime.jsx("span", { className: usePrefixedClassNames('file-label'), children: buttonLabel || 'Choose a file\u2026' }), iconRight && (jsxRuntime.jsx("span", { className: prefixedClassNames(classPrefix, 'file-icon'), children: iconRight }))] }), hasName && fileName && (jsxRuntime.jsx("span", { className: prefixedClassNames(classPrefix, 'file-name'), children: fileName }))] }) }));
5972
+ const fileElement = (jsxRuntime.jsx("div", { className: fileClass, children: jsxRuntime.jsxs("label", { className: usePrefixedClassNames('file-label'), children: [jsxRuntime.jsx("input", { ref: ref, className: classNames(usePrefixedClassNames('file-input'), inputClassName), type: "file", id: controlId, ...rest }), jsxRuntime.jsxs("span", { className: usePrefixedClassNames('file-cta'), children: [iconLeft && (jsxRuntime.jsx("span", { className: prefixedClassNames(classPrefix, 'file-icon'), children: iconLeft })), jsxRuntime.jsx("span", { className: usePrefixedClassNames('file-label'), children: buttonLabel || 'Choose a file\u2026' }), iconRight && (jsxRuntime.jsx("span", { className: prefixedClassNames(classPrefix, 'file-icon'), children: iconRight }))] }), hasName && fileName && (jsxRuntime.jsx("span", { className: prefixedClassNames(classPrefix, 'file-name'), children: fileName }))] }) }));
5948
5973
  if (!insideField) {
5949
- return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: labelProps, horizontal: horizontal, className: fieldClassName, children: [fileElement, messageEl] }));
5974
+ return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [fileElement, messageEl] }));
5950
5975
  }
5951
5976
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [fileElement, messageEl] }));
5952
5977
  });
@@ -6239,6 +6264,14 @@ const Slider = React.forwardRef((props, ref) => {
6239
6264
  const insideField = useInsideField();
6240
6265
  const insideControl = useInsideControl();
6241
6266
  const { bulmaHelperClasses, rest } = useBulmaClasses(restProps);
6267
+ // In range mode the low thumb carries `rest` (and any user id), so the
6268
+ // label targets it; each thumb keeps its own aria-label for AT.
6269
+ const { controlId, fieldLabelProps } = useAutoLabelId({
6270
+ label,
6271
+ id: restProps.id,
6272
+ labelProps,
6273
+ rendersLabel: !insideField,
6274
+ });
6242
6275
  // Resolve tooltip mode: explicit tooltip prop takes precedence, else showOutput maps to 'auto'
6243
6276
  const tooltipMode = tooltip ?? (showOutput ? 'auto' : 'hidden');
6244
6277
  // --- Range mode state ---
@@ -6503,7 +6536,7 @@ const Slider = React.forwardRef((props, ref) => {
6503
6536
  // --- Single slider ---
6504
6537
  const sliderElement = !range ? (jsxRuntime.jsxs("div", { ref: wrapperRef, className: combinedClasses, style: wrapperStyle, children: [jsxRuntime.jsx("input", { ref: combinedRef, type: "range", min: min, max: max, step: step, value: currentSingle, disabled: disabled, onChange: handleSingleChange, onKeyDown: handleKeyDown, onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), onFocus: () => setShowTooltip(true), onBlur: () => setShowTooltip(false), className: prefixedClassNames(classPrefix, 'slider-input'), style: {
6505
6538
  '--slider-progress': `${progressSingle}%`,
6506
- }, "aria-valuenow": currentSingle, "aria-valuemin": min, "aria-valuemax": max, "aria-orientation": isVertical ? 'vertical' : undefined, "aria-label": ariaLabel, ...getAriaProps(currentSingle), ...rest }), tooltipMode !== 'hidden' && (jsxRuntime.jsx("output", { ref: outputRef, className: prefixedClassNames(classPrefix, 'slider-output', {
6539
+ }, "aria-valuenow": currentSingle, "aria-valuemin": min, "aria-valuemax": max, "aria-orientation": isVertical ? 'vertical' : undefined, "aria-label": ariaLabel, ...getAriaProps(currentSingle), id: controlId, ...rest }), tooltipMode !== 'hidden' && (jsxRuntime.jsx("output", { ref: outputRef, className: prefixedClassNames(classPrefix, 'slider-output', {
6507
6540
  'is-visible': showTipLow,
6508
6541
  'is-flipped': flipped,
6509
6542
  'is-flipped-left': isVertical && verticalFlippedLeft,
@@ -6531,7 +6564,7 @@ const Slider = React.forwardRef((props, ref) => {
6531
6564
  : {
6532
6565
  '--slider-progress-low': `${progressLow}%`,
6533
6566
  '--slider-progress-high': `${progressHigh}%`,
6534
- } }), jsxRuntime.jsx("input", { ref: combinedRef, type: "range", min: min, max: max, step: step, value: currentRange[0], disabled: disabled, onChange: handleRangeLowChange, onKeyDown: handleKeyDown, onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), onFocus: () => setShowTooltip(true), onBlur: () => setShowTooltip(false), className: prefixedClassNames(classPrefix, 'slider-input', 'slider-input-low'), "aria-valuenow": currentRange[0], "aria-valuemin": min, "aria-valuemax": max, "aria-orientation": isVertical ? 'vertical' : undefined, "aria-label": ariaLabel?.[0] ?? 'Minimum value', ...getAriaProps(currentRange[0]), ...rest, ...(nameLow !== undefined ? { name: nameLow } : {}) }), jsxRuntime.jsx("input", { ref: inputHighRef, type: "range", min: min, max: max, step: step, value: currentRange[1], disabled: disabled, onChange: handleRangeHighChange, onMouseEnter: () => setShowTooltipHigh(true), onMouseLeave: () => setShowTooltipHigh(false), onFocus: () => setShowTooltipHigh(true), onBlur: () => setShowTooltipHigh(false), className: prefixedClassNames(classPrefix, 'slider-input', 'slider-input-high'), "aria-valuenow": currentRange[1], "aria-valuemin": min, "aria-valuemax": max, "aria-orientation": isVertical ? 'vertical' : undefined, "aria-label": ariaLabel?.[1] ?? 'Maximum value', ...getAriaProps(currentRange[1]), name: nameHigh }), tooltipMode !== 'hidden' && (jsxRuntime.jsx("output", { ref: outputRef, className: prefixedClassNames(classPrefix, 'slider-output', 'slider-output-low', {
6567
+ } }), jsxRuntime.jsx("input", { ref: combinedRef, type: "range", min: min, max: max, step: step, value: currentRange[0], disabled: disabled, onChange: handleRangeLowChange, onKeyDown: handleKeyDown, onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), onFocus: () => setShowTooltip(true), onBlur: () => setShowTooltip(false), className: prefixedClassNames(classPrefix, 'slider-input', 'slider-input-low'), "aria-valuenow": currentRange[0], "aria-valuemin": min, "aria-valuemax": max, "aria-orientation": isVertical ? 'vertical' : undefined, "aria-label": ariaLabel?.[0] ?? 'Minimum value', ...getAriaProps(currentRange[0]), id: controlId, ...rest, ...(nameLow !== undefined ? { name: nameLow } : {}) }), jsxRuntime.jsx("input", { ref: inputHighRef, type: "range", min: min, max: max, step: step, value: currentRange[1], disabled: disabled, onChange: handleRangeHighChange, onMouseEnter: () => setShowTooltipHigh(true), onMouseLeave: () => setShowTooltipHigh(false), onFocus: () => setShowTooltipHigh(true), onBlur: () => setShowTooltipHigh(false), className: prefixedClassNames(classPrefix, 'slider-input', 'slider-input-high'), "aria-valuenow": currentRange[1], "aria-valuemin": min, "aria-valuemax": max, "aria-orientation": isVertical ? 'vertical' : undefined, "aria-label": ariaLabel?.[1] ?? 'Maximum value', ...getAriaProps(currentRange[1]), name: nameHigh }), tooltipMode !== 'hidden' && (jsxRuntime.jsx("output", { ref: outputRef, className: prefixedClassNames(classPrefix, 'slider-output', 'slider-output-low', {
6535
6568
  'is-visible': showTipLow,
6536
6569
  'is-flipped': flipped,
6537
6570
  'is-flipped-left': isVertical && verticalFlippedLeft,
@@ -6577,7 +6610,7 @@ const Slider = React.forwardRef((props, ref) => {
6577
6610
  content = jsxRuntime.jsx(Control, { children: content });
6578
6611
  }
6579
6612
  if (!insideField) {
6580
- return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: labelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
6613
+ return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
6581
6614
  }
6582
6615
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [content, messageEl] }));
6583
6616
  });
@@ -6615,6 +6648,13 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
6615
6648
  const isStepper = variant === 'stepper';
6616
6649
  const isAddons = compact || isStepper;
6617
6650
  const effectiveControlsPosition = isStepper ? 'right' : controlsPosition;
6651
+ // The plusminus bare branch renders no Field and no label at all.
6652
+ const { controlId, fieldLabelProps } = useAutoLabelId({
6653
+ label,
6654
+ id: props.id,
6655
+ labelProps,
6656
+ rendersLabel: !insideField && (isStepper || !effectiveBare),
6657
+ });
6618
6658
  // Clamp value to min/max
6619
6659
  const clampValue = React.useCallback((val) => {
6620
6660
  let clamped = val;
@@ -6713,12 +6753,12 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
6713
6753
  }
6714
6754
  };
6715
6755
  // Shared input element
6716
- const inputControl = (jsxRuntime.jsx("div", { className: expandedControlClasses, children: jsxRuntime.jsx("input", { ref: combinedRef, type: "number", className: inputClasses, value: currentValue ?? '', min: min, max: max, step: step, disabled: disabled, readOnly: !editable, onChange: handleInputChange, onKeyDown: handleKeyDown, "aria-valuenow": currentValue ?? undefined, "aria-valuemin": min, "aria-valuemax": max, ...rest }) }));
6756
+ const inputControl = (jsxRuntime.jsx("div", { className: expandedControlClasses, children: jsxRuntime.jsx("input", { ref: combinedRef, type: "number", className: inputClasses, value: currentValue ?? '', min: min, max: max, step: step, disabled: disabled, readOnly: !editable, onChange: handleInputChange, onKeyDown: handleKeyDown, "aria-valuenow": currentValue ?? undefined, "aria-valuemin": min, "aria-valuemax": max, id: controlId, ...rest }) }));
6717
6757
  // Stepper variant
6718
6758
  if (isStepper) {
6719
6759
  const stepperElement = (jsxRuntime.jsxs("div", { className: combinedClasses, children: [inputControl, jsxRuntime.jsx("div", { className: controlClasses, children: jsxRuntime.jsxs("div", { className: stepperClasses, children: [jsxRuntime.jsx("button", { type: "button", className: stepperButtonClasses, onClick: handleIncrement, disabled: disabled || isAtMax, tabIndex: -1, "aria-label": "Increase value", children: jsxRuntime.jsx(ArrowDropUp, {}) }), jsxRuntime.jsx("button", { type: "button", className: stepperButtonClasses, onClick: handleDecrement, disabled: disabled || isAtMin, tabIndex: -1, "aria-label": "Decrease value", children: jsxRuntime.jsx(ArrowDropDown, {}) })] }) })] }));
6720
6760
  if (!insideField) {
6721
- return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: labelProps, horizontal: horizontal, className: fieldClassName, children: [stepperElement, messageEl] }));
6761
+ return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [stepperElement, messageEl] }));
6722
6762
  }
6723
6763
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [stepperElement, messageEl] }));
6724
6764
  }
@@ -6752,7 +6792,7 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
6752
6792
  numberinputElement = (jsxRuntime.jsxs("div", { className: combinedClasses, children: [decrementControl, inputControl, incrementControl] }));
6753
6793
  }
6754
6794
  if (!insideField) {
6755
- return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: labelProps, horizontal: horizontal, className: fieldClassName, children: [numberinputElement, messageEl] }));
6795
+ return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [numberinputElement, messageEl] }));
6756
6796
  }
6757
6797
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [numberinputElement, messageEl] }));
6758
6798
  });
@@ -7029,10 +7069,16 @@ Rate.displayName = 'Rate';
7029
7069
  * onSelect={(item) => console.log(item)}
7030
7070
  * />
7031
7071
  */
7032
- const Autocomplete = React.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,
7072
+ const Autocomplete = React.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,
7033
7073
  // Field props
7034
7074
  label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName, className, ...props }, ref) => {
7035
7075
  const insideField = useInsideField();
7076
+ const { controlId, fieldLabelProps } = useAutoLabelId({
7077
+ label,
7078
+ id,
7079
+ labelProps,
7080
+ rendersLabel: !insideField,
7081
+ });
7036
7082
  const { bulmaHelperClasses, rest } = useBulmaClasses(props);
7037
7083
  const { classPrefix } = useConfig();
7038
7084
  const containerRef = React.useRef(null);
@@ -7228,7 +7274,7 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
7228
7274
  [`is-${messageColor}`]: !!messageColor,
7229
7275
  });
7230
7276
  const messageEl = message ? jsxRuntime.jsx("p", { className: helpClass, children: message }) : null;
7231
- const autocompleteElement = (jsxRuntime.jsxs("div", { ref: containerRef, className: combinedClasses, ...rest, children: [jsxRuntime.jsxs("div", { className: controlClasses, children: [jsxRuntime.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 && (jsxRuntime.jsx("span", { className: iconRightClickableClass, onClick: handleClear, role: "button", "aria-label": "Clear", children: jsxRuntime.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: [jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }) })), loading && (jsxRuntime.jsx("span", { className: iconRightClass, children: jsxRuntime.jsx("span", { className: loaderClass }) }))] }), isActive && (filteredData.length > 0 || empty) && (jsxRuntime.jsx("div", { className: dropdownMenuClasses, children: jsxRuntime.jsxs("div", { ref: dropdownRef, className: dropdownContentClass, style: { maxHeight: `${maxHeight}px`, overflowY: 'auto' }, role: "listbox", onScroll: handleDropdownScroll, children: [header && jsxRuntime.jsx("div", { className: dropdownHeaderClass, children: header }), filteredData.length > 0 ? (filteredData.map((item, index) => {
7277
+ const autocompleteElement = (jsxRuntime.jsxs("div", { ref: containerRef, className: combinedClasses, ...rest, children: [jsxRuntime.jsxs("div", { className: controlClasses, children: [jsxRuntime.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 && (jsxRuntime.jsx("span", { className: iconRightClickableClass, onClick: handleClear, role: "button", "aria-label": "Clear", children: jsxRuntime.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: [jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }) })), loading && (jsxRuntime.jsx("span", { className: iconRightClass, children: jsxRuntime.jsx("span", { className: loaderClass }) }))] }), isActive && (filteredData.length > 0 || empty) && (jsxRuntime.jsx("div", { className: dropdownMenuClasses, children: jsxRuntime.jsxs("div", { ref: dropdownRef, className: dropdownContentClass, style: { maxHeight: `${maxHeight}px`, overflowY: 'auto' }, role: "listbox", onScroll: handleDropdownScroll, children: [header && jsxRuntime.jsx("div", { className: dropdownHeaderClass, children: header }), filteredData.length > 0 ? (filteredData.map((item, index) => {
7232
7278
  const isDisabled = typeof item !== 'string' && item.disabled;
7233
7279
  const isHighlighted = index === highlightedIndex;
7234
7280
  const itemClasses = prefixedClassNames(classPrefix, 'dropdown-item', {
@@ -7240,7 +7286,7 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
7240
7286
  : getDisplayValue(item) }, index));
7241
7287
  })) : (jsxRuntime.jsx("div", { className: emptyItemClasses, children: empty })), footer && jsxRuntime.jsx("div", { className: dropdownFooterClass, children: footer })] }) }))] }));
7242
7288
  if (!insideField) {
7243
- return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: labelProps, horizontal: horizontal, className: fieldClassName, children: [autocompleteElement, messageEl] }));
7289
+ return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [autocompleteElement, messageEl] }));
7244
7290
  }
7245
7291
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [autocompleteElement, messageEl] }));
7246
7292
  });
@@ -7271,7 +7317,7 @@ Autocomplete.displayName = 'Autocomplete';
7271
7317
  */
7272
7318
  const Taginput = React.forwardRef(({
7273
7319
  // Field props
7274
- 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) => {
7320
+ 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) => {
7275
7321
  const insideField = useInsideField();
7276
7322
  const { bulmaHelperClasses, rest } = useBulmaClasses(props);
7277
7323
  const { classPrefix } = useConfig();
@@ -7287,6 +7333,15 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
7287
7333
  const [highlightedIndex, setHighlightedIndex] = React.useState(-1);
7288
7334
  // Use controlled or internal tags
7289
7335
  const tags = controlledValue !== undefined ? controlledValue : internalTags;
7336
+ const isMaxReached = maxTags !== undefined && tags.length >= maxTags;
7337
+ // At the tag limit the text input is not rendered, so there is nothing to
7338
+ // wire the label to.
7339
+ const { controlId, fieldLabelProps } = useAutoLabelId({
7340
+ label,
7341
+ id,
7342
+ labelProps,
7343
+ rendersLabel: !insideField && !isMaxReached,
7344
+ });
7290
7345
  // Get display value from tag
7291
7346
  const getDisplayValue = (tag) => {
7292
7347
  if (typeof tag === 'string')
@@ -7529,7 +7584,6 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
7529
7584
  [`is-${size}`]: !!size,
7530
7585
  });
7531
7586
  const combinedClasses = classNames(taginputClasses, bulmaHelperClasses, className);
7532
- const isMaxReached = maxTags !== undefined && tags.length >= maxTags;
7533
7587
  // Counter text
7534
7588
  const showCounter = hasCounter && (maxTags !== undefined || maxlength !== undefined);
7535
7589
  const counterText = maxTags !== undefined
@@ -7553,12 +7607,14 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
7553
7607
  e.stopPropagation();
7554
7608
  removeTag(index);
7555
7609
  }, "aria-label": ariaCloseLabel || `Remove ${displayVal}` }))] }, index));
7556
- }), !isMaxReached && (jsxRuntime.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 && (jsxRuntime.jsx("span", { className: iconRightClass, children: jsxRuntime.jsx("span", { className: loaderClass }) }))] }), isActive && filteredData.length > 0 && (jsxRuntime.jsx("div", { className: dropdownMenuClasses, children: jsxRuntime.jsx("div", { ref: dropdownRef, className: dropdownContentClasses, role: "listbox", children: filteredData.map((item, index) => (jsxRuntime.jsx("a", { className: pcn('dropdown-item', {
7610
+ }), !isMaxReached && (jsxRuntime.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
7611
+ ? undefined
7612
+ : 'Add tag' }))] }), loading && (jsxRuntime.jsx("span", { className: iconRightClass, children: jsxRuntime.jsx("span", { className: loaderClass }) }))] }), isActive && filteredData.length > 0 && (jsxRuntime.jsx("div", { className: dropdownMenuClasses, children: jsxRuntime.jsx("div", { ref: dropdownRef, className: dropdownContentClasses, role: "listbox", children: filteredData.map((item, index) => (jsxRuntime.jsx("a", { className: pcn('dropdown-item', {
7557
7613
  'is-active': index === highlightedIndex,
7558
7614
  }), onClick: () => addTag(item), onMouseEnter: () => setHighlightedIndex(index), role: "option", "aria-selected": index === highlightedIndex, children: item }, index))) }) })), showCounter && jsxRuntime.jsx("small", { className: counterClasses, children: counterText }), name &&
7559
7615
  tags.map((tag, i) => (jsxRuntime.jsx("input", { type: "hidden", name: name, value: getDisplayValue(tag), form: form }, `tag-input-${i}`)))] }));
7560
7616
  if (!insideField) {
7561
- return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: labelProps, horizontal: horizontal, className: fieldClassName, children: [taginputElement, messageEl] }));
7617
+ return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [taginputElement, messageEl] }));
7562
7618
  }
7563
7619
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [taginputElement, messageEl] }));
7564
7620
  });
@@ -7696,16 +7752,22 @@ fieldClassName, controlClassName,
7696
7752
  ...inputProps }, ref) => {
7697
7753
  const insideField = useInsideField();
7698
7754
  const insideControl = useInsideControl();
7755
+ const { controlId, fieldLabelProps } = useAutoLabelId({
7756
+ label,
7757
+ id: inputProps.id,
7758
+ labelProps,
7759
+ rendersLabel: !insideField,
7760
+ });
7699
7761
  const helpClass = usePrefixedClassNames('help', {
7700
7762
  [`is-${messageColor}`]: !!messageColor,
7701
7763
  });
7702
- let content = jsxRuntime.jsx(InputBase, { ref: ref, ...inputProps });
7764
+ let content = jsxRuntime.jsx(InputBase, { ref: ref, id: controlId, ...inputProps });
7703
7765
  if (!insideControl) {
7704
7766
  content = (jsxRuntime.jsx(Control, { iconLeft: iconLeft, iconRight: iconRight, iconLeftName: iconLeftName, iconRightName: iconRightName, iconLeftSize: iconLeftSize, iconRightSize: iconRightSize, hasIconsLeft: hasIconsLeft, hasIconsRight: hasIconsRight, isLoading: isLoading, isExpanded: isExpanded, size: controlSize, className: controlClassName, children: content }));
7705
7767
  }
7706
7768
  const messageEl = message ? jsxRuntime.jsx("p", { className: helpClass, children: message }) : null;
7707
7769
  if (!insideField) {
7708
- return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: labelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
7770
+ return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
7709
7771
  }
7710
7772
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [content, messageEl] }));
7711
7773
  });
@@ -7740,16 +7802,22 @@ fieldClassName, controlClassName,
7740
7802
  ...selectProps }, ref) => {
7741
7803
  const insideField = useInsideField();
7742
7804
  const insideControl = useInsideControl();
7805
+ const { controlId, fieldLabelProps } = useAutoLabelId({
7806
+ label,
7807
+ id: selectProps.id,
7808
+ labelProps,
7809
+ rendersLabel: !insideField,
7810
+ });
7743
7811
  const helpClass = usePrefixedClassNames('help', {
7744
7812
  [`is-${messageColor}`]: !!messageColor,
7745
7813
  });
7746
- let content = jsxRuntime.jsx(SelectBase, { ref: ref, ...selectProps });
7814
+ let content = jsxRuntime.jsx(SelectBase, { ref: ref, id: controlId, ...selectProps });
7747
7815
  if (!insideControl) {
7748
7816
  content = (jsxRuntime.jsx(Control, { iconLeft: iconLeft, iconLeftName: iconLeftName, iconLeftSize: iconLeftSize, hasIconsLeft: hasIconsLeft, isExpanded: isExpanded, size: controlSize, className: controlClassName, children: content }));
7749
7817
  }
7750
7818
  const messageEl = message ? jsxRuntime.jsx("p", { className: helpClass, children: message }) : null;
7751
7819
  if (!insideField) {
7752
- return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: labelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
7820
+ return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
7753
7821
  }
7754
7822
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [content, messageEl] }));
7755
7823
  });
@@ -7785,16 +7853,22 @@ fieldClassName, controlClassName,
7785
7853
  ...textAreaProps }, ref) => {
7786
7854
  const insideField = useInsideField();
7787
7855
  const insideControl = useInsideControl();
7856
+ const { controlId, fieldLabelProps } = useAutoLabelId({
7857
+ label,
7858
+ id: textAreaProps.id,
7859
+ labelProps,
7860
+ rendersLabel: !insideField,
7861
+ });
7788
7862
  const helpClass = usePrefixedClassNames('help', {
7789
7863
  [`is-${messageColor}`]: !!messageColor,
7790
7864
  });
7791
- let content = jsxRuntime.jsx(TextAreaBase, { ref: ref, ...textAreaProps });
7865
+ let content = jsxRuntime.jsx(TextAreaBase, { ref: ref, id: controlId, ...textAreaProps });
7792
7866
  if (!insideControl) {
7793
7867
  content = (jsxRuntime.jsx(Control, { isLoading: controlIsLoading, size: controlSize, className: controlClassName, children: content }));
7794
7868
  }
7795
7869
  const messageEl = message ? jsxRuntime.jsx("p", { className: helpClass, children: message }) : null;
7796
7870
  if (!insideField) {
7797
- return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: labelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
7871
+ return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
7798
7872
  }
7799
7873
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [content, messageEl] }));
7800
7874
  });
@@ -9471,12 +9545,19 @@ DateInputBase.displayName = 'DateInputBase';
9471
9545
  const DateInput = React.forwardRef(({ label, labelSize, labelProps, horizontal, iconLeft, iconRight, iconLeftName = 'calendar', iconRightName, iconLeftSize, iconRightSize, hasIconsLeft, hasIconsRight, isLoading, isExpanded, controlSize, message, messageColor, fieldClassName, controlClassName, ...baseProps }, ref) => {
9472
9546
  const insideField = useInsideField();
9473
9547
  const insideControl = useInsideControl();
9548
+ const { controlId, fieldLabelProps } = useAutoLabelId({
9549
+ label,
9550
+ id: baseProps.id,
9551
+ labelProps,
9552
+ // Inline mode renders a bare calendar with no input to label.
9553
+ rendersLabel: !insideField && !baseProps.inline,
9554
+ });
9474
9555
  const helpClass = usePrefixedClassNames('help', {
9475
9556
  [`is-${messageColor}`]: !!messageColor,
9476
9557
  });
9477
9558
  // The right-side launcher is on by default; suppress it while the Control
9478
9559
  // shows its loading spinner (also on the right) unless explicitly set.
9479
- let content = (jsxRuntime.jsx(DateInputBase, { ref: ref, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
9560
+ let content = (jsxRuntime.jsx(DateInputBase, { ref: ref, id: controlId, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
9480
9561
  // Inline mode renders a bare calendar with no input, so the Control's
9481
9562
  // icon-left container has nothing to anchor to. Skip the Control wrap.
9482
9563
  if (!insideControl && !baseProps.inline) {
@@ -9484,7 +9565,7 @@ const DateInput = React.forwardRef(({ label, labelSize, labelProps, horizontal,
9484
9565
  }
9485
9566
  const messageEl = message ? jsxRuntime.jsx("p", { className: helpClass, children: message }) : null;
9486
9567
  if (!insideField) {
9487
- return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: labelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
9568
+ return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
9488
9569
  }
9489
9570
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [content, messageEl] }));
9490
9571
  });
@@ -10555,12 +10636,19 @@ TimeInputBase.displayName = 'TimeInputBase';
10555
10636
  const TimeInput = React.forwardRef(({ label, labelSize, labelProps, horizontal, iconLeft, iconRight, iconLeftName = 'clock', iconRightName, iconLeftSize, iconRightSize, hasIconsLeft, hasIconsRight, isLoading, isExpanded, controlSize, message, messageColor, fieldClassName, controlClassName, ...baseProps }, ref) => {
10556
10637
  const insideField = useInsideField();
10557
10638
  const insideControl = useInsideControl();
10639
+ const { controlId, fieldLabelProps } = useAutoLabelId({
10640
+ label,
10641
+ id: baseProps.id,
10642
+ labelProps,
10643
+ // Inline mode renders a bare panel with no input to label.
10644
+ rendersLabel: !insideField && !baseProps.inline,
10645
+ });
10558
10646
  const helpClass = usePrefixedClassNames('help', {
10559
10647
  [`is-${messageColor}`]: !!messageColor,
10560
10648
  });
10561
10649
  // The right-side launcher is on by default; suppress it while the Control
10562
10650
  // shows its loading spinner (also on the right) unless explicitly set.
10563
- let content = (jsxRuntime.jsx(TimeInputBase, { ref: ref, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
10651
+ let content = (jsxRuntime.jsx(TimeInputBase, { ref: ref, id: controlId, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
10564
10652
  // Inline mode renders a bare panel with no input, so the Control's
10565
10653
  // icon-left container has nothing to anchor to. Skip the Control wrap.
10566
10654
  if (!insideControl && !baseProps.inline) {
@@ -10568,7 +10656,7 @@ const TimeInput = React.forwardRef(({ label, labelSize, labelProps, horizontal,
10568
10656
  }
10569
10657
  const messageEl = message ? jsxRuntime.jsx("p", { className: helpClass, children: message }) : null;
10570
10658
  if (!insideField) {
10571
- return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: labelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
10659
+ return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
10572
10660
  }
10573
10661
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [content, messageEl] }));
10574
10662
  });
@@ -10844,12 +10932,19 @@ DateTimeInputBase.displayName = 'DateTimeInputBase';
10844
10932
  const DateTimeInput = React.forwardRef(({ label, labelSize, labelProps, horizontal, iconLeft, iconRight, iconLeftName = 'calendar-alt', iconRightName, iconLeftSize, iconRightSize, hasIconsLeft, hasIconsRight, isLoading, isExpanded, controlSize, message, messageColor, fieldClassName, controlClassName, ...baseProps }, ref) => {
10845
10933
  const insideField = useInsideField();
10846
10934
  const insideControl = useInsideControl();
10935
+ const { controlId, fieldLabelProps } = useAutoLabelId({
10936
+ label,
10937
+ id: baseProps.id,
10938
+ labelProps,
10939
+ // Inline mode renders a bare picker with no input to label.
10940
+ rendersLabel: !insideField && !baseProps.inline,
10941
+ });
10847
10942
  const helpClass = usePrefixedClassNames('help', {
10848
10943
  [`is-${messageColor}`]: !!messageColor,
10849
10944
  });
10850
10945
  // The right-side launcher is on by default; suppress it while the Control
10851
10946
  // shows its loading spinner (also on the right) unless explicitly set.
10852
- let content = (jsxRuntime.jsx(DateTimeInputBase, { ref: ref, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
10947
+ let content = (jsxRuntime.jsx(DateTimeInputBase, { ref: ref, id: controlId, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
10853
10948
  // Inline mode renders a bare picker with no input, so the Control's
10854
10949
  // icon-left container has nothing to anchor to. Skip the Control wrap.
10855
10950
  if (!insideControl && !baseProps.inline) {
@@ -10857,7 +10952,7 @@ const DateTimeInput = React.forwardRef(({ label, labelSize, labelProps, horizont
10857
10952
  }
10858
10953
  const messageEl = message ? jsxRuntime.jsx("p", { className: helpClass, children: message }) : null;
10859
10954
  if (!insideField) {
10860
- return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: labelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
10955
+ return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
10861
10956
  }
10862
10957
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [content, messageEl] }));
10863
10958
  });