@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 +122 -27
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +122 -27
- package/dist/index.esm.js.map +1 -1
- package/dist/types/form/Autocomplete.d.ts +9 -1
- package/dist/types/form/DateInput.d.ts +2 -2
- package/dist/types/form/DateTimeInput.d.ts +2 -2
- package/dist/types/form/Field.d.ts +2 -2
- package/dist/types/form/File.d.ts +6 -0
- package/dist/types/form/Input.d.ts +2 -2
- package/dist/types/form/Numberinput.d.ts +6 -0
- package/dist/types/form/Select.d.ts +2 -2
- package/dist/types/form/Slider.d.ts +6 -0
- package/dist/types/form/Taginput.d.ts +9 -1
- package/dist/types/form/TextArea.d.ts +2 -2
- package/dist/types/form/TimeInput.d.ts +2 -2
- package/dist/types/form/useAutoLabelId.d.ts +28 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -5901,6 +5901,25 @@ const CheckboxesComponent = ({ label, labelSize, labelProps, horizontal, message
|
|
|
5901
5901
|
};
|
|
5902
5902
|
const Checkboxes = withSubComponents(CheckboxesComponent, { Checkbox }, 'Checkboxes');
|
|
5903
5903
|
|
|
5904
|
+
/**
|
|
5905
|
+
* Associates the convenience `label` prop with its control (#368): generates
|
|
5906
|
+
* an id for the control and returns labelProps carrying a matching `htmlFor`.
|
|
5907
|
+
* A user-supplied `id` is used as the target instead of the generated one, and
|
|
5908
|
+
* an explicit `labelProps.htmlFor` disables generation entirely — the user has
|
|
5909
|
+
* taken over the association. Internal; not part of the public API.
|
|
5910
|
+
*/
|
|
5911
|
+
function useAutoLabelId({ label, id, labelProps, rendersLabel, }) {
|
|
5912
|
+
// Called unconditionally per the rules of hooks; SSR-safe on React 18 and 19.
|
|
5913
|
+
const generatedId = useId();
|
|
5914
|
+
// Truthiness mirrors Field's own `if (label)` render gate.
|
|
5915
|
+
const active = !!label && rendersLabel;
|
|
5916
|
+
const controlId = id ?? (active && !labelProps?.htmlFor ? generatedId : undefined);
|
|
5917
|
+
const fieldLabelProps = active
|
|
5918
|
+
? { htmlFor: controlId, ...labelProps }
|
|
5919
|
+
: labelProps;
|
|
5920
|
+
return { controlId, fieldLabelProps };
|
|
5921
|
+
}
|
|
5922
|
+
|
|
5904
5923
|
/**
|
|
5905
5924
|
* The `File` component provides a Bulma-styled file input, supporting color, size, boxed/fullwidth/align styles, icons, "has name", and filename display.
|
|
5906
5925
|
*
|
|
@@ -5913,6 +5932,12 @@ const File = forwardRef(({
|
|
|
5913
5932
|
// Field props
|
|
5914
5933
|
label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName, color, size, isBoxed, isFullwidth, isRight, isCentered, hasName, buttonLabel, iconLeft, iconRight, className, inputClassName, fileName, ...props }, ref) => {
|
|
5915
5934
|
const insideField = useInsideField();
|
|
5935
|
+
const { controlId, fieldLabelProps } = useAutoLabelId({
|
|
5936
|
+
label,
|
|
5937
|
+
id: props.id,
|
|
5938
|
+
labelProps,
|
|
5939
|
+
rendersLabel: !insideField,
|
|
5940
|
+
});
|
|
5916
5941
|
const { classPrefix } = useConfig();
|
|
5917
5942
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
5918
5943
|
color,
|
|
@@ -5942,9 +5967,9 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
|
|
|
5942
5967
|
[`is-${messageColor}`]: !!messageColor,
|
|
5943
5968
|
});
|
|
5944
5969
|
const messageEl = message ? jsx("p", { className: helpClass, children: message }) : null;
|
|
5945
|
-
const fileElement = (jsx("div", { className: fileClass, children: jsxs("label", { className: usePrefixedClassNames('file-label'), children: [jsx("input", { ref: ref, className: classNames(usePrefixedClassNames('file-input'), inputClassName), type: "file", ...rest }), jsxs("span", { className: usePrefixedClassNames('file-cta'), children: [iconLeft && (jsx("span", { className: prefixedClassNames(classPrefix, 'file-icon'), children: iconLeft })), jsx("span", { className: usePrefixedClassNames('file-label'), children: buttonLabel || 'Choose a file\u2026' }), iconRight && (jsx("span", { className: prefixedClassNames(classPrefix, 'file-icon'), children: iconRight }))] }), hasName && fileName && (jsx("span", { className: prefixedClassNames(classPrefix, 'file-name'), children: fileName }))] }) }));
|
|
5970
|
+
const fileElement = (jsx("div", { className: fileClass, children: jsxs("label", { className: usePrefixedClassNames('file-label'), children: [jsx("input", { ref: ref, className: classNames(usePrefixedClassNames('file-input'), inputClassName), type: "file", id: controlId, ...rest }), jsxs("span", { className: usePrefixedClassNames('file-cta'), children: [iconLeft && (jsx("span", { className: prefixedClassNames(classPrefix, 'file-icon'), children: iconLeft })), jsx("span", { className: usePrefixedClassNames('file-label'), children: buttonLabel || 'Choose a file\u2026' }), iconRight && (jsx("span", { className: prefixedClassNames(classPrefix, 'file-icon'), children: iconRight }))] }), hasName && fileName && (jsx("span", { className: prefixedClassNames(classPrefix, 'file-name'), children: fileName }))] }) }));
|
|
5946
5971
|
if (!insideField) {
|
|
5947
|
-
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
5972
|
+
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [fileElement, messageEl] }));
|
|
5948
5973
|
}
|
|
5949
5974
|
return (jsxs(Fragment, { children: [fileElement, messageEl] }));
|
|
5950
5975
|
});
|
|
@@ -6237,6 +6262,14 @@ const Slider = forwardRef((props, ref) => {
|
|
|
6237
6262
|
const insideField = useInsideField();
|
|
6238
6263
|
const insideControl = useInsideControl();
|
|
6239
6264
|
const { bulmaHelperClasses, rest } = useBulmaClasses(restProps);
|
|
6265
|
+
// In range mode the low thumb carries `rest` (and any user id), so the
|
|
6266
|
+
// label targets it; each thumb keeps its own aria-label for AT.
|
|
6267
|
+
const { controlId, fieldLabelProps } = useAutoLabelId({
|
|
6268
|
+
label,
|
|
6269
|
+
id: restProps.id,
|
|
6270
|
+
labelProps,
|
|
6271
|
+
rendersLabel: !insideField,
|
|
6272
|
+
});
|
|
6240
6273
|
// Resolve tooltip mode: explicit tooltip prop takes precedence, else showOutput maps to 'auto'
|
|
6241
6274
|
const tooltipMode = tooltip ?? (showOutput ? 'auto' : 'hidden');
|
|
6242
6275
|
// --- Range mode state ---
|
|
@@ -6501,7 +6534,7 @@ const Slider = forwardRef((props, ref) => {
|
|
|
6501
6534
|
// --- Single slider ---
|
|
6502
6535
|
const sliderElement = !range ? (jsxs("div", { ref: wrapperRef, className: combinedClasses, style: wrapperStyle, children: [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: {
|
|
6503
6536
|
'--slider-progress': `${progressSingle}%`,
|
|
6504
|
-
}, "aria-valuenow": currentSingle, "aria-valuemin": min, "aria-valuemax": max, "aria-orientation": isVertical ? 'vertical' : undefined, "aria-label": ariaLabel, ...getAriaProps(currentSingle), ...rest }), tooltipMode !== 'hidden' && (jsx("output", { ref: outputRef, className: prefixedClassNames(classPrefix, 'slider-output', {
|
|
6537
|
+
}, "aria-valuenow": currentSingle, "aria-valuemin": min, "aria-valuemax": max, "aria-orientation": isVertical ? 'vertical' : undefined, "aria-label": ariaLabel, ...getAriaProps(currentSingle), id: controlId, ...rest }), tooltipMode !== 'hidden' && (jsx("output", { ref: outputRef, className: prefixedClassNames(classPrefix, 'slider-output', {
|
|
6505
6538
|
'is-visible': showTipLow,
|
|
6506
6539
|
'is-flipped': flipped,
|
|
6507
6540
|
'is-flipped-left': isVertical && verticalFlippedLeft,
|
|
@@ -6529,7 +6562,7 @@ const Slider = forwardRef((props, ref) => {
|
|
|
6529
6562
|
: {
|
|
6530
6563
|
'--slider-progress-low': `${progressLow}%`,
|
|
6531
6564
|
'--slider-progress-high': `${progressHigh}%`,
|
|
6532
|
-
} }), 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 } : {}) }), 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' && (jsx("output", { ref: outputRef, className: prefixedClassNames(classPrefix, 'slider-output', 'slider-output-low', {
|
|
6565
|
+
} }), 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 } : {}) }), 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' && (jsx("output", { ref: outputRef, className: prefixedClassNames(classPrefix, 'slider-output', 'slider-output-low', {
|
|
6533
6566
|
'is-visible': showTipLow,
|
|
6534
6567
|
'is-flipped': flipped,
|
|
6535
6568
|
'is-flipped-left': isVertical && verticalFlippedLeft,
|
|
@@ -6575,7 +6608,7 @@ const Slider = forwardRef((props, ref) => {
|
|
|
6575
6608
|
content = jsx(Control, { children: content });
|
|
6576
6609
|
}
|
|
6577
6610
|
if (!insideField) {
|
|
6578
|
-
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
6611
|
+
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
|
|
6579
6612
|
}
|
|
6580
6613
|
return (jsxs(Fragment, { children: [content, messageEl] }));
|
|
6581
6614
|
});
|
|
@@ -6613,6 +6646,13 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
|
|
|
6613
6646
|
const isStepper = variant === 'stepper';
|
|
6614
6647
|
const isAddons = compact || isStepper;
|
|
6615
6648
|
const effectiveControlsPosition = isStepper ? 'right' : controlsPosition;
|
|
6649
|
+
// The plusminus bare branch renders no Field and no label at all.
|
|
6650
|
+
const { controlId, fieldLabelProps } = useAutoLabelId({
|
|
6651
|
+
label,
|
|
6652
|
+
id: props.id,
|
|
6653
|
+
labelProps,
|
|
6654
|
+
rendersLabel: !insideField && (isStepper || !effectiveBare),
|
|
6655
|
+
});
|
|
6616
6656
|
// Clamp value to min/max
|
|
6617
6657
|
const clampValue = useCallback((val) => {
|
|
6618
6658
|
let clamped = val;
|
|
@@ -6711,12 +6751,12 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
|
|
|
6711
6751
|
}
|
|
6712
6752
|
};
|
|
6713
6753
|
// Shared input element
|
|
6714
|
-
const inputControl = (jsx("div", { className: expandedControlClasses, children: 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 }) }));
|
|
6754
|
+
const inputControl = (jsx("div", { className: expandedControlClasses, children: 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 }) }));
|
|
6715
6755
|
// Stepper variant
|
|
6716
6756
|
if (isStepper) {
|
|
6717
6757
|
const stepperElement = (jsxs("div", { className: combinedClasses, children: [inputControl, jsx("div", { className: controlClasses, children: jsxs("div", { className: stepperClasses, children: [jsx("button", { type: "button", className: stepperButtonClasses, onClick: handleIncrement, disabled: disabled || isAtMax, tabIndex: -1, "aria-label": "Increase value", children: jsx(ArrowDropUp, {}) }), jsx("button", { type: "button", className: stepperButtonClasses, onClick: handleDecrement, disabled: disabled || isAtMin, tabIndex: -1, "aria-label": "Decrease value", children: jsx(ArrowDropDown, {}) })] }) })] }));
|
|
6718
6758
|
if (!insideField) {
|
|
6719
|
-
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
6759
|
+
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [stepperElement, messageEl] }));
|
|
6720
6760
|
}
|
|
6721
6761
|
return (jsxs(Fragment, { children: [stepperElement, messageEl] }));
|
|
6722
6762
|
}
|
|
@@ -6750,7 +6790,7 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
|
|
|
6750
6790
|
numberinputElement = (jsxs("div", { className: combinedClasses, children: [decrementControl, inputControl, incrementControl] }));
|
|
6751
6791
|
}
|
|
6752
6792
|
if (!insideField) {
|
|
6753
|
-
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
6793
|
+
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [numberinputElement, messageEl] }));
|
|
6754
6794
|
}
|
|
6755
6795
|
return (jsxs(Fragment, { children: [numberinputElement, messageEl] }));
|
|
6756
6796
|
});
|
|
@@ -7027,10 +7067,16 @@ Rate.displayName = 'Rate';
|
|
|
7027
7067
|
* onSelect={(item) => console.log(item)}
|
|
7028
7068
|
* />
|
|
7029
7069
|
*/
|
|
7030
|
-
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,
|
|
7031
7071
|
// Field props
|
|
7032
7072
|
label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName, className, ...props }, ref) => {
|
|
7033
7073
|
const insideField = useInsideField();
|
|
7074
|
+
const { controlId, fieldLabelProps } = useAutoLabelId({
|
|
7075
|
+
label,
|
|
7076
|
+
id,
|
|
7077
|
+
labelProps,
|
|
7078
|
+
rendersLabel: !insideField,
|
|
7079
|
+
});
|
|
7034
7080
|
const { bulmaHelperClasses, rest } = useBulmaClasses(props);
|
|
7035
7081
|
const { classPrefix } = useConfig();
|
|
7036
7082
|
const containerRef = useRef(null);
|
|
@@ -7226,7 +7272,7 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
|
|
|
7226
7272
|
[`is-${messageColor}`]: !!messageColor,
|
|
7227
7273
|
});
|
|
7228
7274
|
const messageEl = message ? jsx("p", { className: helpClass, children: message }) : null;
|
|
7229
|
-
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) => {
|
|
7230
7276
|
const isDisabled = typeof item !== 'string' && item.disabled;
|
|
7231
7277
|
const isHighlighted = index === highlightedIndex;
|
|
7232
7278
|
const itemClasses = prefixedClassNames(classPrefix, 'dropdown-item', {
|
|
@@ -7238,7 +7284,7 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
|
|
|
7238
7284
|
: getDisplayValue(item) }, index));
|
|
7239
7285
|
})) : (jsx("div", { className: emptyItemClasses, children: empty })), footer && jsx("div", { className: dropdownFooterClass, children: footer })] }) }))] }));
|
|
7240
7286
|
if (!insideField) {
|
|
7241
|
-
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
7287
|
+
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [autocompleteElement, messageEl] }));
|
|
7242
7288
|
}
|
|
7243
7289
|
return (jsxs(Fragment, { children: [autocompleteElement, messageEl] }));
|
|
7244
7290
|
});
|
|
@@ -7269,7 +7315,7 @@ Autocomplete.displayName = 'Autocomplete';
|
|
|
7269
7315
|
*/
|
|
7270
7316
|
const Taginput = forwardRef(({
|
|
7271
7317
|
// Field props
|
|
7272
|
-
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) => {
|
|
7273
7319
|
const insideField = useInsideField();
|
|
7274
7320
|
const { bulmaHelperClasses, rest } = useBulmaClasses(props);
|
|
7275
7321
|
const { classPrefix } = useConfig();
|
|
@@ -7285,6 +7331,15 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
|
|
|
7285
7331
|
const [highlightedIndex, setHighlightedIndex] = useState(-1);
|
|
7286
7332
|
// Use controlled or internal tags
|
|
7287
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
|
+
});
|
|
7288
7343
|
// Get display value from tag
|
|
7289
7344
|
const getDisplayValue = (tag) => {
|
|
7290
7345
|
if (typeof tag === 'string')
|
|
@@ -7527,7 +7582,6 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
|
|
|
7527
7582
|
[`is-${size}`]: !!size,
|
|
7528
7583
|
});
|
|
7529
7584
|
const combinedClasses = classNames(taginputClasses, bulmaHelperClasses, className);
|
|
7530
|
-
const isMaxReached = maxTags !== undefined && tags.length >= maxTags;
|
|
7531
7585
|
// Counter text
|
|
7532
7586
|
const showCounter = hasCounter && (maxTags !== undefined || maxlength !== undefined);
|
|
7533
7587
|
const counterText = maxTags !== undefined
|
|
@@ -7551,12 +7605,14 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
|
|
|
7551
7605
|
e.stopPropagation();
|
|
7552
7606
|
removeTag(index);
|
|
7553
7607
|
}, "aria-label": ariaCloseLabel || `Remove ${displayVal}` }))] }, index));
|
|
7554
|
-
}), !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":
|
|
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', {
|
|
7555
7611
|
'is-active': index === highlightedIndex,
|
|
7556
7612
|
}), onClick: () => addTag(item), onMouseEnter: () => setHighlightedIndex(index), role: "option", "aria-selected": index === highlightedIndex, children: item }, index))) }) })), showCounter && jsx("small", { className: counterClasses, children: counterText }), name &&
|
|
7557
7613
|
tags.map((tag, i) => (jsx("input", { type: "hidden", name: name, value: getDisplayValue(tag), form: form }, `tag-input-${i}`)))] }));
|
|
7558
7614
|
if (!insideField) {
|
|
7559
|
-
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
7615
|
+
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [taginputElement, messageEl] }));
|
|
7560
7616
|
}
|
|
7561
7617
|
return (jsxs(Fragment, { children: [taginputElement, messageEl] }));
|
|
7562
7618
|
});
|
|
@@ -7694,16 +7750,22 @@ fieldClassName, controlClassName,
|
|
|
7694
7750
|
...inputProps }, ref) => {
|
|
7695
7751
|
const insideField = useInsideField();
|
|
7696
7752
|
const insideControl = useInsideControl();
|
|
7753
|
+
const { controlId, fieldLabelProps } = useAutoLabelId({
|
|
7754
|
+
label,
|
|
7755
|
+
id: inputProps.id,
|
|
7756
|
+
labelProps,
|
|
7757
|
+
rendersLabel: !insideField,
|
|
7758
|
+
});
|
|
7697
7759
|
const helpClass = usePrefixedClassNames('help', {
|
|
7698
7760
|
[`is-${messageColor}`]: !!messageColor,
|
|
7699
7761
|
});
|
|
7700
|
-
let content = jsx(InputBase, { ref: ref, ...inputProps });
|
|
7762
|
+
let content = jsx(InputBase, { ref: ref, id: controlId, ...inputProps });
|
|
7701
7763
|
if (!insideControl) {
|
|
7702
7764
|
content = (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 }));
|
|
7703
7765
|
}
|
|
7704
7766
|
const messageEl = message ? jsx("p", { className: helpClass, children: message }) : null;
|
|
7705
7767
|
if (!insideField) {
|
|
7706
|
-
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
7768
|
+
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
|
|
7707
7769
|
}
|
|
7708
7770
|
return (jsxs(Fragment, { children: [content, messageEl] }));
|
|
7709
7771
|
});
|
|
@@ -7738,16 +7800,22 @@ fieldClassName, controlClassName,
|
|
|
7738
7800
|
...selectProps }, ref) => {
|
|
7739
7801
|
const insideField = useInsideField();
|
|
7740
7802
|
const insideControl = useInsideControl();
|
|
7803
|
+
const { controlId, fieldLabelProps } = useAutoLabelId({
|
|
7804
|
+
label,
|
|
7805
|
+
id: selectProps.id,
|
|
7806
|
+
labelProps,
|
|
7807
|
+
rendersLabel: !insideField,
|
|
7808
|
+
});
|
|
7741
7809
|
const helpClass = usePrefixedClassNames('help', {
|
|
7742
7810
|
[`is-${messageColor}`]: !!messageColor,
|
|
7743
7811
|
});
|
|
7744
|
-
let content = jsx(SelectBase, { ref: ref, ...selectProps });
|
|
7812
|
+
let content = jsx(SelectBase, { ref: ref, id: controlId, ...selectProps });
|
|
7745
7813
|
if (!insideControl) {
|
|
7746
7814
|
content = (jsx(Control, { iconLeft: iconLeft, iconLeftName: iconLeftName, iconLeftSize: iconLeftSize, hasIconsLeft: hasIconsLeft, isExpanded: isExpanded, size: controlSize, className: controlClassName, children: content }));
|
|
7747
7815
|
}
|
|
7748
7816
|
const messageEl = message ? jsx("p", { className: helpClass, children: message }) : null;
|
|
7749
7817
|
if (!insideField) {
|
|
7750
|
-
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
7818
|
+
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
|
|
7751
7819
|
}
|
|
7752
7820
|
return (jsxs(Fragment, { children: [content, messageEl] }));
|
|
7753
7821
|
});
|
|
@@ -7783,16 +7851,22 @@ fieldClassName, controlClassName,
|
|
|
7783
7851
|
...textAreaProps }, ref) => {
|
|
7784
7852
|
const insideField = useInsideField();
|
|
7785
7853
|
const insideControl = useInsideControl();
|
|
7854
|
+
const { controlId, fieldLabelProps } = useAutoLabelId({
|
|
7855
|
+
label,
|
|
7856
|
+
id: textAreaProps.id,
|
|
7857
|
+
labelProps,
|
|
7858
|
+
rendersLabel: !insideField,
|
|
7859
|
+
});
|
|
7786
7860
|
const helpClass = usePrefixedClassNames('help', {
|
|
7787
7861
|
[`is-${messageColor}`]: !!messageColor,
|
|
7788
7862
|
});
|
|
7789
|
-
let content = jsx(TextAreaBase, { ref: ref, ...textAreaProps });
|
|
7863
|
+
let content = jsx(TextAreaBase, { ref: ref, id: controlId, ...textAreaProps });
|
|
7790
7864
|
if (!insideControl) {
|
|
7791
7865
|
content = (jsx(Control, { isLoading: controlIsLoading, size: controlSize, className: controlClassName, children: content }));
|
|
7792
7866
|
}
|
|
7793
7867
|
const messageEl = message ? jsx("p", { className: helpClass, children: message }) : null;
|
|
7794
7868
|
if (!insideField) {
|
|
7795
|
-
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
7869
|
+
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
|
|
7796
7870
|
}
|
|
7797
7871
|
return (jsxs(Fragment, { children: [content, messageEl] }));
|
|
7798
7872
|
});
|
|
@@ -9469,12 +9543,19 @@ DateInputBase.displayName = 'DateInputBase';
|
|
|
9469
9543
|
const DateInput = forwardRef(({ label, labelSize, labelProps, horizontal, iconLeft, iconRight, iconLeftName = 'calendar', iconRightName, iconLeftSize, iconRightSize, hasIconsLeft, hasIconsRight, isLoading, isExpanded, controlSize, message, messageColor, fieldClassName, controlClassName, ...baseProps }, ref) => {
|
|
9470
9544
|
const insideField = useInsideField();
|
|
9471
9545
|
const insideControl = useInsideControl();
|
|
9546
|
+
const { controlId, fieldLabelProps } = useAutoLabelId({
|
|
9547
|
+
label,
|
|
9548
|
+
id: baseProps.id,
|
|
9549
|
+
labelProps,
|
|
9550
|
+
// Inline mode renders a bare calendar with no input to label.
|
|
9551
|
+
rendersLabel: !insideField && !baseProps.inline,
|
|
9552
|
+
});
|
|
9472
9553
|
const helpClass = usePrefixedClassNames('help', {
|
|
9473
9554
|
[`is-${messageColor}`]: !!messageColor,
|
|
9474
9555
|
});
|
|
9475
9556
|
// The right-side launcher is on by default; suppress it while the Control
|
|
9476
9557
|
// shows its loading spinner (also on the right) unless explicitly set.
|
|
9477
|
-
let content = (jsx(DateInputBase, { ref: ref, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
|
|
9558
|
+
let content = (jsx(DateInputBase, { ref: ref, id: controlId, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
|
|
9478
9559
|
// Inline mode renders a bare calendar with no input, so the Control's
|
|
9479
9560
|
// icon-left container has nothing to anchor to. Skip the Control wrap.
|
|
9480
9561
|
if (!insideControl && !baseProps.inline) {
|
|
@@ -9482,7 +9563,7 @@ const DateInput = forwardRef(({ label, labelSize, labelProps, horizontal, iconLe
|
|
|
9482
9563
|
}
|
|
9483
9564
|
const messageEl = message ? jsx("p", { className: helpClass, children: message }) : null;
|
|
9484
9565
|
if (!insideField) {
|
|
9485
|
-
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
9566
|
+
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
|
|
9486
9567
|
}
|
|
9487
9568
|
return (jsxs(Fragment, { children: [content, messageEl] }));
|
|
9488
9569
|
});
|
|
@@ -10553,12 +10634,19 @@ TimeInputBase.displayName = 'TimeInputBase';
|
|
|
10553
10634
|
const TimeInput = forwardRef(({ label, labelSize, labelProps, horizontal, iconLeft, iconRight, iconLeftName = 'clock', iconRightName, iconLeftSize, iconRightSize, hasIconsLeft, hasIconsRight, isLoading, isExpanded, controlSize, message, messageColor, fieldClassName, controlClassName, ...baseProps }, ref) => {
|
|
10554
10635
|
const insideField = useInsideField();
|
|
10555
10636
|
const insideControl = useInsideControl();
|
|
10637
|
+
const { controlId, fieldLabelProps } = useAutoLabelId({
|
|
10638
|
+
label,
|
|
10639
|
+
id: baseProps.id,
|
|
10640
|
+
labelProps,
|
|
10641
|
+
// Inline mode renders a bare panel with no input to label.
|
|
10642
|
+
rendersLabel: !insideField && !baseProps.inline,
|
|
10643
|
+
});
|
|
10556
10644
|
const helpClass = usePrefixedClassNames('help', {
|
|
10557
10645
|
[`is-${messageColor}`]: !!messageColor,
|
|
10558
10646
|
});
|
|
10559
10647
|
// The right-side launcher is on by default; suppress it while the Control
|
|
10560
10648
|
// shows its loading spinner (also on the right) unless explicitly set.
|
|
10561
|
-
let content = (jsx(TimeInputBase, { ref: ref, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
|
|
10649
|
+
let content = (jsx(TimeInputBase, { ref: ref, id: controlId, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
|
|
10562
10650
|
// Inline mode renders a bare panel with no input, so the Control's
|
|
10563
10651
|
// icon-left container has nothing to anchor to. Skip the Control wrap.
|
|
10564
10652
|
if (!insideControl && !baseProps.inline) {
|
|
@@ -10566,7 +10654,7 @@ const TimeInput = forwardRef(({ label, labelSize, labelProps, horizontal, iconLe
|
|
|
10566
10654
|
}
|
|
10567
10655
|
const messageEl = message ? jsx("p", { className: helpClass, children: message }) : null;
|
|
10568
10656
|
if (!insideField) {
|
|
10569
|
-
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
10657
|
+
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
|
|
10570
10658
|
}
|
|
10571
10659
|
return (jsxs(Fragment, { children: [content, messageEl] }));
|
|
10572
10660
|
});
|
|
@@ -10842,12 +10930,19 @@ DateTimeInputBase.displayName = 'DateTimeInputBase';
|
|
|
10842
10930
|
const DateTimeInput = forwardRef(({ label, labelSize, labelProps, horizontal, iconLeft, iconRight, iconLeftName = 'calendar-alt', iconRightName, iconLeftSize, iconRightSize, hasIconsLeft, hasIconsRight, isLoading, isExpanded, controlSize, message, messageColor, fieldClassName, controlClassName, ...baseProps }, ref) => {
|
|
10843
10931
|
const insideField = useInsideField();
|
|
10844
10932
|
const insideControl = useInsideControl();
|
|
10933
|
+
const { controlId, fieldLabelProps } = useAutoLabelId({
|
|
10934
|
+
label,
|
|
10935
|
+
id: baseProps.id,
|
|
10936
|
+
labelProps,
|
|
10937
|
+
// Inline mode renders a bare picker with no input to label.
|
|
10938
|
+
rendersLabel: !insideField && !baseProps.inline,
|
|
10939
|
+
});
|
|
10845
10940
|
const helpClass = usePrefixedClassNames('help', {
|
|
10846
10941
|
[`is-${messageColor}`]: !!messageColor,
|
|
10847
10942
|
});
|
|
10848
10943
|
// The right-side launcher is on by default; suppress it while the Control
|
|
10849
10944
|
// shows its loading spinner (also on the right) unless explicitly set.
|
|
10850
|
-
let content = (jsx(DateTimeInputBase, { ref: ref, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
|
|
10945
|
+
let content = (jsx(DateTimeInputBase, { ref: ref, id: controlId, ...baseProps, triggerIcon: baseProps.triggerIcon ?? !isLoading }));
|
|
10851
10946
|
// Inline mode renders a bare picker with no input, so the Control's
|
|
10852
10947
|
// icon-left container has nothing to anchor to. Skip the Control wrap.
|
|
10853
10948
|
if (!insideControl && !baseProps.inline) {
|
|
@@ -10855,7 +10950,7 @@ const DateTimeInput = forwardRef(({ label, labelSize, labelProps, horizontal, ic
|
|
|
10855
10950
|
}
|
|
10856
10951
|
const messageEl = message ? jsx("p", { className: helpClass, children: message }) : null;
|
|
10857
10952
|
if (!insideField) {
|
|
10858
|
-
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
10953
|
+
return (jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [content, messageEl] }));
|
|
10859
10954
|
}
|
|
10860
10955
|
return (jsxs(Fragment, { children: [content, messageEl] }));
|
|
10861
10956
|
});
|